From fbaabca6f1f768c73babeae583605079edd3d86f Mon Sep 17 00:00:00 2001 From: netpoe Date: Tue, 10 Mar 2026 11:29:36 -0600 Subject: [PATCH 01/16] =?UTF-8?q?=E2=9C=A8=20feat:=20update=20.gitignore,?= =?UTF-8?q?=20add=20Prettier=20and=20ESLint=20configurations,=20and=20refa?= =?UTF-8?q?ctor=20Binance=20client=20setup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../use-bun-instead-of-node-vite-npm-pnpm.mdc | 111 ++ .gitignore | 283 +-- .prettierrc | 9 + config.json | 17 - eslint.config.js | 55 + package.json | 38 +- src/binance.ts | 35 +- src/config/binanceClient.ts | 927 +++++---- src/config/binanceUsClient.ts | 875 ++++----- src/config/client.ts | 31 +- src/config/types.ts | 631 +++---- src/index.ts | 144 +- src/init.ts | 258 +-- src/modules/algo/future-algo/TwapNewTrade.ts | 159 +- src/modules/algo/future-algo/VPNewTrade.ts | 151 +- .../algo/future-algo/cancelAlgoOrder.ts | 79 +- .../algo/future-algo/currentAlgoOpenOrders.ts | 75 +- .../algo/future-algo/historicalAlgoOrder.ts | 121 +- src/modules/algo/future-algo/index.ts | 39 +- src/modules/algo/future-algo/subOrders.ts | 105 +- src/modules/algo/index.ts | 15 +- .../algo/spot-algo/cancelOpenTWAPOrder.ts | 79 +- .../algo/spot-algo/currentAlgoOpenOrders.ts | 79 +- .../algo/spot-algo/historicalAlgoOrders.ts | 125 +- src/modules/algo/spot-algo/index.ts | 33 +- src/modules/algo/spot-algo/spotTWAPOrder.ts | 137 +- src/modules/algo/spot-algo/subOrders.ts | 105 +- src/modules/auto-invest/changePlanStatus.ts | 89 +- src/modules/auto-invest/createPlan.ts | 132 +- src/modules/auto-invest/editPlan.ts | 128 +- src/modules/auto-invest/getHistoryList.ts | 158 +- src/modules/auto-invest/getIndexInfo.ts | 119 +- .../getIndexLinkedPlanPositionDetails.ts | 127 +- .../auto-invest/getIndexUserSummary.ts | 99 +- src/modules/auto-invest/getPlanList.ts | 134 +- src/modules/auto-invest/getSourceAssetList.ts | 134 +- src/modules/auto-invest/getTargetAssetList.ts | 129 +- .../auto-invest/getTargetAssetRoiData.ts | 120 +- src/modules/auto-invest/index.ts | 7 +- src/modules/auto-invest/oneTimeTransaction.ts | 119 +- src/modules/auto-invest/rebalanceHistory.ts | 133 +- src/modules/auto-invest/redemption.ts | 83 +- src/modules/c2c/C2C/getAds.ts | 91 +- src/modules/c2c/C2C/getC2CTradeHistory.ts | 87 +- src/modules/c2c/index.ts | 9 +- src/modules/convert/index.ts | 17 +- src/modules/convert/market-data-api/index.ts | 15 +- .../market-data-api/listAllConvertPairs.ts | 79 +- .../queryOrderQuantityPrecisionPerAsset.ts | 89 +- src/modules/convert/trade-api/acceptQuote.ts | 89 +- .../convert/trade-api/cancelLimitOrder.ts | 89 +- .../trade-api/getConvertTradeHistory.ts | 101 +- src/modules/convert/trade-api/index.ts | 45 +- src/modules/convert/trade-api/orderStatus.ts | 83 +- .../convert/trade-api/placeLimitOrder.ts | 146 +- .../convert/trade-api/queryLimitOpenOrders.ts | 89 +- .../convert/trade-api/sendQuoteRequest.ts | 126 +- .../FutureCopyTrading-api/followTrader.ts | 102 +- .../FutureCopyTrading-api/getCopyOrders.ts | 87 +- .../FutureCopyTrading-api/getCopyPositions.ts | 71 +- .../getFollowingTraders.ts | 71 +- .../getFuturesLeadTraderStatus.ts | 79 +- .../getFuturesLeadTradingSymbolWhitelist.ts | 75 +- .../FutureCopyTrading-api/getLeadTraders.ts | 87 +- .../getTraderPerformance.ts | 79 +- .../getTraderPositions.ts | 79 +- .../getTraderSymbolStats.ts | 79 +- .../FutureCopyTrading-api/index.ts | 15 +- .../FutureCopyTrading-api/unfollowTrader.ts | 75 +- src/modules/copy-trading/index.ts | 11 +- .../crypto-loans/flexible/adjustLTV.ts | 89 +- src/modules/crypto-loans/flexible/borrow.ts | 93 +- .../crypto-loans/flexible/getBorrowHistory.ts | 95 +- .../flexible/getFlexibleCollateralAssets.ts | 75 +- .../flexible/getFlexibleLoanAssets.ts | 75 +- .../crypto-loans/flexible/getOngoingOrders.ts | 87 +- .../crypto-loans/flexible/getRepayHistory.ts | 95 +- src/modules/crypto-loans/flexible/index.ts | 35 +- src/modules/crypto-loans/flexible/repay.ts | 93 +- src/modules/crypto-loans/index.ts | 7 +- src/modules/dual-investment/index.ts | 13 +- .../getDualInvestmentProductList.ts | 121 +- .../dual-investment/market-api/index.ts | 7 +- .../trade-api/changeAutoCompoundStatus.ts | 103 +- .../trade-api/checkDualInvestmentAccounts.ts | 89 +- .../trade-api/getDualInvestmentPositions.ts | 139 +- .../dual-investment/trade-api/index.ts | 19 +- .../subscribeDualInvestmentProducts.ts | 109 +- .../fiat-api/getFiatDepositWithdrawHistory.ts | 111 +- .../fiat/fiat-api/getFiatPaymentsHistory.ts | 109 +- src/modules/fiat/index.ts | 13 +- src/modules/futures-coinm/index.ts | 7 +- src/modules/futures-usdm/index.ts | 7 +- src/modules/gift-card/index.ts | 7 +- src/modules/margin/index.ts | 7 +- src/modules/mining/index.ts | 57 +- src/modules/mining/mining-api/accountList.ts | 87 +- .../mining/mining-api/acquiringAlgorithm.ts | 68 +- .../mining/mining-api/acquiringCoinname.ts | 64 +- .../cancelHashrateResaleConfiguration.ts | 87 +- src/modules/mining/mining-api/earningsList.ts | 126 +- .../mining/mining-api/extraBonusList.ts | 116 +- .../mining/mining-api/hashrateResaleDetail.ts | 111 +- .../mining/mining-api/hashrateResaleList.ts | 109 +- .../mining-api/hashrateResaleRequest.ts | 113 +- .../mining/mining-api/miningAccountEarning.ts | 111 +- .../mining-api/requestForDetailMinerList.ts | 91 +- .../mining/mining-api/requestForMinerList.ts | 153 +- .../mining/mining-api/statisticList.ts | 91 +- src/modules/nft/index.ts | 21 +- src/modules/nft/nft-api/getNFTAsset.ts | 97 +- .../nft/nft-api/getNFTDepositHistory.ts | 105 +- .../nft/nft-api/getNFTTransactionHistory.ts | 113 +- .../nft/nft-api/getNFTWithdrawHistory.ts | 105 +- src/modules/options/account-api/getAccount.ts | 113 +- .../options/account-api/getBillHistory.ts | 139 +- .../options/account-api/getIncomeAsyn.ts | 83 +- .../options/account-api/getIncomeAsynId.ts | 101 +- .../options/account-api/getPosition.ts | 119 +- src/modules/options/account-api/index.ts | 23 +- src/modules/options/index.ts | 7 +- src/modules/options/market-api/depth.ts | 128 +- .../options/market-api/exchangeInfo.ts | 106 +- .../options/market-api/exerciseHistory.ts | 129 +- .../options/market-api/historicalTrades.ts | 125 +- src/modules/options/market-api/index.ts | 47 +- src/modules/options/market-api/indexPrice.ts | 111 +- src/modules/options/market-api/klines.ts | 141 +- src/modules/options/market-api/mark.ts | 129 +- src/modules/options/market-api/ping.ts | 62 +- src/modules/options/market-api/ticker.ts | 132 +- src/modules/options/market-api/time.ts | 66 +- src/modules/options/market-api/trades.ts | 116 +- src/modules/options/trade-api/batchOrders.ts | 137 +- .../options/trade-api/cancelAllOrders.ts | 79 +- .../options/trade-api/cancelBatchOrders.ts | 145 +- .../options/trade-api/cancelBySymbol.ts | 79 +- src/modules/options/trade-api/cancelOrder.ts | 109 +- .../options/trade-api/getHistoryOrders.ts | 141 +- .../options/trade-api/getOpenOrders.ts | 117 +- .../options/trade-api/getUserTrades.ts | 147 +- src/modules/options/trade-api/index.ts | 39 +- src/modules/options/trade-api/newOrder.ts | 119 +- .../options/userdata-api/createListenKey.ts | 62 +- .../options/userdata-api/deleteListenKey.ts | 76 +- src/modules/options/userdata-api/index.ts | 15 +- .../options/userdata-api/renewListenKey.ts | 76 +- src/modules/pay/index.ts | 9 +- src/modules/pay/pay-api/createOrder.ts | 99 +- src/modules/pay/pay-api/getHistory.ts | 89 +- src/modules/pay/pay-api/getPayTradeHistory.ts | 97 +- src/modules/pay/pay-api/queryOrder.ts | 83 +- .../account/getAccountInfo.ts | 105 +- .../portfolio-margin/account/getBalance.ts | 116 +- .../portfolio-margin/account/getCmAccount.ts | 125 +- .../portfolio-margin/account/getCmPosition.ts | 131 +- .../account/getMarginAccount.ts | 132 +- .../account/getMaxBorrowable.ts | 79 +- .../account/getMaxWithdraw.ts | 79 +- .../portfolio-margin/account/getUmAccount.ts | 117 +- .../portfolio-margin/account/getUmPosition.ts | 127 +- src/modules/portfolio-margin/account/index.ts | 39 +- .../cm-trade/cancelAllOrders.ts | 79 +- .../portfolio-margin/cm-trade/cancelOrder.ts | 109 +- .../cm-trade/changeLeverage.ts | 83 +- .../cm-trade/changeMarginType.ts | 83 +- .../portfolio-margin/cm-trade/getAllOrders.ts | 141 +- .../cm-trade/getOpenOrders.ts | 115 +- .../portfolio-margin/cm-trade/getOrder.ts | 129 +- .../cm-trade/getUserTrades.ts | 147 +- .../portfolio-margin/cm-trade/index.ts | 39 +- .../portfolio-margin/cm-trade/newOrder.ts | 129 +- src/modules/portfolio-margin/index.ts | 7 +- .../margin-trade/cancelAllOrders.ts | 79 +- .../margin-trade/cancelOrder.ts | 109 +- .../margin-trade/getAllOrders.ts | 135 +- .../margin-trade/getOpenOrders.ts | 111 +- .../portfolio-margin/margin-trade/getOrder.ts | 127 +- .../margin-trade/getUserTrades.ts | 141 +- .../portfolio-margin/margin-trade/index.ts | 39 +- .../margin-trade/marginLoan.ts | 83 +- .../margin-trade/marginRepay.ts | 83 +- .../portfolio-margin/margin-trade/newOrder.ts | 130 +- .../um-trade/cancelAllOrders.ts | 79 +- .../portfolio-margin/um-trade/cancelOrder.ts | 109 +- .../um-trade/changeLeverage.ts | 83 +- .../um-trade/changeMarginType.ts | 83 +- .../portfolio-margin/um-trade/getAllOrders.ts | 135 +- .../um-trade/getOpenOrders.ts | 111 +- .../portfolio-margin/um-trade/getOrder.ts | 129 +- .../um-trade/getUserTrades.ts | 141 +- .../portfolio-margin/um-trade/index.ts | 39 +- .../portfolio-margin/um-trade/newOrder.ts | 129 +- .../userdata/createListenKey.ts | 62 +- .../userdata/deleteListenKey.ts | 73 +- .../portfolio-margin/userdata/index.ts | 15 +- .../userdata/renewListenKey.ts | 73 +- src/modules/rebate/index.ts | 9 +- .../rebate-api/getSpotRebateHistoryRecords.ts | 91 +- .../account-api/getFlexibleProductPosition.ts | 114 +- src/modules/simple-earn/account-api/index.ts | 15 +- .../simpleEarnFlexibleProductList.ts | 110 +- src/modules/simple-earn/account/getAccount.ts | 71 +- .../account/getCollateralRecord.ts | 95 +- .../simple-earn/account/getRewardRecord.ts | 99 +- src/modules/simple-earn/account/index.ts | 15 +- src/modules/simple-earn/earn-api/index.ts | 15 +- .../earn-api/redeemFlexibleProduct.ts | 131 +- .../earn-api/subscribeFlexibleProduct.ts | 101 +- .../flexible/getFlexiblePosition.ts | 87 +- .../flexible/getFlexibleProductList.ts | 89 +- .../getFlexibleSubscriptionPreview.ts | 79 +- .../simple-earn/flexible/getRateHistory.ts | 91 +- .../flexible/getRedemptionRecord.ts | 99 +- .../flexible/getSubscriptionRecord.ts | 99 +- src/modules/simple-earn/flexible/index.ts | 35 +- .../simple-earn/flexible/redeemFlexible.ts | 94 +- .../simple-earn/flexible/subscribeFlexible.ts | 94 +- src/modules/simple-earn/index.ts | 17 +- .../locked/getLockedPersonalQuota.ts | 75 +- .../simple-earn/locked/getLockedPosition.ts | 91 +- .../locked/getLockedProductList.ts | 89 +- .../locked/getLockedSubscriptionPreview.ts | 83 +- .../simple-earn/locked/getRedemptionRecord.ts | 99 +- .../locked/getSubscriptionRecord.ts | 95 +- src/modules/simple-earn/locked/index.ts | 39 +- .../simple-earn/locked/redeemLocked.ts | 75 +- .../simple-earn/locked/setAutoSubscribe.ts | 79 +- .../simple-earn/locked/subscribeLocked.ts | 91 +- .../spot/account-api/accountCommission.ts | 72 +- src/modules/spot/account-api/getAccount.ts | 70 +- src/modules/spot/account-api/index.ts | 27 +- src/modules/spot/account-api/myAllocations.ts | 94 +- .../spot/account-api/myPreventedMatches.ts | 95 +- src/modules/spot/account-api/myTrades.ts | 98 +- .../spot/account-api/rateLimitOrder.ts | 70 +- src/modules/spot/general-api/exchangeInfo.ts | 91 +- src/modules/spot/general-api/index.ts | 16 +- src/modules/spot/general-api/ping.ts | 53 +- src/modules/spot/general-api/time.ts | 57 +- src/modules/spot/index.ts | 44 +- src/modules/spot/market-api/aggTrades.ts | 92 +- src/modules/spot/market-api/avgPrice.ts | 68 +- src/modules/spot/market-api/depth.ts | 72 +- src/modules/spot/market-api/getTrades.ts | 79 +- .../spot/market-api/historicalTrades.ts | 85 +- src/modules/spot/market-api/index.ts | 54 +- src/modules/spot/market-api/klines.ts | 115 +- src/modules/spot/market-api/ticker.ts | 95 +- src/modules/spot/market-api/ticker24hr.ts | 86 +- .../spot/market-api/tickerBookTicker.ts | 86 +- src/modules/spot/market-api/tickerPrice.ts | 86 +- .../spot/market-api/tickerTradingDay.ts | 88 +- src/modules/spot/market-api/uiKlines.ts | 115 +- src/modules/spot/trade-api/allOrders.ts | 94 +- .../spot/trade-api/deleteOpenOrders.ts | 69 +- src/modules/spot/trade-api/deleteOrder.ts | 83 +- src/modules/spot/trade-api/getOpenOrders.ts | 71 +- src/modules/spot/trade-api/getOrder.ts | 85 +- src/modules/spot/trade-api/index.ts | 38 +- src/modules/spot/trade-api/newOrder.ts | 141 +- src/modules/spot/trade-api/openOrderList.ts | 71 +- src/modules/spot/trade-api/orderOco.ts | 134 +- .../deleteUserDataStream.ts | 67 +- src/modules/spot/userdatastream-api/index.ts | 16 +- .../userdatastream-api/newUserDataStream.ts | 57 +- .../userdatastream-api/putUserDataStream.ts | 69 +- .../ETH-staking-api/ethStakingAccount.ts | 79 +- .../getCurrentEthStakingQuota.ts | 79 +- .../getEthRedemptionHistory.ts | 129 +- .../ETH-staking-api/getEthStakingHistory.ts | 129 +- .../ETH-staking-api/getWbethRateHistory.ts | 125 +- .../ETH-staking-api/getWbethRewardsHistory.ts | 129 +- .../ETH-staking-api/getWbethUnwrapHistory.ts | 125 +- .../ETH-staking-api/getWbethWrapHistory.ts | 121 +- src/modules/staking/ETH-staking-api/index.ts | 47 +- .../staking/ETH-staking-api/redeemEth.ts | 87 +- .../ETH-staking-api/subscribeEthStaking.ts | 79 +- .../staking/ETH-staking-api/wrapBeth.ts | 79 +- .../SOL-staking-api/claimBoostRewards.ts | 79 +- .../SOL-staking-api/getBnsolRateHistory.ts | 121 +- .../SOL-staking-api/getBnsolRewardsHistory.ts | 131 +- .../SOL-staking-api/getBoostRewardsHistory.ts | 131 +- .../getSolRedemptionHistory.ts | 117 +- .../SOL-staking-api/getSolStakingHistory.ts | 117 +- .../getSolStakingQuotaDetails.ts | 75 +- .../SOL-staking-api/getUnclaimedRewards.ts | 79 +- src/modules/staking/SOL-staking-api/index.ts | 47 +- .../staking/SOL-staking-api/redeemSol.ts | 87 +- .../SOL-staking-api/solStakingAccount.ts | 75 +- .../SOL-staking-api/subscribeSolStaking.ts | 79 +- src/modules/staking/index.ts | 13 +- src/modules/sub-account/index.ts | 7 +- src/modules/vip-loan/index.ts | 17 +- .../market-api/getBorrowInterestRate.ts | 83 +- .../market-api/getCollateralAssetData.ts | 83 +- .../market-api/getLoanableAssetsData.ts | 91 +- src/modules/vip-loan/market-api/index.ts | 15 +- src/modules/vip-loan/trade-api/index.ts | 15 +- .../vip-loan/trade-api/vipLoanBorrow.ts | 114 +- .../vip-loan/trade-api/vipLoanRenew.ts | 89 +- .../vip-loan/trade-api/vipLoanRepay.ts | 83 +- .../checkVIPLoanCollateralAccount.ts | 91 +- .../getVIPLoanOngoingOrders.ts | 119 +- .../vip-loan/userInformation-api/index.ts | 15 +- .../queryApplicationStatus.ts | 99 +- .../account-api/accountApiTradingStatus.ts | 76 +- src/modules/wallet/account-api/accountInfo.ts | 76 +- .../wallet/account-api/accountStatus.ts | 73 +- .../account-api/dailyAccountSnapshot.ts | 87 +- .../account-api/disableFastWithdrawSwitch.ts | 73 +- .../account-api/enableFastWithdrawSwitch.ts | 73 +- .../wallet/account-api/getApiKeyPermission.ts | 73 +- src/modules/wallet/account-api/index.ts | 34 +- src/modules/wallet/asset-api/assetDetail.ts | 75 +- .../wallet/asset-api/assetDividendRecord.ts | 89 +- src/modules/wallet/asset-api/dustTransfer.ts | 74 +- src/modules/wallet/asset-api/dustlog.ts | 79 +- src/modules/wallet/asset-api/fundingWallet.ts | 81 +- .../getAssetsThatCanBeConvertedIntoBnb.ts | 73 +- .../getCloudMiningPaymentAndRefundHistory.ts | 91 +- .../wallet/asset-api/getOpenSymbolList.ts | 56 +- src/modules/wallet/asset-api/index.ts | 65 +- .../asset-api/queryUserDelegationHistory.ts | 95 +- .../queryUserUniversalTransferHistory.ts | 102 +- .../asset-api/queryUserWalletBalance.ts | 73 +- ...ggleBnbBurnOnSpotTradeAndMarginInterest.ts | 80 +- src/modules/wallet/asset-api/tradeFee.ts | 77 +- src/modules/wallet/asset-api/userAsset.ts | 75 +- .../wallet/asset-api/userUniversalTransfer.ts | 96 +- .../wallet/capital-api/allCoinsInformation.ts | 71 +- .../wallet/capital-api/depositAddress.ts | 77 +- .../wallet/capital-api/depositHistory.ts | 93 +- .../fetchDepositAddressListWithNetwork.ts | 79 +- .../capital-api/fetchWithdrawAddressList.ts | 63 +- src/modules/wallet/capital-api/index.ts | 37 +- .../oneClickArrivalDepositApply.ts | 80 +- src/modules/wallet/capital-api/withdraw.ts | 120 +- .../wallet/capital-api/withdrawHistory.ts | 99 +- src/modules/wallet/index.ts | 43 +- .../getSymbolsDelistScheduleForSpot.ts | 58 +- src/modules/wallet/others-api/index.ts | 14 +- src/modules/wallet/others-api/systemStatus.ts | 55 +- .../wallet/travel-rule-api/brokerWithdraw.ts | 132 +- .../depositHistoryTravelRule.ts | 95 +- src/modules/wallet/travel-rule-api/index.ts | 38 +- .../travel-rule-api/onboardedVaspList.ts | 61 +- .../submitDepositQuestionnaire.ts | 95 +- .../submitDepositQuestionnaireTravelRule.ts | 83 +- .../travel-rule-api/withdrawHistoryV1.ts | 95 +- .../travel-rule-api/withdrawHistoryV2.ts | 95 +- .../travel-rule-api/withdrawTravelRule.ts | 120 +- src/server/base.ts | 4 +- src/server/sse.ts | 24 +- src/server/stdio.ts | 10 +- src/tools/account/index.ts | 419 +++-- .../binance-algo/future-algo/TwapNewTrade.ts | 159 +- .../binance-algo/future-algo/VPNewTrade.ts | 151 +- .../future-algo/cancelAlgoOrder.ts | 79 +- .../future-algo/currentAlgoOpenOrders.ts | 75 +- .../future-algo/historicalAlgoOrder.ts | 121 +- src/tools/binance-algo/future-algo/index.ts | 39 +- .../binance-algo/future-algo/subOrders.ts | 105 +- src/tools/binance-algo/index.ts | 13 +- .../spot-algo/cancelOpenTWAPOrder.ts | 79 +- .../spot-algo/currentAlgoOpenOrders.ts | 79 +- .../spot-algo/historicalAlgoOrders.ts | 125 +- src/tools/binance-algo/spot-algo/index.ts | 33 +- .../binance-algo/spot-algo/spotTWAPOrder.ts | 137 +- src/tools/binance-algo/spot-algo/subOrders.ts | 105 +- .../changeIndexPlanStatus.ts | 72 +- .../binance-auto-invest/changePlanStatus.ts | 70 +- src/tools/binance-auto-invest/createPlan.ts | 116 +- src/tools/binance-auto-invest/editPlan.ts | 109 +- .../binance-auto-invest/getHistoryList.ts | 98 +- src/tools/binance-auto-invest/getIndexInfo.ts | 68 +- .../getIndexLinkedPlanPositionDetails.ts | 68 +- .../getIndexLinkedPlanPositionList.ts | 73 +- .../getIndexLinkedPlanRebalanceHistory.ts | 89 +- .../getIndexUserSummary.ts | 68 +- .../binance-auto-invest/getOneTimePlans.ts | 72 +- src/tools/binance-auto-invest/getPlanList.ts | 70 +- .../binance-auto-invest/getSourceAssetList.ts | 85 +- .../getSubscriptionHistory.ts | 94 +- .../binance-auto-invest/getTargetAssetList.ts | 78 +- .../binance-auto-invest/getTargetAssetROI.ts | 72 +- .../getTargetAssetRoiData.ts | 74 +- src/tools/binance-auto-invest/index.ts | 50 +- .../binance-auto-invest/oneTimeTransaction.ts | 116 +- .../binance-auto-invest/rebalanceHistory.ts | 83 +- .../redeemIndexLinkedPlan.ts | 74 +- src/tools/binance-auto-invest/redemption.ts | 87 +- .../binance-c2c/C2C/getC2CTradeHistory.ts | 87 +- src/tools/binance-c2c/index.ts | 7 +- src/tools/binance-convert/index.ts | 15 +- .../binance-convert/market-data-api/index.ts | 15 +- .../market-data-api/listAllConvertPairs.ts | 79 +- .../queryOrderQuantityPrecisionPerAsset.ts | 89 +- .../binance-convert/trade-api/acceptQuote.ts | 89 +- .../trade-api/cancelLimitOrder.ts | 89 +- .../trade-api/getConvertTradeHistory.ts | 101 +- src/tools/binance-convert/trade-api/index.ts | 45 +- .../binance-convert/trade-api/orderStatus.ts | 83 +- .../trade-api/placeLimitOrder.ts | 146 +- .../trade-api/queryLimitOpenOrders.ts | 89 +- .../trade-api/sendQuoteRequest.ts | 126 +- .../FutureCopyTrading-api/followTrader.ts | 103 +- .../FutureCopyTrading-api/getCopyOrders.ts | 94 +- .../FutureCopyTrading-api/getCopyPositions.ts | 74 +- .../getFollowingTraders.ts | 64 +- .../getFuturesLeadTraderStatus.ts | 79 +- .../getFuturesLeadTradingSymbolWhitelist.ts | 75 +- .../FutureCopyTrading-api/getLeadTraders.ts | 74 +- .../getTraderPerformance.ts | 69 +- .../FutureCopyTrading-api/index.ts | 15 +- .../FutureCopyTrading-api/unfollowTrader.ts | 69 +- src/tools/binance-copy-trading/index.ts | 9 +- .../fixed-api/adjustLTV.ts | 84 +- .../binance-crypto-loans/fixed-api/borrow.ts | 109 +- .../fixed-api/checkCollateralRate.ts | 79 +- .../fixed-api/customizeMarginCall.ts | 74 +- .../fixed-api/getBorrowHistory.ts | 99 +- .../fixed-api/getFixedCollateralData.ts | 74 +- .../fixed-api/getFixedLoanData.ts | 80 +- .../fixed-api/getOngoingOrders.ts | 89 +- .../fixed-api/getRepayHistory.ts | 99 +- .../binance-crypto-loans/fixed-api/index.ts | 43 +- .../binance-crypto-loans/fixed-api/repay.ts | 92 +- .../flexible-api/adjustLTV.ts | 91 +- .../flexible-api/borrow.ts | 106 +- .../flexible-api/getBorrowHistory.ts | 94 +- .../getFlexibleCollateralAssets.ts | 72 +- .../flexible-api/getFlexibleLoanAssets.ts | 72 +- .../flexible-api/getOngoingOrders.ts | 84 +- .../flexible-api/getRepayHistory.ts | 94 +- .../flexible-api/index.ts | 35 +- .../flexible-api/repay.ts | 94 +- .../flexibleLoanAdjustLTV.ts | 76 +- .../flexibleLoanBorrow.ts | 78 +- .../flexibleLoanBorrowHistory.ts | 92 +- .../flexibleLoanCollateralAssets.ts | 75 +- .../flexibleLoanLTVAdjustmentHistory.ts | 95 +- .../flexibleLoanLoanableAssets.ts | 64 +- .../flexibleLoanOngoingOrders.ts | 84 +- .../binance-crypto-loans/flexibleLoanRepay.ts | 80 +- .../flexibleLoanRepayHistory.ts | 92 +- .../getCollateralAssetsData.ts | 76 +- .../getCollateralRepayRate.ts | 72 +- .../getLoanableAssetsData.ts | 76 +- src/tools/binance-crypto-loans/index.ts | 64 +- src/tools/binance-dual-investment/index.ts | 11 +- .../getDualInvestmentProductList.ts | 121 +- .../market-api/index.ts | 7 +- .../trade-api/changeAutoCompoundStatus.ts | 103 +- .../trade-api/checkDualInvestmentAccounts.ts | 89 +- .../trade-api/getDualInvestmentPositions.ts | 139 +- .../trade-api/index.ts | 19 +- .../subscribeDualInvestmentProducts.ts | 109 +- .../fiat-api/getFiatDepositWithdrawHistory.ts | 111 +- .../fiat-api/getFiatPaymentsHistory.ts | 109 +- src/tools/binance-fiat/index.ts | 11 +- .../account-api/account.ts | 67 +- .../account-api/adlQuantile.ts | 71 +- .../account-api/balance.ts | 67 +- .../account-api/commissionRate.ts | 71 +- .../account-api/forceOrders.ts | 87 +- .../account-api/income.ts | 106 +- .../account-api/index.ts | 57 +- .../account-api/leverageBracket.ts | 71 +- .../account-api/positionMode.ts | 69 +- .../account-api/positionRisk.ts | 75 +- .../account-api/userTrades.ts | 91 +- src/tools/binance-futures-coinm/account.ts | 55 +- .../binance-futures-coinm/adlQuantile.ts | 76 +- src/tools/binance-futures-coinm/aggTrades.ts | 91 +- src/tools/binance-futures-coinm/allOrders.ts | 89 +- src/tools/binance-futures-coinm/balance.ts | 55 +- .../binance-futures-coinm/batchOrders.ts | 68 +- src/tools/binance-futures-coinm/bookTicker.ts | 80 +- .../binance-futures-coinm/cancelAllOrders.ts | 59 +- .../cancelBatchOrders.ts | 77 +- .../binance-futures-coinm/cancelOrder.ts | 67 +- .../binance-futures-coinm/commissionRate.ts | 67 +- .../binance-futures-coinm/continuousKlines.ts | 107 +- src/tools/binance-futures-coinm/depth.ts | 78 +- .../binance-futures-coinm/exchangeInfo.ts | 58 +- .../binance-futures-coinm/forceOrders.ts | 90 +- .../binance-futures-coinm/fundingRate.ts | 83 +- src/tools/binance-futures-coinm/getOrder.ts | 67 +- .../binance-futures-coinm/historicalTrades.ts | 80 +- src/tools/binance-futures-coinm/income.ts | 99 +- src/tools/binance-futures-coinm/index.ts | 172 +- .../binance-futures-coinm/indexPriceKlines.ts | 103 +- src/tools/binance-futures-coinm/klines.ts | 100 +- src/tools/binance-futures-coinm/leverage.ts | 63 +- src/tools/binance-futures-coinm/listenKey.ts | 161 +- src/tools/binance-futures-coinm/marginType.ts | 67 +- .../binance-futures-coinm/markPriceKlines.ts | 103 +- .../market-api/aggTrades.ts | 83 +- .../market-api/bookTicker.ts | 74 +- .../market-api/continuousKlines.ts | 111 +- .../binance-futures-coinm/market-api/depth.ts | 75 +- .../market-api/exchangeInfo.ts | 58 +- .../market-api/fundingRate.ts | 79 +- .../market-api/historicalTrades.ts | 75 +- .../binance-futures-coinm/market-api/index.ts | 97 +- .../market-api/indexPriceKlines.ts | 105 +- .../market-api/klines.ts | 105 +- .../market-api/markPriceKlines.ts | 105 +- .../market-api/openInterest.ts | 67 +- .../market-api/openInterestHist.ts | 93 +- .../binance-futures-coinm/market-api/ping.ts | 54 +- .../market-api/premiumIndex.ts | 70 +- .../market-api/ticker24hr.ts | 74 +- .../market-api/tickerPrice.ts | 74 +- .../binance-futures-coinm/market-api/time.ts | 54 +- .../market-api/trades.ts | 71 +- src/tools/binance-futures-coinm/newOrder.ts | 108 +- .../binance-futures-coinm/openInterest.ts | 67 +- src/tools/binance-futures-coinm/openOrders.ts | 63 +- src/tools/binance-futures-coinm/ping.ts | 56 +- .../binance-futures-coinm/positionMargin.ts | 81 +- .../binance-futures-coinm/positionMode.ts | 69 +- .../binance-futures-coinm/positionRisk.ts | 63 +- .../binance-futures-coinm/premiumIndex.ts | 76 +- src/tools/binance-futures-coinm/ticker24hr.ts | 80 +- .../binance-futures-coinm/tickerPrice.ts | 80 +- src/tools/binance-futures-coinm/time.ts | 58 +- .../trade-api/allOrders.ts | 91 +- .../trade-api/batchOrders.ts | 79 +- .../trade-api/cancelAllOrders.ts | 71 +- .../trade-api/cancelBatchOrders.ts | 100 +- .../trade-api/cancelOrder.ts | 95 +- .../trade-api/changeLeverage.ts | 75 +- .../trade-api/changeMarginType.ts | 75 +- .../trade-api/changePositionMode.ts | 73 +- .../trade-api/countdownCancelAll.ts | 80 +- .../trade-api/getAllOrders.ts | 99 +- .../trade-api/getOrder.ts | 95 +- .../binance-futures-coinm/trade-api/index.ts | 77 +- .../trade-api/modifyIsolatedPositionMargin.ts | 88 +- .../trade-api/newOrder.ts | 235 +-- .../trade-api/openOrder.ts | 95 +- .../trade-api/openOrders.ts | 75 +- src/tools/binance-futures-coinm/trades.ts | 73 +- src/tools/binance-futures-coinm/userTrades.ts | 96 +- .../userdatastream-api/closeListenKey.ts | 71 +- .../userdatastream-api/createListenKey.ts | 67 +- .../userdatastream-api/index.ts | 17 +- .../userdatastream-api/keepAliveListenKey.ts | 71 +- .../account-api/account.ts | 64 +- .../account-api/adlQuantile.ts | 68 +- .../account-api/apiTradingStatus.ts | 68 +- .../account-api/balance.ts | 64 +- .../account-api/commissionRate.ts | 68 +- .../account-api/downloadId.ts | 72 +- .../account-api/forceOrders.ts | 84 +- .../account-api/income.ts | 113 +- .../binance-futures-usdm/account-api/index.ts | 85 +- .../account-api/leverage.ts | 77 +- .../account-api/leverageBracket.ts | 68 +- .../account-api/marginType.ts | 72 +- .../account-api/multiAssetsMode.ts | 64 +- .../account-api/positionMargin.ts | 167 +- .../account-api/positionMode.ts | 64 +- .../account-api/positionRisk.ts | 68 +- .../account-api/userTrades.ts | 88 +- src/tools/binance-futures-usdm/account.ts | 56 +- src/tools/binance-futures-usdm/adlQuantile.ts | 75 +- src/tools/binance-futures-usdm/aggTrades.ts | 90 +- src/tools/binance-futures-usdm/allOrders.ts | 81 +- src/tools/binance-futures-usdm/balance.ts | 56 +- src/tools/binance-futures-usdm/batchOrders.ts | 67 +- src/tools/binance-futures-usdm/bookTicker.ts | 72 +- .../binance-futures-usdm/cancelAllOrders.ts | 63 +- .../binance-futures-usdm/cancelBatchOrders.ts | 76 +- src/tools/binance-futures-usdm/cancelOrder.ts | 73 +- .../binance-futures-usdm/commissionRate.ts | 66 +- .../binance-futures-usdm/continuousKlines.ts | 106 +- src/tools/binance-futures-usdm/depth.ts | 77 +- .../binance-futures-usdm/exchangeInfo.ts | 57 +- src/tools/binance-futures-usdm/forceOrders.ts | 89 +- src/tools/binance-futures-usdm/fundingRate.ts | 82 +- src/tools/binance-futures-usdm/getOrder.ts | 73 +- .../binance-futures-usdm/historicalTrades.ts | 79 +- src/tools/binance-futures-usdm/income.ts | 106 +- src/tools/binance-futures-usdm/index.ts | 176 +- .../binance-futures-usdm/indexPriceKlines.ts | 102 +- src/tools/binance-futures-usdm/klines.ts | 100 +- src/tools/binance-futures-usdm/leverage.ts | 66 +- src/tools/binance-futures-usdm/listenKey.ts | 162 +- src/tools/binance-futures-usdm/marginType.ts | 66 +- .../binance-futures-usdm/markPriceKlines.ts | 103 +- .../market-api/aggTrades.ts | 80 +- .../market-api/assetIndex.ts | 64 +- .../market-api/continuousKlines.ts | 109 +- .../binance-futures-usdm/market-api/depth.ts | 72 +- .../market-api/exchangeInfo.ts | 53 +- .../market-api/fundingInfo.ts | 53 +- .../market-api/fundingRate.ts | 76 +- .../market-api/globalLongShortAccountRatio.ts | 92 +- .../market-api/historicalTrades.ts | 72 +- .../binance-futures-usdm/market-api/index.ts | 133 +- .../market-api/indexInfo.ts | 64 +- .../market-api/indexPriceKlines.ts | 102 +- .../binance-futures-usdm/market-api/klines.ts | 102 +- .../market-api/lvtKlines.ts | 107 +- .../market-api/markPriceKlines.ts | 102 +- .../market-api/openInterest.ts | 64 +- .../market-api/openInterestHist.ts | 87 +- .../binance-futures-usdm/market-api/ping.ts | 53 +- .../market-api/premiumIndex.ts | 67 +- .../market-api/takerLongShortRatio.ts | 89 +- .../market-api/ticker24hr.ts | 64 +- .../market-api/tickerBookTicker.ts | 67 +- .../market-api/tickerPrice.ts | 64 +- .../binance-futures-usdm/market-api/time.ts | 50 +- .../market-api/topLongShortAccountRatio.ts | 89 +- .../market-api/topLongShortPositionRatio.ts | 89 +- .../binance-futures-usdm/market-api/trades.ts | 72 +- .../binance-futures-usdm/multiAssetsMode.ts | 71 +- src/tools/binance-futures-usdm/newOrder.ts | 156 +- .../binance-futures-usdm/openInterest.ts | 67 +- src/tools/binance-futures-usdm/openOrders.ts | 73 +- src/tools/binance-futures-usdm/ping.ts | 56 +- .../binance-futures-usdm/positionMargin.ts | 80 +- .../binance-futures-usdm/positionMode.ts | 66 +- .../binance-futures-usdm/positionRisk.ts | 76 +- .../binance-futures-usdm/premiumIndex.ts | 76 +- src/tools/binance-futures-usdm/ticker24hr.ts | 73 +- src/tools/binance-futures-usdm/tickerPrice.ts | 76 +- src/tools/binance-futures-usdm/time.ts | 58 +- .../trade-api/allOrders.ts | 90 +- .../trade-api/batchOrders.ts | 141 +- .../trade-api/cancelAllOpenOrders.ts | 69 +- .../trade-api/cancelAllOrders.ts | 71 +- .../trade-api/cancelBatchOrders.ts | 130 +- .../trade-api/cancelOrder.ts | 95 +- .../trade-api/changeLeverage.ts | 80 +- .../trade-api/changeMarginType.ts | 79 +- .../trade-api/changeMultiAssetsMode.ts | 75 +- .../trade-api/changePositionMode.ts | 75 +- .../trade-api/countdownCancelAll.ts | 87 +- .../trade-api/getAllOrders.ts | 96 +- .../trade-api/getOpenOrder.ts | 95 +- .../trade-api/getOpenOrders.ts | 92 +- .../trade-api/getOrder.ts | 95 +- .../binance-futures-usdm/trade-api/index.ts | 89 +- .../trade-api/modifyIsolatedPositionMargin.ts | 90 +- .../trade-api/modifyOrder.ts | 123 +- .../trade-api/newOrder.ts | 172 +- .../trade-api/openOrder.ts | 104 +- .../trade-api/openOrders.ts | 76 +- .../trade-api/positionMarginHistory.ts | 89 +- src/tools/binance-futures-usdm/trades.ts | 73 +- src/tools/binance-futures-usdm/userTrades.ts | 86 +- .../userdatastream-api/closeListenKey.ts | 74 +- .../userdatastream-api/createListenKey.ts | 67 +- .../userdatastream-api/index.ts | 17 +- .../userdatastream-api/keepAliveListenKey.ts | 74 +- src/tools/binance-gift-card/buyCode.ts | 73 +- src/tools/binance-gift-card/createCode.ts | 71 +- .../binance-gift-card/createDualTokenCode.ts | 81 +- .../createDualTokenGiftCard.ts | 85 +- src/tools/binance-gift-card/createGiftCard.ts | 75 +- src/tools/binance-gift-card/getTokenLimit.ts | 69 +- src/tools/binance-gift-card/index.ts | 41 +- src/tools/binance-gift-card/redeemCode.ts | 73 +- .../redeemDualTokenGiftCard.ts | 77 +- src/tools/binance-gift-card/redeemGiftCard.ts | 75 +- src/tools/binance-gift-card/rsaPublicKey.ts | 67 +- src/tools/binance-gift-card/tokenLimit.ts | 71 +- src/tools/binance-gift-card/verify.ts | 69 +- src/tools/binance-gift-card/verifyGiftCard.ts | 79 +- .../cross-margin-api/crossMarginAccount.ts | 61 +- .../cross-margin-api/crossMarginAllAssets.ts | 86 +- .../cross-margin-api/crossMarginAllOrders.ts | 85 +- .../crossMarginAvailableInventory.ts | 67 +- .../cross-margin-api/crossMarginBorrow.ts | 80 +- .../crossMarginCancelAllOrders.ts | 65 +- .../crossMarginCancelOrder.ts | 80 +- .../crossMarginCapitalFlow.ts | 104 +- .../cross-margin-api/crossMarginDelist.ts | 61 +- .../cross-margin-api/crossMarginDustLog.ts | 69 +- .../cross-margin-api/crossMarginFee.ts | 73 +- .../crossMarginForceLiquidationRec.ts | 81 +- .../crossMarginInterestHistory.ts | 89 +- .../crossMarginInterestRateHistory.ts | 83 +- .../cross-margin-api/crossMarginLoanRecord.ts | 93 +- .../crossMarginMaxBorrowable.ts | 69 +- .../crossMarginMaxTransferable.ts | 69 +- .../cross-margin-api/crossMarginMyTrades.ts | 89 +- .../cross-margin-api/crossMarginNewOrder.ts | 140 +- .../cross-margin-api/crossMarginOpenOrders.ts | 69 +- .../cross-margin-api/crossMarginPairs.ts | 61 +- .../cross-margin-api/crossMarginPriceIndex.ts | 61 +- .../cross-margin-api/crossMarginRepay.ts | 80 +- .../crossMarginRepayRecord.ts | 93 +- .../crossMarginSmallLiabilityExchange.ts | 67 +- ...rossMarginSmallLiabilityExchangeHistory.ts | 77 +- .../cross-margin-api/crossMarginTransfer.ts | 73 +- .../binance-margin/cross-margin-api/index.ts | 129 +- src/tools/binance-margin/index.ts | 17 +- .../disableIsolatedMarginAccount.ts | 68 +- .../enableIsolatedMarginAccount.ts | 68 +- .../isolated-margin-api/getBnbBurnStatus.ts | 61 +- .../isolated-margin-api/index.ts | 77 +- .../isolatedMarginAccount.ts | 68 +- .../isolatedMarginAccountLimit.ts | 61 +- .../isolatedMarginAllOrders.ts | 83 +- .../isolatedMarginAllPairs.ts | 61 +- .../isolatedMarginAllSymbols.ts | 64 +- .../isolatedMarginBorrow.ts | 80 +- .../isolatedMarginCancelOrder.ts | 84 +- .../isolated-margin-api/isolatedMarginFee.ts | 73 +- .../isolatedMarginMyTrades.ts | 87 +- .../isolatedMarginNewOrder.ts | 144 +- .../isolatedMarginOpenOrders.ts | 67 +- .../isolated-margin-api/isolatedMarginPair.ts | 65 +- .../isolatedMarginRepay.ts | 80 +- .../isolatedMarginSymbol.ts | 68 +- .../isolatedMarginTierData.ts | 69 +- .../isolatedMarginTransfer.ts | 81 +- .../isolatedMarginTransferHistory.ts | 100 +- .../isolated-margin-api/toggleBnbBurn.ts | 75 +- .../binance-margin/margin-order-api/index.ts | 25 +- .../margin-order-api/marginCancelOco.ts | 106 +- .../margin-order-api/marginGetAllOco.ts | 96 +- .../margin-order-api/marginGetOco.ts | 102 +- .../margin-order-api/marginGetOpenOco.ts | 80 +- .../margin-order-api/marginNewOco.ts | 153 +- src/tools/binance-mining/index.ts | 55 +- .../binance-mining/mining-api/accountList.ts | 87 +- .../mining-api/acquiringAlgorithm.ts | 68 +- .../mining-api/acquiringCoinname.ts | 64 +- .../cancelHashrateResaleConfiguration.ts | 87 +- .../binance-mining/mining-api/earningsList.ts | 126 +- .../mining-api/extraBonusList.ts | 116 +- .../mining-api/hashrateResaleDetail.ts | 111 +- .../mining-api/hashrateResaleList.ts | 109 +- .../mining-api/hashrateResaleRequest.ts | 113 +- .../mining-api/miningAccountEarning.ts | 111 +- .../mining-api/requestForDetailMinerList.ts | 91 +- .../mining-api/requestForMinerList.ts | 153 +- .../mining-api/statisticList.ts | 91 +- src/tools/binance-nft/index.ts | 19 +- src/tools/binance-nft/nft-api/getNFTAsset.ts | 97 +- .../nft-api/getNFTDepositHistory.ts | 105 +- .../nft-api/getNFTTransactionHistory.ts | 113 +- .../nft-api/getNFTWithdrawHistory.ts | 105 +- src/tools/binance-options/account.ts | 53 +- src/tools/binance-options/batchOrders.ts | 71 +- src/tools/binance-options/bill.ts | 85 +- src/tools/binance-options/cancelAllOrders.ts | 67 +- .../binance-options/cancelBatchOrders.ts | 78 +- src/tools/binance-options/cancelOrder.ts | 75 +- src/tools/binance-options/depth.ts | 71 +- src/tools/binance-options/exchangeInfo.ts | 69 +- src/tools/binance-options/exerciseHistory.ts | 81 +- src/tools/binance-options/exerciseRecord.ts | 81 +- src/tools/binance-options/getOrder.ts | 75 +- src/tools/binance-options/historicalTrades.ts | 75 +- src/tools/binance-options/historyOrders.ts | 83 +- src/tools/binance-options/index.ts | 132 +- src/tools/binance-options/indexPrice.ts | 67 +- src/tools/binance-options/klines.ts | 83 +- src/tools/binance-options/listenKey.ts | 169 +- src/tools/binance-options/mark.ts | 69 +- src/tools/binance-options/newOrder.ts | 108 +- src/tools/binance-options/openInterest.ts | 69 +- src/tools/binance-options/openOrders.ts | 69 +- src/tools/binance-options/ping.ts | 58 +- src/tools/binance-options/position.ts | 69 +- src/tools/binance-options/ticker.ts | 69 +- src/tools/binance-options/time.ts | 56 +- src/tools/binance-options/trades.ts | 70 +- src/tools/binance-options/userTrades.ts | 85 +- src/tools/binance-pay/index.ts | 7 +- .../binance-pay/pay-api/getPayTradeHistory.ts | 97 +- .../binance-portfolio-margin/bnbTransfer.ts | 73 +- .../changeAutoRepayFutures.ts | 71 +- .../fundAutoCollection.ts | 69 +- .../fundCollection.ts | 69 +- .../getAccountBalance.ts | 74 +- .../getAutoRepayFuturesStatus.ts | 69 +- .../getCollateralRate.ts | 67 +- .../getPortfolioMarginAccount.ts | 69 +- .../getPortfolioMarginAssetIndexPrice.ts | 76 +- .../getPortfolioMarginAssetLeverage.ts | 67 +- .../getPortfolioMarginBankruptcyLoanAmount.ts | 69 +- .../getPortfolioMarginInterestHistory.ts | 83 +- src/tools/binance-portfolio-margin/index.ts | 73 +- .../repayFuturesNegativeBalance.ts | 69 +- .../repayPortfolioMarginBankruptcyLoan.ts | 67 +- src/tools/binance-rebate/index.ts | 7 +- .../rebate-api/getSpotRebateHistoryRecords.ts | 91 +- .../account-api/getFlexibleProductPosition.ts | 114 +- .../binance-simple-earn/account-api/index.ts | 15 +- .../simpleEarnFlexibleProductList.ts | 110 +- .../binance-simple-earn/earn-api/index.ts | 15 +- .../earn-api/redeemFlexibleProduct.ts | 131 +- .../earn-api/subscribeFlexibleProduct.ts | 101 +- src/tools/binance-simple-earn/index.ts | 15 +- .../account-api/accountCommission.ts | 72 +- .../binance-spot/account-api/getAccount.ts | 70 +- src/tools/binance-spot/account-api/index.ts | 27 +- .../binance-spot/account-api/myAllocations.ts | 94 +- .../account-api/myPreventedMatches.ts | 95 +- .../binance-spot/account-api/myTrades.ts | 98 +- .../account-api/rateLimitOrder.ts | 70 +- .../binance-spot/general-api/exchangeInfo.ts | 91 +- src/tools/binance-spot/general-api/index.ts | 16 +- src/tools/binance-spot/general-api/ping.ts | 53 +- src/tools/binance-spot/general-api/time.ts | 57 +- src/tools/binance-spot/index.ts | 42 +- .../binance-spot/market-api/aggTrades.ts | 92 +- src/tools/binance-spot/market-api/avgPrice.ts | 68 +- src/tools/binance-spot/market-api/depth.ts | 72 +- .../binance-spot/market-api/getTrades.ts | 79 +- .../market-api/historicalTrades.ts | 85 +- src/tools/binance-spot/market-api/index.ts | 54 +- src/tools/binance-spot/market-api/klines.ts | 115 +- src/tools/binance-spot/market-api/ticker.ts | 95 +- .../binance-spot/market-api/ticker24hr.ts | 86 +- .../market-api/tickerBookTicker.ts | 86 +- .../binance-spot/market-api/tickerPrice.ts | 86 +- .../market-api/tickerTradingDay.ts | 88 +- src/tools/binance-spot/market-api/uiKlines.ts | 115 +- src/tools/binance-spot/trade-api/allOrders.ts | 94 +- .../trade-api/deleteOpenOrders.ts | 69 +- .../binance-spot/trade-api/deleteOrder.ts | 83 +- .../binance-spot/trade-api/getOpenOrders.ts | 71 +- src/tools/binance-spot/trade-api/getOrder.ts | 85 +- src/tools/binance-spot/trade-api/index.ts | 38 +- src/tools/binance-spot/trade-api/newOrder.ts | 141 +- .../binance-spot/trade-api/openOrderList.ts | 71 +- src/tools/binance-spot/trade-api/orderOco.ts | 134 +- .../deleteUserDataStream.ts | 67 +- .../binance-spot/userdatastream-api/index.ts | 16 +- .../userdatastream-api/newUserDataStream.ts | 57 +- .../userdatastream-api/putUserDataStream.ts | 69 +- .../ETH-staking-api/ethStakingAccount.ts | 79 +- .../getCurrentEthStakingQuota.ts | 79 +- .../getEthRedemptionHistory.ts | 129 +- .../ETH-staking-api/getEthStakingHistory.ts | 129 +- .../ETH-staking-api/getWbethRateHistory.ts | 125 +- .../ETH-staking-api/getWbethRewardsHistory.ts | 129 +- .../ETH-staking-api/getWbethUnwrapHistory.ts | 125 +- .../ETH-staking-api/getWbethWrapHistory.ts | 121 +- .../binance-staking/ETH-staking-api/index.ts | 47 +- .../ETH-staking-api/redeemEth.ts | 87 +- .../ETH-staking-api/subscribeEthStaking.ts | 79 +- .../ETH-staking-api/wrapBeth.ts | 79 +- .../SOL-staking-api/claimBoostRewards.ts | 79 +- .../SOL-staking-api/getBnsolRateHistory.ts | 121 +- .../SOL-staking-api/getBnsolRewardsHistory.ts | 131 +- .../SOL-staking-api/getBoostRewardsHistory.ts | 131 +- .../getSolRedemptionHistory.ts | 117 +- .../SOL-staking-api/getSolStakingHistory.ts | 117 +- .../getSolStakingQuotaDetails.ts | 75 +- .../SOL-staking-api/getUnclaimedRewards.ts | 79 +- .../binance-staking/SOL-staking-api/index.ts | 47 +- .../SOL-staking-api/redeemSol.ts | 87 +- .../SOL-staking-api/solStakingAccount.ts | 75 +- .../SOL-staking-api/subscribeSolStaking.ts | 79 +- src/tools/binance-staking/index.ts | 11 +- .../assets-api/getFuturesAssetsSummary.ts | 72 +- .../assets-api/getFuturesPositionRisk.ts | 77 +- .../assets-api/getMarginAssetsSummary.ts | 64 +- .../assets-api/getSpotAssetsSummary.ts | 85 +- .../assets-api/getSubAccountAssets.ts | 69 +- .../binance-sub-account/assets-api/index.ts | 23 +- src/tools/binance-sub-account/createApiKey.ts | 81 +- .../createVirtualSubAccount.ts | 71 +- src/tools/binance-sub-account/deleteApiKey.ts | 73 +- .../deposit-api/getDepositAddress.ts | 79 +- .../deposit-api/getDepositHistory.ts | 102 +- .../binance-sub-account/deposit-api/index.ts | 11 +- .../binance-sub-account/enableFutures.ts | 71 +- src/tools/binance-sub-account/enableMargin.ts | 71 +- .../getApiKeyIpRestriction.ts | 71 +- .../getSubAccountAssets.ts | 69 +- .../getSubAccountDepositAddress.ts | 77 +- .../getSubAccountDepositHistory.ts | 98 +- .../getSubAccountFuturesPositionRisk.ts | 81 +- .../getSubAccountFuturesSummary.ts | 73 +- .../binance-sub-account/getSubAccountList.ts | 83 +- .../getSubAccountMarginSummary.ts | 73 +- .../getSubAccountSpotSummary.ts | 84 +- .../getSubAccountStatus.ts | 71 +- .../getSubAccountTransferHistory.ts | 89 +- .../getUniversalTransferHistory.ts | 93 +- src/tools/binance-sub-account/index.ts | 109 +- .../management-api/createSubAccount.ts | 73 +- .../management-api/enableFutures.ts | 69 +- .../management-api/enableMargin.ts | 69 +- .../getSubAccountApiPermission.ts | 74 +- .../management-api/getSubAccountList.ts | 90 +- .../management-api/getSubAccountStatus.ts | 69 +- .../management-api/index.ts | 27 +- .../transfer-api/futuresTransfer.ts | 89 +- .../transfer-api/getTransferHistory.ts | 92 +- .../binance-sub-account/transfer-api/index.ts | 23 +- .../transfer-api/transferToMaster.ts | 74 +- .../transfer-api/transferToSubAccount.ts | 79 +- .../transfer-api/universalTransfer.ts | 116 +- .../binance-sub-account/transferToMaster.ts | 73 +- .../transferToSubAccount.ts | 73 +- .../binance-sub-account/universalTransfer.ts | 107 +- .../updateIpRestriction.ts | 77 +- src/tools/binance-vip-loan/index.ts | 15 +- .../market-api/getBorrowInterestRate.ts | 83 +- .../market-api/getCollateralAssetData.ts | 83 +- .../market-api/getLoanableAssetsData.ts | 91 +- .../binance-vip-loan/market-api/index.ts | 15 +- src/tools/binance-vip-loan/trade-api/index.ts | 15 +- .../trade-api/vipLoanBorrow.ts | 114 +- .../trade-api/vipLoanRenew.ts | 89 +- .../trade-api/vipLoanRepay.ts | 83 +- .../checkVIPLoanCollateralAccount.ts | 91 +- .../getVIPLoanOngoingOrders.ts | 119 +- .../userInformation-api/index.ts | 15 +- .../queryApplicationStatus.ts | 99 +- .../account-api/accountApiTradingStatus.ts | 76 +- .../binance-wallet/account-api/accountInfo.ts | 76 +- .../account-api/accountStatus.ts | 73 +- .../account-api/dailyAccountSnapshot.ts | 87 +- .../account-api/disableFastWithdrawSwitch.ts | 73 +- .../account-api/enableFastWithdrawSwitch.ts | 73 +- .../account-api/getApiKeyPermission.ts | 73 +- src/tools/binance-wallet/account-api/index.ts | 34 +- .../binance-wallet/asset-api/assetDetail.ts | 75 +- .../asset-api/assetDividendRecord.ts | 89 +- .../binance-wallet/asset-api/dustTransfer.ts | 74 +- src/tools/binance-wallet/asset-api/dustlog.ts | 79 +- .../binance-wallet/asset-api/fundingWallet.ts | 81 +- .../getAssetsThatCanBeConvertedIntoBnb.ts | 73 +- .../getCloudMiningPaymentAndRefundHistory.ts | 91 +- .../asset-api/getOpenSymbolList.ts | 56 +- src/tools/binance-wallet/asset-api/index.ts | 65 +- .../asset-api/queryUserDelegationHistory.ts | 95 +- .../queryUserUniversalTransferHistory.ts | 102 +- .../asset-api/queryUserWalletBalance.ts | 73 +- ...ggleBnbBurnOnSpotTradeAndMarginInterest.ts | 80 +- .../binance-wallet/asset-api/tradeFee.ts | 77 +- .../binance-wallet/asset-api/userAsset.ts | 75 +- .../asset-api/userUniversalTransfer.ts | 96 +- .../capital-api/allCoinsInformation.ts | 71 +- .../capital-api/depositAddress.ts | 77 +- .../capital-api/depositHistory.ts | 93 +- .../fetchDepositAddressListWithNetwork.ts | 79 +- .../capital-api/fetchWithdrawAddressList.ts | 63 +- src/tools/binance-wallet/capital-api/index.ts | 37 +- .../oneClickArrivalDepositApply.ts | 80 +- .../binance-wallet/capital-api/withdraw.ts | 120 +- .../capital-api/withdrawHistory.ts | 99 +- src/tools/binance-wallet/index.ts | 43 +- .../getSymbolsDelistScheduleForSpot.ts | 58 +- src/tools/binance-wallet/others-api/index.ts | 14 +- .../binance-wallet/others-api/systemStatus.ts | 55 +- .../travel-rule-api/brokerWithdraw.ts | 132 +- .../depositHistoryTravelRule.ts | 95 +- .../binance-wallet/travel-rule-api/index.ts | 38 +- .../travel-rule-api/onboardedVaspList.ts | 61 +- .../submitDepositQuestionnaire.ts | 95 +- .../submitDepositQuestionnaireTravelRule.ts | 83 +- .../travel-rule-api/withdrawHistoryV1.ts | 95 +- .../travel-rule-api/withdrawHistoryV2.ts | 95 +- .../travel-rule-api/withdrawTravelRule.ts | 120 +- src/tools/binanceAccountInfo.ts | 122 +- src/tools/binanceOrderBook.ts | 73 +- src/tools/binanceSpotPlaceOrder.ts | 101 +- ...nanceTimeWeightedAveragePriceFutureAlgo.ts | 98 +- src/tools/credit-line/index.ts | 396 ++-- src/tools/creditline/index.ts | 498 ++--- src/tools/custodial-solution/index.ts | 754 ++++---- src/tools/custodial/index.ts | 1661 +++++++++-------- src/tools/general/index.ts | 298 +-- src/tools/market/index.ts | 1101 ++++++----- src/tools/otc/index.ts | 446 +++-- src/tools/staking/index.ts | 452 +++-- src/tools/subaccount/index.ts | 485 ++--- src/tools/trade/index.ts | 49 +- src/tools/trade/oco.ts | 939 ++++++---- src/tools/trade/orders.ts | 1494 ++++++++------- src/tools/userdata-stream/index.ts | 311 +-- src/tools/wallet/index.ts | 523 +++--- src/utils/logger.ts | 7 +- 988 files changed, 48902 insertions(+), 42548 deletions(-) create mode 100644 .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc create mode 100644 .prettierrc delete mode 100644 config.json create mode 100644 eslint.config.js diff --git a/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc b/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc new file mode 100644 index 00000000..ebda9951 --- /dev/null +++ b/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc @@ -0,0 +1,111 @@ +--- +description: Use Bun instead of Node.js, npm, pnpm, or vite. +globs: "*.ts, *.tsx, *.html, *.css, *.js, *.jsx, package.json" +alwaysApply: false +--- + +Default to using Bun instead of Node.js. + +- Use `bun ` instead of `node ` or `ts-node ` +- Use `bun test` instead of `jest` or `vitest` +- Use `bun build ` instead of `webpack` or `esbuild` +- Use `bun install` instead of `npm install` or `yarn install` or `pnpm install` +- Use `bun run + + +``` + +With the following `frontend.tsx`: + +```tsx#frontend.tsx +import React from "react"; +import { createRoot } from "react-dom/client"; + +// import .css files directly and it works +import './index.css'; + +const root = createRoot(document.body); + +export default function Frontend() { + return

Hello, world!

; +} + +root.render(); +``` + +Then, run index.ts + +```sh +bun --hot ./index.ts +``` + +For more information, read the Bun API docs in `node_modules/bun-types/docs/**.mdx`. diff --git a/.gitignore b/.gitignore index 7b958523..fe0c3414 100644 --- a/.gitignore +++ b/.gitignore @@ -1,141 +1,142 @@ -# Gitignore for Universal Crypto MCP -################################################################ - -# System files -.DS_Store -Thumbs.db -ehthumbs.db -Desktop.ini - -# Linux/Ubuntu system files -*~ -*.swp -*.swo -.fuse_hidden* -.directory -.Trash-* -.nfs* -.gvfs-fuse-daemon-* - -# IDE and editors -.idea/ -*.sublime-* -.history/ -.windsurfrules -*.code-workspace -.vscode/sessions.json - -# Temporary files -.temp/ -temp/ -tmp/ -*.tmp -*.temp -*.log -*.cache -.cache/ - -# Environment files -.env -.env.local -.env*.local -.env.development -venv/ -.venv/ -.env.example.development -.env.example -.env.desktop -.env* -.env.sentry-build-plugin - -# Dependencies -node_modules/ -*.lock -package-lock.json -bun.lockb -.pnpm-store/ -/.pnp -.pnp.js - -# Build outputs -dist/ -es/ -/lib/ -.next/ -/out/ -/build -logs/ -test-output/ -*.tsbuildinfo -next-env.d.ts - -# Framework specific -# Umi -.umi/ -.umi-production/ -.umi-test/ -.dumi/tmp*/ - -# Vercel -.vercel/ - -# Testing and CI -coverage/ -.coverage/ -.nyc_output/ -.eslintcache -.stylelintcache - -# Database -/prisma/db.sqlite -/prisma/db.sqlite-journal -db.sqlite - -# Debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* -.pnpm-debug.log* - -# Misc -*.pem -src/tools/binance-spot/a.sh -a.sh -src/tools/binance-spot/a.txt - -# Service Worker / Serwist -public/sw* -public/swe-worker* - -# Generated files -public/*.js -public/sitemap.xml -public/sitemap-index.xml -sitemap*.xml -robots.txt - -# Git hooks -.husky/prepare-commit-msg - -# Documents and media -*.patch -*.pdf -*.ppt* -*.doc* -*.xls* - -# Cloud service keys -vertex-ai-key.json - -# AI coding tools -.local/ -.claude/ -.mcp.json -CLAUDE.local.md -.serena/** - -# Misc -./packages/lobe-ui -prd -GEMINI.md -e2e/reports +# Gitignore for Universal Crypto MCP +################################################################ + +# System files +.DS_Store +Thumbs.db +ehthumbs.db +Desktop.ini + +# Linux/Ubuntu system files +*~ +*.swp +*.swo +.fuse_hidden* +.directory +.Trash-* +.nfs* +.gvfs-fuse-daemon-* + +# IDE and editors +.idea/ +*.sublime-* +.history/ +.windsurfrules +*.code-workspace +.vscode/sessions.json + +# Temporary files +.temp/ +temp/ +tmp/ +*.tmp +*.temp +*.log +*.cache +.cache/ + +# Environment files +.env +.env.local +.env*.local +.env.development +venv/ +.venv/ +.env.example.development +.env.example +.env.desktop +.env* +.env.sentry-build-plugin +config.json + +# Dependencies +node_modules/ +*.lock +package-lock.json +bun.lockb +.pnpm-store/ +/.pnp +.pnp.js + +# Build outputs +dist/ +es/ +/lib/ +.next/ +/out/ +/build +logs/ +test-output/ +*.tsbuildinfo +next-env.d.ts + +# Framework specific +# Umi +.umi/ +.umi-production/ +.umi-test/ +.dumi/tmp*/ + +# Vercel +.vercel/ + +# Testing and CI +coverage/ +.coverage/ +.nyc_output/ +.eslintcache +.stylelintcache + +# Database +/prisma/db.sqlite +/prisma/db.sqlite-journal +db.sqlite + +# Debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* +.pnpm-debug.log* + +# Misc +*.pem +src/tools/binance-spot/a.sh +a.sh +src/tools/binance-spot/a.txt + +# Service Worker / Serwist +public/sw* +public/swe-worker* + +# Generated files +public/*.js +public/sitemap.xml +public/sitemap-index.xml +sitemap*.xml +robots.txt + +# Git hooks +.husky/prepare-commit-msg + +# Documents and media +*.patch +*.pdf +*.ppt* +*.doc* +*.xls* + +# Cloud service keys +vertex-ai-key.json + +# AI coding tools +.local/ +.claude/ +.mcp.json +CLAUDE.local.md +.serena/** + +# Misc +./packages/lobe-ui +prd +GEMINI.md +e2e/reports diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..80b05da9 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,9 @@ +{ + "semi": false, + "singleQuote": false, + "trailingComma": "all", + "printWidth": 100, + "tabWidth": 2, + "arrowParens": "always", + "endOfLine": "lf" +} diff --git a/config.json b/config.json deleted file mode 100644 index f769e982..00000000 --- a/config.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "mcpServers": { - "binance-mcp": { - "command": "node", - "args": [ - "/Users/Username/Desktop/bsc-mpc/build/index.js" - ], - "env": { - "BINANCE_API_KEY": "BINANCE_API_KEY", - "BINANCE_API_SECRET": "BINANCE_API_SECRET" - }, - "disabled": false, - "autoApprove": [] - } - } -} - diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 00000000..9cc2c5e7 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,55 @@ +import js from "@eslint/js" +import stylistic from "@stylistic/eslint-plugin" +import perfectionist from "eslint-plugin-perfectionist" +import tseslint from "typescript-eslint" +import prettierConfig from "eslint-config-prettier" + +export default tseslint.config( + js.configs.recommended, + ...tseslint.configs.strict, + ...tseslint.configs.stylistic, + prettierConfig, + { + plugins: { + "@stylistic": stylistic, + perfectionist, + }, + rules: { + "@stylistic/padding-line-between-statements": [ + "error", + { blankLine: "always", prev: "*", next: "return" }, + ], + "perfectionist/sort-imports": [ + "error", + { + type: "natural", + order: "asc", + groups: [ + "type", + "builtin", + "external", + "internal", + "parent", + "sibling", + "index", + "side-effect", + ], + newlinesBetween: 1, + }, + ], + "perfectionist/sort-named-imports": ["error", { type: "natural", order: "asc" }], + "@typescript-eslint/consistent-type-imports": [ + "error", + { prefer: "type-imports", fixStyle: "separate-type-imports" }, + ], + "@typescript-eslint/no-explicit-any": "warn", + "@typescript-eslint/no-unused-vars": [ + "error", + { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }, + ], + }, + }, + { + ignores: ["build/**", "node_modules/**"], + }, +) diff --git a/package.json b/package.json index 1112aafd..232f8726 100644 --- a/package.json +++ b/package.json @@ -5,13 +5,17 @@ "type": "module", "main": "./build/index.js", "scripts": { - "start": "node build/index.js", - "start:sse": "node build/index.js --sse", - "dev": "tsx watch src/index.ts", - "dev:sse": "tsx watch src/index.ts --sse", + "start": "bun run build/index.js", + "start:sse": "bun run build/index.js --sse", + "dev": "bun --watch src/index.ts", + "dev:sse": "bun --watch src/index.ts --sse", "build": "tsc", - "init": "tsx src/init.ts", - "test": "npx @modelcontextprotocol/inspector tsx src/index.ts" + "init": "bun src/init.ts", + "test": "bunx @modelcontextprotocol/inspector bun src/index.ts", + "lint": "eslint src/", + "lint:fix": "eslint src/ --fix", + "format": "prettier --write \"src/**/*.ts\"", + "format:check": "prettier --check \"src/**/*.ts\"" }, "bin": { "binance-mcp": "./build/index.js" @@ -69,21 +73,29 @@ "zod": "^3.22.4" }, "devDependencies": { + "@eslint/js": "^10.0.1", + "@stylistic/eslint-plugin": "^5.10.0", + "@types/bun": "latest", "@types/cors": "^2.8.17", "@types/express": "^4.17.21", + "@types/figlet": "^1.5.8", + "@types/fs-extra": "^11.0.4", "@types/node": "^20.0.0", + "@types/prompts": "^2.4.9", "chalk": "^5.3.0", + "eslint": "^10.0.3", + "eslint-config-prettier": "^10.1.8", + "eslint-plugin-perfectionist": "^5.6.0", "figlet": "^1.8.0", "fs-extra": "^11.2.0", + "prettier": "^3.8.1", "prompts": "^2.4.2", - "@types/figlet": "^1.5.8", - "@types/fs-extra": "^11.0.4", - "@types/prompts": "^2.4.9", - "tsx": "^4.7.0", - "typescript": "^5.0.0" + "typescript": "^5.0.0", + "typescript-eslint": "^8.57.0" }, "license": "MIT", "engines": { - "node": ">=18.0.0" - } + "bun": ">=1.3.9" + }, + "private": true } diff --git a/src/binance.ts b/src/binance.ts index 3a351158..67a519d3 100644 --- a/src/binance.ts +++ b/src/binance.ts @@ -1,27 +1,27 @@ // src/binance.ts // Central registration file for all Binance modules -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" -// Import module registration functions -import { registerBinanceSpotTools } from "./modules/spot/index.js" import { registerBinanceAlgoTools } from "./modules/algo/index.js" -import { registerBinanceSimpleEarnTools } from "./modules/simple-earn/index.js" import { registerBinanceC2CTradeHistoryTools } from "./modules/c2c/index.js" import { registerBinanceConvertTools } from "./modules/convert/index.js" -import { registerBinanceWalletTools } from "./modules/wallet/index.js" import { registerBinanceCopyTradingTools } from "./modules/copy-trading/index.js" +import { registerBinanceDualInvestmentTools } from "./modules/dual-investment/index.js" import { registerBinanceFiatDepositWithdrawHistoryTools } from "./modules/fiat/index.js" +import { registerGiftCard } from "./modules/gift-card/index.js" +import { registerBinanceMiningTools } from "./modules/mining/index.js" import { registerBinanceNFTTools } from "./modules/nft/index.js" import { registerBinancePayTools } from "./modules/pay/index.js" +import { registerPortfolioMargin } from "./modules/portfolio-margin/index.js" import { registerBinanceRebateTools } from "./modules/rebate/index.js" -import { registerBinanceDualInvestmentTools } from "./modules/dual-investment/index.js" -import { registerBinanceMiningTools } from "./modules/mining/index.js" -import { registerBinanceVipLoanTools } from "./modules/vip-loan/index.js" +import { registerBinanceSimpleEarnTools } from "./modules/simple-earn/index.js" +// Import module registration functions +import { registerBinanceSpotTools } from "./modules/spot/index.js" import { registerBinanceStakingTools } from "./modules/staking/index.js" -import { registerPortfolioMargin } from "./modules/portfolio-margin/index.js" -import { registerGiftCard } from "./modules/gift-card/index.js" import { registerSubAccount } from "./modules/sub-account/index.js" +import { registerBinanceVipLoanTools } from "./modules/vip-loan/index.js" +import { registerBinanceWalletTools } from "./modules/wallet/index.js" // NOTE: The following modules are disabled due to missing/incompatible npm packages: // - Margin (@binance/margin doesn't exist, needs refactoring to use connector-typescript) @@ -38,35 +38,34 @@ export function registerBinance(server: McpServer) { // Core trading modules registerBinanceSpotTools(server) registerBinanceAlgoTools(server) - + // Earn & Investment modules registerBinanceSimpleEarnTools(server) registerBinanceDualInvestmentTools(server) registerBinanceStakingTools(server) - + // Trading modules registerBinanceC2CTradeHistoryTools(server) registerBinanceConvertTools(server) registerBinanceCopyTradingTools(server) - + // Wallet & Finance modules registerBinanceWalletTools(server) registerBinanceFiatDepositWithdrawHistoryTools(server) registerBinanceVipLoanTools(server) - + // Portfolio Margin module registerPortfolioMargin(server) - + // Gift Card module registerGiftCard(server) - + // Sub-Account Management module registerSubAccount(server) - + // Other modules registerBinanceNFTTools(server) registerBinancePayTools(server) registerBinanceRebateTools(server) registerBinanceMiningTools(server) } - diff --git a/src/config/binanceClient.ts b/src/config/binanceClient.ts index f74b5b06..eac5dbb4 100644 --- a/src/config/binanceClient.ts +++ b/src/config/binanceClient.ts @@ -1,480 +1,579 @@ +import crypto from "crypto" + +import { Algo } from "@binance/algo" +import { AutoInvest } from "@binance/auto-invest" +import { C2C } from "@binance/c2c" +import { Spot as ConnectorSpot } from "@binance/connector-typescript" +import { Convert } from "@binance/convert" +import { CopyTrading } from "@binance/copy-trading" +import { CryptoLoan } from "@binance/crypto-loan" +import { DualInvestment } from "@binance/dual-investment" +import { Fiat } from "@binance/fiat" +import { Mining } from "@binance/mining" +import { NFT } from "@binance/nft" +import { Pay } from "@binance/pay" +import { Rebate } from "@binance/rebate" +import { SimpleEarn } from "@binance/simple-earn" // src/config/binanceClient.ts // Existing SDK packages -import { Spot } from "@binance/spot"; -import { Spot as ConnectorSpot } from "@binance/connector-typescript"; -import { SimpleEarn } from "@binance/simple-earn"; -import { Algo } from "@binance/algo"; -import { C2C } from "@binance/c2c"; -import { Convert } from "@binance/convert"; -import { Wallet } from "@binance/wallet"; -import { CopyTrading } from "@binance/copy-trading"; -import { Fiat } from "@binance/fiat"; -import { NFT } from "@binance/nft"; -import { Pay } from "@binance/pay"; -import { Rebate } from "@binance/rebate"; -import { DualInvestment } from "@binance/dual-investment"; -import { Mining } from "@binance/mining"; -import { VIPLoan } from "@binance/vip-loan"; -import { Staking } from "@binance/staking"; -import { AutoInvest } from "@binance/auto-invest"; -import { CryptoLoan } from "@binance/crypto-loan"; -import { SubAccount } from "@binance/sub-account"; -import crypto from "crypto"; - -const API_KEY = process.env.BINANCE_API_KEY ?? ""; -const API_SECRET = process.env.BINANCE_API_SECRET ?? ""; -const BASE_URL = "https://api.binance.com"; +import { Spot } from "@binance/spot" +import { Staking } from "@binance/staking" +import { SubAccount } from "@binance/sub-account" +import { VIPLoan } from "@binance/vip-loan" +import { Wallet } from "@binance/wallet" + +const API_KEY = process.env.BINANCE_API_KEY ?? "" +const API_SECRET = process.env.BINANCE_API_SECRET ?? "" +const BASE_URL = "https://api.binance.com" const configurationRestAPI = { - apiKey: API_KEY, - apiSecret: API_SECRET, - basePath: BASE_URL -}; + apiKey: API_KEY, + apiSecret: API_SECRET, + basePath: BASE_URL, +} // Spot Trading -export const spotClient = new Spot({ configurationRestAPI }); +export const spotClient = new Spot({ configurationRestAPI }) // Connector-typescript client (for margin and other APIs) -export const connectorClient = new ConnectorSpot(API_KEY, API_SECRET, { baseURL: BASE_URL }); +export const connectorClient = new ConnectorSpot(API_KEY, API_SECRET, { baseURL: BASE_URL }) // Algo Trading -export const algoClient = new Algo({ configurationRestAPI }); +export const algoClient = new Algo({ configurationRestAPI }) // Earn & Investment -export const simpleEarnClient = new SimpleEarn({ configurationRestAPI }); -export const dualInvestmentClient = new DualInvestment({ configurationRestAPI }); -export const stakingClient = new Staking({ configurationRestAPI }); -export const autoInvestClient = new AutoInvest({ configurationRestAPI }); +export const simpleEarnClient = new SimpleEarn({ configurationRestAPI }) +export const dualInvestmentClient = new DualInvestment({ configurationRestAPI }) +export const stakingClient = new Staking({ configurationRestAPI }) +export const autoInvestClient = new AutoInvest({ configurationRestAPI }) // Trading -export const c2cClient = new C2C({ configurationRestAPI }); -export const convertClient = new Convert({ configurationRestAPI }); -export const copyTradingClient = new CopyTrading({ configurationRestAPI }); +export const c2cClient = new C2C({ configurationRestAPI }) +export const convertClient = new Convert({ configurationRestAPI }) +export const copyTradingClient = new CopyTrading({ configurationRestAPI }) // Loans -export const vipLoanClient = new VIPLoan({ configurationRestAPI }); -export const cryptoLoanClient = new CryptoLoan({ configurationRestAPI }); +export const vipLoanClient = new VIPLoan({ configurationRestAPI }) +export const cryptoLoanClient = new CryptoLoan({ configurationRestAPI }) // Wallet & Finance -export const walletClient = new Wallet({ configurationRestAPI }); -export const fiatClient = new Fiat({ configurationRestAPI }); +export const walletClient = new Wallet({ configurationRestAPI }) +export const fiatClient = new Fiat({ configurationRestAPI }) // Sub-Account Management -export const subAccountClient = new SubAccount({ configurationRestAPI }); +export const subAccountClient = new SubAccount({ configurationRestAPI }) // Other -export const nftClient = new NFT({ configurationRestAPI }); -export const payClient = new Pay({ configurationRestAPI }); -export const rebateClient = new Rebate({ configurationRestAPI }); -export const miningClient = new Mining({ configurationRestAPI }); +export const nftClient = new NFT({ configurationRestAPI }) +export const payClient = new Pay({ configurationRestAPI }) +export const rebateClient = new Rebate({ configurationRestAPI }) +export const miningClient = new Mining({ configurationRestAPI }) // Generic REST client for APIs without dedicated packages // (Margin, Futures, Options, Gift Card, Portfolio Margin) function generateSignature(queryString: string): string { - return crypto.createHmac("sha256", API_SECRET).update(queryString).digest("hex"); + return crypto.createHmac("sha256", API_SECRET).update(queryString).digest("hex") } async function makeSignedRequest( - method: "GET" | "POST" | "DELETE", - endpoint: string, - params: Record = {} + method: "GET" | "POST" | "DELETE", + endpoint: string, + params: Record = {}, ): Promise { - const timestamp = Date.now(); - const queryParams = { ...params, timestamp }; - const queryString = new URLSearchParams( - Object.fromEntries(Object.entries(queryParams).map(([k, v]) => [k, String(v)])) - ).toString(); - const signature = generateSignature(queryString); - const url = `${BASE_URL}${endpoint}?${queryString}&signature=${signature}`; - - const response = await fetch(url, { - method, - headers: { - "X-MBX-APIKEY": API_KEY, - "Content-Type": "application/json" - } - }); - - if (!response.ok) { - const errorData = await response.json().catch(() => ({})); - throw new Error(`Binance API error: ${response.status} - ${JSON.stringify(errorData)}`); - } - - return response.json(); + const timestamp = Date.now() + const queryParams = { ...params, timestamp } + const queryString = new URLSearchParams( + Object.fromEntries(Object.entries(queryParams).map(([k, v]) => [k, String(v)])), + ).toString() + const signature = generateSignature(queryString) + const url = `${BASE_URL}${endpoint}?${queryString}&signature=${signature}` + + const response = await fetch(url, { + method, + headers: { + "X-MBX-APIKEY": API_KEY, + "Content-Type": "application/json", + }, + }) + + if (!response.ok) { + const errorData = await response.json().catch(() => ({})) + throw new Error(`Binance API error: ${response.status} - ${JSON.stringify(errorData)}`) + } + + return response.json() } async function makePublicRequest(endpoint: string, params: Record = {}): Promise { - const queryString = new URLSearchParams( - Object.fromEntries(Object.entries(params).map(([k, v]) => [k, String(v)])) - ).toString(); - const url = `${BASE_URL}${endpoint}${queryString ? "?" + queryString : ""}`; - - const response = await fetch(url, { - method: "GET", - headers: { - "Content-Type": "application/json" - } - }); - - if (!response.ok) { - const errorData = await response.json().catch(() => ({})); - throw new Error(`Binance API error: ${response.status} - ${JSON.stringify(errorData)}`); - } - - return response.json(); + const queryString = new URLSearchParams( + Object.fromEntries(Object.entries(params).map(([k, v]) => [k, String(v)])), + ).toString() + const url = `${BASE_URL}${endpoint}${queryString ? "?" + queryString : ""}` + + const response = await fetch(url, { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + }) + + if (!response.ok) { + const errorData = await response.json().catch(() => ({})) + throw new Error(`Binance API error: ${response.status} - ${JSON.stringify(errorData)}`) + } + + return response.json() } // Portfolio Margin client wrapper export const portfolioMarginClient = { - getAccount: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/portfolio/account", params), - getCollateralRate: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/portfolio/collateralRate", params), - getBankruptcyLoanAmount: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/portfolio/pmLoan", params), - repayBankruptcyLoan: (params: Record = {}) => - makeSignedRequest("POST", "/sapi/v1/portfolio/repay", params), - getInterestHistory: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/portfolio/interest-history", params), - getAssetIndexPrice: (params: Record = {}) => - makePublicRequest("/sapi/v1/portfolio/asset-index-price", params), - fundAutoCollection: (params: Record = {}) => - makeSignedRequest("POST", "/sapi/v1/portfolio/auto-collection", params), - fundCollection: (params: Record = {}) => - makeSignedRequest("POST", "/sapi/v1/portfolio/asset-collection", params), - bnbTransfer: (params: Record = {}) => - makeSignedRequest("POST", "/sapi/v1/portfolio/bnb-transfer", params), - changeAutoRepayFutures: (params: Record = {}) => - makeSignedRequest("POST", "/sapi/v1/portfolio/repay-futures-switch", params), - getAutoRepayFuturesStatus: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/portfolio/repay-futures-switch", params), - repayFuturesNegativeBalance: (params: Record = {}) => - makeSignedRequest("POST", "/sapi/v1/portfolio/repay-futures-negative-balance", params), - getAssetLeverage: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/portfolio/margin-asset-leverage", params), - getBalance: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/portfolio/balance", params) -}; + getAccount: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/portfolio/account", params), + getCollateralRate: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/portfolio/collateralRate", params), + getBankruptcyLoanAmount: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/portfolio/pmLoan", params), + repayBankruptcyLoan: (params: Record = {}) => + makeSignedRequest("POST", "/sapi/v1/portfolio/repay", params), + getInterestHistory: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/portfolio/interest-history", params), + getAssetIndexPrice: (params: Record = {}) => + makePublicRequest("/sapi/v1/portfolio/asset-index-price", params), + fundAutoCollection: (params: Record = {}) => + makeSignedRequest("POST", "/sapi/v1/portfolio/auto-collection", params), + fundCollection: (params: Record = {}) => + makeSignedRequest("POST", "/sapi/v1/portfolio/asset-collection", params), + bnbTransfer: (params: Record = {}) => + makeSignedRequest("POST", "/sapi/v1/portfolio/bnb-transfer", params), + changeAutoRepayFutures: (params: Record = {}) => + makeSignedRequest("POST", "/sapi/v1/portfolio/repay-futures-switch", params), + getAutoRepayFuturesStatus: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/portfolio/repay-futures-switch", params), + repayFuturesNegativeBalance: (params: Record = {}) => + makeSignedRequest("POST", "/sapi/v1/portfolio/repay-futures-negative-balance", params), + getAssetLeverage: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/portfolio/margin-asset-leverage", params), + getBalance: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/portfolio/balance", params), +} // Gift Card client wrapper export const giftCardClient = { - createCode: (params: Record = {}) => - makeSignedRequest("POST", "/sapi/v1/giftcard/createCode", params), - createDualTokenCode: (params: Record = {}) => - makeSignedRequest("POST", "/sapi/v1/giftcard/buyCode", params), - redeemCode: (params: Record = {}) => - makeSignedRequest("POST", "/sapi/v1/giftcard/redeemCode", params), - verify: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/giftcard/verify", params), - rsaPublicKey: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/giftcard/cryptography/rsa-public-key", params), - buyCode: (params: Record = {}) => - makeSignedRequest("POST", "/sapi/v1/giftcard/buyCode", params), - getTokenLimit: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/giftcard/buyCode/token-limit", params) -}; + createCode: (params: Record = {}) => + makeSignedRequest("POST", "/sapi/v1/giftcard/createCode", params), + createDualTokenCode: (params: Record = {}) => + makeSignedRequest("POST", "/sapi/v1/giftcard/buyCode", params), + redeemCode: (params: Record = {}) => + makeSignedRequest("POST", "/sapi/v1/giftcard/redeemCode", params), + verify: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/giftcard/verify", params), + rsaPublicKey: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/giftcard/cryptography/rsa-public-key", params), + buyCode: (params: Record = {}) => + makeSignedRequest("POST", "/sapi/v1/giftcard/buyCode", params), + getTokenLimit: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/giftcard/buyCode/token-limit", params), +} // Margin client wrapper export const marginClient = { - borrow: (params: Record = {}) => - makeSignedRequest("POST", "/sapi/v1/margin/loan", params), - repay: (params: Record = {}) => - makeSignedRequest("POST", "/sapi/v1/margin/repay", params), - getAccount: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/margin/account", params), - getMaxBorrowable: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/margin/maxBorrowable", params), - getMaxTransferable: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/margin/maxTransferable", params), - transfer: (params: Record = {}) => - makeSignedRequest("POST", "/sapi/v1/margin/transfer", params), - getAllPairs: (params: Record = {}) => - makePublicRequest("/sapi/v1/margin/allPairs", params), - getPriceIndex: (params: Record = {}) => - makePublicRequest("/sapi/v1/margin/priceIndex", params), - newOrder: (params: Record = {}) => - makeSignedRequest("POST", "/sapi/v1/margin/order", params), - cancelOrder: (params: Record = {}) => - makeSignedRequest("DELETE", "/sapi/v1/margin/order", params), - getOpenOrders: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/margin/openOrders", params), - getAllOrders: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/margin/allOrders", params), - getMyTrades: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/margin/myTrades", params), - cancelAllOpenOrders: (params: Record = {}) => - makeSignedRequest("DELETE", "/sapi/v1/margin/openOrders", params), - getLoanRecord: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/margin/loan", params), - getRepayRecord: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/margin/repay", params), - getInterestHistory: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/margin/interestHistory", params), - getForceLiquidationRecord: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/margin/forceLiquidationRec", params), - getIsolatedAccount: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/margin/isolated/account", params), - enableIsolatedAccount: (params: Record = {}) => - makeSignedRequest("POST", "/sapi/v1/margin/isolated/account", params), - disableIsolatedAccount: (params: Record = {}) => - makeSignedRequest("DELETE", "/sapi/v1/margin/isolated/account", params), - getIsolatedMarginPairs: (params: Record = {}) => - makePublicRequest("/sapi/v1/margin/isolated/allPairs", params), - getIsolatedMarginTier: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/margin/isolatedMarginTier", params), - getCrossMarginFee: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/margin/crossMarginData", params), - getIsolatedMarginFee: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/margin/isolatedMarginData", params), - getSmallLiabilityExchangeCoinList: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/margin/exchange-small-liability", params), - smallLiabilityExchange: (params: Record = {}) => - makeSignedRequest("POST", "/sapi/v1/margin/exchange-small-liability", params), - getSmallLiabilityExchangeHistory: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/margin/exchange-small-liability-history", params), - getDustLog: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/margin/dribblet", params), - getCapitalFlow: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/margin/capital-flow", params), - getDelistSchedule: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/margin/delist-schedule", params), - getAvailableInventory: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/margin/available-inventory", params), - getAllAssets: (params: Record = {}) => - makePublicRequest("/sapi/v1/margin/allAssets", params), - getInterestRateHistory: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/margin/interestRateHistory", params) -}; + borrow: (params: Record = {}) => + makeSignedRequest("POST", "/sapi/v1/margin/loan", params), + repay: (params: Record = {}) => + makeSignedRequest("POST", "/sapi/v1/margin/repay", params), + getAccount: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/margin/account", params), + getMaxBorrowable: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/margin/maxBorrowable", params), + getMaxTransferable: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/margin/maxTransferable", params), + transfer: (params: Record = {}) => + makeSignedRequest("POST", "/sapi/v1/margin/transfer", params), + getAllPairs: (params: Record = {}) => + makePublicRequest("/sapi/v1/margin/allPairs", params), + getPriceIndex: (params: Record = {}) => + makePublicRequest("/sapi/v1/margin/priceIndex", params), + newOrder: (params: Record = {}) => + makeSignedRequest("POST", "/sapi/v1/margin/order", params), + cancelOrder: (params: Record = {}) => + makeSignedRequest("DELETE", "/sapi/v1/margin/order", params), + getOpenOrders: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/margin/openOrders", params), + getAllOrders: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/margin/allOrders", params), + getMyTrades: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/margin/myTrades", params), + cancelAllOpenOrders: (params: Record = {}) => + makeSignedRequest("DELETE", "/sapi/v1/margin/openOrders", params), + getLoanRecord: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/margin/loan", params), + getRepayRecord: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/margin/repay", params), + getInterestHistory: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/margin/interestHistory", params), + getForceLiquidationRecord: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/margin/forceLiquidationRec", params), + getIsolatedAccount: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/margin/isolated/account", params), + enableIsolatedAccount: (params: Record = {}) => + makeSignedRequest("POST", "/sapi/v1/margin/isolated/account", params), + disableIsolatedAccount: (params: Record = {}) => + makeSignedRequest("DELETE", "/sapi/v1/margin/isolated/account", params), + getIsolatedMarginPairs: (params: Record = {}) => + makePublicRequest("/sapi/v1/margin/isolated/allPairs", params), + getIsolatedMarginTier: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/margin/isolatedMarginTier", params), + getCrossMarginFee: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/margin/crossMarginData", params), + getIsolatedMarginFee: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/margin/isolatedMarginData", params), + getSmallLiabilityExchangeCoinList: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/margin/exchange-small-liability", params), + smallLiabilityExchange: (params: Record = {}) => + makeSignedRequest("POST", "/sapi/v1/margin/exchange-small-liability", params), + getSmallLiabilityExchangeHistory: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/margin/exchange-small-liability-history", params), + getDustLog: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/margin/dribblet", params), + getCapitalFlow: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/margin/capital-flow", params), + getDelistSchedule: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/margin/delist-schedule", params), + getAvailableInventory: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/margin/available-inventory", params), + getAllAssets: (params: Record = {}) => + makePublicRequest("/sapi/v1/margin/allAssets", params), + getInterestRateHistory: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/margin/interestRateHistory", params), +} // Helper for Futures API with different base URLs -const FUTURES_USD_BASE_URL = "https://fapi.binance.com"; -const FUTURES_COIN_BASE_URL = "https://dapi.binance.com"; +const FUTURES_USD_BASE_URL = "https://fapi.binance.com" +const FUTURES_COIN_BASE_URL = "https://dapi.binance.com" async function makeFuturesSignedRequest( - baseUrl: string, - method: "GET" | "POST" | "DELETE" | "PUT", - endpoint: string, - params: Record = {} + baseUrl: string, + method: "GET" | "POST" | "DELETE" | "PUT", + endpoint: string, + params: Record = {}, ): Promise { - const timestamp = Date.now(); - const queryParams = { ...params, timestamp }; - const queryString = new URLSearchParams( - Object.fromEntries(Object.entries(queryParams).map(([k, v]) => [k, String(v)])) - ).toString(); - const signature = generateSignature(queryString); - const url = `${baseUrl}${endpoint}?${queryString}&signature=${signature}`; - - const response = await fetch(url, { - method, - headers: { - "X-MBX-APIKEY": API_KEY, - "Content-Type": "application/json" - } - }); - - if (!response.ok) { - const errorData = await response.json().catch(() => ({})); - throw new Error(`Binance API error: ${response.status} - ${JSON.stringify(errorData)}`); - } - - return response.json(); + const timestamp = Date.now() + const queryParams = { ...params, timestamp } + const queryString = new URLSearchParams( + Object.fromEntries(Object.entries(queryParams).map(([k, v]) => [k, String(v)])), + ).toString() + const signature = generateSignature(queryString) + const url = `${baseUrl}${endpoint}?${queryString}&signature=${signature}` + + const response = await fetch(url, { + method, + headers: { + "X-MBX-APIKEY": API_KEY, + "Content-Type": "application/json", + }, + }) + + if (!response.ok) { + const errorData = await response.json().catch(() => ({})) + throw new Error(`Binance API error: ${response.status} - ${JSON.stringify(errorData)}`) + } + + return response.json() } async function makeFuturesPublicRequest( - baseUrl: string, - endpoint: string, - params: Record = {} + baseUrl: string, + endpoint: string, + params: Record = {}, ): Promise { - const queryString = new URLSearchParams( - Object.fromEntries(Object.entries(params).map(([k, v]) => [k, String(v)])) - ).toString(); - const url = `${baseUrl}${endpoint}${queryString ? "?" + queryString : ""}`; - - const response = await fetch(url, { - method: "GET", - headers: { "Content-Type": "application/json" } - }); - - if (!response.ok) { - const errorData = await response.json().catch(() => ({})); - throw new Error(`Binance API error: ${response.status} - ${JSON.stringify(errorData)}`); - } - - return response.json(); + const queryString = new URLSearchParams( + Object.fromEntries(Object.entries(params).map(([k, v]) => [k, String(v)])), + ).toString() + const url = `${baseUrl}${endpoint}${queryString ? "?" + queryString : ""}` + + const response = await fetch(url, { + method: "GET", + headers: { "Content-Type": "application/json" }, + }) + + if (!response.ok) { + const errorData = await response.json().catch(() => ({})) + throw new Error(`Binance API error: ${response.status} - ${JSON.stringify(errorData)}`) + } + + return response.json() } // Futures USD-M client wrapper export const futuresClient = { - // Market Data - ping: () => makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/ping"), - time: () => makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/time"), - exchangeInfo: () => makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/exchangeInfo"), - depth: (params: Record) => makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/depth", params), - trades: (params: Record) => makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/trades", params), - historicalTrades: (params: Record) => makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/historicalTrades", params), - aggTrades: (params: Record) => makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/aggTrades", params), - klines: (params: Record) => makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/klines", params), - continuousKlines: (params: Record) => makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/continuousKlines", params), - indexPriceKlines: (params: Record) => makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/indexPriceKlines", params), - markPriceKlines: (params: Record) => makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/markPriceKlines", params), - premiumIndex: (params: Record = {}) => makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/premiumIndex", params), - fundingRate: (params: Record) => makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/fundingRate", params), - ticker24hr: (params: Record = {}) => makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/ticker/24hr", params), - tickerPrice: (params: Record = {}) => makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/ticker/price", params), - bookTicker: (params: Record = {}) => makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/ticker/bookTicker", params), - openInterest: (params: Record) => makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/openInterest", params), - // Account/Trade - newOrder: (params: Record) => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "POST", "/fapi/v1/order", params), - batchOrders: (params: Record) => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "POST", "/fapi/v1/batchOrders", params), - getOrder: (params: Record) => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v1/order", params), - cancelOrder: (params: Record) => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "DELETE", "/fapi/v1/order", params), - cancelAllOpenOrders: (params: Record) => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "DELETE", "/fapi/v1/allOpenOrders", params), - cancelBatchOrders: (params: Record) => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "DELETE", "/fapi/v1/batchOrders", params), - openOrders: (params: Record = {}) => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v1/openOrders", params), - allOrders: (params: Record) => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v1/allOrders", params), - balance: (params: Record = {}) => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v2/balance", params), - account: (params: Record = {}) => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v2/account", params), - leverage: (params: Record) => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "POST", "/fapi/v1/leverage", params), - marginType: (params: Record) => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "POST", "/fapi/v1/marginType", params), - positionMargin: (params: Record) => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "POST", "/fapi/v1/positionMargin", params), - positionRisk: (params: Record = {}) => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v2/positionRisk", params), - userTrades: (params: Record) => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v1/userTrades", params), - income: (params: Record = {}) => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v1/income", params), - commissionRate: (params: Record) => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v1/commissionRate", params), - adlQuantile: (params: Record = {}) => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v1/adlQuantile", params), - forceOrders: (params: Record = {}) => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v1/forceOrders", params), - positionMode: (params: Record = {}) => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v1/positionSide/dual", params), - changePositionMode: (params: Record) => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "POST", "/fapi/v1/positionSide/dual", params), - // User Data Stream - createListenKey: () => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "POST", "/fapi/v1/listenKey", {}), - keepAliveListenKey: () => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "PUT", "/fapi/v1/listenKey", {}), - closeListenKey: () => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "DELETE", "/fapi/v1/listenKey", {}) -}; + // Market Data + ping: () => makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/ping"), + time: () => makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/time"), + exchangeInfo: () => makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/exchangeInfo"), + depth: (params: Record) => + makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/depth", params), + trades: (params: Record) => + makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/trades", params), + historicalTrades: (params: Record) => + makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/historicalTrades", params), + aggTrades: (params: Record) => + makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/aggTrades", params), + klines: (params: Record) => + makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/klines", params), + continuousKlines: (params: Record) => + makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/continuousKlines", params), + indexPriceKlines: (params: Record) => + makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/indexPriceKlines", params), + markPriceKlines: (params: Record) => + makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/markPriceKlines", params), + premiumIndex: (params: Record = {}) => + makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/premiumIndex", params), + fundingRate: (params: Record) => + makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/fundingRate", params), + ticker24hr: (params: Record = {}) => + makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/ticker/24hr", params), + tickerPrice: (params: Record = {}) => + makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/ticker/price", params), + bookTicker: (params: Record = {}) => + makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/ticker/bookTicker", params), + openInterest: (params: Record) => + makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/openInterest", params), + // Account/Trade + newOrder: (params: Record) => + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "POST", "/fapi/v1/order", params), + batchOrders: (params: Record) => + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "POST", "/fapi/v1/batchOrders", params), + getOrder: (params: Record) => + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v1/order", params), + cancelOrder: (params: Record) => + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "DELETE", "/fapi/v1/order", params), + cancelAllOpenOrders: (params: Record) => + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "DELETE", "/fapi/v1/allOpenOrders", params), + cancelBatchOrders: (params: Record) => + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "DELETE", "/fapi/v1/batchOrders", params), + openOrders: (params: Record = {}) => + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v1/openOrders", params), + allOrders: (params: Record) => + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v1/allOrders", params), + balance: (params: Record = {}) => + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v2/balance", params), + account: (params: Record = {}) => + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v2/account", params), + leverage: (params: Record) => + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "POST", "/fapi/v1/leverage", params), + marginType: (params: Record) => + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "POST", "/fapi/v1/marginType", params), + positionMargin: (params: Record) => + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "POST", "/fapi/v1/positionMargin", params), + positionRisk: (params: Record = {}) => + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v2/positionRisk", params), + userTrades: (params: Record) => + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v1/userTrades", params), + income: (params: Record = {}) => + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v1/income", params), + commissionRate: (params: Record) => + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v1/commissionRate", params), + adlQuantile: (params: Record = {}) => + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v1/adlQuantile", params), + forceOrders: (params: Record = {}) => + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v1/forceOrders", params), + positionMode: (params: Record = {}) => + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v1/positionSide/dual", params), + changePositionMode: (params: Record) => + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "POST", "/fapi/v1/positionSide/dual", params), + // User Data Stream + createListenKey: () => + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "POST", "/fapi/v1/listenKey", {}), + keepAliveListenKey: () => + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "PUT", "/fapi/v1/listenKey", {}), + closeListenKey: () => + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "DELETE", "/fapi/v1/listenKey", {}), +} // Futures COIN-M client wrapper (delivery) export const deliveryClient = { - // Market Data - ping: () => makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/ping"), - time: () => makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/time"), - exchangeInfo: () => makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/exchangeInfo"), - depth: (params: Record) => makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/depth", params), - trades: (params: Record) => makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/trades", params), - historicalTrades: (params: Record) => makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/historicalTrades", params), - aggTrades: (params: Record) => makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/aggTrades", params), - klines: (params: Record) => makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/klines", params), - continuousKlines: (params: Record) => makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/continuousKlines", params), - indexPriceKlines: (params: Record) => makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/indexPriceKlines", params), - markPriceKlines: (params: Record) => makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/markPriceKlines", params), - premiumIndex: (params: Record = {}) => makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/premiumIndex", params), - fundingRate: (params: Record) => makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/fundingRate", params), - ticker24hr: (params: Record = {}) => makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/ticker/24hr", params), - tickerPrice: (params: Record = {}) => makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/ticker/price", params), - bookTicker: (params: Record = {}) => makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/ticker/bookTicker", params), - openInterest: (params: Record) => makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/openInterest", params), - // Account/Trade - newOrder: (params: Record) => makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "POST", "/dapi/v1/order", params), - batchOrders: (params: Record) => makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "POST", "/dapi/v1/batchOrders", params), - getOrder: (params: Record) => makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "GET", "/dapi/v1/order", params), - cancelOrder: (params: Record) => makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "DELETE", "/dapi/v1/order", params), - cancelAllOpenOrders: (params: Record) => makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "DELETE", "/dapi/v1/allOpenOrders", params), - cancelBatchOrders: (params: Record) => makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "DELETE", "/dapi/v1/batchOrders", params), - openOrders: (params: Record = {}) => makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "GET", "/dapi/v1/openOrders", params), - allOrders: (params: Record) => makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "GET", "/dapi/v1/allOrders", params), - balance: (params: Record = {}) => makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "GET", "/dapi/v1/balance", params), - account: (params: Record = {}) => makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "GET", "/dapi/v1/account", params), - leverage: (params: Record) => makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "POST", "/dapi/v1/leverage", params), - marginType: (params: Record) => makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "POST", "/dapi/v1/marginType", params), - positionMargin: (params: Record) => makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "POST", "/dapi/v1/positionMargin", params), - positionRisk: (params: Record = {}) => makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "GET", "/dapi/v1/positionRisk", params), - userTrades: (params: Record) => makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "GET", "/dapi/v1/userTrades", params), - income: (params: Record = {}) => makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "GET", "/dapi/v1/income", params), - commissionRate: (params: Record) => makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "GET", "/dapi/v1/commissionRate", params), - adlQuantile: (params: Record = {}) => makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "GET", "/dapi/v1/adlQuantile", params), - forceOrders: (params: Record = {}) => makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "GET", "/dapi/v1/forceOrders", params), - positionMode: (params: Record = {}) => makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "GET", "/dapi/v1/positionSide/dual", params), - changePositionMode: (params: Record) => makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "POST", "/dapi/v1/positionSide/dual", params), - // User Data Stream - createListenKey: () => makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "POST", "/dapi/v1/listenKey", {}), - keepAliveListenKey: () => makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "PUT", "/dapi/v1/listenKey", {}), - closeListenKey: () => makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "DELETE", "/dapi/v1/listenKey", {}) -}; + // Market Data + ping: () => makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/ping"), + time: () => makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/time"), + exchangeInfo: () => makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/exchangeInfo"), + depth: (params: Record) => + makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/depth", params), + trades: (params: Record) => + makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/trades", params), + historicalTrades: (params: Record) => + makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/historicalTrades", params), + aggTrades: (params: Record) => + makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/aggTrades", params), + klines: (params: Record) => + makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/klines", params), + continuousKlines: (params: Record) => + makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/continuousKlines", params), + indexPriceKlines: (params: Record) => + makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/indexPriceKlines", params), + markPriceKlines: (params: Record) => + makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/markPriceKlines", params), + premiumIndex: (params: Record = {}) => + makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/premiumIndex", params), + fundingRate: (params: Record) => + makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/fundingRate", params), + ticker24hr: (params: Record = {}) => + makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/ticker/24hr", params), + tickerPrice: (params: Record = {}) => + makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/ticker/price", params), + bookTicker: (params: Record = {}) => + makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/ticker/bookTicker", params), + openInterest: (params: Record) => + makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/openInterest", params), + // Account/Trade + newOrder: (params: Record) => + makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "POST", "/dapi/v1/order", params), + batchOrders: (params: Record) => + makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "POST", "/dapi/v1/batchOrders", params), + getOrder: (params: Record) => + makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "GET", "/dapi/v1/order", params), + cancelOrder: (params: Record) => + makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "DELETE", "/dapi/v1/order", params), + cancelAllOpenOrders: (params: Record) => + makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "DELETE", "/dapi/v1/allOpenOrders", params), + cancelBatchOrders: (params: Record) => + makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "DELETE", "/dapi/v1/batchOrders", params), + openOrders: (params: Record = {}) => + makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "GET", "/dapi/v1/openOrders", params), + allOrders: (params: Record) => + makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "GET", "/dapi/v1/allOrders", params), + balance: (params: Record = {}) => + makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "GET", "/dapi/v1/balance", params), + account: (params: Record = {}) => + makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "GET", "/dapi/v1/account", params), + leverage: (params: Record) => + makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "POST", "/dapi/v1/leverage", params), + marginType: (params: Record) => + makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "POST", "/dapi/v1/marginType", params), + positionMargin: (params: Record) => + makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "POST", "/dapi/v1/positionMargin", params), + positionRisk: (params: Record = {}) => + makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "GET", "/dapi/v1/positionRisk", params), + userTrades: (params: Record) => + makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "GET", "/dapi/v1/userTrades", params), + income: (params: Record = {}) => + makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "GET", "/dapi/v1/income", params), + commissionRate: (params: Record) => + makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "GET", "/dapi/v1/commissionRate", params), + adlQuantile: (params: Record = {}) => + makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "GET", "/dapi/v1/adlQuantile", params), + forceOrders: (params: Record = {}) => + makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "GET", "/dapi/v1/forceOrders", params), + positionMode: (params: Record = {}) => + makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "GET", "/dapi/v1/positionSide/dual", params), + changePositionMode: (params: Record) => + makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "POST", "/dapi/v1/positionSide/dual", params), + // User Data Stream + createListenKey: () => + makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "POST", "/dapi/v1/listenKey", {}), + keepAliveListenKey: () => + makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "PUT", "/dapi/v1/listenKey", {}), + closeListenKey: () => + makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "DELETE", "/dapi/v1/listenKey", {}), +} // Sub-Account client wrapper (using REST API) export const subAccountApiClient = { - createVirtualSubAccount: (params: Record) => - makeSignedRequest("POST", "/sapi/v1/sub-account/virtualSubAccount", params), - getSubAccountList: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/sub-account/list", params), - getSubAccountSpotSummary: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/sub-account/spotSummary", params), - getSubAccountStatus: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/sub-account/status", params), - getSubAccountAssets: (params: Record) => - makeSignedRequest("GET", "/sapi/v3/sub-account/assets", params), - enableMarginForSubAccount: (params: Record) => - makeSignedRequest("POST", "/sapi/v1/sub-account/margin/enable", params), - enableFuturesForSubAccount: (params: Record) => - makeSignedRequest("POST", "/sapi/v1/sub-account/futures/enable", params), - getSubAccountMarginSummary: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/sub-account/margin/accountSummary", params), - getSubAccountFuturesSummary: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v2/sub-account/futures/accountSummary", params), - getSubAccountFuturesPositionRisk: (params: Record) => - makeSignedRequest("GET", "/sapi/v2/sub-account/futures/positionRisk", params), - transferToSubAccount: (params: Record) => - makeSignedRequest("POST", "/sapi/v1/sub-account/transfer/subToSub", params), - transferToMaster: (params: Record) => - makeSignedRequest("POST", "/sapi/v1/sub-account/transfer/subToMaster", params), - subAccountUniversalTransfer: (params: Record) => - makeSignedRequest("POST", "/sapi/v1/sub-account/universalTransfer", params), - getSubAccountUniversalTransferHistory: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/sub-account/universalTransfer", params), - getSubAccountTransferHistory: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/sub-account/sub/transfer/history", params), - getSubAccountDepositAddress: (params: Record) => - makeSignedRequest("GET", "/sapi/v1/capital/deposit/subAddress", params), - getSubAccountDepositHistory: (params: Record = {}) => - makeSignedRequest("GET", "/sapi/v1/capital/deposit/subHisrec", params), - createSubAccountApiKey: (params: Record) => - makeSignedRequest("POST", "/sapi/v1/sub-account/subAccountApi/ipRestriction", params), - deleteSubAccountApiKey: (params: Record) => - makeSignedRequest("DELETE", "/sapi/v1/sub-account/subAccountApi/ipRestriction/ipList", params), - getSubAccountApiKeyIpRestriction: (params: Record) => - makeSignedRequest("GET", "/sapi/v1/sub-account/subAccountApi/ipRestriction", params), - updateSubAccountApiKeyIpRestriction: (params: Record) => - makeSignedRequest("POST", "/sapi/v1/sub-account/subAccountApi/ipRestriction", params) -}; + createVirtualSubAccount: (params: Record) => + makeSignedRequest("POST", "/sapi/v1/sub-account/virtualSubAccount", params), + getSubAccountList: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/sub-account/list", params), + getSubAccountSpotSummary: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/sub-account/spotSummary", params), + getSubAccountStatus: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/sub-account/status", params), + getSubAccountAssets: (params: Record) => + makeSignedRequest("GET", "/sapi/v3/sub-account/assets", params), + enableMarginForSubAccount: (params: Record) => + makeSignedRequest("POST", "/sapi/v1/sub-account/margin/enable", params), + enableFuturesForSubAccount: (params: Record) => + makeSignedRequest("POST", "/sapi/v1/sub-account/futures/enable", params), + getSubAccountMarginSummary: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/sub-account/margin/accountSummary", params), + getSubAccountFuturesSummary: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v2/sub-account/futures/accountSummary", params), + getSubAccountFuturesPositionRisk: (params: Record) => + makeSignedRequest("GET", "/sapi/v2/sub-account/futures/positionRisk", params), + transferToSubAccount: (params: Record) => + makeSignedRequest("POST", "/sapi/v1/sub-account/transfer/subToSub", params), + transferToMaster: (params: Record) => + makeSignedRequest("POST", "/sapi/v1/sub-account/transfer/subToMaster", params), + subAccountUniversalTransfer: (params: Record) => + makeSignedRequest("POST", "/sapi/v1/sub-account/universalTransfer", params), + getSubAccountUniversalTransferHistory: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/sub-account/universalTransfer", params), + getSubAccountTransferHistory: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/sub-account/sub/transfer/history", params), + getSubAccountDepositAddress: (params: Record) => + makeSignedRequest("GET", "/sapi/v1/capital/deposit/subAddress", params), + getSubAccountDepositHistory: (params: Record = {}) => + makeSignedRequest("GET", "/sapi/v1/capital/deposit/subHisrec", params), + createSubAccountApiKey: (params: Record) => + makeSignedRequest("POST", "/sapi/v1/sub-account/subAccountApi/ipRestriction", params), + deleteSubAccountApiKey: (params: Record) => + makeSignedRequest("DELETE", "/sapi/v1/sub-account/subAccountApi/ipRestriction/ipList", params), + getSubAccountApiKeyIpRestriction: (params: Record) => + makeSignedRequest("GET", "/sapi/v1/sub-account/subAccountApi/ipRestriction", params), + updateSubAccountApiKeyIpRestriction: (params: Record) => + makeSignedRequest("POST", "/sapi/v1/sub-account/subAccountApi/ipRestriction", params), +} // Options client wrapper -const OPTIONS_BASE_URL = "https://eapi.binance.com"; +const OPTIONS_BASE_URL = "https://eapi.binance.com" export const optionsClient = { - // Market Data - ping: () => makeFuturesPublicRequest(OPTIONS_BASE_URL, "/eapi/v1/ping"), - time: () => makeFuturesPublicRequest(OPTIONS_BASE_URL, "/eapi/v1/time"), - exchangeInfo: () => makeFuturesPublicRequest(OPTIONS_BASE_URL, "/eapi/v1/exchangeInfo"), - depth: (params: Record) => makeFuturesPublicRequest(OPTIONS_BASE_URL, "/eapi/v1/depth", params), - trades: (params: Record) => makeFuturesPublicRequest(OPTIONS_BASE_URL, "/eapi/v1/trades", params), - klines: (params: Record) => makeFuturesPublicRequest(OPTIONS_BASE_URL, "/eapi/v1/klines", params), - mark: (params: Record = {}) => makeFuturesPublicRequest(OPTIONS_BASE_URL, "/eapi/v1/mark", params), - ticker: (params: Record = {}) => makeFuturesPublicRequest(OPTIONS_BASE_URL, "/eapi/v1/ticker", params), - index: (params: Record) => makeFuturesPublicRequest(OPTIONS_BASE_URL, "/eapi/v1/index", params), - // Account/Trade - newOrder: (params: Record) => makeFuturesSignedRequest(OPTIONS_BASE_URL, "POST", "/eapi/v1/order", params), - batchOrders: (params: Record) => makeFuturesSignedRequest(OPTIONS_BASE_URL, "POST", "/eapi/v1/batchOrders", params), - cancelOrder: (params: Record) => makeFuturesSignedRequest(OPTIONS_BASE_URL, "DELETE", "/eapi/v1/order", params), - cancelBatchOrders: (params: Record) => makeFuturesSignedRequest(OPTIONS_BASE_URL, "DELETE", "/eapi/v1/batchOrders", params), - cancelAllOrders: (params: Record) => makeFuturesSignedRequest(OPTIONS_BASE_URL, "DELETE", "/eapi/v1/allOpenOrders", params), - getOrder: (params: Record) => makeFuturesSignedRequest(OPTIONS_BASE_URL, "GET", "/eapi/v1/order", params), - openOrders: (params: Record = {}) => makeFuturesSignedRequest(OPTIONS_BASE_URL, "GET", "/eapi/v1/openOrders", params), - historyOrders: (params: Record) => makeFuturesSignedRequest(OPTIONS_BASE_URL, "GET", "/eapi/v1/historyOrders", params), - position: (params: Record = {}) => makeFuturesSignedRequest(OPTIONS_BASE_URL, "GET", "/eapi/v1/position", params), - userTrades: (params: Record) => makeFuturesSignedRequest(OPTIONS_BASE_URL, "GET", "/eapi/v1/userTrades", params), - account: (params: Record = {}) => makeFuturesSignedRequest(OPTIONS_BASE_URL, "GET", "/eapi/v1/account", params), - exerciseRecord: (params: Record = {}) => makeFuturesSignedRequest(OPTIONS_BASE_URL, "GET", "/eapi/v1/exerciseRecord", params), - bill: (params: Record = {}) => makeFuturesSignedRequest(OPTIONS_BASE_URL, "GET", "/eapi/v1/bill", params), - // User Data Stream - createListenKey: () => makeFuturesSignedRequest(OPTIONS_BASE_URL, "POST", "/eapi/v1/listenKey", {}), - keepAliveListenKey: () => makeFuturesSignedRequest(OPTIONS_BASE_URL, "PUT", "/eapi/v1/listenKey", {}), - closeListenKey: () => makeFuturesSignedRequest(OPTIONS_BASE_URL, "DELETE", "/eapi/v1/listenKey", {}) -}; + // Market Data + ping: () => makeFuturesPublicRequest(OPTIONS_BASE_URL, "/eapi/v1/ping"), + time: () => makeFuturesPublicRequest(OPTIONS_BASE_URL, "/eapi/v1/time"), + exchangeInfo: () => makeFuturesPublicRequest(OPTIONS_BASE_URL, "/eapi/v1/exchangeInfo"), + depth: (params: Record) => + makeFuturesPublicRequest(OPTIONS_BASE_URL, "/eapi/v1/depth", params), + trades: (params: Record) => + makeFuturesPublicRequest(OPTIONS_BASE_URL, "/eapi/v1/trades", params), + klines: (params: Record) => + makeFuturesPublicRequest(OPTIONS_BASE_URL, "/eapi/v1/klines", params), + mark: (params: Record = {}) => + makeFuturesPublicRequest(OPTIONS_BASE_URL, "/eapi/v1/mark", params), + ticker: (params: Record = {}) => + makeFuturesPublicRequest(OPTIONS_BASE_URL, "/eapi/v1/ticker", params), + index: (params: Record) => + makeFuturesPublicRequest(OPTIONS_BASE_URL, "/eapi/v1/index", params), + // Account/Trade + newOrder: (params: Record) => + makeFuturesSignedRequest(OPTIONS_BASE_URL, "POST", "/eapi/v1/order", params), + batchOrders: (params: Record) => + makeFuturesSignedRequest(OPTIONS_BASE_URL, "POST", "/eapi/v1/batchOrders", params), + cancelOrder: (params: Record) => + makeFuturesSignedRequest(OPTIONS_BASE_URL, "DELETE", "/eapi/v1/order", params), + cancelBatchOrders: (params: Record) => + makeFuturesSignedRequest(OPTIONS_BASE_URL, "DELETE", "/eapi/v1/batchOrders", params), + cancelAllOrders: (params: Record) => + makeFuturesSignedRequest(OPTIONS_BASE_URL, "DELETE", "/eapi/v1/allOpenOrders", params), + getOrder: (params: Record) => + makeFuturesSignedRequest(OPTIONS_BASE_URL, "GET", "/eapi/v1/order", params), + openOrders: (params: Record = {}) => + makeFuturesSignedRequest(OPTIONS_BASE_URL, "GET", "/eapi/v1/openOrders", params), + historyOrders: (params: Record) => + makeFuturesSignedRequest(OPTIONS_BASE_URL, "GET", "/eapi/v1/historyOrders", params), + position: (params: Record = {}) => + makeFuturesSignedRequest(OPTIONS_BASE_URL, "GET", "/eapi/v1/position", params), + userTrades: (params: Record) => + makeFuturesSignedRequest(OPTIONS_BASE_URL, "GET", "/eapi/v1/userTrades", params), + account: (params: Record = {}) => + makeFuturesSignedRequest(OPTIONS_BASE_URL, "GET", "/eapi/v1/account", params), + exerciseRecord: (params: Record = {}) => + makeFuturesSignedRequest(OPTIONS_BASE_URL, "GET", "/eapi/v1/exerciseRecord", params), + bill: (params: Record = {}) => + makeFuturesSignedRequest(OPTIONS_BASE_URL, "GET", "/eapi/v1/bill", params), + // User Data Stream + createListenKey: () => + makeFuturesSignedRequest(OPTIONS_BASE_URL, "POST", "/eapi/v1/listenKey", {}), + keepAliveListenKey: () => + makeFuturesSignedRequest(OPTIONS_BASE_URL, "PUT", "/eapi/v1/listenKey", {}), + closeListenKey: () => + makeFuturesSignedRequest(OPTIONS_BASE_URL, "DELETE", "/eapi/v1/listenKey", {}), +} diff --git a/src/config/binanceUsClient.ts b/src/config/binanceUsClient.ts index a9c45e20..47861d97 100644 --- a/src/config/binanceUsClient.ts +++ b/src/config/binanceUsClient.ts @@ -1,17 +1,17 @@ // src/config/binanceUsClient.ts -import crypto from "crypto"; +import crypto from "crypto" /** * Binance.US API Client Configuration - * + * * Base URLs: * - REST API: https://api.binance.us * - WebSocket: wss://stream.binance.us:9443 - * + * * Authentication: * - API Key passed via X-MBX-APIKEY header * - Signature generated using HMAC SHA256 - * + * * Key Differences from Binance.com: * - US regulatory compliance * - No futures, margin, or lending @@ -25,11 +25,11 @@ export const BINANCE_US_CONFIG = { WS_URL: "wss://stream.binance.us:9443", DEFAULT_RECV_WINDOW: 5000, MAX_RECV_WINDOW: 60000, -} as const; +} as const -const API_KEY = process.env.BINANCE_US_API_KEY || ""; -const API_SECRET = process.env.BINANCE_US_API_SECRET || ""; -const BASE_URL = BINANCE_US_CONFIG.BASE_URL; +const API_KEY = process.env.BINANCE_US_API_KEY || "" +const API_SECRET = process.env.BINANCE_US_API_SECRET || "" +const BASE_URL = BINANCE_US_CONFIG.BASE_URL // ============================================================================ // Type Definitions @@ -37,205 +37,212 @@ const BASE_URL = BINANCE_US_CONFIG.BASE_URL; /** Rate limit information from API response headers */ export interface RateLimitInfo { - usedWeight: number; - weightLimit: number; - orderCount?: number; - retryAfter?: number; + usedWeight: number + weightLimit: number + orderCount?: number + retryAfter?: number } /** API response wrapper with rate limit info */ export interface BinanceUsResponse { - data: T; - rateLimitInfo?: RateLimitInfo; + data: T + rateLimitInfo?: RateLimitInfo } /** Ping response (empty object) */ -export interface PingResponse {} +export type PingResponse = Record /** Server time response */ export interface ServerTimeResponse { - serverTime: number; + serverTime: number } /** System status response */ export interface SystemStatusResponse { - status: 0 | 1; // 0: normal, 1: system maintenance + status: 0 | 1 // 0: normal, 1: system maintenance } /** Symbol information in exchange info */ export interface SymbolInfo { - symbol: string; - status: "PRE_TRADING" | "TRADING" | "POST_TRADING" | "END_OF_DAY" | "HALT" | "AUCTION_MATCH" | "BREAK"; - baseAsset: string; - baseAssetPrecision: number; - quoteAsset: string; - quotePrecision: number; - quoteAssetPrecision: number; - baseCommissionPrecision: number; - quoteCommissionPrecision: number; - orderTypes: string[]; - icebergAllowed: boolean; - ocoAllowed: boolean; - quoteOrderQtyMarketAllowed: boolean; - allowTrailingStop: boolean; - cancelReplaceAllowed: boolean; - isSpotTradingAllowed: boolean; - isMarginTradingAllowed: boolean; - filters: any[]; - permissions: string[]; + symbol: string + status: + | "PRE_TRADING" + | "TRADING" + | "POST_TRADING" + | "END_OF_DAY" + | "HALT" + | "AUCTION_MATCH" + | "BREAK" + baseAsset: string + baseAssetPrecision: number + quoteAsset: string + quotePrecision: number + quoteAssetPrecision: number + baseCommissionPrecision: number + quoteCommissionPrecision: number + orderTypes: string[] + icebergAllowed: boolean + ocoAllowed: boolean + quoteOrderQtyMarketAllowed: boolean + allowTrailingStop: boolean + cancelReplaceAllowed: boolean + isSpotTradingAllowed: boolean + isMarginTradingAllowed: boolean + filters: any[] + permissions: string[] } /** Exchange information response */ export interface ExchangeInfoResponse { - timezone: string; - serverTime: number; - rateLimits: any[]; - exchangeFilters: any[]; - symbols: SymbolInfo[]; - permissions: string[]; - defaultSelfTradePreventionMode?: string; - allowedSelfTradePreventionModes?: string[]; + timezone: string + serverTime: number + rateLimits: any[] + exchangeFilters: any[] + symbols: SymbolInfo[] + permissions: string[] + defaultSelfTradePreventionMode?: string + allowedSelfTradePreventionModes?: string[] } /** Order book response */ export interface OrderBookResponse { - lastUpdateId: number; - bids: [string, string][]; // [price, quantity][] - asks: [string, string][]; // [price, quantity][] + lastUpdateId: number + bids: [string, string][] // [price, quantity][] + asks: [string, string][] // [price, quantity][] } /** Trade response */ export interface TradeResponse { - id: number; - price: string; - qty: string; - quoteQty: string; - time: number; - isBuyerMaker: boolean; - isBestMatch: boolean; + id: number + price: string + qty: string + quoteQty: string + time: number + isBuyerMaker: boolean + isBestMatch: boolean } /** Aggregate trade response */ export interface AggTradeResponse { - a: number; // Aggregate tradeId - p: string; // Price - q: string; // Quantity - f: number; // First tradeId - l: number; // Last tradeId - T: number; // Timestamp - m: boolean; // Was the buyer the maker? - M: boolean; // Was the trade the best price match? + a: number // Aggregate tradeId + p: string // Price + q: string // Quantity + f: number // First tradeId + l: number // Last tradeId + T: number // Timestamp + m: boolean // Was the buyer the maker? + M: boolean // Was the trade the best price match? } /** Formatted aggregate trade (human-readable) */ export interface FormattedAggTrade { - aggregateTradeId: number; - price: string; - quantity: string; - firstTradeId: number; - lastTradeId: number; - timestamp: number; - timestampISO: string; - isBuyerMaker: boolean; - isBestMatch: boolean; + aggregateTradeId: number + price: string + quantity: string + firstTradeId: number + lastTradeId: number + timestamp: number + timestampISO: string + isBuyerMaker: boolean + isBestMatch: boolean } /** Raw kline data (array format from API) */ export type KlineRaw = [ - number, // 0: Open time - string, // 1: Open price - string, // 2: High price - string, // 3: Low price - string, // 4: Close price - string, // 5: Volume - number, // 6: Close time - string, // 7: Quote asset volume - number, // 8: Number of trades - string, // 9: Taker buy base asset volume - string, // 10: Taker buy quote asset volume - string // 11: Ignore -]; + number, // 0: Open time + string, // 1: Open price + string, // 2: High price + string, // 3: Low price + string, // 4: Close price + string, // 5: Volume + number, // 6: Close time + string, // 7: Quote asset volume + number, // 8: Number of trades + string, // 9: Taker buy base asset volume + string, // 10: Taker buy quote asset volume + string, // 11: Ignore +] /** Formatted kline (human-readable) */ export interface FormattedKline { - openTime: number; - openTimeISO: string; - open: string; - high: string; - low: string; - close: string; - volume: string; - closeTime: number; - closeTimeISO: string; - quoteAssetVolume: string; - numberOfTrades: number; - takerBuyBaseVolume: string; - takerBuyQuoteVolume: string; + openTime: number + openTimeISO: string + open: string + high: string + low: string + close: string + volume: string + closeTime: number + closeTimeISO: string + quoteAssetVolume: string + numberOfTrades: number + takerBuyBaseVolume: string + takerBuyQuoteVolume: string } /** Average price response */ export interface AvgPriceResponse { - mins: number; - price: string; + mins: number + price: string } /** Ticker price response */ export interface TickerPriceResponse { - symbol: string; - price: string; + symbol: string + price: string } /** Book ticker response */ export interface BookTickerResponse { - symbol: string; - bidPrice: string; - bidQty: string; - askPrice: string; - askQty: string; + symbol: string + bidPrice: string + bidQty: string + askPrice: string + askQty: string } /** 24hr ticker response */ export interface Ticker24hrResponse { - symbol: string; - priceChange: string; - priceChangePercent: string; - weightedAvgPrice: string; - prevClosePrice: string; - lastPrice: string; - lastQty: string; - bidPrice: string; - bidQty: string; - askPrice: string; - askQty: string; - openPrice: string; - highPrice: string; - lowPrice: string; - volume: string; - quoteVolume: string; - openTime: number; - closeTime: number; - firstId: number; - lastId: number; - count: number; + symbol: string + priceChange: string + priceChangePercent: string + weightedAvgPrice: string + prevClosePrice: string + lastPrice: string + lastQty: string + bidPrice: string + bidQty: string + askPrice: string + askQty: string + openPrice: string + highPrice: string + lowPrice: string + volume: string + quoteVolume: string + openTime: number + closeTime: number + firstId: number + lastId: number + count: number } /** Rolling window ticker response */ export interface RollingWindowTickerResponse { - symbol: string; - priceChange: string; - priceChangePercent: string; - weightedAvgPrice: string; - openPrice: string; - highPrice: string; - lowPrice: string; - lastPrice: string; - volume: string; - quoteVolume: string; - openTime: number; - closeTime: number; - firstId: number; - lastId: number; - count: number; + symbol: string + priceChange: string + priceChangePercent: string + weightedAvgPrice: string + openPrice: string + highPrice: string + lowPrice: string + lastPrice: string + volume: string + quoteVolume: string + openTime: number + closeTime: number + firstId: number + lastId: number + count: number } // ============================================================================ @@ -244,39 +251,39 @@ export interface RollingWindowTickerResponse { /** Custom error class for Binance.US API errors */ export class BinanceUsApiError extends Error { - constructor( - public readonly code: number, - message: string, - public readonly httpStatus: number, - public readonly rateLimitInfo?: RateLimitInfo - ) { - super(message); - this.name = "BinanceUsApiError"; - } + constructor( + public readonly code: number, + message: string, + public readonly httpStatus: number, + public readonly rateLimitInfo?: RateLimitInfo, + ) { + super(message) + this.name = "BinanceUsApiError" + } } /** Rate limit error (HTTP 429) */ export class RateLimitError extends BinanceUsApiError { - constructor( - message: string, - public readonly retryAfter: number, - rateLimitInfo?: RateLimitInfo - ) { - super(-1003, message, 429, rateLimitInfo); - this.name = "RateLimitError"; - } + constructor( + message: string, + public readonly retryAfter: number, + rateLimitInfo?: RateLimitInfo, + ) { + super(-1003, message, 429, rateLimitInfo) + this.name = "RateLimitError" + } } /** IP ban error (HTTP 418) */ export class IpBanError extends BinanceUsApiError { - constructor( - message: string, - public readonly retryAfter: number, - rateLimitInfo?: RateLimitInfo - ) { - super(-1003, message, 418, rateLimitInfo); - this.name = "IpBanError"; - } + constructor( + message: string, + public readonly retryAfter: number, + rateLimitInfo?: RateLimitInfo, + ) { + super(-1003, message, 418, rateLimitInfo) + this.name = "IpBanError" + } } // ============================================================================ @@ -287,96 +294,94 @@ export class IpBanError extends BinanceUsApiError { * Generate HMAC SHA256 signature for Binance.US API requests */ export function generateSignature(queryString: string): string { - return crypto - .createHmac("sha256", API_SECRET) - .update(queryString) - .digest("hex"); + return crypto.createHmac("sha256", API_SECRET).update(queryString).digest("hex") } /** * Build query string from parameters object */ export function buildQueryString(params: Record): string { - const filteredParams = Object.entries(params) - .filter(([_, value]) => value !== undefined && value !== null) - .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`) - .join("&"); - return filteredParams; + const filteredParams = Object.entries(params) + .filter(([_, value]) => value !== undefined && value !== null) + .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`) + .join("&") + + return filteredParams } /** * Check if API credentials are configured */ export function hasApiCredentials(): boolean { - return !!(API_KEY && API_SECRET); + return !!(API_KEY && API_SECRET) } /** * Check if API key is configured (for MARKET_DATA requests) */ export function hasApiKey(): boolean { - return !!API_KEY; + return !!API_KEY } /** * Get current timestamp in milliseconds */ export function getTimestamp(): number { - return Date.now(); + return Date.now() } /** * Parse rate limit info from response headers */ function parseRateLimitInfo(headers: Headers): RateLimitInfo | undefined { - const usedWeight = headers.get("X-MBX-USED-WEIGHT-1M"); - const retryAfter = headers.get("Retry-After"); - - if (!usedWeight && !retryAfter) return undefined; - - return { - usedWeight: usedWeight ? parseInt(usedWeight, 10) : 0, - weightLimit: 1200, // Default weight limit per minute - retryAfter: retryAfter ? parseInt(retryAfter, 10) : undefined, - }; + const usedWeight = headers.get("X-MBX-USED-WEIGHT-1M") + const retryAfter = headers.get("Retry-After") + + if (!usedWeight && !retryAfter) return undefined + + return { + usedWeight: usedWeight ? parseInt(usedWeight, 10) : 0, + weightLimit: 1200, // Default weight limit per minute + retryAfter: retryAfter ? parseInt(retryAfter, 10) : undefined, + } } /** * Format a kline array into a readable object */ export function formatKline(kline: KlineRaw): FormattedKline { - return { - openTime: kline[0], - openTimeISO: new Date(kline[0]).toISOString(), - open: kline[1], - high: kline[2], - low: kline[3], - close: kline[4], - volume: kline[5], - closeTime: kline[6], - closeTimeISO: new Date(kline[6]).toISOString(), - quoteAssetVolume: kline[7], - numberOfTrades: kline[8], - takerBuyBaseVolume: kline[9], - takerBuyQuoteVolume: kline[10], - }; + return { + openTime: kline[0], + openTimeISO: new Date(kline[0]).toISOString(), + open: kline[1], + high: kline[2], + low: kline[3], + close: kline[4], + volume: kline[5], + closeTime: kline[6], + closeTimeISO: new Date(kline[6]).toISOString(), + quoteAssetVolume: kline[7], + numberOfTrades: kline[8], + takerBuyBaseVolume: kline[9], + takerBuyQuoteVolume: kline[10], + } } /** * Format an aggregate trade into a readable object */ export function formatAggTrade(trade: AggTradeResponse): FormattedAggTrade { - return { - aggregateTradeId: trade.a, - price: trade.p, - quantity: trade.q, - firstTradeId: trade.f, - lastTradeId: trade.l, - timestamp: trade.T, - timestampISO: new Date(trade.T).toISOString(), - isBuyerMaker: trade.m, - isBestMatch: trade.M, - }; + return { + aggregateTradeId: trade.a, + price: trade.p, + quantity: trade.q, + firstTradeId: trade.f, + lastTradeId: trade.l, + timestamp: trade.T, + timestampISO: new Date(trade.T).toISOString(), + isBuyerMaker: trade.m, + isBestMatch: trade.M, + } } // ============================================================================ @@ -391,206 +396,203 @@ export function formatAggTrade(trade: AggTradeResponse): FormattedAggTrade { * @param recvWindow Optional receive window (default 5000, max 60000) */ export async function makeSignedRequest( - method: "GET" | "POST" | "PUT" | "DELETE", - endpoint: string, - params: Record = {}, - recvWindow: number = BINANCE_US_CONFIG.DEFAULT_RECV_WINDOW + method: "GET" | "POST" | "PUT" | "DELETE", + endpoint: string, + params: Record = {}, + recvWindow: number = BINANCE_US_CONFIG.DEFAULT_RECV_WINDOW, ): Promise { - // Validate credentials - if (!hasApiCredentials()) { - throw new BinanceUsApiError( - -2015, - "API credentials required. Set BINANCE_US_API_KEY and BINANCE_US_API_SECRET environment variables.", - 401 - ); - } - - // Validate recvWindow - if (recvWindow > BINANCE_US_CONFIG.MAX_RECV_WINDOW) { - recvWindow = BINANCE_US_CONFIG.MAX_RECV_WINDOW; - } - - // Add timestamp and recvWindow to params - const timestamp = Date.now(); - const paramsWithTimestamp = { ...params, timestamp, recvWindow }; - - // Build query string and generate signature - const queryString = buildQueryString(paramsWithTimestamp); - const signature = generateSignature(queryString); - const signedQueryString = `${queryString}&signature=${signature}`; - - // Build URL and headers - const url = method === "GET" || method === "DELETE" - ? `${BASE_URL}${endpoint}?${signedQueryString}` - : `${BASE_URL}${endpoint}`; - - const headers: HeadersInit = { - "X-MBX-APIKEY": API_KEY, - "Content-Type": "application/x-www-form-urlencoded" - }; - - const fetchOptions: RequestInit = { - method, - headers - }; - - // For POST and PUT requests, send data in body - if (method === "POST" || method === "PUT") { - fetchOptions.body = signedQueryString; - } - - const response = await fetch(url, fetchOptions); - const rateLimitInfo = parseRateLimitInfo(response.headers); - - // Handle rate limiting (429) - if (response.status === 429) { - const retryAfter = parseInt(response.headers.get("Retry-After") || "60", 10); - throw new RateLimitError( - `Rate limit exceeded. Retry after ${retryAfter} seconds.`, - retryAfter, - rateLimitInfo - ); - } - - // Handle IP ban (418) - if (response.status === 418) { - const retryAfter = parseInt(response.headers.get("Retry-After") || "120", 10); - throw new IpBanError( - `IP temporarily banned. Ban lifted after ${retryAfter} seconds.`, - retryAfter, - rateLimitInfo - ); - } - - if (!response.ok) { - const errorData = await response.json().catch(() => ({ msg: response.statusText })); - throw new BinanceUsApiError( - errorData.code || response.status, - errorData.msg || response.statusText, - response.status, - rateLimitInfo - ); - } - - return response.json(); + // Validate credentials + if (!hasApiCredentials()) { + throw new BinanceUsApiError( + -2015, + "API credentials required. Set BINANCE_US_API_KEY and BINANCE_US_API_SECRET environment variables.", + 401, + ) + } + + // Validate recvWindow + if (recvWindow > BINANCE_US_CONFIG.MAX_RECV_WINDOW) { + recvWindow = BINANCE_US_CONFIG.MAX_RECV_WINDOW + } + + // Add timestamp and recvWindow to params + const timestamp = Date.now() + const paramsWithTimestamp = { ...params, timestamp, recvWindow } + + // Build query string and generate signature + const queryString = buildQueryString(paramsWithTimestamp) + const signature = generateSignature(queryString) + const signedQueryString = `${queryString}&signature=${signature}` + + // Build URL and headers + const url = + method === "GET" || method === "DELETE" + ? `${BASE_URL}${endpoint}?${signedQueryString}` + : `${BASE_URL}${endpoint}` + + const headers: HeadersInit = { + "X-MBX-APIKEY": API_KEY, + "Content-Type": "application/x-www-form-urlencoded", + } + + const fetchOptions: RequestInit = { + method, + headers, + } + + // For POST and PUT requests, send data in body + if (method === "POST" || method === "PUT") { + fetchOptions.body = signedQueryString + } + + const response = await fetch(url, fetchOptions) + const rateLimitInfo = parseRateLimitInfo(response.headers) + + // Handle rate limiting (429) + if (response.status === 429) { + const retryAfter = parseInt(response.headers.get("Retry-After") || "60", 10) + throw new RateLimitError( + `Rate limit exceeded. Retry after ${retryAfter} seconds.`, + retryAfter, + rateLimitInfo, + ) + } + + // Handle IP ban (418) + if (response.status === 418) { + const retryAfter = parseInt(response.headers.get("Retry-After") || "120", 10) + throw new IpBanError( + `IP temporarily banned. Ban lifted after ${retryAfter} seconds.`, + retryAfter, + rateLimitInfo, + ) + } + + if (!response.ok) { + const errorData = await response.json().catch(() => ({ msg: response.statusText })) + throw new BinanceUsApiError( + errorData.code || response.status, + errorData.msg || response.statusText, + response.status, + rateLimitInfo, + ) + } + + return response.json() } /** * Make a public (unsigned) request to Binance.US API */ export async function makePublicRequest( - method: "GET", - endpoint: string, - params: Record = {} + method: "GET", + endpoint: string, + params: Record = {}, ): Promise { - const queryString = buildQueryString(params); - const url = queryString - ? `${BASE_URL}${endpoint}?${queryString}` - : `${BASE_URL}${endpoint}`; - - const response = await fetch(url, { method }); - const rateLimitInfo = parseRateLimitInfo(response.headers); - - // Handle rate limiting (429) - if (response.status === 429) { - const retryAfter = parseInt(response.headers.get("Retry-After") || "60", 10); - throw new RateLimitError( - `Rate limit exceeded. Retry after ${retryAfter} seconds.`, - retryAfter, - rateLimitInfo - ); - } - - // Handle IP ban (418) - if (response.status === 418) { - const retryAfter = parseInt(response.headers.get("Retry-After") || "120", 10); - throw new IpBanError( - `IP temporarily banned. Ban lifted after ${retryAfter} seconds.`, - retryAfter, - rateLimitInfo - ); - } - - if (!response.ok) { - const errorData = await response.json().catch(() => ({ msg: response.statusText })); - throw new BinanceUsApiError( - errorData.code || response.status, - errorData.msg || response.statusText, - response.status, - rateLimitInfo - ); - } - - return response.json(); + const queryString = buildQueryString(params) + const url = queryString ? `${BASE_URL}${endpoint}?${queryString}` : `${BASE_URL}${endpoint}` + + const response = await fetch(url, { method }) + const rateLimitInfo = parseRateLimitInfo(response.headers) + + // Handle rate limiting (429) + if (response.status === 429) { + const retryAfter = parseInt(response.headers.get("Retry-After") || "60", 10) + throw new RateLimitError( + `Rate limit exceeded. Retry after ${retryAfter} seconds.`, + retryAfter, + rateLimitInfo, + ) + } + + // Handle IP ban (418) + if (response.status === 418) { + const retryAfter = parseInt(response.headers.get("Retry-After") || "120", 10) + throw new IpBanError( + `IP temporarily banned. Ban lifted after ${retryAfter} seconds.`, + retryAfter, + rateLimitInfo, + ) + } + + if (!response.ok) { + const errorData = await response.json().catch(() => ({ msg: response.statusText })) + throw new BinanceUsApiError( + errorData.code || response.status, + errorData.msg || response.statusText, + response.status, + rateLimitInfo, + ) + } + + return response.json() } export const binanceUsConfig = { - apiKey: API_KEY, - apiSecret: API_SECRET, - baseUrl: BASE_URL, - wsUrl: BINANCE_US_CONFIG.WS_URL -}; + apiKey: API_KEY, + apiSecret: API_SECRET, + baseUrl: BASE_URL, + wsUrl: BINANCE_US_CONFIG.WS_URL, +} /** * Make a MARKET_DATA request (requires API key but no signature) */ export async function makeMarketDataRequest( - method: "GET", - endpoint: string, - params: Record = {} + method: "GET", + endpoint: string, + params: Record = {}, ): Promise { - // Validate API key - if (!hasApiKey()) { - throw new BinanceUsApiError( - -2015, - "API key required for MARKET_DATA endpoints. Set BINANCE_US_API_KEY environment variable.", - 401 - ); - } - - const queryString = buildQueryString(params); - const url = queryString - ? `${BASE_URL}${endpoint}?${queryString}` - : `${BASE_URL}${endpoint}`; - - const headers: HeadersInit = { - "X-MBX-APIKEY": API_KEY - }; - - const response = await fetch(url, { method, headers }); - const rateLimitInfo = parseRateLimitInfo(response.headers); - - // Handle rate limiting (429) - if (response.status === 429) { - const retryAfter = parseInt(response.headers.get("Retry-After") || "60", 10); - throw new RateLimitError( - `Rate limit exceeded. Retry after ${retryAfter} seconds.`, - retryAfter, - rateLimitInfo - ); - } - - // Handle IP ban (418) - if (response.status === 418) { - const retryAfter = parseInt(response.headers.get("Retry-After") || "120", 10); - throw new IpBanError( - `IP temporarily banned. Ban lifted after ${retryAfter} seconds.`, - retryAfter, - rateLimitInfo - ); - } - - if (!response.ok) { - const errorData = await response.json().catch(() => ({ msg: response.statusText })); - throw new BinanceUsApiError( - errorData.code || response.status, - errorData.msg || response.statusText, - response.status, - rateLimitInfo - ); - } - - return response.json(); + // Validate API key + if (!hasApiKey()) { + throw new BinanceUsApiError( + -2015, + "API key required for MARKET_DATA endpoints. Set BINANCE_US_API_KEY environment variable.", + 401, + ) + } + + const queryString = buildQueryString(params) + const url = queryString ? `${BASE_URL}${endpoint}?${queryString}` : `${BASE_URL}${endpoint}` + + const headers: HeadersInit = { + "X-MBX-APIKEY": API_KEY, + } + + const response = await fetch(url, { method, headers }) + const rateLimitInfo = parseRateLimitInfo(response.headers) + + // Handle rate limiting (429) + if (response.status === 429) { + const retryAfter = parseInt(response.headers.get("Retry-After") || "60", 10) + throw new RateLimitError( + `Rate limit exceeded. Retry after ${retryAfter} seconds.`, + retryAfter, + rateLimitInfo, + ) + } + + // Handle IP ban (418) + if (response.status === 418) { + const retryAfter = parseInt(response.headers.get("Retry-After") || "120", 10) + throw new IpBanError( + `IP temporarily banned. Ban lifted after ${retryAfter} seconds.`, + retryAfter, + rateLimitInfo, + ) + } + + if (!response.ok) { + const errorData = await response.json().catch(() => ({ msg: response.statusText })) + throw new BinanceUsApiError( + errorData.code || response.status, + errorData.msg || response.statusText, + response.status, + rateLimitInfo, + ) + } + + return response.json() } /** @@ -603,20 +605,20 @@ export async function makeMarketDataRequest( * @param recvWindow Optional receive window for signed requests (default 5000, max 60000) */ export async function binanceUsRequest( - method: "GET" | "POST" | "DELETE", - path: string, - params: Record = {}, - signed: boolean = false, - apiKeyRequired: boolean = false, - recvWindow?: number + method: "GET" | "POST" | "DELETE", + path: string, + params: Record = {}, + signed = false, + apiKeyRequired = false, + recvWindow?: number, ): Promise { - if (signed) { - return makeSignedRequest(method, path, params, recvWindow) as Promise; - } else if (apiKeyRequired) { - return makeMarketDataRequest("GET", path, params) as Promise; - } else { - return makePublicRequest("GET", path, params) as Promise; - } + if (signed) { + return makeSignedRequest(method, path, params, recvWindow) as Promise + } else if (apiKeyRequired) { + return makeMarketDataRequest("GET", path, params) as Promise + } else { + return makePublicRequest("GET", path, params) as Promise + } } // ============================================================================ @@ -624,26 +626,51 @@ export async function binanceUsRequest( // ============================================================================ /** Valid limit values for order book depth endpoint */ -export const ORDER_BOOK_VALID_LIMITS = [5, 10, 20, 50, 100, 500, 1000, 5000] as const; +export const ORDER_BOOK_VALID_LIMITS = [5, 10, 20, 50, 100, 500, 1000, 5000] as const /** Valid kline intervals */ export const KLINE_INTERVALS = [ - "1m", "3m", "5m", "15m", "30m", - "1h", "2h", "4h", "6h", "8h", "12h", - "1d", "3d", "1w", "1M" -] as const; + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", +] as const /** Valid rolling window sizes */ export const ROLLING_WINDOW_SIZES = [ - "1m", "2m", "3m", "4m", "5m", "15m", "30m", - "1h", "2h", "4h", "6h", "8h", "12h", - "1d", "3d", "7d" -] as const; + "1m", + "2m", + "3m", + "4m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "7d", +] as const /** Max results for trade endpoints */ -export const MAX_TRADES_LIMIT = 1000; -export const DEFAULT_TRADES_LIMIT = 500; +export const MAX_TRADES_LIMIT = 1000 +export const DEFAULT_TRADES_LIMIT = 500 /** Max results for klines endpoint */ -export const MAX_KLINES_LIMIT = 1000; -export const DEFAULT_KLINES_LIMIT = 500; +export const MAX_KLINES_LIMIT = 1000 +export const DEFAULT_KLINES_LIMIT = 500 diff --git a/src/config/client.ts b/src/config/client.ts index 51f03cd6..3e18250d 100644 --- a/src/config/client.ts +++ b/src/config/client.ts @@ -1,16 +1,15 @@ -import { Algo } from '@binance/algo'; -import { Spot } from '@binance/connector-typescript'; - -const API_KEY = process.env.BINANCE_API_KEY; -const API_SECRET = process.env.BINANCE_API_SECRET; -const BASE_URL = 'https://api.binance.com'; - -export const spotClient = new Spot(API_KEY, API_SECRET, { baseURL: BASE_URL }); -export const algoClient = new Algo({ - configurationRestAPI: { - apiKey: API_KEY ?? '', - apiSecret: API_SECRET ?? '', - basePath: BASE_URL, - } -}); - +import { Algo } from "@binance/algo" +import { Spot } from "@binance/connector-typescript" + +const API_KEY = process.env.BINANCE_API_KEY +const API_SECRET = process.env.BINANCE_API_SECRET +const BASE_URL = "https://api.binance.com" + +export const spotClient = new Spot(API_KEY, API_SECRET, { baseURL: BASE_URL }) +export const algoClient = new Algo({ + configurationRestAPI: { + apiKey: API_KEY ?? "", + apiSecret: API_SECRET ?? "", + basePath: BASE_URL, + }, +}) diff --git a/src/config/types.ts b/src/config/types.ts index c5435357..3bc6d4f1 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -5,481 +5,488 @@ * API Response wrapper */ export interface BinanceUsApiResponse { - success: boolean; - data?: T; - error?: BinanceUsApiError; + success: boolean + data?: T + error?: BinanceUsApiError } export interface BinanceUsApiError { - code: number; - msg: string; + code: number + msg: string } /** * Rate Limit Information */ export interface RateLimitInfo { - rateLimitType: "REQUEST_WEIGHT" | "ORDERS" | "RAW_REQUESTS"; - interval: "SECOND" | "MINUTE" | "HOUR" | "DAY"; - intervalNum: number; - limit: number; + rateLimitType: "REQUEST_WEIGHT" | "ORDERS" | "RAW_REQUESTS" + interval: "SECOND" | "MINUTE" | "HOUR" | "DAY" + intervalNum: number + limit: number } /** * Exchange Information */ export interface ExchangeInfo { - timezone: string; - serverTime: number; - rateLimits: RateLimitInfo[]; - exchangeFilters: unknown[]; - symbols: SymbolInfo[]; + timezone: string + serverTime: number + rateLimits: RateLimitInfo[] + exchangeFilters: unknown[] + symbols: SymbolInfo[] } export interface SymbolInfo { - symbol: string; - status: SymbolStatus; - baseAsset: string; - baseAssetPrecision: number; - quoteAsset: string; - quotePrecision: number; - quoteAssetPrecision: number; - orderTypes: OrderType[]; - icebergAllowed: boolean; - ocoAllowed: boolean; - quoteOrderQtyMarketAllowed: boolean; - allowTrailingStop: boolean; - cancelReplaceAllowed: boolean; - isSpotTradingAllowed: boolean; - isMarginTradingAllowed: boolean; - filters: SymbolFilter[]; - permissions: string[]; - defaultSelfTradePreventionMode: string; - allowedSelfTradePreventionModes: string[]; -} - -export type SymbolStatus = "PRE_TRADING" | "TRADING" | "POST_TRADING" | "END_OF_DAY" | "HALT" | "AUCTION_MATCH" | "BREAK"; - -export type OrderType = "LIMIT" | "MARKET" | "STOP_LOSS_LIMIT" | "TAKE_PROFIT_LIMIT" | "LIMIT_MAKER"; - -export type OrderSide = "BUY" | "SELL"; - -export type TimeInForce = "GTC" | "IOC" | "FOK"; - -export type OrderStatus = - | "NEW" - | "PARTIALLY_FILLED" - | "FILLED" - | "CANCELED" - | "PENDING_CANCEL" - | "REJECTED" - | "EXPIRED" - | "EXPIRED_IN_MATCH"; + symbol: string + status: SymbolStatus + baseAsset: string + baseAssetPrecision: number + quoteAsset: string + quotePrecision: number + quoteAssetPrecision: number + orderTypes: OrderType[] + icebergAllowed: boolean + ocoAllowed: boolean + quoteOrderQtyMarketAllowed: boolean + allowTrailingStop: boolean + cancelReplaceAllowed: boolean + isSpotTradingAllowed: boolean + isMarginTradingAllowed: boolean + filters: SymbolFilter[] + permissions: string[] + defaultSelfTradePreventionMode: string + allowedSelfTradePreventionModes: string[] +} + +export type SymbolStatus = + | "PRE_TRADING" + | "TRADING" + | "POST_TRADING" + | "END_OF_DAY" + | "HALT" + | "AUCTION_MATCH" + | "BREAK" + +export type OrderType = "LIMIT" | "MARKET" | "STOP_LOSS_LIMIT" | "TAKE_PROFIT_LIMIT" | "LIMIT_MAKER" + +export type OrderSide = "BUY" | "SELL" + +export type TimeInForce = "GTC" | "IOC" | "FOK" + +export type OrderStatus = + | "NEW" + | "PARTIALLY_FILLED" + | "FILLED" + | "CANCELED" + | "PENDING_CANCEL" + | "REJECTED" + | "EXPIRED" + | "EXPIRED_IN_MATCH" export interface SymbolFilter { - filterType: string; - [key: string]: unknown; + filterType: string + [key: string]: unknown } /** * Order Book */ export interface OrderBook { - lastUpdateId: number; - bids: [string, string][]; // [price, quantity][] - asks: [string, string][]; // [price, quantity][] + lastUpdateId: number + bids: [string, string][] // [price, quantity][] + asks: [string, string][] // [price, quantity][] } /** * Trade */ export interface Trade { - id: number; - price: string; - qty: string; - quoteQty: string; - time: number; - isBuyerMaker: boolean; - isBestMatch: boolean; + id: number + price: string + qty: string + quoteQty: string + time: number + isBuyerMaker: boolean + isBestMatch: boolean } /** * Aggregate Trade */ export interface AggregateTrade { - a: number; // Aggregate tradeId - p: string; // Price - q: string; // Quantity - f: number; // First tradeId - l: number; // Last tradeId - T: number; // Timestamp - m: boolean; // Was the buyer the maker? - M: boolean; // Was the trade the best price match? + a: number // Aggregate tradeId + p: string // Price + q: string // Quantity + f: number // First tradeId + l: number // Last tradeId + T: number // Timestamp + m: boolean // Was the buyer the maker? + M: boolean // Was the trade the best price match? } /** * Candlestick/Kline */ export type Kline = [ - number, // Open time - string, // Open - string, // High - string, // Low - string, // Close - string, // Volume - number, // Close time - string, // Quote asset volume - number, // Number of trades - string, // Taker buy base asset volume - string, // Taker buy quote asset volume - string // Ignore -]; + number, // Open time + string, // Open + string, // High + string, // Low + string, // Close + string, // Volume + number, // Close time + string, // Quote asset volume + number, // Number of trades + string, // Taker buy base asset volume + string, // Taker buy quote asset volume + string, // Ignore +] /** * 24hr Ticker */ export interface Ticker24hr { - symbol: string; - priceChange: string; - priceChangePercent: string; - weightedAvgPrice: string; - prevClosePrice: string; - lastPrice: string; - lastQty: string; - bidPrice: string; - bidQty: string; - askPrice: string; - askQty: string; - openPrice: string; - highPrice: string; - lowPrice: string; - volume: string; - quoteVolume: string; - openTime: number; - closeTime: number; - firstId: number; - lastId: number; - count: number; + symbol: string + priceChange: string + priceChangePercent: string + weightedAvgPrice: string + prevClosePrice: string + lastPrice: string + lastQty: string + bidPrice: string + bidQty: string + askPrice: string + askQty: string + openPrice: string + highPrice: string + lowPrice: string + volume: string + quoteVolume: string + openTime: number + closeTime: number + firstId: number + lastId: number + count: number } /** * Price Ticker */ export interface PriceTicker { - symbol: string; - price: string; + symbol: string + price: string } /** * Book Ticker */ export interface BookTicker { - symbol: string; - bidPrice: string; - bidQty: string; - askPrice: string; - askQty: string; + symbol: string + bidPrice: string + bidQty: string + askPrice: string + askQty: string } /** * Account Information */ export interface AccountInfo { - makerCommission: number; - takerCommission: number; - buyerCommission: number; - sellerCommission: number; + makerCommission: number + takerCommission: number + buyerCommission: number + sellerCommission: number commissionRates: { - maker: string; - taker: string; - buyer: string; - seller: string; - }; - canTrade: boolean; - canWithdraw: boolean; - canDeposit: boolean; - brokered: boolean; - requireSelfTradePrevention: boolean; - updateTime: number; - accountType: string; - balances: Balance[]; - permissions: string[]; - tradeGroupId?: number; + maker: string + taker: string + buyer: string + seller: string + } + canTrade: boolean + canWithdraw: boolean + canDeposit: boolean + brokered: boolean + requireSelfTradePrevention: boolean + updateTime: number + accountType: string + balances: Balance[] + permissions: string[] + tradeGroupId?: number } export interface Balance { - asset: string; - free: string; - locked: string; + asset: string + free: string + locked: string } /** * Order */ export interface Order { - symbol: string; - orderId: number; - orderListId: number; - clientOrderId: string; - transactTime?: number; - price: string; - origQty: string; - executedQty: string; - cummulativeQuoteQty: string; - status: OrderStatus; - timeInForce: TimeInForce; - type: OrderType; - side: OrderSide; - stopPrice?: string; - icebergQty?: string; - time: number; - updateTime: number; - isWorking: boolean; - workingTime?: number; - origQuoteOrderQty: string; - selfTradePreventionMode: string; - preventedMatchId?: number; - preventedQuantity?: string; + symbol: string + orderId: number + orderListId: number + clientOrderId: string + transactTime?: number + price: string + origQty: string + executedQty: string + cummulativeQuoteQty: string + status: OrderStatus + timeInForce: TimeInForce + type: OrderType + side: OrderSide + stopPrice?: string + icebergQty?: string + time: number + updateTime: number + isWorking: boolean + workingTime?: number + origQuoteOrderQty: string + selfTradePreventionMode: string + preventedMatchId?: number + preventedQuantity?: string } /** * OCO Order */ export interface OcoOrder { - orderListId: number; - contingencyType: string; - listStatusType: string; - listOrderStatus: string; - listClientOrderId: string; - transactionTime: number; - symbol: string; + orderListId: number + contingencyType: string + listStatusType: string + listOrderStatus: string + listClientOrderId: string + transactionTime: number + symbol: string orders: { - symbol: string; - orderId: number; - clientOrderId: string; - }[]; - orderReports?: Order[]; + symbol: string + orderId: number + clientOrderId: string + }[] + orderReports?: Order[] } /** * User Trade */ export interface UserTrade { - symbol: string; - id: number; - orderId: number; - orderListId: number; - price: string; - qty: string; - quoteQty: string; - commission: string; - commissionAsset: string; - time: number; - isBuyer: boolean; - isMaker: boolean; - isBestMatch: boolean; + symbol: string + id: number + orderId: number + orderListId: number + price: string + qty: string + quoteQty: string + commission: string + commissionAsset: string + time: number + isBuyer: boolean + isMaker: boolean + isBestMatch: boolean } /** * Deposit/Withdrawal */ export interface DepositHistory { - amount: string; - coin: string; - network: string; - status: number; - address: string; - addressTag: string; - txId: string; - insertTime: number; - transferType: number; - confirmTimes: string; + amount: string + coin: string + network: string + status: number + address: string + addressTag: string + txId: string + insertTime: number + transferType: number + confirmTimes: string } export interface WithdrawHistory { - address: string; - amount: string; - applyTime: string; - coin: string; - id: string; - withdrawOrderId?: string; - network: string; - transferType: number; - status: number; - transactionFee: string; - txId: string; - confirmNo?: number; + address: string + amount: string + applyTime: string + coin: string + id: string + withdrawOrderId?: string + network: string + transferType: number + status: number + transactionFee: string + txId: string + confirmNo?: number } /** * Asset Configuration */ export interface AssetConfig { - coin: string; - depositAllEnable: boolean; - withdrawAllEnable: boolean; - name: string; - free: string; - locked: string; - freeze: string; - withdrawing: string; - ipoing: string; - ipoable: string; - storage: string; - isLegalMoney: boolean; - trading: boolean; - networkList: NetworkInfo[]; + coin: string + depositAllEnable: boolean + withdrawAllEnable: boolean + name: string + free: string + locked: string + freeze: string + withdrawing: string + ipoing: string + ipoable: string + storage: string + isLegalMoney: boolean + trading: boolean + networkList: NetworkInfo[] } export interface NetworkInfo { - network: string; - coin: string; - withdrawIntegerMultiple: string; - isDefault: boolean; - depositEnable: boolean; - withdrawEnable: boolean; - depositDesc: string; - withdrawDesc: string; - specialTips: string; - specialWithdrawTips: string; - name: string; - resetAddressStatus: boolean; - addressRegex: string; - addressRule: string; - memoRegex: string; - withdrawFee: string; - withdrawMin: string; - withdrawMax: string; - minConfirm: number; - unLockConfirm: number; - sameAddress: boolean; - estimatedArrivalTime: number; - busy: boolean; - country: string; + network: string + coin: string + withdrawIntegerMultiple: string + isDefault: boolean + depositEnable: boolean + withdrawEnable: boolean + depositDesc: string + withdrawDesc: string + specialTips: string + specialWithdrawTips: string + name: string + resetAddressStatus: boolean + addressRegex: string + addressRule: string + memoRegex: string + withdrawFee: string + withdrawMin: string + withdrawMax: string + minConfirm: number + unLockConfirm: number + sameAddress: boolean + estimatedArrivalTime: number + busy: boolean + country: string } /** * Staking */ export interface StakingAsset { - stakingAsset: string; - rewardAsset: string; - apr: string; - apy: string; - unstakingPeriod: number; - minStakingAmount: string; - maxStakingAmount: string; - autoRestake: boolean; + stakingAsset: string + rewardAsset: string + apr: string + apy: string + unstakingPeriod: number + minStakingAmount: string + maxStakingAmount: string + autoRestake: boolean } export interface StakingBalance { - stakingAsset: string; - holdingInStaking: string; - pendingRedemption: string; + stakingAsset: string + holdingInStaking: string + pendingRedemption: string } /** * OTC Trading */ export interface OtcCoinPair { - fromCoin: string; - toCoin: string; - fromCoinMinAmount: string; - fromCoinMaxAmount: string; - toCoinMinAmount: string; - toCoinMaxAmount: string; + fromCoin: string + toCoin: string + fromCoinMinAmount: string + fromCoinMaxAmount: string + toCoinMinAmount: string + toCoinMaxAmount: string } export interface OtcQuote { - symbol: string; - ratio: string; - inverseRatio: string; - validTimestamp: number; - toAmount: string; - fromAmount: string; + symbol: string + ratio: string + inverseRatio: string + validTimestamp: number + toAmount: string + fromAmount: string } /** * User Data Stream */ export interface ListenKeyResponse { - listenKey: string; + listenKey: string } /** * Custodial Solution Types (Unique to Binance.US) */ export interface CustodialAccountInfo { - email: string; - canTrade: boolean; - canWithdraw: boolean; - canDeposit: boolean; - balances: Balance[]; + email: string + canTrade: boolean + canWithdraw: boolean + canDeposit: boolean + balances: Balance[] } export interface CustodialTransfer { - txnId: string; - clientTranId?: string; - asset: string; - amount: string; - fromEmail: string; - toEmail: string; - status: string; - timestamp: number; + txnId: string + clientTranId?: string + asset: string + amount: string + fromEmail: string + toEmail: string + status: string + timestamp: number } /** * Credit Line Types (Unique to Binance.US) */ export interface CreditLineAccount { - collaterals: CreditLineCollateral[]; - loans: CreditLineLoan[]; - creditLimit: string; - availableCredit: string; - usedCredit: string; - status: string; + collaterals: CreditLineCollateral[] + loans: CreditLineLoan[] + creditLimit: string + availableCredit: string + usedCredit: string + status: string } export interface CreditLineCollateral { - asset: string; - amount: string; - collateralValue: string; + asset: string + amount: string + collateralValue: string } export interface CreditLineLoan { - loanAsset: string; - loanAmount: string; - interestRate: string; - accrueInterest: string; + loanAsset: string + loanAmount: string + interestRate: string + accrueInterest: string } export interface CreditLineAlert { - alertId: string; - alertType: string; - alertTime: number; - message: string; + alertId: string + alertType: string + alertTime: number + message: string } /** * Sub-Account Types */ export interface SubAccount { - email: string; - isFreeze: boolean; - createTime: number; - isManagedSubAccount: boolean; - isAssetManagementSubAccount: boolean; + email: string + isFreeze: boolean + createTime: number + isManagedSubAccount: boolean + isAssetManagementSubAccount: boolean } export interface SubAccountTransfer { - tranId: number; - clientTranId?: string; - fromEmail: string; - toEmail: string; - asset: string; - amount: string; - timestamp: number; - status: string; + tranId: number + clientTranId?: string + fromEmail: string + toEmail: string + asset: string + amount: string + timestamp: number + status: string } /** @@ -506,6 +513,6 @@ export const ERROR_CODES = { BAD_API_KEY_FMT: -2014, REJECTED_MBX_KEY: -2015, ORDER_ARCHIVED: -2026, -} as const; +} as const -export type ErrorCode = typeof ERROR_CODES[keyof typeof ERROR_CODES]; +export type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES] diff --git a/src/index.ts b/src/index.ts index e5f7751a..10caa1f4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,72 +1,72 @@ -#!/usr/bin/env node -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" - -import { startSSEServer } from "./server/sse.js" -import { startStdioServer } from "./server/stdio.js" -import Logger from "./utils/logger.js" - -const args = process.argv.slice(2) - -// Transport mode flags -const sseMode = args.includes("--sse") || args.includes("-s") -// Default to stdio mode (for Claude Desktop) - -function printUsage() { - console.log(` -Binance MCP Server - -Usage: binance-mcp [options] - -Options: - --stdio, (default) Run in stdio mode (for Claude Desktop) - --sse, -s Run in SSE mode (HTTP) - -Environment Variables: - PORT Server port for SSE mode (default: 3002) - BINANCE_API_KEY Binance API key - BINANCE_API_SECRET Binance API secret - LOG_LEVEL Logging level (DEBUG, INFO, WARN, ERROR) - -Examples: - # Claude Desktop (stdio) - binance-mcp - - # SSE mode - binance-mcp --sse -`) -} - -async function main() { - if (args.includes("--help")) { - printUsage() - process.exit(0) - } - - let server: McpServer | undefined - - if (sseMode) { - Logger.info("Starting in SSE mode") - server = await startSSEServer() - } else { - // Default: stdio mode for Claude Desktop - server = await startStdioServer() - } - - if (!server) { - Logger.error("Failed to start server") - process.exit(1) - } - - const handleShutdown = async () => { - if ("close" in server && typeof server.close === "function") { - await server.close() - } - process.exit(0) - } - - // Handle process termination - process.on("SIGINT", handleShutdown) - process.on("SIGTERM", handleShutdown) -} - -main() +#!/usr/bin/env node +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { startSSEServer } from "./server/sse.js" +import { startStdioServer } from "./server/stdio.js" +import Logger from "./utils/logger.js" + +const args = process.argv.slice(2) + +// Transport mode flags +const sseMode = args.includes("--sse") || args.includes("-s") +// Default to stdio mode (for Claude Desktop) + +function printUsage() { + console.log(` +Binance MCP Server + +Usage: binance-mcp [options] + +Options: + --stdio, (default) Run in stdio mode (for Claude Desktop) + --sse, -s Run in SSE mode (HTTP) + +Environment Variables: + PORT Server port for SSE mode (default: 3002) + BINANCE_API_KEY Binance API key + BINANCE_API_SECRET Binance API secret + LOG_LEVEL Logging level (DEBUG, INFO, WARN, ERROR) + +Examples: + # Claude Desktop (stdio) + binance-mcp + + # SSE mode + binance-mcp --sse +`) +} + +async function main() { + if (args.includes("--help")) { + printUsage() + process.exit(0) + } + + let server: McpServer | undefined + + if (sseMode) { + Logger.info("Starting in SSE mode") + server = await startSSEServer() + } else { + // Default: stdio mode for Claude Desktop + server = await startStdioServer() + } + + if (!server) { + Logger.error("Failed to start server") + process.exit(1) + } + + const handleShutdown = async () => { + if ("close" in server && typeof server.close === "function") { + await server.close() + } + process.exit(0) + } + + // Handle process termination + process.on("SIGINT", handleShutdown) + process.on("SIGTERM", handleShutdown) +} + +main() diff --git a/src/init.ts b/src/init.ts index f8de7ba9..eff41cbd 100644 --- a/src/init.ts +++ b/src/init.ts @@ -1,161 +1,181 @@ -import prompts, { PromptObject } from 'prompts'; -import figlet from 'figlet'; -import chalk from 'chalk'; -import path from 'path'; -import fs from 'fs-extra'; -import os from 'os'; -import { fileURLToPath } from 'url'; +import type { PromptObject } from "prompts" -import dotenv from "dotenv"; -dotenv.config(); +import os from "os" +import path from "path" +import { fileURLToPath } from "url" + +import chalk from "chalk" +import dotenv from "dotenv" +import figlet from "figlet" +import fs from "fs-extra" +import prompts from "prompts" +dotenv.config() // Binance Gold Color -const yellow = chalk.hex('#F0B90B'); +const yellow = chalk.hex("#F0B90B") // ESModule __dirname workaround -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); +const __filename = fileURLToPath(import.meta.url) +const __dirname = path.dirname(__filename) // Cancel handler const onCancel = () => { - console.log(chalk.red('\n❌ Configuration cancelled by user (Ctrl+C or ESC). Exiting...')); - process.exit(0); -}; + console.log(chalk.red("\n❌ Configuration cancelled by user (Ctrl+C or ESC). Exiting...")) + process.exit(0) +} // Show Banner const showBanner = () => { - const banner = figlet.textSync('Binance MCP ', { font: 'Big' }); - console.log(yellow(banner)); - console.log(yellow('🚀 Welcome to the Binance MCP Configurator\n')); -}; + const banner = figlet.textSync("Binance MCP ", { font: "Big" }) + console.log(yellow(banner)) + console.log(yellow("🚀 Welcome to the Binance MCP Configurator\n")) +} // User Input Types interface UserInputs { - BINANCE_API_KEY: string; - BINANCE_API_SECRET: string; + BINANCE_API_KEY: string + BINANCE_API_SECRET: string } // Ask for credentials const getInputs = async (): Promise => { - const questions: PromptObject[] = [ - { - type: 'password', - name: 'BINANCE_API_KEY', - message: '🔑Enter your BINANCE API KEY:', - validate: (val: string) => - val.trim() === '' ? 'BINANCE API KEY is required!' : true, - }, - { - type: 'password', - name: 'BINANCE_API_SECRET', - message: ' 🔐 Enter your BINANCE API SECRET:', - validate: (val: string) => - val.trim() === '' ? 'BINANCE API SECRET is required!' : true, - }, - ]; - - return await prompts(questions, { onCancel }) as UserInputs; -}; + const questions: PromptObject[] = [ + { + type: "password", + name: "BINANCE_API_KEY", + message: "🔑Enter your BINANCE API KEY:", + validate: (val: string) => (val.trim() === "" ? "BINANCE API KEY is required!" : true), + }, + { + type: "password", + name: "BINANCE_API_SECRET", + message: " 🔐 Enter your BINANCE API SECRET:", + validate: (val: string) => (val.trim() === "" ? "BINANCE API SECRET is required!" : true), + }, + ] + + return (await prompts(questions, { onCancel })) as UserInputs +} // Generate .env file -const generateEnvFile = async (BINANCE_API_KEY: string, BINANCE_API_SECRET: string,): Promise => { - const envContent = ` +const generateEnvFile = async ( + BINANCE_API_KEY: string, + BINANCE_API_SECRET: string, +): Promise => { + const envContent = ` BINANCE_API_KEY=${BINANCE_API_KEY} BINANCE_API_SECRET=${BINANCE_API_SECRET} -`.trim(); +`.trim() - await fs.writeFile('.env', envContent); - console.log(yellow('✅ .env file generated.')); -}; + await fs.writeFile(".env", envContent) + console.log(yellow("✅ .env file generated.")) +} // Generate config object -const generateConfig = async (BINANCE_API_KEY: string, BINANCE_API_SECRET: string,): Promise => { - const indexPath = path.resolve(__dirname, '..', 'build', 'index.js'); // one level up from cli/ - - return { - 'binance-mcp': { - command: 'node', - args: [indexPath], - env: { - BINANCE_API_KEY: BINANCE_API_KEY, - BINANCE_API_SECRET: BINANCE_API_SECRET, - }, - disabled: false, - autoApprove: [] - } - }; -}; +const generateConfig = async ( + BINANCE_API_KEY: string, + BINANCE_API_SECRET: string, +): Promise => { + const indexPath = path.resolve(__dirname, "..", "build", "index.js") // one level up from cli/ + + return { + "binance-mcp": { + command: "bun", + args: ["run", indexPath], + env: { + BINANCE_API_KEY: BINANCE_API_KEY, + BINANCE_API_SECRET: BINANCE_API_SECRET, + }, + disabled: false, + autoApprove: [], + }, + } +} // Configure Claude Desktop const configureClaude = async (config: object): Promise => { - const userHome = os.homedir(); - let claudePath; - const platform = os.platform(); - if (platform == "darwin") { - claudePath = path.join(userHome, 'Library/Application Support/Claude/claude_desktop_config.json'); - } else if (platform == "win32") { - claudePath = path.join(userHome, 'AppData', 'Roaming', 'Claude', 'claude_desktop_config.json'); - } else { - console.log(chalk.red('❌ Unsupported platform.')); - return false; + const userHome = os.homedir() + let claudePath + const platform = os.platform() + if (platform == "darwin") { + claudePath = path.join( + userHome, + "Library/Application Support/Claude/claude_desktop_config.json", + ) + } else if (platform == "win32") { + claudePath = path.join(userHome, "AppData", "Roaming", "Claude", "claude_desktop_config.json") + } else { + console.log(chalk.red("❌ Unsupported platform.")) + + return false + } + + if (!fs.existsSync(claudePath)) { + console.log( + chalk.yellow( + "⚠️ Claude config file not found. Creating a new one with default configuration.", + ), + ) + // Create a default configuration object + const defaultConfig = { + mcpServers: {}, } - - if (!fs.existsSync(claudePath)) { - console.log(chalk.yellow('⚠️ Claude config file not found. Creating a new one with default configuration.')); - // Create a default configuration object - const defaultConfig = { - mcpServers: {} - }; - // Write the default configuration to the file - await fs.writeJSON(claudePath, defaultConfig, { spaces: 2 }); - } - - - const jsonData = fs.readFileSync(claudePath, 'utf8'); - const data = JSON.parse(jsonData); - - data.mcpServers = { - ...data.mcpServers, - ...config, - }; - - await fs.writeJSON(claudePath, data, { spaces: 2 }); - console.log(yellow('✅ Binance MCP configured for Claude Desktop. Please RESTART your Claude to enjoy it 🎉')); - return true; -}; + // Write the default configuration to the file + await fs.writeJSON(claudePath, defaultConfig, { spaces: 2 }) + } + + const jsonData = fs.readFileSync(claudePath, "utf8") + const data = JSON.parse(jsonData) + + data.mcpServers = { + ...data.mcpServers, + ...config, + } + + await fs.writeJSON(claudePath, data, { spaces: 2 }) + console.log( + yellow( + "✅ Binance MCP configured for Claude Desktop. Please RESTART your Claude to enjoy it 🎉", + ), + ) + + return true +} // Save fallback config file const saveFallbackConfig = async (config: object): Promise => { - await fs.writeJSON('config.json', config, { spaces: 2 }); - console.log(yellow('📁 Saved config.json in root project folder.')); -}; + await fs.writeJSON("config.json", config, { spaces: 2 }) + console.log(yellow("📁 Saved config.json in root project folder.")) +} // Main logic const init = async () => { - showBanner(); - - const { BINANCE_API_KEY, BINANCE_API_SECRET } = await getInputs(); + showBanner() + const { BINANCE_API_KEY, BINANCE_API_SECRET } = await getInputs() - await generateEnvFile(BINANCE_API_KEY, BINANCE_API_SECRET); + await generateEnvFile(BINANCE_API_KEY, BINANCE_API_SECRET) - const config = await generateConfig(BINANCE_API_KEY, BINANCE_API_SECRET); + const config = await generateConfig(BINANCE_API_KEY, BINANCE_API_SECRET) - const { setupClaude } = await prompts({ - type: 'confirm', - name: 'setupClaude', - message: '🧠 Do you want to configure in Claude Desktop?', - initial: true - }, { onCancel }); + const { setupClaude } = await prompts( + { + type: "confirm", + name: "setupClaude", + message: "🧠 Do you want to configure in Claude Desktop?", + initial: true, + }, + { onCancel }, + ) - if (setupClaude) { - const success = await configureClaude(config); - if (!success) { - await saveFallbackConfig(config); - } - } else { - await saveFallbackConfig(config); + if (setupClaude) { + const success = await configureClaude(config) + if (!success) { + await saveFallbackConfig(config) } -}; + } else { + await saveFallbackConfig(config) + } +} -init(); \ No newline at end of file +init() diff --git a/src/modules/algo/future-algo/TwapNewTrade.ts b/src/modules/algo/future-algo/TwapNewTrade.ts index 2bae1220..4be4e66d 100644 --- a/src/modules/algo/future-algo/TwapNewTrade.ts +++ b/src/modules/algo/future-algo/TwapNewTrade.ts @@ -1,81 +1,92 @@ // src/tools/binance-algo/future-algo/TwapNewTrade.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { algoClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { algoClient } from "../../../config/binanceClient.js" export function registerBinanceTwapNewTrade(server: McpServer) { - server.tool( - "BinanceTimeWeightedAveragePriceNewOrder", - "The Time-Weighted Average Price (TWAP) New Order API allows users to place a TWAP order on USDⓈ-M Contracts in Binance Futures. TWAP orders execute gradually over a specified duration to achieve a better average execution price while minimizing market impact.", - { - symbol: z.string().describe("Trading symbol (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Trading side (BUY or SELL)"), - positionSide: z - .enum(["BOTH", "LONG", "SHORT"]) - .optional() - .describe("Default BOTH for One-way Mode; LONG or SHORT for Hedge Mode. Must be sent in Hedge Mode."), - quantity: z - .number() - .positive() - .min(1000) - .max(1000000) - .describe("Quantity of base asset; Notional must be between 1,000 and 1,000,000 USDT"), - duration: z - .number() - .int() - .min(300) - .max(86400) - .describe("Duration for TWAP orders in seconds. Must be between 300 and 86400"), - clientAlgoId: z.string().length(32).optional().describe("A unique 32-character ID among Algo orders"), - reduceOnly: z - .boolean() - .optional() - .describe("true or false. Default false; Cannot be sent in Hedge Mode or when opening a position"), - limitPrice: z - .number() - .positive() - .optional() - .describe("Limit price of the order; Defaults to market price if not sent"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await algoClient.restAPI.timeWeightedAveragePriceFutureAlgo({ - symbol: params.symbol, - side: params.side, - quantity: params.quantity, - duration: params.duration, - ...(params.positionSide && { positionSide: params.positionSide }), - ...(params.clientAlgoId && { clientAlgoId: params.clientAlgoId }), - ...(params.reduceOnly !== undefined && { reduceOnly: params.reduceOnly }), - ...(params.limitPrice !== undefined && { limitPrice: params.limitPrice }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceTimeWeightedAveragePriceNewOrder", + "The Time-Weighted Average Price (TWAP) New Order API allows users to place a TWAP order on USDⓈ-M Contracts in Binance Futures. TWAP orders execute gradually over a specified duration to achieve a better average execution price while minimizing market impact.", + { + symbol: z.string().describe("Trading symbol (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Trading side (BUY or SELL)"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe( + "Default BOTH for One-way Mode; LONG or SHORT for Hedge Mode. Must be sent in Hedge Mode.", + ), + quantity: z + .number() + .positive() + .min(1000) + .max(1000000) + .describe("Quantity of base asset; Notional must be between 1,000 and 1,000,000 USDT"), + duration: z + .number() + .int() + .min(300) + .max(86400) + .describe("Duration for TWAP orders in seconds. Must be between 300 and 86400"), + clientAlgoId: z + .string() + .length(32) + .optional() + .describe("A unique 32-character ID among Algo orders"), + reduceOnly: z + .boolean() + .optional() + .describe( + "true or false. Default false; Cannot be sent in Hedge Mode or when opening a position", + ), + limitPrice: z + .number() + .positive() + .optional() + .describe("Limit price of the order; Defaults to market price if not sent"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await algoClient.restAPI.timeWeightedAveragePriceFutureAlgo({ + symbol: params.symbol, + side: params.side, + quantity: params.quantity, + duration: params.duration, + ...(params.positionSide && { positionSide: params.positionSide }), + ...(params.clientAlgoId && { clientAlgoId: params.clientAlgoId }), + ...(params.reduceOnly !== undefined && { reduceOnly: params.reduceOnly }), + ...(params.limitPrice !== undefined && { limitPrice: params.limitPrice }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `TWAP order on USDⓈ-M Contracts placed successfully for ${ + params.symbol + }. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `TWAP order on USDⓈ-M Contracts placed successfully for ${ - params.symbol - }. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to place a TWAP order on: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to place a TWAP order on: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/algo/future-algo/VPNewTrade.ts b/src/modules/algo/future-algo/VPNewTrade.ts index 904623be..d9ab7294 100644 --- a/src/modules/algo/future-algo/VPNewTrade.ts +++ b/src/modules/algo/future-algo/VPNewTrade.ts @@ -1,78 +1,87 @@ // src/tools/binance-algo/future-algo/VPNewTrade.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { algoClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { algoClient } from "../../../config/binanceClient.js" export function registerBinanceVPNewTrade(server: McpServer) { - server.tool( - "BinanceVolumeParticipationNewTrade", - "The Volume Participation (VP) New Order API allows users to place a VP order on USDⓈ-M Contracts in Binance Futures.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Trading side (BUY or SELL)"), - positionSide: z - .enum(["BOTH", "LONG", "SHORT"]) - .optional() - .describe( - "Default BOTH for One-way Mode; LONG or SHORT for Hedge Mode. It must be sent in Hedge Mode." - ), - quantity: z - .number() - .positive() - .min(10000) - .max(1000000) - .describe("Quantity of base asset; Notional must be between 10,000 and 1,000,000 USDT"), - urgency: z.enum(["LOW", "MEDIUM", "HIGH"]).describe("Execution speed: LOW, MEDIUM, HIGH"), - clientAlgoId: z.string().length(32).optional().describe("A unique 32-character ID among Algo orders"), - reduceOnly: z - .boolean() - .optional() - .describe("true or false. Default false; Cannot be sent in Hedge Mode or when opening a position"), - limitPrice: z - .number() - .positive() - .optional() - .describe("Limit price of the order; Defaults to market price if not sent"), - recvWindow: z.number().int().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await algoClient.restAPI.volumeParticipationFutureAlgo({ - symbol: params.symbol, - side: params.side, - quantity: params.quantity, - urgency: params.urgency, - ...(params.positionSide && { positionSide: params.positionSide }), - ...(params.clientAlgoId && { clientAlgoId: params.clientAlgoId }), - ...(params.reduceOnly !== undefined && { reduceOnly: params.reduceOnly }), - ...(params.limitPrice !== undefined && { limitPrice: params.limitPrice }), - recvWindow: params.recvWindow - }); + server.tool( + "BinanceVolumeParticipationNewTrade", + "The Volume Participation (VP) New Order API allows users to place a VP order on USDⓈ-M Contracts in Binance Futures.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Trading side (BUY or SELL)"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe( + "Default BOTH for One-way Mode; LONG or SHORT for Hedge Mode. It must be sent in Hedge Mode.", + ), + quantity: z + .number() + .positive() + .min(10000) + .max(1000000) + .describe("Quantity of base asset; Notional must be between 10,000 and 1,000,000 USDT"), + urgency: z.enum(["LOW", "MEDIUM", "HIGH"]).describe("Execution speed: LOW, MEDIUM, HIGH"), + clientAlgoId: z + .string() + .length(32) + .optional() + .describe("A unique 32-character ID among Algo orders"), + reduceOnly: z + .boolean() + .optional() + .describe( + "true or false. Default false; Cannot be sent in Hedge Mode or when opening a position", + ), + limitPrice: z + .number() + .positive() + .optional() + .describe("Limit price of the order; Defaults to market price if not sent"), + recvWindow: z.number().int().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await algoClient.restAPI.volumeParticipationFutureAlgo({ + symbol: params.symbol, + side: params.side, + quantity: params.quantity, + urgency: params.urgency, + ...(params.positionSide && { positionSide: params.positionSide }), + ...(params.clientAlgoId && { clientAlgoId: params.clientAlgoId }), + ...(params.reduceOnly !== undefined && { reduceOnly: params.reduceOnly }), + ...(params.limitPrice !== undefined && { limitPrice: params.limitPrice }), + recvWindow: params.recvWindow, + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `VP order on USDⓈ-M Contracts placed successfully for ${ + params.symbol + }. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `VP order on USDⓈ-M Contracts placed successfully for ${ - params.symbol - }. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to place a VP order: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to place a VP order: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/algo/future-algo/cancelAlgoOrder.ts b/src/modules/algo/future-algo/cancelAlgoOrder.ts index cc80a4a3..e068f8bb 100644 --- a/src/modules/algo/future-algo/cancelAlgoOrder.ts +++ b/src/modules/algo/future-algo/cancelAlgoOrder.ts @@ -1,45 +1,48 @@ // src/tools/binance-algo/future-algo/cancelAlgoOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { algoClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { algoClient } from "../../../config/binanceClient.js" export function registerBinanceFutureCancelAlgoOrder(server: McpServer) { - server.tool( - "BinanceFutureCancelAlgoOrder", - "The Cancel Algo Order API allows users to cancel an active algorithmic order on USDⓈ-M Contracts in Binance Futures.", - { - algoId: z.number().int().describe("Algo order ID (e.g., 14511)"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await algoClient.restAPI.cancelAlgoOrderFutureAlgo({ - algoId: params.algoId, - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceFutureCancelAlgoOrder", + "The Cancel Algo Order API allows users to cancel an active algorithmic order on USDⓈ-M Contracts in Binance Futures.", + { + algoId: z.number().int().describe("Algo order ID (e.g., 14511)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await algoClient.restAPI.cancelAlgoOrderFutureAlgo({ + algoId: params.algoId, + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Algo order ${params.algoId} canceled successfully. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Algo order ${params.algoId} canceled successfully. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to cancel Algo Order: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to cancel Algo Order: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/algo/future-algo/currentAlgoOpenOrders.ts b/src/modules/algo/future-algo/currentAlgoOpenOrders.ts index 14a2de89..39890130 100644 --- a/src/modules/algo/future-algo/currentAlgoOpenOrders.ts +++ b/src/modules/algo/future-algo/currentAlgoOpenOrders.ts @@ -1,43 +1,46 @@ // src/tools/binance-algo/future-algo/currentAlgoOpenOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { algoClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { algoClient } from "../../../config/binanceClient.js" export function registerBinanceFutureCurrentAlgoOpenOrders(server: McpServer) { - server.tool( - "BinanceFutureCurrentAlgoOpenOrders", - "The Query Current Algo Open Orders API retrieves a list of currently active algorithmic orders for USDⓈ-M Contracts in Binance Futures.", - { - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await algoClient.restAPI.queryCurrentAlgoOpenOrdersFutureAlgo({ - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceFutureCurrentAlgoOpenOrders", + "The Query Current Algo Open Orders API retrieves a list of currently active algorithmic orders for USDⓈ-M Contracts in Binance Futures.", + { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await algoClient.restAPI.queryCurrentAlgoOpenOrdersFutureAlgo({ + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Currently active algorithmic orders. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Currently active algorithmic orders. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to Query Current Algo Open Orders: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to Query Current Algo Open Orders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/algo/future-algo/historicalAlgoOrder.ts b/src/modules/algo/future-algo/historicalAlgoOrder.ts index bf3f942d..50583309 100644 --- a/src/modules/algo/future-algo/historicalAlgoOrder.ts +++ b/src/modules/algo/future-algo/historicalAlgoOrder.ts @@ -1,62 +1,73 @@ // src/tools/binance-algo/future-algo/historicalAlgoOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { algoClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { algoClient } from "../../../config/binanceClient.js" export function registerBinanceFutureHistoricalAlgoOrder(server: McpServer) { - server.tool( - "BinanceFutureHistoricalAlgoOrder", - "The Query Historical Algo Orders API retrieves a list of past algorithmic orders for USDⓈ-M Contracts in Binance Futures.", - { - symbol: z.string().optional().describe("Trading symbol (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).optional().describe("Trading side (BUY or SELL)"), - startTime: z.number().int().optional().describe("Start time in milliseconds (e.g., 1641522717552)"), - endTime: z.number().int().optional().describe("End time in milliseconds (e.g., 1641522526562)"), - page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), - pageSize: z - .number() - .int() - .min(1) - .max(100) - .default(100) - .optional() - .describe("Number of results per page, MIN 1, MAX 100, default is 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await algoClient.restAPI.queryHistoricalAlgoOrdersFutureAlgo({ - ...(params.symbol !== undefined && { symbol: params.symbol }), - ...(params.side !== undefined && { side: params.side }), - ...(params.startTime !== undefined && { startTime: params.startTime }), - ...(params.endTime !== undefined && { endTime: params.endTime }), - ...(params.page !== undefined && { page: params.page }), - ...(params.pageSize !== undefined && { pageSize: params.pageSize }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceFutureHistoricalAlgoOrder", + "The Query Historical Algo Orders API retrieves a list of past algorithmic orders for USDⓈ-M Contracts in Binance Futures.", + { + symbol: z.string().optional().describe("Trading symbol (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).optional().describe("Trading side (BUY or SELL)"), + startTime: z + .number() + .int() + .optional() + .describe("Start time in milliseconds (e.g., 1641522717552)"), + endTime: z + .number() + .int() + .optional() + .describe("End time in milliseconds (e.g., 1641522526562)"), + page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), + pageSize: z + .number() + .int() + .min(1) + .max(100) + .default(100) + .optional() + .describe("Number of results per page, MIN 1, MAX 100, default is 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await algoClient.restAPI.queryHistoricalAlgoOrdersFutureAlgo({ + ...(params.symbol !== undefined && { symbol: params.symbol }), + ...(params.side !== undefined && { side: params.side }), + ...(params.startTime !== undefined && { startTime: params.startTime }), + ...(params.endTime !== undefined && { endTime: params.endTime }), + ...(params.page !== undefined && { page: params.page }), + ...(params.pageSize !== undefined && { pageSize: params.pageSize }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Historical Algo Orders retrieves successfully. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Historical Algo Orders retrieves successfully. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to Query Historical Algo Orders: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to Query Historical Algo Orders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/algo/future-algo/index.ts b/src/modules/algo/future-algo/index.ts index 9dfdc703..4369d2aa 100644 --- a/src/modules/algo/future-algo/index.ts +++ b/src/modules/algo/future-algo/index.ts @@ -1,28 +1,29 @@ // src/tools/binance-spot/market-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceVPNewTrade } from "./VPNewTrade.js"; -import { registerBinanceFutureHistoricalAlgoOrder } from "./historicalAlgoOrder.js"; -import { registerBinanceFutureCancelAlgoOrder } from "./cancelAlgoOrder.js"; -import { registerBinanceFutureCurrentAlgoOpenOrders } from "./currentAlgoOpenOrders.js"; -import { registerBinanceFutureSubOrders } from "./subOrders.js"; -import { registerBinanceTwapNewTrade } from "./TwapNewTrade.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceFutureCancelAlgoOrder } from "./cancelAlgoOrder.js" +import { registerBinanceFutureCurrentAlgoOpenOrders } from "./currentAlgoOpenOrders.js" +import { registerBinanceFutureHistoricalAlgoOrder } from "./historicalAlgoOrder.js" +import { registerBinanceFutureSubOrders } from "./subOrders.js" +import { registerBinanceTwapNewTrade } from "./TwapNewTrade.js" +import { registerBinanceVPNewTrade } from "./VPNewTrade.js" export function registerBinanceAlgoFutureApiTools(server: McpServer) { - // Registers a new VP (Volume Participation) trade - registerBinanceVPNewTrade(server); + // Registers a new VP (Volume Participation) trade + registerBinanceVPNewTrade(server) - // Registers a new TWAP (Time-Weighted Average Price) trade - registerBinanceTwapNewTrade(server); + // Registers a new TWAP (Time-Weighted Average Price) trade + registerBinanceTwapNewTrade(server) - // Registers functionality to cancel an algorithmic order - registerBinanceFutureCancelAlgoOrder(server); + // Registers functionality to cancel an algorithmic order + registerBinanceFutureCancelAlgoOrder(server) - // Registers API to query sub-orders of an algorithmic order - registerBinanceFutureSubOrders(server); + // Registers API to query sub-orders of an algorithmic order + registerBinanceFutureSubOrders(server) - // Registers API to retrieve currently open algorithmic orders - registerBinanceFutureCurrentAlgoOpenOrders(server); + // Registers API to retrieve currently open algorithmic orders + registerBinanceFutureCurrentAlgoOpenOrders(server) - // Registers API to fetch historical algorithmic orders - registerBinanceFutureHistoricalAlgoOrder(server); + // Registers API to fetch historical algorithmic orders + registerBinanceFutureHistoricalAlgoOrder(server) } diff --git a/src/modules/algo/future-algo/subOrders.ts b/src/modules/algo/future-algo/subOrders.ts index cb334943..4a46a1d7 100644 --- a/src/modules/algo/future-algo/subOrders.ts +++ b/src/modules/algo/future-algo/subOrders.ts @@ -1,58 +1,61 @@ // src/tools/binance-algo/future-algo/subOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { algoClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { algoClient } from "../../../config/binanceClient.js" export function registerBinanceFutureSubOrders(server: McpServer) { - server.tool( - "BinanceFutureSubOrders", - "The Sub Orders API retrieves sub-orders associated with a specified algoId for USDⓈ-M Contracts in Binance Futures.", - { - algoId: z.number().int().describe("Algo order ID"), - page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), - pageSize: z - .number() - .int() - .min(1) - .max(100) - .default(100) - .optional() - .describe("Number of results per page, MIN 1, MAX 100, default is 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await algoClient.restAPI.querySubOrdersFutureAlgo({ - algoId: params.algoId, - page: params.page, - pageSize: params.pageSize, - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceFutureSubOrders", + "The Sub Orders API retrieves sub-orders associated with a specified algoId for USDⓈ-M Contracts in Binance Futures.", + { + algoId: z.number().int().describe("Algo order ID"), + page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), + pageSize: z + .number() + .int() + .min(1) + .max(100) + .default(100) + .optional() + .describe("Number of results per page, MIN 1, MAX 100, default is 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await algoClient.restAPI.querySubOrdersFutureAlgo({ + algoId: params.algoId, + page: params.page, + pageSize: params.pageSize, + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Sub Orders retrieved successfully for id ${ + params.algoId + }. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Sub Orders retrieved successfully for id ${ - params.algoId - }. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve retrieve sub-orders: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve retrieve sub-orders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/algo/index.ts b/src/modules/algo/index.ts index 864916a6..4dae6dbb 100644 --- a/src/modules/algo/index.ts +++ b/src/modules/algo/index.ts @@ -1,13 +1,14 @@ // src/tools/binance-spot/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceAlgoFutureApiTools } from "./future-algo/index.js"; -import { registerBinanceAlgoSpotApiTools } from "./spot-algo/index.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceAlgoFutureApiTools } from "./future-algo/index.js" +import { registerBinanceAlgoSpotApiTools } from "./spot-algo/index.js" export function registerBinanceAlgoTools(server: McpServer) { - // Algo API tools - registerBinanceAlgoFutureApiTools(server); - registerBinanceAlgoSpotApiTools(server); + // Algo API tools + registerBinanceAlgoFutureApiTools(server) + registerBinanceAlgoSpotApiTools(server) } // Alias for binance.ts compatibility -export { registerBinanceAlgoTools as registerAlgo }; +export { registerBinanceAlgoTools as registerAlgo } diff --git a/src/modules/algo/spot-algo/cancelOpenTWAPOrder.ts b/src/modules/algo/spot-algo/cancelOpenTWAPOrder.ts index d69c2904..3517999e 100644 --- a/src/modules/algo/spot-algo/cancelOpenTWAPOrder.ts +++ b/src/modules/algo/spot-algo/cancelOpenTWAPOrder.ts @@ -1,45 +1,48 @@ // src/tools/binance-algo/spot-algo/cancelOpenTWAPOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { algoClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { algoClient } from "../../../config/binanceClient.js" export function registerBinanceSpotCancelOpenTWAPOrder(server: McpServer) { - server.tool( - "BinanceSpotCancelOpenTWAPOrder", - "The Cancel Algo Order API allows users to cancel an open TWAP algorithmic order for spot trading on Binance.", - { - algoId: z.number().int().describe("Algo order ID (e.g., 14511)"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await algoClient.restAPI.cancelAlgoOrderSpotAlgo({ - algoId: params.algoId, - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSpotCancelOpenTWAPOrder", + "The Cancel Algo Order API allows users to cancel an open TWAP algorithmic order for spot trading on Binance.", + { + algoId: z.number().int().describe("Algo order ID (e.g., 14511)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await algoClient.restAPI.cancelAlgoOrderSpotAlgo({ + algoId: params.algoId, + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Algo order ${params.algoId} canceled successfully. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Algo order ${params.algoId} canceled successfully. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to Cancel Algo Order: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to Cancel Algo Order: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/algo/spot-algo/currentAlgoOpenOrders.ts b/src/modules/algo/spot-algo/currentAlgoOpenOrders.ts index c47bc2cc..14b6d6cc 100644 --- a/src/modules/algo/spot-algo/currentAlgoOpenOrders.ts +++ b/src/modules/algo/spot-algo/currentAlgoOpenOrders.ts @@ -1,45 +1,48 @@ // src/tools/binance-algo/spot-algo/currentAlgoOpenOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { algoClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { algoClient } from "../../../config/binanceClient.js" export function registerBinanceSpotCurrentAlgoOpenOrders(server: McpServer) { - server.tool( - "BinanceSpotCurrentAlgoOpenOrders", - "This API retrieves all open SPOT TWAP (Time-Weighted Average Price) orders on Binance.", - { - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await algoClient.restAPI.queryCurrentAlgoOpenOrdersSpotAlgo({ - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSpotCurrentAlgoOpenOrders", + "This API retrieves all open SPOT TWAP (Time-Weighted Average Price) orders on Binance.", + { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await algoClient.restAPI.queryCurrentAlgoOpenOrdersSpotAlgo({ + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieve all open SPOT TWAP (Time-Weighted Average Price) orders. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieve all open SPOT TWAP (Time-Weighted Average Price) orders. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieves all open SPOT TWAP: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieves all open SPOT TWAP: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/algo/spot-algo/historicalAlgoOrders.ts b/src/modules/algo/spot-algo/historicalAlgoOrders.ts index aa95a22e..543a9c62 100644 --- a/src/modules/algo/spot-algo/historicalAlgoOrders.ts +++ b/src/modules/algo/spot-algo/historicalAlgoOrders.ts @@ -1,64 +1,75 @@ // src/tools/binance-algo/spot-algo/historicalAlgoOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { algoClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { algoClient } from "../../../config/binanceClient.js" export function registerBinanceSpotHistoricalAlgoOrders(server: McpServer) { - server.tool( - "BinanceSpotHistoricalAlgoOrders", - "This API retrieves all historical SPOT TWAP (Time-Weighted Average Price) orders from Binance.", - { - symbol: z.string().optional().describe("Trading symbol (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).optional().describe("Trading side (BUY or SELL)"), - startTime: z.number().int().optional().describe("Start time in milliseconds (e.g., 1641522717552)"), - endTime: z.number().int().optional().describe("End time in milliseconds (e.g., 1641522526562)"), - page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), - pageSize: z - .number() - .int() - .min(1) - .max(100) - .default(100) - .optional() - .describe("Number of results per page, MIN 1, MAX 100, default is 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await algoClient.restAPI.queryHistoricalAlgoOrdersSpotAlgo({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.side && { side: params.side }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.page && { page: params.page }), - ...(params.pageSize && { pageSize: params.pageSize }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSpotHistoricalAlgoOrders", + "This API retrieves all historical SPOT TWAP (Time-Weighted Average Price) orders from Binance.", + { + symbol: z.string().optional().describe("Trading symbol (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).optional().describe("Trading side (BUY or SELL)"), + startTime: z + .number() + .int() + .optional() + .describe("Start time in milliseconds (e.g., 1641522717552)"), + endTime: z + .number() + .int() + .optional() + .describe("End time in milliseconds (e.g., 1641522526562)"), + page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), + pageSize: z + .number() + .int() + .min(1) + .max(100) + .default(100) + .optional() + .describe("Number of results per page, MIN 1, MAX 100, default is 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await algoClient.restAPI.queryHistoricalAlgoOrdersSpotAlgo({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.side && { side: params.side }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.page && { page: params.page }), + ...(params.pageSize && { pageSize: params.pageSize }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieves all historical SPOT TWAP (Time-Weighted Average Price) orders from Binance. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieves all historical SPOT TWAP (Time-Weighted Average Price) orders from Binance. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve all historical SPOT TWAP: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve all historical SPOT TWAP: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/algo/spot-algo/index.ts b/src/modules/algo/spot-algo/index.ts index d43c1f94..a8f1e420 100644 --- a/src/modules/algo/spot-algo/index.ts +++ b/src/modules/algo/spot-algo/index.ts @@ -1,24 +1,25 @@ // src/tools/binance-spot/market-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceSpotTwapNewTrade } from "./spotTWAPOrder.js"; -import { registerBinanceSpotCancelOpenTWAPOrder } from "./cancelOpenTWAPOrder.js"; -import { registerBinanceSpotSubOrders } from "./subOrders.js"; -import { registerBinanceSpotCurrentAlgoOpenOrders } from "./currentAlgoOpenOrders.js"; -import { registerBinanceSpotHistoricalAlgoOrders } from "./historicalAlgoOrders.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceSpotCancelOpenTWAPOrder } from "./cancelOpenTWAPOrder.js" +import { registerBinanceSpotCurrentAlgoOpenOrders } from "./currentAlgoOpenOrders.js" +import { registerBinanceSpotHistoricalAlgoOrders } from "./historicalAlgoOrders.js" +import { registerBinanceSpotTwapNewTrade } from "./spotTWAPOrder.js" +import { registerBinanceSpotSubOrders } from "./subOrders.js" export function registerBinanceAlgoSpotApiTools(server: McpServer) { - // Register the TWAP (Time-Weighted Average Price) tool for placing new spot algo orders - registerBinanceSpotTwapNewTrade(server); + // Register the TWAP (Time-Weighted Average Price) tool for placing new spot algo orders + registerBinanceSpotTwapNewTrade(server) - // Register the tool for canceling open TWAP spot algo orders - registerBinanceSpotCancelOpenTWAPOrder(server); + // Register the tool for canceling open TWAP spot algo orders + registerBinanceSpotCancelOpenTWAPOrder(server) - // Register the tool to handle sub-orders created under a parent algo order - registerBinanceSpotSubOrders(server); + // Register the tool to handle sub-orders created under a parent algo order + registerBinanceSpotSubOrders(server) - // Register the tool to fetch currently open algo orders for spot trading - registerBinanceSpotCurrentAlgoOpenOrders(server); + // Register the tool to fetch currently open algo orders for spot trading + registerBinanceSpotCurrentAlgoOpenOrders(server) - // Register the tool to fetch historical algo orders for spot trading - registerBinanceSpotHistoricalAlgoOrders(server); + // Register the tool to fetch historical algo orders for spot trading + registerBinanceSpotHistoricalAlgoOrders(server) } diff --git a/src/modules/algo/spot-algo/spotTWAPOrder.ts b/src/modules/algo/spot-algo/spotTWAPOrder.ts index 60b6f055..03510e6c 100644 --- a/src/modules/algo/spot-algo/spotTWAPOrder.ts +++ b/src/modules/algo/spot-algo/spotTWAPOrder.ts @@ -1,73 +1,78 @@ // src/tools/binance-algo/spot-algo/spotTwapNewTrade.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { algoClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { algoClient } from "../../../config/binanceClient.js" export function registerBinanceSpotTwapNewTrade(server: McpServer) { - server.tool( - "BinanceSpotTimeWeightedAveragePriceNewOrder", - "The TWAP (Time-Weighted Average Price) New Order API allows users to place TWAP algorithmic orders for USDⓈ-M Futures on Binance.", - { - symbol: z.string().describe("Trading symbol (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Trading side (BUY or SELL)"), - quantity: z - .number() - .positive() - .describe( - "Quantity of base asset; Maximum notional per order is 200k, 2mm, or 10mm, depending on the symbol" - ), - duration: z - .number() - .int() - .min(300) - .max(86400) - .describe("Duration for TWAP orders in seconds. Must be between 300 and 86400"), - clientAlgoId: z - .string() - .length(32) - .optional() - .describe("A unique 32-character ID among Algo orders. If not sent, a default value will be assigned"), - limitPrice: z - .number() - .positive() - .optional() - .describe("Limit price of the order; Defaults to market price if not sent") - }, - async (params) => { - try { - const response = await algoClient.restAPI.timeWeightedAveragePriceSpotAlgo({ - symbol: params.symbol, - side: params.side, - quantity: params.quantity, - duration: params.duration, - ...(params.clientAlgoId !== undefined && { clientAlgoId: params.clientAlgoId }), - ...(params.limitPrice !== undefined && { limitPrice: params.limitPrice }) - }); + server.tool( + "BinanceSpotTimeWeightedAveragePriceNewOrder", + "The TWAP (Time-Weighted Average Price) New Order API allows users to place TWAP algorithmic orders for USDⓈ-M Futures on Binance.", + { + symbol: z.string().describe("Trading symbol (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Trading side (BUY or SELL)"), + quantity: z + .number() + .positive() + .describe( + "Quantity of base asset; Maximum notional per order is 200k, 2mm, or 10mm, depending on the symbol", + ), + duration: z + .number() + .int() + .min(300) + .max(86400) + .describe("Duration for TWAP orders in seconds. Must be between 300 and 86400"), + clientAlgoId: z + .string() + .length(32) + .optional() + .describe( + "A unique 32-character ID among Algo orders. If not sent, a default value will be assigned", + ), + limitPrice: z + .number() + .positive() + .optional() + .describe("Limit price of the order; Defaults to market price if not sent"), + }, + async (params) => { + try { + const response = await algoClient.restAPI.timeWeightedAveragePriceSpotAlgo({ + symbol: params.symbol, + side: params.side, + quantity: params.quantity, + duration: params.duration, + ...(params.clientAlgoId !== undefined && { clientAlgoId: params.clientAlgoId }), + ...(params.limitPrice !== undefined && { limitPrice: params.limitPrice }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `TWAP order on USDⓈ-M Contracts placed successfully for ${ + params.symbol + }. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `TWAP order on USDⓈ-M Contracts placed successfully for ${ - params.symbol - }. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to place TWAP algorithmic orders for USDⓈ-M Futures on Binance: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to place TWAP algorithmic orders for USDⓈ-M Futures on Binance: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/algo/spot-algo/subOrders.ts b/src/modules/algo/spot-algo/subOrders.ts index 6836d7b4..2c7ac0c4 100644 --- a/src/modules/algo/spot-algo/subOrders.ts +++ b/src/modules/algo/spot-algo/subOrders.ts @@ -1,58 +1,61 @@ // src/tools/binance-algo/spot-algo/subOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { algoClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { algoClient } from "../../../config/binanceClient.js" export function registerBinanceSpotSubOrders(server: McpServer) { - server.tool( - "BinanceSpotSubOrders", - "The Query Sub Orders API retrieves details of sub-orders associated with a specific algorithmic (Algo) order for spot trading on Binance.", - { - algoId: z.number().int().describe("Algo order ID"), - page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), - pageSize: z - .number() - .int() - .min(1) - .max(100) - .default(100) - .optional() - .describe("Number of results per page, MIN 1, MAX 100, default is 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await algoClient.restAPI.querySubOrdersSpotAlgo({ - algoId: params.algoId, - ...(params.page !== undefined && { page: params.page }), - ...(params.pageSize !== undefined && { pageSize: params.pageSize }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSpotSubOrders", + "The Query Sub Orders API retrieves details of sub-orders associated with a specific algorithmic (Algo) order for spot trading on Binance.", + { + algoId: z.number().int().describe("Algo order ID"), + page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), + pageSize: z + .number() + .int() + .min(1) + .max(100) + .default(100) + .optional() + .describe("Number of results per page, MIN 1, MAX 100, default is 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await algoClient.restAPI.querySubOrdersSpotAlgo({ + algoId: params.algoId, + ...(params.page !== undefined && { page: params.page }), + ...(params.pageSize !== undefined && { pageSize: params.pageSize }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Sub Orders retrieved successfully for id${params.algoId}. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Sub Orders retrieved successfully for id${params.algoId}. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to Query Sub Orders: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to Query Sub Orders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/auto-invest/changePlanStatus.ts b/src/modules/auto-invest/changePlanStatus.ts index 182a20e8..c8a51a7b 100644 --- a/src/modules/auto-invest/changePlanStatus.ts +++ b/src/modules/auto-invest/changePlanStatus.ts @@ -5,47 +5,56 @@ * @license Apache-2.0 */ // src/modules/auto-invest/changePlanStatus.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { autoInvestClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerAutoInvestChangePlanStatus(server: McpServer) { - server.tool( - "BinanceAutoInvestChangePlanStatus", - "Change the status of an auto-invest plan (pause or resume).", - { - planId: z.number().int().describe("Plan ID to modify"), - status: z.enum(["ONGOING", "PAUSED"]).describe("New status (ONGOING to resume, PAUSED to pause)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await autoInvestClient.restAPI.planEditStatus({ - planId: params.planId, - status: params.status, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - const statusText = params.status === "ONGOING" ? "resumed" : "paused"; - - return { - content: [{ - type: "text", - text: `✅ Auto-invest plan ${statusText}!\n\nPlan ID: ${params.planId}\nNew Status: ${params.status}\n\nResponse: ${JSON.stringify(data)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to change auto-invest plan status: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceAutoInvestChangePlanStatus", + "Change the status of an auto-invest plan (pause or resume).", + { + planId: z.number().int().describe("Plan ID to modify"), + status: z + .enum(["ONGOING", "PAUSED"]) + .describe("New status (ONGOING to resume, PAUSED to pause)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await autoInvestClient.restAPI.planEditStatus({ + planId: params.planId, + status: params.status, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + const statusText = params.status === "ONGOING" ? "resumed" : "paused" + + return { + content: [ + { + type: "text", + text: `✅ Auto-invest plan ${statusText}!\n\nPlan ID: ${params.planId}\nNew Status: ${params.status}\n\nResponse: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to change auto-invest plan status: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/auto-invest/createPlan.ts b/src/modules/auto-invest/createPlan.ts index 6f33f73e..1ef727e4 100644 --- a/src/modules/auto-invest/createPlan.ts +++ b/src/modules/auto-invest/createPlan.ts @@ -5,65 +5,81 @@ * @license Apache-2.0 */ // src/modules/auto-invest/createPlan.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { autoInvestClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerAutoInvestCreatePlan(server: McpServer) { - server.tool( - "BinanceAutoInvestCreatePlan", - "Create an auto-invest plan for dollar-cost averaging. Automatically purchases crypto at regular intervals.", - { - sourceType: z.enum(["MAIN_SITE", "TR"]).describe("Source type"), - planType: z.enum(["SINGLE", "PORTFOLIO", "INDEX"]).describe("Plan type"), - subscriptionAmount: z.string().describe("Amount per subscription"), - subscriptionCycle: z.enum(["H1", "H4", "H8", "H12", "WEEKLY", "DAILY", "MONTHLY", "BI_WEEKLY"]) - .describe("Subscription frequency"), - subscriptionStartDay: z.number().int().optional() - .describe("Start day (1-31 for MONTHLY, 1-7 for WEEKLY)"), - subscriptionStartTime: z.number().int().min(0).max(23).describe("Start hour (0-23)"), - sourceAsset: z.string().describe("Source asset (e.g., 'USDT')"), - flexibleAllowedToUse: z.boolean().optional() - .describe("Allow using flexible savings balance"), - details: z.array(z.object({ - targetAsset: z.string().describe("Target asset to purchase"), - percentage: z.number().describe("Percentage allocation (0-100)") - })).describe("Target assets and allocation percentages"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await autoInvestClient.restAPI.planAdd({ - sourceType: params.sourceType, - planType: params.planType, - subscriptionAmount: params.subscriptionAmount, - subscriptionCycle: params.subscriptionCycle, - subscriptionStartTime: params.subscriptionStartTime, - sourceAsset: params.sourceAsset, - details: JSON.stringify(params.details), - ...(params.subscriptionStartDay && { subscriptionStartDay: params.subscriptionStartDay }), - ...(params.flexibleAllowedToUse !== undefined && { flexibleAllowedToUse: params.flexibleAllowedToUse }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Auto-invest plan created!\n\nPlan ID: ${data.planId}\nNext Execution: ${data.nextExecutionDateTime || 'Scheduled'}\n\nYour recurring investment plan is now active.` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to create auto-invest plan: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceAutoInvestCreatePlan", + "Create an auto-invest plan for dollar-cost averaging. Automatically purchases crypto at regular intervals.", + { + sourceType: z.enum(["MAIN_SITE", "TR"]).describe("Source type"), + planType: z.enum(["SINGLE", "PORTFOLIO", "INDEX"]).describe("Plan type"), + subscriptionAmount: z.string().describe("Amount per subscription"), + subscriptionCycle: z + .enum(["H1", "H4", "H8", "H12", "WEEKLY", "DAILY", "MONTHLY", "BI_WEEKLY"]) + .describe("Subscription frequency"), + subscriptionStartDay: z + .number() + .int() + .optional() + .describe("Start day (1-31 for MONTHLY, 1-7 for WEEKLY)"), + subscriptionStartTime: z.number().int().min(0).max(23).describe("Start hour (0-23)"), + sourceAsset: z.string().describe("Source asset (e.g., 'USDT')"), + flexibleAllowedToUse: z.boolean().optional().describe("Allow using flexible savings balance"), + details: z + .array( + z.object({ + targetAsset: z.string().describe("Target asset to purchase"), + percentage: z.number().describe("Percentage allocation (0-100)"), + }), + ) + .describe("Target assets and allocation percentages"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await autoInvestClient.restAPI.planAdd({ + sourceType: params.sourceType, + planType: params.planType, + subscriptionAmount: params.subscriptionAmount, + subscriptionCycle: params.subscriptionCycle, + subscriptionStartTime: params.subscriptionStartTime, + sourceAsset: params.sourceAsset, + details: JSON.stringify(params.details), + ...(params.subscriptionStartDay && { subscriptionStartDay: params.subscriptionStartDay }), + ...(params.flexibleAllowedToUse !== undefined && { + flexibleAllowedToUse: params.flexibleAllowedToUse, + }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Auto-invest plan created!\n\nPlan ID: ${data.planId}\nNext Execution: ${data.nextExecutionDateTime || "Scheduled"}\n\nYour recurring investment plan is now active.`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to create auto-invest plan: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/auto-invest/editPlan.ts b/src/modules/auto-invest/editPlan.ts index da0ae5f5..dc3982f1 100644 --- a/src/modules/auto-invest/editPlan.ts +++ b/src/modules/auto-invest/editPlan.ts @@ -5,63 +5,79 @@ * @license Apache-2.0 */ // src/modules/auto-invest/editPlan.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { autoInvestClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerAutoInvestEditPlan(server: McpServer) { - server.tool( - "BinanceAutoInvestEditPlan", - "Edit an existing auto-invest plan. Modify subscription amount, cycle, or target allocations.", - { - planId: z.number().int().describe("Plan ID to edit"), - subscriptionAmount: z.string().describe("New amount per subscription"), - subscriptionCycle: z.enum(["H1", "H4", "H8", "H12", "WEEKLY", "DAILY", "MONTHLY", "BI_WEEKLY"]) - .describe("New subscription frequency"), - subscriptionStartDay: z.number().int().optional() - .describe("New start day (1-31 for MONTHLY, 1-7 for WEEKLY)"), - subscriptionStartTime: z.number().int().min(0).max(23).describe("New start hour (0-23)"), - sourceAsset: z.string().describe("Source asset (e.g., 'USDT')"), - flexibleAllowedToUse: z.boolean().optional() - .describe("Allow using flexible savings balance"), - details: z.array(z.object({ - targetAsset: z.string().describe("Target asset to purchase"), - percentage: z.number().describe("Percentage allocation (0-100)") - })).describe("New target assets and allocation percentages"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await autoInvestClient.restAPI.planEdit({ - planId: params.planId, - subscriptionAmount: params.subscriptionAmount, - subscriptionCycle: params.subscriptionCycle, - subscriptionStartTime: params.subscriptionStartTime, - sourceAsset: params.sourceAsset, - details: JSON.stringify(params.details), - ...(params.subscriptionStartDay && { subscriptionStartDay: params.subscriptionStartDay }), - ...(params.flexibleAllowedToUse !== undefined && { flexibleAllowedToUse: params.flexibleAllowedToUse }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Auto-invest plan updated!\n\nPlan ID: ${params.planId}\nNext Execution: ${data.nextExecutionDateTime || 'Scheduled'}\n\nYour plan has been modified.` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to edit auto-invest plan: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceAutoInvestEditPlan", + "Edit an existing auto-invest plan. Modify subscription amount, cycle, or target allocations.", + { + planId: z.number().int().describe("Plan ID to edit"), + subscriptionAmount: z.string().describe("New amount per subscription"), + subscriptionCycle: z + .enum(["H1", "H4", "H8", "H12", "WEEKLY", "DAILY", "MONTHLY", "BI_WEEKLY"]) + .describe("New subscription frequency"), + subscriptionStartDay: z + .number() + .int() + .optional() + .describe("New start day (1-31 for MONTHLY, 1-7 for WEEKLY)"), + subscriptionStartTime: z.number().int().min(0).max(23).describe("New start hour (0-23)"), + sourceAsset: z.string().describe("Source asset (e.g., 'USDT')"), + flexibleAllowedToUse: z.boolean().optional().describe("Allow using flexible savings balance"), + details: z + .array( + z.object({ + targetAsset: z.string().describe("Target asset to purchase"), + percentage: z.number().describe("Percentage allocation (0-100)"), + }), + ) + .describe("New target assets and allocation percentages"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await autoInvestClient.restAPI.planEdit({ + planId: params.planId, + subscriptionAmount: params.subscriptionAmount, + subscriptionCycle: params.subscriptionCycle, + subscriptionStartTime: params.subscriptionStartTime, + sourceAsset: params.sourceAsset, + details: JSON.stringify(params.details), + ...(params.subscriptionStartDay && { subscriptionStartDay: params.subscriptionStartDay }), + ...(params.flexibleAllowedToUse !== undefined && { + flexibleAllowedToUse: params.flexibleAllowedToUse, + }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Auto-invest plan updated!\n\nPlan ID: ${params.planId}\nNext Execution: ${data.nextExecutionDateTime || "Scheduled"}\n\nYour plan has been modified.`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to edit auto-invest plan: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/auto-invest/getHistoryList.ts b/src/modules/auto-invest/getHistoryList.ts index bd4574c2..ae773010 100644 --- a/src/modules/auto-invest/getHistoryList.ts +++ b/src/modules/auto-invest/getHistoryList.ts @@ -5,78 +5,94 @@ * @license Apache-2.0 */ // src/modules/auto-invest/getHistoryList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { autoInvestClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerAutoInvestGetHistoryList(server: McpServer) { - server.tool( - "BinanceAutoInvestGetHistoryList", - "Get auto-invest transaction history. Shows all past recurring purchases.", - { - planId: z.number().int().optional().describe("Filter by plan ID"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - targetAsset: z.string().optional().describe("Filter by target asset"), - planType: z.enum(["SINGLE", "PORTFOLIO", "INDEX", "ALL"]).optional().describe("Plan type filter"), - size: z.number().int().min(1).max(100).optional().describe("Number of results (default 10, max 100)"), - current: z.number().int().min(1).optional().describe("Page number (default 1)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await autoInvestClient.restAPI.historyList({ - ...(params.planId && { planId: params.planId }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.targetAsset && { targetAsset: params.targetAsset }), - ...(params.planType && { planType: params.planType }), - ...(params.size && { size: params.size }), - ...(params.current && { current: params.current }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Auto-Invest Transaction History\n\n`; - - const history = data.list || data.data || data; - - if (Array.isArray(history) && history.length > 0) { - result += `Total transactions: ${data.total || history.length}\n\n`; - history.slice(0, 20).forEach((tx: any, index: number) => { - result += `**${index + 1}. Transaction ID: ${tx.id || tx.transactionId}**\n`; - result += ` Plan ID: ${tx.planId}\n`; - result += ` Target Asset: ${tx.targetAsset}\n`; - result += ` Source Asset: ${tx.sourceAsset}\n`; - result += ` Source Amount: ${tx.sourceAmount || tx.sourceAssetAmount}\n`; - result += ` Target Amount: ${tx.targetAmount || tx.targetAssetAmount}\n`; - result += ` Status: ${tx.status}\n`; - result += ` Time: ${tx.transactionDateTime || new Date(tx.time).toISOString()}\n\n`; - }); - if (history.length > 20) { - result += `... and ${history.length - 20} more transactions`; - } - } else { - result += `No transaction history found`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get auto-invest history: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceAutoInvestGetHistoryList", + "Get auto-invest transaction history. Shows all past recurring purchases.", + { + planId: z.number().int().optional().describe("Filter by plan ID"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + targetAsset: z.string().optional().describe("Filter by target asset"), + planType: z + .enum(["SINGLE", "PORTFOLIO", "INDEX", "ALL"]) + .optional() + .describe("Plan type filter"), + size: z + .number() + .int() + .min(1) + .max(100) + .optional() + .describe("Number of results (default 10, max 100)"), + current: z.number().int().min(1).optional().describe("Page number (default 1)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await autoInvestClient.restAPI.historyList({ + ...(params.planId && { planId: params.planId }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.targetAsset && { targetAsset: params.targetAsset }), + ...(params.planType && { planType: params.planType }), + ...(params.size && { size: params.size }), + ...(params.current && { current: params.current }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Auto-Invest Transaction History\n\n` + + const history = data.list || data.data || data + + if (Array.isArray(history) && history.length > 0) { + result += `Total transactions: ${data.total || history.length}\n\n` + history.slice(0, 20).forEach((tx: any, index: number) => { + result += `**${index + 1}. Transaction ID: ${tx.id || tx.transactionId}**\n` + result += ` Plan ID: ${tx.planId}\n` + result += ` Target Asset: ${tx.targetAsset}\n` + result += ` Source Asset: ${tx.sourceAsset}\n` + result += ` Source Amount: ${tx.sourceAmount || tx.sourceAssetAmount}\n` + result += ` Target Amount: ${tx.targetAmount || tx.targetAssetAmount}\n` + result += ` Status: ${tx.status}\n` + result += ` Time: ${tx.transactionDateTime || new Date(tx.time).toISOString()}\n\n` + }) + if (history.length > 20) { + result += `... and ${history.length - 20} more transactions` + } + } else { + result += `No transaction history found` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get auto-invest history: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/auto-invest/getIndexInfo.ts b/src/modules/auto-invest/getIndexInfo.ts index ccec9e76..c51600f1 100644 --- a/src/modules/auto-invest/getIndexInfo.ts +++ b/src/modules/auto-invest/getIndexInfo.ts @@ -5,63 +5,70 @@ * @license Apache-2.0 */ // src/modules/auto-invest/getIndexInfo.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { autoInvestClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerAutoInvestGetIndexInfo(server: McpServer) { - server.tool( - "BinanceAutoInvestGetIndexInfo", - "Get auto-invest index information. Index plans allow investing in a basket of cryptocurrencies.", - { - indexId: z.number().int().optional().describe("Specific index ID to query"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await autoInvestClient.restAPI.indexInfo({ - ...(params.indexId && { indexId: params.indexId }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Auto-Invest Index Information\n\n`; - - if (data.indexId) { - result += `**Index ID: ${data.indexId}**\n`; - result += `Status: ${data.status}\n\n`; - if (data.assetAllocation && Array.isArray(data.assetAllocation)) { - result += `**Asset Allocation**\n`; - data.assetAllocation.forEach((asset: any) => { - result += `- ${asset.targetAsset}: ${asset.allocation}%\n`; - }); - } - } else if (Array.isArray(data)) { - data.forEach((index: any) => { - result += `**Index ID: ${index.indexId}**\n`; - result += `Status: ${index.status}\n\n`; - }); - } else { - result += `Index Info: ${JSON.stringify(data)}`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get auto-invest index info: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceAutoInvestGetIndexInfo", + "Get auto-invest index information. Index plans allow investing in a basket of cryptocurrencies.", + { + indexId: z.number().int().optional().describe("Specific index ID to query"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await autoInvestClient.restAPI.indexInfo({ + ...(params.indexId && { indexId: params.indexId }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Auto-Invest Index Information\n\n` + + if (data.indexId) { + result += `**Index ID: ${data.indexId}**\n` + result += `Status: ${data.status}\n\n` + if (data.assetAllocation && Array.isArray(data.assetAllocation)) { + result += `**Asset Allocation**\n` + data.assetAllocation.forEach((asset: any) => { + result += `- ${asset.targetAsset}: ${asset.allocation}%\n` + }) + } + } else if (Array.isArray(data)) { + data.forEach((index: any) => { + result += `**Index ID: ${index.indexId}**\n` + result += `Status: ${index.status}\n\n` + }) + } else { + result += `Index Info: ${JSON.stringify(data)}` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get auto-invest index info: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/auto-invest/getIndexLinkedPlanPositionDetails.ts b/src/modules/auto-invest/getIndexLinkedPlanPositionDetails.ts index 1c8457c9..243e3d09 100644 --- a/src/modules/auto-invest/getIndexLinkedPlanPositionDetails.ts +++ b/src/modules/auto-invest/getIndexLinkedPlanPositionDetails.ts @@ -5,67 +5,74 @@ * @license Apache-2.0 */ // src/modules/auto-invest/getIndexLinkedPlanPositionDetails.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { autoInvestClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerAutoInvestGetIndexLinkedPlanPositionDetails(server: McpServer) { - server.tool( - "BinanceAutoInvestGetPlanDetails", - "Get detailed information about a specific auto-invest plan including position details.", - { - planId: z.number().int().describe("Plan ID to query"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await autoInvestClient.restAPI.planId({ - planId: params.planId, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Auto-Invest Plan Details\n\n`; - result += `Plan ID: ${params.planId}\n\n`; - - if (data) { - result += `**Plan Configuration**\n`; - result += `Type: ${data.planType || 'N/A'}\n`; - result += `Status: ${data.status || 'N/A'}\n`; - result += `Source Asset: ${data.sourceAsset || 'N/A'}\n`; - result += `Subscription Amount: ${data.subscriptionAmount || 'N/A'}\n`; - result += `Cycle: ${data.subscriptionCycle || 'N/A'}\n`; - result += `Next Execution: ${data.nextExecutionDateTime || 'N/A'}\n\n`; - - if (data.details && Array.isArray(data.details)) { - result += `**Position Details**\n`; - data.details.forEach((detail: any) => { - result += `**${detail.targetAsset}** (${detail.percentage}%)\n`; - result += ` Purchased Amount: ${detail.purchasedAmount || '0'}\n`; - result += ` Average Price: ${detail.avgPrice || 'N/A'}\n`; - result += ` Current Value: ${detail.currentValue || 'N/A'}\n`; - result += ` PnL: ${detail.pnl || 'N/A'}\n\n`; - }); - } - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get auto-invest plan details: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceAutoInvestGetPlanDetails", + "Get detailed information about a specific auto-invest plan including position details.", + { + planId: z.number().int().describe("Plan ID to query"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await autoInvestClient.restAPI.planId({ + planId: params.planId, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Auto-Invest Plan Details\n\n` + result += `Plan ID: ${params.planId}\n\n` + + if (data) { + result += `**Plan Configuration**\n` + result += `Type: ${data.planType || "N/A"}\n` + result += `Status: ${data.status || "N/A"}\n` + result += `Source Asset: ${data.sourceAsset || "N/A"}\n` + result += `Subscription Amount: ${data.subscriptionAmount || "N/A"}\n` + result += `Cycle: ${data.subscriptionCycle || "N/A"}\n` + result += `Next Execution: ${data.nextExecutionDateTime || "N/A"}\n\n` + + if (data.details && Array.isArray(data.details)) { + result += `**Position Details**\n` + data.details.forEach((detail: any) => { + result += `**${detail.targetAsset}** (${detail.percentage}%)\n` + result += ` Purchased Amount: ${detail.purchasedAmount || "0"}\n` + result += ` Average Price: ${detail.avgPrice || "N/A"}\n` + result += ` Current Value: ${detail.currentValue || "N/A"}\n` + result += ` PnL: ${detail.pnl || "N/A"}\n\n` + }) + } + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get auto-invest plan details: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/auto-invest/getIndexUserSummary.ts b/src/modules/auto-invest/getIndexUserSummary.ts index c376857c..ea2ba3d9 100644 --- a/src/modules/auto-invest/getIndexUserSummary.ts +++ b/src/modules/auto-invest/getIndexUserSummary.ts @@ -5,53 +5,60 @@ * @license Apache-2.0 */ // src/modules/auto-invest/getIndexUserSummary.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { autoInvestClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerAutoInvestGetIndexUserSummary(server: McpServer) { - server.tool( - "BinanceAutoInvestGetIndexUserSummary", - "Get user's auto-invest index subscription summary.", - { - indexId: z.number().int().describe("Index ID to query"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await autoInvestClient.restAPI.indexUserSummary({ - indexId: params.indexId, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Auto-Invest Index User Summary\n\n`; - result += `Index ID: ${params.indexId}\n\n`; - - if (data) { - result += `Total Invested: ${data.totalInvestedInUSD || data.totalInvested || 'N/A'}\n`; - result += `Current Value: ${data.currentInvestedInUSD || data.currentValue || 'N/A'}\n`; - result += `PnL: ${data.pnlInUSD || data.pnl || 'N/A'}\n`; - result += `ROI: ${data.roi || 'N/A'}%\n`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get auto-invest index user summary: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceAutoInvestGetIndexUserSummary", + "Get user's auto-invest index subscription summary.", + { + indexId: z.number().int().describe("Index ID to query"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await autoInvestClient.restAPI.indexUserSummary({ + indexId: params.indexId, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Auto-Invest Index User Summary\n\n` + result += `Index ID: ${params.indexId}\n\n` + + if (data) { + result += `Total Invested: ${data.totalInvestedInUSD || data.totalInvested || "N/A"}\n` + result += `Current Value: ${data.currentInvestedInUSD || data.currentValue || "N/A"}\n` + result += `PnL: ${data.pnlInUSD || data.pnl || "N/A"}\n` + result += `ROI: ${data.roi || "N/A"}%\n` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get auto-invest index user summary: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/auto-invest/getPlanList.ts b/src/modules/auto-invest/getPlanList.ts index d25250f4..07e06457 100644 --- a/src/modules/auto-invest/getPlanList.ts +++ b/src/modules/auto-invest/getPlanList.ts @@ -5,70 +5,80 @@ * @license Apache-2.0 */ // src/modules/auto-invest/getPlanList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { autoInvestClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerAutoInvestGetPlanList(server: McpServer) { - server.tool( - "BinanceAutoInvestGetPlanList", - "Get list of user's auto-invest plans. Shows all recurring investment plans.", - { - planType: z.enum(["SINGLE", "PORTFOLIO", "INDEX", "ALL"]).optional().describe("Plan type filter"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await autoInvestClient.restAPI.planList({ - ...(params.planType && { planType: params.planType }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Auto-Invest Plans\n\n`; - - const plans = data.planList || data.plans || data; - - if (Array.isArray(plans) && plans.length > 0) { - result += `Total plans: ${plans.length}\n\n`; - plans.forEach((plan: any, index: number) => { - result += `**${index + 1}. Plan ID: ${plan.planId}**\n`; - result += ` Type: ${plan.planType}\n`; - result += ` Status: ${plan.status}\n`; - result += ` Source Asset: ${plan.sourceAsset}\n`; - result += ` Subscription Amount: ${plan.subscriptionAmount}\n`; - result += ` Cycle: ${plan.subscriptionCycle}\n`; - result += ` Next Execution: ${plan.nextExecutionDateTime || 'N/A'}\n\n`; - - if (plan.details && Array.isArray(plan.details)) { - result += ` **Target Assets:**\n`; - plan.details.forEach((detail: any) => { - result += ` - ${detail.targetAsset}: ${detail.percentage}%\n`; - }); - result += '\n'; - } - }); - } else { - result += `No auto-invest plans found`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get auto-invest plans: ${errorMessage}` - }], - isError: true - }; + server.tool( + "BinanceAutoInvestGetPlanList", + "Get list of user's auto-invest plans. Shows all recurring investment plans.", + { + planType: z + .enum(["SINGLE", "PORTFOLIO", "INDEX", "ALL"]) + .optional() + .describe("Plan type filter"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await autoInvestClient.restAPI.planList({ + ...(params.planType && { planType: params.planType }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Auto-Invest Plans\n\n` + + const plans = data.planList || data.plans || data + + if (Array.isArray(plans) && plans.length > 0) { + result += `Total plans: ${plans.length}\n\n` + plans.forEach((plan: any, index: number) => { + result += `**${index + 1}. Plan ID: ${plan.planId}**\n` + result += ` Type: ${plan.planType}\n` + result += ` Status: ${plan.status}\n` + result += ` Source Asset: ${plan.sourceAsset}\n` + result += ` Subscription Amount: ${plan.subscriptionAmount}\n` + result += ` Cycle: ${plan.subscriptionCycle}\n` + result += ` Next Execution: ${plan.nextExecutionDateTime || "N/A"}\n\n` + + if (plan.details && Array.isArray(plan.details)) { + result += ` **Target Assets:**\n` + plan.details.forEach((detail: any) => { + result += ` - ${detail.targetAsset}: ${detail.percentage}%\n` + }) + result += "\n" } + }) + } else { + result += `No auto-invest plans found` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get auto-invest plans: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/auto-invest/getSourceAssetList.ts b/src/modules/auto-invest/getSourceAssetList.ts index 1920639a..2f7493c8 100644 --- a/src/modules/auto-invest/getSourceAssetList.ts +++ b/src/modules/auto-invest/getSourceAssetList.ts @@ -5,68 +5,80 @@ * @license Apache-2.0 */ // src/modules/auto-invest/getSourceAssetList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { autoInvestClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerAutoInvestGetSourceAssetList(server: McpServer) { - server.tool( - "BinanceAutoInvestGetSourceAssetList", - "Get the list of available source assets for auto-invest plans. These are the assets you can use to fund your recurring purchases.", - { - usageType: z.enum(["RECURRING", "ONE_TIME"]).optional().describe("Usage type filter"), - targetAsset: z.string().optional().describe("Filter by target asset"), - indexId: z.number().int().optional().describe("Index ID filter"), - flexibleAllowedToUse: z.boolean().optional().describe("Filter by flexible savings availability"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await autoInvestClient.restAPI.sourceAssetList({ - ...(params.usageType && { usageType: params.usageType }), - ...(params.targetAsset && { targetAsset: params.targetAsset }), - ...(params.indexId && { indexId: params.indexId }), - ...(params.flexibleAllowedToUse !== undefined && { flexibleAllowedToUse: params.flexibleAllowedToUse }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Auto-Invest Source Assets\n\n`; - - if (data.sourceAssetList && Array.isArray(data.sourceAssetList)) { - result += `Total: ${data.sourceAssetList.length} assets\n\n`; - data.sourceAssetList.forEach((asset: any) => { - result += `**${asset.sourceAsset}**\n`; - result += ` Free Amount: ${asset.freeAmount}\n`; - result += ` Min Amount: ${asset.minAmount}\n`; - result += ` Max Amount: ${asset.maxAmount}\n\n`; - }); - } else if (Array.isArray(data)) { - data.forEach((asset: any) => { - result += `**${asset.sourceAsset || asset.asset}**\n`; - result += ` Available: ${asset.freeAmount || 'N/A'}\n\n`; - }); - } else { - result += `Source Assets: ${JSON.stringify(data)}`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get auto-invest source assets: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceAutoInvestGetSourceAssetList", + "Get the list of available source assets for auto-invest plans. These are the assets you can use to fund your recurring purchases.", + { + usageType: z.enum(["RECURRING", "ONE_TIME"]).optional().describe("Usage type filter"), + targetAsset: z.string().optional().describe("Filter by target asset"), + indexId: z.number().int().optional().describe("Index ID filter"), + flexibleAllowedToUse: z + .boolean() + .optional() + .describe("Filter by flexible savings availability"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await autoInvestClient.restAPI.sourceAssetList({ + ...(params.usageType && { usageType: params.usageType }), + ...(params.targetAsset && { targetAsset: params.targetAsset }), + ...(params.indexId && { indexId: params.indexId }), + ...(params.flexibleAllowedToUse !== undefined && { + flexibleAllowedToUse: params.flexibleAllowedToUse, + }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Auto-Invest Source Assets\n\n` + + if (data.sourceAssetList && Array.isArray(data.sourceAssetList)) { + result += `Total: ${data.sourceAssetList.length} assets\n\n` + data.sourceAssetList.forEach((asset: any) => { + result += `**${asset.sourceAsset}**\n` + result += ` Free Amount: ${asset.freeAmount}\n` + result += ` Min Amount: ${asset.minAmount}\n` + result += ` Max Amount: ${asset.maxAmount}\n\n` + }) + } else if (Array.isArray(data)) { + data.forEach((asset: any) => { + result += `**${asset.sourceAsset || asset.asset}**\n` + result += ` Available: ${asset.freeAmount || "N/A"}\n\n` + }) + } else { + result += `Source Assets: ${JSON.stringify(data)}` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get auto-invest source assets: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/auto-invest/getTargetAssetList.ts b/src/modules/auto-invest/getTargetAssetList.ts index 60e9104e..ba261fef 100644 --- a/src/modules/auto-invest/getTargetAssetList.ts +++ b/src/modules/auto-invest/getTargetAssetList.ts @@ -5,65 +5,78 @@ * @license Apache-2.0 */ // src/modules/auto-invest/getTargetAssetList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { autoInvestClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerAutoInvestGetTargetAssetList(server: McpServer) { - server.tool( - "BinanceAutoInvestGetTargetAssetList", - "Get the list of available target assets for auto-invest plans. Shows assets available for dollar-cost averaging.", - { - targetAsset: z.string().optional().describe("Filter by specific target asset (e.g., 'BTC')"), - size: z.number().int().min(1).max(100).optional().describe("Number of results (default 10, max 100)"), - current: z.number().int().min(1).optional().describe("Page number (default 1)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await autoInvestClient.restAPI.targetAssetList({ - ...(params.targetAsset && { targetAsset: params.targetAsset }), - ...(params.size && { size: params.size }), - ...(params.current && { current: params.current }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Auto-Invest Target Assets\n\n`; - - if (data.data && Array.isArray(data.data) && data.data.length > 0) { - result += `Total assets: ${data.total || data.data.length}\n\n`; - data.data.forEach((asset: any) => { - result += `**${asset.targetAsset}**\n`; - result += ` ROI: ${asset.roiAndDimensionTypeList ? 'Available' : 'N/A'}\n`; - result += ` Available: ${asset.available !== false}\n\n`; - }); - } else if (Array.isArray(data) && data.length > 0) { - data.forEach((asset: any) => { - result += `**${asset.targetAsset || asset.asset}**\n`; - result += ` Available: ${asset.available !== false}\n\n`; - }); - } else { - result += `No target assets found`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get auto-invest target assets: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceAutoInvestGetTargetAssetList", + "Get the list of available target assets for auto-invest plans. Shows assets available for dollar-cost averaging.", + { + targetAsset: z.string().optional().describe("Filter by specific target asset (e.g., 'BTC')"), + size: z + .number() + .int() + .min(1) + .max(100) + .optional() + .describe("Number of results (default 10, max 100)"), + current: z.number().int().min(1).optional().describe("Page number (default 1)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await autoInvestClient.restAPI.targetAssetList({ + ...(params.targetAsset && { targetAsset: params.targetAsset }), + ...(params.size && { size: params.size }), + ...(params.current && { current: params.current }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Auto-Invest Target Assets\n\n` + + if (data.data && Array.isArray(data.data) && data.data.length > 0) { + result += `Total assets: ${data.total || data.data.length}\n\n` + data.data.forEach((asset: any) => { + result += `**${asset.targetAsset}**\n` + result += ` ROI: ${asset.roiAndDimensionTypeList ? "Available" : "N/A"}\n` + result += ` Available: ${asset.available !== false}\n\n` + }) + } else if (Array.isArray(data) && data.length > 0) { + data.forEach((asset: any) => { + result += `**${asset.targetAsset || asset.asset}**\n` + result += ` Available: ${asset.available !== false}\n\n` + }) + } else { + result += `No target assets found` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get auto-invest target assets: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/auto-invest/getTargetAssetRoiData.ts b/src/modules/auto-invest/getTargetAssetRoiData.ts index 530da996..ebacd2a5 100644 --- a/src/modules/auto-invest/getTargetAssetRoiData.ts +++ b/src/modules/auto-invest/getTargetAssetRoiData.ts @@ -5,63 +5,71 @@ * @license Apache-2.0 */ // src/modules/auto-invest/getTargetAssetRoiData.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { autoInvestClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerAutoInvestGetTargetAssetRoiData(server: McpServer) { - server.tool( - "BinanceAutoInvestGetTargetAssetRoiData", - "Get ROI (Return on Investment) data for auto-invest target assets. Shows historical performance data.", - { - targetAsset: z.string().describe("Target asset (e.g., 'BTC')"), - hisRoiType: z.enum(["FIVE_YEAR", "THREE_YEAR", "ONE_YEAR", "SIX_MONTH", "THREE_MONTH", "SEVEN_DAY"]) - .describe("Historical ROI time period"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await autoInvestClient.restAPI.targetAssetRoiList({ - targetAsset: params.targetAsset, - hisRoiType: params.hisRoiType, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Auto-Invest ROI Data - ${params.targetAsset}\n\n`; - result += `Period: ${params.hisRoiType}\n\n`; - - if (Array.isArray(data) && data.length > 0) { - data.forEach((item: any) => { - result += `Date: ${item.date}\n`; - result += ` Simulated ROI: ${item.simulatedRoi}%\n\n`; - }); - } else if (data.data && Array.isArray(data.data)) { - data.data.forEach((item: any) => { - result += `Date: ${item.date}\n`; - result += ` Simulated ROI: ${item.simulatedRoi}%\n\n`; - }); - } else { - result += `ROI Data: ${JSON.stringify(data)}`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get auto-invest ROI data: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceAutoInvestGetTargetAssetRoiData", + "Get ROI (Return on Investment) data for auto-invest target assets. Shows historical performance data.", + { + targetAsset: z.string().describe("Target asset (e.g., 'BTC')"), + hisRoiType: z + .enum(["FIVE_YEAR", "THREE_YEAR", "ONE_YEAR", "SIX_MONTH", "THREE_MONTH", "SEVEN_DAY"]) + .describe("Historical ROI time period"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await autoInvestClient.restAPI.targetAssetRoiList({ + targetAsset: params.targetAsset, + hisRoiType: params.hisRoiType, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Auto-Invest ROI Data - ${params.targetAsset}\n\n` + result += `Period: ${params.hisRoiType}\n\n` + + if (Array.isArray(data) && data.length > 0) { + data.forEach((item: any) => { + result += `Date: ${item.date}\n` + result += ` Simulated ROI: ${item.simulatedRoi}%\n\n` + }) + } else if (data.data && Array.isArray(data.data)) { + data.data.forEach((item: any) => { + result += `Date: ${item.date}\n` + result += ` Simulated ROI: ${item.simulatedRoi}%\n\n` + }) + } else { + result += `ROI Data: ${JSON.stringify(data)}` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get auto-invest ROI data: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/auto-invest/index.ts b/src/modules/auto-invest/index.ts index 06651cac..3a74a6f3 100644 --- a/src/modules/auto-invest/index.ts +++ b/src/modules/auto-invest/index.ts @@ -1,7 +1,8 @@ // src/modules/auto-invest/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceAutoInvestTools } from "../../tools/binance-auto-invest/index.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceAutoInvestTools } from "../../tools/binance-auto-invest/index.js" export function registerAutoInvest(server: McpServer) { - registerBinanceAutoInvestTools(server); + registerBinanceAutoInvestTools(server) } diff --git a/src/modules/auto-invest/oneTimeTransaction.ts b/src/modules/auto-invest/oneTimeTransaction.ts index 5483cbb7..ca1e5b8b 100644 --- a/src/modules/auto-invest/oneTimeTransaction.ts +++ b/src/modules/auto-invest/oneTimeTransaction.ts @@ -5,60 +5,73 @@ * @license Apache-2.0 */ // src/modules/auto-invest/oneTimeTransaction.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { autoInvestClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerAutoInvestOneTimeTransaction(server: McpServer) { - server.tool( - "BinanceAutoInvestOneTimeTransaction", - "Execute a one-time auto-invest purchase. Instantly buy crypto using auto-invest infrastructure.", - { - sourceType: z.enum(["MAIN_SITE", "TR"]).describe("Source type"), - subscriptionAmount: z.string().describe("Amount to invest"), - sourceAsset: z.string().describe("Source asset (e.g., 'USDT')"), - flexibleAllowedToUse: z.boolean().optional() - .describe("Allow using flexible savings balance"), - planId: z.number().int().optional().describe("Plan ID for plan-based one-time purchase"), - indexId: z.number().int().optional().describe("Index ID for index-based purchase"), - details: z.array(z.object({ - targetAsset: z.string().describe("Target asset to purchase"), - percentage: z.number().describe("Percentage allocation (0-100)") - })).optional().describe("Target assets and allocation (for non-plan purchases)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const requestParams: any = { - sourceType: params.sourceType, - subscriptionAmount: params.subscriptionAmount, - sourceAsset: params.sourceAsset, - ...(params.flexibleAllowedToUse !== undefined && { flexibleAllowedToUse: params.flexibleAllowedToUse }), - ...(params.planId && { planId: params.planId }), - ...(params.indexId && { indexId: params.indexId }), - ...(params.details && { details: JSON.stringify(params.details) }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }; - - const response = await autoInvestClient.restAPI.oneOff(requestParams); - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ One-time auto-invest purchase executed!\n\nTransaction ID: ${data.transactionId || data.tranId || 'Completed'}\nAmount: ${params.subscriptionAmount} ${params.sourceAsset}\n\nResponse: ${JSON.stringify(data)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to execute one-time purchase: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceAutoInvestOneTimeTransaction", + "Execute a one-time auto-invest purchase. Instantly buy crypto using auto-invest infrastructure.", + { + sourceType: z.enum(["MAIN_SITE", "TR"]).describe("Source type"), + subscriptionAmount: z.string().describe("Amount to invest"), + sourceAsset: z.string().describe("Source asset (e.g., 'USDT')"), + flexibleAllowedToUse: z.boolean().optional().describe("Allow using flexible savings balance"), + planId: z.number().int().optional().describe("Plan ID for plan-based one-time purchase"), + indexId: z.number().int().optional().describe("Index ID for index-based purchase"), + details: z + .array( + z.object({ + targetAsset: z.string().describe("Target asset to purchase"), + percentage: z.number().describe("Percentage allocation (0-100)"), + }), + ) + .optional() + .describe("Target assets and allocation (for non-plan purchases)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const requestParams: any = { + sourceType: params.sourceType, + subscriptionAmount: params.subscriptionAmount, + sourceAsset: params.sourceAsset, + ...(params.flexibleAllowedToUse !== undefined && { + flexibleAllowedToUse: params.flexibleAllowedToUse, + }), + ...(params.planId && { planId: params.planId }), + ...(params.indexId && { indexId: params.indexId }), + ...(params.details && { details: JSON.stringify(params.details) }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + } + + const response = await autoInvestClient.restAPI.oneOff(requestParams) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ One-time auto-invest purchase executed!\n\nTransaction ID: ${data.transactionId || data.tranId || "Completed"}\nAmount: ${params.subscriptionAmount} ${params.sourceAsset}\n\nResponse: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to execute one-time purchase: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/auto-invest/rebalanceHistory.ts b/src/modules/auto-invest/rebalanceHistory.ts index 0bc1c447..1bb6f1cb 100644 --- a/src/modules/auto-invest/rebalanceHistory.ts +++ b/src/modules/auto-invest/rebalanceHistory.ts @@ -5,68 +5,81 @@ * @license Apache-2.0 */ // src/modules/auto-invest/rebalanceHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { autoInvestClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerAutoInvestRebalanceHistory(server: McpServer) { - server.tool( - "BinanceAutoInvestRebalanceHistory", - "Get auto-invest portfolio rebalance history. Shows past rebalancing transactions.", - { - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - size: z.number().int().min(1).max(100).optional().describe("Number of results (default 10, max 100)"), - current: z.number().int().min(1).optional().describe("Page number (default 1)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await autoInvestClient.restAPI.rebalanceHistory({ - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.size && { size: params.size }), - ...(params.current && { current: params.current }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Auto-Invest Rebalance History\n\n`; - - const history = data.list || data.data || data; - - if (Array.isArray(history) && history.length > 0) { - result += `Total rebalances: ${data.total || history.length}\n\n`; - history.forEach((rebalance: any, index: number) => { - result += `**${index + 1}. Rebalance ID: ${rebalance.id || rebalance.rebalanceId}**\n`; - result += ` Status: ${rebalance.status}\n`; - result += ` Time: ${rebalance.rebalanceDateTime || new Date(rebalance.time).toISOString()}\n`; - if (rebalance.details) { - result += ` Details: ${JSON.stringify(rebalance.details)}\n`; - } - result += '\n'; - }); - } else { - result += `No rebalance history found`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get rebalance history: ${errorMessage}` - }], - isError: true - }; + server.tool( + "BinanceAutoInvestRebalanceHistory", + "Get auto-invest portfolio rebalance history. Shows past rebalancing transactions.", + { + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + size: z + .number() + .int() + .min(1) + .max(100) + .optional() + .describe("Number of results (default 10, max 100)"), + current: z.number().int().min(1).optional().describe("Page number (default 1)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await autoInvestClient.restAPI.rebalanceHistory({ + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.size && { size: params.size }), + ...(params.current && { current: params.current }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Auto-Invest Rebalance History\n\n` + + const history = data.list || data.data || data + + if (Array.isArray(history) && history.length > 0) { + result += `Total rebalances: ${data.total || history.length}\n\n` + history.forEach((rebalance: any, index: number) => { + result += `**${index + 1}. Rebalance ID: ${rebalance.id || rebalance.rebalanceId}**\n` + result += ` Status: ${rebalance.status}\n` + result += ` Time: ${rebalance.rebalanceDateTime || new Date(rebalance.time).toISOString()}\n` + if (rebalance.details) { + result += ` Details: ${JSON.stringify(rebalance.details)}\n` } + result += "\n" + }) + } else { + result += `No rebalance history found` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get rebalance history: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/auto-invest/redemption.ts b/src/modules/auto-invest/redemption.ts index 2a858dc7..5a1f395a 100644 --- a/src/modules/auto-invest/redemption.ts +++ b/src/modules/auto-invest/redemption.ts @@ -5,45 +5,52 @@ * @license Apache-2.0 */ // src/modules/auto-invest/redemption.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { autoInvestClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerAutoInvestRedemption(server: McpServer) { - server.tool( - "BinanceAutoInvestRedemption", - "Redeem/sell assets from an auto-invest index plan.", - { - indexId: z.number().int().describe("Index ID to redeem from"), - redemptionPercentage: z.number().min(0).max(100).describe("Percentage to redeem (0-100)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await autoInvestClient.restAPI.redeem({ - indexId: params.indexId, - redemptionPercentage: params.redemptionPercentage, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Auto-invest redemption successful!\n\nIndex ID: ${params.indexId}\nRedemption Percentage: ${params.redemptionPercentage}%\nTransaction ID: ${data.transactionId || data.redemptionId || 'Completed'}\n\nResponse: ${JSON.stringify(data)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to redeem from auto-invest: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceAutoInvestRedemption", + "Redeem/sell assets from an auto-invest index plan.", + { + indexId: z.number().int().describe("Index ID to redeem from"), + redemptionPercentage: z.number().min(0).max(100).describe("Percentage to redeem (0-100)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await autoInvestClient.restAPI.redeem({ + indexId: params.indexId, + redemptionPercentage: params.redemptionPercentage, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Auto-invest redemption successful!\n\nIndex ID: ${params.indexId}\nRedemption Percentage: ${params.redemptionPercentage}%\nTransaction ID: ${data.transactionId || data.redemptionId || "Completed"}\n\nResponse: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to redeem from auto-invest: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/c2c/C2C/getAds.ts b/src/modules/c2c/C2C/getAds.ts index 13c8697b..11fbc2aa 100644 --- a/src/modules/c2c/C2C/getAds.ts +++ b/src/modules/c2c/C2C/getAds.ts @@ -5,51 +5,58 @@ * @license Apache-2.0 */ // src/modules/c2c/C2C/getAds.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { c2cClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { c2cClient } from "../../../config/binanceClient.js" export function registerBinanceC2CGetAds(server: McpServer) { - server.tool( - "BinanceC2CGetAds", - "Get available C2C/P2P trading advertisements. Browse buy/sell offers from other users.", - { - asset: z.string().optional().describe("Filter by crypto asset (e.g., 'BTC', 'USDT')"), - fiat: z.string().optional().describe("Filter by fiat currency (e.g., 'USD', 'EUR')"), - tradeType: z.enum(["BUY", "SELL"]).optional().describe("Filter by trade type"), - page: z.number().int().min(1).default(1).optional().describe("Page number"), - rows: z.number().int().min(1).max(20).default(10).optional().describe("Number of rows"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await c2cClient.restAPI.getAds({ - ...(params.asset && { asset: params.asset }), - ...(params.fiat && { fiat: params.fiat }), - ...(params.tradeType && { tradeType: params.tradeType }), - ...(params.page && { page: params.page }), - ...(params.rows && { rows: params.rows }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceC2CGetAds", + "Get available C2C/P2P trading advertisements. Browse buy/sell offers from other users.", + { + asset: z.string().optional().describe("Filter by crypto asset (e.g., 'BTC', 'USDT')"), + fiat: z.string().optional().describe("Filter by fiat currency (e.g., 'USD', 'EUR')"), + tradeType: z.enum(["BUY", "SELL"]).optional().describe("Filter by trade type"), + page: z.number().int().min(1).default(1).optional().describe("Page number"), + rows: z.number().int().min(1).max(20).default(10).optional().describe("Number of rows"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await c2cClient.restAPI.getAds({ + ...(params.asset && { asset: params.asset }), + ...(params.fiat && { fiat: params.fiat }), + ...(params.tradeType && { tradeType: params.tradeType }), + ...(params.page && { page: params.page }), + ...(params.rows && { rows: params.rows }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📋 C2C Advertisements\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `📋 C2C Advertisements\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get C2C ads: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to get C2C ads: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/c2c/C2C/getC2CTradeHistory.ts b/src/modules/c2c/C2C/getC2CTradeHistory.ts index 1570b7ad..d3fac5ea 100644 --- a/src/modules/c2c/C2C/getC2CTradeHistory.ts +++ b/src/modules/c2c/C2C/getC2CTradeHistory.ts @@ -1,48 +1,51 @@ // src/tools/binance-c2c/getC2CTradeHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { c2cClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { c2cClient } from "../../../config/binanceClient.js" export function registerBinanceGetC2CTradeHistory(server: McpServer) { - server.tool( - "BinanceGetC2CTradeHistory", - "Allows the user to retrieve their own past C2C trades, including details such as asset type, trade direction (BUY/SELL), fiat currency used, trade status, and more.", - { - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - page: z.number().int().optional().describe("Page number, default is 1"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await c2cClient.restAPI.getC2CTradeHistory({ - ...(params.startTime !== undefined && { startTime: params.startTime }), - ...(params.endTime !== undefined && { endTime: params.endTime }), - ...(params.page !== undefined && { page: params.page }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); + server.tool( + "BinanceGetC2CTradeHistory", + "Allows the user to retrieve their own past C2C trades, including details such as asset type, trade direction (BUY/SELL), fiat currency used, trade status, and more.", + { + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + page: z.number().int().optional().describe("Page number, default is 1"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await c2cClient.restAPI.getC2CTradeHistory({ + ...(params.startTime !== undefined && { startTime: params.startTime }), + ...(params.endTime !== undefined && { endTime: params.endTime }), + ...(params.page !== undefined && { page: params.page }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved the past C2C trades. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved the past C2C trades. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve users past C2C trades: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve users past C2C trades: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/c2c/index.ts b/src/modules/c2c/index.ts index afe3e888..e2880732 100644 --- a/src/modules/c2c/index.ts +++ b/src/modules/c2c/index.ts @@ -1,10 +1,11 @@ // src/tools/binance-c2c/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetC2CTradeHistory } from "./C2C/getC2CTradeHistory.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceGetC2CTradeHistory } from "./C2C/getC2CTradeHistory.js" export function registerBinanceC2CTradeHistoryTools(server: McpServer) { - registerBinanceGetC2CTradeHistory(server); + registerBinanceGetC2CTradeHistory(server) } // Alias for binance.ts compatibility -export { registerBinanceC2CTradeHistoryTools as registerC2C }; +export { registerBinanceC2CTradeHistoryTools as registerC2C } diff --git a/src/modules/convert/index.ts b/src/modules/convert/index.ts index 7a75053a..58912a82 100644 --- a/src/modules/convert/index.ts +++ b/src/modules/convert/index.ts @@ -1,15 +1,16 @@ // src/tools/binance-convert/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceConvertTradeTools } from "./trade-api/index.js"; -import { registerBinanceConvertMarketDataTools } from "./market-data-api/index.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceConvertMarketDataTools } from "./market-data-api/index.js" +import { registerBinanceConvertTradeTools } from "./trade-api/index.js" export function registerBinanceConvertTools(server: McpServer) { - // Register tools for accessing market data from Binance Convert - registerBinanceConvertMarketDataTools(server); + // Register tools for accessing market data from Binance Convert + registerBinanceConvertMarketDataTools(server) - // Register tools for performing trades on Binance Convert - registerBinanceConvertTradeTools(server); + // Register tools for performing trades on Binance Convert + registerBinanceConvertTradeTools(server) } // Alias for binance.ts compatibility -export { registerBinanceConvertTools as registerConvert }; +export { registerBinanceConvertTools as registerConvert } diff --git a/src/modules/convert/market-data-api/index.ts b/src/modules/convert/market-data-api/index.ts index 923f432b..c9bcf504 100644 --- a/src/modules/convert/market-data-api/index.ts +++ b/src/modules/convert/market-data-api/index.ts @@ -1,12 +1,13 @@ // src/tools/binance-convert/market-data-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceConvertQueryOrderQuantityPrecisionPerAsset } from "./queryOrderQuantityPrecisionPerAsset.js"; -import { registerBinanceConvertGetListAllConvertPairs } from "./listAllConvertPairs.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceConvertGetListAllConvertPairs } from "./listAllConvertPairs.js" +import { registerBinanceConvertQueryOrderQuantityPrecisionPerAsset } from "./queryOrderQuantityPrecisionPerAsset.js" export function registerBinanceConvertMarketDataTools(server: McpServer) { - // Register the route to get a list of all supported convert trading pairs - registerBinanceConvertGetListAllConvertPairs(server); + // Register the route to get a list of all supported convert trading pairs + registerBinanceConvertGetListAllConvertPairs(server) - // Register the route to get quantity precision details for each asset - registerBinanceConvertQueryOrderQuantityPrecisionPerAsset(server); + // Register the route to get quantity precision details for each asset + registerBinanceConvertQueryOrderQuantityPrecisionPerAsset(server) } diff --git a/src/modules/convert/market-data-api/listAllConvertPairs.ts b/src/modules/convert/market-data-api/listAllConvertPairs.ts index 6f130319..845a72b6 100644 --- a/src/modules/convert/market-data-api/listAllConvertPairs.ts +++ b/src/modules/convert/market-data-api/listAllConvertPairs.ts @@ -1,45 +1,48 @@ // src/tools/binance-convert/market-data-api/listAllConvertPairs.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { convertClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { convertClient } from "../../../config/binanceClient.js" export function registerBinanceConvertGetListAllConvertPairs(server: McpServer) { - server.tool( - "BinanceConvertGetListAllConvertPairs", - "Query available conversion pairs (like BTC to USDT), and shows the minimum and maximum allowed amounts for both the source and destination tokens.", - { - fromAsset: z.string().optional().describe("User spends coin"), - toAsset: z.string().optional().describe("User receives coin") - }, - async (params) => { - try { - const response = await convertClient.restAPI.listAllConvertPairs({ - ...(params.fromAsset && { fromAsset: params.fromAsset }), - ...(params.toAsset && { toAsset: params.toAsset }) - }); + server.tool( + "BinanceConvertGetListAllConvertPairs", + "Query available conversion pairs (like BTC to USDT), and shows the minimum and maximum allowed amounts for both the source and destination tokens.", + { + fromAsset: z.string().optional().describe("User spends coin"), + toAsset: z.string().optional().describe("User receives coin"), + }, + async (params) => { + try { + const response = await convertClient.restAPI.listAllConvertPairs({ + ...(params.fromAsset && { fromAsset: params.fromAsset }), + ...(params.toAsset && { toAsset: params.toAsset }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully queried available conversion pairs. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully queried available conversion pairs. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to query available conversion pairs: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to query available conversion pairs: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/convert/market-data-api/queryOrderQuantityPrecisionPerAsset.ts b/src/modules/convert/market-data-api/queryOrderQuantityPrecisionPerAsset.ts index 27c59705..dc097eb2 100644 --- a/src/modules/convert/market-data-api/queryOrderQuantityPrecisionPerAsset.ts +++ b/src/modules/convert/market-data-api/queryOrderQuantityPrecisionPerAsset.ts @@ -1,50 +1,53 @@ // src/tools/binance-convert/market-data-api/queryOrderQuantityPrecisionPerAsset.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { convertClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { convertClient } from "../../../config/binanceClient.js" export function registerBinanceConvertQueryOrderQuantityPrecisionPerAsset(server: McpServer) { - server.tool( - "BinanceConvertQueryOrderQuantityPrecisionPerAsset", - "Retrieve decimal precision (fraction) information for each supported asset in the Convert feature.", - { - recvWindow: z - .number() - .int() - .max(60000, "recvWindow cannot be greater than 60000") - .optional() - .describe("The value cannot be greater than 60000") - }, - async (params) => { - try { - const response = await convertClient.restAPI.queryOrderQuantityPrecisionPerAsset({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceConvertQueryOrderQuantityPrecisionPerAsset", + "Retrieve decimal precision (fraction) information for each supported asset in the Convert feature.", + { + recvWindow: z + .number() + .int() + .max(60000, "recvWindow cannot be greater than 60000") + .optional() + .describe("The value cannot be greater than 60000"), + }, + async (params) => { + try { + const response = await convertClient.restAPI.queryOrderQuantityPrecisionPerAsset({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved decimal precision information for each supported asset. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved decimal precision information for each supported asset. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve decimal precision (fraction) information: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve decimal precision (fraction) information: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/convert/trade-api/acceptQuote.ts b/src/modules/convert/trade-api/acceptQuote.ts index 50189a97..b7ff1b5a 100644 --- a/src/modules/convert/trade-api/acceptQuote.ts +++ b/src/modules/convert/trade-api/acceptQuote.ts @@ -1,49 +1,52 @@ // src/tools/binance-convert/trade-api/acceptQuote.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { convertClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { convertClient } from "../../../config/binanceClient.js" export function registerBinanceConvertAcceptQuote(server: McpServer) { - server.tool( - "BinanceConvertAcceptQuote", - "The API confirms and executes a token conversion using a previously received quote ID.", - { - quoteId: z.string().describe("Quote ID"), - recvWindow: z - .number() - .int() - .max(60000, "recvWindow cannot be greater than 60000") - .optional() - .describe("The value cannot be greater than 60000") - }, - async (params) => { - try { - const response = await convertClient.restAPI.acceptQuote({ - quoteId: params.quoteId, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); + server.tool( + "BinanceConvertAcceptQuote", + "The API confirms and executes a token conversion using a previously received quote ID.", + { + quoteId: z.string().describe("Quote ID"), + recvWindow: z + .number() + .int() + .max(60000, "recvWindow cannot be greater than 60000") + .optional() + .describe("The value cannot be greater than 60000"), + }, + async (params) => { + try { + const response = await convertClient.restAPI.acceptQuote({ + quoteId: params.quoteId, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully executed the token conversion. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully executed the token conversion. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to execute a token conversion : ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to execute a token conversion : ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/convert/trade-api/cancelLimitOrder.ts b/src/modules/convert/trade-api/cancelLimitOrder.ts index 0e960cc2..1a097a79 100644 --- a/src/modules/convert/trade-api/cancelLimitOrder.ts +++ b/src/modules/convert/trade-api/cancelLimitOrder.ts @@ -1,49 +1,52 @@ // src/tools/binance-convert/trade-api/cancelLimitOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { convertClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { convertClient } from "../../../config/binanceClient.js" export function registerBinanceConvertCancelLimitOrder(server: McpServer) { - server.tool( - "BinanceConvertCancelLimitOrder", - "Cancels a previously placed limit order using the orderId and returns the cancellation status along with the orderId.", - { - orderId: z.number().int().describe("The orderId from placeOrder API"), - recvWindow: z - .number() - .int() - .max(60000, "recvWindow cannot be greater than 60000") - .optional() - .describe("Time window for request validity") - }, - async (params) => { - try { - const response = await convertClient.restAPI.cancelLimitOrder({ - orderId: params.orderId, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); + server.tool( + "BinanceConvertCancelLimitOrder", + "Cancels a previously placed limit order using the orderId and returns the cancellation status along with the orderId.", + { + orderId: z.number().int().describe("The orderId from placeOrder API"), + recvWindow: z + .number() + .int() + .max(60000, "recvWindow cannot be greater than 60000") + .optional() + .describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await convertClient.restAPI.cancelLimitOrder({ + orderId: params.orderId, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Canceled the placed limit order. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Canceled the placed limit order. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to placed limit order: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to placed limit order: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/convert/trade-api/getConvertTradeHistory.ts b/src/modules/convert/trade-api/getConvertTradeHistory.ts index 6da43a22..458bba40 100644 --- a/src/modules/convert/trade-api/getConvertTradeHistory.ts +++ b/src/modules/convert/trade-api/getConvertTradeHistory.ts @@ -1,56 +1,59 @@ // src/tools/binance-convert/trade-api/getConvertTradeHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { convertClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { convertClient } from "../../../config/binanceClient.js" export function registerBinanceGetConvertTradeHistory(server: McpServer) { - server.tool( - "BinanceGetConvertTradeHistory", - "The API retrieves your token conversion trade history within a specified time range, with support for pagination using the limit parameter (up to 1000 records).", - { - startTime: z.number().int().describe("Start time in milliseconds"), - endTime: z.number().int().describe("End time in milliseconds"), - limit: z - .number() - .int() - .max(1000, "Limit cannot be greater than 1000") - .optional() - .describe("Default 100, Max 1000"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await convertClient.restAPI.getConvertTradeHistory({ - startTime: params.startTime, - endTime: params.endTime, - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetConvertTradeHistory", + "The API retrieves your token conversion trade history within a specified time range, with support for pagination using the limit parameter (up to 1000 records).", + { + startTime: z.number().int().describe("Start time in milliseconds"), + endTime: z.number().int().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(1000, "Limit cannot be greater than 1000") + .optional() + .describe("Default 100, Max 1000"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await convertClient.restAPI.getConvertTradeHistory({ + startTime: params.startTime, + endTime: params.endTime, + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved your token conversion trade history. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved your token conversion trade history. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve your token conversion: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve your token conversion: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/convert/trade-api/index.ts b/src/modules/convert/trade-api/index.ts index a7efa11e..3b5e9db9 100644 --- a/src/modules/convert/trade-api/index.ts +++ b/src/modules/convert/trade-api/index.ts @@ -1,32 +1,33 @@ // src/tools/binance-convert/trade-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceConvertAcceptQuote } from "./acceptQuote.js"; -import { registerBinanceConvertCancelLimitOrder } from "./cancelLimitOrder.js"; -import { registerBinanceGetConvertTradeHistory } from "./getConvertTradeHistory.js"; -import { registerBinanceConvertOrderStatus } from "./orderStatus.js"; -import { registerBinanceConvertPlaceLimitOrder } from "./placeLimitOrder.js"; -import { registerBinanceConvertQueryLimitOpenOrders } from "./queryLimitOpenOrders.js"; -import { registerBinanceConvertSendQuoteRequest } from "./sendQuoteRequest.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceConvertAcceptQuote } from "./acceptQuote.js" +import { registerBinanceConvertCancelLimitOrder } from "./cancelLimitOrder.js" +import { registerBinanceGetConvertTradeHistory } from "./getConvertTradeHistory.js" +import { registerBinanceConvertOrderStatus } from "./orderStatus.js" +import { registerBinanceConvertPlaceLimitOrder } from "./placeLimitOrder.js" +import { registerBinanceConvertQueryLimitOpenOrders } from "./queryLimitOpenOrders.js" +import { registerBinanceConvertSendQuoteRequest } from "./sendQuoteRequest.js" export function registerBinanceConvertTradeTools(server: McpServer) { - // Register the route to accept a quote for a convert trade - registerBinanceConvertAcceptQuote(server); + // Register the route to accept a quote for a convert trade + registerBinanceConvertAcceptQuote(server) - // Register the route to cancel an existing convert limit order - registerBinanceConvertCancelLimitOrder(server); + // Register the route to cancel an existing convert limit order + registerBinanceConvertCancelLimitOrder(server) - // Register the route to get the convert trade history - registerBinanceGetConvertTradeHistory(server); + // Register the route to get the convert trade history + registerBinanceGetConvertTradeHistory(server) - // Register the route to check the status of a convert order - registerBinanceConvertOrderStatus(server); + // Register the route to check the status of a convert order + registerBinanceConvertOrderStatus(server) - // Register the route to place a new convert limit order - registerBinanceConvertPlaceLimitOrder(server); + // Register the route to place a new convert limit order + registerBinanceConvertPlaceLimitOrder(server) - // Register the route to query currently open convert limit orders - registerBinanceConvertQueryLimitOpenOrders(server); + // Register the route to query currently open convert limit orders + registerBinanceConvertQueryLimitOpenOrders(server) - // Register the route to send a quote request for a convert trade - registerBinanceConvertSendQuoteRequest(server); + // Register the route to send a quote request for a convert trade + registerBinanceConvertSendQuoteRequest(server) } diff --git a/src/modules/convert/trade-api/orderStatus.ts b/src/modules/convert/trade-api/orderStatus.ts index 72d4b323..2a6521a6 100644 --- a/src/modules/convert/trade-api/orderStatus.ts +++ b/src/modules/convert/trade-api/orderStatus.ts @@ -1,47 +1,50 @@ // src/tools/binance-convert/trade-api/orderStatus.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { convertClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { convertClient } from "../../../config/binanceClient.js" export function registerBinanceConvertOrderStatus(server: McpServer) { - server.tool( - "BinanceConvertOrderStatus", - "The API checks the status of a token conversion order using either the orderId or quoteId, and returns details like conversion status, assets involved, amounts, exchange rate, and order creation time.", - { - orderId: z.string().optional().describe("Order ID (either this or quoteId is required)"), - quoteId: z.string().optional().describe("Quote ID (either this or orderId is required)") - }, - async (params) => { - try { - const response = await convertClient.restAPI.orderStatus({ - ...(params.orderId && { orderId: params.orderId }), - ...(params.quoteId && { quoteId: params.quoteId }) - }); + server.tool( + "BinanceConvertOrderStatus", + "The API checks the status of a token conversion order using either the orderId or quoteId, and returns details like conversion status, assets involved, amounts, exchange rate, and order creation time.", + { + orderId: z.string().optional().describe("Order ID (either this or quoteId is required)"), + quoteId: z.string().optional().describe("Quote ID (either this or orderId is required)"), + }, + async (params) => { + try { + const response = await convertClient.restAPI.orderStatus({ + ...(params.orderId && { orderId: params.orderId }), + ...(params.quoteId && { quoteId: params.quoteId }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully get the status of a token conversion . Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully get the status of a token conversion . Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to check the status: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to check the status: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/convert/trade-api/placeLimitOrder.ts b/src/modules/convert/trade-api/placeLimitOrder.ts index 42fb17f1..775c1b66 100644 --- a/src/modules/convert/trade-api/placeLimitOrder.ts +++ b/src/modules/convert/trade-api/placeLimitOrder.ts @@ -1,77 +1,83 @@ // src/tools/binance-convert/trade-api/placeLimitOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { convertClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { convertClient } from "../../../config/binanceClient.js" export function registerBinanceConvertPlaceLimitOrder(server: McpServer) { - server.tool( - "BinanceConvertPlaceLimitOrder", - "Places a limit order to convert between two tokens at a specified price, using either base or quote amount, with options for wallet type and order expiry.", - { - baseAsset: z.string().describe("Base asset (from `fromIsBase` in /exchangeInfo API)"), - quoteAsset: z.string().describe("Quote asset"), - limitPrice: z.number().positive().describe("Symbol limit price (from baseAsset to quoteAsset)"), - baseAmount: z - .number() - .positive() - .optional() - .describe("Base asset amount (either this or quoteAmount is required)"), - quoteAmount: z - .number() - .positive() - .optional() - .describe("Quote asset amount (either this or baseAmount is required)"), - side: z.enum(["BUY", "SELL"]).describe("BUY or SELL"), - walletType: z - .enum(["SPOT", "FUNDING", "SPOT_FUNDING"]) - .optional() - .describe("Type of assets used: SPOT, FUNDING, or SPOT_FUNDING. Default is SPOT"), - expiredType: z - .enum(["1_D", "3_D", "7_D", "30_D"]) - .describe("Expiration type: 1_D, 3_D, 7_D, or 30_D (D = days)"), - recvWindow: z - .number() - .int() - .max(60000, "recvWindow cannot be greater than 60000") - .optional() - .describe("Time window for request validity") - }, - async (params) => { - try { - const response = await convertClient.restAPI.placeLimitOrder({ - baseAsset: params.baseAsset, - quoteAsset: params.quoteAsset, - limitPrice: params.limitPrice, - side: params.side, - expiredType: params.expiredType, - ...(params.baseAmount !== undefined && { baseAmount: params.baseAmount }), - ...(params.quoteAmount !== undefined && { quoteAmount: params.quoteAmount }), - ...(params.walletType && { walletType: params.walletType }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceConvertPlaceLimitOrder", + "Places a limit order to convert between two tokens at a specified price, using either base or quote amount, with options for wallet type and order expiry.", + { + baseAsset: z.string().describe("Base asset (from `fromIsBase` in /exchangeInfo API)"), + quoteAsset: z.string().describe("Quote asset"), + limitPrice: z + .number() + .positive() + .describe("Symbol limit price (from baseAsset to quoteAsset)"), + baseAmount: z + .number() + .positive() + .optional() + .describe("Base asset amount (either this or quoteAmount is required)"), + quoteAmount: z + .number() + .positive() + .optional() + .describe("Quote asset amount (either this or baseAmount is required)"), + side: z.enum(["BUY", "SELL"]).describe("BUY or SELL"), + walletType: z + .enum(["SPOT", "FUNDING", "SPOT_FUNDING"]) + .optional() + .describe("Type of assets used: SPOT, FUNDING, or SPOT_FUNDING. Default is SPOT"), + expiredType: z + .enum(["1_D", "3_D", "7_D", "30_D"]) + .describe("Expiration type: 1_D, 3_D, 7_D, or 30_D (D = days)"), + recvWindow: z + .number() + .int() + .max(60000, "recvWindow cannot be greater than 60000") + .optional() + .describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await convertClient.restAPI.placeLimitOrder({ + baseAsset: params.baseAsset, + quoteAsset: params.quoteAsset, + limitPrice: params.limitPrice, + side: params.side, + expiredType: params.expiredType, + ...(params.baseAmount !== undefined && { baseAmount: params.baseAmount }), + ...(params.quoteAmount !== undefined && { quoteAmount: params.quoteAmount }), + ...(params.walletType && { walletType: params.walletType }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully placed the limit order. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully placed the limit order. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to places a limit order: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to places a limit order: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/convert/trade-api/queryLimitOpenOrders.ts b/src/modules/convert/trade-api/queryLimitOpenOrders.ts index c397279c..84e405af 100644 --- a/src/modules/convert/trade-api/queryLimitOpenOrders.ts +++ b/src/modules/convert/trade-api/queryLimitOpenOrders.ts @@ -1,50 +1,53 @@ // src/tools/binance-convert/trade-api/queryLimitOpenOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { convertClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { convertClient } from "../../../config/binanceClient.js" export function registerBinanceConvertQueryLimitOpenOrders(server: McpServer) { - server.tool( - "BinanceConvertQueryLimitOpenOrders", - "Retrieves all your open limit orders for token conversions, showing details like assets, amounts, exchange rate, order status, and expiration time.", - { - recvWindow: z - .number() - .int() - .max(60000, "recvWindow must not be greater than 60000") - .optional() - .describe("This value must not exceed 60000") - }, - async (params) => { - try { - const response = await convertClient.restAPI.queryLimitOpenOrders({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceConvertQueryLimitOpenOrders", + "Retrieves all your open limit orders for token conversions, showing details like assets, amounts, exchange rate, order status, and expiration time.", + { + recvWindow: z + .number() + .int() + .max(60000, "recvWindow must not be greater than 60000") + .optional() + .describe("This value must not exceed 60000"), + }, + async (params) => { + try { + const response = await convertClient.restAPI.queryLimitOpenOrders({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved all the open limit orders for token conversions. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved all the open limit orders for token conversions. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve all your open limit orders : ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve all your open limit orders : ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/convert/trade-api/sendQuoteRequest.ts b/src/modules/convert/trade-api/sendQuoteRequest.ts index d3594f0c..8b7c40c7 100644 --- a/src/modules/convert/trade-api/sendQuoteRequest.ts +++ b/src/modules/convert/trade-api/sendQuoteRequest.ts @@ -1,65 +1,75 @@ // src/tools/binance-convert/trade-api/sendQuoteRequest.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { convertClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { convertClient } from "../../../config/binanceClient.js" export function registerBinanceConvertSendQuoteRequest(server: McpServer) { - server.tool( - "BinanceConvertSendQuoteRequest", - "Get a real-time quote to convert one token to another, including rate and amount, if you have enough funds.", - { - fromAsset: z.string().describe("Asset you will spend (required)"), - toAsset: z.string().describe("Asset you will receive (required)"), - fromAmount: z.number().positive().optional().describe("Amount to be debited after conversion"), - toAmount: z.number().positive().optional().describe("Amount to be credited after conversion"), - walletType: z.enum(["SPOT", "FUNDING"]).optional().describe("SPOT or FUNDING. Default is SPOT"), - validTime: z - .enum(["10s", "30s", "1m"]) - .optional() - .describe("Quote validity duration: 10s, 30s, 1m; default is 10s"), - recvWindow: z - .number() - .int() - .max(60000, "recvWindow cannot be greater than 60000") - .optional() - .describe("The value cannot be greater than 60000") - }, - async (params) => { - try { - const response = await convertClient.restAPI.sendQuoteRequest({ - fromAsset: params.fromAsset, - toAsset: params.toAsset, - ...(params.fromAmount && { fromAmount: params.fromAmount }), - ...(params.toAmount && { toAmount: params.toAmount }), - ...(params.walletType && { walletType: params.walletType }), - ...(params.validTime && { validTime: params.validTime }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceConvertSendQuoteRequest", + "Get a real-time quote to convert one token to another, including rate and amount, if you have enough funds.", + { + fromAsset: z.string().describe("Asset you will spend (required)"), + toAsset: z.string().describe("Asset you will receive (required)"), + fromAmount: z + .number() + .positive() + .optional() + .describe("Amount to be debited after conversion"), + toAmount: z.number().positive().optional().describe("Amount to be credited after conversion"), + walletType: z + .enum(["SPOT", "FUNDING"]) + .optional() + .describe("SPOT or FUNDING. Default is SPOT"), + validTime: z + .enum(["10s", "30s", "1m"]) + .optional() + .describe("Quote validity duration: 10s, 30s, 1m; default is 10s"), + recvWindow: z + .number() + .int() + .max(60000, "recvWindow cannot be greater than 60000") + .optional() + .describe("The value cannot be greater than 60000"), + }, + async (params) => { + try { + const response = await convertClient.restAPI.sendQuoteRequest({ + fromAsset: params.fromAsset, + toAsset: params.toAsset, + ...(params.fromAmount && { fromAmount: params.fromAmount }), + ...(params.toAmount && { toAmount: params.toAmount }), + ...(params.walletType && { walletType: params.walletType }), + ...(params.validTime && { validTime: params.validTime }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved real-time quote to convert one token to another. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved real-time quote to convert one token to another. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to get a real-time quote to convert: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to get a real-time quote to convert: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/copy-trading/FutureCopyTrading-api/followTrader.ts b/src/modules/copy-trading/FutureCopyTrading-api/followTrader.ts index 68c469d3..8f20dc19 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/followTrader.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/followTrader.ts @@ -5,53 +5,67 @@ * @license Apache-2.0 */ // src/modules/copy-trading/FutureCopyTrading-api/followTrader.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { copyTradingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { copyTradingClient } from "../../../config/binanceClient.js" export function registerBinanceCopyTradingFollowTrader(server: McpServer) { - server.tool( - "BinanceCopyTradingFollowTrader", - "Start following a lead trader to automatically copy their trades. ⚠️ RISK: Your funds will be used to copy trades. Only follow traders you trust.", - { - leadPortfolioId: z.string().describe("Lead trader's portfolio ID to follow"), - copyRatio: z.number().min(0.1).max(10).describe("Copy ratio (0.1-10x of their trades)"), - fixedAmount: z.string().optional().describe("Fixed amount per trade (alternative to ratio)"), - stopLossRatio: z.number().min(0.01).max(1).optional() - .describe("Stop loss ratio (e.g., 0.1 = stop if 10% loss)"), - takeProfitRatio: z.number().min(0.01).optional() - .describe("Take profit ratio (e.g., 0.5 = take profit at 50% gain)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await copyTradingClient.restAPI.followTrader({ - leadPortfolioId: params.leadPortfolioId, - copyRatio: params.copyRatio, - ...(params.fixedAmount && { fixedAmount: params.fixedAmount }), - ...(params.stopLossRatio && { stopLossRatio: params.stopLossRatio }), - ...(params.takeProfitRatio && { takeProfitRatio: params.takeProfitRatio }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCopyTradingFollowTrader", + "Start following a lead trader to automatically copy their trades. ⚠️ RISK: Your funds will be used to copy trades. Only follow traders you trust.", + { + leadPortfolioId: z.string().describe("Lead trader's portfolio ID to follow"), + copyRatio: z.number().min(0.1).max(10).describe("Copy ratio (0.1-10x of their trades)"), + fixedAmount: z.string().optional().describe("Fixed amount per trade (alternative to ratio)"), + stopLossRatio: z + .number() + .min(0.01) + .max(1) + .optional() + .describe("Stop loss ratio (e.g., 0.1 = stop if 10% loss)"), + takeProfitRatio: z + .number() + .min(0.01) + .optional() + .describe("Take profit ratio (e.g., 0.5 = take profit at 50% gain)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await copyTradingClient.restAPI.followTrader({ + leadPortfolioId: params.leadPortfolioId, + copyRatio: params.copyRatio, + ...(params.fixedAmount && { fixedAmount: params.fixedAmount }), + ...(params.stopLossRatio && { stopLossRatio: params.stopLossRatio }), + ...(params.takeProfitRatio && { takeProfitRatio: params.takeProfitRatio }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const _data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Now Following Trader!\n\nPortfolio: ${params.leadPortfolioId}\nCopy Ratio: ${params.copyRatio}x\nStop Loss: ${params.stopLossRatio ? params.stopLossRatio * 100 + "%" : "Not set"}\nTake Profit: ${params.takeProfitRatio ? params.takeProfitRatio * 100 + "%" : "Not set"}\n\n⚠️ Your trades will now automatically copy this trader.`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `✅ Now Following Trader!\n\nPortfolio: ${params.leadPortfolioId}\nCopy Ratio: ${params.copyRatio}x\nStop Loss: ${params.stopLossRatio ? (params.stopLossRatio * 100) + '%' : 'Not set'}\nTake Profit: ${params.takeProfitRatio ? (params.takeProfitRatio * 100) + '%' : 'Not set'}\n\n⚠️ Your trades will now automatically copy this trader.` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to follow trader: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to follow trader: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getCopyOrders.ts b/src/modules/copy-trading/FutureCopyTrading-api/getCopyOrders.ts index c2f2a36f..dab694e3 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getCopyOrders.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getCopyOrders.ts @@ -5,49 +5,56 @@ * @license Apache-2.0 */ // src/modules/copy-trading/FutureCopyTrading-api/getCopyOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { copyTradingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { copyTradingClient } from "../../../config/binanceClient.js" export function registerBinanceCopyTradingGetCopyOrders(server: McpServer) { - server.tool( - "BinanceCopyTradingGetCopyOrders", - "Get your copy trading order history. Shows all orders executed from copying lead traders.", - { - startTime: z.number().int().optional().describe("Start time in ms"), - endTime: z.number().int().optional().describe("End time in ms"), - pageNumber: z.number().int().min(1).default(1).optional().describe("Page number"), - pageSize: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await copyTradingClient.restAPI.getCopyOrders({ - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.pageNumber && { pageNumber: params.pageNumber }), - ...(params.pageSize && { pageSize: params.pageSize }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCopyTradingGetCopyOrders", + "Get your copy trading order history. Shows all orders executed from copying lead traders.", + { + startTime: z.number().int().optional().describe("Start time in ms"), + endTime: z.number().int().optional().describe("End time in ms"), + pageNumber: z.number().int().min(1).default(1).optional().describe("Page number"), + pageSize: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await copyTradingClient.restAPI.getCopyOrders({ + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.pageNumber && { pageNumber: params.pageNumber }), + ...(params.pageSize && { pageSize: params.pageSize }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📋 Copy Trading Orders\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `📋 Copy Trading Orders\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get copy orders: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to get copy orders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getCopyPositions.ts b/src/modules/copy-trading/FutureCopyTrading-api/getCopyPositions.ts index 52644037..6e294740 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getCopyPositions.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getCopyPositions.ts @@ -5,41 +5,48 @@ * @license Apache-2.0 */ // src/modules/copy-trading/FutureCopyTrading-api/getCopyPositions.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { copyTradingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { copyTradingClient } from "../../../config/binanceClient.js" export function registerBinanceCopyTradingGetCopyPositions(server: McpServer) { - server.tool( - "BinanceCopyTradingGetCopyPositions", - "Get your current positions from copy trading. Shows all open positions created by following lead traders.", - { - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await copyTradingClient.restAPI.getCopyPositions({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCopyTradingGetCopyPositions", + "Get your current positions from copy trading. Shows all open positions created by following lead traders.", + { + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await copyTradingClient.restAPI.getCopyPositions({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📈 Your Copy Trading Positions\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `📈 Your Copy Trading Positions\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get copy positions: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to get copy positions: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getFollowingTraders.ts b/src/modules/copy-trading/FutureCopyTrading-api/getFollowingTraders.ts index 91ce27a0..bbb58675 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getFollowingTraders.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getFollowingTraders.ts @@ -5,41 +5,48 @@ * @license Apache-2.0 */ // src/modules/copy-trading/FutureCopyTrading-api/getFollowingTraders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { copyTradingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { copyTradingClient } from "../../../config/binanceClient.js" export function registerBinanceCopyTradingGetFollowingTraders(server: McpServer) { - server.tool( - "BinanceCopyTradingGetFollowingTraders", - "Get the list of traders you are currently following. Shows copy settings and performance for each.", - { - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await copyTradingClient.restAPI.getFollowingTraders({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCopyTradingGetFollowingTraders", + "Get the list of traders you are currently following. Shows copy settings and performance for each.", + { + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await copyTradingClient.restAPI.getFollowingTraders({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `👥 Traders You're Following\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `👥 Traders You're Following\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get following traders: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to get following traders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts b/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts index def3b5f3..57786147 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts @@ -1,45 +1,48 @@ // src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { copyTradingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { copyTradingClient } from "../../../config/binanceClient.js" export function registerBinanceGetFuturesLeadTraderStatus(server: McpServer) { - server.tool( - "BinanceGetFuturesLeadTraderStatus", - "Checks and returns whether the user is currently a Futures Lead Trader in Binance Copy Trading, along with the timestamp of the status check.", - { - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await copyTradingClient.restAPI.getFuturesLeadTraderStatus({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetFuturesLeadTraderStatus", + "Checks and returns whether the user is currently a Futures Lead Trader in Binance Copy Trading, along with the timestamp of the status check.", + { + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await copyTradingClient.restAPI.getFuturesLeadTraderStatus({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved user futures trading details. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved user futures trading details. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to Check and return whether the user is currently a Futures Lead Trader in Binance Copy Trading: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to Check and return whether the user is currently a Futures Lead Trader in Binance Copy Trading: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts b/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts index 09399375..925b449f 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts @@ -1,43 +1,46 @@ // src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { copyTradingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { copyTradingClient } from "../../../config/binanceClient.js" export function registerBinanceGetFuturesLeadTradingSymbolWhitelist(server: McpServer) { - server.tool( - "BinanceGetFuturesLeadTradingSymbolWhitelist", - "Whitelist of trading pairs (symbols) that are allowed for Futures Lead Traders in copy trading, including base and quote assets.", - { - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await copyTradingClient.restAPI.getFuturesLeadTradingSymbolWhitelist({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetFuturesLeadTradingSymbolWhitelist", + "Whitelist of trading pairs (symbols) that are allowed for Futures Lead Traders in copy trading, including base and quote assets.", + { + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await copyTradingClient.restAPI.getFuturesLeadTradingSymbolWhitelist({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved trading pairs. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved trading pairs. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to whitelist of trading pairs: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to whitelist of trading pairs: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getLeadTraders.ts b/src/modules/copy-trading/FutureCopyTrading-api/getLeadTraders.ts index ddde5634..b4820e90 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getLeadTraders.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getLeadTraders.ts @@ -5,49 +5,56 @@ * @license Apache-2.0 */ // src/modules/copy-trading/FutureCopyTrading-api/getLeadTraders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { copyTradingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { copyTradingClient } from "../../../config/binanceClient.js" export function registerBinanceGetLeadTraders(server: McpServer) { - server.tool( - "BinanceCopyTradingGetLeadTraders", - "Browse available lead traders for copy trading. View their performance stats and follower count to find traders to copy.", - { - isShared: z.boolean().optional().describe("Filter by shared portfolio traders"), - tradeType: z.enum(["PERPETUAL"]).optional().describe("Trade type filter"), - pageNumber: z.number().int().min(1).default(1).optional().describe("Page number"), - pageSize: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await copyTradingClient.restAPI.getLeadTraders({ - ...(params.isShared !== undefined && { isShared: params.isShared }), - ...(params.tradeType && { tradeType: params.tradeType }), - ...(params.pageNumber && { pageNumber: params.pageNumber }), - ...(params.pageSize && { pageSize: params.pageSize }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCopyTradingGetLeadTraders", + "Browse available lead traders for copy trading. View their performance stats and follower count to find traders to copy.", + { + isShared: z.boolean().optional().describe("Filter by shared portfolio traders"), + tradeType: z.enum(["PERPETUAL"]).optional().describe("Trade type filter"), + pageNumber: z.number().int().min(1).default(1).optional().describe("Page number"), + pageSize: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await copyTradingClient.restAPI.getLeadTraders({ + ...(params.isShared !== undefined && { isShared: params.isShared }), + ...(params.tradeType && { tradeType: params.tradeType }), + ...(params.pageNumber && { pageNumber: params.pageNumber }), + ...(params.pageSize && { pageSize: params.pageSize }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `👥 Lead Traders\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `👥 Lead Traders\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get lead traders: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to get lead traders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getTraderPerformance.ts b/src/modules/copy-trading/FutureCopyTrading-api/getTraderPerformance.ts index 7d72ea80..1e87be5c 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getTraderPerformance.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getTraderPerformance.ts @@ -5,45 +5,52 @@ * @license Apache-2.0 */ // src/modules/copy-trading/FutureCopyTrading-api/getTraderPerformance.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { copyTradingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { copyTradingClient } from "../../../config/binanceClient.js" export function registerBinanceGetTraderPerformance(server: McpServer) { - server.tool( - "BinanceCopyTradingGetTraderPerformance", - "Get detailed performance statistics for a lead trader. Includes ROI, PNL, win rate, and other metrics.", - { - leadPortfolioId: z.string().describe("Lead trader's portfolio ID"), - tradeType: z.enum(["PERPETUAL"]).optional().describe("Trade type"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await copyTradingClient.restAPI.getTraderPerformance({ - leadPortfolioId: params.leadPortfolioId, - ...(params.tradeType && { tradeType: params.tradeType }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCopyTradingGetTraderPerformance", + "Get detailed performance statistics for a lead trader. Includes ROI, PNL, win rate, and other metrics.", + { + leadPortfolioId: z.string().describe("Lead trader's portfolio ID"), + tradeType: z.enum(["PERPETUAL"]).optional().describe("Trade type"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await copyTradingClient.restAPI.getTraderPerformance({ + leadPortfolioId: params.leadPortfolioId, + ...(params.tradeType && { tradeType: params.tradeType }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📊 Trader Performance\n\nPortfolio: ${params.leadPortfolioId}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `📊 Trader Performance\n\nPortfolio: ${params.leadPortfolioId}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get trader performance: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to get trader performance: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getTraderPositions.ts b/src/modules/copy-trading/FutureCopyTrading-api/getTraderPositions.ts index 37294f80..e1d601c5 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getTraderPositions.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getTraderPositions.ts @@ -5,45 +5,52 @@ * @license Apache-2.0 */ // src/modules/copy-trading/FutureCopyTrading-api/getTraderPositions.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { copyTradingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { copyTradingClient } from "../../../config/binanceClient.js" export function registerBinanceGetTraderPositions(server: McpServer) { - server.tool( - "BinanceCopyTradingGetTraderPositions", - "View a lead trader's current open positions. See what positions they are holding to understand their strategy.", - { - leadPortfolioId: z.string().describe("Lead trader's portfolio ID"), - tradeType: z.enum(["PERPETUAL"]).optional().describe("Trade type"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await copyTradingClient.restAPI.getTraderPositions({ - leadPortfolioId: params.leadPortfolioId, - ...(params.tradeType && { tradeType: params.tradeType }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCopyTradingGetTraderPositions", + "View a lead trader's current open positions. See what positions they are holding to understand their strategy.", + { + leadPortfolioId: z.string().describe("Lead trader's portfolio ID"), + tradeType: z.enum(["PERPETUAL"]).optional().describe("Trade type"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await copyTradingClient.restAPI.getTraderPositions({ + leadPortfolioId: params.leadPortfolioId, + ...(params.tradeType && { tradeType: params.tradeType }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📈 Trader Positions\n\nPortfolio: ${params.leadPortfolioId}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `📈 Trader Positions\n\nPortfolio: ${params.leadPortfolioId}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get trader positions: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to get trader positions: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getTraderSymbolStats.ts b/src/modules/copy-trading/FutureCopyTrading-api/getTraderSymbolStats.ts index e9d9f4e3..71090402 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getTraderSymbolStats.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getTraderSymbolStats.ts @@ -5,45 +5,52 @@ * @license Apache-2.0 */ // src/modules/copy-trading/FutureCopyTrading-api/getTraderSymbolStats.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { copyTradingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { copyTradingClient } from "../../../config/binanceClient.js" export function registerBinanceGetTraderSymbolStats(server: McpServer) { - server.tool( - "BinanceCopyTradingGetTraderSymbolStats", - "Get a lead trader's trading statistics per symbol. Shows which symbols they trade most and their success rate.", - { - leadPortfolioId: z.string().describe("Lead trader's portfolio ID"), - tradeType: z.enum(["PERPETUAL"]).optional().describe("Trade type"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await copyTradingClient.restAPI.getTraderSymbolStats({ - leadPortfolioId: params.leadPortfolioId, - ...(params.tradeType && { tradeType: params.tradeType }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCopyTradingGetTraderSymbolStats", + "Get a lead trader's trading statistics per symbol. Shows which symbols they trade most and their success rate.", + { + leadPortfolioId: z.string().describe("Lead trader's portfolio ID"), + tradeType: z.enum(["PERPETUAL"]).optional().describe("Trade type"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await copyTradingClient.restAPI.getTraderSymbolStats({ + leadPortfolioId: params.leadPortfolioId, + ...(params.tradeType && { tradeType: params.tradeType }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📊 Trader Symbol Statistics\n\nPortfolio: ${params.leadPortfolioId}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `📊 Trader Symbol Statistics\n\nPortfolio: ${params.leadPortfolioId}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get trader symbol stats: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to get trader symbol stats: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/copy-trading/FutureCopyTrading-api/index.ts b/src/modules/copy-trading/FutureCopyTrading-api/index.ts index 486470c3..c7be5c17 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/index.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/index.ts @@ -1,13 +1,14 @@ // src/tools/binance-copy-trading/FutureCopyTrading-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetFuturesLeadTraderStatus } from "./getFuturesLeadTraderStatus.js"; -import { registerBinanceGetFuturesLeadTradingSymbolWhitelist } from "./getFuturesLeadTradingSymbolWhitelist.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceGetFuturesLeadTraderStatus } from "./getFuturesLeadTraderStatus.js" +import { registerBinanceGetFuturesLeadTradingSymbolWhitelist } from "./getFuturesLeadTradingSymbolWhitelist.js" // Registers Binance Futures Copy Trading API tools with the MCP server. export function registerBinanceFutureCopyTradingApiTools(server: McpServer) { - // Registers an endpoint to get the status of a lead trader in futures copy trading - registerBinanceGetFuturesLeadTraderStatus(server); + // Registers an endpoint to get the status of a lead trader in futures copy trading + registerBinanceGetFuturesLeadTraderStatus(server) - // Registers an endpoint to get the whitelist of symbols available for futures copy trading - registerBinanceGetFuturesLeadTradingSymbolWhitelist(server); + // Registers an endpoint to get the whitelist of symbols available for futures copy trading + registerBinanceGetFuturesLeadTradingSymbolWhitelist(server) } diff --git a/src/modules/copy-trading/FutureCopyTrading-api/unfollowTrader.ts b/src/modules/copy-trading/FutureCopyTrading-api/unfollowTrader.ts index abdf5426..343b3347 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/unfollowTrader.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/unfollowTrader.ts @@ -5,43 +5,50 @@ * @license Apache-2.0 */ // src/modules/copy-trading/FutureCopyTrading-api/unfollowTrader.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { copyTradingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { copyTradingClient } from "../../../config/binanceClient.js" export function registerBinanceCopyTradingUnfollowTrader(server: McpServer) { - server.tool( - "BinanceCopyTradingUnfollowTrader", - "Stop following a lead trader. Your existing copied positions will remain open until manually closed.", - { - leadPortfolioId: z.string().describe("Lead trader's portfolio ID to unfollow"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await copyTradingClient.restAPI.unfollowTrader({ - leadPortfolioId: params.leadPortfolioId, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCopyTradingUnfollowTrader", + "Stop following a lead trader. Your existing copied positions will remain open until manually closed.", + { + leadPortfolioId: z.string().describe("Lead trader's portfolio ID to unfollow"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await copyTradingClient.restAPI.unfollowTrader({ + leadPortfolioId: params.leadPortfolioId, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const _data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Stopped Following Trader!\n\nPortfolio: ${params.leadPortfolioId}\n\n💡 Note: Existing positions from copy trading are still open. You may want to close them manually.`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `✅ Stopped Following Trader!\n\nPortfolio: ${params.leadPortfolioId}\n\n💡 Note: Existing positions from copy trading are still open. You may want to close them manually.` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to unfollow trader: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to unfollow trader: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/copy-trading/index.ts b/src/modules/copy-trading/index.ts index fc607ffa..73dce807 100644 --- a/src/modules/copy-trading/index.ts +++ b/src/modules/copy-trading/index.ts @@ -1,12 +1,13 @@ // src/tools/binance-copy-trading/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceFutureCopyTradingApiTools } from "./FutureCopyTrading-api/index.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceFutureCopyTradingApiTools } from "./FutureCopyTrading-api/index.js" // Registers all Binance Copy Trading related tools with the MCP server. export function registerBinanceCopyTradingTools(server: McpServer) { - // Register the Binance Futures Copy Trading API tools with the given server. - registerBinanceFutureCopyTradingApiTools(server); + // Register the Binance Futures Copy Trading API tools with the given server. + registerBinanceFutureCopyTradingApiTools(server) } // Alias for binance.ts compatibility -export { registerBinanceCopyTradingTools as registerCopyTrading }; +export { registerBinanceCopyTradingTools as registerCopyTrading } diff --git a/src/modules/crypto-loans/flexible/adjustLTV.ts b/src/modules/crypto-loans/flexible/adjustLTV.ts index df400e4d..eb86c208 100644 --- a/src/modules/crypto-loans/flexible/adjustLTV.ts +++ b/src/modules/crypto-loans/flexible/adjustLTV.ts @@ -5,49 +5,58 @@ * @license Apache-2.0 */ // src/modules/crypto-loans/flexible/adjustLTV.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { cryptoLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../../config/binanceClient.js" export function registerFlexibleLoanAdjustLTV(server: McpServer) { - server.tool( - "BinanceCryptoLoanFlexibleAdjustLTV", - "Adjust LTV (Loan-to-Value) ratio by adding or removing collateral. Lower LTV = safer position.", - { - loanCoin: z.string().describe("Loan coin"), - collateralCoin: z.string().describe("Collateral coin"), - adjustmentAmount: z.string().describe("Amount to add (positive) or remove (negative)"), - direction: z.enum(["ADDITIONAL", "REDUCED"]).describe("ADDITIONAL to add collateral, REDUCED to remove"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await cryptoLoanClient.restAPI.flexibleLoanAdjustLTV({ - loanCoin: params.loanCoin, - collateralCoin: params.collateralCoin, - adjustmentAmount: params.adjustmentAmount, - direction: params.direction, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCryptoLoanFlexibleAdjustLTV", + "Adjust LTV (Loan-to-Value) ratio by adding or removing collateral. Lower LTV = safer position.", + { + loanCoin: z.string().describe("Loan coin"), + collateralCoin: z.string().describe("Collateral coin"), + adjustmentAmount: z.string().describe("Amount to add (positive) or remove (negative)"), + direction: z + .enum(["ADDITIONAL", "REDUCED"]) + .describe("ADDITIONAL to add collateral, REDUCED to remove"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await cryptoLoanClient.restAPI.flexibleLoanAdjustLTV({ + loanCoin: params.loanCoin, + collateralCoin: params.collateralCoin, + adjustmentAmount: params.adjustmentAmount, + direction: params.direction, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ LTV Adjusted!\n\nDirection: ${params.direction}\nAmount: ${params.adjustmentAmount} ${params.collateralCoin}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `✅ LTV Adjusted!\n\nDirection: ${params.direction}\nAmount: ${params.adjustmentAmount} ${params.collateralCoin}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to adjust LTV: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to adjust LTV: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/crypto-loans/flexible/borrow.ts b/src/modules/crypto-loans/flexible/borrow.ts index e5ec8ad6..66961310 100644 --- a/src/modules/crypto-loans/flexible/borrow.ts +++ b/src/modules/crypto-loans/flexible/borrow.ts @@ -5,49 +5,62 @@ * @license Apache-2.0 */ // src/modules/crypto-loans/flexible/borrow.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { cryptoLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../../config/binanceClient.js" export function registerFlexibleLoanBorrow(server: McpServer) { - server.tool( - "BinanceCryptoLoanFlexibleBorrow", - "Borrow crypto using a flexible loan. ⚠️ Your collateral will be locked. Interest accrues daily. Monitor LTV ratio to avoid liquidation.", - { - loanCoin: z.string().describe("Coin to borrow (e.g., 'USDT')"), - loanAmount: z.string().optional().describe("Amount to borrow (provide either loanAmount or collateralAmount)"), - collateralCoin: z.string().describe("Collateral coin (e.g., 'BTC')"), - collateralAmount: z.string().optional().describe("Collateral amount (provide either loanAmount or collateralAmount)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await cryptoLoanClient.restAPI.flexibleLoanBorrow({ - loanCoin: params.loanCoin, - collateralCoin: params.collateralCoin, - ...(params.loanAmount && { loanAmount: params.loanAmount }), - ...(params.collateralAmount && { collateralAmount: params.collateralAmount }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCryptoLoanFlexibleBorrow", + "Borrow crypto using a flexible loan. ⚠️ Your collateral will be locked. Interest accrues daily. Monitor LTV ratio to avoid liquidation.", + { + loanCoin: z.string().describe("Coin to borrow (e.g., 'USDT')"), + loanAmount: z + .string() + .optional() + .describe("Amount to borrow (provide either loanAmount or collateralAmount)"), + collateralCoin: z.string().describe("Collateral coin (e.g., 'BTC')"), + collateralAmount: z + .string() + .optional() + .describe("Collateral amount (provide either loanAmount or collateralAmount)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await cryptoLoanClient.restAPI.flexibleLoanBorrow({ + loanCoin: params.loanCoin, + collateralCoin: params.collateralCoin, + ...(params.loanAmount && { loanAmount: params.loanAmount }), + ...(params.collateralAmount && { collateralAmount: params.collateralAmount }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Flexible Loan Borrowed!\n\nLoan Coin: ${params.loanCoin}\nCollateral: ${params.collateralCoin}\n\n⚠️ Remember to monitor your LTV ratio and repay to avoid liquidation.\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `✅ Flexible Loan Borrowed!\n\nLoan Coin: ${params.loanCoin}\nCollateral: ${params.collateralCoin}\n\n⚠️ Remember to monitor your LTV ratio and repay to avoid liquidation.\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to borrow: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to borrow: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/crypto-loans/flexible/getBorrowHistory.ts b/src/modules/crypto-loans/flexible/getBorrowHistory.ts index e18acb61..14a80099 100644 --- a/src/modules/crypto-loans/flexible/getBorrowHistory.ts +++ b/src/modules/crypto-loans/flexible/getBorrowHistory.ts @@ -5,53 +5,60 @@ * @license Apache-2.0 */ // src/modules/crypto-loans/flexible/getBorrowHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { cryptoLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../../config/binanceClient.js" export function registerFlexibleLoanBorrowHistory(server: McpServer) { - server.tool( - "BinanceCryptoLoanFlexibleBorrowHistory", - "Get your flexible loan borrowing history.", - { - loanCoin: z.string().optional().describe("Filter by loan coin"), - collateralCoin: z.string().optional().describe("Filter by collateral coin"), - startTime: z.number().int().optional().describe("Start time in ms"), - endTime: z.number().int().optional().describe("End time in ms"), - current: z.number().int().min(1).default(1).optional().describe("Page number"), - limit: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await cryptoLoanClient.restAPI.getFlexibleLoanBorrowHistory({ - ...(params.loanCoin && { loanCoin: params.loanCoin }), - ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.current && { current: params.current }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCryptoLoanFlexibleBorrowHistory", + "Get your flexible loan borrowing history.", + { + loanCoin: z.string().optional().describe("Filter by loan coin"), + collateralCoin: z.string().optional().describe("Filter by collateral coin"), + startTime: z.number().int().optional().describe("Start time in ms"), + endTime: z.number().int().optional().describe("End time in ms"), + current: z.number().int().min(1).default(1).optional().describe("Page number"), + limit: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await cryptoLoanClient.restAPI.getFlexibleLoanBorrowHistory({ + ...(params.loanCoin && { loanCoin: params.loanCoin }), + ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.current && { current: params.current }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📜 Flexible Loan Borrow History\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `📜 Flexible Loan Borrow History\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get borrow history: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to get borrow history: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/crypto-loans/flexible/getFlexibleCollateralAssets.ts b/src/modules/crypto-loans/flexible/getFlexibleCollateralAssets.ts index 93989ff4..87479c0a 100644 --- a/src/modules/crypto-loans/flexible/getFlexibleCollateralAssets.ts +++ b/src/modules/crypto-loans/flexible/getFlexibleCollateralAssets.ts @@ -5,43 +5,50 @@ * @license Apache-2.0 */ // src/modules/crypto-loans/flexible/getFlexibleCollateralAssets.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { cryptoLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../../config/binanceClient.js" export function registerFlexibleCollateralAssets(server: McpServer) { - server.tool( - "BinanceCryptoLoanFlexibleCollateralAssets", - "Get available collateral assets for flexible crypto loans. Shows which assets you can use as collateral.", - { - collateralCoin: z.string().optional().describe("Filter by collateral coin"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await cryptoLoanClient.restAPI.getFlexibleCollateralAssets({ - ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCryptoLoanFlexibleCollateralAssets", + "Get available collateral assets for flexible crypto loans. Shows which assets you can use as collateral.", + { + collateralCoin: z.string().optional().describe("Filter by collateral coin"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await cryptoLoanClient.restAPI.getFlexibleCollateralAssets({ + ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `🔒 Flexible Loan Collateral Assets\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `🔒 Flexible Loan Collateral Assets\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get collateral assets: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to get collateral assets: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/crypto-loans/flexible/getFlexibleLoanAssets.ts b/src/modules/crypto-loans/flexible/getFlexibleLoanAssets.ts index 91c0e497..8aee566d 100644 --- a/src/modules/crypto-loans/flexible/getFlexibleLoanAssets.ts +++ b/src/modules/crypto-loans/flexible/getFlexibleLoanAssets.ts @@ -5,43 +5,50 @@ * @license Apache-2.0 */ // src/modules/crypto-loans/flexible/getFlexibleLoanAssets.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { cryptoLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../../config/binanceClient.js" export function registerFlexibleLoanAssets(server: McpServer) { - server.tool( - "BinanceCryptoLoanFlexibleAssets", - "Get available assets for flexible crypto loans. Shows which assets you can borrow and their rates.", - { - loanCoin: z.string().optional().describe("Filter by loan coin (e.g., 'USDT', 'BUSD')"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await cryptoLoanClient.restAPI.getFlexibleLoanAssets({ - ...(params.loanCoin && { loanCoin: params.loanCoin }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCryptoLoanFlexibleAssets", + "Get available assets for flexible crypto loans. Shows which assets you can borrow and their rates.", + { + loanCoin: z.string().optional().describe("Filter by loan coin (e.g., 'USDT', 'BUSD')"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await cryptoLoanClient.restAPI.getFlexibleLoanAssets({ + ...(params.loanCoin && { loanCoin: params.loanCoin }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `💰 Flexible Loan Assets\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `💰 Flexible Loan Assets\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get flexible loan assets: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to get flexible loan assets: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/crypto-loans/flexible/getOngoingOrders.ts b/src/modules/crypto-loans/flexible/getOngoingOrders.ts index dd0a5fbf..72f55f1b 100644 --- a/src/modules/crypto-loans/flexible/getOngoingOrders.ts +++ b/src/modules/crypto-loans/flexible/getOngoingOrders.ts @@ -5,49 +5,56 @@ * @license Apache-2.0 */ // src/modules/crypto-loans/flexible/getOngoingOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { cryptoLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../../config/binanceClient.js" export function registerFlexibleLoanOngoingOrders(server: McpServer) { - server.tool( - "BinanceCryptoLoanFlexibleOngoingOrders", - "Get your current flexible loan positions. Shows outstanding amounts, collateral, and LTV ratios.", - { - loanCoin: z.string().optional().describe("Filter by loan coin"), - collateralCoin: z.string().optional().describe("Filter by collateral coin"), - current: z.number().int().min(1).default(1).optional().describe("Page number"), - limit: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await cryptoLoanClient.restAPI.getFlexibleLoanOngoingOrders({ - ...(params.loanCoin && { loanCoin: params.loanCoin }), - ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), - ...(params.current && { current: params.current }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCryptoLoanFlexibleOngoingOrders", + "Get your current flexible loan positions. Shows outstanding amounts, collateral, and LTV ratios.", + { + loanCoin: z.string().optional().describe("Filter by loan coin"), + collateralCoin: z.string().optional().describe("Filter by collateral coin"), + current: z.number().int().min(1).default(1).optional().describe("Page number"), + limit: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await cryptoLoanClient.restAPI.getFlexibleLoanOngoingOrders({ + ...(params.loanCoin && { loanCoin: params.loanCoin }), + ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), + ...(params.current && { current: params.current }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📊 Ongoing Flexible Loans\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `📊 Ongoing Flexible Loans\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get ongoing orders: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to get ongoing orders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/crypto-loans/flexible/getRepayHistory.ts b/src/modules/crypto-loans/flexible/getRepayHistory.ts index b86353b5..1e64c2dd 100644 --- a/src/modules/crypto-loans/flexible/getRepayHistory.ts +++ b/src/modules/crypto-loans/flexible/getRepayHistory.ts @@ -5,53 +5,60 @@ * @license Apache-2.0 */ // src/modules/crypto-loans/flexible/getRepayHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { cryptoLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../../config/binanceClient.js" export function registerFlexibleLoanRepayHistory(server: McpServer) { - server.tool( - "BinanceCryptoLoanFlexibleRepayHistory", - "Get your flexible loan repayment history.", - { - loanCoin: z.string().optional().describe("Filter by loan coin"), - collateralCoin: z.string().optional().describe("Filter by collateral coin"), - startTime: z.number().int().optional().describe("Start time in ms"), - endTime: z.number().int().optional().describe("End time in ms"), - current: z.number().int().min(1).default(1).optional().describe("Page number"), - limit: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await cryptoLoanClient.restAPI.getFlexibleLoanRepayHistory({ - ...(params.loanCoin && { loanCoin: params.loanCoin }), - ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.current && { current: params.current }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCryptoLoanFlexibleRepayHistory", + "Get your flexible loan repayment history.", + { + loanCoin: z.string().optional().describe("Filter by loan coin"), + collateralCoin: z.string().optional().describe("Filter by collateral coin"), + startTime: z.number().int().optional().describe("Start time in ms"), + endTime: z.number().int().optional().describe("End time in ms"), + current: z.number().int().min(1).default(1).optional().describe("Page number"), + limit: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await cryptoLoanClient.restAPI.getFlexibleLoanRepayHistory({ + ...(params.loanCoin && { loanCoin: params.loanCoin }), + ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.current && { current: params.current }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📜 Flexible Loan Repay History\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `📜 Flexible Loan Repay History\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get repay history: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to get repay history: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/crypto-loans/flexible/index.ts b/src/modules/crypto-loans/flexible/index.ts index c267589e..199128f2 100644 --- a/src/modules/crypto-loans/flexible/index.ts +++ b/src/modules/crypto-loans/flexible/index.ts @@ -5,23 +5,24 @@ * @license Apache-2.0 */ // src/modules/crypto-loans/flexible/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerFlexibleLoanAssets } from "./getFlexibleLoanAssets.js"; -import { registerFlexibleCollateralAssets } from "./getFlexibleCollateralAssets.js"; -import { registerFlexibleLoanBorrow } from "./borrow.js"; -import { registerFlexibleLoanRepay } from "./repay.js"; -import { registerFlexibleLoanAdjustLTV } from "./adjustLTV.js"; -import { registerFlexibleLoanOngoingOrders } from "./getOngoingOrders.js"; -import { registerFlexibleLoanBorrowHistory } from "./getBorrowHistory.js"; -import { registerFlexibleLoanRepayHistory } from "./getRepayHistory.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerFlexibleLoanAdjustLTV } from "./adjustLTV.js" +import { registerFlexibleLoanBorrow } from "./borrow.js" +import { registerFlexibleLoanBorrowHistory } from "./getBorrowHistory.js" +import { registerFlexibleCollateralAssets } from "./getFlexibleCollateralAssets.js" +import { registerFlexibleLoanAssets } from "./getFlexibleLoanAssets.js" +import { registerFlexibleLoanOngoingOrders } from "./getOngoingOrders.js" +import { registerFlexibleLoanRepayHistory } from "./getRepayHistory.js" +import { registerFlexibleLoanRepay } from "./repay.js" export function registerCryptoLoansFlexibleTools(server: McpServer) { - registerFlexibleLoanAssets(server); - registerFlexibleCollateralAssets(server); - registerFlexibleLoanBorrow(server); - registerFlexibleLoanRepay(server); - registerFlexibleLoanAdjustLTV(server); - registerFlexibleLoanOngoingOrders(server); - registerFlexibleLoanBorrowHistory(server); - registerFlexibleLoanRepayHistory(server); + registerFlexibleLoanAssets(server) + registerFlexibleCollateralAssets(server) + registerFlexibleLoanBorrow(server) + registerFlexibleLoanRepay(server) + registerFlexibleLoanAdjustLTV(server) + registerFlexibleLoanOngoingOrders(server) + registerFlexibleLoanBorrowHistory(server) + registerFlexibleLoanRepayHistory(server) } diff --git a/src/modules/crypto-loans/flexible/repay.ts b/src/modules/crypto-loans/flexible/repay.ts index 1412b6a8..54c8f843 100644 --- a/src/modules/crypto-loans/flexible/repay.ts +++ b/src/modules/crypto-loans/flexible/repay.ts @@ -5,51 +5,60 @@ * @license Apache-2.0 */ // src/modules/crypto-loans/flexible/repay.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { cryptoLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../../config/binanceClient.js" export function registerFlexibleLoanRepay(server: McpServer) { - server.tool( - "BinanceCryptoLoanFlexibleRepay", - "Repay a flexible crypto loan. Your collateral will be released proportionally. 💸", - { - loanCoin: z.string().describe("Loan coin to repay"), - collateralCoin: z.string().describe("Collateral coin"), - repayAmount: z.string().describe("Amount to repay"), - collateralReturn: z.boolean().optional().describe("Return collateral after full repayment"), - fullRepayment: z.boolean().optional().describe("Repay full outstanding amount"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await cryptoLoanClient.restAPI.flexibleLoanRepay({ - loanCoin: params.loanCoin, - collateralCoin: params.collateralCoin, - repayAmount: params.repayAmount, - ...(params.collateralReturn !== undefined && { collateralReturn: params.collateralReturn }), - ...(params.fullRepayment !== undefined && { fullRepayment: params.fullRepayment }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCryptoLoanFlexibleRepay", + "Repay a flexible crypto loan. Your collateral will be released proportionally. 💸", + { + loanCoin: z.string().describe("Loan coin to repay"), + collateralCoin: z.string().describe("Collateral coin"), + repayAmount: z.string().describe("Amount to repay"), + collateralReturn: z.boolean().optional().describe("Return collateral after full repayment"), + fullRepayment: z.boolean().optional().describe("Repay full outstanding amount"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await cryptoLoanClient.restAPI.flexibleLoanRepay({ + loanCoin: params.loanCoin, + collateralCoin: params.collateralCoin, + repayAmount: params.repayAmount, + ...(params.collateralReturn !== undefined && { + collateralReturn: params.collateralReturn, + }), + ...(params.fullRepayment !== undefined && { fullRepayment: params.fullRepayment }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Loan Repayment Successful!\n\nRepaid: ${params.repayAmount} ${params.loanCoin}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `✅ Loan Repayment Successful!\n\nRepaid: ${params.repayAmount} ${params.loanCoin}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to repay loan: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to repay loan: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/crypto-loans/index.ts b/src/modules/crypto-loans/index.ts index b0e7ae92..87939007 100644 --- a/src/modules/crypto-loans/index.ts +++ b/src/modules/crypto-loans/index.ts @@ -1,7 +1,8 @@ // src/modules/crypto-loans/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceCryptoLoansTools } from "../../tools/binance-crypto-loans/index.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceCryptoLoansTools } from "../../tools/binance-crypto-loans/index.js" export function registerCryptoLoans(server: McpServer) { - registerBinanceCryptoLoansTools(server); + registerBinanceCryptoLoansTools(server) } diff --git a/src/modules/dual-investment/index.ts b/src/modules/dual-investment/index.ts index d3c2e381..3ceddc92 100644 --- a/src/modules/dual-investment/index.ts +++ b/src/modules/dual-investment/index.ts @@ -1,12 +1,13 @@ // src/tools/binance-dual-investment/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceDualInvestmentTradeApiTools } from "./trade-api/index.js"; -import { registerBinanceDualInvestmentMarketApiTools } from "./market-api/index.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceDualInvestmentMarketApiTools } from "./market-api/index.js" +import { registerBinanceDualInvestmentTradeApiTools } from "./trade-api/index.js" export function registerBinanceDualInvestmentTools(server: McpServer) { - registerBinanceDualInvestmentTradeApiTools(server); - registerBinanceDualInvestmentMarketApiTools(server); + registerBinanceDualInvestmentTradeApiTools(server) + registerBinanceDualInvestmentMarketApiTools(server) } // Alias for binance.ts compatibility -export { registerBinanceDualInvestmentTools as registerDualInvestment }; +export { registerBinanceDualInvestmentTools as registerDualInvestment } diff --git a/src/modules/dual-investment/market-api/getDualInvestmentProductList.ts b/src/modules/dual-investment/market-api/getDualInvestmentProductList.ts index 048f342d..b9d20a31 100644 --- a/src/modules/dual-investment/market-api/getDualInvestmentProductList.ts +++ b/src/modules/dual-investment/market-api/getDualInvestmentProductList.ts @@ -1,66 +1,69 @@ // src/tools/binance-dual-investment/market-api/getDualInvestmentProductList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { dualInvestmentClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { dualInvestmentClient } from "../../../config/binanceClient.js" export function registerBinanceGetDualInvestmentProductList(server: McpServer) { - server.tool( - "BinanceGetDualInvestmentProductList", - "Retrieve available Dual Investment products (CALL or PUT options), specifying invest and exercised coins, to view details like APR, strike price, duration, and purchase availability.", - { - optionType: z.enum(["CALL", "PUT"]).describe("Input CALL or PUT"), - exercisedCoin: z.string().describe("Target exercised asset, e.g., USDT or BNB"), - investCoin: z.string().describe("Asset used for subscribing, e.g., BNB or USDT"), - pageSize: z - .number() - .int() - .max(100, "Maximum pageSize is 100") - .default(10) - .optional() - .describe("Number of records per page, default 10, max 100"), - pageIndex: z.number().int().default(1).optional().describe("Page index, default is 1"), - recvWindow: z - .number() - .int() - .max(60000, "recvWindow cannot be greater than 60000") - .optional() - .describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await dualInvestmentClient.restAPI.getDualInvestmentProductList({ - optionType: params.optionType, - exercisedCoin: params.exercisedCoin, - investCoin: params.investCoin, - ...(params.pageSize && { pageSize: params.pageSize }), - ...(params.pageIndex && { pageIndex: params.pageIndex }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetDualInvestmentProductList", + "Retrieve available Dual Investment products (CALL or PUT options), specifying invest and exercised coins, to view details like APR, strike price, duration, and purchase availability.", + { + optionType: z.enum(["CALL", "PUT"]).describe("Input CALL or PUT"), + exercisedCoin: z.string().describe("Target exercised asset, e.g., USDT or BNB"), + investCoin: z.string().describe("Asset used for subscribing, e.g., BNB or USDT"), + pageSize: z + .number() + .int() + .max(100, "Maximum pageSize is 100") + .default(10) + .optional() + .describe("Number of records per page, default 10, max 100"), + pageIndex: z.number().int().default(1).optional().describe("Page index, default is 1"), + recvWindow: z + .number() + .int() + .max(60000, "recvWindow cannot be greater than 60000") + .optional() + .describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await dualInvestmentClient.restAPI.getDualInvestmentProductList({ + optionType: params.optionType, + exercisedCoin: params.exercisedCoin, + investCoin: params.investCoin, + ...(params.pageSize && { pageSize: params.pageSize }), + ...(params.pageIndex && { pageIndex: params.pageIndex }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved available Dual Investment products. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved available Dual Investment products. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve available Dual Investment products: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve available Dual Investment products: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/dual-investment/market-api/index.ts b/src/modules/dual-investment/market-api/index.ts index 5b6b81f2..b2d90200 100644 --- a/src/modules/dual-investment/market-api/index.ts +++ b/src/modules/dual-investment/market-api/index.ts @@ -1,7 +1,8 @@ // src/tools/binance-dual-investment/market-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetDualInvestmentProductList } from "./getDualInvestmentProductList.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceGetDualInvestmentProductList } from "./getDualInvestmentProductList.js" export function registerBinanceDualInvestmentMarketApiTools(server: McpServer) { - registerBinanceGetDualInvestmentProductList(server); + registerBinanceGetDualInvestmentProductList(server) } diff --git a/src/modules/dual-investment/trade-api/changeAutoCompoundStatus.ts b/src/modules/dual-investment/trade-api/changeAutoCompoundStatus.ts index 8904f7b9..b47051eb 100644 --- a/src/modules/dual-investment/trade-api/changeAutoCompoundStatus.ts +++ b/src/modules/dual-investment/trade-api/changeAutoCompoundStatus.ts @@ -1,57 +1,60 @@ // src/tools/binance-dual-investment/trade-api/changeAutoCompoundStatus.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { dualInvestmentClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { dualInvestmentClient } from "../../../config/binanceClient.js" export function registerBinanceChangeAutoCompoundStatus(server: McpServer) { - server.tool( - "registerBinanceChangeAutoCompoundStatus", - "Change the Auto-Compound plan for a Dual Investment position to NONE, STANDARD, or ADVANCED using the position ID.", - { - positionId: z.string().describe("Get positionId from /sapi/v1/dci/product/positions"), - autoCompoundPlan: z - .enum(["NONE", "STANDARD", "ADVANCED"]) - .optional() - .describe("Auto compound plan: NONE, STANDARD, or ADVANCED"), - recvWindow: z - .number() - .int() - .max(60000) - .optional() - .describe("Optional time window for request validity (max 60000)") - }, - async (params) => { - try { - const response = await dualInvestmentClient.restAPI.changeAutoCompoundStatus({ - positionId: params.positionId, - autoCompoundPlan: params.autoCompoundPlan, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "registerBinanceChangeAutoCompoundStatus", + "Change the Auto-Compound plan for a Dual Investment position to NONE, STANDARD, or ADVANCED using the position ID.", + { + positionId: z.string().describe("Get positionId from /sapi/v1/dci/product/positions"), + autoCompoundPlan: z + .enum(["NONE", "STANDARD", "ADVANCED"]) + .optional() + .describe("Auto compound plan: NONE, STANDARD, or ADVANCED"), + recvWindow: z + .number() + .int() + .max(60000) + .optional() + .describe("Optional time window for request validity (max 60000)"), + }, + async (params) => { + try { + const response = await dualInvestmentClient.restAPI.changeAutoCompoundStatus({ + positionId: params.positionId, + autoCompoundPlan: params.autoCompoundPlan, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully Changed the Auto-Compound plan for a Dual Investment position. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully Changed the Auto-Compound plan for a Dual Investment position. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to change the Auto-Compound plan for a Dual Investment position: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to change the Auto-Compound plan for a Dual Investment position: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/dual-investment/trade-api/checkDualInvestmentAccounts.ts b/src/modules/dual-investment/trade-api/checkDualInvestmentAccounts.ts index 0026a009..a37c71f5 100644 --- a/src/modules/dual-investment/trade-api/checkDualInvestmentAccounts.ts +++ b/src/modules/dual-investment/trade-api/checkDualInvestmentAccounts.ts @@ -1,50 +1,53 @@ // src/tools/binance-dual-investment/trade-api/checkDualInvestmentAccounts.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { dualInvestmentClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { dualInvestmentClient } from "../../../config/binanceClient.js" export function registerBinanceCheckDualInvestmentAccounts(server: McpServer) { - server.tool( - "BinanceCheckDualInvestmentAccounts", - "Retrieve Dual Investment account balances, including total value in BTC and USDT equivalents.", - { - recvWindow: z - .number() - .int() - .max(60000) - .optional() - .describe("Optional time window for request validity (max 60000)") - }, - async (params) => { - try { - const response = await dualInvestmentClient.restAPI.checkDualInvestmentAccounts({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCheckDualInvestmentAccounts", + "Retrieve Dual Investment account balances, including total value in BTC and USDT equivalents.", + { + recvWindow: z + .number() + .int() + .max(60000) + .optional() + .describe("Optional time window for request validity (max 60000)"), + }, + async (params) => { + try { + const response = await dualInvestmentClient.restAPI.checkDualInvestmentAccounts({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieve Dual Investment account balances, including total value in BTC and USDT equivalents. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieve Dual Investment account balances, including total value in BTC and USDT equivalents. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve Dual Investment account balances: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve Dual Investment account balances: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/dual-investment/trade-api/getDualInvestmentPositions.ts b/src/modules/dual-investment/trade-api/getDualInvestmentPositions.ts index 824c169e..8a24b7b8 100644 --- a/src/modules/dual-investment/trade-api/getDualInvestmentPositions.ts +++ b/src/modules/dual-investment/trade-api/getDualInvestmentPositions.ts @@ -1,75 +1,78 @@ // src/tools/binance-dual-investment/trade-api/getDualInvestmentPositions.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { dualInvestmentClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { dualInvestmentClient } from "../../../config/binanceClient.js" export function registerBinanceGetDualInvestmentPositions(server: McpServer) { - server.tool( - "BinanceGetDualInvestmentPositions", - "Fetch Dual Investment positions in batch, including status, subscription details, APR, and settlement info. Filter by status or paginate results.", - { - status: z - .enum([ - "PENDING", - "PURCHASE_SUCCESS", - "SETTLED", - "PURCHASE_FAIL", - "REFUNDING", - "REFUND_SUCCESS", - "SETTLING" - ]) - .optional() - .describe( - "Position status: PENDING (awaiting results), PURCHASE_SUCCESS, SETTLED, PURCHASE_FAIL, REFUNDING, REFUND_SUCCESS, or SETTLING. If not provided, returns all." - ), - pageSize: z - .number() - .int() - .min(1) - .max(100) - .optional() - .describe("Number of items per page, default 10, max 100"), - pageIndex: z.number().int().min(1).optional().describe("Page index, default 1"), - recvWindow: z - .number() - .int() - .max(60000) - .optional() - .describe("Optional time window for request validity (max 60000)") - }, - async (params) => { - try { - const response = await dualInvestmentClient.restAPI.getDualInvestmentPositions({ - ...(params.status && { status: params.status }), - ...(params.pageSize && { pageSize: params.pageSize }), - ...(params.pageIndex && { pageIndex: params.pageIndex }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetDualInvestmentPositions", + "Fetch Dual Investment positions in batch, including status, subscription details, APR, and settlement info. Filter by status or paginate results.", + { + status: z + .enum([ + "PENDING", + "PURCHASE_SUCCESS", + "SETTLED", + "PURCHASE_FAIL", + "REFUNDING", + "REFUND_SUCCESS", + "SETTLING", + ]) + .optional() + .describe( + "Position status: PENDING (awaiting results), PURCHASE_SUCCESS, SETTLED, PURCHASE_FAIL, REFUNDING, REFUND_SUCCESS, or SETTLING. If not provided, returns all.", + ), + pageSize: z + .number() + .int() + .min(1) + .max(100) + .optional() + .describe("Number of items per page, default 10, max 100"), + pageIndex: z.number().int().min(1).optional().describe("Page index, default 1"), + recvWindow: z + .number() + .int() + .max(60000) + .optional() + .describe("Optional time window for request validity (max 60000)"), + }, + async (params) => { + try { + const response = await dualInvestmentClient.restAPI.getDualInvestmentPositions({ + ...(params.status && { status: params.status }), + ...(params.pageSize && { pageSize: params.pageSize }), + ...(params.pageIndex && { pageIndex: params.pageIndex }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully Fetched Dual Investment positions in batch, including status, subscription details, APR, and settlement info. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully Fetched Dual Investment positions in batch, including status, subscription details, APR, and settlement info. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to fetch dual investment positions: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to fetch dual investment positions: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/dual-investment/trade-api/index.ts b/src/modules/dual-investment/trade-api/index.ts index 5e0692bf..157890bc 100644 --- a/src/modules/dual-investment/trade-api/index.ts +++ b/src/modules/dual-investment/trade-api/index.ts @@ -1,13 +1,14 @@ // src/tools/binance-dual-investment/trade-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceSubscribeDualInvestmentProducts } from "./subscribeDualInvestmentProducts.js"; -import { registerBinanceCheckDualInvestmentAccounts } from "./checkDualInvestmentAccounts.js"; -import { registerBinanceGetDualInvestmentPositions } from "./getDualInvestmentPositions.js"; -import { registerBinanceChangeAutoCompoundStatus } from "./changeAutoCompoundStatus.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceChangeAutoCompoundStatus } from "./changeAutoCompoundStatus.js" +import { registerBinanceCheckDualInvestmentAccounts } from "./checkDualInvestmentAccounts.js" +import { registerBinanceGetDualInvestmentPositions } from "./getDualInvestmentPositions.js" +import { registerBinanceSubscribeDualInvestmentProducts } from "./subscribeDualInvestmentProducts.js" export function registerBinanceDualInvestmentTradeApiTools(server: McpServer) { - registerBinanceSubscribeDualInvestmentProducts(server); - registerBinanceCheckDualInvestmentAccounts(server); - registerBinanceGetDualInvestmentPositions(server); - registerBinanceChangeAutoCompoundStatus(server); + registerBinanceSubscribeDualInvestmentProducts(server) + registerBinanceCheckDualInvestmentAccounts(server) + registerBinanceGetDualInvestmentPositions(server) + registerBinanceChangeAutoCompoundStatus(server) } diff --git a/src/modules/dual-investment/trade-api/subscribeDualInvestmentProducts.ts b/src/modules/dual-investment/trade-api/subscribeDualInvestmentProducts.ts index 36fa6626..41221ba1 100644 --- a/src/modules/dual-investment/trade-api/subscribeDualInvestmentProducts.ts +++ b/src/modules/dual-investment/trade-api/subscribeDualInvestmentProducts.ts @@ -1,60 +1,63 @@ // src/tools/binance-dual-investment/trade-api/subscribeDualInvestmentProducts.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { dualInvestmentClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { dualInvestmentClient } from "../../../config/binanceClient.js" export function registerBinanceSubscribeDualInvestmentProducts(server: McpServer) { - server.tool( - "BinanceSubscribeDualInvestmentProducts", - "Subscribe to Dual Investment products by providing product ID, order ID, deposit amount, and auto compound plan to initiate investment with specified terms.", - { - id: z.string().describe("Product ID from /sapi/v1/dci/product/list"), - orderId: z.string().describe("Order ID from /sapi/v1/dci/product/list"), - depositAmount: z.number().positive().describe("The amount for subscribing"), - autoCompoundPlan: z - .enum(["NONE", "STANDARD", "ADVANCED"]) - .describe("Auto-compound plan: NONE (off), STANDARD, or ADVANCED"), - recvWindow: z - .number() - .int() - .max(60000, "recvWindow cannot be greater than 60000") - .optional() - .describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await dualInvestmentClient.restAPI.subscribeDualInvestmentProducts({ - id: params.id, - orderId: params.orderId, - depositAmount: params.depositAmount, - autoCompoundPlan: params.autoCompoundPlan, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSubscribeDualInvestmentProducts", + "Subscribe to Dual Investment products by providing product ID, order ID, deposit amount, and auto compound plan to initiate investment with specified terms.", + { + id: z.string().describe("Product ID from /sapi/v1/dci/product/list"), + orderId: z.string().describe("Order ID from /sapi/v1/dci/product/list"), + depositAmount: z.number().positive().describe("The amount for subscribing"), + autoCompoundPlan: z + .enum(["NONE", "STANDARD", "ADVANCED"]) + .describe("Auto-compound plan: NONE (off), STANDARD, or ADVANCED"), + recvWindow: z + .number() + .int() + .max(60000, "recvWindow cannot be greater than 60000") + .optional() + .describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await dualInvestmentClient.restAPI.subscribeDualInvestmentProducts({ + id: params.id, + orderId: params.orderId, + depositAmount: params.depositAmount, + autoCompoundPlan: params.autoCompoundPlan, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully subscribed to Dual Investment products. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully subscribed to Dual Investment products. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to subscribe to dual investment products: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to subscribe to dual investment products: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/fiat/fiat-api/getFiatDepositWithdrawHistory.ts b/src/modules/fiat/fiat-api/getFiatDepositWithdrawHistory.ts index feff9fbb..bb1dd8d2 100644 --- a/src/modules/fiat/fiat-api/getFiatDepositWithdrawHistory.ts +++ b/src/modules/fiat/fiat-api/getFiatDepositWithdrawHistory.ts @@ -1,60 +1,65 @@ // src/tools/binance-fiat/fiat-api/getFiatDepositWithdrawHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { fiatClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { fiatClient } from "../../../config/binanceClient.js" export function registerBinanceGetFiatDepositWithdrawHistory(server: McpServer) { - server.tool( - "BinanceGetFiatDepositWithdrawHistory", - "Fetches fiat deposit or withdrawal history, showing transaction details like amount, currency, method, status, and timestamps.", - { - transactionType: z.enum(["0", "1"]).describe("Transaction type: 0 for deposit, 1 for withdraw"), - beginTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - page: z.number().int().optional().describe("Page number, default is 1"), - rows: z - .number() - .int() - .max(500, "Rows cannot be greater than 500") - .optional() - .describe("Number of records per page, default 100, max 500"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await fiatClient.restAPI.getFiatDepositWithdrawHistory({ - transactionType: params.transactionType, - ...(params.beginTime && { beginTime: params.beginTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.page && { page: params.page }), - ...(params.rows && { rows: params.rows }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetFiatDepositWithdrawHistory", + "Fetches fiat deposit or withdrawal history, showing transaction details like amount, currency, method, status, and timestamps.", + { + transactionType: z + .enum(["0", "1"]) + .describe("Transaction type: 0 for deposit, 1 for withdraw"), + beginTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + page: z.number().int().optional().describe("Page number, default is 1"), + rows: z + .number() + .int() + .max(500, "Rows cannot be greater than 500") + .optional() + .describe("Number of records per page, default 100, max 500"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await fiatClient.restAPI.getFiatDepositWithdrawHistory({ + transactionType: params.transactionType, + ...(params.beginTime && { beginTime: params.beginTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.page && { page: params.page }), + ...(params.rows && { rows: params.rows }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully fetched fiat deposit or withdrawal history. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully fetched fiat deposit or withdrawal history. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to fetches fiat deposit or withdrawal history: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to fetches fiat deposit or withdrawal history: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/fiat/fiat-api/getFiatPaymentsHistory.ts b/src/modules/fiat/fiat-api/getFiatPaymentsHistory.ts index 330a61a3..952e542f 100644 --- a/src/modules/fiat/fiat-api/getFiatPaymentsHistory.ts +++ b/src/modules/fiat/fiat-api/getFiatPaymentsHistory.ts @@ -1,60 +1,63 @@ // src/tools/binance-fiat/fiat-api/getFiatPaymentsHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { fiatClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { fiatClient } from "../../../config/binanceClient.js" export function registerBinanceGetFiatPaymentsHistory(server: McpServer) { - server.tool( - "BinanceGetFiatPaymentsHistory", - "Retrieves fiat buy/sell payment history, including trade amount, currency, crypto received, fees, status, payment method, and timestamps.", - { - transactionType: z.enum(["0", "1"]).describe("Transaction type: 0 for buy, 1 for sell"), - beginTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - page: z.number().int().optional().describe("Page number, default is 1"), - rows: z - .number() - .int() - .max(500, "Rows cannot be greater than 500") - .optional() - .describe("Number of records per page, default 100, max 500"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await fiatClient.restAPI.getFiatPaymentsHistory({ - transactionType: params.transactionType, - ...(params.beginTime && { beginTime: params.beginTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.page && { page: params.page }), - ...(params.rows && { rows: params.rows }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetFiatPaymentsHistory", + "Retrieves fiat buy/sell payment history, including trade amount, currency, crypto received, fees, status, payment method, and timestamps.", + { + transactionType: z.enum(["0", "1"]).describe("Transaction type: 0 for buy, 1 for sell"), + beginTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + page: z.number().int().optional().describe("Page number, default is 1"), + rows: z + .number() + .int() + .max(500, "Rows cannot be greater than 500") + .optional() + .describe("Number of records per page, default 100, max 500"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await fiatClient.restAPI.getFiatPaymentsHistory({ + transactionType: params.transactionType, + ...(params.beginTime && { beginTime: params.beginTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.page && { page: params.page }), + ...(params.rows && { rows: params.rows }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved fiat buy/sell payment history. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved fiat buy/sell payment history. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve fiat buy/sell payment history: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve fiat buy/sell payment history: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/fiat/index.ts b/src/modules/fiat/index.ts index 5103765b..e013e5f3 100644 --- a/src/modules/fiat/index.ts +++ b/src/modules/fiat/index.ts @@ -1,12 +1,13 @@ // src/tools/binance-fiat/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetFiatDepositWithdrawHistory } from "./fiat-api/getFiatDepositWithdrawHistory.js"; -import { registerBinanceGetFiatPaymentsHistory } from "./fiat-api/getFiatPaymentsHistory.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceGetFiatDepositWithdrawHistory } from "./fiat-api/getFiatDepositWithdrawHistory.js" +import { registerBinanceGetFiatPaymentsHistory } from "./fiat-api/getFiatPaymentsHistory.js" export function registerBinanceFiatDepositWithdrawHistoryTools(server: McpServer) { - registerBinanceGetFiatDepositWithdrawHistory(server); - registerBinanceGetFiatPaymentsHistory(server); + registerBinanceGetFiatDepositWithdrawHistory(server) + registerBinanceGetFiatPaymentsHistory(server) } // Alias for binance.ts compatibility -export { registerBinanceFiatDepositWithdrawHistoryTools as registerFiat }; +export { registerBinanceFiatDepositWithdrawHistoryTools as registerFiat } diff --git a/src/modules/futures-coinm/index.ts b/src/modules/futures-coinm/index.ts index 31b6765e..22526810 100644 --- a/src/modules/futures-coinm/index.ts +++ b/src/modules/futures-coinm/index.ts @@ -1,7 +1,8 @@ // src/modules/futures-coinm/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceFuturesCOINMTools } from "../../tools/binance-futures-coinm/index.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceFuturesCOINMTools } from "../../tools/binance-futures-coinm/index.js" export function registerFuturesCOINM(server: McpServer) { - registerBinanceFuturesCOINMTools(server); + registerBinanceFuturesCOINMTools(server) } diff --git a/src/modules/futures-usdm/index.ts b/src/modules/futures-usdm/index.ts index 1a476f2e..9ce9f819 100644 --- a/src/modules/futures-usdm/index.ts +++ b/src/modules/futures-usdm/index.ts @@ -1,7 +1,8 @@ // src/modules/futures-usdm/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceFuturesUSDMTools } from "../../tools/binance-futures-usdm/index.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceFuturesUSDMTools } from "../../tools/binance-futures-usdm/index.js" export function registerFuturesUSDM(server: McpServer) { - registerBinanceFuturesUSDMTools(server); + registerBinanceFuturesUSDMTools(server) } diff --git a/src/modules/gift-card/index.ts b/src/modules/gift-card/index.ts index ac98394b..c777e988 100644 --- a/src/modules/gift-card/index.ts +++ b/src/modules/gift-card/index.ts @@ -1,7 +1,8 @@ // src/modules/gift-card/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGiftCardTools } from "../../tools/binance-gift-card/index.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceGiftCardTools } from "../../tools/binance-gift-card/index.js" export function registerGiftCard(server: McpServer) { - registerBinanceGiftCardTools(server); + registerBinanceGiftCardTools(server) } diff --git a/src/modules/margin/index.ts b/src/modules/margin/index.ts index f2713925..a32fd8f6 100644 --- a/src/modules/margin/index.ts +++ b/src/modules/margin/index.ts @@ -1,7 +1,8 @@ // src/modules/margin/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceMarginTools } from "../../tools/binance-margin/index.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceMarginTools } from "../../tools/binance-margin/index.js" export function registerMargin(server: McpServer) { - registerBinanceMarginTools(server); + registerBinanceMarginTools(server) } diff --git a/src/modules/mining/index.ts b/src/modules/mining/index.ts index 2119488e..de3474d9 100644 --- a/src/modules/mining/index.ts +++ b/src/modules/mining/index.ts @@ -1,34 +1,35 @@ // src/tools/binance-mining/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceAcquiringAlgorithm } from "./mining-api/acquiringAlgorithm.js"; -import { registerBinanceAcquiringCoinName } from "./mining-api/acquiringCoinname.js"; -import { registerBinanceHashRateResaleList } from "./mining-api/hashrateResaleList.js"; -import { registerBinanceRequestForMinerList } from "./mining-api/requestForMinerList.js"; -import { registerBinanceRequestForDetailMinerList } from "./mining-api/requestForDetailMinerList.js"; -import { registerBinanceExtraBonusList } from "./mining-api/extraBonusList.js"; -import { registerBinanceEarningsList } from "./mining-api/earningsList.js"; -import { registerBinanceCancelHashRateResaleConfiguration } from "./mining-api/cancelHashrateResaleConfiguration.js"; -import { registerBinanceHashRateResaleDetail } from "./mining-api/hashrateResaleDetail.js"; -import { registerBinanceMiningAccountEarning } from "./mining-api/miningAccountEarning.js"; -import { registerBinanceStatisticList } from "./mining-api/statisticList.js"; -import { registerBinanceHashRateResaleRequest } from "./mining-api/hashrateResaleRequest.js"; -import { registerBinanceAccountList } from "./mining-api/accountList.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceAccountList } from "./mining-api/accountList.js" +import { registerBinanceAcquiringAlgorithm } from "./mining-api/acquiringAlgorithm.js" +import { registerBinanceAcquiringCoinName } from "./mining-api/acquiringCoinname.js" +import { registerBinanceCancelHashRateResaleConfiguration } from "./mining-api/cancelHashrateResaleConfiguration.js" +import { registerBinanceEarningsList } from "./mining-api/earningsList.js" +import { registerBinanceExtraBonusList } from "./mining-api/extraBonusList.js" +import { registerBinanceHashRateResaleDetail } from "./mining-api/hashrateResaleDetail.js" +import { registerBinanceHashRateResaleList } from "./mining-api/hashrateResaleList.js" +import { registerBinanceHashRateResaleRequest } from "./mining-api/hashrateResaleRequest.js" +import { registerBinanceMiningAccountEarning } from "./mining-api/miningAccountEarning.js" +import { registerBinanceRequestForDetailMinerList } from "./mining-api/requestForDetailMinerList.js" +import { registerBinanceRequestForMinerList } from "./mining-api/requestForMinerList.js" +import { registerBinanceStatisticList } from "./mining-api/statisticList.js" export function registerBinanceMiningTools(server: McpServer) { - registerBinanceAcquiringAlgorithm(server); - registerBinanceAcquiringCoinName(server); - registerBinanceHashRateResaleList(server); - registerBinanceRequestForMinerList(server); - registerBinanceRequestForDetailMinerList(server); - registerBinanceExtraBonusList(server); - registerBinanceEarningsList(server); - registerBinanceCancelHashRateResaleConfiguration(server); - registerBinanceHashRateResaleDetail(server); - registerBinanceMiningAccountEarning(server); - registerBinanceStatisticList(server); - registerBinanceHashRateResaleRequest(server); - registerBinanceAccountList(server); + registerBinanceAcquiringAlgorithm(server) + registerBinanceAcquiringCoinName(server) + registerBinanceHashRateResaleList(server) + registerBinanceRequestForMinerList(server) + registerBinanceRequestForDetailMinerList(server) + registerBinanceExtraBonusList(server) + registerBinanceEarningsList(server) + registerBinanceCancelHashRateResaleConfiguration(server) + registerBinanceHashRateResaleDetail(server) + registerBinanceMiningAccountEarning(server) + registerBinanceStatisticList(server) + registerBinanceHashRateResaleRequest(server) + registerBinanceAccountList(server) } // Alias for binance.ts compatibility -export { registerBinanceMiningTools as registerMining }; +export { registerBinanceMiningTools as registerMining } diff --git a/src/modules/mining/mining-api/accountList.ts b/src/modules/mining/mining-api/accountList.ts index 068013a9..cb48f137 100644 --- a/src/modules/mining/mining-api/accountList.ts +++ b/src/modules/mining/mining-api/accountList.ts @@ -1,49 +1,52 @@ // src/tools/binance-mining/mining-api/accountList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { miningClient } from "../../../config/binanceClient.js" export function registerBinanceAccountList(server: McpServer) { - server.tool( - "BinanceAccountList", - "Retrieve hashrate statistics for a mining account. It returns both hourly (H_hashrate) and daily (D_hashrate) data, including timestamps, hashrate values, and rejection rates.", - { - algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), - userName: z.string().min(1).describe("Mining account"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await miningClient.restAPI.accountList({ - algo: params.algo, - userName: params.userName, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceAccountList", + "Retrieve hashrate statistics for a mining account. It returns both hourly (H_hashrate) and daily (D_hashrate) data, including timestamps, hashrate values, and rejection rates.", + { + algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), + userName: z.string().min(1).describe("Mining account"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await miningClient.restAPI.accountList({ + algo: params.algo, + userName: params.userName, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved hashrate statistics for a mining account.. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved hashrate statistics for a mining account.. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve hashrate statistics for a mining account.. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve hashrate statistics for a mining account.. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/mining/mining-api/acquiringAlgorithm.ts b/src/modules/mining/mining-api/acquiringAlgorithm.ts index 0aef5307..4551274c 100644 --- a/src/modules/mining/mining-api/acquiringAlgorithm.ts +++ b/src/modules/mining/mining-api/acquiringAlgorithm.ts @@ -1,40 +1,42 @@ // src/tools/binance-mining/mining-api/acquiringAlgorithm.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { miningClient } from "../../../config/binanceClient.js" export function registerBinanceAcquiringAlgorithm(server: McpServer) { - server.tool( - "BinanceAcquiringAlgorithm", - "Retrieve a list of available mining algorithms, including their name, ID, sequence, and unit.", - {}, - async () => { - try { - const response = await miningClient.restAPI.acquiringAlgorithm(); + server.tool( + "BinanceAcquiringAlgorithm", + "Retrieve a list of available mining algorithms, including their name, ID, sequence, and unit.", + {}, + async () => { + try { + const response = await miningClient.restAPI.acquiringAlgorithm() + + const data = await response.data() - const data = await response.data(); + return { + content: [ + { + type: "text", + text: `Successfully retrieve a list of available mining algorithms. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieve a list of available mining algorithms. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve a list of available mining algorithms: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve a list of available mining algorithms: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/mining/mining-api/acquiringCoinname.ts b/src/modules/mining/mining-api/acquiringCoinname.ts index ef422b24..aef4b04c 100644 --- a/src/modules/mining/mining-api/acquiringCoinname.ts +++ b/src/modules/mining/mining-api/acquiringCoinname.ts @@ -1,38 +1,40 @@ // src/tools/binance-mining/mining-api/acquiringCoinname.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { miningClient } from "../../../config/binanceClient.js" export function registerBinanceAcquiringCoinName(server: McpServer) { - server.tool( - "BinanceAcquiringCoinName", - "Fetch supported mining coins with details like coin name, ID, algorithm name, and associated algorithm ID.", - {}, - async () => { - try { - const response = await miningClient.restAPI.acquiringCoinname(); + server.tool( + "BinanceAcquiringCoinName", + "Fetch supported mining coins with details like coin name, ID, algorithm name, and associated algorithm ID.", + {}, + async () => { + try { + const response = await miningClient.restAPI.acquiringCoinname() + + const data = await response.data() - const data = await response.data(); + return { + content: [ + { + type: "text", + text: `Successfully fetched supported mining coins. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully fetched supported mining coins. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to fetched supported mining coins: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to fetched supported mining coins: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/mining/mining-api/cancelHashrateResaleConfiguration.ts b/src/modules/mining/mining-api/cancelHashrateResaleConfiguration.ts index 1caed1c1..5dd7d120 100644 --- a/src/modules/mining/mining-api/cancelHashrateResaleConfiguration.ts +++ b/src/modules/mining/mining-api/cancelHashrateResaleConfiguration.ts @@ -1,49 +1,52 @@ // src/tools/binance-mining/mining-api/cancelHashrateResaleConfiguration.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { miningClient } from "../../../config/binanceClient.js" export function registerBinanceCancelHashRateResaleConfiguration(server: McpServer) { - server.tool( - "BinanceCancelHashRateResaleConfiguration", - "Cancel an existing hashrate resale configuration using the mining ID and account details.", - { - configId: z.number().int().describe("Mining ID").min(1), - userName: z.string().min(1).describe("Mining Account"), - recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000") - }, - async (params) => { - try { - const response = await miningClient.restAPI.cancelHashrateResaleConfiguration({ - configId: params.configId, - userName: params.userName, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCancelHashRateResaleConfiguration", + "Cancel an existing hashrate resale configuration using the mining ID and account details.", + { + configId: z.number().int().describe("Mining ID").min(1), + userName: z.string().min(1).describe("Mining Account"), + recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + }, + async (params) => { + try { + const response = await miningClient.restAPI.cancelHashrateResaleConfiguration({ + configId: params.configId, + userName: params.userName, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully canceled an existing hashrate resale configuration. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully canceled an existing hashrate resale configuration. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to canceled an existing hashrate resale configuration. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to canceled an existing hashrate resale configuration. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/mining/mining-api/earningsList.ts b/src/modules/mining/mining-api/earningsList.ts index 06a4740b..3afee161 100644 --- a/src/modules/mining/mining-api/earningsList.ts +++ b/src/modules/mining/mining-api/earningsList.ts @@ -1,64 +1,76 @@ // src/tools/binance-mining/mining-api/earningsList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { miningClient } from "../../../config/binanceClient.js" export function registerBinanceEarningsList(server: McpServer) { - server.tool( - "BinanceEarningsList", - "Retrieves list of earnings related to mining activities, including transferred hashrate, daily hashrate, profit amount, and the status of the payment (unpaid, paying, or paid).", - { - algo: z.string().min(1).describe("Transfer algorithm (e.g., sha256)"), - userName: z.string().min(1).describe("Mining account username"), - coin: z.string().optional().describe("Coin name (optional)"), - startDate: z.number().optional().describe("Search start date (milliseconds timestamp, optional)"), - endDate: z.number().optional().describe("Search end date (milliseconds timestamp, optional)"), - pageIndex: z - .number() - .int() - .min(1) - .optional() - .describe("Page number, default is the first page starting from 1"), - pageSize: z.number().int().min(10).max(200).optional().describe("Number of pages, minimum 10, maximum 200"), - recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000") - }, - async (params) => { - try { - const response = await miningClient.restAPI.earningsList({ - algo: params.algo, - userName: params.userName, - ...(params.coin && { coin: params.coin }), - ...(params.startDate && { startDate: params.startDate }), - ...(params.endDate && { endDate: params.endDate }), - ...(params.pageIndex && { pageIndex: params.pageIndex }), - ...(params.pageSize && { pageSize: params.pageSize }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceEarningsList", + "Retrieves list of earnings related to mining activities, including transferred hashrate, daily hashrate, profit amount, and the status of the payment (unpaid, paying, or paid).", + { + algo: z.string().min(1).describe("Transfer algorithm (e.g., sha256)"), + userName: z.string().min(1).describe("Mining account username"), + coin: z.string().optional().describe("Coin name (optional)"), + startDate: z + .number() + .optional() + .describe("Search start date (milliseconds timestamp, optional)"), + endDate: z.number().optional().describe("Search end date (milliseconds timestamp, optional)"), + pageIndex: z + .number() + .int() + .min(1) + .optional() + .describe("Page number, default is the first page starting from 1"), + pageSize: z + .number() + .int() + .min(10) + .max(200) + .optional() + .describe("Number of pages, minimum 10, maximum 200"), + recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + }, + async (params) => { + try { + const response = await miningClient.restAPI.earningsList({ + algo: params.algo, + userName: params.userName, + ...(params.coin && { coin: params.coin }), + ...(params.startDate && { startDate: params.startDate }), + ...(params.endDate && { endDate: params.endDate }), + ...(params.pageIndex && { pageIndex: params.pageIndex }), + ...(params.pageSize && { pageSize: params.pageSize }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved list of earnings related to mining activities. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved list of earnings related to mining activities. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve list of earnings related to mining activities. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve list of earnings related to mining activities. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/mining/mining-api/extraBonusList.ts b/src/modules/mining/mining-api/extraBonusList.ts index 0a46c53b..a49e7c0d 100644 --- a/src/modules/mining/mining-api/extraBonusList.ts +++ b/src/modules/mining/mining-api/extraBonusList.ts @@ -1,58 +1,70 @@ // src/tools/binance-mining/mining-api/extraBonusList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { miningClient } from "../../../config/binanceClient.js" export function registerBinanceExtraBonusList(server: McpServer) { - server.tool( - "BinanceExtraBonusList", - "Retrieves extra bonuses related to mining activities, including merged mining, activity bonuses, rebates, smart pool bonuses, income transfers, and pool savings.", - { - algo: z.string().min(1).describe("Transfer algorithm (e.g., sha256)"), - userName: z.string().min(1).describe("Mining account username"), - coin: z.string().optional().describe("Coin name (optional)"), - startDate: z.number().optional().describe("Search start date (milliseconds timestamp, optional)"), - endDate: z.number().optional().describe("Search end date (milliseconds timestamp, optional)"), - pageIndex: z.number().int().min(1).optional().describe("Page number, default is 1"), - pageSize: z.number().int().min(10).max(200).optional().describe("Number of pages, minimum 10, maximum 200"), - recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000") - }, - async (params) => { - try { - const response = await miningClient.restAPI.extraBonusList({ - algo: params.algo, - userName: params.userName, - ...(params.coin && { coin: params.coin }), - ...(params.startDate && { startDate: params.startDate }), - ...(params.endDate && { endDate: params.endDate }), - ...(params.pageIndex && { pageIndex: params.pageIndex }), - ...(params.pageSize && { pageSize: params.pageSize }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); + server.tool( + "BinanceExtraBonusList", + "Retrieves extra bonuses related to mining activities, including merged mining, activity bonuses, rebates, smart pool bonuses, income transfers, and pool savings.", + { + algo: z.string().min(1).describe("Transfer algorithm (e.g., sha256)"), + userName: z.string().min(1).describe("Mining account username"), + coin: z.string().optional().describe("Coin name (optional)"), + startDate: z + .number() + .optional() + .describe("Search start date (milliseconds timestamp, optional)"), + endDate: z.number().optional().describe("Search end date (milliseconds timestamp, optional)"), + pageIndex: z.number().int().min(1).optional().describe("Page number, default is 1"), + pageSize: z + .number() + .int() + .min(10) + .max(200) + .optional() + .describe("Number of pages, minimum 10, maximum 200"), + recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + }, + async (params) => { + try { + const response = await miningClient.restAPI.extraBonusList({ + algo: params.algo, + userName: params.userName, + ...(params.coin && { coin: params.coin }), + ...(params.startDate && { startDate: params.startDate }), + ...(params.endDate && { endDate: params.endDate }), + ...(params.pageIndex && { pageIndex: params.pageIndex }), + ...(params.pageSize && { pageSize: params.pageSize }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved extra bonuses related to mining activities. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved extra bonuses related to mining activities. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve extra bonuses related to mining activities. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve extra bonuses related to mining activities. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/mining/mining-api/hashrateResaleDetail.ts b/src/modules/mining/mining-api/hashrateResaleDetail.ts index fb286b2e..770d81c9 100644 --- a/src/modules/mining/mining-api/hashrateResaleDetail.ts +++ b/src/modules/mining/mining-api/hashrateResaleDetail.ts @@ -1,58 +1,67 @@ // src/tools/binance-mining/mining-api/hashrateResaleDetail.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { miningClient } from "../../../config/binanceClient.js" export function registerBinanceHashRateResaleDetail(server: McpServer) { - server.tool( - "BinanceHashRateResaleDetail", - "Retrieves details of hashrate resale transactions, including the transferring and receiving subaccounts, algorithm, hash rate, transfer date, and associated income.", - { - configId: z.number().int().min(1).describe("Mining ID"), - userName: z.string().min(1).describe("Mining Account"), - pageIndex: z - .number() - .int() - .min(1) - .optional() - .describe("Page number, default is the first page starting from 1"), - pageSize: z.number().int().min(10).max(200).optional().describe("Number of pages, minimum 10, maximum 200"), - recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000") - }, - async (params) => { - try { - const response = await miningClient.restAPI.hashrateResaleDetail({ - configId: params.configId, - userName: params.userName, - ...(params.pageIndex && { pageIndex: params.pageIndex }), - ...(params.pageSize && { pageSize: params.pageSize }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceHashRateResaleDetail", + "Retrieves details of hashrate resale transactions, including the transferring and receiving subaccounts, algorithm, hash rate, transfer date, and associated income.", + { + configId: z.number().int().min(1).describe("Mining ID"), + userName: z.string().min(1).describe("Mining Account"), + pageIndex: z + .number() + .int() + .min(1) + .optional() + .describe("Page number, default is the first page starting from 1"), + pageSize: z + .number() + .int() + .min(10) + .max(200) + .optional() + .describe("Number of pages, minimum 10, maximum 200"), + recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + }, + async (params) => { + try { + const response = await miningClient.restAPI.hashrateResaleDetail({ + configId: params.configId, + userName: params.userName, + ...(params.pageIndex && { pageIndex: params.pageIndex }), + ...(params.pageSize && { pageSize: params.pageSize }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved details of hashrate resale transactions. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved details of hashrate resale transactions. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve details of hashrate resale transactions. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve details of hashrate resale transactions. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/mining/mining-api/hashrateResaleList.ts b/src/modules/mining/mining-api/hashrateResaleList.ts index 83ee293f..b5b6ab27 100644 --- a/src/modules/mining/mining-api/hashrateResaleList.ts +++ b/src/modules/mining/mining-api/hashrateResaleList.ts @@ -1,60 +1,63 @@ // src/tools/binance-mining/mining-api/hashrateResaleList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { miningClient } from "../../../config/binanceClient.js" export function registerBinanceHashRateResaleList(server: McpServer) { - server.tool( - "BinanceHashRateResaleList", - "Returns the list of hashRate resale configurations including transfer details such as algorithm, hashrate amount, sender and receiver pool usernames, start and end dates, and status of the transfer.", - { - pageIndex: z - .number() - .int() - .min(1) - .optional() - .describe("Page number, default is the first page starting from 1"), - pageSize: z - .number() - .int() - .min(10) - .max(200) - .optional() - .describe("Number of records per page, min 10, max 200"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await miningClient.restAPI.hashrateResaleList({ - ...(params.pageIndex && { pageIndex: params.pageIndex }), - ...(params.pageSize && { pageSize: params.pageSize }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceHashRateResaleList", + "Returns the list of hashRate resale configurations including transfer details such as algorithm, hashrate amount, sender and receiver pool usernames, start and end dates, and status of the transfer.", + { + pageIndex: z + .number() + .int() + .min(1) + .optional() + .describe("Page number, default is the first page starting from 1"), + pageSize: z + .number() + .int() + .min(10) + .max(200) + .optional() + .describe("Number of records per page, min 10, max 200"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await miningClient.restAPI.hashrateResaleList({ + ...(params.pageIndex && { pageIndex: params.pageIndex }), + ...(params.pageSize && { pageSize: params.pageSize }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully return the list of hashRate resale configurations. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully return the list of hashRate resale configurations. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to return the list of hashRate resale configurations. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to return the list of hashRate resale configurations. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/mining/mining-api/hashrateResaleRequest.ts b/src/modules/mining/mining-api/hashrateResaleRequest.ts index 408caca8..73c3b099 100644 --- a/src/modules/mining/mining-api/hashrateResaleRequest.ts +++ b/src/modules/mining/mining-api/hashrateResaleRequest.ts @@ -1,60 +1,67 @@ // src/tools/binance-mining/mining-api/hashrateResaleRequest.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { miningClient } from "../../../config/binanceClient.js" export function registerBinanceHashRateResaleRequest(server: McpServer) { - server.tool( - "BinanceHashRateResaleRequest", - "Retrieve a request for setting up a hashrate resale, specifying the mining account, algorithm, start and end times, target mining account for resale, and the amount of hashrate to transfer", - { - userName: z.string().min(1).describe("Mining Account"), - algo: z.string().min(1).describe("Transfer algorithm (e.g., sha256)"), - endDate: z.number().int().describe("Resale End Time (Millisecond timestamp)"), - startDate: z.number().int().describe("Resale Start Time (Millisecond timestamp)"), - toPoolUser: z.string().min(1).describe("Mining Account of the recipient pool user"), - hashRate: z - .number() - .int() - .describe("Resale hashrate h/s must be transferred (BTC > 500000000000, ETH > 500000)"), - recvWindow: z.number().int().optional().describe("Optional: Time window for request validity") - }, - async (params) => { - try { - const response = await miningClient.restAPI.hashrateResaleRequest({ - userName: params.userName, - algo: params.algo, - endDate: params.endDate, - startDate: params.startDate, - toPoolUser: params.toPoolUser, - hashRate: params.hashRate, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceHashRateResaleRequest", + "Retrieve a request for setting up a hashrate resale, specifying the mining account, algorithm, start and end times, target mining account for resale, and the amount of hashrate to transfer", + { + userName: z.string().min(1).describe("Mining Account"), + algo: z.string().min(1).describe("Transfer algorithm (e.g., sha256)"), + endDate: z.number().int().describe("Resale End Time (Millisecond timestamp)"), + startDate: z.number().int().describe("Resale Start Time (Millisecond timestamp)"), + toPoolUser: z.string().min(1).describe("Mining Account of the recipient pool user"), + hashRate: z + .number() + .int() + .describe("Resale hashrate h/s must be transferred (BTC > 500000000000, ETH > 500000)"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional: Time window for request validity"), + }, + async (params) => { + try { + const response = await miningClient.restAPI.hashrateResaleRequest({ + userName: params.userName, + algo: params.algo, + endDate: params.endDate, + startDate: params.startDate, + toPoolUser: params.toPoolUser, + hashRate: params.hashRate, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved request for setting up a hashrate resale. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved request for setting up a hashrate resale. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve request for setting up a hashrate resale. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve request for setting up a hashrate resale. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/mining/mining-api/miningAccountEarning.ts b/src/modules/mining/mining-api/miningAccountEarning.ts index 09399b8b..17f4e9ac 100644 --- a/src/modules/mining/mining-api/miningAccountEarning.ts +++ b/src/modules/mining/mining-api/miningAccountEarning.ts @@ -1,61 +1,64 @@ // src/tools/binance-mining/mining-api/miningAccountEarning.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { miningClient } from "../../../config/binanceClient.js" export function registerBinanceMiningAccountEarning(server: McpServer) { - server.tool( - "BinanceMiningAccountEarning", - "Retrieves the earnings associated with a mining account, including the type of earnings (e.g., rebate, referral, refund), sub-account ID, the mining account name, and the amount earned. It also supports pagination for large data sets.", - { - algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), - startDate: z.number().int().optional().describe("Millisecond timestamp for the start date"), - endDate: z.number().int().optional().describe("Millisecond timestamp for the end date"), - pageIndex: z.number().int().min(1).optional().describe("Page number, default is 1"), - pageSize: z - .number() - .int() - .min(10) - .max(200) - .optional() - .describe("Number of records per page, min 10, max 200"), - recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000") - }, - async (params) => { - try { - const response = await miningClient.restAPI.miningAccountEarning({ - algo: params.algo, - ...(params.startDate && { startDate: params.startDate }), - ...(params.endDate && { endDate: params.endDate }), - ...(params.pageIndex && { pageIndex: params.pageIndex }), - ...(params.pageSize && { pageSize: params.pageSize }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceMiningAccountEarning", + "Retrieves the earnings associated with a mining account, including the type of earnings (e.g., rebate, referral, refund), sub-account ID, the mining account name, and the amount earned. It also supports pagination for large data sets.", + { + algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), + startDate: z.number().int().optional().describe("Millisecond timestamp for the start date"), + endDate: z.number().int().optional().describe("Millisecond timestamp for the end date"), + pageIndex: z.number().int().min(1).optional().describe("Page number, default is 1"), + pageSize: z + .number() + .int() + .min(10) + .max(200) + .optional() + .describe("Number of records per page, min 10, max 200"), + recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + }, + async (params) => { + try { + const response = await miningClient.restAPI.miningAccountEarning({ + algo: params.algo, + ...(params.startDate && { startDate: params.startDate }), + ...(params.endDate && { endDate: params.endDate }), + ...(params.pageIndex && { pageIndex: params.pageIndex }), + ...(params.pageSize && { pageSize: params.pageSize }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved the earnings associated with a mining account. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved the earnings associated with a mining account. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve the earnings associated with a mining account. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve the earnings associated with a mining account. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/mining/mining-api/requestForDetailMinerList.ts b/src/modules/mining/mining-api/requestForDetailMinerList.ts index df5fb763..a45268a5 100644 --- a/src/modules/mining/mining-api/requestForDetailMinerList.ts +++ b/src/modules/mining/mining-api/requestForDetailMinerList.ts @@ -1,51 +1,54 @@ // src/tools/binance-mining/mining-api/requestForDetailMinerList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { miningClient } from "../../../config/binanceClient.js" export function registerBinanceRequestForDetailMinerList(server: McpServer) { - server.tool( - "BinanceRequestForDetailMinerList", - "Retrieves detailed hashrate data for a specific miner, including both hourly (H_hashrate) and daily (D_hashrate) metrics such as time, hashrate, and rejection rate.", - { - algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), - userName: z.string().min(1).describe("Mining account username"), - workerName: z.string().min(1).describe("Miner’s name (required), e.g., bhdc1.16A10404B"), - recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000") - }, - async (params) => { - try { - const response = await miningClient.restAPI.requestForDetailMinerList({ - algo: params.algo, - userName: params.userName, - workerName: params.workerName, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceRequestForDetailMinerList", + "Retrieves detailed hashrate data for a specific miner, including both hourly (H_hashrate) and daily (D_hashrate) metrics such as time, hashrate, and rejection rate.", + { + algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), + userName: z.string().min(1).describe("Mining account username"), + workerName: z.string().min(1).describe("Miner’s name (required), e.g., bhdc1.16A10404B"), + recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + }, + async (params) => { + try { + const response = await miningClient.restAPI.requestForDetailMinerList({ + algo: params.algo, + userName: params.userName, + workerName: params.workerName, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved detailed hashrate data for a specific miner. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved detailed hashrate data for a specific miner. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve detailed hashrate data for a specific miner. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve detailed hashrate data for a specific miner. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/mining/mining-api/requestForMinerList.ts b/src/modules/mining/mining-api/requestForMinerList.ts index 009f3811..f83cb473 100644 --- a/src/modules/mining/mining-api/requestForMinerList.ts +++ b/src/modules/mining/mining-api/requestForMinerList.ts @@ -1,82 +1,85 @@ // src/tools/binance-mining/mining-api/requestForMinerList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { miningClient } from "../../../config/binanceClient.js" export function registerBinanceRequestForMinerList(server: McpServer) { - server.tool( - "BinanceRequestForMinerList", - "Retrieves a list of miners (workers) associated with a mining account, including details such as miner name, status, real-time hashrate, 24H hashrate, rejection rate, and last submission time.", - { - algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), - userName: z.string().min(1).describe("Mining account username"), - pageIndex: z - .number() - .int() - .min(1) - .optional() - .describe("Page number, default is first page, starting from 1"), - sort: z - .number() - .int() - .min(0) - .max(1) - .optional() - .describe("Sort sequence: 0 = ascending (default), 1 = descending"), - sortColumn: z - .number() - .int() - .min(1) - .max(5) - .optional() - .describe( - `Sort by (default = 1): 1: miner name, 2: real-time computing power, 3: daily average computing power, 4: real-time rejection rate, 5: last submission time` - ), - workerStatus: z - .number() - .int() - .min(0) - .max(3) - .optional() - .describe("Miner status (default = 0): 0 = all, 1 = valid, 2 = invalid, 3 = failure"), - recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000") - }, - async (params) => { - try { - const response = await miningClient.restAPI.requestForMinerList({ - algo: params.algo, - userName: params.userName, - ...(params.pageIndex && { pageIndex: params.pageIndex }), - ...(params.sort && { sort: params.sort }), - ...(params.sortColumn && { sortColumn: params.sortColumn }), - ...(params.workerStatus && { workerStatus: params.workerStatus }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceRequestForMinerList", + "Retrieves a list of miners (workers) associated with a mining account, including details such as miner name, status, real-time hashrate, 24H hashrate, rejection rate, and last submission time.", + { + algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), + userName: z.string().min(1).describe("Mining account username"), + pageIndex: z + .number() + .int() + .min(1) + .optional() + .describe("Page number, default is first page, starting from 1"), + sort: z + .number() + .int() + .min(0) + .max(1) + .optional() + .describe("Sort sequence: 0 = ascending (default), 1 = descending"), + sortColumn: z + .number() + .int() + .min(1) + .max(5) + .optional() + .describe( + `Sort by (default = 1): 1: miner name, 2: real-time computing power, 3: daily average computing power, 4: real-time rejection rate, 5: last submission time`, + ), + workerStatus: z + .number() + .int() + .min(0) + .max(3) + .optional() + .describe("Miner status (default = 0): 0 = all, 1 = valid, 2 = invalid, 3 = failure"), + recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + }, + async (params) => { + try { + const response = await miningClient.restAPI.requestForMinerList({ + algo: params.algo, + userName: params.userName, + ...(params.pageIndex && { pageIndex: params.pageIndex }), + ...(params.sort && { sort: params.sort }), + ...(params.sortColumn && { sortColumn: params.sortColumn }), + ...(params.workerStatus && { workerStatus: params.workerStatus }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved a list of miners (workers) associated with a mining account. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved a list of miners (workers) associated with a mining account. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve a list of miners (workers) associated with a mining account. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve a list of miners (workers) associated with a mining account. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/mining/mining-api/statisticList.ts b/src/modules/mining/mining-api/statisticList.ts index 3be2a279..0b7e4631 100644 --- a/src/modules/mining/mining-api/statisticList.ts +++ b/src/modules/mining/mining-api/statisticList.ts @@ -1,48 +1,55 @@ // src/tools/binance-mining/mining-api/statisticList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { miningClient } from "../../../config/binanceClient.js" export function registerBinanceStatisticList(server: McpServer) { - server.tool( - "BinanceStatisticList", - "Retrieve mining statistics for a specific account, including hash rates for the past 15 minutes and 24 hours, the number of valid and invalid mining units, and the estimated profit for today and yesterday in various cryptocurrencies.", - { - algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), - userName: z.string().min(1).describe("Mining account username"), - recvWindow: z.number().int().optional().describe("Optional: Time window for request validity") - }, - async (params) => { - try { - const response = await miningClient.restAPI.statisticList({ - algo: params.algo, - userName: params.userName, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); + server.tool( + "BinanceStatisticList", + "Retrieve mining statistics for a specific account, including hash rates for the past 15 minutes and 24 hours, the number of valid and invalid mining units, and the estimated profit for today and yesterday in various cryptocurrencies.", + { + algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), + userName: z.string().min(1).describe("Mining account username"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional: Time window for request validity"), + }, + async (params) => { + try { + const response = await miningClient.restAPI.statisticList({ + algo: params.algo, + userName: params.userName, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved mining statistics for a specific account. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved mining statistics for a specific account. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve mining statistics for a specific account. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve mining statistics for a specific account. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/nft/index.ts b/src/modules/nft/index.ts index 949f44e2..e2bf6eb7 100644 --- a/src/modules/nft/index.ts +++ b/src/modules/nft/index.ts @@ -1,16 +1,17 @@ // src/tools/binance-fiat/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetNFTDepositHistory } from "./nft-api/getNFTDepositHistory.js"; -import { registerBinanceGetNFTWithdrawHistory } from "./nft-api/getNFTWithdrawHistory.js"; -import { registerBinanceGetNFTTransactionHistory } from "./nft-api/getNFTTransactionHistory.js"; -import { registerBinanceGetNFTAsset } from "./nft-api/getNFTAsset.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceGetNFTAsset } from "./nft-api/getNFTAsset.js" +import { registerBinanceGetNFTDepositHistory } from "./nft-api/getNFTDepositHistory.js" +import { registerBinanceGetNFTTransactionHistory } from "./nft-api/getNFTTransactionHistory.js" +import { registerBinanceGetNFTWithdrawHistory } from "./nft-api/getNFTWithdrawHistory.js" export function registerBinanceNFTTools(server: McpServer) { - registerBinanceGetNFTDepositHistory(server); - registerBinanceGetNFTWithdrawHistory(server); - registerBinanceGetNFTTransactionHistory(server); - registerBinanceGetNFTAsset(server); + registerBinanceGetNFTDepositHistory(server) + registerBinanceGetNFTWithdrawHistory(server) + registerBinanceGetNFTTransactionHistory(server) + registerBinanceGetNFTAsset(server) } // Alias for binance.ts compatibility -export { registerBinanceNFTTools as registerNFT }; +export { registerBinanceNFTTools as registerNFT } diff --git a/src/modules/nft/nft-api/getNFTAsset.ts b/src/modules/nft/nft-api/getNFTAsset.ts index e5d658b0..dc5cc49c 100644 --- a/src/modules/nft/nft-api/getNFTAsset.ts +++ b/src/modules/nft/nft-api/getNFTAsset.ts @@ -1,54 +1,57 @@ // src/tools/binance-nft/nft-api/getNFTAsset.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { nftClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { nftClient } from "../../../config/binanceClient.js" export function registerBinanceGetNFTAsset(server: McpServer) { - server.tool( - "BinanceGetNFTAsset", - "Retrieve NFT assets associated with a user's account. It returns details about the network, contract address, and token IDs for each NFT asset.", - { - limit: z - .number() - .int() - .max(50, "Limit cannot be greater than 50") - .default(50) - .describe("Number of records to return, default 50, max 50"), - page: z.number().int().default(1).describe("Page number, default is 1"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await nftClient.restAPI.getNFTAsset({ - ...(params.limit && { limit: params.limit }), - ...(params.page && { page: params.page }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetNFTAsset", + "Retrieve NFT assets associated with a user's account. It returns details about the network, contract address, and token IDs for each NFT asset.", + { + limit: z + .number() + .int() + .max(50, "Limit cannot be greater than 50") + .default(50) + .describe("Number of records to return, default 50, max 50"), + page: z.number().int().default(1).describe("Page number, default is 1"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await nftClient.restAPI.getNFTAsset({ + ...(params.limit && { limit: params.limit }), + ...(params.page && { page: params.page }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved NFT assets associated with a user's account. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved NFT assets associated with a user's account. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve NFT assets : ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve NFT assets : ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/nft/nft-api/getNFTDepositHistory.ts b/src/modules/nft/nft-api/getNFTDepositHistory.ts index 631e647c..a01bc6a2 100644 --- a/src/modules/nft/nft-api/getNFTDepositHistory.ts +++ b/src/modules/nft/nft-api/getNFTDepositHistory.ts @@ -1,58 +1,61 @@ // src/tools/binance-nft/nft-api/getNFTDepositHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { nftClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { nftClient } from "../../../config/binanceClient.js" export function registerBinanceGetNFTDepositHistory(server: McpServer) { - server.tool( - "BinanceGetNFTDepositHistory", - "Retrieves NFT deposit history, including network, contract address, token ID, transaction ID (if available), and timestamps.", - { - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .max(50, "Limit cannot be greater than 50") - .optional() - .describe("Number of records to return, default 50, max 50"), - page: z.number().int().optional().describe("Page number, default is 1"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await nftClient.restAPI.getNFTDepositHistory({ - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.page && { page: params.page }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetNFTDepositHistory", + "Retrieves NFT deposit history, including network, contract address, token ID, transaction ID (if available), and timestamps.", + { + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(50, "Limit cannot be greater than 50") + .optional() + .describe("Number of records to return, default 50, max 50"), + page: z.number().int().optional().describe("Page number, default is 1"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await nftClient.restAPI.getNFTDepositHistory({ + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.page && { page: params.page }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved NFT deposit history, including network, contract address, token ID. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved NFT deposit history, including network, contract address, token ID. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieves NFT deposit history: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieves NFT deposit history: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/nft/nft-api/getNFTTransactionHistory.ts b/src/modules/nft/nft-api/getNFTTransactionHistory.ts index 86b27c9f..8c755bc9 100644 --- a/src/modules/nft/nft-api/getNFTTransactionHistory.ts +++ b/src/modules/nft/nft-api/getNFTTransactionHistory.ts @@ -1,62 +1,65 @@ // src/tools/binance-nft/nft-api/getNFTTransactionHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { nftClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { nftClient } from "../../../config/binanceClient.js" export function registerBinanceGetNFTTransactionHistory(server: McpServer) { - server.tool( - "BinanceGetNFTTransactionHistory", - "Retrieves NFT transaction history, including purchase orders, sale orders, royalty income, primary market orders, and mint fees. It returns details about the NFT network, token IDs, contract addresses, transaction times, trade amounts, and the currencies used in the transactions.", - { - orderType: z - .number() - .describe( - "Order type: 0 for purchase order, 1 for sell order, 2 for royalty income, 3 for primary market order, 4 for mint fee" - ), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .max(50, "Limit cannot be greater than 50") - .default(50) - .describe("Number of records to return, default 50, max 50"), - page: z.number().int().default(1).describe("Page number, default is 1"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await nftClient.restAPI.getNFTTransactionHistory({ - orderType: params.orderType, - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.page && { page: params.page }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetNFTTransactionHistory", + "Retrieves NFT transaction history, including purchase orders, sale orders, royalty income, primary market orders, and mint fees. It returns details about the NFT network, token IDs, contract addresses, transaction times, trade amounts, and the currencies used in the transactions.", + { + orderType: z + .number() + .describe( + "Order type: 0 for purchase order, 1 for sell order, 2 for royalty income, 3 for primary market order, 4 for mint fee", + ), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(50, "Limit cannot be greater than 50") + .default(50) + .describe("Number of records to return, default 50, max 50"), + page: z.number().int().default(1).describe("Page number, default is 1"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await nftClient.restAPI.getNFTTransactionHistory({ + orderType: params.orderType, + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.page && { page: params.page }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved NFT transaction history. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved NFT transaction history. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve NFT transaction history: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve NFT transaction history: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/nft/nft-api/getNFTWithdrawHistory.ts b/src/modules/nft/nft-api/getNFTWithdrawHistory.ts index f2ab7722..6cf2bdb7 100644 --- a/src/modules/nft/nft-api/getNFTWithdrawHistory.ts +++ b/src/modules/nft/nft-api/getNFTWithdrawHistory.ts @@ -1,58 +1,61 @@ // src/tools/binance-nft/nft-api/getNFTWithdrawHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { nftClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { nftClient } from "../../../config/binanceClient.js" export function registerBinanceGetNFTWithdrawHistory(server: McpServer) { - server.tool( - "BinanceGetNFTWithdrawHistory", - "Retrieves NFT withdraw history, including network, transaction ID, contract address, token ID, withdrawal fee, fee asset, and timestamps.", - { - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .max(50, "Limit cannot be greater than 50") - .default(50) - .describe("Number of records to return, default 50, max 50"), - page: z.number().int().default(1).describe("Page number, default is 1"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await nftClient.restAPI.getNFTWithdrawHistory({ - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.page && { page: params.page }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetNFTWithdrawHistory", + "Retrieves NFT withdraw history, including network, transaction ID, contract address, token ID, withdrawal fee, fee asset, and timestamps.", + { + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(50, "Limit cannot be greater than 50") + .default(50) + .describe("Number of records to return, default 50, max 50"), + page: z.number().int().default(1).describe("Page number, default is 1"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await nftClient.restAPI.getNFTWithdrawHistory({ + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.page && { page: params.page }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved NFT withdraw history, including network, transaction ID, contract address. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved NFT withdraw history, including network, transaction ID, contract address. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve NFT withdraw history: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve NFT withdraw history: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/options/account-api/getAccount.ts b/src/modules/options/account-api/getAccount.ts index 3fc5e4f0..d1081ddf 100644 --- a/src/modules/options/account-api/getAccount.ts +++ b/src/modules/options/account-api/getAccount.ts @@ -5,60 +5,67 @@ * @license Apache-2.0 */ // src/modules/options/account-api/getAccount.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../../config/binanceClient.js" export function registerOptionsGetAccount(server: McpServer) { - server.tool( - "BinanceOptionsGetAccount", - "Get options account information including balances and Greeks.", - { - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await optionsClient.restAPI.account({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Options Account Information\n\n`; - - if (data) { - result += `**Account Details**\n`; - result += `Asset: ${data.asset}\n`; - result += `Margin Balance: ${data.marginBalance}\n`; - result += `Equity: ${data.equity}\n`; - result += `Available: ${data.available}\n`; - result += `Unrealized PnL: ${data.unrealizedPNL}\n`; - result += `Maintenance Margin: ${data.maintenanceMargin}\n`; - result += `Initial Margin: ${data.initialMargin}\n\n`; - - result += `**Greeks**\n`; - result += `Delta: ${data.delta || 'N/A'}\n`; - result += `Theta: ${data.theta || 'N/A'}\n`; - result += `Gamma: ${data.gamma || 'N/A'}\n`; - result += `Vega: ${data.vega || 'N/A'}\n`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get options account: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceOptionsGetAccount", + "Get options account information including balances and Greeks.", + { + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await optionsClient.restAPI.account({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Options Account Information\n\n` + + if (data) { + result += `**Account Details**\n` + result += `Asset: ${data.asset}\n` + result += `Margin Balance: ${data.marginBalance}\n` + result += `Equity: ${data.equity}\n` + result += `Available: ${data.available}\n` + result += `Unrealized PnL: ${data.unrealizedPNL}\n` + result += `Maintenance Margin: ${data.maintenanceMargin}\n` + result += `Initial Margin: ${data.initialMargin}\n\n` + + result += `**Greeks**\n` + result += `Delta: ${data.delta || "N/A"}\n` + result += `Theta: ${data.theta || "N/A"}\n` + result += `Gamma: ${data.gamma || "N/A"}\n` + result += `Vega: ${data.vega || "N/A"}\n` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get options account: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/options/account-api/getBillHistory.ts b/src/modules/options/account-api/getBillHistory.ts index 1eff6bb5..c6ecf835 100644 --- a/src/modules/options/account-api/getBillHistory.ts +++ b/src/modules/options/account-api/getBillHistory.ts @@ -5,70 +5,83 @@ * @license Apache-2.0 */ // src/modules/options/account-api/getBillHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../../config/binanceClient.js" export function registerOptionsGetBillHistory(server: McpServer) { - server.tool( - "BinanceOptionsGetBillHistory", - "Get options account funding flow (bill history). Shows transfers, fees, PnL, and other account activities.", - { - currency: z.string().describe("Currency (e.g., 'USDT')"), - recordId: z.number().int().optional().describe("Record ID to start from"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z.number().int().min(1).max(1000).optional().describe("Number of records to return (default 100, max 1000)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await optionsClient.restAPI.bill({ - currency: params.currency, - ...(params.recordId && { recordId: params.recordId }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Options Bill History\n\n`; - - if (Array.isArray(data) && data.length > 0) { - result += `Total records: ${data.length}\n\n`; - data.slice(0, 20).forEach((record: any, index: number) => { - result += `**${index + 1}. ${record.type}**\n`; - result += ` ID: ${record.id}\n`; - result += ` Amount: ${record.amount} ${record.currency}\n`; - result += ` Balance: ${record.balance}\n`; - if (record.symbol) result += ` Symbol: ${record.symbol}\n`; - result += ` Time: ${new Date(record.createTime).toISOString()}\n\n`; - }); - if (data.length > 20) { - result += `... and ${data.length - 20} more records`; - } - } else { - result += `No bill history found`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get options bill history: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceOptionsGetBillHistory", + "Get options account funding flow (bill history). Shows transfers, fees, PnL, and other account activities.", + { + currency: z.string().describe("Currency (e.g., 'USDT')"), + recordId: z.number().int().optional().describe("Record ID to start from"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .describe("Number of records to return (default 100, max 1000)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await optionsClient.restAPI.bill({ + currency: params.currency, + ...(params.recordId && { recordId: params.recordId }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Options Bill History\n\n` + + if (Array.isArray(data) && data.length > 0) { + result += `Total records: ${data.length}\n\n` + data.slice(0, 20).forEach((record: any, index: number) => { + result += `**${index + 1}. ${record.type}**\n` + result += ` ID: ${record.id}\n` + result += ` Amount: ${record.amount} ${record.currency}\n` + result += ` Balance: ${record.balance}\n` + if (record.symbol) result += ` Symbol: ${record.symbol}\n` + result += ` Time: ${new Date(record.createTime).toISOString()}\n\n` + }) + if (data.length > 20) { + result += `... and ${data.length - 20} more records` + } + } else { + result += `No bill history found` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get options bill history: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/options/account-api/getIncomeAsyn.ts b/src/modules/options/account-api/getIncomeAsyn.ts index 1552198b..a2eef35d 100644 --- a/src/modules/options/account-api/getIncomeAsyn.ts +++ b/src/modules/options/account-api/getIncomeAsyn.ts @@ -5,45 +5,52 @@ * @license Apache-2.0 */ // src/modules/options/account-api/getIncomeAsyn.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../../config/binanceClient.js" export function registerOptionsGetIncomeAsyn(server: McpServer) { - server.tool( - "BinanceOptionsGetIncomeAsyn", - "Request to generate an async download ID for options income history. Use with BinanceOptionsGetIncomeAsynId to retrieve results.", - { - startTime: z.number().int().describe("Start time in milliseconds"), - endTime: z.number().int().describe("End time in milliseconds"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await optionsClient.restAPI.incomeAsyn({ - startTime: params.startTime, - endTime: params.endTime, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Options Income Download Request Submitted\n\nDownload ID: ${data.downloadId || data.id}\n\nUse BinanceOptionsGetIncomeAsynId with this ID to retrieve the download URL.` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to request options income download: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceOptionsGetIncomeAsyn", + "Request to generate an async download ID for options income history. Use with BinanceOptionsGetIncomeAsynId to retrieve results.", + { + startTime: z.number().int().describe("Start time in milliseconds"), + endTime: z.number().int().describe("End time in milliseconds"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await optionsClient.restAPI.incomeAsyn({ + startTime: params.startTime, + endTime: params.endTime, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Options Income Download Request Submitted\n\nDownload ID: ${data.downloadId || data.id}\n\nUse BinanceOptionsGetIncomeAsynId with this ID to retrieve the download URL.`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to request options income download: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/options/account-api/getIncomeAsynId.ts b/src/modules/options/account-api/getIncomeAsynId.ts index 3f6e9e19..9df80c85 100644 --- a/src/modules/options/account-api/getIncomeAsynId.ts +++ b/src/modules/options/account-api/getIncomeAsynId.ts @@ -5,54 +5,61 @@ * @license Apache-2.0 */ // src/modules/options/account-api/getIncomeAsynId.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../../config/binanceClient.js" export function registerOptionsGetIncomeAsynId(server: McpServer) { - server.tool( - "BinanceOptionsGetIncomeAsynId", - "Get the download URL for options income history using a download ID from BinanceOptionsGetIncomeAsyn.", - { - downloadId: z.string().describe("Download ID from BinanceOptionsGetIncomeAsyn"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await optionsClient.restAPI.incomeAsynId({ - downloadId: params.downloadId, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Options Income Download Status\n\n`; - result += `Download ID: ${params.downloadId}\n`; - result += `Status: ${data.status}\n`; - - if (data.url) { - result += `\n**Download URL**: ${data.url}\n`; - result += `\nNote: URL is valid for a limited time.`; - } else if (data.status === 'processing') { - result += `\nThe download is still being processed. Please try again in a few moments.`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get options income download: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceOptionsGetIncomeAsynId", + "Get the download URL for options income history using a download ID from BinanceOptionsGetIncomeAsyn.", + { + downloadId: z.string().describe("Download ID from BinanceOptionsGetIncomeAsyn"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await optionsClient.restAPI.incomeAsynId({ + downloadId: params.downloadId, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Options Income Download Status\n\n` + result += `Download ID: ${params.downloadId}\n` + result += `Status: ${data.status}\n` + + if (data.url) { + result += `\n**Download URL**: ${data.url}\n` + result += `\nNote: URL is valid for a limited time.` + } else if (data.status === "processing") { + result += `\nThe download is still being processed. Please try again in a few moments.` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get options income download: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/options/account-api/getPosition.ts b/src/modules/options/account-api/getPosition.ts index 9d10a360..f127d8cc 100644 --- a/src/modules/options/account-api/getPosition.ts +++ b/src/modules/options/account-api/getPosition.ts @@ -5,63 +5,70 @@ * @license Apache-2.0 */ // src/modules/options/account-api/getPosition.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../../config/binanceClient.js" export function registerOptionsGetPosition(server: McpServer) { - server.tool( - "BinanceOptionsGetPosition", - "Get current options positions. Shows all active option contracts held.", - { - symbol: z.string().optional().describe("Option symbol to filter by"), - underlying: z.string().optional().describe("Underlying asset to filter by (e.g., 'BTCUSDT')"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await optionsClient.restAPI.position({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.underlying && { underlying: params.underlying }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Options Positions\n\n`; - - if (Array.isArray(data) && data.length > 0) { - result += `Total positions: ${data.length}\n\n`; - data.forEach((pos: any, index: number) => { - result += `**${index + 1}. ${pos.symbol}**\n`; - result += ` Side: ${pos.side}\n`; - result += ` Quantity: ${pos.quantity}\n`; - result += ` Entry Price: ${pos.entryPrice}\n`; - result += ` Mark Price: ${pos.markPrice}\n`; - result += ` Unrealized PnL: ${pos.unrealizedPNL}\n`; - result += ` Maintenance Margin: ${pos.maintMargin}\n`; - result += ` Expiry Date: ${pos.expiryDate}\n\n`; - }); - } else { - result += `No positions found`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get options positions: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceOptionsGetPosition", + "Get current options positions. Shows all active option contracts held.", + { + symbol: z.string().optional().describe("Option symbol to filter by"), + underlying: z.string().optional().describe("Underlying asset to filter by (e.g., 'BTCUSDT')"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await optionsClient.restAPI.position({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.underlying && { underlying: params.underlying }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Options Positions\n\n` + + if (Array.isArray(data) && data.length > 0) { + result += `Total positions: ${data.length}\n\n` + data.forEach((pos: any, index: number) => { + result += `**${index + 1}. ${pos.symbol}**\n` + result += ` Side: ${pos.side}\n` + result += ` Quantity: ${pos.quantity}\n` + result += ` Entry Price: ${pos.entryPrice}\n` + result += ` Mark Price: ${pos.markPrice}\n` + result += ` Unrealized PnL: ${pos.unrealizedPNL}\n` + result += ` Maintenance Margin: ${pos.maintMargin}\n` + result += ` Expiry Date: ${pos.expiryDate}\n\n` + }) + } else { + result += `No positions found` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get options positions: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/options/account-api/index.ts b/src/modules/options/account-api/index.ts index 1a2485fe..25b14262 100644 --- a/src/modules/options/account-api/index.ts +++ b/src/modules/options/account-api/index.ts @@ -5,17 +5,18 @@ * @license Apache-2.0 */ // src/modules/options/account-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerOptionsGetAccount } from "./getAccount.js"; -import { registerOptionsGetPosition } from "./getPosition.js"; -import { registerOptionsGetBillHistory } from "./getBillHistory.js"; -import { registerOptionsGetIncomeAsyn } from "./getIncomeAsyn.js"; -import { registerOptionsGetIncomeAsynId } from "./getIncomeAsynId.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerOptionsGetAccount } from "./getAccount.js" +import { registerOptionsGetBillHistory } from "./getBillHistory.js" +import { registerOptionsGetIncomeAsyn } from "./getIncomeAsyn.js" +import { registerOptionsGetIncomeAsynId } from "./getIncomeAsynId.js" +import { registerOptionsGetPosition } from "./getPosition.js" export function registerOptionsAccountApi(server: McpServer) { - registerOptionsGetAccount(server); - registerOptionsGetPosition(server); - registerOptionsGetBillHistory(server); - registerOptionsGetIncomeAsyn(server); - registerOptionsGetIncomeAsynId(server); + registerOptionsGetAccount(server) + registerOptionsGetPosition(server) + registerOptionsGetBillHistory(server) + registerOptionsGetIncomeAsyn(server) + registerOptionsGetIncomeAsynId(server) } diff --git a/src/modules/options/index.ts b/src/modules/options/index.ts index 255719b1..acc6b8e3 100644 --- a/src/modules/options/index.ts +++ b/src/modules/options/index.ts @@ -1,7 +1,8 @@ // src/modules/options/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceOptionsTools } from "../../tools/binance-options/index.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceOptionsTools } from "../../tools/binance-options/index.js" export function registerOptions(server: McpServer) { - registerBinanceOptionsTools(server); + registerBinanceOptionsTools(server) } diff --git a/src/modules/options/market-api/depth.ts b/src/modules/options/market-api/depth.ts index 7fa55c34..28402d2c 100644 --- a/src/modules/options/market-api/depth.ts +++ b/src/modules/options/market-api/depth.ts @@ -5,65 +5,77 @@ * @license Apache-2.0 */ // src/modules/options/market-api/depth.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../../config/binanceClient.js" export function registerOptionsMarketDepth(server: McpServer) { - server.tool( - "BinanceOptionsDepth", - "Get the order book depth for an options contract. Shows current bids and asks at various price levels.", - { - symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), - limit: z.number().int().min(1).max(1000).optional() - .describe("Limit the number of price levels returned (default 100, max 1000)") - }, - async (params) => { - try { - const response = await optionsClient.restAPI.depth({ - symbol: params.symbol, - ...(params.limit && { limit: params.limit }) - }); - - const data = await response.data(); - - let result = `✅ Options Order Book - ${params.symbol}\n\n`; - - // Format asks (sell orders) - result += `**Asks (Sell Orders)**:\n`; - if (data.asks && data.asks.length > 0) { - data.asks.slice(0, 10).forEach((ask: [string, string]) => { - result += ` Price: ${ask[0]} | Qty: ${ask[1]}\n`; - }); - } else { - result += ` No asks available\n`; - } - - result += `\n**Bids (Buy Orders)**:\n`; - if (data.bids && data.bids.length > 0) { - data.bids.slice(0, 10).forEach((bid: [string, string]) => { - result += ` Price: ${bid[0]} | Qty: ${bid[1]}\n`; - }); - } else { - result += ` No bids available\n`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get Options order book: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceOptionsDepth", + "Get the order book depth for an options contract. Shows current bids and asks at various price levels.", + { + symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), + limit: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .describe("Limit the number of price levels returned (default 100, max 1000)"), + }, + async (params) => { + try { + const response = await optionsClient.restAPI.depth({ + symbol: params.symbol, + ...(params.limit && { limit: params.limit }), + }) + + const data = await response.data() + + let result = `✅ Options Order Book - ${params.symbol}\n\n` + + // Format asks (sell orders) + result += `**Asks (Sell Orders)**:\n` + if (data.asks && data.asks.length > 0) { + data.asks.slice(0, 10).forEach((ask: [string, string]) => { + result += ` Price: ${ask[0]} | Qty: ${ask[1]}\n` + }) + } else { + result += ` No asks available\n` + } + + result += `\n**Bids (Buy Orders)**:\n` + if (data.bids && data.bids.length > 0) { + data.bids.slice(0, 10).forEach((bid: [string, string]) => { + result += ` Price: ${bid[0]} | Qty: ${bid[1]}\n` + }) + } else { + result += ` No bids available\n` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get Options order book: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/options/market-api/exchangeInfo.ts b/src/modules/options/market-api/exchangeInfo.ts index 54597549..7180d199 100644 --- a/src/modules/options/market-api/exchangeInfo.ts +++ b/src/modules/options/market-api/exchangeInfo.ts @@ -5,57 +5,63 @@ * @license Apache-2.0 */ // src/modules/options/market-api/exchangeInfo.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { optionsClient } from "../../../config/binanceClient.js" export function registerOptionsMarketExchangeInfo(server: McpServer) { - server.tool( - "BinanceOptionsExchangeInfo", - "Get current exchange trading rules and symbol information for options. Returns available option contracts, trading pairs, and their specifications.", - {}, - async () => { - try { - const response = await optionsClient.restAPI.exchangeInfo(); - const data = await response.data(); - - // Summarize the response - const optionSymbols = data.optionSymbols || []; - const assets = data.optionAssets || []; - - let summary = `✅ Options Exchange Information\n\n`; - summary += `**Timezone**: ${data.timezone}\n`; - summary += `**Server Time**: ${new Date(data.serverTime).toISOString()}\n\n`; - summary += `**Available Assets**: ${assets.length}\n`; - summary += `**Option Contracts**: ${optionSymbols.length}\n\n`; - - if (assets.length > 0) { - summary += `**Assets**: ${assets.map((a: any) => a.name || a).join(', ')}\n\n`; - } - - // Show first few contracts as examples - if (optionSymbols.length > 0) { - summary += `**Sample Contracts** (first 5):\n`; - optionSymbols.slice(0, 5).forEach((sym: any) => { - summary += `- ${sym.symbol}: ${sym.underlying} ${sym.side} Strike: ${sym.strikePrice} Expiry: ${sym.expiryDate}\n`; - }); - } - - return { - content: [{ - type: "text", - text: summary - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get Options exchange info: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceOptionsExchangeInfo", + "Get current exchange trading rules and symbol information for options. Returns available option contracts, trading pairs, and their specifications.", + {}, + async () => { + try { + const response = await optionsClient.restAPI.exchangeInfo() + const data = await response.data() + + // Summarize the response + const optionSymbols = data.optionSymbols || [] + const assets = data.optionAssets || [] + + let summary = `✅ Options Exchange Information\n\n` + summary += `**Timezone**: ${data.timezone}\n` + summary += `**Server Time**: ${new Date(data.serverTime).toISOString()}\n\n` + summary += `**Available Assets**: ${assets.length}\n` + summary += `**Option Contracts**: ${optionSymbols.length}\n\n` + + if (assets.length > 0) { + summary += `**Assets**: ${assets.map((a: any) => a.name || a).join(", ")}\n\n` + } + + // Show first few contracts as examples + if (optionSymbols.length > 0) { + summary += `**Sample Contracts** (first 5):\n` + optionSymbols.slice(0, 5).forEach((sym: any) => { + summary += `- ${sym.symbol}: ${sym.underlying} ${sym.side} Strike: ${sym.strikePrice} Expiry: ${sym.expiryDate}\n` + }) + } + + return { + content: [ + { + type: "text", + text: summary, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get Options exchange info: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/options/market-api/exerciseHistory.ts b/src/modules/options/market-api/exerciseHistory.ts index 92312ceb..fa61d9c2 100644 --- a/src/modules/options/market-api/exerciseHistory.ts +++ b/src/modules/options/market-api/exerciseHistory.ts @@ -5,67 +5,76 @@ * @license Apache-2.0 */ // src/modules/options/market-api/exerciseHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../../config/binanceClient.js" export function registerOptionsMarketExerciseHistory(server: McpServer) { - server.tool( - "BinanceOptionsExerciseHistory", - "Get the exercise history for options contracts. Shows historical exercise records and settlement prices.", - { - underlying: z.string().optional() - .describe("Underlying asset (e.g., 'BTCUSDT')"), - startTime: z.number().int().optional() - .describe("Start time in milliseconds"), - endTime: z.number().int().optional() - .describe("End time in milliseconds"), - limit: z.number().int().min(1).max(100).optional() - .describe("Number of records to return (default 100, max 100)") - }, - async (params) => { - try { - const response = await optionsClient.restAPI.exerciseHistory({ - ...(params.underlying && { underlying: params.underlying }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }) - }); - - const data = await response.data(); - - let result = `✅ Options Exercise History\n\n`; - - if (Array.isArray(data) && data.length > 0) { - result += `Total records: ${data.length}\n\n`; - data.forEach((record: any) => { - const exerciseTime = new Date(record.expiryDate).toISOString(); - result += `**${record.symbol}**\n`; - result += ` Strike Price: ${record.strikePrice}\n`; - result += ` Real Strike Price: ${record.realStrikePrice}\n`; - result += ` Exercise Price: ${record.exercisePrice}\n`; - result += ` Expiry Date: ${exerciseTime}\n\n`; - }); - } else { - result += `No exercise history found`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get Options exercise history: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceOptionsExerciseHistory", + "Get the exercise history for options contracts. Shows historical exercise records and settlement prices.", + { + underlying: z.string().optional().describe("Underlying asset (e.g., 'BTCUSDT')"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .min(1) + .max(100) + .optional() + .describe("Number of records to return (default 100, max 100)"), + }, + async (params) => { + try { + const response = await optionsClient.restAPI.exerciseHistory({ + ...(params.underlying && { underlying: params.underlying }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + }) + + const data = await response.data() + + let result = `✅ Options Exercise History\n\n` + + if (Array.isArray(data) && data.length > 0) { + result += `Total records: ${data.length}\n\n` + data.forEach((record: any) => { + const exerciseTime = new Date(record.expiryDate).toISOString() + result += `**${record.symbol}**\n` + result += ` Strike Price: ${record.strikePrice}\n` + result += ` Real Strike Price: ${record.realStrikePrice}\n` + result += ` Exercise Price: ${record.exercisePrice}\n` + result += ` Expiry Date: ${exerciseTime}\n\n` + }) + } else { + result += `No exercise history found` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get Options exercise history: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/options/market-api/historicalTrades.ts b/src/modules/options/market-api/historicalTrades.ts index 91725fb7..f18a3577 100644 --- a/src/modules/options/market-api/historicalTrades.ts +++ b/src/modules/options/market-api/historicalTrades.ts @@ -5,62 +5,77 @@ * @license Apache-2.0 */ // src/modules/options/market-api/historicalTrades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../../config/binanceClient.js" export function registerOptionsMarketHistoricalTrades(server: McpServer) { - server.tool( - "BinanceOptionsHistoricalTrades", - "Get older market trades for an options contract. Requires API key.", - { - symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), - limit: z.number().int().min(1).max(500).optional() - .describe("Number of trades to return (default 100, max 500)"), - fromId: z.number().int().optional() - .describe("Trade ID to fetch from. Default gets most recent trades") - }, - async (params) => { - try { - const response = await optionsClient.restAPI.historicalTrades({ - symbol: params.symbol, - ...(params.limit && { limit: params.limit }), - ...(params.fromId && { fromId: params.fromId }) - }); - - const data = await response.data(); - - let result = `✅ Historical Trades - ${params.symbol}\n\n`; - - if (Array.isArray(data) && data.length > 0) { - result += `Total trades returned: ${data.length}\n\n`; - data.slice(0, 20).forEach((trade: any, index: number) => { - const time = new Date(trade.time).toISOString(); - result += `${index + 1}. ID: ${trade.id} | Price: ${trade.price} | Qty: ${trade.qty} | Time: ${time}\n`; - }); - if (data.length > 20) { - result += `\n... and ${data.length - 20} more trades`; - } - } else { - result += `No historical trades found`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get Options historical trades: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceOptionsHistoricalTrades", + "Get older market trades for an options contract. Requires API key.", + { + symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), + limit: z + .number() + .int() + .min(1) + .max(500) + .optional() + .describe("Number of trades to return (default 100, max 500)"), + fromId: z + .number() + .int() + .optional() + .describe("Trade ID to fetch from. Default gets most recent trades"), + }, + async (params) => { + try { + const response = await optionsClient.restAPI.historicalTrades({ + symbol: params.symbol, + ...(params.limit && { limit: params.limit }), + ...(params.fromId && { fromId: params.fromId }), + }) + + const data = await response.data() + + let result = `✅ Historical Trades - ${params.symbol}\n\n` + + if (Array.isArray(data) && data.length > 0) { + result += `Total trades returned: ${data.length}\n\n` + data.slice(0, 20).forEach((trade: any, index: number) => { + const time = new Date(trade.time).toISOString() + result += `${index + 1}. ID: ${trade.id} | Price: ${trade.price} | Qty: ${trade.qty} | Time: ${time}\n` + }) + if (data.length > 20) { + result += `\n... and ${data.length - 20} more trades` + } + } else { + result += `No historical trades found` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get Options historical trades: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/options/market-api/index.ts b/src/modules/options/market-api/index.ts index f70eef80..73767068 100644 --- a/src/modules/options/market-api/index.ts +++ b/src/modules/options/market-api/index.ts @@ -5,29 +5,30 @@ * @license Apache-2.0 */ // src/modules/options/market-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerOptionsMarketPing } from "./ping.js"; -import { registerOptionsMarketTime } from "./time.js"; -import { registerOptionsMarketExchangeInfo } from "./exchangeInfo.js"; -import { registerOptionsMarketDepth } from "./depth.js"; -import { registerOptionsMarketTrades } from "./trades.js"; -import { registerOptionsMarketHistoricalTrades } from "./historicalTrades.js"; -import { registerOptionsMarketKlines } from "./klines.js"; -import { registerOptionsMarketMark } from "./mark.js"; -import { registerOptionsMarketTicker } from "./ticker.js"; -import { registerOptionsMarketIndex } from "./indexPrice.js"; -import { registerOptionsMarketExerciseHistory } from "./exerciseHistory.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerOptionsMarketDepth } from "./depth.js" +import { registerOptionsMarketExchangeInfo } from "./exchangeInfo.js" +import { registerOptionsMarketExerciseHistory } from "./exerciseHistory.js" +import { registerOptionsMarketHistoricalTrades } from "./historicalTrades.js" +import { registerOptionsMarketIndex } from "./indexPrice.js" +import { registerOptionsMarketKlines } from "./klines.js" +import { registerOptionsMarketMark } from "./mark.js" +import { registerOptionsMarketPing } from "./ping.js" +import { registerOptionsMarketTicker } from "./ticker.js" +import { registerOptionsMarketTime } from "./time.js" +import { registerOptionsMarketTrades } from "./trades.js" export function registerOptionsMarketApi(server: McpServer) { - registerOptionsMarketPing(server); - registerOptionsMarketTime(server); - registerOptionsMarketExchangeInfo(server); - registerOptionsMarketDepth(server); - registerOptionsMarketTrades(server); - registerOptionsMarketHistoricalTrades(server); - registerOptionsMarketKlines(server); - registerOptionsMarketMark(server); - registerOptionsMarketTicker(server); - registerOptionsMarketIndex(server); - registerOptionsMarketExerciseHistory(server); + registerOptionsMarketPing(server) + registerOptionsMarketTime(server) + registerOptionsMarketExchangeInfo(server) + registerOptionsMarketDepth(server) + registerOptionsMarketTrades(server) + registerOptionsMarketHistoricalTrades(server) + registerOptionsMarketKlines(server) + registerOptionsMarketMark(server) + registerOptionsMarketTicker(server) + registerOptionsMarketIndex(server) + registerOptionsMarketExerciseHistory(server) } diff --git a/src/modules/options/market-api/indexPrice.ts b/src/modules/options/market-api/indexPrice.ts index 5e74f6f4..668d9242 100644 --- a/src/modules/options/market-api/indexPrice.ts +++ b/src/modules/options/market-api/indexPrice.ts @@ -5,60 +5,67 @@ * @license Apache-2.0 */ // src/modules/options/market-api/indexPrice.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../../config/binanceClient.js" export function registerOptionsMarketIndex(server: McpServer) { - server.tool( - "BinanceOptionsIndex", - "Get the current index price for the underlying asset. The index price is used as a reference for options pricing.", - { - underlying: z.string().describe("Underlying asset (e.g., 'BTCUSDT', 'ETHUSDT')") - }, - async (params) => { - try { - const response = await optionsClient.restAPI.index({ - underlying: params.underlying - }); - - const data = await response.data(); - - let result = `✅ Options Index Price\n\n`; - - if (Array.isArray(data)) { - data.forEach((item: any) => { - result += `**${item.underlying || item.indexSymbol}**\n`; - result += `Index Price: ${item.indexPrice}\n`; - if (item.time) { - result += `Time: ${new Date(item.time).toISOString()}\n`; - } - result += '\n'; - }); - } else if (data) { - result += `**${data.underlying || data.indexSymbol || params.underlying}**\n`; - result += `Index Price: ${data.indexPrice}\n`; - if (data.time) { - result += `Time: ${new Date(data.time).toISOString()}\n`; - } - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get Options index price: ${errorMessage}` - }], - isError: true - }; + server.tool( + "BinanceOptionsIndex", + "Get the current index price for the underlying asset. The index price is used as a reference for options pricing.", + { + underlying: z.string().describe("Underlying asset (e.g., 'BTCUSDT', 'ETHUSDT')"), + }, + async (params) => { + try { + const response = await optionsClient.restAPI.index({ + underlying: params.underlying, + }) + + const data = await response.data() + + let result = `✅ Options Index Price\n\n` + + if (Array.isArray(data)) { + data.forEach((item: any) => { + result += `**${item.underlying || item.indexSymbol}**\n` + result += `Index Price: ${item.indexPrice}\n` + if (item.time) { + result += `Time: ${new Date(item.time).toISOString()}\n` } + result += "\n" + }) + } else if (data) { + result += `**${data.underlying || data.indexSymbol || params.underlying}**\n` + result += `Index Price: ${data.indexPrice}\n` + if (data.time) { + result += `Time: ${new Date(data.time).toISOString()}\n` + } + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get Options index price: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/options/market-api/klines.ts b/src/modules/options/market-api/klines.ts index a63d7053..4141f20f 100644 --- a/src/modules/options/market-api/klines.ts +++ b/src/modules/options/market-api/klines.ts @@ -5,72 +5,83 @@ * @license Apache-2.0 */ // src/modules/options/market-api/klines.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../../config/binanceClient.js" export function registerOptionsMarketKlines(server: McpServer) { - server.tool( - "BinanceOptionsKlines", - "Get kline/candlestick data for an options contract. Returns OHLCV data for technical analysis.", - { - symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), - interval: z.enum(["1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d", "3d", "1w"]) - .describe("Kline interval"), - startTime: z.number().int().optional() - .describe("Start time in milliseconds"), - endTime: z.number().int().optional() - .describe("End time in milliseconds"), - limit: z.number().int().min(1).max(1500).optional() - .describe("Number of klines to return (default 500, max 1500)") - }, - async (params) => { - try { - const response = await optionsClient.restAPI.klines({ - symbol: params.symbol, - interval: params.interval, - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }) - }); - - const data = await response.data(); - - let result = `✅ Klines - ${params.symbol} (${params.interval})\n\n`; - - if (Array.isArray(data) && data.length > 0) { - result += `Total candles: ${data.length}\n\n`; - result += `| Open Time | Open | High | Low | Close | Volume |\n`; - result += `|-----------|------|------|-----|-------|--------|\n`; - - data.slice(-10).forEach((kline: any) => { - const openTime = new Date(kline[0]).toISOString().slice(0, 16); - result += `| ${openTime} | ${kline[1]} | ${kline[2]} | ${kline[3]} | ${kline[4]} | ${kline[5]} |\n`; - }); - - if (data.length > 10) { - result += `\nShowing last 10 of ${data.length} candles`; - } - } else { - result += `No kline data found`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get Options klines: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceOptionsKlines", + "Get kline/candlestick data for an options contract. Returns OHLCV data for technical analysis.", + { + symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), + interval: z + .enum(["1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d", "3d", "1w"]) + .describe("Kline interval"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .min(1) + .max(1500) + .optional() + .describe("Number of klines to return (default 500, max 1500)"), + }, + async (params) => { + try { + const response = await optionsClient.restAPI.klines({ + symbol: params.symbol, + interval: params.interval, + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + }) + + const data = await response.data() + + let result = `✅ Klines - ${params.symbol} (${params.interval})\n\n` + + if (Array.isArray(data) && data.length > 0) { + result += `Total candles: ${data.length}\n\n` + result += `| Open Time | Open | High | Low | Close | Volume |\n` + result += `|-----------|------|------|-----|-------|--------|\n` + + data.slice(-10).forEach((kline: any) => { + const openTime = new Date(kline[0]).toISOString().slice(0, 16) + result += `| ${openTime} | ${kline[1]} | ${kline[2]} | ${kline[3]} | ${kline[4]} | ${kline[5]} |\n` + }) + + if (data.length > 10) { + result += `\nShowing last 10 of ${data.length} candles` + } + } else { + result += `No kline data found` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get Options klines: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/options/market-api/mark.ts b/src/modules/options/market-api/mark.ts index f929ffb1..0f384050 100644 --- a/src/modules/options/market-api/mark.ts +++ b/src/modules/options/market-api/mark.ts @@ -5,66 +5,77 @@ * @license Apache-2.0 */ // src/modules/options/market-api/mark.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../../config/binanceClient.js" export function registerOptionsMarketMark(server: McpServer) { - server.tool( - "BinanceOptionsMark", - "Get the mark price for options contracts. Mark price is used for liquidation and margin calculations.", - { - symbol: z.string().optional() - .describe("Option symbol (e.g., 'BTC-240126-40000-C'). If not provided, returns all mark prices") - }, - async (params) => { - try { - const response = await optionsClient.restAPI.mark({ - ...(params.symbol && { symbol: params.symbol }) - }); - - const data = await response.data(); - - let result = `✅ Options Mark Prices\n\n`; - - if (Array.isArray(data)) { - result += `Total contracts: ${data.length}\n\n`; - data.slice(0, 20).forEach((item: any) => { - result += `**${item.symbol}**\n`; - result += ` Mark Price: ${item.markPrice}\n`; - result += ` Bid IV: ${item.bidIV} | Ask IV: ${item.askIV}\n`; - result += ` Mark IV: ${item.markIV}\n`; - result += ` Delta: ${item.delta} | Theta: ${item.theta}\n`; - result += ` Gamma: ${item.gamma} | Vega: ${item.vega}\n\n`; - }); - if (data.length > 20) { - result += `... and ${data.length - 20} more contracts`; - } - } else if (data) { - result += `**${data.symbol}**\n`; - result += `Mark Price: ${data.markPrice}\n`; - result += `Bid IV: ${data.bidIV} | Ask IV: ${data.askIV}\n`; - result += `Mark IV: ${data.markIV}\n`; - result += `Delta: ${data.delta} | Theta: ${data.theta}\n`; - result += `Gamma: ${data.gamma} | Vega: ${data.vega}\n`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get Options mark prices: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceOptionsMark", + "Get the mark price for options contracts. Mark price is used for liquidation and margin calculations.", + { + symbol: z + .string() + .optional() + .describe( + "Option symbol (e.g., 'BTC-240126-40000-C'). If not provided, returns all mark prices", + ), + }, + async (params) => { + try { + const response = await optionsClient.restAPI.mark({ + ...(params.symbol && { symbol: params.symbol }), + }) + + const data = await response.data() + + let result = `✅ Options Mark Prices\n\n` + + if (Array.isArray(data)) { + result += `Total contracts: ${data.length}\n\n` + data.slice(0, 20).forEach((item: any) => { + result += `**${item.symbol}**\n` + result += ` Mark Price: ${item.markPrice}\n` + result += ` Bid IV: ${item.bidIV} | Ask IV: ${item.askIV}\n` + result += ` Mark IV: ${item.markIV}\n` + result += ` Delta: ${item.delta} | Theta: ${item.theta}\n` + result += ` Gamma: ${item.gamma} | Vega: ${item.vega}\n\n` + }) + if (data.length > 20) { + result += `... and ${data.length - 20} more contracts` + } + } else if (data) { + result += `**${data.symbol}**\n` + result += `Mark Price: ${data.markPrice}\n` + result += `Bid IV: ${data.bidIV} | Ask IV: ${data.askIV}\n` + result += `Mark IV: ${data.markIV}\n` + result += `Delta: ${data.delta} | Theta: ${data.theta}\n` + result += `Gamma: ${data.gamma} | Vega: ${data.vega}\n` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get Options mark prices: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/options/market-api/ping.ts b/src/modules/options/market-api/ping.ts index dcf972df..4372ced6 100644 --- a/src/modules/options/market-api/ping.ts +++ b/src/modules/options/market-api/ping.ts @@ -5,35 +5,41 @@ * @license Apache-2.0 */ // src/modules/options/market-api/ping.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { optionsClient } from "../../../config/binanceClient.js" export function registerOptionsMarketPing(server: McpServer) { - server.tool( - "BinanceOptionsPing", - "Test connectivity to the Options API. Returns empty object if successful.", - {}, - async () => { - try { - const response = await optionsClient.restAPI.ping(); - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Options API connectivity test successful!\n\nResponse: ${JSON.stringify(data)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Options API connectivity test failed: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceOptionsPing", + "Test connectivity to the Options API. Returns empty object if successful.", + {}, + async () => { + try { + const response = await optionsClient.restAPI.ping() + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Options API connectivity test successful!\n\nResponse: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Options API connectivity test failed: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/options/market-api/ticker.ts b/src/modules/options/market-api/ticker.ts index 46c2ff40..e60c86d7 100644 --- a/src/modules/options/market-api/ticker.ts +++ b/src/modules/options/market-api/ticker.ts @@ -5,67 +5,79 @@ * @license Apache-2.0 */ // src/modules/options/market-api/ticker.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../../config/binanceClient.js" export function registerOptionsMarketTicker(server: McpServer) { - server.tool( - "BinanceOptionsTicker", - "Get 24hr ticker price change statistics for options contracts. Returns price change, volume, and other trading stats.", - { - symbol: z.string().optional() - .describe("Option symbol (e.g., 'BTC-240126-40000-C'). If not provided, returns all tickers") - }, - async (params) => { - try { - const response = await optionsClient.restAPI.ticker({ - ...(params.symbol && { symbol: params.symbol }) - }); - - const data = await response.data(); - - let result = `✅ Options 24hr Ticker Statistics\n\n`; - - const formatTicker = (ticker: any) => { - let str = `**${ticker.symbol}**\n`; - str += ` Price Change: ${ticker.priceChange} (${ticker.priceChangePercent}%)\n`; - str += ` Last Price: ${ticker.lastPrice}\n`; - str += ` High: ${ticker.high} | Low: ${ticker.low}\n`; - str += ` Volume: ${ticker.volume}\n`; - str += ` Quote Volume: ${ticker.quoteVolume}\n`; - str += ` Open Interest: ${ticker.openInterest}\n`; - return str; - }; - - if (Array.isArray(data)) { - result += `Total contracts: ${data.length}\n\n`; - data.slice(0, 15).forEach((ticker: any) => { - result += formatTicker(ticker) + '\n'; - }); - if (data.length > 15) { - result += `... and ${data.length - 15} more contracts`; - } - } else if (data) { - result += formatTicker(data); - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get Options ticker: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceOptionsTicker", + "Get 24hr ticker price change statistics for options contracts. Returns price change, volume, and other trading stats.", + { + symbol: z + .string() + .optional() + .describe( + "Option symbol (e.g., 'BTC-240126-40000-C'). If not provided, returns all tickers", + ), + }, + async (params) => { + try { + const response = await optionsClient.restAPI.ticker({ + ...(params.symbol && { symbol: params.symbol }), + }) + + const data = await response.data() + + let result = `✅ Options 24hr Ticker Statistics\n\n` + + const formatTicker = (ticker: any) => { + let str = `**${ticker.symbol}**\n` + str += ` Price Change: ${ticker.priceChange} (${ticker.priceChangePercent}%)\n` + str += ` Last Price: ${ticker.lastPrice}\n` + str += ` High: ${ticker.high} | Low: ${ticker.low}\n` + str += ` Volume: ${ticker.volume}\n` + str += ` Quote Volume: ${ticker.quoteVolume}\n` + str += ` Open Interest: ${ticker.openInterest}\n` + + return str + } + + if (Array.isArray(data)) { + result += `Total contracts: ${data.length}\n\n` + data.slice(0, 15).forEach((ticker: any) => { + result += formatTicker(ticker) + "\n" + }) + if (data.length > 15) { + result += `... and ${data.length - 15} more contracts` + } + } else if (data) { + result += formatTicker(data) + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get Options ticker: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/options/market-api/time.ts b/src/modules/options/market-api/time.ts index 1b049745..fcacecce 100644 --- a/src/modules/options/market-api/time.ts +++ b/src/modules/options/market-api/time.ts @@ -5,37 +5,43 @@ * @license Apache-2.0 */ // src/modules/options/market-api/time.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { optionsClient } from "../../../config/binanceClient.js" export function registerOptionsMarketTime(server: McpServer) { - server.tool( - "BinanceOptionsTime", - "Get the current server time from the Options API.", - {}, - async () => { - try { - const response = await optionsClient.restAPI.time(); - const data = await response.data(); - - const serverTime = new Date(data.serverTime).toISOString(); - - return { - content: [{ - type: "text", - text: `✅ Options Server Time\n\nTimestamp: ${data.serverTime}\nUTC: ${serverTime}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get Options server time: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceOptionsTime", + "Get the current server time from the Options API.", + {}, + async () => { + try { + const response = await optionsClient.restAPI.time() + const data = await response.data() + + const serverTime = new Date(data.serverTime).toISOString() + + return { + content: [ + { + type: "text", + text: `✅ Options Server Time\n\nTimestamp: ${data.serverTime}\nUTC: ${serverTime}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get Options server time: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/options/market-api/trades.ts b/src/modules/options/market-api/trades.ts index 66c4b463..17f88219 100644 --- a/src/modules/options/market-api/trades.ts +++ b/src/modules/options/market-api/trades.ts @@ -5,59 +5,71 @@ * @license Apache-2.0 */ // src/modules/options/market-api/trades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../../config/binanceClient.js" export function registerOptionsMarketTrades(server: McpServer) { - server.tool( - "BinanceOptionsTrades", - "Get recent trades for an options contract. Shows the most recent executed trades.", - { - symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), - limit: z.number().int().min(1).max(500).optional() - .describe("Number of trades to return (default 100, max 500)") - }, - async (params) => { - try { - const response = await optionsClient.restAPI.trades({ - symbol: params.symbol, - ...(params.limit && { limit: params.limit }) - }); - - const data = await response.data(); - - let result = `✅ Recent Trades - ${params.symbol}\n\n`; - - if (Array.isArray(data) && data.length > 0) { - result += `Total trades returned: ${data.length}\n\n`; - data.slice(0, 20).forEach((trade: any, index: number) => { - const time = new Date(trade.time).toISOString(); - result += `${index + 1}. Price: ${trade.price} | Qty: ${trade.qty} | Time: ${time}\n`; - }); - if (data.length > 20) { - result += `\n... and ${data.length - 20} more trades`; - } - } else { - result += `No recent trades found`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get Options trades: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceOptionsTrades", + "Get recent trades for an options contract. Shows the most recent executed trades.", + { + symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), + limit: z + .number() + .int() + .min(1) + .max(500) + .optional() + .describe("Number of trades to return (default 100, max 500)"), + }, + async (params) => { + try { + const response = await optionsClient.restAPI.trades({ + symbol: params.symbol, + ...(params.limit && { limit: params.limit }), + }) + + const data = await response.data() + + let result = `✅ Recent Trades - ${params.symbol}\n\n` + + if (Array.isArray(data) && data.length > 0) { + result += `Total trades returned: ${data.length}\n\n` + data.slice(0, 20).forEach((trade: any, index: number) => { + const time = new Date(trade.time).toISOString() + result += `${index + 1}. Price: ${trade.price} | Qty: ${trade.qty} | Time: ${time}\n` + }) + if (data.length > 20) { + result += `\n... and ${data.length - 20} more trades` + } + } else { + result += `No recent trades found` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get Options trades: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/options/trade-api/batchOrders.ts b/src/modules/options/trade-api/batchOrders.ts index ddc2f619..a19dccb9 100644 --- a/src/modules/options/trade-api/batchOrders.ts +++ b/src/modules/options/trade-api/batchOrders.ts @@ -5,70 +5,83 @@ * @license Apache-2.0 */ // src/modules/options/trade-api/batchOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../../config/binanceClient.js" export function registerOptionsBatchOrders(server: McpServer) { - server.tool( - "BinanceOptionsBatchOrders", - "Place multiple options orders in a single request. Maximum 5 orders per request. ⚠️ HIGH RISK: Options can expire worthless.", - { - orders: z.array(z.object({ - symbol: z.string().describe("Option symbol"), - side: z.enum(["BUY", "SELL"]).describe("Order side"), - type: z.enum(["LIMIT"]).describe("Order type"), - quantity: z.string().describe("Number of contracts"), - price: z.string().describe("Limit price"), - timeInForce: z.enum(["GTC", "IOC", "FOK"]).optional(), - reduceOnly: z.boolean().optional(), - postOnly: z.boolean().optional(), - newClientOrderId: z.string().optional() - })).min(1).max(5).describe("Array of orders (max 5)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await optionsClient.restAPI.batchOrders({ - orders: JSON.stringify(params.orders), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Batch Options Orders Placed\n\n`; - - if (Array.isArray(data)) { - data.forEach((order: any, index: number) => { - if (order.orderId) { - result += `Order ${index + 1}: ✅ Success\n`; - result += ` Order ID: ${order.orderId}\n`; - result += ` Symbol: ${order.symbol}\n`; - result += ` Side: ${order.side} | Qty: ${order.quantity}\n`; - result += ` Price: ${order.price} | Status: ${order.status}\n\n`; - } else { - result += `Order ${index + 1}: ❌ Failed\n`; - result += ` Error: ${order.msg || 'Unknown error'}\n\n`; - } - }); - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to place batch options orders: ${errorMessage}` - }], - isError: true - }; + server.tool( + "BinanceOptionsBatchOrders", + "Place multiple options orders in a single request. Maximum 5 orders per request. ⚠️ HIGH RISK: Options can expire worthless.", + { + orders: z + .array( + z.object({ + symbol: z.string().describe("Option symbol"), + side: z.enum(["BUY", "SELL"]).describe("Order side"), + type: z.enum(["LIMIT"]).describe("Order type"), + quantity: z.string().describe("Number of contracts"), + price: z.string().describe("Limit price"), + timeInForce: z.enum(["GTC", "IOC", "FOK"]).optional(), + reduceOnly: z.boolean().optional(), + postOnly: z.boolean().optional(), + newClientOrderId: z.string().optional(), + }), + ) + .min(1) + .max(5) + .describe("Array of orders (max 5)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await optionsClient.restAPI.batchOrders({ + orders: JSON.stringify(params.orders), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Batch Options Orders Placed\n\n` + + if (Array.isArray(data)) { + data.forEach((order: any, index: number) => { + if (order.orderId) { + result += `Order ${index + 1}: ✅ Success\n` + result += ` Order ID: ${order.orderId}\n` + result += ` Symbol: ${order.symbol}\n` + result += ` Side: ${order.side} | Qty: ${order.quantity}\n` + result += ` Price: ${order.price} | Status: ${order.status}\n\n` + } else { + result += `Order ${index + 1}: ❌ Failed\n` + result += ` Error: ${order.msg || "Unknown error"}\n\n` } + }) + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to place batch options orders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/options/trade-api/cancelAllOrders.ts b/src/modules/options/trade-api/cancelAllOrders.ts index c7ed6906..639b8ed6 100644 --- a/src/modules/options/trade-api/cancelAllOrders.ts +++ b/src/modules/options/trade-api/cancelAllOrders.ts @@ -5,43 +5,50 @@ * @license Apache-2.0 */ // src/modules/options/trade-api/cancelAllOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../../config/binanceClient.js" export function registerOptionsCancelAllOrders(server: McpServer) { - server.tool( - "BinanceOptionsCancelAllOrders", - "Cancel all open options orders for a specific symbol. ⚠️ This will cancel ALL open orders for the symbol.", - { - symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await optionsClient.restAPI.cancelAllOpenOrders({ - symbol: params.symbol, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ All open orders cancelled for ${params.symbol}\n\nResponse: ${JSON.stringify(data)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to cancel all options orders: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceOptionsCancelAllOrders", + "Cancel all open options orders for a specific symbol. ⚠️ This will cancel ALL open orders for the symbol.", + { + symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await optionsClient.restAPI.cancelAllOpenOrders({ + symbol: params.symbol, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ All open orders cancelled for ${params.symbol}\n\nResponse: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to cancel all options orders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/options/trade-api/cancelBatchOrders.ts b/src/modules/options/trade-api/cancelBatchOrders.ts index 52163a99..0cf7ad44 100644 --- a/src/modules/options/trade-api/cancelBatchOrders.ts +++ b/src/modules/options/trade-api/cancelBatchOrders.ts @@ -5,73 +5,88 @@ * @license Apache-2.0 */ // src/modules/options/trade-api/cancelBatchOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../../config/binanceClient.js" export function registerOptionsCancelBatchOrders(server: McpServer) { - server.tool( - "BinanceOptionsCancelBatchOrders", - "Cancel multiple options orders in a single request. Maximum 5 orders per request.", - { - symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), - orderIds: z.array(z.number().int()).optional().describe("Array of order IDs to cancel (max 5)"), - clientOrderIds: z.array(z.string()).optional().describe("Array of client order IDs to cancel (max 5)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - if (!params.orderIds && !params.clientOrderIds) { - return { - content: [{ - type: "text", - text: `❌ Either orderIds or clientOrderIds must be provided` - }], - isError: true - }; - } - - const response = await optionsClient.restAPI.cancelBatchOrders({ - symbol: params.symbol, - ...(params.orderIds && { orderIds: JSON.stringify(params.orderIds) }), - ...(params.clientOrderIds && { clientOrderIds: JSON.stringify(params.clientOrderIds) }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Batch Options Orders Cancelled\n\n`; - - if (Array.isArray(data)) { - data.forEach((order: any, index: number) => { - if (order.orderId && !order.code) { - result += `Order ${index + 1}: ✅ Cancelled\n`; - result += ` Order ID: ${order.orderId}\n`; - result += ` Symbol: ${order.symbol}\n`; - result += ` Status: ${order.status}\n\n`; - } else { - result += `Order ${index + 1}: ❌ Failed\n`; - result += ` Error: ${order.msg || 'Unknown error'}\n\n`; - } - }); - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to cancel batch options orders: ${errorMessage}` - }], - isError: true - }; + server.tool( + "BinanceOptionsCancelBatchOrders", + "Cancel multiple options orders in a single request. Maximum 5 orders per request.", + { + symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), + orderIds: z + .array(z.number().int()) + .optional() + .describe("Array of order IDs to cancel (max 5)"), + clientOrderIds: z + .array(z.string()) + .optional() + .describe("Array of client order IDs to cancel (max 5)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + if (!params.orderIds && !params.clientOrderIds) { + return { + content: [ + { + type: "text", + text: `❌ Either orderIds or clientOrderIds must be provided`, + }, + ], + isError: true, + } + } + + const response = await optionsClient.restAPI.cancelBatchOrders({ + symbol: params.symbol, + ...(params.orderIds && { orderIds: JSON.stringify(params.orderIds) }), + ...(params.clientOrderIds && { clientOrderIds: JSON.stringify(params.clientOrderIds) }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Batch Options Orders Cancelled\n\n` + + if (Array.isArray(data)) { + data.forEach((order: any, index: number) => { + if (order.orderId && !order.code) { + result += `Order ${index + 1}: ✅ Cancelled\n` + result += ` Order ID: ${order.orderId}\n` + result += ` Symbol: ${order.symbol}\n` + result += ` Status: ${order.status}\n\n` + } else { + result += `Order ${index + 1}: ❌ Failed\n` + result += ` Error: ${order.msg || "Unknown error"}\n\n` } + }) + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to cancel batch options orders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/options/trade-api/cancelBySymbol.ts b/src/modules/options/trade-api/cancelBySymbol.ts index 5083904e..9e7ea442 100644 --- a/src/modules/options/trade-api/cancelBySymbol.ts +++ b/src/modules/options/trade-api/cancelBySymbol.ts @@ -5,43 +5,50 @@ * @license Apache-2.0 */ // src/modules/options/trade-api/cancelBySymbol.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../../config/binanceClient.js" export function registerOptionsCancelBySymbol(server: McpServer) { - server.tool( - "BinanceOptionsCancelByUnderlying", - "Cancel all open options orders for all contracts of an underlying asset (e.g., all BTC options). ⚠️ This will cancel ALL open orders for the underlying.", - { - underlying: z.string().describe("Underlying asset (e.g., 'BTCUSDT')"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await optionsClient.restAPI.cancelAllOpenOrdersByUnderlying({ - underlying: params.underlying, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ All open orders cancelled for underlying ${params.underlying}\n\nResponse: ${JSON.stringify(data)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to cancel orders by underlying: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceOptionsCancelByUnderlying", + "Cancel all open options orders for all contracts of an underlying asset (e.g., all BTC options). ⚠️ This will cancel ALL open orders for the underlying.", + { + underlying: z.string().describe("Underlying asset (e.g., 'BTCUSDT')"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await optionsClient.restAPI.cancelAllOpenOrdersByUnderlying({ + underlying: params.underlying, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ All open orders cancelled for underlying ${params.underlying}\n\nResponse: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to cancel orders by underlying: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/options/trade-api/cancelOrder.ts b/src/modules/options/trade-api/cancelOrder.ts index 1f4dded0..5a913a6a 100644 --- a/src/modules/options/trade-api/cancelOrder.ts +++ b/src/modules/options/trade-api/cancelOrder.ts @@ -5,57 +5,66 @@ * @license Apache-2.0 */ // src/modules/options/trade-api/cancelOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../../config/binanceClient.js" export function registerOptionsCancelOrder(server: McpServer) { - server.tool( - "BinanceOptionsCancelOrder", - "Cancel an active options order by order ID or client order ID.", - { - symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), - orderId: z.number().int().optional().describe("Order ID to cancel"), - clientOrderId: z.string().optional().describe("Client order ID to cancel"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - if (!params.orderId && !params.clientOrderId) { - return { - content: [{ - type: "text", - text: `❌ Either orderId or clientOrderId must be provided` - }], - isError: true - }; - } - - const response = await optionsClient.restAPI.cancelOrder({ - symbol: params.symbol, - ...(params.orderId && { orderId: params.orderId }), - ...(params.clientOrderId && { clientOrderId: params.clientOrderId }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Options order cancelled!\n\nOrder ID: ${data.orderId}\nSymbol: ${data.symbol}\nSide: ${data.side}\nQuantity: ${data.quantity}\nPrice: ${data.price}\nStatus: ${data.status}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to cancel options order: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceOptionsCancelOrder", + "Cancel an active options order by order ID or client order ID.", + { + symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), + orderId: z.number().int().optional().describe("Order ID to cancel"), + clientOrderId: z.string().optional().describe("Client order ID to cancel"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + if (!params.orderId && !params.clientOrderId) { + return { + content: [ + { + type: "text", + text: `❌ Either orderId or clientOrderId must be provided`, + }, + ], + isError: true, + } + } + + const response = await optionsClient.restAPI.cancelOrder({ + symbol: params.symbol, + ...(params.orderId && { orderId: params.orderId }), + ...(params.clientOrderId && { clientOrderId: params.clientOrderId }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Options order cancelled!\n\nOrder ID: ${data.orderId}\nSymbol: ${data.symbol}\nSide: ${data.side}\nQuantity: ${data.quantity}\nPrice: ${data.price}\nStatus: ${data.status}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to cancel options order: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/options/trade-api/getHistoryOrders.ts b/src/modules/options/trade-api/getHistoryOrders.ts index 21385e69..e33363f0 100644 --- a/src/modules/options/trade-api/getHistoryOrders.ts +++ b/src/modules/options/trade-api/getHistoryOrders.ts @@ -5,71 +5,84 @@ * @license Apache-2.0 */ // src/modules/options/trade-api/getHistoryOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../../config/binanceClient.js" export function registerOptionsGetHistoryOrders(server: McpServer) { - server.tool( - "BinanceOptionsGetHistoryOrders", - "Get historical options orders. Returns filled, cancelled, and expired orders.", - { - symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), - orderId: z.number().int().optional().describe("Order ID to start from"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z.number().int().min(1).max(1000).optional().describe("Number of orders to return (default 500, max 1000)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await optionsClient.restAPI.historyOrders({ - symbol: params.symbol, - ...(params.orderId && { orderId: params.orderId }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Options Order History - ${params.symbol}\n\n`; - - if (Array.isArray(data) && data.length > 0) { - result += `Total orders: ${data.length}\n\n`; - data.slice(0, 20).forEach((order: any, index: number) => { - result += `**${index + 1}. Order ID: ${order.orderId}**\n`; - result += ` Side: ${order.side} | Type: ${order.type}\n`; - result += ` Price: ${order.price} | Qty: ${order.quantity}\n`; - result += ` Executed Qty: ${order.executedQty}\n`; - result += ` Avg Price: ${order.avgPrice}\n`; - result += ` Status: ${order.status}\n`; - result += ` Time: ${new Date(order.createTime).toISOString()}\n\n`; - }); - if (data.length > 20) { - result += `... and ${data.length - 20} more orders`; - } - } else { - result += `No historical orders found`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get options order history: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceOptionsGetHistoryOrders", + "Get historical options orders. Returns filled, cancelled, and expired orders.", + { + symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), + orderId: z.number().int().optional().describe("Order ID to start from"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .describe("Number of orders to return (default 500, max 1000)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await optionsClient.restAPI.historyOrders({ + symbol: params.symbol, + ...(params.orderId && { orderId: params.orderId }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Options Order History - ${params.symbol}\n\n` + + if (Array.isArray(data) && data.length > 0) { + result += `Total orders: ${data.length}\n\n` + data.slice(0, 20).forEach((order: any, index: number) => { + result += `**${index + 1}. Order ID: ${order.orderId}**\n` + result += ` Side: ${order.side} | Type: ${order.type}\n` + result += ` Price: ${order.price} | Qty: ${order.quantity}\n` + result += ` Executed Qty: ${order.executedQty}\n` + result += ` Avg Price: ${order.avgPrice}\n` + result += ` Status: ${order.status}\n` + result += ` Time: ${new Date(order.createTime).toISOString()}\n\n` + }) + if (data.length > 20) { + result += `... and ${data.length - 20} more orders` + } + } else { + result += `No historical orders found` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get options order history: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/options/trade-api/getOpenOrders.ts b/src/modules/options/trade-api/getOpenOrders.ts index 4a65645f..908cad82 100644 --- a/src/modules/options/trade-api/getOpenOrders.ts +++ b/src/modules/options/trade-api/getOpenOrders.ts @@ -5,62 +5,69 @@ * @license Apache-2.0 */ // src/modules/options/trade-api/getOpenOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../../config/binanceClient.js" export function registerOptionsGetOpenOrders(server: McpServer) { - server.tool( - "BinanceOptionsGetOpenOrders", - "Get all open options orders. Can filter by symbol or underlying asset.", - { - symbol: z.string().optional().describe("Option symbol to filter by"), - underlying: z.string().optional().describe("Underlying asset to filter by (e.g., 'BTCUSDT')"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await optionsClient.restAPI.openOrders({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.underlying && { underlying: params.underlying }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Open Options Orders\n\n`; - - if (Array.isArray(data) && data.length > 0) { - result += `Total open orders: ${data.length}\n\n`; - data.forEach((order: any, index: number) => { - result += `**${index + 1}. ${order.symbol}**\n`; - result += ` Order ID: ${order.orderId}\n`; - result += ` Side: ${order.side} | Type: ${order.type}\n`; - result += ` Price: ${order.price} | Qty: ${order.quantity}\n`; - result += ` Executed Qty: ${order.executedQty}\n`; - result += ` Status: ${order.status}\n`; - result += ` Time: ${new Date(order.createTime).toISOString()}\n\n`; - }); - } else { - result += `No open orders found`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get open options orders: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceOptionsGetOpenOrders", + "Get all open options orders. Can filter by symbol or underlying asset.", + { + symbol: z.string().optional().describe("Option symbol to filter by"), + underlying: z.string().optional().describe("Underlying asset to filter by (e.g., 'BTCUSDT')"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await optionsClient.restAPI.openOrders({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.underlying && { underlying: params.underlying }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Open Options Orders\n\n` + + if (Array.isArray(data) && data.length > 0) { + result += `Total open orders: ${data.length}\n\n` + data.forEach((order: any, index: number) => { + result += `**${index + 1}. ${order.symbol}**\n` + result += ` Order ID: ${order.orderId}\n` + result += ` Side: ${order.side} | Type: ${order.type}\n` + result += ` Price: ${order.price} | Qty: ${order.quantity}\n` + result += ` Executed Qty: ${order.executedQty}\n` + result += ` Status: ${order.status}\n` + result += ` Time: ${new Date(order.createTime).toISOString()}\n\n` + }) + } else { + result += `No open orders found` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get open options orders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/options/trade-api/getUserTrades.ts b/src/modules/options/trade-api/getUserTrades.ts index 68fb598b..cb967d00 100644 --- a/src/modules/options/trade-api/getUserTrades.ts +++ b/src/modules/options/trade-api/getUserTrades.ts @@ -5,74 +5,87 @@ * @license Apache-2.0 */ // src/modules/options/trade-api/getUserTrades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../../config/binanceClient.js" export function registerOptionsGetUserTrades(server: McpServer) { - server.tool( - "BinanceOptionsGetUserTrades", - "Get user's options trade history. Returns executed trades with prices and quantities.", - { - symbol: z.string().optional().describe("Option symbol to filter by"), - underlying: z.string().optional().describe("Underlying asset to filter by (e.g., 'BTCUSDT')"), - fromId: z.number().int().optional().describe("Trade ID to fetch from"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z.number().int().min(1).max(1000).optional().describe("Number of trades to return (default 100, max 1000)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await optionsClient.restAPI.userTrades({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.underlying && { underlying: params.underlying }), - ...(params.fromId && { fromId: params.fromId }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Options Trade History\n\n`; - - if (Array.isArray(data) && data.length > 0) { - result += `Total trades: ${data.length}\n\n`; - data.slice(0, 20).forEach((trade: any, index: number) => { - result += `**${index + 1}. ${trade.symbol}**\n`; - result += ` Trade ID: ${trade.id}\n`; - result += ` Order ID: ${trade.orderId}\n`; - result += ` Side: ${trade.side}\n`; - result += ` Price: ${trade.price} | Qty: ${trade.quantity}\n`; - result += ` Fee: ${trade.fee} ${trade.feeAsset}\n`; - result += ` Realized PnL: ${trade.realizedProfit}\n`; - result += ` Time: ${new Date(trade.time).toISOString()}\n\n`; - }); - if (data.length > 20) { - result += `... and ${data.length - 20} more trades`; - } - } else { - result += `No trades found`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get options trades: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceOptionsGetUserTrades", + "Get user's options trade history. Returns executed trades with prices and quantities.", + { + symbol: z.string().optional().describe("Option symbol to filter by"), + underlying: z.string().optional().describe("Underlying asset to filter by (e.g., 'BTCUSDT')"), + fromId: z.number().int().optional().describe("Trade ID to fetch from"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .describe("Number of trades to return (default 100, max 1000)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await optionsClient.restAPI.userTrades({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.underlying && { underlying: params.underlying }), + ...(params.fromId && { fromId: params.fromId }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Options Trade History\n\n` + + if (Array.isArray(data) && data.length > 0) { + result += `Total trades: ${data.length}\n\n` + data.slice(0, 20).forEach((trade: any, index: number) => { + result += `**${index + 1}. ${trade.symbol}**\n` + result += ` Trade ID: ${trade.id}\n` + result += ` Order ID: ${trade.orderId}\n` + result += ` Side: ${trade.side}\n` + result += ` Price: ${trade.price} | Qty: ${trade.quantity}\n` + result += ` Fee: ${trade.fee} ${trade.feeAsset}\n` + result += ` Realized PnL: ${trade.realizedProfit}\n` + result += ` Time: ${new Date(trade.time).toISOString()}\n\n` + }) + if (data.length > 20) { + result += `... and ${data.length - 20} more trades` + } + } else { + result += `No trades found` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get options trades: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/options/trade-api/index.ts b/src/modules/options/trade-api/index.ts index d25e76e7..a3f52f02 100644 --- a/src/modules/options/trade-api/index.ts +++ b/src/modules/options/trade-api/index.ts @@ -5,25 +5,26 @@ * @license Apache-2.0 */ // src/modules/options/trade-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerOptionsNewOrder } from "./newOrder.js"; -import { registerOptionsBatchOrders } from "./batchOrders.js"; -import { registerOptionsCancelOrder } from "./cancelOrder.js"; -import { registerOptionsCancelBatchOrders } from "./cancelBatchOrders.js"; -import { registerOptionsCancelAllOrders } from "./cancelAllOrders.js"; -import { registerOptionsCancelBySymbol } from "./cancelBySymbol.js"; -import { registerOptionsGetOpenOrders } from "./getOpenOrders.js"; -import { registerOptionsGetHistoryOrders } from "./getHistoryOrders.js"; -import { registerOptionsGetUserTrades } from "./getUserTrades.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerOptionsBatchOrders } from "./batchOrders.js" +import { registerOptionsCancelAllOrders } from "./cancelAllOrders.js" +import { registerOptionsCancelBatchOrders } from "./cancelBatchOrders.js" +import { registerOptionsCancelBySymbol } from "./cancelBySymbol.js" +import { registerOptionsCancelOrder } from "./cancelOrder.js" +import { registerOptionsGetHistoryOrders } from "./getHistoryOrders.js" +import { registerOptionsGetOpenOrders } from "./getOpenOrders.js" +import { registerOptionsGetUserTrades } from "./getUserTrades.js" +import { registerOptionsNewOrder } from "./newOrder.js" export function registerOptionsTradeApi(server: McpServer) { - registerOptionsNewOrder(server); - registerOptionsBatchOrders(server); - registerOptionsCancelOrder(server); - registerOptionsCancelBatchOrders(server); - registerOptionsCancelAllOrders(server); - registerOptionsCancelBySymbol(server); - registerOptionsGetOpenOrders(server); - registerOptionsGetHistoryOrders(server); - registerOptionsGetUserTrades(server); + registerOptionsNewOrder(server) + registerOptionsBatchOrders(server) + registerOptionsCancelOrder(server) + registerOptionsCancelBatchOrders(server) + registerOptionsCancelAllOrders(server) + registerOptionsCancelBySymbol(server) + registerOptionsGetOpenOrders(server) + registerOptionsGetHistoryOrders(server) + registerOptionsGetUserTrades(server) } diff --git a/src/modules/options/trade-api/newOrder.ts b/src/modules/options/trade-api/newOrder.ts index e18e6178..1ba6f341 100644 --- a/src/modules/options/trade-api/newOrder.ts +++ b/src/modules/options/trade-api/newOrder.ts @@ -5,62 +5,71 @@ * @license Apache-2.0 */ // src/modules/options/trade-api/newOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../../config/binanceClient.js" export function registerOptionsNewOrder(server: McpServer) { - server.tool( - "BinanceOptionsNewOrder", - "Place a new options order. Options trading allows you to buy/sell call and put contracts. ⚠️ HIGH RISK: Options can expire worthless.", - { - symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), - side: z.enum(["BUY", "SELL"]).describe("Order side"), - type: z.enum(["LIMIT"]).describe("Order type (only LIMIT supported)"), - quantity: z.string().describe("Number of contracts"), - price: z.string().describe("Limit price per contract"), - timeInForce: z.enum(["GTC", "IOC", "FOK"]).optional() - .describe("Time in force (default: GTC)"), - reduceOnly: z.boolean().optional().describe("Reduce position only (default: false)"), - postOnly: z.boolean().optional().describe("Post only order (default: false)"), - newClientOrderId: z.string().optional().describe("Custom client order ID"), - isMmp: z.boolean().optional().describe("Is market maker protection order"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await optionsClient.restAPI.newOrder({ - symbol: params.symbol, - side: params.side, - type: params.type, - quantity: params.quantity, - price: params.price, - ...(params.timeInForce && { timeInForce: params.timeInForce }), - ...(params.reduceOnly !== undefined && { reduceOnly: params.reduceOnly }), - ...(params.postOnly !== undefined && { postOnly: params.postOnly }), - ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), - ...(params.isMmp !== undefined && { isMmp: params.isMmp }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Options order placed!\n\nOrder ID: ${data.orderId}\nSymbol: ${data.symbol}\nSide: ${data.side}\nType: ${data.type}\nQuantity: ${data.quantity}\nPrice: ${data.price}\nStatus: ${data.status}\nClient Order ID: ${data.clientOrderId || 'N/A'}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to place options order: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceOptionsNewOrder", + "Place a new options order. Options trading allows you to buy/sell call and put contracts. ⚠️ HIGH RISK: Options can expire worthless.", + { + symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), + side: z.enum(["BUY", "SELL"]).describe("Order side"), + type: z.enum(["LIMIT"]).describe("Order type (only LIMIT supported)"), + quantity: z.string().describe("Number of contracts"), + price: z.string().describe("Limit price per contract"), + timeInForce: z + .enum(["GTC", "IOC", "FOK"]) + .optional() + .describe("Time in force (default: GTC)"), + reduceOnly: z.boolean().optional().describe("Reduce position only (default: false)"), + postOnly: z.boolean().optional().describe("Post only order (default: false)"), + newClientOrderId: z.string().optional().describe("Custom client order ID"), + isMmp: z.boolean().optional().describe("Is market maker protection order"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await optionsClient.restAPI.newOrder({ + symbol: params.symbol, + side: params.side, + type: params.type, + quantity: params.quantity, + price: params.price, + ...(params.timeInForce && { timeInForce: params.timeInForce }), + ...(params.reduceOnly !== undefined && { reduceOnly: params.reduceOnly }), + ...(params.postOnly !== undefined && { postOnly: params.postOnly }), + ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), + ...(params.isMmp !== undefined && { isMmp: params.isMmp }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Options order placed!\n\nOrder ID: ${data.orderId}\nSymbol: ${data.symbol}\nSide: ${data.side}\nType: ${data.type}\nQuantity: ${data.quantity}\nPrice: ${data.price}\nStatus: ${data.status}\nClient Order ID: ${data.clientOrderId || "N/A"}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to place options order: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/options/userdata-api/createListenKey.ts b/src/modules/options/userdata-api/createListenKey.ts index 8fab31ae..6d6ca2b8 100644 --- a/src/modules/options/userdata-api/createListenKey.ts +++ b/src/modules/options/userdata-api/createListenKey.ts @@ -5,35 +5,41 @@ * @license Apache-2.0 */ // src/modules/options/userdata-api/createListenKey.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { optionsClient } from "../../../config/binanceClient.js" export function registerOptionsCreateListenKey(server: McpServer) { - server.tool( - "BinanceOptionsCreateListenKey", - "Create a listen key for options user data stream. The listen key is used to subscribe to account updates via WebSocket.", - {}, - async () => { - try { - const response = await optionsClient.restAPI.createListenKey(); - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Options Listen Key Created\n\nListen Key: ${data.listenKey}\n\n**Note**: This listen key is valid for 60 minutes. Use BinanceOptionsRenewListenKey to extend validity. Use this key to connect to the WebSocket user data stream.` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to create options listen key: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceOptionsCreateListenKey", + "Create a listen key for options user data stream. The listen key is used to subscribe to account updates via WebSocket.", + {}, + async () => { + try { + const response = await optionsClient.restAPI.createListenKey() + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Options Listen Key Created\n\nListen Key: ${data.listenKey}\n\n**Note**: This listen key is valid for 60 minutes. Use BinanceOptionsRenewListenKey to extend validity. Use this key to connect to the WebSocket user data stream.`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to create options listen key: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/options/userdata-api/deleteListenKey.ts b/src/modules/options/userdata-api/deleteListenKey.ts index 310b13a3..18b2b0b4 100644 --- a/src/modules/options/userdata-api/deleteListenKey.ts +++ b/src/modules/options/userdata-api/deleteListenKey.ts @@ -5,40 +5,50 @@ * @license Apache-2.0 */ // src/modules/options/userdata-api/deleteListenKey.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../../config/binanceClient.js" export function registerOptionsDeleteListenKey(server: McpServer) { - server.tool( - "BinanceOptionsDeleteListenKey", - "Close/delete an options listen key. This will terminate the user data stream connection.", - { - listenKey: z.string().optional().describe("Listen key to delete. If not provided, deletes the current active key") - }, - async (params) => { - try { - const response = await optionsClient.restAPI.deleteListenKey({ - ...(params.listenKey && { listenKey: params.listenKey }) - }); - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Options Listen Key Deleted\n\nThe listen key has been invalidated and the user data stream will be closed.\n\nResponse: ${JSON.stringify(data)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to delete options listen key: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceOptionsDeleteListenKey", + "Close/delete an options listen key. This will terminate the user data stream connection.", + { + listenKey: z + .string() + .optional() + .describe("Listen key to delete. If not provided, deletes the current active key"), + }, + async (params) => { + try { + const response = await optionsClient.restAPI.deleteListenKey({ + ...(params.listenKey && { listenKey: params.listenKey }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Options Listen Key Deleted\n\nThe listen key has been invalidated and the user data stream will be closed.\n\nResponse: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to delete options listen key: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/options/userdata-api/index.ts b/src/modules/options/userdata-api/index.ts index 334a3494..66faf721 100644 --- a/src/modules/options/userdata-api/index.ts +++ b/src/modules/options/userdata-api/index.ts @@ -5,13 +5,14 @@ * @license Apache-2.0 */ // src/modules/options/userdata-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerOptionsCreateListenKey } from "./createListenKey.js"; -import { registerOptionsRenewListenKey } from "./renewListenKey.js"; -import { registerOptionsDeleteListenKey } from "./deleteListenKey.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerOptionsCreateListenKey } from "./createListenKey.js" +import { registerOptionsDeleteListenKey } from "./deleteListenKey.js" +import { registerOptionsRenewListenKey } from "./renewListenKey.js" export function registerOptionsUserdataApi(server: McpServer) { - registerOptionsCreateListenKey(server); - registerOptionsRenewListenKey(server); - registerOptionsDeleteListenKey(server); + registerOptionsCreateListenKey(server) + registerOptionsRenewListenKey(server) + registerOptionsDeleteListenKey(server) } diff --git a/src/modules/options/userdata-api/renewListenKey.ts b/src/modules/options/userdata-api/renewListenKey.ts index 350e81e0..da60776d 100644 --- a/src/modules/options/userdata-api/renewListenKey.ts +++ b/src/modules/options/userdata-api/renewListenKey.ts @@ -5,40 +5,50 @@ * @license Apache-2.0 */ // src/modules/options/userdata-api/renewListenKey.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../../config/binanceClient.js" export function registerOptionsRenewListenKey(server: McpServer) { - server.tool( - "BinanceOptionsRenewListenKey", - "Extend the validity of an options listen key by 60 minutes. Should be called periodically to keep the user data stream active.", - { - listenKey: z.string().optional().describe("Listen key to renew. If not provided, renews the current active key") - }, - async (params) => { - try { - const response = await optionsClient.restAPI.renewListenKey({ - ...(params.listenKey && { listenKey: params.listenKey }) - }); - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Options Listen Key Renewed\n\nThe listen key validity has been extended by 60 minutes.\n\nResponse: ${JSON.stringify(data)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to renew options listen key: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceOptionsRenewListenKey", + "Extend the validity of an options listen key by 60 minutes. Should be called periodically to keep the user data stream active.", + { + listenKey: z + .string() + .optional() + .describe("Listen key to renew. If not provided, renews the current active key"), + }, + async (params) => { + try { + const response = await optionsClient.restAPI.renewListenKey({ + ...(params.listenKey && { listenKey: params.listenKey }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Options Listen Key Renewed\n\nThe listen key validity has been extended by 60 minutes.\n\nResponse: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to renew options listen key: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/pay/index.ts b/src/modules/pay/index.ts index e5640021..e6dbf79d 100644 --- a/src/modules/pay/index.ts +++ b/src/modules/pay/index.ts @@ -1,10 +1,11 @@ // src/tools/binance-pay/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetPayTradeHistory } from "./pay-api/getPayTradeHistory.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceGetPayTradeHistory } from "./pay-api/getPayTradeHistory.js" export function registerBinancePayTools(server: McpServer) { - registerBinanceGetPayTradeHistory(server); + registerBinanceGetPayTradeHistory(server) } // Alias for binance.ts compatibility -export { registerBinancePayTools as registerPay }; +export { registerBinancePayTools as registerPay } diff --git a/src/modules/pay/pay-api/createOrder.ts b/src/modules/pay/pay-api/createOrder.ts index bb120a39..0d21f44a 100644 --- a/src/modules/pay/pay-api/createOrder.ts +++ b/src/modules/pay/pay-api/createOrder.ts @@ -5,55 +5,62 @@ * @license Apache-2.0 */ // src/modules/pay/pay-api/createOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { payClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { payClient } from "../../../config/binanceClient.js" export function registerBinancePayCreateOrder(server: McpServer) { - server.tool( - "BinancePayCreateOrder", - "Create a Binance Pay order for receiving crypto payments. Generate payment links for e-commerce or P2P transactions. 💳", - { - merchantId: z.string().optional().describe("Merchant ID (for business accounts)"), - orderId: z.string().describe("Unique order ID for your reference"), - currency: z.string().describe("Payment currency (e.g., 'USDT', 'BTC')"), - totalAmount: z.string().describe("Total payment amount"), - description: z.string().optional().describe("Order description"), - goodsName: z.string().optional().describe("Name of goods/service"), - goodsDetail: z.string().optional().describe("Details of goods/service"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await payClient.restAPI.createOrder({ - orderId: params.orderId, - currency: params.currency, - totalAmount: params.totalAmount, - ...(params.merchantId && { merchantId: params.merchantId }), - ...(params.description && { description: params.description }), - ...(params.goodsName && { goodsName: params.goodsName }), - ...(params.goodsDetail && { goodsDetail: params.goodsDetail }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinancePayCreateOrder", + "Create a Binance Pay order for receiving crypto payments. Generate payment links for e-commerce or P2P transactions. 💳", + { + merchantId: z.string().optional().describe("Merchant ID (for business accounts)"), + orderId: z.string().describe("Unique order ID for your reference"), + currency: z.string().describe("Payment currency (e.g., 'USDT', 'BTC')"), + totalAmount: z.string().describe("Total payment amount"), + description: z.string().optional().describe("Order description"), + goodsName: z.string().optional().describe("Name of goods/service"), + goodsDetail: z.string().optional().describe("Details of goods/service"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await payClient.restAPI.createOrder({ + orderId: params.orderId, + currency: params.currency, + totalAmount: params.totalAmount, + ...(params.merchantId && { merchantId: params.merchantId }), + ...(params.description && { description: params.description }), + ...(params.goodsName && { goodsName: params.goodsName }), + ...(params.goodsDetail && { goodsDetail: params.goodsDetail }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Binance Pay Order Created!\n\nOrder ID: ${params.orderId}\nCurrency: ${params.currency}\nAmount: ${params.totalAmount}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `✅ Binance Pay Order Created!\n\nOrder ID: ${params.orderId}\nCurrency: ${params.currency}\nAmount: ${params.totalAmount}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to create pay order: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to create pay order: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/pay/pay-api/getHistory.ts b/src/modules/pay/pay-api/getHistory.ts index 80435eb6..3cbc01df 100644 --- a/src/modules/pay/pay-api/getHistory.ts +++ b/src/modules/pay/pay-api/getHistory.ts @@ -5,47 +5,60 @@ * @license Apache-2.0 */ // src/modules/pay/pay-api/getHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { payClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { payClient } from "../../../config/binanceClient.js" export function registerBinancePayGetHistory(server: McpServer) { - server.tool( - "BinancePayGetHistory", - "Get your Binance Pay transaction history. Shows all Pay transactions including C2C transfers, merchant payments, and refunds.", - { - startTime: z.number().int().optional().describe("Start time in ms"), - endTime: z.number().int().optional().describe("End time in ms"), - limit: z.number().int().max(100).default(100).optional().describe("Number of records (max 100)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await payClient.restAPI.getPayTradeHistory({ - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinancePayGetHistory", + "Get your Binance Pay transaction history. Shows all Pay transactions including C2C transfers, merchant payments, and refunds.", + { + startTime: z.number().int().optional().describe("Start time in ms"), + endTime: z.number().int().optional().describe("End time in ms"), + limit: z + .number() + .int() + .max(100) + .default(100) + .optional() + .describe("Number of records (max 100)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await payClient.restAPI.getPayTradeHistory({ + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📜 Binance Pay Transaction History\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `📜 Binance Pay Transaction History\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get pay history: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to get pay history: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/pay/pay-api/getPayTradeHistory.ts b/src/modules/pay/pay-api/getPayTradeHistory.ts index d37b514c..e55a6c73 100644 --- a/src/modules/pay/pay-api/getPayTradeHistory.ts +++ b/src/modules/pay/pay-api/getPayTradeHistory.ts @@ -1,54 +1,57 @@ // src/tools/binance-pay/pay-api/getPayTradeHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { payClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { payClient } from "../../../config/binanceClient.js" export function registerBinanceGetPayTradeHistory(server: McpServer) { - server.tool( - "BinanceGetPayTradeHistory", - "Retrieve Binance Pay trade history using GET to fetch transaction records such as C2C transfers, merchant payments, crypto box activity, refunds, payouts, and remittance details.", - { - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .max(100, "Limit cannot be greater than 100") - .default(100) - .describe("Number of records to return, default 100, max 100"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await payClient.restAPI.getPayTradeHistory({ - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetPayTradeHistory", + "Retrieve Binance Pay trade history using GET to fetch transaction records such as C2C transfers, merchant payments, crypto box activity, refunds, payouts, and remittance details.", + { + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(100, "Limit cannot be greater than 100") + .default(100) + .describe("Number of records to return, default 100, max 100"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await payClient.restAPI.getPayTradeHistory({ + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved Binance Pay trade history. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved Binance Pay trade history. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve Binance Pay trade history: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve Binance Pay trade history: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/pay/pay-api/queryOrder.ts b/src/modules/pay/pay-api/queryOrder.ts index 22a7b508..bb67e9a5 100644 --- a/src/modules/pay/pay-api/queryOrder.ts +++ b/src/modules/pay/pay-api/queryOrder.ts @@ -5,47 +5,54 @@ * @license Apache-2.0 */ // src/modules/pay/pay-api/queryOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { payClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { payClient } from "../../../config/binanceClient.js" export function registerBinancePayQueryOrder(server: McpServer) { - server.tool( - "BinancePayQueryOrder", - "Query the status of a Binance Pay order. Check if payment has been received.", - { - merchantId: z.string().optional().describe("Merchant ID"), - prepayId: z.string().optional().describe("Prepay ID from order creation"), - merchantTradeNo: z.string().optional().describe("Your merchant trade number"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await payClient.restAPI.queryOrder({ - ...(params.merchantId && { merchantId: params.merchantId }), - ...(params.prepayId && { prepayId: params.prepayId }), - ...(params.merchantTradeNo && { merchantTradeNo: params.merchantTradeNo }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinancePayQueryOrder", + "Query the status of a Binance Pay order. Check if payment has been received.", + { + merchantId: z.string().optional().describe("Merchant ID"), + prepayId: z.string().optional().describe("Prepay ID from order creation"), + merchantTradeNo: z.string().optional().describe("Your merchant trade number"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await payClient.restAPI.queryOrder({ + ...(params.merchantId && { merchantId: params.merchantId }), + ...(params.prepayId && { prepayId: params.prepayId }), + ...(params.merchantTradeNo && { merchantTradeNo: params.merchantTradeNo }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📋 Binance Pay Order Status\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `📋 Binance Pay Order Status\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to query pay order: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to query pay order: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/account/getAccountInfo.ts b/src/modules/portfolio-margin/account/getAccountInfo.ts index 9a0f8f5b..a6232191 100644 --- a/src/modules/portfolio-margin/account/getAccountInfo.ts +++ b/src/modules/portfolio-margin/account/getAccountInfo.ts @@ -5,56 +5,63 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/account/getAccountInfo.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginGetAccountInfo(server: McpServer) { - server.tool( - "BinancePortfolioMarginGetAccount", - "Get Portfolio Margin account information including unified account equity, margin status, and risk levels.", - { - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.account({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Portfolio Margin Account Information\n\n`; - - if (data) { - result += `**Account Status**\n`; - result += `UniMMR: ${data.uniMMR}\n`; - result += `Account Equity: ${data.accountEquity}\n`; - result += `Actual Equity: ${data.actualEquity}\n`; - result += `Account Maint. Margin: ${data.accountMaintMargin}\n`; - result += `Account Status: ${data.accountStatus}\n\n`; - - if (data.accountType) { - result += `Account Type: ${data.accountType}\n`; - } - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get Portfolio Margin account: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginGetAccount", + "Get Portfolio Margin account information including unified account equity, margin status, and risk levels.", + { + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.account({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Portfolio Margin Account Information\n\n` + + if (data) { + result += `**Account Status**\n` + result += `UniMMR: ${data.uniMMR}\n` + result += `Account Equity: ${data.accountEquity}\n` + result += `Actual Equity: ${data.actualEquity}\n` + result += `Account Maint. Margin: ${data.accountMaintMargin}\n` + result += `Account Status: ${data.accountStatus}\n\n` + + if (data.accountType) { + result += `Account Type: ${data.accountType}\n` + } + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get Portfolio Margin account: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/account/getBalance.ts b/src/modules/portfolio-margin/account/getBalance.ts index 8a0d771f..0f9597af 100644 --- a/src/modules/portfolio-margin/account/getBalance.ts +++ b/src/modules/portfolio-margin/account/getBalance.ts @@ -5,60 +5,70 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/account/getBalance.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginGetBalance(server: McpServer) { - server.tool( - "BinancePortfolioMarginGetBalance", - "Get Portfolio Margin account balance information for all assets.", - { - asset: z.string().optional().describe("Asset to query (e.g., 'USDT'). If not provided, returns all assets"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.balance({ - ...(params.asset && { asset: params.asset }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Portfolio Margin Balance\n\n`; - - if (Array.isArray(data) && data.length > 0) { - result += `| Asset | Total | Available | In Order | Borrowed |\n`; - result += `|-------|-------|-----------|----------|----------|\n`; - data.forEach((balance: any) => { - result += `| ${balance.asset} | ${balance.totalWalletBalance || balance.balance} | ${balance.availableBalance || 'N/A'} | ${balance.crossWalletBalance || 'N/A'} | ${balance.borrowed || '0'} |\n`; - }); - } else if (data && !Array.isArray(data)) { - result += `**${data.asset}**\n`; - result += `Total Balance: ${data.totalWalletBalance || data.balance}\n`; - result += `Available: ${data.availableBalance || 'N/A'}\n`; - result += `Borrowed: ${data.borrowed || '0'}\n`; - } else { - result += `No balance information found`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get Portfolio Margin balance: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginGetBalance", + "Get Portfolio Margin account balance information for all assets.", + { + asset: z + .string() + .optional() + .describe("Asset to query (e.g., 'USDT'). If not provided, returns all assets"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.balance({ + ...(params.asset && { asset: params.asset }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Portfolio Margin Balance\n\n` + + if (Array.isArray(data) && data.length > 0) { + result += `| Asset | Total | Available | In Order | Borrowed |\n` + result += `|-------|-------|-----------|----------|----------|\n` + data.forEach((balance: any) => { + result += `| ${balance.asset} | ${balance.totalWalletBalance || balance.balance} | ${balance.availableBalance || "N/A"} | ${balance.crossWalletBalance || "N/A"} | ${balance.borrowed || "0"} |\n` + }) + } else if (data && !Array.isArray(data)) { + result += `**${data.asset}**\n` + result += `Total Balance: ${data.totalWalletBalance || data.balance}\n` + result += `Available: ${data.availableBalance || "N/A"}\n` + result += `Borrowed: ${data.borrowed || "0"}\n` + } else { + result += `No balance information found` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get Portfolio Margin balance: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/account/getCmAccount.ts b/src/modules/portfolio-margin/account/getCmAccount.ts index bbff79a5..5ab2f909 100644 --- a/src/modules/portfolio-margin/account/getCmAccount.ts +++ b/src/modules/portfolio-margin/account/getCmAccount.ts @@ -5,65 +5,74 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/account/getCmAccount.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginGetCmAccount(server: McpServer) { - server.tool( - "BinancePortfolioMarginGetCmAccount", - "Get COIN-M Futures account information within Portfolio Margin mode.", - { - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.cmAccount({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Portfolio Margin CM (COIN-M) Account\n\n`; - - if (data) { - result += `**Account Overview**\n`; - if (data.assets && data.assets.length > 0) { - result += `\n**Assets**\n`; - data.assets.forEach((asset: any) => { - result += `**${asset.asset}**\n`; - result += ` Wallet Balance: ${asset.walletBalance}\n`; - result += ` Unrealized Profit: ${asset.unrealizedProfit}\n`; - result += ` Margin Balance: ${asset.marginBalance}\n`; - result += ` Maint Margin: ${asset.maintMargin}\n`; - result += ` Available Balance: ${asset.availableBalance}\n\n`; - }); - } - - if (data.positions && data.positions.length > 0) { - result += `\n**Positions**\n`; - data.positions.filter((p: any) => parseFloat(p.positionAmt) !== 0).forEach((pos: any) => { - result += `- ${pos.symbol}: ${pos.positionAmt} @ ${pos.entryPrice}\n`; - }); - } - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get Portfolio Margin CM account: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginGetCmAccount", + "Get COIN-M Futures account information within Portfolio Margin mode.", + { + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.cmAccount({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Portfolio Margin CM (COIN-M) Account\n\n` + + if (data) { + result += `**Account Overview**\n` + if (data.assets && data.assets.length > 0) { + result += `\n**Assets**\n` + data.assets.forEach((asset: any) => { + result += `**${asset.asset}**\n` + result += ` Wallet Balance: ${asset.walletBalance}\n` + result += ` Unrealized Profit: ${asset.unrealizedProfit}\n` + result += ` Margin Balance: ${asset.marginBalance}\n` + result += ` Maint Margin: ${asset.maintMargin}\n` + result += ` Available Balance: ${asset.availableBalance}\n\n` + }) + } + + if (data.positions && data.positions.length > 0) { + result += `\n**Positions**\n` + data.positions + .filter((p: any) => parseFloat(p.positionAmt) !== 0) + .forEach((pos: any) => { + result += `- ${pos.symbol}: ${pos.positionAmt} @ ${pos.entryPrice}\n` + }) + } + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get Portfolio Margin CM account: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/account/getCmPosition.ts b/src/modules/portfolio-margin/account/getCmPosition.ts index ef765a9d..df89717d 100644 --- a/src/modules/portfolio-margin/account/getCmPosition.ts +++ b/src/modules/portfolio-margin/account/getCmPosition.ts @@ -5,69 +5,76 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/account/getCmPosition.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginGetCmPosition(server: McpServer) { - server.tool( - "BinancePortfolioMarginGetCmPosition", - "Get COIN-M Futures position risk information within Portfolio Margin mode.", - { - marginAsset: z.string().optional().describe("Margin asset (e.g., 'BTC')"), - pair: z.string().optional().describe("Trading pair (e.g., 'BTCUSD')"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.cmPositionRisk({ - ...(params.marginAsset && { marginAsset: params.marginAsset }), - ...(params.pair && { pair: params.pair }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Portfolio Margin CM Position Risk\n\n`; - - if (Array.isArray(data) && data.length > 0) { - const activePositions = data.filter((p: any) => parseFloat(p.positionAmt) !== 0); - - if (activePositions.length > 0) { - result += `Active Positions: ${activePositions.length}\n\n`; - activePositions.forEach((pos: any) => { - result += `**${pos.symbol}**\n`; - result += ` Position: ${pos.positionAmt} contracts\n`; - result += ` Entry Price: ${pos.entryPrice}\n`; - result += ` Mark Price: ${pos.markPrice}\n`; - result += ` Unrealized PnL: ${pos.unrealizedProfit}\n`; - result += ` Liquidation Price: ${pos.liquidationPrice}\n`; - result += ` Leverage: ${pos.leverage}x\n`; - result += ` Margin Type: ${pos.marginType}\n\n`; - }); - } else { - result += `No active CM positions`; - } - } else { - result += `No position data found`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get Portfolio Margin CM positions: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginGetCmPosition", + "Get COIN-M Futures position risk information within Portfolio Margin mode.", + { + marginAsset: z.string().optional().describe("Margin asset (e.g., 'BTC')"), + pair: z.string().optional().describe("Trading pair (e.g., 'BTCUSD')"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.cmPositionRisk({ + ...(params.marginAsset && { marginAsset: params.marginAsset }), + ...(params.pair && { pair: params.pair }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Portfolio Margin CM Position Risk\n\n` + + if (Array.isArray(data) && data.length > 0) { + const activePositions = data.filter((p: any) => parseFloat(p.positionAmt) !== 0) + + if (activePositions.length > 0) { + result += `Active Positions: ${activePositions.length}\n\n` + activePositions.forEach((pos: any) => { + result += `**${pos.symbol}**\n` + result += ` Position: ${pos.positionAmt} contracts\n` + result += ` Entry Price: ${pos.entryPrice}\n` + result += ` Mark Price: ${pos.markPrice}\n` + result += ` Unrealized PnL: ${pos.unrealizedProfit}\n` + result += ` Liquidation Price: ${pos.liquidationPrice}\n` + result += ` Leverage: ${pos.leverage}x\n` + result += ` Margin Type: ${pos.marginType}\n\n` + }) + } else { + result += `No active CM positions` + } + } else { + result += `No position data found` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get Portfolio Margin CM positions: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/account/getMarginAccount.ts b/src/modules/portfolio-margin/account/getMarginAccount.ts index 72608034..c188af03 100644 --- a/src/modules/portfolio-margin/account/getMarginAccount.ts +++ b/src/modules/portfolio-margin/account/getMarginAccount.ts @@ -5,70 +5,78 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/account/getMarginAccount.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginGetMarginAccount(server: McpServer) { - server.tool( - "BinancePortfolioMarginGetMarginAccount", - "Get cross margin account information within Portfolio Margin mode.", - { - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.marginAccount({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Portfolio Margin - Cross Margin Account\n\n`; - - if (data) { - result += `**Account Overview**\n`; - result += `Borrow Enabled: ${data.borrowEnabled}\n`; - result += `Trade Enabled: ${data.tradeEnabled}\n`; - result += `Transfer Enabled: ${data.transferEnabled}\n`; - result += `Margin Level: ${data.marginLevel}\n`; - result += `Total Asset (BTC): ${data.totalAssetOfBtc}\n`; - result += `Total Liability (BTC): ${data.totalLiabilityOfBtc}\n`; - result += `Total Net Asset (BTC): ${data.totalNetAssetOfBtc}\n\n`; - - if (data.userAssets && data.userAssets.length > 0) { - result += `**Assets with Balance**\n`; - const assetsWithBalance = data.userAssets.filter((a: any) => - parseFloat(a.free) > 0 || parseFloat(a.locked) > 0 || parseFloat(a.borrowed) > 0 - ); - assetsWithBalance.slice(0, 15).forEach((asset: any) => { - result += `**${asset.asset}**\n`; - result += ` Free: ${asset.free} | Locked: ${asset.locked}\n`; - result += ` Borrowed: ${asset.borrowed} | Interest: ${asset.interest}\n`; - result += ` Net Asset: ${asset.netAsset}\n\n`; - }); - if (assetsWithBalance.length > 15) { - result += `... and ${assetsWithBalance.length - 15} more assets`; - } - } - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get Portfolio Margin margin account: ${errorMessage}` - }], - isError: true - }; + server.tool( + "BinancePortfolioMarginGetMarginAccount", + "Get cross margin account information within Portfolio Margin mode.", + { + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.marginAccount({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Portfolio Margin - Cross Margin Account\n\n` + + if (data) { + result += `**Account Overview**\n` + result += `Borrow Enabled: ${data.borrowEnabled}\n` + result += `Trade Enabled: ${data.tradeEnabled}\n` + result += `Transfer Enabled: ${data.transferEnabled}\n` + result += `Margin Level: ${data.marginLevel}\n` + result += `Total Asset (BTC): ${data.totalAssetOfBtc}\n` + result += `Total Liability (BTC): ${data.totalLiabilityOfBtc}\n` + result += `Total Net Asset (BTC): ${data.totalNetAssetOfBtc}\n\n` + + if (data.userAssets && data.userAssets.length > 0) { + result += `**Assets with Balance**\n` + const assetsWithBalance = data.userAssets.filter( + (a: any) => + parseFloat(a.free) > 0 || parseFloat(a.locked) > 0 || parseFloat(a.borrowed) > 0, + ) + assetsWithBalance.slice(0, 15).forEach((asset: any) => { + result += `**${asset.asset}**\n` + result += ` Free: ${asset.free} | Locked: ${asset.locked}\n` + result += ` Borrowed: ${asset.borrowed} | Interest: ${asset.interest}\n` + result += ` Net Asset: ${asset.netAsset}\n\n` + }) + if (assetsWithBalance.length > 15) { + result += `... and ${assetsWithBalance.length - 15} more assets` } + } + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get Portfolio Margin margin account: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/account/getMaxBorrowable.ts b/src/modules/portfolio-margin/account/getMaxBorrowable.ts index 2bb58887..ecd5b9dc 100644 --- a/src/modules/portfolio-margin/account/getMaxBorrowable.ts +++ b/src/modules/portfolio-margin/account/getMaxBorrowable.ts @@ -5,43 +5,50 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/account/getMaxBorrowable.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginGetMaxBorrowable(server: McpServer) { - server.tool( - "BinancePortfolioMarginGetMaxBorrowable", - "Query the maximum amount that can be borrowed for a specific asset in Portfolio Margin mode.", - { - asset: z.string().describe("Asset to query (e.g., 'USDT')"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.marginMaxBorrowable({ - asset: params.asset, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Portfolio Margin Max Borrowable\n\nAsset: ${params.asset}\nMax Borrowable Amount: ${data.amount}\nBorrowed: ${data.borrowedAmount || '0'}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get max borrowable: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginGetMaxBorrowable", + "Query the maximum amount that can be borrowed for a specific asset in Portfolio Margin mode.", + { + asset: z.string().describe("Asset to query (e.g., 'USDT')"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.marginMaxBorrowable({ + asset: params.asset, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Portfolio Margin Max Borrowable\n\nAsset: ${params.asset}\nMax Borrowable Amount: ${data.amount}\nBorrowed: ${data.borrowedAmount || "0"}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get max borrowable: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/account/getMaxWithdraw.ts b/src/modules/portfolio-margin/account/getMaxWithdraw.ts index 858b05e5..1661572f 100644 --- a/src/modules/portfolio-margin/account/getMaxWithdraw.ts +++ b/src/modules/portfolio-margin/account/getMaxWithdraw.ts @@ -5,43 +5,50 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/account/getMaxWithdraw.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginGetMaxWithdraw(server: McpServer) { - server.tool( - "BinancePortfolioMarginGetMaxWithdraw", - "Query the maximum amount that can be withdrawn for a specific asset from Portfolio Margin account.", - { - asset: z.string().describe("Asset to query (e.g., 'USDT')"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.marginMaxWithdraw({ - asset: params.asset, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Portfolio Margin Max Withdraw\n\nAsset: ${params.asset}\nMax Withdraw Amount: ${data.amount}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get max withdraw: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginGetMaxWithdraw", + "Query the maximum amount that can be withdrawn for a specific asset from Portfolio Margin account.", + { + asset: z.string().describe("Asset to query (e.g., 'USDT')"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.marginMaxWithdraw({ + asset: params.asset, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Portfolio Margin Max Withdraw\n\nAsset: ${params.asset}\nMax Withdraw Amount: ${data.amount}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get max withdraw: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/account/getUmAccount.ts b/src/modules/portfolio-margin/account/getUmAccount.ts index 946160a3..7b990b53 100644 --- a/src/modules/portfolio-margin/account/getUmAccount.ts +++ b/src/modules/portfolio-margin/account/getUmAccount.ts @@ -5,62 +5,69 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/account/getUmAccount.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginGetUmAccount(server: McpServer) { - server.tool( - "BinancePortfolioMarginGetUmAccount", - "Get USDT-M Futures account information within Portfolio Margin mode.", - { - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.umAccount({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Portfolio Margin UM (USDT-M) Account\n\n`; - - if (data) { - result += `**Account Overview**\n`; - result += `Total Wallet Balance: ${data.totalWalletBalance}\n`; - result += `Total Unrealized Profit: ${data.totalUnrealizedProfit}\n`; - result += `Total Margin Balance: ${data.totalMarginBalance}\n`; - result += `Total Position Initial Margin: ${data.totalPositionInitialMargin}\n`; - result += `Total Open Order Initial Margin: ${data.totalOpenOrderInitialMargin}\n`; - result += `Total Cross Wallet Balance: ${data.totalCrossWalletBalance}\n`; - result += `Available Balance: ${data.availableBalance}\n`; - result += `Max Withdraw Amount: ${data.maxWithdrawAmount}\n\n`; - - if (data.assets && data.assets.length > 0) { - result += `**Assets**\n`; - data.assets.slice(0, 10).forEach((asset: any) => { - result += `- ${asset.asset}: Balance ${asset.walletBalance}, Available ${asset.availableBalance}\n`; - }); - } - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get Portfolio Margin UM account: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginGetUmAccount", + "Get USDT-M Futures account information within Portfolio Margin mode.", + { + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.umAccount({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Portfolio Margin UM (USDT-M) Account\n\n` + + if (data) { + result += `**Account Overview**\n` + result += `Total Wallet Balance: ${data.totalWalletBalance}\n` + result += `Total Unrealized Profit: ${data.totalUnrealizedProfit}\n` + result += `Total Margin Balance: ${data.totalMarginBalance}\n` + result += `Total Position Initial Margin: ${data.totalPositionInitialMargin}\n` + result += `Total Open Order Initial Margin: ${data.totalOpenOrderInitialMargin}\n` + result += `Total Cross Wallet Balance: ${data.totalCrossWalletBalance}\n` + result += `Available Balance: ${data.availableBalance}\n` + result += `Max Withdraw Amount: ${data.maxWithdrawAmount}\n\n` + + if (data.assets && data.assets.length > 0) { + result += `**Assets**\n` + data.assets.slice(0, 10).forEach((asset: any) => { + result += `- ${asset.asset}: Balance ${asset.walletBalance}, Available ${asset.availableBalance}\n` + }) + } + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get Portfolio Margin UM account: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/account/getUmPosition.ts b/src/modules/portfolio-margin/account/getUmPosition.ts index 75d57e7a..fcd67cc2 100644 --- a/src/modules/portfolio-margin/account/getUmPosition.ts +++ b/src/modules/portfolio-margin/account/getUmPosition.ts @@ -5,67 +5,74 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/account/getUmPosition.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginGetUmPosition(server: McpServer) { - server.tool( - "BinancePortfolioMarginGetUmPosition", - "Get USDT-M Futures position risk information within Portfolio Margin mode.", - { - symbol: z.string().optional().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.umPositionRisk({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Portfolio Margin UM Position Risk\n\n`; - - if (Array.isArray(data) && data.length > 0) { - const activePositions = data.filter((p: any) => parseFloat(p.positionAmt) !== 0); - - if (activePositions.length > 0) { - result += `Active Positions: ${activePositions.length}\n\n`; - activePositions.forEach((pos: any) => { - result += `**${pos.symbol}**\n`; - result += ` Position: ${pos.positionAmt}\n`; - result += ` Entry Price: ${pos.entryPrice}\n`; - result += ` Mark Price: ${pos.markPrice}\n`; - result += ` Unrealized PnL: ${pos.unrealizedProfit}\n`; - result += ` Liquidation Price: ${pos.liquidationPrice}\n`; - result += ` Leverage: ${pos.leverage}x\n`; - result += ` Margin Type: ${pos.marginType}\n\n`; - }); - } else { - result += `No active UM positions`; - } - } else { - result += `No position data found`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get Portfolio Margin UM positions: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginGetUmPosition", + "Get USDT-M Futures position risk information within Portfolio Margin mode.", + { + symbol: z.string().optional().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.umPositionRisk({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Portfolio Margin UM Position Risk\n\n` + + if (Array.isArray(data) && data.length > 0) { + const activePositions = data.filter((p: any) => parseFloat(p.positionAmt) !== 0) + + if (activePositions.length > 0) { + result += `Active Positions: ${activePositions.length}\n\n` + activePositions.forEach((pos: any) => { + result += `**${pos.symbol}**\n` + result += ` Position: ${pos.positionAmt}\n` + result += ` Entry Price: ${pos.entryPrice}\n` + result += ` Mark Price: ${pos.markPrice}\n` + result += ` Unrealized PnL: ${pos.unrealizedProfit}\n` + result += ` Liquidation Price: ${pos.liquidationPrice}\n` + result += ` Leverage: ${pos.leverage}x\n` + result += ` Margin Type: ${pos.marginType}\n\n` + }) + } else { + result += `No active UM positions` + } + } else { + result += `No position data found` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get Portfolio Margin UM positions: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/account/index.ts b/src/modules/portfolio-margin/account/index.ts index c2d89b87..d7bee058 100644 --- a/src/modules/portfolio-margin/account/index.ts +++ b/src/modules/portfolio-margin/account/index.ts @@ -5,25 +5,26 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/account/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerPortfolioMarginGetAccountInfo } from "./getAccountInfo.js"; -import { registerPortfolioMarginGetBalance } from "./getBalance.js"; -import { registerPortfolioMarginGetMaxBorrowable } from "./getMaxBorrowable.js"; -import { registerPortfolioMarginGetMaxWithdraw } from "./getMaxWithdraw.js"; -import { registerPortfolioMarginGetUmAccount } from "./getUmAccount.js"; -import { registerPortfolioMarginGetCmAccount } from "./getCmAccount.js"; -import { registerPortfolioMarginGetUmPosition } from "./getUmPosition.js"; -import { registerPortfolioMarginGetCmPosition } from "./getCmPosition.js"; -import { registerPortfolioMarginGetMarginAccount } from "./getMarginAccount.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerPortfolioMarginGetAccountInfo } from "./getAccountInfo.js" +import { registerPortfolioMarginGetBalance } from "./getBalance.js" +import { registerPortfolioMarginGetCmAccount } from "./getCmAccount.js" +import { registerPortfolioMarginGetCmPosition } from "./getCmPosition.js" +import { registerPortfolioMarginGetMarginAccount } from "./getMarginAccount.js" +import { registerPortfolioMarginGetMaxBorrowable } from "./getMaxBorrowable.js" +import { registerPortfolioMarginGetMaxWithdraw } from "./getMaxWithdraw.js" +import { registerPortfolioMarginGetUmAccount } from "./getUmAccount.js" +import { registerPortfolioMarginGetUmPosition } from "./getUmPosition.js" export function registerPortfolioMarginAccountApi(server: McpServer) { - registerPortfolioMarginGetAccountInfo(server); - registerPortfolioMarginGetBalance(server); - registerPortfolioMarginGetMaxBorrowable(server); - registerPortfolioMarginGetMaxWithdraw(server); - registerPortfolioMarginGetUmAccount(server); - registerPortfolioMarginGetCmAccount(server); - registerPortfolioMarginGetUmPosition(server); - registerPortfolioMarginGetCmPosition(server); - registerPortfolioMarginGetMarginAccount(server); + registerPortfolioMarginGetAccountInfo(server) + registerPortfolioMarginGetBalance(server) + registerPortfolioMarginGetMaxBorrowable(server) + registerPortfolioMarginGetMaxWithdraw(server) + registerPortfolioMarginGetUmAccount(server) + registerPortfolioMarginGetCmAccount(server) + registerPortfolioMarginGetUmPosition(server) + registerPortfolioMarginGetCmPosition(server) + registerPortfolioMarginGetMarginAccount(server) } diff --git a/src/modules/portfolio-margin/cm-trade/cancelAllOrders.ts b/src/modules/portfolio-margin/cm-trade/cancelAllOrders.ts index d4f6c727..7e298256 100644 --- a/src/modules/portfolio-margin/cm-trade/cancelAllOrders.ts +++ b/src/modules/portfolio-margin/cm-trade/cancelAllOrders.ts @@ -5,43 +5,50 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/cm-trade/cancelAllOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginCmCancelAllOrders(server: McpServer) { - server.tool( - "BinancePortfolioMarginCmCancelAllOrders", - "Cancel all open COIN-M Futures orders for a symbol in Portfolio Margin mode. ⚠️ This will cancel ALL open orders.", - { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.cmCancelAllOpenOrders({ - symbol: params.symbol, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ All Portfolio Margin CM orders cancelled for ${params.symbol}\n\nResponse: ${JSON.stringify(data)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to cancel all Portfolio Margin CM orders: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginCmCancelAllOrders", + "Cancel all open COIN-M Futures orders for a symbol in Portfolio Margin mode. ⚠️ This will cancel ALL open orders.", + { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.cmCancelAllOpenOrders({ + symbol: params.symbol, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ All Portfolio Margin CM orders cancelled for ${params.symbol}\n\nResponse: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to cancel all Portfolio Margin CM orders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/cm-trade/cancelOrder.ts b/src/modules/portfolio-margin/cm-trade/cancelOrder.ts index 8621e751..e2c4b659 100644 --- a/src/modules/portfolio-margin/cm-trade/cancelOrder.ts +++ b/src/modules/portfolio-margin/cm-trade/cancelOrder.ts @@ -5,57 +5,66 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/cm-trade/cancelOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginCmCancelOrder(server: McpServer) { - server.tool( - "BinancePortfolioMarginCmCancelOrder", - "Cancel an active COIN-M Futures order in Portfolio Margin mode.", - { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), - orderId: z.number().int().optional().describe("Order ID to cancel"), - origClientOrderId: z.string().optional().describe("Original client order ID to cancel"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - if (!params.orderId && !params.origClientOrderId) { - return { - content: [{ - type: "text", - text: `❌ Either orderId or origClientOrderId must be provided` - }], - isError: true - }; - } - - const response = await portfolioMarginClient.restAPI.cmCancelOrder({ - symbol: params.symbol, - ...(params.orderId && { orderId: params.orderId }), - ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Portfolio Margin CM Order Cancelled!\n\nOrder ID: ${data.orderId}\nSymbol: ${data.symbol}\nStatus: ${data.status}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to cancel Portfolio Margin CM order: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginCmCancelOrder", + "Cancel an active COIN-M Futures order in Portfolio Margin mode.", + { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), + orderId: z.number().int().optional().describe("Order ID to cancel"), + origClientOrderId: z.string().optional().describe("Original client order ID to cancel"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + if (!params.orderId && !params.origClientOrderId) { + return { + content: [ + { + type: "text", + text: `❌ Either orderId or origClientOrderId must be provided`, + }, + ], + isError: true, + } + } + + const response = await portfolioMarginClient.restAPI.cmCancelOrder({ + symbol: params.symbol, + ...(params.orderId && { orderId: params.orderId }), + ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Portfolio Margin CM Order Cancelled!\n\nOrder ID: ${data.orderId}\nSymbol: ${data.symbol}\nStatus: ${data.status}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to cancel Portfolio Margin CM order: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/cm-trade/changeLeverage.ts b/src/modules/portfolio-margin/cm-trade/changeLeverage.ts index e73e2332..1f510fc3 100644 --- a/src/modules/portfolio-margin/cm-trade/changeLeverage.ts +++ b/src/modules/portfolio-margin/cm-trade/changeLeverage.ts @@ -5,45 +5,52 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/cm-trade/changeLeverage.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginCmChangeLeverage(server: McpServer) { - server.tool( - "BinancePortfolioMarginCmChangeLeverage", - "Change leverage for a COIN-M Futures symbol in Portfolio Margin mode. ⚠️ Higher leverage increases risk.", - { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), - leverage: z.number().int().min(1).max(125).describe("Target leverage (1-125)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.cmLeverage({ - symbol: params.symbol, - leverage: params.leverage, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Portfolio Margin CM Leverage Changed!\n\nSymbol: ${data.symbol}\nNew Leverage: ${data.leverage}x\nMax Qty: ${data.maxQty}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to change Portfolio Margin CM leverage: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginCmChangeLeverage", + "Change leverage for a COIN-M Futures symbol in Portfolio Margin mode. ⚠️ Higher leverage increases risk.", + { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), + leverage: z.number().int().min(1).max(125).describe("Target leverage (1-125)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.cmLeverage({ + symbol: params.symbol, + leverage: params.leverage, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Portfolio Margin CM Leverage Changed!\n\nSymbol: ${data.symbol}\nNew Leverage: ${data.leverage}x\nMax Qty: ${data.maxQty}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to change Portfolio Margin CM leverage: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/cm-trade/changeMarginType.ts b/src/modules/portfolio-margin/cm-trade/changeMarginType.ts index 22c122c5..83f01239 100644 --- a/src/modules/portfolio-margin/cm-trade/changeMarginType.ts +++ b/src/modules/portfolio-margin/cm-trade/changeMarginType.ts @@ -5,45 +5,52 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/cm-trade/changeMarginType.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginCmChangeMarginType(server: McpServer) { - server.tool( - "BinancePortfolioMarginCmChangeMarginType", - "Change margin type (ISOLATED/CROSSED) for a COIN-M Futures symbol in Portfolio Margin mode.", - { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), - marginType: z.enum(["ISOLATED", "CROSSED"]).describe("Margin type"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.cmMarginType({ - symbol: params.symbol, - marginType: params.marginType, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Portfolio Margin CM Margin Type Changed!\n\nSymbol: ${params.symbol}\nNew Margin Type: ${params.marginType}\n\nResponse: ${JSON.stringify(data)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to change Portfolio Margin CM margin type: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginCmChangeMarginType", + "Change margin type (ISOLATED/CROSSED) for a COIN-M Futures symbol in Portfolio Margin mode.", + { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), + marginType: z.enum(["ISOLATED", "CROSSED"]).describe("Margin type"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.cmMarginType({ + symbol: params.symbol, + marginType: params.marginType, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Portfolio Margin CM Margin Type Changed!\n\nSymbol: ${params.symbol}\nNew Margin Type: ${params.marginType}\n\nResponse: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to change Portfolio Margin CM margin type: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/cm-trade/getAllOrders.ts b/src/modules/portfolio-margin/cm-trade/getAllOrders.ts index f99f911c..9152854b 100644 --- a/src/modules/portfolio-margin/cm-trade/getAllOrders.ts +++ b/src/modules/portfolio-margin/cm-trade/getAllOrders.ts @@ -5,71 +5,84 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/cm-trade/getAllOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginCmGetAllOrders(server: McpServer) { - server.tool( - "BinancePortfolioMarginCmGetAllOrders", - "Get all COIN-M Futures orders (active, cancelled, filled) in Portfolio Margin mode.", - { - symbol: z.string().optional().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), - pair: z.string().optional().describe("Trading pair (e.g., 'BTCUSD')"), - orderId: z.number().int().optional().describe("Order ID to start from"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z.number().int().min(1).max(1000).optional().describe("Number of orders to return (default 500, max 1000)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.cmAllOrders({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.pair && { pair: params.pair }), - ...(params.orderId && { orderId: params.orderId }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Portfolio Margin CM All Orders\n\n`; - - if (Array.isArray(data) && data.length > 0) { - result += `Total orders: ${data.length}\n\n`; - data.slice(0, 20).forEach((order: any, index: number) => { - result += `**${index + 1}. ${order.symbol}**\n`; - result += ` Order ID: ${order.orderId}\n`; - result += ` Side: ${order.side} | Type: ${order.type}\n`; - result += ` Price: ${order.price} | Qty: ${order.origQty}\n`; - result += ` Executed: ${order.executedQty} | Status: ${order.status}\n\n`; - }); - if (data.length > 20) { - result += `... and ${data.length - 20} more orders`; - } - } else { - result += `No orders found`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get Portfolio Margin CM orders: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginCmGetAllOrders", + "Get all COIN-M Futures orders (active, cancelled, filled) in Portfolio Margin mode.", + { + symbol: z.string().optional().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), + pair: z.string().optional().describe("Trading pair (e.g., 'BTCUSD')"), + orderId: z.number().int().optional().describe("Order ID to start from"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .describe("Number of orders to return (default 500, max 1000)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.cmAllOrders({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.pair && { pair: params.pair }), + ...(params.orderId && { orderId: params.orderId }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Portfolio Margin CM All Orders\n\n` + + if (Array.isArray(data) && data.length > 0) { + result += `Total orders: ${data.length}\n\n` + data.slice(0, 20).forEach((order: any, index: number) => { + result += `**${index + 1}. ${order.symbol}**\n` + result += ` Order ID: ${order.orderId}\n` + result += ` Side: ${order.side} | Type: ${order.type}\n` + result += ` Price: ${order.price} | Qty: ${order.origQty}\n` + result += ` Executed: ${order.executedQty} | Status: ${order.status}\n\n` + }) + if (data.length > 20) { + result += `... and ${data.length - 20} more orders` + } + } else { + result += `No orders found` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get Portfolio Margin CM orders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/cm-trade/getOpenOrders.ts b/src/modules/portfolio-margin/cm-trade/getOpenOrders.ts index ff119842..a4a35938 100644 --- a/src/modules/portfolio-margin/cm-trade/getOpenOrders.ts +++ b/src/modules/portfolio-margin/cm-trade/getOpenOrders.ts @@ -5,61 +5,68 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/cm-trade/getOpenOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginCmGetOpenOrders(server: McpServer) { - server.tool( - "BinancePortfolioMarginCmGetOpenOrders", - "Get all open COIN-M Futures orders in Portfolio Margin mode.", - { - symbol: z.string().optional().describe("Trading pair symbol to filter by"), - pair: z.string().optional().describe("Trading pair to filter by (e.g., 'BTCUSD')"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.cmOpenOrders({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.pair && { pair: params.pair }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Portfolio Margin CM Open Orders\n\n`; - - if (Array.isArray(data) && data.length > 0) { - result += `Total open orders: ${data.length}\n\n`; - data.forEach((order: any, index: number) => { - result += `**${index + 1}. ${order.symbol}**\n`; - result += ` Order ID: ${order.orderId}\n`; - result += ` Side: ${order.side} | Type: ${order.type}\n`; - result += ` Price: ${order.price} | Qty: ${order.origQty}\n`; - result += ` Executed: ${order.executedQty}\n`; - result += ` Status: ${order.status}\n\n`; - }); - } else { - result += `No open orders found`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get Portfolio Margin CM open orders: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginCmGetOpenOrders", + "Get all open COIN-M Futures orders in Portfolio Margin mode.", + { + symbol: z.string().optional().describe("Trading pair symbol to filter by"), + pair: z.string().optional().describe("Trading pair to filter by (e.g., 'BTCUSD')"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.cmOpenOrders({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.pair && { pair: params.pair }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Portfolio Margin CM Open Orders\n\n` + + if (Array.isArray(data) && data.length > 0) { + result += `Total open orders: ${data.length}\n\n` + data.forEach((order: any, index: number) => { + result += `**${index + 1}. ${order.symbol}**\n` + result += ` Order ID: ${order.orderId}\n` + result += ` Side: ${order.side} | Type: ${order.type}\n` + result += ` Price: ${order.price} | Qty: ${order.origQty}\n` + result += ` Executed: ${order.executedQty}\n` + result += ` Status: ${order.status}\n\n` + }) + } else { + result += `No open orders found` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get Portfolio Margin CM open orders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/cm-trade/getOrder.ts b/src/modules/portfolio-margin/cm-trade/getOrder.ts index 3b321c8e..2c8516de 100644 --- a/src/modules/portfolio-margin/cm-trade/getOrder.ts +++ b/src/modules/portfolio-margin/cm-trade/getOrder.ts @@ -5,67 +5,76 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/cm-trade/getOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginCmGetOrder(server: McpServer) { - server.tool( - "BinancePortfolioMarginCmGetOrder", - "Query a specific COIN-M Futures order in Portfolio Margin mode.", - { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), - orderId: z.number().int().optional().describe("Order ID to query"), - origClientOrderId: z.string().optional().describe("Original client order ID to query"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - if (!params.orderId && !params.origClientOrderId) { - return { - content: [{ - type: "text", - text: `❌ Either orderId or origClientOrderId must be provided` - }], - isError: true - }; - } - - const response = await portfolioMarginClient.restAPI.cmOrder({ - symbol: params.symbol, - ...(params.orderId && { orderId: params.orderId }), - ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Portfolio Margin CM Order Details\n\n`; - result += `Order ID: ${data.orderId}\n`; - result += `Symbol: ${data.symbol}\n`; - result += `Side: ${data.side} | Type: ${data.type}\n`; - result += `Price: ${data.price} | Qty: ${data.origQty}\n`; - result += `Executed Qty: ${data.executedQty}\n`; - result += `Avg Price: ${data.avgPrice}\n`; - result += `Status: ${data.status}\n`; - result += `Time: ${new Date(data.time).toISOString()}`; - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get Portfolio Margin CM order: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginCmGetOrder", + "Query a specific COIN-M Futures order in Portfolio Margin mode.", + { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), + orderId: z.number().int().optional().describe("Order ID to query"), + origClientOrderId: z.string().optional().describe("Original client order ID to query"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + if (!params.orderId && !params.origClientOrderId) { + return { + content: [ + { + type: "text", + text: `❌ Either orderId or origClientOrderId must be provided`, + }, + ], + isError: true, + } + } + + const response = await portfolioMarginClient.restAPI.cmOrder({ + symbol: params.symbol, + ...(params.orderId && { orderId: params.orderId }), + ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Portfolio Margin CM Order Details\n\n` + result += `Order ID: ${data.orderId}\n` + result += `Symbol: ${data.symbol}\n` + result += `Side: ${data.side} | Type: ${data.type}\n` + result += `Price: ${data.price} | Qty: ${data.origQty}\n` + result += `Executed Qty: ${data.executedQty}\n` + result += `Avg Price: ${data.avgPrice}\n` + result += `Status: ${data.status}\n` + result += `Time: ${new Date(data.time).toISOString()}` + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get Portfolio Margin CM order: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/cm-trade/getUserTrades.ts b/src/modules/portfolio-margin/cm-trade/getUserTrades.ts index c9b9b41c..19ce908f 100644 --- a/src/modules/portfolio-margin/cm-trade/getUserTrades.ts +++ b/src/modules/portfolio-margin/cm-trade/getUserTrades.ts @@ -5,74 +5,87 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/cm-trade/getUserTrades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginCmGetUserTrades(server: McpServer) { - server.tool( - "BinancePortfolioMarginCmGetUserTrades", - "Get COIN-M Futures trade history in Portfolio Margin mode.", - { - symbol: z.string().optional().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), - pair: z.string().optional().describe("Trading pair (e.g., 'BTCUSD')"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - fromId: z.number().int().optional().describe("Trade ID to start from"), - limit: z.number().int().min(1).max(1000).optional().describe("Number of trades to return (default 500, max 1000)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.cmUserTrades({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.pair && { pair: params.pair }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.fromId && { fromId: params.fromId }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Portfolio Margin CM Trade History\n\n`; - - if (Array.isArray(data) && data.length > 0) { - result += `Total trades: ${data.length}\n\n`; - data.slice(0, 20).forEach((trade: any, index: number) => { - result += `**${index + 1}. ${trade.symbol}**\n`; - result += ` Trade ID: ${trade.id}\n`; - result += ` Order ID: ${trade.orderId}\n`; - result += ` Side: ${trade.side} | Price: ${trade.price}\n`; - result += ` Qty: ${trade.qty} | Base Qty: ${trade.baseQty}\n`; - result += ` Realized PnL: ${trade.realizedPnl}\n`; - result += ` Commission: ${trade.commission} ${trade.commissionAsset}\n`; - result += ` Time: ${new Date(trade.time).toISOString()}\n\n`; - }); - if (data.length > 20) { - result += `... and ${data.length - 20} more trades`; - } - } else { - result += `No trades found`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get Portfolio Margin CM trades: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginCmGetUserTrades", + "Get COIN-M Futures trade history in Portfolio Margin mode.", + { + symbol: z.string().optional().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), + pair: z.string().optional().describe("Trading pair (e.g., 'BTCUSD')"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + fromId: z.number().int().optional().describe("Trade ID to start from"), + limit: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .describe("Number of trades to return (default 500, max 1000)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.cmUserTrades({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.pair && { pair: params.pair }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.fromId && { fromId: params.fromId }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Portfolio Margin CM Trade History\n\n` + + if (Array.isArray(data) && data.length > 0) { + result += `Total trades: ${data.length}\n\n` + data.slice(0, 20).forEach((trade: any, index: number) => { + result += `**${index + 1}. ${trade.symbol}**\n` + result += ` Trade ID: ${trade.id}\n` + result += ` Order ID: ${trade.orderId}\n` + result += ` Side: ${trade.side} | Price: ${trade.price}\n` + result += ` Qty: ${trade.qty} | Base Qty: ${trade.baseQty}\n` + result += ` Realized PnL: ${trade.realizedPnl}\n` + result += ` Commission: ${trade.commission} ${trade.commissionAsset}\n` + result += ` Time: ${new Date(trade.time).toISOString()}\n\n` + }) + if (data.length > 20) { + result += `... and ${data.length - 20} more trades` + } + } else { + result += `No trades found` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get Portfolio Margin CM trades: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/cm-trade/index.ts b/src/modules/portfolio-margin/cm-trade/index.ts index 690498ca..a9c74975 100644 --- a/src/modules/portfolio-margin/cm-trade/index.ts +++ b/src/modules/portfolio-margin/cm-trade/index.ts @@ -5,25 +5,26 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/cm-trade/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerPortfolioMarginCmNewOrder } from "./newOrder.js"; -import { registerPortfolioMarginCmCancelOrder } from "./cancelOrder.js"; -import { registerPortfolioMarginCmCancelAllOrders } from "./cancelAllOrders.js"; -import { registerPortfolioMarginCmGetOrder } from "./getOrder.js"; -import { registerPortfolioMarginCmGetAllOrders } from "./getAllOrders.js"; -import { registerPortfolioMarginCmGetOpenOrders } from "./getOpenOrders.js"; -import { registerPortfolioMarginCmGetUserTrades } from "./getUserTrades.js"; -import { registerPortfolioMarginCmChangeLeverage } from "./changeLeverage.js"; -import { registerPortfolioMarginCmChangeMarginType } from "./changeMarginType.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerPortfolioMarginCmCancelAllOrders } from "./cancelAllOrders.js" +import { registerPortfolioMarginCmCancelOrder } from "./cancelOrder.js" +import { registerPortfolioMarginCmChangeLeverage } from "./changeLeverage.js" +import { registerPortfolioMarginCmChangeMarginType } from "./changeMarginType.js" +import { registerPortfolioMarginCmGetAllOrders } from "./getAllOrders.js" +import { registerPortfolioMarginCmGetOpenOrders } from "./getOpenOrders.js" +import { registerPortfolioMarginCmGetOrder } from "./getOrder.js" +import { registerPortfolioMarginCmGetUserTrades } from "./getUserTrades.js" +import { registerPortfolioMarginCmNewOrder } from "./newOrder.js" export function registerPortfolioMarginCmTradeApi(server: McpServer) { - registerPortfolioMarginCmNewOrder(server); - registerPortfolioMarginCmCancelOrder(server); - registerPortfolioMarginCmCancelAllOrders(server); - registerPortfolioMarginCmGetOrder(server); - registerPortfolioMarginCmGetAllOrders(server); - registerPortfolioMarginCmGetOpenOrders(server); - registerPortfolioMarginCmGetUserTrades(server); - registerPortfolioMarginCmChangeLeverage(server); - registerPortfolioMarginCmChangeMarginType(server); + registerPortfolioMarginCmNewOrder(server) + registerPortfolioMarginCmCancelOrder(server) + registerPortfolioMarginCmCancelAllOrders(server) + registerPortfolioMarginCmGetOrder(server) + registerPortfolioMarginCmGetAllOrders(server) + registerPortfolioMarginCmGetOpenOrders(server) + registerPortfolioMarginCmGetUserTrades(server) + registerPortfolioMarginCmChangeLeverage(server) + registerPortfolioMarginCmChangeMarginType(server) } diff --git a/src/modules/portfolio-margin/cm-trade/newOrder.ts b/src/modules/portfolio-margin/cm-trade/newOrder.ts index 1474e9e4..ae006b3e 100644 --- a/src/modules/portfolio-margin/cm-trade/newOrder.ts +++ b/src/modules/portfolio-margin/cm-trade/newOrder.ts @@ -5,62 +5,81 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/cm-trade/newOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginCmNewOrder(server: McpServer) { - server.tool( - "BinancePortfolioMarginCmNewOrder", - "Place a new COIN-M Futures order in Portfolio Margin mode. ⚠️ HIGH RISK: Futures trading involves leverage.", - { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), - side: z.enum(["BUY", "SELL"]).describe("Order side"), - type: z.enum(["LIMIT", "MARKET", "STOP", "STOP_MARKET", "TAKE_PROFIT", "TAKE_PROFIT_MARKET", "TRAILING_STOP_MARKET"]) - .describe("Order type"), - quantity: z.string().optional().describe("Order quantity in contracts"), - price: z.string().optional().describe("Limit price (required for LIMIT orders)"), - stopPrice: z.string().optional().describe("Stop price (required for STOP orders)"), - timeInForce: z.enum(["GTC", "IOC", "FOK", "GTX"]).optional().describe("Time in force"), - reduceOnly: z.boolean().optional().describe("Reduce position only"), - newClientOrderId: z.string().optional().describe("Custom client order ID"), - positionSide: z.enum(["BOTH", "LONG", "SHORT"]).optional().describe("Position side for hedge mode"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.cmNewOrder({ - symbol: params.symbol, - side: params.side, - type: params.type, - ...(params.quantity && { quantity: params.quantity }), - ...(params.price && { price: params.price }), - ...(params.stopPrice && { stopPrice: params.stopPrice }), - ...(params.timeInForce && { timeInForce: params.timeInForce }), - ...(params.reduceOnly !== undefined && { reduceOnly: params.reduceOnly }), - ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), - ...(params.positionSide && { positionSide: params.positionSide }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Portfolio Margin CM Order Placed!\n\nOrder ID: ${data.orderId}\nSymbol: ${data.symbol}\nSide: ${data.side}\nType: ${data.type}\nQuantity: ${data.origQty}\nPrice: ${data.price || 'MARKET'}\nStatus: ${data.status}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to place Portfolio Margin CM order: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginCmNewOrder", + "Place a new COIN-M Futures order in Portfolio Margin mode. ⚠️ HIGH RISK: Futures trading involves leverage.", + { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), + side: z.enum(["BUY", "SELL"]).describe("Order side"), + type: z + .enum([ + "LIMIT", + "MARKET", + "STOP", + "STOP_MARKET", + "TAKE_PROFIT", + "TAKE_PROFIT_MARKET", + "TRAILING_STOP_MARKET", + ]) + .describe("Order type"), + quantity: z.string().optional().describe("Order quantity in contracts"), + price: z.string().optional().describe("Limit price (required for LIMIT orders)"), + stopPrice: z.string().optional().describe("Stop price (required for STOP orders)"), + timeInForce: z.enum(["GTC", "IOC", "FOK", "GTX"]).optional().describe("Time in force"), + reduceOnly: z.boolean().optional().describe("Reduce position only"), + newClientOrderId: z.string().optional().describe("Custom client order ID"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe("Position side for hedge mode"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.cmNewOrder({ + symbol: params.symbol, + side: params.side, + type: params.type, + ...(params.quantity && { quantity: params.quantity }), + ...(params.price && { price: params.price }), + ...(params.stopPrice && { stopPrice: params.stopPrice }), + ...(params.timeInForce && { timeInForce: params.timeInForce }), + ...(params.reduceOnly !== undefined && { reduceOnly: params.reduceOnly }), + ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), + ...(params.positionSide && { positionSide: params.positionSide }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Portfolio Margin CM Order Placed!\n\nOrder ID: ${data.orderId}\nSymbol: ${data.symbol}\nSide: ${data.side}\nType: ${data.type}\nQuantity: ${data.origQty}\nPrice: ${data.price || "MARKET"}\nStatus: ${data.status}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to place Portfolio Margin CM order: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/index.ts b/src/modules/portfolio-margin/index.ts index a808a195..0d11473e 100644 --- a/src/modules/portfolio-margin/index.ts +++ b/src/modules/portfolio-margin/index.ts @@ -1,7 +1,8 @@ // src/modules/portfolio-margin/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinancePortfolioMarginTools } from "../../tools/binance-portfolio-margin/index.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinancePortfolioMarginTools } from "../../tools/binance-portfolio-margin/index.js" export function registerPortfolioMargin(server: McpServer) { - registerBinancePortfolioMarginTools(server); + registerBinancePortfolioMarginTools(server) } diff --git a/src/modules/portfolio-margin/margin-trade/cancelAllOrders.ts b/src/modules/portfolio-margin/margin-trade/cancelAllOrders.ts index e40106c8..5dbacf95 100644 --- a/src/modules/portfolio-margin/margin-trade/cancelAllOrders.ts +++ b/src/modules/portfolio-margin/margin-trade/cancelAllOrders.ts @@ -5,43 +5,50 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/margin-trade/cancelAllOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginMarginCancelAllOrders(server: McpServer) { - server.tool( - "BinancePortfolioMarginMarginCancelAllOrders", - "Cancel all open cross margin orders for a symbol in Portfolio Margin mode. ⚠️ This will cancel ALL open orders.", - { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.marginCancelAllOpenOrders({ - symbol: params.symbol, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ All Portfolio Margin margin orders cancelled for ${params.symbol}\n\nResponse: ${JSON.stringify(data)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to cancel all Portfolio Margin margin orders: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginMarginCancelAllOrders", + "Cancel all open cross margin orders for a symbol in Portfolio Margin mode. ⚠️ This will cancel ALL open orders.", + { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.marginCancelAllOpenOrders({ + symbol: params.symbol, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ All Portfolio Margin margin orders cancelled for ${params.symbol}\n\nResponse: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to cancel all Portfolio Margin margin orders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/margin-trade/cancelOrder.ts b/src/modules/portfolio-margin/margin-trade/cancelOrder.ts index 5a9a9e88..f2a57e7f 100644 --- a/src/modules/portfolio-margin/margin-trade/cancelOrder.ts +++ b/src/modules/portfolio-margin/margin-trade/cancelOrder.ts @@ -5,57 +5,66 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/margin-trade/cancelOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginMarginCancelOrder(server: McpServer) { - server.tool( - "BinancePortfolioMarginMarginCancelOrder", - "Cancel an active cross margin order in Portfolio Margin mode.", - { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - orderId: z.number().int().optional().describe("Order ID to cancel"), - origClientOrderId: z.string().optional().describe("Original client order ID to cancel"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - if (!params.orderId && !params.origClientOrderId) { - return { - content: [{ - type: "text", - text: `❌ Either orderId or origClientOrderId must be provided` - }], - isError: true - }; - } - - const response = await portfolioMarginClient.restAPI.marginCancelOrder({ - symbol: params.symbol, - ...(params.orderId && { orderId: params.orderId }), - ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Portfolio Margin Margin Order Cancelled!\n\nOrder ID: ${data.orderId}\nSymbol: ${data.symbol}\nStatus: ${data.status}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to cancel Portfolio Margin margin order: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginMarginCancelOrder", + "Cancel an active cross margin order in Portfolio Margin mode.", + { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + orderId: z.number().int().optional().describe("Order ID to cancel"), + origClientOrderId: z.string().optional().describe("Original client order ID to cancel"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + if (!params.orderId && !params.origClientOrderId) { + return { + content: [ + { + type: "text", + text: `❌ Either orderId or origClientOrderId must be provided`, + }, + ], + isError: true, + } + } + + const response = await portfolioMarginClient.restAPI.marginCancelOrder({ + symbol: params.symbol, + ...(params.orderId && { orderId: params.orderId }), + ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Portfolio Margin Margin Order Cancelled!\n\nOrder ID: ${data.orderId}\nSymbol: ${data.symbol}\nStatus: ${data.status}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to cancel Portfolio Margin margin order: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/margin-trade/getAllOrders.ts b/src/modules/portfolio-margin/margin-trade/getAllOrders.ts index d6636d7e..cb86cc69 100644 --- a/src/modules/portfolio-margin/margin-trade/getAllOrders.ts +++ b/src/modules/portfolio-margin/margin-trade/getAllOrders.ts @@ -5,68 +5,81 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/margin-trade/getAllOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginMarginGetAllOrders(server: McpServer) { - server.tool( - "BinancePortfolioMarginMarginGetAllOrders", - "Get all cross margin orders (active, cancelled, filled) in Portfolio Margin mode.", - { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - orderId: z.number().int().optional().describe("Order ID to start from"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z.number().int().min(1).max(500).optional().describe("Number of orders to return (default 500, max 500)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.marginAllOrders({ - symbol: params.symbol, - ...(params.orderId && { orderId: params.orderId }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Portfolio Margin Margin All Orders - ${params.symbol}\n\n`; - - if (Array.isArray(data) && data.length > 0) { - result += `Total orders: ${data.length}\n\n`; - data.slice(0, 20).forEach((order: any, index: number) => { - result += `**${index + 1}. Order ID: ${order.orderId}**\n`; - result += ` Side: ${order.side} | Type: ${order.type}\n`; - result += ` Price: ${order.price} | Qty: ${order.origQty}\n`; - result += ` Executed: ${order.executedQty} | Status: ${order.status}\n\n`; - }); - if (data.length > 20) { - result += `... and ${data.length - 20} more orders`; - } - } else { - result += `No orders found`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get Portfolio Margin margin orders: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginMarginGetAllOrders", + "Get all cross margin orders (active, cancelled, filled) in Portfolio Margin mode.", + { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + orderId: z.number().int().optional().describe("Order ID to start from"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .min(1) + .max(500) + .optional() + .describe("Number of orders to return (default 500, max 500)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.marginAllOrders({ + symbol: params.symbol, + ...(params.orderId && { orderId: params.orderId }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Portfolio Margin Margin All Orders - ${params.symbol}\n\n` + + if (Array.isArray(data) && data.length > 0) { + result += `Total orders: ${data.length}\n\n` + data.slice(0, 20).forEach((order: any, index: number) => { + result += `**${index + 1}. Order ID: ${order.orderId}**\n` + result += ` Side: ${order.side} | Type: ${order.type}\n` + result += ` Price: ${order.price} | Qty: ${order.origQty}\n` + result += ` Executed: ${order.executedQty} | Status: ${order.status}\n\n` + }) + if (data.length > 20) { + result += `... and ${data.length - 20} more orders` + } + } else { + result += `No orders found` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get Portfolio Margin margin orders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/margin-trade/getOpenOrders.ts b/src/modules/portfolio-margin/margin-trade/getOpenOrders.ts index 02359040..33e7cdab 100644 --- a/src/modules/portfolio-margin/margin-trade/getOpenOrders.ts +++ b/src/modules/portfolio-margin/margin-trade/getOpenOrders.ts @@ -5,59 +5,66 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/margin-trade/getOpenOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginMarginGetOpenOrders(server: McpServer) { - server.tool( - "BinancePortfolioMarginMarginGetOpenOrders", - "Get all open cross margin orders in Portfolio Margin mode.", - { - symbol: z.string().optional().describe("Trading pair symbol to filter by"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.marginOpenOrders({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Portfolio Margin Margin Open Orders\n\n`; - - if (Array.isArray(data) && data.length > 0) { - result += `Total open orders: ${data.length}\n\n`; - data.forEach((order: any, index: number) => { - result += `**${index + 1}. ${order.symbol}**\n`; - result += ` Order ID: ${order.orderId}\n`; - result += ` Side: ${order.side} | Type: ${order.type}\n`; - result += ` Price: ${order.price} | Qty: ${order.origQty}\n`; - result += ` Executed: ${order.executedQty}\n`; - result += ` Status: ${order.status}\n\n`; - }); - } else { - result += `No open orders found`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get Portfolio Margin margin open orders: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginMarginGetOpenOrders", + "Get all open cross margin orders in Portfolio Margin mode.", + { + symbol: z.string().optional().describe("Trading pair symbol to filter by"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.marginOpenOrders({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Portfolio Margin Margin Open Orders\n\n` + + if (Array.isArray(data) && data.length > 0) { + result += `Total open orders: ${data.length}\n\n` + data.forEach((order: any, index: number) => { + result += `**${index + 1}. ${order.symbol}**\n` + result += ` Order ID: ${order.orderId}\n` + result += ` Side: ${order.side} | Type: ${order.type}\n` + result += ` Price: ${order.price} | Qty: ${order.origQty}\n` + result += ` Executed: ${order.executedQty}\n` + result += ` Status: ${order.status}\n\n` + }) + } else { + result += `No open orders found` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get Portfolio Margin margin open orders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/margin-trade/getOrder.ts b/src/modules/portfolio-margin/margin-trade/getOrder.ts index b3ba8195..9d7d74c8 100644 --- a/src/modules/portfolio-margin/margin-trade/getOrder.ts +++ b/src/modules/portfolio-margin/margin-trade/getOrder.ts @@ -5,66 +5,75 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/margin-trade/getOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginMarginGetOrder(server: McpServer) { - server.tool( - "BinancePortfolioMarginMarginGetOrder", - "Query a specific cross margin order in Portfolio Margin mode.", - { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - orderId: z.number().int().optional().describe("Order ID to query"), - origClientOrderId: z.string().optional().describe("Original client order ID to query"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - if (!params.orderId && !params.origClientOrderId) { - return { - content: [{ - type: "text", - text: `❌ Either orderId or origClientOrderId must be provided` - }], - isError: true - }; - } - - const response = await portfolioMarginClient.restAPI.marginOrder({ - symbol: params.symbol, - ...(params.orderId && { orderId: params.orderId }), - ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Portfolio Margin Margin Order Details\n\n`; - result += `Order ID: ${data.orderId}\n`; - result += `Symbol: ${data.symbol}\n`; - result += `Side: ${data.side} | Type: ${data.type}\n`; - result += `Price: ${data.price} | Qty: ${data.origQty}\n`; - result += `Executed Qty: ${data.executedQty}\n`; - result += `Status: ${data.status}\n`; - result += `Time: ${new Date(data.time).toISOString()}`; - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get Portfolio Margin margin order: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginMarginGetOrder", + "Query a specific cross margin order in Portfolio Margin mode.", + { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + orderId: z.number().int().optional().describe("Order ID to query"), + origClientOrderId: z.string().optional().describe("Original client order ID to query"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + if (!params.orderId && !params.origClientOrderId) { + return { + content: [ + { + type: "text", + text: `❌ Either orderId or origClientOrderId must be provided`, + }, + ], + isError: true, + } + } + + const response = await portfolioMarginClient.restAPI.marginOrder({ + symbol: params.symbol, + ...(params.orderId && { orderId: params.orderId }), + ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Portfolio Margin Margin Order Details\n\n` + result += `Order ID: ${data.orderId}\n` + result += `Symbol: ${data.symbol}\n` + result += `Side: ${data.side} | Type: ${data.type}\n` + result += `Price: ${data.price} | Qty: ${data.origQty}\n` + result += `Executed Qty: ${data.executedQty}\n` + result += `Status: ${data.status}\n` + result += `Time: ${new Date(data.time).toISOString()}` + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get Portfolio Margin margin order: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/margin-trade/getUserTrades.ts b/src/modules/portfolio-margin/margin-trade/getUserTrades.ts index 48a85705..ccb71ec5 100644 --- a/src/modules/portfolio-margin/margin-trade/getUserTrades.ts +++ b/src/modules/portfolio-margin/margin-trade/getUserTrades.ts @@ -5,71 +5,84 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/margin-trade/getUserTrades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginMarginGetUserTrades(server: McpServer) { - server.tool( - "BinancePortfolioMarginMarginGetUserTrades", - "Get cross margin trade history in Portfolio Margin mode.", - { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - fromId: z.number().int().optional().describe("Trade ID to start from"), - limit: z.number().int().min(1).max(1000).optional().describe("Number of trades to return (default 500, max 1000)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.marginMyTrades({ - symbol: params.symbol, - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.fromId && { fromId: params.fromId }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Portfolio Margin Margin Trade History - ${params.symbol}\n\n`; - - if (Array.isArray(data) && data.length > 0) { - result += `Total trades: ${data.length}\n\n`; - data.slice(0, 20).forEach((trade: any, index: number) => { - result += `**${index + 1}. Trade ID: ${trade.id}**\n`; - result += ` Order ID: ${trade.orderId}\n`; - result += ` Price: ${trade.price} | Qty: ${trade.qty}\n`; - result += ` Quote Qty: ${trade.quoteQty}\n`; - result += ` Commission: ${trade.commission} ${trade.commissionAsset}\n`; - result += ` Is Buyer: ${trade.isBuyer} | Is Maker: ${trade.isMaker}\n`; - result += ` Time: ${new Date(trade.time).toISOString()}\n\n`; - }); - if (data.length > 20) { - result += `... and ${data.length - 20} more trades`; - } - } else { - result += `No trades found`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get Portfolio Margin margin trades: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginMarginGetUserTrades", + "Get cross margin trade history in Portfolio Margin mode.", + { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + fromId: z.number().int().optional().describe("Trade ID to start from"), + limit: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .describe("Number of trades to return (default 500, max 1000)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.marginMyTrades({ + symbol: params.symbol, + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.fromId && { fromId: params.fromId }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Portfolio Margin Margin Trade History - ${params.symbol}\n\n` + + if (Array.isArray(data) && data.length > 0) { + result += `Total trades: ${data.length}\n\n` + data.slice(0, 20).forEach((trade: any, index: number) => { + result += `**${index + 1}. Trade ID: ${trade.id}**\n` + result += ` Order ID: ${trade.orderId}\n` + result += ` Price: ${trade.price} | Qty: ${trade.qty}\n` + result += ` Quote Qty: ${trade.quoteQty}\n` + result += ` Commission: ${trade.commission} ${trade.commissionAsset}\n` + result += ` Is Buyer: ${trade.isBuyer} | Is Maker: ${trade.isMaker}\n` + result += ` Time: ${new Date(trade.time).toISOString()}\n\n` + }) + if (data.length > 20) { + result += `... and ${data.length - 20} more trades` + } + } else { + result += `No trades found` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get Portfolio Margin margin trades: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/margin-trade/index.ts b/src/modules/portfolio-margin/margin-trade/index.ts index c6293d1d..3da3d783 100644 --- a/src/modules/portfolio-margin/margin-trade/index.ts +++ b/src/modules/portfolio-margin/margin-trade/index.ts @@ -5,25 +5,26 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/margin-trade/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerPortfolioMarginMarginNewOrder } from "./newOrder.js"; -import { registerPortfolioMarginMarginCancelOrder } from "./cancelOrder.js"; -import { registerPortfolioMarginMarginCancelAllOrders } from "./cancelAllOrders.js"; -import { registerPortfolioMarginMarginGetOrder } from "./getOrder.js"; -import { registerPortfolioMarginMarginGetAllOrders } from "./getAllOrders.js"; -import { registerPortfolioMarginMarginGetOpenOrders } from "./getOpenOrders.js"; -import { registerPortfolioMarginMarginLoan } from "./marginLoan.js"; -import { registerPortfolioMarginMarginRepay } from "./marginRepay.js"; -import { registerPortfolioMarginMarginGetUserTrades } from "./getUserTrades.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerPortfolioMarginMarginCancelAllOrders } from "./cancelAllOrders.js" +import { registerPortfolioMarginMarginCancelOrder } from "./cancelOrder.js" +import { registerPortfolioMarginMarginGetAllOrders } from "./getAllOrders.js" +import { registerPortfolioMarginMarginGetOpenOrders } from "./getOpenOrders.js" +import { registerPortfolioMarginMarginGetOrder } from "./getOrder.js" +import { registerPortfolioMarginMarginGetUserTrades } from "./getUserTrades.js" +import { registerPortfolioMarginMarginLoan } from "./marginLoan.js" +import { registerPortfolioMarginMarginRepay } from "./marginRepay.js" +import { registerPortfolioMarginMarginNewOrder } from "./newOrder.js" export function registerPortfolioMarginMarginTradeApi(server: McpServer) { - registerPortfolioMarginMarginNewOrder(server); - registerPortfolioMarginMarginCancelOrder(server); - registerPortfolioMarginMarginCancelAllOrders(server); - registerPortfolioMarginMarginGetOrder(server); - registerPortfolioMarginMarginGetAllOrders(server); - registerPortfolioMarginMarginGetOpenOrders(server); - registerPortfolioMarginMarginLoan(server); - registerPortfolioMarginMarginRepay(server); - registerPortfolioMarginMarginGetUserTrades(server); + registerPortfolioMarginMarginNewOrder(server) + registerPortfolioMarginMarginCancelOrder(server) + registerPortfolioMarginMarginCancelAllOrders(server) + registerPortfolioMarginMarginGetOrder(server) + registerPortfolioMarginMarginGetAllOrders(server) + registerPortfolioMarginMarginGetOpenOrders(server) + registerPortfolioMarginMarginLoan(server) + registerPortfolioMarginMarginRepay(server) + registerPortfolioMarginMarginGetUserTrades(server) } diff --git a/src/modules/portfolio-margin/margin-trade/marginLoan.ts b/src/modules/portfolio-margin/margin-trade/marginLoan.ts index f893f9bb..b234f161 100644 --- a/src/modules/portfolio-margin/margin-trade/marginLoan.ts +++ b/src/modules/portfolio-margin/margin-trade/marginLoan.ts @@ -5,45 +5,52 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/margin-trade/marginLoan.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginMarginLoan(server: McpServer) { - server.tool( - "BinancePortfolioMarginMarginLoan", - "Borrow funds for margin trading in Portfolio Margin mode. ⚠️ Borrowed funds accrue interest.", - { - asset: z.string().describe("Asset to borrow (e.g., 'USDT')"), - amount: z.string().describe("Amount to borrow"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.marginLoan({ - asset: params.asset, - amount: params.amount, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Portfolio Margin Loan Successful!\n\nTransaction ID: ${data.tranId}\nAsset: ${params.asset}\nAmount: ${params.amount}\n\n⚠️ Note: Borrowed funds will accrue interest.` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to borrow funds: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginMarginLoan", + "Borrow funds for margin trading in Portfolio Margin mode. ⚠️ Borrowed funds accrue interest.", + { + asset: z.string().describe("Asset to borrow (e.g., 'USDT')"), + amount: z.string().describe("Amount to borrow"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.marginLoan({ + asset: params.asset, + amount: params.amount, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Portfolio Margin Loan Successful!\n\nTransaction ID: ${data.tranId}\nAsset: ${params.asset}\nAmount: ${params.amount}\n\n⚠️ Note: Borrowed funds will accrue interest.`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to borrow funds: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/margin-trade/marginRepay.ts b/src/modules/portfolio-margin/margin-trade/marginRepay.ts index 06600ce2..20297772 100644 --- a/src/modules/portfolio-margin/margin-trade/marginRepay.ts +++ b/src/modules/portfolio-margin/margin-trade/marginRepay.ts @@ -5,45 +5,52 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/margin-trade/marginRepay.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginMarginRepay(server: McpServer) { - server.tool( - "BinancePortfolioMarginMarginRepay", - "Repay borrowed funds in Portfolio Margin mode.", - { - asset: z.string().describe("Asset to repay (e.g., 'USDT')"), - amount: z.string().describe("Amount to repay"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.marginRepay({ - asset: params.asset, - amount: params.amount, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Portfolio Margin Repayment Successful!\n\nTransaction ID: ${data.tranId}\nAsset: ${params.asset}\nAmount: ${params.amount}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to repay funds: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginMarginRepay", + "Repay borrowed funds in Portfolio Margin mode.", + { + asset: z.string().describe("Asset to repay (e.g., 'USDT')"), + amount: z.string().describe("Amount to repay"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.marginRepay({ + asset: params.asset, + amount: params.amount, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Portfolio Margin Repayment Successful!\n\nTransaction ID: ${data.tranId}\nAsset: ${params.asset}\nAmount: ${params.amount}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to repay funds: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/margin-trade/newOrder.ts b/src/modules/portfolio-margin/margin-trade/newOrder.ts index 14e031c4..399856bf 100644 --- a/src/modules/portfolio-margin/margin-trade/newOrder.ts +++ b/src/modules/portfolio-margin/margin-trade/newOrder.ts @@ -5,63 +5,81 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/margin-trade/newOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginMarginNewOrder(server: McpServer) { - server.tool( - "BinancePortfolioMarginMarginNewOrder", - "Place a new cross margin order in Portfolio Margin mode. ⚠️ Margin trading involves borrowing and interest.", - { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - side: z.enum(["BUY", "SELL"]).describe("Order side"), - type: z.enum(["LIMIT", "MARKET", "STOP_LOSS", "STOP_LOSS_LIMIT", "TAKE_PROFIT", "TAKE_PROFIT_LIMIT", "LIMIT_MAKER"]) - .describe("Order type"), - quantity: z.string().optional().describe("Order quantity"), - quoteOrderQty: z.string().optional().describe("Quote quantity (for MARKET orders)"), - price: z.string().optional().describe("Limit price"), - stopPrice: z.string().optional().describe("Stop price"), - timeInForce: z.enum(["GTC", "IOC", "FOK"]).optional().describe("Time in force"), - newClientOrderId: z.string().optional().describe("Custom client order ID"), - sideEffectType: z.enum(["NO_SIDE_EFFECT", "MARGIN_BUY", "AUTO_REPAY", "AUTO_BORROW_REPAY"]).optional() - .describe("Side effect type for margin orders"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.marginNewOrder({ - symbol: params.symbol, - side: params.side, - type: params.type, - ...(params.quantity && { quantity: params.quantity }), - ...(params.quoteOrderQty && { quoteOrderQty: params.quoteOrderQty }), - ...(params.price && { price: params.price }), - ...(params.stopPrice && { stopPrice: params.stopPrice }), - ...(params.timeInForce && { timeInForce: params.timeInForce }), - ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), - ...(params.sideEffectType && { sideEffectType: params.sideEffectType }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Portfolio Margin Margin Order Placed!\n\nOrder ID: ${data.orderId}\nSymbol: ${data.symbol}\nSide: ${data.side}\nType: ${data.type}\nQuantity: ${data.origQty}\nPrice: ${data.price || 'MARKET'}\nStatus: ${data.status}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to place Portfolio Margin margin order: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginMarginNewOrder", + "Place a new cross margin order in Portfolio Margin mode. ⚠️ Margin trading involves borrowing and interest.", + { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + side: z.enum(["BUY", "SELL"]).describe("Order side"), + type: z + .enum([ + "LIMIT", + "MARKET", + "STOP_LOSS", + "STOP_LOSS_LIMIT", + "TAKE_PROFIT", + "TAKE_PROFIT_LIMIT", + "LIMIT_MAKER", + ]) + .describe("Order type"), + quantity: z.string().optional().describe("Order quantity"), + quoteOrderQty: z.string().optional().describe("Quote quantity (for MARKET orders)"), + price: z.string().optional().describe("Limit price"), + stopPrice: z.string().optional().describe("Stop price"), + timeInForce: z.enum(["GTC", "IOC", "FOK"]).optional().describe("Time in force"), + newClientOrderId: z.string().optional().describe("Custom client order ID"), + sideEffectType: z + .enum(["NO_SIDE_EFFECT", "MARGIN_BUY", "AUTO_REPAY", "AUTO_BORROW_REPAY"]) + .optional() + .describe("Side effect type for margin orders"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.marginNewOrder({ + symbol: params.symbol, + side: params.side, + type: params.type, + ...(params.quantity && { quantity: params.quantity }), + ...(params.quoteOrderQty && { quoteOrderQty: params.quoteOrderQty }), + ...(params.price && { price: params.price }), + ...(params.stopPrice && { stopPrice: params.stopPrice }), + ...(params.timeInForce && { timeInForce: params.timeInForce }), + ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), + ...(params.sideEffectType && { sideEffectType: params.sideEffectType }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Portfolio Margin Margin Order Placed!\n\nOrder ID: ${data.orderId}\nSymbol: ${data.symbol}\nSide: ${data.side}\nType: ${data.type}\nQuantity: ${data.origQty}\nPrice: ${data.price || "MARKET"}\nStatus: ${data.status}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to place Portfolio Margin margin order: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/um-trade/cancelAllOrders.ts b/src/modules/portfolio-margin/um-trade/cancelAllOrders.ts index d67a13dc..03fad42c 100644 --- a/src/modules/portfolio-margin/um-trade/cancelAllOrders.ts +++ b/src/modules/portfolio-margin/um-trade/cancelAllOrders.ts @@ -5,43 +5,50 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/um-trade/cancelAllOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginUmCancelAllOrders(server: McpServer) { - server.tool( - "BinancePortfolioMarginUmCancelAllOrders", - "Cancel all open USDT-M Futures orders for a symbol in Portfolio Margin mode. ⚠️ This will cancel ALL open orders.", - { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.umCancelAllOpenOrders({ - symbol: params.symbol, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ All Portfolio Margin UM orders cancelled for ${params.symbol}\n\nResponse: ${JSON.stringify(data)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to cancel all Portfolio Margin UM orders: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginUmCancelAllOrders", + "Cancel all open USDT-M Futures orders for a symbol in Portfolio Margin mode. ⚠️ This will cancel ALL open orders.", + { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.umCancelAllOpenOrders({ + symbol: params.symbol, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ All Portfolio Margin UM orders cancelled for ${params.symbol}\n\nResponse: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to cancel all Portfolio Margin UM orders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/um-trade/cancelOrder.ts b/src/modules/portfolio-margin/um-trade/cancelOrder.ts index 0656a949..2bdf71b8 100644 --- a/src/modules/portfolio-margin/um-trade/cancelOrder.ts +++ b/src/modules/portfolio-margin/um-trade/cancelOrder.ts @@ -5,57 +5,66 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/um-trade/cancelOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginUmCancelOrder(server: McpServer) { - server.tool( - "BinancePortfolioMarginUmCancelOrder", - "Cancel an active USDT-M Futures order in Portfolio Margin mode.", - { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - orderId: z.number().int().optional().describe("Order ID to cancel"), - origClientOrderId: z.string().optional().describe("Original client order ID to cancel"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - if (!params.orderId && !params.origClientOrderId) { - return { - content: [{ - type: "text", - text: `❌ Either orderId or origClientOrderId must be provided` - }], - isError: true - }; - } - - const response = await portfolioMarginClient.restAPI.umCancelOrder({ - symbol: params.symbol, - ...(params.orderId && { orderId: params.orderId }), - ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Portfolio Margin UM Order Cancelled!\n\nOrder ID: ${data.orderId}\nSymbol: ${data.symbol}\nStatus: ${data.status}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to cancel Portfolio Margin UM order: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginUmCancelOrder", + "Cancel an active USDT-M Futures order in Portfolio Margin mode.", + { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + orderId: z.number().int().optional().describe("Order ID to cancel"), + origClientOrderId: z.string().optional().describe("Original client order ID to cancel"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + if (!params.orderId && !params.origClientOrderId) { + return { + content: [ + { + type: "text", + text: `❌ Either orderId or origClientOrderId must be provided`, + }, + ], + isError: true, + } + } + + const response = await portfolioMarginClient.restAPI.umCancelOrder({ + symbol: params.symbol, + ...(params.orderId && { orderId: params.orderId }), + ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Portfolio Margin UM Order Cancelled!\n\nOrder ID: ${data.orderId}\nSymbol: ${data.symbol}\nStatus: ${data.status}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to cancel Portfolio Margin UM order: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/um-trade/changeLeverage.ts b/src/modules/portfolio-margin/um-trade/changeLeverage.ts index e0cd3c52..734830ee 100644 --- a/src/modules/portfolio-margin/um-trade/changeLeverage.ts +++ b/src/modules/portfolio-margin/um-trade/changeLeverage.ts @@ -5,45 +5,52 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/um-trade/changeLeverage.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginUmChangeLeverage(server: McpServer) { - server.tool( - "BinancePortfolioMarginUmChangeLeverage", - "Change leverage for a USDT-M Futures symbol in Portfolio Margin mode. ⚠️ Higher leverage increases risk.", - { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - leverage: z.number().int().min(1).max(125).describe("Target leverage (1-125)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.umLeverage({ - symbol: params.symbol, - leverage: params.leverage, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Portfolio Margin UM Leverage Changed!\n\nSymbol: ${data.symbol}\nNew Leverage: ${data.leverage}x\nMax Notional Value: ${data.maxNotionalValue}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to change Portfolio Margin UM leverage: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginUmChangeLeverage", + "Change leverage for a USDT-M Futures symbol in Portfolio Margin mode. ⚠️ Higher leverage increases risk.", + { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + leverage: z.number().int().min(1).max(125).describe("Target leverage (1-125)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.umLeverage({ + symbol: params.symbol, + leverage: params.leverage, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Portfolio Margin UM Leverage Changed!\n\nSymbol: ${data.symbol}\nNew Leverage: ${data.leverage}x\nMax Notional Value: ${data.maxNotionalValue}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to change Portfolio Margin UM leverage: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/um-trade/changeMarginType.ts b/src/modules/portfolio-margin/um-trade/changeMarginType.ts index 587ef418..935376ba 100644 --- a/src/modules/portfolio-margin/um-trade/changeMarginType.ts +++ b/src/modules/portfolio-margin/um-trade/changeMarginType.ts @@ -5,45 +5,52 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/um-trade/changeMarginType.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginUmChangeMarginType(server: McpServer) { - server.tool( - "BinancePortfolioMarginUmChangeMarginType", - "Change margin type (ISOLATED/CROSSED) for a USDT-M Futures symbol in Portfolio Margin mode.", - { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - marginType: z.enum(["ISOLATED", "CROSSED"]).describe("Margin type"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.umMarginType({ - symbol: params.symbol, - marginType: params.marginType, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Portfolio Margin UM Margin Type Changed!\n\nSymbol: ${params.symbol}\nNew Margin Type: ${params.marginType}\n\nResponse: ${JSON.stringify(data)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to change Portfolio Margin UM margin type: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginUmChangeMarginType", + "Change margin type (ISOLATED/CROSSED) for a USDT-M Futures symbol in Portfolio Margin mode.", + { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + marginType: z.enum(["ISOLATED", "CROSSED"]).describe("Margin type"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.umMarginType({ + symbol: params.symbol, + marginType: params.marginType, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Portfolio Margin UM Margin Type Changed!\n\nSymbol: ${params.symbol}\nNew Margin Type: ${params.marginType}\n\nResponse: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to change Portfolio Margin UM margin type: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/um-trade/getAllOrders.ts b/src/modules/portfolio-margin/um-trade/getAllOrders.ts index c3db2be6..a38741ef 100644 --- a/src/modules/portfolio-margin/um-trade/getAllOrders.ts +++ b/src/modules/portfolio-margin/um-trade/getAllOrders.ts @@ -5,68 +5,81 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/um-trade/getAllOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginUmGetAllOrders(server: McpServer) { - server.tool( - "BinancePortfolioMarginUmGetAllOrders", - "Get all USDT-M Futures orders (active, cancelled, filled) in Portfolio Margin mode.", - { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - orderId: z.number().int().optional().describe("Order ID to start from"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z.number().int().min(1).max(1000).optional().describe("Number of orders to return (default 500, max 1000)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.umAllOrders({ - symbol: params.symbol, - ...(params.orderId && { orderId: params.orderId }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Portfolio Margin UM All Orders - ${params.symbol}\n\n`; - - if (Array.isArray(data) && data.length > 0) { - result += `Total orders: ${data.length}\n\n`; - data.slice(0, 20).forEach((order: any, index: number) => { - result += `**${index + 1}. Order ID: ${order.orderId}**\n`; - result += ` Side: ${order.side} | Type: ${order.type}\n`; - result += ` Price: ${order.price} | Qty: ${order.origQty}\n`; - result += ` Executed: ${order.executedQty} | Status: ${order.status}\n\n`; - }); - if (data.length > 20) { - result += `... and ${data.length - 20} more orders`; - } - } else { - result += `No orders found`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get Portfolio Margin UM orders: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginUmGetAllOrders", + "Get all USDT-M Futures orders (active, cancelled, filled) in Portfolio Margin mode.", + { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + orderId: z.number().int().optional().describe("Order ID to start from"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .describe("Number of orders to return (default 500, max 1000)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.umAllOrders({ + symbol: params.symbol, + ...(params.orderId && { orderId: params.orderId }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Portfolio Margin UM All Orders - ${params.symbol}\n\n` + + if (Array.isArray(data) && data.length > 0) { + result += `Total orders: ${data.length}\n\n` + data.slice(0, 20).forEach((order: any, index: number) => { + result += `**${index + 1}. Order ID: ${order.orderId}**\n` + result += ` Side: ${order.side} | Type: ${order.type}\n` + result += ` Price: ${order.price} | Qty: ${order.origQty}\n` + result += ` Executed: ${order.executedQty} | Status: ${order.status}\n\n` + }) + if (data.length > 20) { + result += `... and ${data.length - 20} more orders` + } + } else { + result += `No orders found` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get Portfolio Margin UM orders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/um-trade/getOpenOrders.ts b/src/modules/portfolio-margin/um-trade/getOpenOrders.ts index bbd464d4..48b3c6e9 100644 --- a/src/modules/portfolio-margin/um-trade/getOpenOrders.ts +++ b/src/modules/portfolio-margin/um-trade/getOpenOrders.ts @@ -5,59 +5,66 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/um-trade/getOpenOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginUmGetOpenOrders(server: McpServer) { - server.tool( - "BinancePortfolioMarginUmGetOpenOrders", - "Get all open USDT-M Futures orders in Portfolio Margin mode.", - { - symbol: z.string().optional().describe("Trading pair symbol to filter by"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.umOpenOrders({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Portfolio Margin UM Open Orders\n\n`; - - if (Array.isArray(data) && data.length > 0) { - result += `Total open orders: ${data.length}\n\n`; - data.forEach((order: any, index: number) => { - result += `**${index + 1}. ${order.symbol}**\n`; - result += ` Order ID: ${order.orderId}\n`; - result += ` Side: ${order.side} | Type: ${order.type}\n`; - result += ` Price: ${order.price} | Qty: ${order.origQty}\n`; - result += ` Executed: ${order.executedQty}\n`; - result += ` Status: ${order.status}\n\n`; - }); - } else { - result += `No open orders found`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get Portfolio Margin UM open orders: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginUmGetOpenOrders", + "Get all open USDT-M Futures orders in Portfolio Margin mode.", + { + symbol: z.string().optional().describe("Trading pair symbol to filter by"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.umOpenOrders({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Portfolio Margin UM Open Orders\n\n` + + if (Array.isArray(data) && data.length > 0) { + result += `Total open orders: ${data.length}\n\n` + data.forEach((order: any, index: number) => { + result += `**${index + 1}. ${order.symbol}**\n` + result += ` Order ID: ${order.orderId}\n` + result += ` Side: ${order.side} | Type: ${order.type}\n` + result += ` Price: ${order.price} | Qty: ${order.origQty}\n` + result += ` Executed: ${order.executedQty}\n` + result += ` Status: ${order.status}\n\n` + }) + } else { + result += `No open orders found` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get Portfolio Margin UM open orders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/um-trade/getOrder.ts b/src/modules/portfolio-margin/um-trade/getOrder.ts index 6b1eb534..af640b31 100644 --- a/src/modules/portfolio-margin/um-trade/getOrder.ts +++ b/src/modules/portfolio-margin/um-trade/getOrder.ts @@ -5,67 +5,76 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/um-trade/getOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginUmGetOrder(server: McpServer) { - server.tool( - "BinancePortfolioMarginUmGetOrder", - "Query a specific USDT-M Futures order in Portfolio Margin mode.", - { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - orderId: z.number().int().optional().describe("Order ID to query"), - origClientOrderId: z.string().optional().describe("Original client order ID to query"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - if (!params.orderId && !params.origClientOrderId) { - return { - content: [{ - type: "text", - text: `❌ Either orderId or origClientOrderId must be provided` - }], - isError: true - }; - } - - const response = await portfolioMarginClient.restAPI.umOrder({ - symbol: params.symbol, - ...(params.orderId && { orderId: params.orderId }), - ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Portfolio Margin UM Order Details\n\n`; - result += `Order ID: ${data.orderId}\n`; - result += `Symbol: ${data.symbol}\n`; - result += `Side: ${data.side} | Type: ${data.type}\n`; - result += `Price: ${data.price} | Qty: ${data.origQty}\n`; - result += `Executed Qty: ${data.executedQty}\n`; - result += `Avg Price: ${data.avgPrice}\n`; - result += `Status: ${data.status}\n`; - result += `Time: ${new Date(data.time).toISOString()}`; - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get Portfolio Margin UM order: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginUmGetOrder", + "Query a specific USDT-M Futures order in Portfolio Margin mode.", + { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + orderId: z.number().int().optional().describe("Order ID to query"), + origClientOrderId: z.string().optional().describe("Original client order ID to query"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + if (!params.orderId && !params.origClientOrderId) { + return { + content: [ + { + type: "text", + text: `❌ Either orderId or origClientOrderId must be provided`, + }, + ], + isError: true, + } + } + + const response = await portfolioMarginClient.restAPI.umOrder({ + symbol: params.symbol, + ...(params.orderId && { orderId: params.orderId }), + ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Portfolio Margin UM Order Details\n\n` + result += `Order ID: ${data.orderId}\n` + result += `Symbol: ${data.symbol}\n` + result += `Side: ${data.side} | Type: ${data.type}\n` + result += `Price: ${data.price} | Qty: ${data.origQty}\n` + result += `Executed Qty: ${data.executedQty}\n` + result += `Avg Price: ${data.avgPrice}\n` + result += `Status: ${data.status}\n` + result += `Time: ${new Date(data.time).toISOString()}` + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get Portfolio Margin UM order: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/um-trade/getUserTrades.ts b/src/modules/portfolio-margin/um-trade/getUserTrades.ts index 4f25e699..a2daa314 100644 --- a/src/modules/portfolio-margin/um-trade/getUserTrades.ts +++ b/src/modules/portfolio-margin/um-trade/getUserTrades.ts @@ -5,71 +5,84 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/um-trade/getUserTrades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginUmGetUserTrades(server: McpServer) { - server.tool( - "BinancePortfolioMarginUmGetUserTrades", - "Get USDT-M Futures trade history in Portfolio Margin mode.", - { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - fromId: z.number().int().optional().describe("Trade ID to start from"), - limit: z.number().int().min(1).max(1000).optional().describe("Number of trades to return (default 500, max 1000)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.umUserTrades({ - symbol: params.symbol, - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.fromId && { fromId: params.fromId }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let result = `✅ Portfolio Margin UM Trade History - ${params.symbol}\n\n`; - - if (Array.isArray(data) && data.length > 0) { - result += `Total trades: ${data.length}\n\n`; - data.slice(0, 20).forEach((trade: any, index: number) => { - result += `**${index + 1}. Trade ID: ${trade.id}**\n`; - result += ` Order ID: ${trade.orderId}\n`; - result += ` Side: ${trade.side} | Price: ${trade.price}\n`; - result += ` Qty: ${trade.qty} | Quote Qty: ${trade.quoteQty}\n`; - result += ` Realized PnL: ${trade.realizedPnl}\n`; - result += ` Commission: ${trade.commission} ${trade.commissionAsset}\n`; - result += ` Time: ${new Date(trade.time).toISOString()}\n\n`; - }); - if (data.length > 20) { - result += `... and ${data.length - 20} more trades`; - } - } else { - result += `No trades found`; - } - - return { - content: [{ - type: "text", - text: result - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get Portfolio Margin UM trades: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginUmGetUserTrades", + "Get USDT-M Futures trade history in Portfolio Margin mode.", + { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + fromId: z.number().int().optional().describe("Trade ID to start from"), + limit: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .describe("Number of trades to return (default 500, max 1000)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.umUserTrades({ + symbol: params.symbol, + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.fromId && { fromId: params.fromId }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let result = `✅ Portfolio Margin UM Trade History - ${params.symbol}\n\n` + + if (Array.isArray(data) && data.length > 0) { + result += `Total trades: ${data.length}\n\n` + data.slice(0, 20).forEach((trade: any, index: number) => { + result += `**${index + 1}. Trade ID: ${trade.id}**\n` + result += ` Order ID: ${trade.orderId}\n` + result += ` Side: ${trade.side} | Price: ${trade.price}\n` + result += ` Qty: ${trade.qty} | Quote Qty: ${trade.quoteQty}\n` + result += ` Realized PnL: ${trade.realizedPnl}\n` + result += ` Commission: ${trade.commission} ${trade.commissionAsset}\n` + result += ` Time: ${new Date(trade.time).toISOString()}\n\n` + }) + if (data.length > 20) { + result += `... and ${data.length - 20} more trades` + } + } else { + result += `No trades found` + } + + return { + content: [ + { + type: "text", + text: result, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to get Portfolio Margin UM trades: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/um-trade/index.ts b/src/modules/portfolio-margin/um-trade/index.ts index 75232dbe..ee247537 100644 --- a/src/modules/portfolio-margin/um-trade/index.ts +++ b/src/modules/portfolio-margin/um-trade/index.ts @@ -5,25 +5,26 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/um-trade/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerPortfolioMarginUmNewOrder } from "./newOrder.js"; -import { registerPortfolioMarginUmCancelOrder } from "./cancelOrder.js"; -import { registerPortfolioMarginUmCancelAllOrders } from "./cancelAllOrders.js"; -import { registerPortfolioMarginUmGetOrder } from "./getOrder.js"; -import { registerPortfolioMarginUmGetAllOrders } from "./getAllOrders.js"; -import { registerPortfolioMarginUmGetOpenOrders } from "./getOpenOrders.js"; -import { registerPortfolioMarginUmGetUserTrades } from "./getUserTrades.js"; -import { registerPortfolioMarginUmChangeLeverage } from "./changeLeverage.js"; -import { registerPortfolioMarginUmChangeMarginType } from "./changeMarginType.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerPortfolioMarginUmCancelAllOrders } from "./cancelAllOrders.js" +import { registerPortfolioMarginUmCancelOrder } from "./cancelOrder.js" +import { registerPortfolioMarginUmChangeLeverage } from "./changeLeverage.js" +import { registerPortfolioMarginUmChangeMarginType } from "./changeMarginType.js" +import { registerPortfolioMarginUmGetAllOrders } from "./getAllOrders.js" +import { registerPortfolioMarginUmGetOpenOrders } from "./getOpenOrders.js" +import { registerPortfolioMarginUmGetOrder } from "./getOrder.js" +import { registerPortfolioMarginUmGetUserTrades } from "./getUserTrades.js" +import { registerPortfolioMarginUmNewOrder } from "./newOrder.js" export function registerPortfolioMarginUmTradeApi(server: McpServer) { - registerPortfolioMarginUmNewOrder(server); - registerPortfolioMarginUmCancelOrder(server); - registerPortfolioMarginUmCancelAllOrders(server); - registerPortfolioMarginUmGetOrder(server); - registerPortfolioMarginUmGetAllOrders(server); - registerPortfolioMarginUmGetOpenOrders(server); - registerPortfolioMarginUmGetUserTrades(server); - registerPortfolioMarginUmChangeLeverage(server); - registerPortfolioMarginUmChangeMarginType(server); + registerPortfolioMarginUmNewOrder(server) + registerPortfolioMarginUmCancelOrder(server) + registerPortfolioMarginUmCancelAllOrders(server) + registerPortfolioMarginUmGetOrder(server) + registerPortfolioMarginUmGetAllOrders(server) + registerPortfolioMarginUmGetOpenOrders(server) + registerPortfolioMarginUmGetUserTrades(server) + registerPortfolioMarginUmChangeLeverage(server) + registerPortfolioMarginUmChangeMarginType(server) } diff --git a/src/modules/portfolio-margin/um-trade/newOrder.ts b/src/modules/portfolio-margin/um-trade/newOrder.ts index cb836c33..3954aab0 100644 --- a/src/modules/portfolio-margin/um-trade/newOrder.ts +++ b/src/modules/portfolio-margin/um-trade/newOrder.ts @@ -5,62 +5,81 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/um-trade/newOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginUmNewOrder(server: McpServer) { - server.tool( - "BinancePortfolioMarginUmNewOrder", - "Place a new USDT-M Futures order in Portfolio Margin mode. ⚠️ HIGH RISK: Futures trading involves leverage.", - { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - side: z.enum(["BUY", "SELL"]).describe("Order side"), - type: z.enum(["LIMIT", "MARKET", "STOP", "STOP_MARKET", "TAKE_PROFIT", "TAKE_PROFIT_MARKET", "TRAILING_STOP_MARKET"]) - .describe("Order type"), - quantity: z.string().optional().describe("Order quantity"), - price: z.string().optional().describe("Limit price (required for LIMIT orders)"), - stopPrice: z.string().optional().describe("Stop price (required for STOP orders)"), - timeInForce: z.enum(["GTC", "IOC", "FOK", "GTX"]).optional().describe("Time in force"), - reduceOnly: z.boolean().optional().describe("Reduce position only"), - newClientOrderId: z.string().optional().describe("Custom client order ID"), - positionSide: z.enum(["BOTH", "LONG", "SHORT"]).optional().describe("Position side for hedge mode"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.umNewOrder({ - symbol: params.symbol, - side: params.side, - type: params.type, - ...(params.quantity && { quantity: params.quantity }), - ...(params.price && { price: params.price }), - ...(params.stopPrice && { stopPrice: params.stopPrice }), - ...(params.timeInForce && { timeInForce: params.timeInForce }), - ...(params.reduceOnly !== undefined && { reduceOnly: params.reduceOnly }), - ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), - ...(params.positionSide && { positionSide: params.positionSide }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Portfolio Margin UM Order Placed!\n\nOrder ID: ${data.orderId}\nSymbol: ${data.symbol}\nSide: ${data.side}\nType: ${data.type}\nQuantity: ${data.origQty}\nPrice: ${data.price || 'MARKET'}\nStatus: ${data.status}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to place Portfolio Margin UM order: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginUmNewOrder", + "Place a new USDT-M Futures order in Portfolio Margin mode. ⚠️ HIGH RISK: Futures trading involves leverage.", + { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + side: z.enum(["BUY", "SELL"]).describe("Order side"), + type: z + .enum([ + "LIMIT", + "MARKET", + "STOP", + "STOP_MARKET", + "TAKE_PROFIT", + "TAKE_PROFIT_MARKET", + "TRAILING_STOP_MARKET", + ]) + .describe("Order type"), + quantity: z.string().optional().describe("Order quantity"), + price: z.string().optional().describe("Limit price (required for LIMIT orders)"), + stopPrice: z.string().optional().describe("Stop price (required for STOP orders)"), + timeInForce: z.enum(["GTC", "IOC", "FOK", "GTX"]).optional().describe("Time in force"), + reduceOnly: z.boolean().optional().describe("Reduce position only"), + newClientOrderId: z.string().optional().describe("Custom client order ID"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe("Position side for hedge mode"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.umNewOrder({ + symbol: params.symbol, + side: params.side, + type: params.type, + ...(params.quantity && { quantity: params.quantity }), + ...(params.price && { price: params.price }), + ...(params.stopPrice && { stopPrice: params.stopPrice }), + ...(params.timeInForce && { timeInForce: params.timeInForce }), + ...(params.reduceOnly !== undefined && { reduceOnly: params.reduceOnly }), + ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), + ...(params.positionSide && { positionSide: params.positionSide }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Portfolio Margin UM Order Placed!\n\nOrder ID: ${data.orderId}\nSymbol: ${data.symbol}\nSide: ${data.side}\nType: ${data.type}\nQuantity: ${data.origQty}\nPrice: ${data.price || "MARKET"}\nStatus: ${data.status}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to place Portfolio Margin UM order: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/userdata/createListenKey.ts b/src/modules/portfolio-margin/userdata/createListenKey.ts index efbc3718..fde32ec0 100644 --- a/src/modules/portfolio-margin/userdata/createListenKey.ts +++ b/src/modules/portfolio-margin/userdata/createListenKey.ts @@ -5,35 +5,41 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/userdata/createListenKey.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginCreateListenKey(server: McpServer) { - server.tool( - "BinancePortfolioMarginCreateListenKey", - "Create a listen key for Portfolio Margin user data stream. The listen key is used to subscribe to account updates via WebSocket.", - {}, - async () => { - try { - const response = await portfolioMarginClient.restAPI.createListenKey(); - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Portfolio Margin Listen Key Created\n\nListen Key: ${data.listenKey}\n\n**Note**: This listen key is valid for 60 minutes. Use BinancePortfolioMarginRenewListenKey to extend validity.` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to create Portfolio Margin listen key: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginCreateListenKey", + "Create a listen key for Portfolio Margin user data stream. The listen key is used to subscribe to account updates via WebSocket.", + {}, + async () => { + try { + const response = await portfolioMarginClient.restAPI.createListenKey() + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Portfolio Margin Listen Key Created\n\nListen Key: ${data.listenKey}\n\n**Note**: This listen key is valid for 60 minutes. Use BinancePortfolioMarginRenewListenKey to extend validity.`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to create Portfolio Margin listen key: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/userdata/deleteListenKey.ts b/src/modules/portfolio-margin/userdata/deleteListenKey.ts index 8fe5724d..46df9ad5 100644 --- a/src/modules/portfolio-margin/userdata/deleteListenKey.ts +++ b/src/modules/portfolio-margin/userdata/deleteListenKey.ts @@ -5,40 +5,47 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/userdata/deleteListenKey.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginDeleteListenKey(server: McpServer) { - server.tool( - "BinancePortfolioMarginDeleteListenKey", - "Close/delete a Portfolio Margin listen key. This will terminate the user data stream connection.", - { - listenKey: z.string().optional().describe("Listen key to delete") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.deleteListenKey({ - ...(params.listenKey && { listenKey: params.listenKey }) - }); - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Portfolio Margin Listen Key Deleted\n\nThe listen key has been invalidated.\n\nResponse: ${JSON.stringify(data)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to delete Portfolio Margin listen key: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginDeleteListenKey", + "Close/delete a Portfolio Margin listen key. This will terminate the user data stream connection.", + { + listenKey: z.string().optional().describe("Listen key to delete"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.deleteListenKey({ + ...(params.listenKey && { listenKey: params.listenKey }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Portfolio Margin Listen Key Deleted\n\nThe listen key has been invalidated.\n\nResponse: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to delete Portfolio Margin listen key: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/portfolio-margin/userdata/index.ts b/src/modules/portfolio-margin/userdata/index.ts index 31d3a567..5cf34224 100644 --- a/src/modules/portfolio-margin/userdata/index.ts +++ b/src/modules/portfolio-margin/userdata/index.ts @@ -5,13 +5,14 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/userdata/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerPortfolioMarginCreateListenKey } from "./createListenKey.js"; -import { registerPortfolioMarginRenewListenKey } from "./renewListenKey.js"; -import { registerPortfolioMarginDeleteListenKey } from "./deleteListenKey.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerPortfolioMarginCreateListenKey } from "./createListenKey.js" +import { registerPortfolioMarginDeleteListenKey } from "./deleteListenKey.js" +import { registerPortfolioMarginRenewListenKey } from "./renewListenKey.js" export function registerPortfolioMarginUserdataApi(server: McpServer) { - registerPortfolioMarginCreateListenKey(server); - registerPortfolioMarginRenewListenKey(server); - registerPortfolioMarginDeleteListenKey(server); + registerPortfolioMarginCreateListenKey(server) + registerPortfolioMarginRenewListenKey(server) + registerPortfolioMarginDeleteListenKey(server) } diff --git a/src/modules/portfolio-margin/userdata/renewListenKey.ts b/src/modules/portfolio-margin/userdata/renewListenKey.ts index 9aade0e2..f1da3d9d 100644 --- a/src/modules/portfolio-margin/userdata/renewListenKey.ts +++ b/src/modules/portfolio-margin/userdata/renewListenKey.ts @@ -5,40 +5,47 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/userdata/renewListenKey.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../../config/binanceClient.js" export function registerPortfolioMarginRenewListenKey(server: McpServer) { - server.tool( - "BinancePortfolioMarginRenewListenKey", - "Extend the validity of a Portfolio Margin listen key by 60 minutes.", - { - listenKey: z.string().optional().describe("Listen key to renew") - }, - async (params) => { - try { - const response = await portfolioMarginClient.restAPI.renewListenKey({ - ...(params.listenKey && { listenKey: params.listenKey }) - }); - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Portfolio Margin Listen Key Renewed\n\nThe listen key validity has been extended by 60 minutes.\n\nResponse: ${JSON.stringify(data)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to renew Portfolio Margin listen key: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinancePortfolioMarginRenewListenKey", + "Extend the validity of a Portfolio Margin listen key by 60 minutes.", + { + listenKey: z.string().optional().describe("Listen key to renew"), + }, + async (params) => { + try { + const response = await portfolioMarginClient.restAPI.renewListenKey({ + ...(params.listenKey && { listenKey: params.listenKey }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Portfolio Margin Listen Key Renewed\n\nThe listen key validity has been extended by 60 minutes.\n\nResponse: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to renew Portfolio Margin listen key: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/rebate/index.ts b/src/modules/rebate/index.ts index 5e8d5e72..bd20b0df 100644 --- a/src/modules/rebate/index.ts +++ b/src/modules/rebate/index.ts @@ -1,10 +1,11 @@ // src/tools/binance-rebate/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetSpotRebateHistoryRecords } from "./rebate-api/getSpotRebateHistoryRecords.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceGetSpotRebateHistoryRecords } from "./rebate-api/getSpotRebateHistoryRecords.js" export function registerBinanceRebateTools(server: McpServer) { - registerBinanceGetSpotRebateHistoryRecords(server); + registerBinanceGetSpotRebateHistoryRecords(server) } // Alias for binance.ts compatibility -export { registerBinanceRebateTools as registerRebate }; +export { registerBinanceRebateTools as registerRebate } diff --git a/src/modules/rebate/rebate-api/getSpotRebateHistoryRecords.ts b/src/modules/rebate/rebate-api/getSpotRebateHistoryRecords.ts index c3b46ee8..9a5e6b22 100644 --- a/src/modules/rebate/rebate-api/getSpotRebateHistoryRecords.ts +++ b/src/modules/rebate/rebate-api/getSpotRebateHistoryRecords.ts @@ -1,51 +1,54 @@ // src/tools/binance-pay/rebate-api/getSpotRebateHistoryRecords.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { rebateClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { rebateClient } from "../../../config/binanceClient.js" export function registerBinanceGetSpotRebateHistoryRecords(server: McpServer) { - server.tool( - "BinanceGetSpotRebateHistoryRecords", - "Retrieve the history of spot rebate records, including commission rebates and referral kickbacks, for the past 7 days or a custom date range (within 30 days).", - { - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - page: z.number().int().default(1).describe("Page number, default is 1"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await rebateClient.restAPI.getSpotRebateHistoryRecords({ - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.page && { page: params.page }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetSpotRebateHistoryRecords", + "Retrieve the history of spot rebate records, including commission rebates and referral kickbacks, for the past 7 days or a custom date range (within 30 days).", + { + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + page: z.number().int().default(1).describe("Page number, default is 1"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await rebateClient.restAPI.getSpotRebateHistoryRecords({ + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.page && { page: params.page }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved the history of spot rebate records, including commission rebates and referral kickbacks. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved the history of spot rebate records, including commission rebates and referral kickbacks. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve the history of spot rebate records: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve the history of spot rebate records: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/simple-earn/account-api/getFlexibleProductPosition.ts b/src/modules/simple-earn/account-api/getFlexibleProductPosition.ts index df77fa91..5f2208fc 100644 --- a/src/modules/simple-earn/account-api/getFlexibleProductPosition.ts +++ b/src/modules/simple-earn/account-api/getFlexibleProductPosition.ts @@ -1,59 +1,69 @@ // src/tools/binance-simple-earn/account-api/getFlexibleProductPosition.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { simpleEarnClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { simpleEarnClient } from "../../../config/binanceClient.js" export function registerBinanceGetFlexibleProductPosition(server: McpServer) { - server.tool( - "BinanceGetFlexibleProductPosition", - "Fetch your current holdings in Simple Earn Flexible Products, including total amount, reward rates, and redeem status.", - { - asset: z.string().optional().describe("Asset symbol (optional)"), - productId: z.string().optional().describe("Product ID (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying the page. Starts from 1. Default: 1"), - size: z.number().int().min(1).max(100).default(10).optional().describe("Page size. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await simpleEarnClient.restAPI.getFlexibleProductPosition({ - ...(params.asset && { asset: params.asset }), - ...(params.productId && { productId: params.productId }), - ...(params.current && { current: params.current }), - ...(params.size && { size: params.size }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetFlexibleProductPosition", + "Fetch your current holdings in Simple Earn Flexible Products, including total amount, reward rates, and redeem status.", + { + asset: z.string().optional().describe("Asset symbol (optional)"), + productId: z.string().optional().describe("Product ID (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying the page. Starts from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Page size. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await simpleEarnClient.restAPI.getFlexibleProductPosition({ + ...(params.asset && { asset: params.asset }), + ...(params.productId && { productId: params.productId }), + ...(params.current && { current: params.current }), + ...(params.size && { size: params.size }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully fetched your current holdings in Simple Earn Flexible Products. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully fetched your current holdings in Simple Earn Flexible Products. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to fetch your current holdings in Simple Earn Flexible Products: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to fetch your current holdings in Simple Earn Flexible Products: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/simple-earn/account-api/index.ts b/src/modules/simple-earn/account-api/index.ts index 530448c0..c3800c9b 100644 --- a/src/modules/simple-earn/account-api/index.ts +++ b/src/modules/simple-earn/account-api/index.ts @@ -1,12 +1,13 @@ // src/tools/binance-simple-earn/account-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceSimpleEarnFlexibleProductList } from "./simpleEarnFlexibleProductList.js"; -import { registerBinanceGetFlexibleProductPosition } from "./getFlexibleProductPosition.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceGetFlexibleProductPosition } from "./getFlexibleProductPosition.js" +import { registerBinanceSimpleEarnFlexibleProductList } from "./simpleEarnFlexibleProductList.js" export function registerBinanceSimpleEarnAccountApiTools(server: McpServer) { - // Registers a tool to get the list of flexible earning products - registerBinanceSimpleEarnFlexibleProductList(server); + // Registers a tool to get the list of flexible earning products + registerBinanceSimpleEarnFlexibleProductList(server) - // Registers a tool to get the user's position in flexible earning products - registerBinanceGetFlexibleProductPosition(server); + // Registers a tool to get the user's position in flexible earning products + registerBinanceGetFlexibleProductPosition(server) } diff --git a/src/modules/simple-earn/account-api/simpleEarnFlexibleProductList.ts b/src/modules/simple-earn/account-api/simpleEarnFlexibleProductList.ts index 70fd0e68..a76d9793 100644 --- a/src/modules/simple-earn/account-api/simpleEarnFlexibleProductList.ts +++ b/src/modules/simple-earn/account-api/simpleEarnFlexibleProductList.ts @@ -1,57 +1,67 @@ // src/tools/binance-simple-earn/account-api/simpleEarnFlexibleProductList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { simpleEarnClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { simpleEarnClient } from "../../../config/binanceClient.js" export function registerBinanceSimpleEarnFlexibleProductList(server: McpServer) { - server.tool( - "BinanceSimpleEarnFlexibleProductList", - "Retrieve a list of available Simple Earn Flexible Products, including details like APR, purchase status, and subscription limits.", - { - asset: z.string().optional().describe("Asset symbol (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Starts from 1. Default: 1"), - size: z.number().int().min(1).max(100).default(10).optional().describe("Page size. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await simpleEarnClient.restAPI.getSimpleEarnFlexibleProductList({ - ...(params.asset && { asset: params.asset }), - ...(params.current && { current: params.current }), - ...(params.size && { size: params.size }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSimpleEarnFlexibleProductList", + "Retrieve a list of available Simple Earn Flexible Products, including details like APR, purchase status, and subscription limits.", + { + asset: z.string().optional().describe("Asset symbol (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Starts from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Page size. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await simpleEarnClient.restAPI.getSimpleEarnFlexibleProductList({ + ...(params.asset && { asset: params.asset }), + ...(params.current && { current: params.current }), + ...(params.size && { size: params.size }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieve a list of available Simple Earn Flexible Products. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieve a list of available Simple Earn Flexible Products. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve a list of available Simple Earn Flexible Products: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve a list of available Simple Earn Flexible Products: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/simple-earn/account/getAccount.ts b/src/modules/simple-earn/account/getAccount.ts index 185a0f31..35ae6815 100644 --- a/src/modules/simple-earn/account/getAccount.ts +++ b/src/modules/simple-earn/account/getAccount.ts @@ -5,41 +5,48 @@ * @license Apache-2.0 */ // src/modules/simple-earn/account/getAccount.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { simpleEarnClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { simpleEarnClient } from "../../../config/binanceClient.js" export function registerSimpleEarnAccount(server: McpServer) { - server.tool( - "BinanceSimpleEarnAccount", - "Get your Simple Earn account overview. Shows total amounts in flexible and locked products, and pending rewards.", - { - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await simpleEarnClient.restAPI.getSimpleEarnAccount({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSimpleEarnAccount", + "Get your Simple Earn account overview. Shows total amounts in flexible and locked products, and pending rewards.", + { + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await simpleEarnClient.restAPI.getSimpleEarnAccount({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `💰 Simple Earn Account Overview\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `💰 Simple Earn Account Overview\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get account overview: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to get account overview: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/simple-earn/account/getCollateralRecord.ts b/src/modules/simple-earn/account/getCollateralRecord.ts index f788c2a7..3fde64c5 100644 --- a/src/modules/simple-earn/account/getCollateralRecord.ts +++ b/src/modules/simple-earn/account/getCollateralRecord.ts @@ -5,53 +5,60 @@ * @license Apache-2.0 */ // src/modules/simple-earn/account/getCollateralRecord.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { simpleEarnClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { simpleEarnClient } from "../../../config/binanceClient.js" export function registerSimpleEarnCollateralRecord(server: McpServer) { - server.tool( - "BinanceSimpleEarnCollateralRecord", - "Get your collateral record history for flexible products used as collateral.", - { - productId: z.string().optional().describe("Filter by product ID"), - asset: z.string().optional().describe("Filter by asset"), - startTime: z.number().int().optional().describe("Start time in ms"), - endTime: z.number().int().optional().describe("End time in ms"), - current: z.number().int().min(1).default(1).optional().describe("Page number"), - size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await simpleEarnClient.restAPI.getFlexibleCollateralRecord({ - ...(params.productId && { productId: params.productId }), - ...(params.asset && { asset: params.asset }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.current && { current: params.current }), - ...(params.size && { size: params.size }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSimpleEarnCollateralRecord", + "Get your collateral record history for flexible products used as collateral.", + { + productId: z.string().optional().describe("Filter by product ID"), + asset: z.string().optional().describe("Filter by asset"), + startTime: z.number().int().optional().describe("Start time in ms"), + endTime: z.number().int().optional().describe("End time in ms"), + current: z.number().int().min(1).default(1).optional().describe("Page number"), + size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await simpleEarnClient.restAPI.getFlexibleCollateralRecord({ + ...(params.productId && { productId: params.productId }), + ...(params.asset && { asset: params.asset }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.current && { current: params.current }), + ...(params.size && { size: params.size }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📜 Collateral Records\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `📜 Collateral Records\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get collateral records: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to get collateral records: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/simple-earn/account/getRewardRecord.ts b/src/modules/simple-earn/account/getRewardRecord.ts index 9d6fe94e..ab07dbfa 100644 --- a/src/modules/simple-earn/account/getRewardRecord.ts +++ b/src/modules/simple-earn/account/getRewardRecord.ts @@ -5,55 +5,62 @@ * @license Apache-2.0 */ // src/modules/simple-earn/account/getRewardRecord.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { simpleEarnClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { simpleEarnClient } from "../../../config/binanceClient.js" export function registerSimpleEarnRewardRecord(server: McpServer) { - server.tool( - "BinanceSimpleEarnRewardRecord", - "Get your reward distribution history. Shows all rewards earned from Simple Earn products.", - { - productId: z.string().optional().describe("Filter by product ID"), - asset: z.string().optional().describe("Filter by asset"), - type: z.enum(["BONUS", "REALTIME", "REWARDS"]).optional().describe("Filter by reward type"), - startTime: z.number().int().optional().describe("Start time in ms"), - endTime: z.number().int().optional().describe("End time in ms"), - current: z.number().int().min(1).default(1).optional().describe("Page number"), - size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await simpleEarnClient.restAPI.getFlexibleRewardsRecord({ - ...(params.productId && { productId: params.productId }), - ...(params.asset && { asset: params.asset }), - ...(params.type && { type: params.type }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.current && { current: params.current }), - ...(params.size && { size: params.size }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSimpleEarnRewardRecord", + "Get your reward distribution history. Shows all rewards earned from Simple Earn products.", + { + productId: z.string().optional().describe("Filter by product ID"), + asset: z.string().optional().describe("Filter by asset"), + type: z.enum(["BONUS", "REALTIME", "REWARDS"]).optional().describe("Filter by reward type"), + startTime: z.number().int().optional().describe("Start time in ms"), + endTime: z.number().int().optional().describe("End time in ms"), + current: z.number().int().min(1).default(1).optional().describe("Page number"), + size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await simpleEarnClient.restAPI.getFlexibleRewardsRecord({ + ...(params.productId && { productId: params.productId }), + ...(params.asset && { asset: params.asset }), + ...(params.type && { type: params.type }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.current && { current: params.current }), + ...(params.size && { size: params.size }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `🎁 Reward Records\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `🎁 Reward Records\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get reward records: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to get reward records: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/simple-earn/account/index.ts b/src/modules/simple-earn/account/index.ts index 34dcf263..8b481963 100644 --- a/src/modules/simple-earn/account/index.ts +++ b/src/modules/simple-earn/account/index.ts @@ -5,13 +5,14 @@ * @license Apache-2.0 */ // src/modules/simple-earn/account/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerSimpleEarnAccount } from "./getAccount.js"; -import { registerSimpleEarnCollateralRecord } from "./getCollateralRecord.js"; -import { registerSimpleEarnRewardRecord } from "./getRewardRecord.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerSimpleEarnAccount } from "./getAccount.js" +import { registerSimpleEarnCollateralRecord } from "./getCollateralRecord.js" +import { registerSimpleEarnRewardRecord } from "./getRewardRecord.js" export function registerSimpleEarnAccountTools(server: McpServer) { - registerSimpleEarnAccount(server); - registerSimpleEarnCollateralRecord(server); - registerSimpleEarnRewardRecord(server); + registerSimpleEarnAccount(server) + registerSimpleEarnCollateralRecord(server) + registerSimpleEarnRewardRecord(server) } diff --git a/src/modules/simple-earn/earn-api/index.ts b/src/modules/simple-earn/earn-api/index.ts index 7d2a23e0..219084b7 100644 --- a/src/modules/simple-earn/earn-api/index.ts +++ b/src/modules/simple-earn/earn-api/index.ts @@ -1,12 +1,13 @@ // src/tools/binance-simple-earn/earn-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceSubscribeFlexibleProduct } from "./subscribeFlexibleProduct.js"; -import { registerBinanceRedeemFlexibleProduct } from "./redeemFlexibleProduct.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceRedeemFlexibleProduct } from "./redeemFlexibleProduct.js" +import { registerBinanceSubscribeFlexibleProduct } from "./subscribeFlexibleProduct.js" export function registerBinanceSimpleEarnApiTools(server: McpServer) { - // Register the route for subscribing to a flexible earn product - registerBinanceSubscribeFlexibleProduct(server); + // Register the route for subscribing to a flexible earn product + registerBinanceSubscribeFlexibleProduct(server) - // Register the route for redeeming from a flexible earn product - registerBinanceRedeemFlexibleProduct(server); + // Register the route for redeeming from a flexible earn product + registerBinanceRedeemFlexibleProduct(server) } diff --git a/src/modules/simple-earn/earn-api/redeemFlexibleProduct.ts b/src/modules/simple-earn/earn-api/redeemFlexibleProduct.ts index 13f0fd16..bdb4d1cc 100644 --- a/src/modules/simple-earn/earn-api/redeemFlexibleProduct.ts +++ b/src/modules/simple-earn/earn-api/redeemFlexibleProduct.ts @@ -1,71 +1,78 @@ // src/tools/binance-simple-earn/earn-api/redeemFlexibleProduct.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { simpleEarnClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { simpleEarnClient } from "../../../config/binanceClient.js" export function registerBinanceRedeemFlexibleProduct(server: McpServer) { - server.tool( - "BinanceRedeemFlexibleProduct", - "Allows users to redeem their funds from a Flexible Earn investment product using a programmatic HTTP POST request.", - { - productId: z.string().describe("Product ID"), - redeemAll: z.boolean().optional().describe("true or false, default to false"), - amount: z.number().positive().optional().describe("If redeemAll is false, amount is mandatory"), - destAccount: z - .enum(["SPOT", "FUND"]) - .optional() - .describe("Destination account: SPOT or FUND; default is SPOT"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const { productId, redeemAll = false, amount, destAccount, recvWindow } = params; + server.tool( + "BinanceRedeemFlexibleProduct", + "Allows users to redeem their funds from a Flexible Earn investment product using a programmatic HTTP POST request.", + { + productId: z.string().describe("Product ID"), + redeemAll: z.boolean().optional().describe("true or false, default to false"), + amount: z + .number() + .positive() + .optional() + .describe("If redeemAll is false, amount is mandatory"), + destAccount: z + .enum(["SPOT", "FUND"]) + .optional() + .describe("Destination account: SPOT or FUND; default is SPOT"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const { productId, redeemAll = false, amount, destAccount, recvWindow } = params - // Defensive check - if (!redeemAll && (amount === undefined || amount <= 0)) { - return { - content: [ - { - type: "text", - text: "You must provide a valid amount when redeemAll is false." - } - ], - isError: true - }; - } + // Defensive check + if (!redeemAll && (amount === undefined || amount <= 0)) { + return { + content: [ + { + type: "text", + text: "You must provide a valid amount when redeemAll is false.", + }, + ], + isError: true, + } + } - const response = await simpleEarnClient.restAPI.redeemFlexibleProduct({ - productId, - ...(redeemAll !== undefined && { redeemAll }), - ...(amount !== undefined && { amount }), - ...(destAccount && { destAccount }), - ...(recvWindow && { recvWindow }) - }); + const response = await simpleEarnClient.restAPI.redeemFlexibleProduct({ + productId, + ...(redeemAll !== undefined && { redeemAll }), + ...(amount !== undefined && { amount }), + ...(destAccount && { destAccount }), + ...(recvWindow && { recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully redeem funds from a flexible earn investment. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully redeem funds from a flexible earn investment. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to allows users to redeem their funds from a Flexible Earn investment: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to allows users to redeem their funds from a Flexible Earn investment: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/simple-earn/earn-api/subscribeFlexibleProduct.ts b/src/modules/simple-earn/earn-api/subscribeFlexibleProduct.ts index 5ec0a898..3532c8eb 100644 --- a/src/modules/simple-earn/earn-api/subscribeFlexibleProduct.ts +++ b/src/modules/simple-earn/earn-api/subscribeFlexibleProduct.ts @@ -1,56 +1,59 @@ // src/tools/binance-simple-earn/earn-api/subscribeFlexibleProduct.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { simpleEarnClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { simpleEarnClient } from "../../../config/binanceClient.js" export function registerBinanceSubscribeFlexibleProduct(server: McpServer) { - server.tool( - "BinanceSubscribeFlexibleProduct", - "Subscribe to a Simple Earn Flexible Product by specifying the product ID and amount. Optional parameters include auto-subscribe and source account. ", - { - productId: z.string().describe("Product ID"), - amount: z.number().positive().describe("Amount to purchase"), - autoSubscribe: z.boolean().optional().describe("true or false, default is true"), - sourceAccount: z - .enum(["SPOT", "FUND", "ALL"]) - .optional() - .describe("Source account: SPOT, FUND, or ALL; default is SPOT"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await simpleEarnClient.restAPI.subscribeFlexibleProduct({ - productId: params.productId, - amount: params.amount, - ...(params.autoSubscribe !== undefined && { autoSubscribe: params.autoSubscribe }), - ...(params.sourceAccount && { sourceAccount: params.sourceAccount }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSubscribeFlexibleProduct", + "Subscribe to a Simple Earn Flexible Product by specifying the product ID and amount. Optional parameters include auto-subscribe and source account. ", + { + productId: z.string().describe("Product ID"), + amount: z.number().positive().describe("Amount to purchase"), + autoSubscribe: z.boolean().optional().describe("true or false, default is true"), + sourceAccount: z + .enum(["SPOT", "FUND", "ALL"]) + .optional() + .describe("Source account: SPOT, FUND, or ALL; default is SPOT"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await simpleEarnClient.restAPI.subscribeFlexibleProduct({ + productId: params.productId, + amount: params.amount, + ...(params.autoSubscribe !== undefined && { autoSubscribe: params.autoSubscribe }), + ...(params.sourceAccount && { sourceAccount: params.sourceAccount }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully Subscribed to Simple Earn Flexible Product id ${ + params.productId + } and amount${params.amount}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully Subscribed to Simple Earn Flexible Product id ${ - params.productId - } and amount${params.amount}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to subscribe to a Simple Earn Flexible Product: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to subscribe to a Simple Earn Flexible Product: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/simple-earn/flexible/getFlexiblePosition.ts b/src/modules/simple-earn/flexible/getFlexiblePosition.ts index ca087462..c9328fc6 100644 --- a/src/modules/simple-earn/flexible/getFlexiblePosition.ts +++ b/src/modules/simple-earn/flexible/getFlexiblePosition.ts @@ -5,49 +5,56 @@ * @license Apache-2.0 */ // src/modules/simple-earn/flexible/getFlexiblePosition.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { simpleEarnClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { simpleEarnClient } from "../../../config/binanceClient.js" export function registerSimpleEarnFlexiblePosition(server: McpServer) { - server.tool( - "BinanceSimpleEarnFlexiblePosition", - "Get your current Simple Earn Flexible positions. Shows subscribed amount, cumulative rewards, and APR for each product.", - { - asset: z.string().optional().describe("Filter by asset symbol"), - productId: z.string().optional().describe("Filter by product ID"), - current: z.number().int().min(1).default(1).optional().describe("Page number"), - size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await simpleEarnClient.restAPI.getFlexibleProductPosition({ - ...(params.asset && { asset: params.asset }), - ...(params.productId && { productId: params.productId }), - ...(params.current && { current: params.current }), - ...(params.size && { size: params.size }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSimpleEarnFlexiblePosition", + "Get your current Simple Earn Flexible positions. Shows subscribed amount, cumulative rewards, and APR for each product.", + { + asset: z.string().optional().describe("Filter by asset symbol"), + productId: z.string().optional().describe("Filter by product ID"), + current: z.number().int().min(1).default(1).optional().describe("Page number"), + size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await simpleEarnClient.restAPI.getFlexibleProductPosition({ + ...(params.asset && { asset: params.asset }), + ...(params.productId && { productId: params.productId }), + ...(params.current && { current: params.current }), + ...(params.size && { size: params.size }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📊 Your Flexible Earn Positions\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `📊 Your Flexible Earn Positions\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get flexible positions: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to get flexible positions: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/simple-earn/flexible/getFlexibleProductList.ts b/src/modules/simple-earn/flexible/getFlexibleProductList.ts index 61bdfab3..3f066cef 100644 --- a/src/modules/simple-earn/flexible/getFlexibleProductList.ts +++ b/src/modules/simple-earn/flexible/getFlexibleProductList.ts @@ -5,47 +5,60 @@ * @license Apache-2.0 */ // src/modules/simple-earn/flexible/getFlexibleProductList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { simpleEarnClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { simpleEarnClient } from "../../../config/binanceClient.js" export function registerSimpleEarnFlexibleProductList(server: McpServer) { - server.tool( - "BinanceSimpleEarnFlexibleProductList", - "Get available Simple Earn Flexible products. Returns product details including APR, minimum purchase amount, and availability status.", - { - asset: z.string().optional().describe("Filter by asset symbol (e.g., 'BTC', 'ETH')"), - current: z.number().int().min(1).default(1).optional().describe("Page number, starting from 1"), - size: z.number().int().min(1).max(100).default(10).optional().describe("Page size (1-100)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await simpleEarnClient.restAPI.getSimpleEarnFlexibleProductList({ - ...(params.asset && { asset: params.asset }), - ...(params.current && { current: params.current }), - ...(params.size && { size: params.size }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSimpleEarnFlexibleProductList", + "Get available Simple Earn Flexible products. Returns product details including APR, minimum purchase amount, and availability status.", + { + asset: z.string().optional().describe("Filter by asset symbol (e.g., 'BTC', 'ETH')"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Page number, starting from 1"), + size: z.number().int().min(1).max(100).default(10).optional().describe("Page size (1-100)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await simpleEarnClient.restAPI.getSimpleEarnFlexibleProductList({ + ...(params.asset && { asset: params.asset }), + ...(params.current && { current: params.current }), + ...(params.size && { size: params.size }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📋 Simple Earn Flexible Products\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `📋 Simple Earn Flexible Products\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get flexible product list: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to get flexible product list: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/simple-earn/flexible/getFlexibleSubscriptionPreview.ts b/src/modules/simple-earn/flexible/getFlexibleSubscriptionPreview.ts index 16fe7231..3021571e 100644 --- a/src/modules/simple-earn/flexible/getFlexibleSubscriptionPreview.ts +++ b/src/modules/simple-earn/flexible/getFlexibleSubscriptionPreview.ts @@ -5,45 +5,52 @@ * @license Apache-2.0 */ // src/modules/simple-earn/flexible/getFlexibleSubscriptionPreview.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { simpleEarnClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { simpleEarnClient } from "../../../config/binanceClient.js" export function registerSimpleEarnFlexibleSubscriptionPreview(server: McpServer) { - server.tool( - "BinanceSimpleEarnFlexibleSubscriptionPreview", - "Preview a flexible product subscription before committing. Shows expected rewards and next interest date.", - { - productId: z.string().describe("Product ID to preview"), - amount: z.number().positive().describe("Amount to preview subscription for"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await simpleEarnClient.restAPI.getFlexibleSubscriptionPreview({ - productId: params.productId, - amount: params.amount, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSimpleEarnFlexibleSubscriptionPreview", + "Preview a flexible product subscription before committing. Shows expected rewards and next interest date.", + { + productId: z.string().describe("Product ID to preview"), + amount: z.number().positive().describe("Amount to preview subscription for"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await simpleEarnClient.restAPI.getFlexibleSubscriptionPreview({ + productId: params.productId, + amount: params.amount, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `🔮 Subscription Preview\n\nProduct ID: ${params.productId}\nAmount: ${params.amount}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `🔮 Subscription Preview\n\nProduct ID: ${params.productId}\nAmount: ${params.amount}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to preview subscription: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to preview subscription: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/simple-earn/flexible/getRateHistory.ts b/src/modules/simple-earn/flexible/getRateHistory.ts index 8f4e71de..b45a4799 100644 --- a/src/modules/simple-earn/flexible/getRateHistory.ts +++ b/src/modules/simple-earn/flexible/getRateHistory.ts @@ -5,51 +5,58 @@ * @license Apache-2.0 */ // src/modules/simple-earn/flexible/getRateHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { simpleEarnClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { simpleEarnClient } from "../../../config/binanceClient.js" export function registerSimpleEarnFlexibleRateHistory(server: McpServer) { - server.tool( - "BinanceSimpleEarnFlexibleRateHistory", - "Get historical APR rates for a flexible product. Useful for analyzing rate trends and making informed investment decisions.", - { - productId: z.string().describe("Product ID to get rate history for"), - startTime: z.number().int().optional().describe("Start time in ms"), - endTime: z.number().int().optional().describe("End time in ms"), - current: z.number().int().min(1).default(1).optional().describe("Page number"), - size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await simpleEarnClient.restAPI.getFlexibleRateHistory({ - productId: params.productId, - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.current && { current: params.current }), - ...(params.size && { size: params.size }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSimpleEarnFlexibleRateHistory", + "Get historical APR rates for a flexible product. Useful for analyzing rate trends and making informed investment decisions.", + { + productId: z.string().describe("Product ID to get rate history for"), + startTime: z.number().int().optional().describe("Start time in ms"), + endTime: z.number().int().optional().describe("End time in ms"), + current: z.number().int().min(1).default(1).optional().describe("Page number"), + size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await simpleEarnClient.restAPI.getFlexibleRateHistory({ + productId: params.productId, + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.current && { current: params.current }), + ...(params.size && { size: params.size }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📈 Flexible Product Rate History\n\nProduct ID: ${params.productId}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `📈 Flexible Product Rate History\n\nProduct ID: ${params.productId}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get rate history: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to get rate history: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/simple-earn/flexible/getRedemptionRecord.ts b/src/modules/simple-earn/flexible/getRedemptionRecord.ts index 9a672005..45f3910b 100644 --- a/src/modules/simple-earn/flexible/getRedemptionRecord.ts +++ b/src/modules/simple-earn/flexible/getRedemptionRecord.ts @@ -5,55 +5,62 @@ * @license Apache-2.0 */ // src/modules/simple-earn/flexible/getRedemptionRecord.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { simpleEarnClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { simpleEarnClient } from "../../../config/binanceClient.js" export function registerSimpleEarnFlexibleRedemptionRecord(server: McpServer) { - server.tool( - "BinanceSimpleEarnFlexibleRedemptionRecord", - "Get your flexible product redemption history. Shows all past redemptions with amounts, dates, and status.", - { - productId: z.string().optional().describe("Filter by product ID"), - redeemId: z.string().optional().describe("Filter by redemption ID"), - asset: z.string().optional().describe("Filter by asset"), - startTime: z.number().int().optional().describe("Start time in ms"), - endTime: z.number().int().optional().describe("End time in ms"), - current: z.number().int().min(1).default(1).optional().describe("Page number"), - size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await simpleEarnClient.restAPI.getFlexibleRedemptionRecord({ - ...(params.productId && { productId: params.productId }), - ...(params.redeemId && { redeemId: params.redeemId }), - ...(params.asset && { asset: params.asset }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.current && { current: params.current }), - ...(params.size && { size: params.size }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSimpleEarnFlexibleRedemptionRecord", + "Get your flexible product redemption history. Shows all past redemptions with amounts, dates, and status.", + { + productId: z.string().optional().describe("Filter by product ID"), + redeemId: z.string().optional().describe("Filter by redemption ID"), + asset: z.string().optional().describe("Filter by asset"), + startTime: z.number().int().optional().describe("Start time in ms"), + endTime: z.number().int().optional().describe("End time in ms"), + current: z.number().int().min(1).default(1).optional().describe("Page number"), + size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await simpleEarnClient.restAPI.getFlexibleRedemptionRecord({ + ...(params.productId && { productId: params.productId }), + ...(params.redeemId && { redeemId: params.redeemId }), + ...(params.asset && { asset: params.asset }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.current && { current: params.current }), + ...(params.size && { size: params.size }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📜 Flexible Redemption Records\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `📜 Flexible Redemption Records\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get redemption records: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to get redemption records: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/simple-earn/flexible/getSubscriptionRecord.ts b/src/modules/simple-earn/flexible/getSubscriptionRecord.ts index aa368a72..d7405194 100644 --- a/src/modules/simple-earn/flexible/getSubscriptionRecord.ts +++ b/src/modules/simple-earn/flexible/getSubscriptionRecord.ts @@ -5,55 +5,62 @@ * @license Apache-2.0 */ // src/modules/simple-earn/flexible/getSubscriptionRecord.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { simpleEarnClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { simpleEarnClient } from "../../../config/binanceClient.js" export function registerSimpleEarnFlexibleSubscriptionRecord(server: McpServer) { - server.tool( - "BinanceSimpleEarnFlexibleSubscriptionRecord", - "Get your flexible product subscription history. Shows all past subscriptions with amounts, dates, and status.", - { - productId: z.string().optional().describe("Filter by product ID"), - purchaseId: z.string().optional().describe("Filter by purchase ID"), - asset: z.string().optional().describe("Filter by asset"), - startTime: z.number().int().optional().describe("Start time in ms"), - endTime: z.number().int().optional().describe("End time in ms"), - current: z.number().int().min(1).default(1).optional().describe("Page number"), - size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await simpleEarnClient.restAPI.getFlexibleSubscriptionRecord({ - ...(params.productId && { productId: params.productId }), - ...(params.purchaseId && { purchaseId: params.purchaseId }), - ...(params.asset && { asset: params.asset }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.current && { current: params.current }), - ...(params.size && { size: params.size }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSimpleEarnFlexibleSubscriptionRecord", + "Get your flexible product subscription history. Shows all past subscriptions with amounts, dates, and status.", + { + productId: z.string().optional().describe("Filter by product ID"), + purchaseId: z.string().optional().describe("Filter by purchase ID"), + asset: z.string().optional().describe("Filter by asset"), + startTime: z.number().int().optional().describe("Start time in ms"), + endTime: z.number().int().optional().describe("End time in ms"), + current: z.number().int().min(1).default(1).optional().describe("Page number"), + size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await simpleEarnClient.restAPI.getFlexibleSubscriptionRecord({ + ...(params.productId && { productId: params.productId }), + ...(params.purchaseId && { purchaseId: params.purchaseId }), + ...(params.asset && { asset: params.asset }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.current && { current: params.current }), + ...(params.size && { size: params.size }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📜 Flexible Subscription Records\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `📜 Flexible Subscription Records\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get subscription records: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to get subscription records: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/simple-earn/flexible/index.ts b/src/modules/simple-earn/flexible/index.ts index f34ea944..097acc91 100644 --- a/src/modules/simple-earn/flexible/index.ts +++ b/src/modules/simple-earn/flexible/index.ts @@ -5,23 +5,24 @@ * @license Apache-2.0 */ // src/modules/simple-earn/flexible/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerSimpleEarnFlexibleProductList } from "./getFlexibleProductList.js"; -import { registerSimpleEarnSubscribeFlexible } from "./subscribeFlexible.js"; -import { registerSimpleEarnRedeemFlexible } from "./redeemFlexible.js"; -import { registerSimpleEarnFlexiblePosition } from "./getFlexiblePosition.js"; -import { registerSimpleEarnFlexibleSubscriptionPreview } from "./getFlexibleSubscriptionPreview.js"; -import { registerSimpleEarnFlexibleRateHistory } from "./getRateHistory.js"; -import { registerSimpleEarnFlexibleSubscriptionRecord } from "./getSubscriptionRecord.js"; -import { registerSimpleEarnFlexibleRedemptionRecord } from "./getRedemptionRecord.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerSimpleEarnFlexiblePosition } from "./getFlexiblePosition.js" +import { registerSimpleEarnFlexibleProductList } from "./getFlexibleProductList.js" +import { registerSimpleEarnFlexibleSubscriptionPreview } from "./getFlexibleSubscriptionPreview.js" +import { registerSimpleEarnFlexibleRateHistory } from "./getRateHistory.js" +import { registerSimpleEarnFlexibleRedemptionRecord } from "./getRedemptionRecord.js" +import { registerSimpleEarnFlexibleSubscriptionRecord } from "./getSubscriptionRecord.js" +import { registerSimpleEarnRedeemFlexible } from "./redeemFlexible.js" +import { registerSimpleEarnSubscribeFlexible } from "./subscribeFlexible.js" export function registerSimpleEarnFlexibleTools(server: McpServer) { - registerSimpleEarnFlexibleProductList(server); - registerSimpleEarnSubscribeFlexible(server); - registerSimpleEarnRedeemFlexible(server); - registerSimpleEarnFlexiblePosition(server); - registerSimpleEarnFlexibleSubscriptionPreview(server); - registerSimpleEarnFlexibleRateHistory(server); - registerSimpleEarnFlexibleSubscriptionRecord(server); - registerSimpleEarnFlexibleRedemptionRecord(server); + registerSimpleEarnFlexibleProductList(server) + registerSimpleEarnSubscribeFlexible(server) + registerSimpleEarnRedeemFlexible(server) + registerSimpleEarnFlexiblePosition(server) + registerSimpleEarnFlexibleSubscriptionPreview(server) + registerSimpleEarnFlexibleRateHistory(server) + registerSimpleEarnFlexibleSubscriptionRecord(server) + registerSimpleEarnFlexibleRedemptionRecord(server) } diff --git a/src/modules/simple-earn/flexible/redeemFlexible.ts b/src/modules/simple-earn/flexible/redeemFlexible.ts index 9664b62d..30602c48 100644 --- a/src/modules/simple-earn/flexible/redeemFlexible.ts +++ b/src/modules/simple-earn/flexible/redeemFlexible.ts @@ -5,49 +5,63 @@ * @license Apache-2.0 */ // src/modules/simple-earn/flexible/redeemFlexible.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { simpleEarnClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { simpleEarnClient } from "../../../config/binanceClient.js" export function registerSimpleEarnRedeemFlexible(server: McpServer) { - server.tool( - "BinanceSimpleEarnFlexibleRedeem", - "Redeem from a Simple Earn Flexible product. Funds are returned to your spot wallet. 💸 Instant redemption available!", - { - productId: z.string().describe("Product ID to redeem from"), - redeemAll: z.boolean().optional().describe("Redeem all position (true/false)"), - amount: z.number().positive().optional().describe("Amount to redeem (required if redeemAll is false)"), - destAccount: z.enum(["SPOT", "FUND"]).optional().describe("Destination account (default: SPOT)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await simpleEarnClient.restAPI.redeemFlexibleProduct({ - productId: params.productId, - ...(params.redeemAll !== undefined && { redeemAll: params.redeemAll }), - ...(params.amount && { amount: params.amount }), - ...(params.destAccount && { destAccount: params.destAccount }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSimpleEarnFlexibleRedeem", + "Redeem from a Simple Earn Flexible product. Funds are returned to your spot wallet. 💸 Instant redemption available!", + { + productId: z.string().describe("Product ID to redeem from"), + redeemAll: z.boolean().optional().describe("Redeem all position (true/false)"), + amount: z + .number() + .positive() + .optional() + .describe("Amount to redeem (required if redeemAll is false)"), + destAccount: z + .enum(["SPOT", "FUND"]) + .optional() + .describe("Destination account (default: SPOT)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await simpleEarnClient.restAPI.redeemFlexibleProduct({ + productId: params.productId, + ...(params.redeemAll !== undefined && { redeemAll: params.redeemAll }), + ...(params.amount && { amount: params.amount }), + ...(params.destAccount && { destAccount: params.destAccount }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Flexible Product Redemption Successful!\n\nProduct ID: ${params.productId}\nAmount: ${params.redeemAll ? "All" : params.amount}\nRedemption ID: ${data.redeemId || "N/A"}\n\n💡 Funds will be credited to your ${params.destAccount || "SPOT"} account shortly.`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `✅ Flexible Product Redemption Successful!\n\nProduct ID: ${params.productId}\nAmount: ${params.redeemAll ? 'All' : params.amount}\nRedemption ID: ${data.redeemId || 'N/A'}\n\n💡 Funds will be credited to your ${params.destAccount || 'SPOT'} account shortly.` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to redeem flexible product: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to redeem flexible product: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/simple-earn/flexible/subscribeFlexible.ts b/src/modules/simple-earn/flexible/subscribeFlexible.ts index a06ea01d..4f381a8f 100644 --- a/src/modules/simple-earn/flexible/subscribeFlexible.ts +++ b/src/modules/simple-earn/flexible/subscribeFlexible.ts @@ -5,50 +5,62 @@ * @license Apache-2.0 */ // src/modules/simple-earn/flexible/subscribeFlexible.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { simpleEarnClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { simpleEarnClient } from "../../../config/binanceClient.js" export function registerSimpleEarnSubscribeFlexible(server: McpServer) { - server.tool( - "BinanceSimpleEarnFlexibleSubscribe", - "Subscribe to a Simple Earn Flexible product to earn daily rewards. Funds can be redeemed anytime. 💰 Start earning passive income on your crypto!", - { - productId: z.string().describe("Product ID from flexible product list"), - amount: z.number().positive().describe("Amount to subscribe"), - autoSubscribe: z.boolean().optional().describe("Auto-subscribe on redemption (default: true)"), - sourceAccount: z.enum(["SPOT", "FUND", "ALL"]).optional() - .describe("Source account for funds (default: SPOT)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await simpleEarnClient.restAPI.subscribeFlexibleProduct({ - productId: params.productId, - amount: params.amount, - ...(params.autoSubscribe !== undefined && { autoSubscribe: params.autoSubscribe }), - ...(params.sourceAccount && { sourceAccount: params.sourceAccount }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSimpleEarnFlexibleSubscribe", + "Subscribe to a Simple Earn Flexible product to earn daily rewards. Funds can be redeemed anytime. 💰 Start earning passive income on your crypto!", + { + productId: z.string().describe("Product ID from flexible product list"), + amount: z.number().positive().describe("Amount to subscribe"), + autoSubscribe: z + .boolean() + .optional() + .describe("Auto-subscribe on redemption (default: true)"), + sourceAccount: z + .enum(["SPOT", "FUND", "ALL"]) + .optional() + .describe("Source account for funds (default: SPOT)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await simpleEarnClient.restAPI.subscribeFlexibleProduct({ + productId: params.productId, + amount: params.amount, + ...(params.autoSubscribe !== undefined && { autoSubscribe: params.autoSubscribe }), + ...(params.sourceAccount && { sourceAccount: params.sourceAccount }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Flexible Product Subscription Successful!\n\nProduct ID: ${params.productId}\nAmount: ${params.amount}\nPurchase ID: ${data.purchaseId || "N/A"}\n\n💡 Your funds will start earning rewards within 24 hours.`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `✅ Flexible Product Subscription Successful!\n\nProduct ID: ${params.productId}\nAmount: ${params.amount}\nPurchase ID: ${data.purchaseId || 'N/A'}\n\n💡 Your funds will start earning rewards within 24 hours.` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to subscribe to flexible product: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to subscribe to flexible product: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/simple-earn/index.ts b/src/modules/simple-earn/index.ts index 6d0e39fa..a50c7ea9 100644 --- a/src/modules/simple-earn/index.ts +++ b/src/modules/simple-earn/index.ts @@ -1,15 +1,16 @@ // src/tools/binance-simple-earn/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceSimpleEarnApiTools } from "./earn-api/index.js"; -import { registerBinanceSimpleEarnAccountApiTools } from "./account-api/index.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceSimpleEarnAccountApiTools } from "./account-api/index.js" +import { registerBinanceSimpleEarnApiTools } from "./earn-api/index.js" export function registerBinanceSimpleEarnTools(server: McpServer) { - // Registers core API tools like subscribing to flexible products - registerBinanceSimpleEarnApiTools(server); + // Registers core API tools like subscribing to flexible products + registerBinanceSimpleEarnApiTools(server) - // Registers account-related tools like viewing product lists and positions - registerBinanceSimpleEarnAccountApiTools(server); + // Registers account-related tools like viewing product lists and positions + registerBinanceSimpleEarnAccountApiTools(server) } // Alias for binance.ts compatibility -export { registerBinanceSimpleEarnTools as registerSimpleEarn }; +export { registerBinanceSimpleEarnTools as registerSimpleEarn } diff --git a/src/modules/simple-earn/locked/getLockedPersonalQuota.ts b/src/modules/simple-earn/locked/getLockedPersonalQuota.ts index d7030053..ee55e664 100644 --- a/src/modules/simple-earn/locked/getLockedPersonalQuota.ts +++ b/src/modules/simple-earn/locked/getLockedPersonalQuota.ts @@ -5,43 +5,50 @@ * @license Apache-2.0 */ // src/modules/simple-earn/locked/getLockedPersonalQuota.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { simpleEarnClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { simpleEarnClient } from "../../../config/binanceClient.js" export function registerSimpleEarnLockedPersonalQuota(server: McpServer) { - server.tool( - "BinanceSimpleEarnLockedPersonalQuota", - "Get your personal subscription quota for a locked product. Shows remaining quota available to subscribe.", - { - projectId: z.string().describe("Project ID to check quota for"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await simpleEarnClient.restAPI.getLockedPersonalLeftQuota({ - projectId: params.projectId, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSimpleEarnLockedPersonalQuota", + "Get your personal subscription quota for a locked product. Shows remaining quota available to subscribe.", + { + projectId: z.string().describe("Project ID to check quota for"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await simpleEarnClient.restAPI.getLockedPersonalLeftQuota({ + projectId: params.projectId, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📊 Personal Quota for Project ${params.projectId}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `📊 Personal Quota for Project ${params.projectId}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get personal quota: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to get personal quota: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/simple-earn/locked/getLockedPosition.ts b/src/modules/simple-earn/locked/getLockedPosition.ts index 34be903e..65ce81e2 100644 --- a/src/modules/simple-earn/locked/getLockedPosition.ts +++ b/src/modules/simple-earn/locked/getLockedPosition.ts @@ -5,51 +5,58 @@ * @license Apache-2.0 */ // src/modules/simple-earn/locked/getLockedPosition.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { simpleEarnClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { simpleEarnClient } from "../../../config/binanceClient.js" export function registerSimpleEarnLockedPosition(server: McpServer) { - server.tool( - "BinanceSimpleEarnLockedPosition", - "Get your current Simple Earn Locked positions. Shows locked amount, rewards, maturity date, and APR.", - { - asset: z.string().optional().describe("Filter by asset symbol"), - positionId: z.string().optional().describe("Filter by position ID"), - projectId: z.string().optional().describe("Filter by project ID"), - current: z.number().int().min(1).default(1).optional().describe("Page number"), - size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await simpleEarnClient.restAPI.getLockedProductPosition({ - ...(params.asset && { asset: params.asset }), - ...(params.positionId && { positionId: params.positionId }), - ...(params.projectId && { projectId: params.projectId }), - ...(params.current && { current: params.current }), - ...(params.size && { size: params.size }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSimpleEarnLockedPosition", + "Get your current Simple Earn Locked positions. Shows locked amount, rewards, maturity date, and APR.", + { + asset: z.string().optional().describe("Filter by asset symbol"), + positionId: z.string().optional().describe("Filter by position ID"), + projectId: z.string().optional().describe("Filter by project ID"), + current: z.number().int().min(1).default(1).optional().describe("Page number"), + size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await simpleEarnClient.restAPI.getLockedProductPosition({ + ...(params.asset && { asset: params.asset }), + ...(params.positionId && { positionId: params.positionId }), + ...(params.projectId && { projectId: params.projectId }), + ...(params.current && { current: params.current }), + ...(params.size && { size: params.size }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📊 Your Locked Earn Positions\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `📊 Your Locked Earn Positions\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get locked positions: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to get locked positions: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/simple-earn/locked/getLockedProductList.ts b/src/modules/simple-earn/locked/getLockedProductList.ts index da7189c8..ed0d2208 100644 --- a/src/modules/simple-earn/locked/getLockedProductList.ts +++ b/src/modules/simple-earn/locked/getLockedProductList.ts @@ -5,47 +5,60 @@ * @license Apache-2.0 */ // src/modules/simple-earn/locked/getLockedProductList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { simpleEarnClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { simpleEarnClient } from "../../../config/binanceClient.js" export function registerSimpleEarnLockedProductList(server: McpServer) { - server.tool( - "BinanceSimpleEarnLockedProductList", - "Get available Simple Earn Locked products. Locked products offer higher APR in exchange for locking funds for a fixed duration.", - { - asset: z.string().optional().describe("Filter by asset symbol (e.g., 'BTC', 'ETH')"), - current: z.number().int().min(1).default(1).optional().describe("Page number, starting from 1"), - size: z.number().int().min(1).max(100).default(10).optional().describe("Page size (1-100)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await simpleEarnClient.restAPI.getSimpleEarnLockedProductList({ - ...(params.asset && { asset: params.asset }), - ...(params.current && { current: params.current }), - ...(params.size && { size: params.size }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSimpleEarnLockedProductList", + "Get available Simple Earn Locked products. Locked products offer higher APR in exchange for locking funds for a fixed duration.", + { + asset: z.string().optional().describe("Filter by asset symbol (e.g., 'BTC', 'ETH')"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Page number, starting from 1"), + size: z.number().int().min(1).max(100).default(10).optional().describe("Page size (1-100)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await simpleEarnClient.restAPI.getSimpleEarnLockedProductList({ + ...(params.asset && { asset: params.asset }), + ...(params.current && { current: params.current }), + ...(params.size && { size: params.size }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📋 Simple Earn Locked Products\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `📋 Simple Earn Locked Products\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get locked product list: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to get locked product list: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/simple-earn/locked/getLockedSubscriptionPreview.ts b/src/modules/simple-earn/locked/getLockedSubscriptionPreview.ts index f4dab642..a3be3f6c 100644 --- a/src/modules/simple-earn/locked/getLockedSubscriptionPreview.ts +++ b/src/modules/simple-earn/locked/getLockedSubscriptionPreview.ts @@ -5,47 +5,54 @@ * @license Apache-2.0 */ // src/modules/simple-earn/locked/getLockedSubscriptionPreview.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { simpleEarnClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { simpleEarnClient } from "../../../config/binanceClient.js" export function registerSimpleEarnLockedSubscriptionPreview(server: McpServer) { - server.tool( - "BinanceSimpleEarnLockedSubscriptionPreview", - "Preview a locked product subscription before committing. Shows expected rewards, lock duration, and maturity date.", - { - projectId: z.string().describe("Project ID to preview"), - amount: z.number().positive().describe("Amount to preview subscription for"), - autoSubscribe: z.boolean().optional().describe("Include auto-subscribe in preview"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await simpleEarnClient.restAPI.getLockedSubscriptionPreview({ - projectId: params.projectId, - amount: params.amount, - ...(params.autoSubscribe !== undefined && { autoSubscribe: params.autoSubscribe }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSimpleEarnLockedSubscriptionPreview", + "Preview a locked product subscription before committing. Shows expected rewards, lock duration, and maturity date.", + { + projectId: z.string().describe("Project ID to preview"), + amount: z.number().positive().describe("Amount to preview subscription for"), + autoSubscribe: z.boolean().optional().describe("Include auto-subscribe in preview"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await simpleEarnClient.restAPI.getLockedSubscriptionPreview({ + projectId: params.projectId, + amount: params.amount, + ...(params.autoSubscribe !== undefined && { autoSubscribe: params.autoSubscribe }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `🔮 Locked Subscription Preview\n\nProject ID: ${params.projectId}\nAmount: ${params.amount}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `🔮 Locked Subscription Preview\n\nProject ID: ${params.projectId}\nAmount: ${params.amount}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to preview subscription: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to preview subscription: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/simple-earn/locked/getRedemptionRecord.ts b/src/modules/simple-earn/locked/getRedemptionRecord.ts index ad82fb74..f868f809 100644 --- a/src/modules/simple-earn/locked/getRedemptionRecord.ts +++ b/src/modules/simple-earn/locked/getRedemptionRecord.ts @@ -5,55 +5,62 @@ * @license Apache-2.0 */ // src/modules/simple-earn/locked/getRedemptionRecord.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { simpleEarnClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { simpleEarnClient } from "../../../config/binanceClient.js" export function registerSimpleEarnLockedRedemptionRecord(server: McpServer) { - server.tool( - "BinanceSimpleEarnLockedRedemptionRecord", - "Get your locked product redemption history. Shows all redemptions including early redemptions and matured positions.", - { - positionId: z.string().optional().describe("Filter by position ID"), - redeemId: z.string().optional().describe("Filter by redemption ID"), - asset: z.string().optional().describe("Filter by asset"), - startTime: z.number().int().optional().describe("Start time in ms"), - endTime: z.number().int().optional().describe("End time in ms"), - current: z.number().int().min(1).default(1).optional().describe("Page number"), - size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await simpleEarnClient.restAPI.getLockedRedemptionRecord({ - ...(params.positionId && { positionId: params.positionId }), - ...(params.redeemId && { redeemId: params.redeemId }), - ...(params.asset && { asset: params.asset }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.current && { current: params.current }), - ...(params.size && { size: params.size }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSimpleEarnLockedRedemptionRecord", + "Get your locked product redemption history. Shows all redemptions including early redemptions and matured positions.", + { + positionId: z.string().optional().describe("Filter by position ID"), + redeemId: z.string().optional().describe("Filter by redemption ID"), + asset: z.string().optional().describe("Filter by asset"), + startTime: z.number().int().optional().describe("Start time in ms"), + endTime: z.number().int().optional().describe("End time in ms"), + current: z.number().int().min(1).default(1).optional().describe("Page number"), + size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await simpleEarnClient.restAPI.getLockedRedemptionRecord({ + ...(params.positionId && { positionId: params.positionId }), + ...(params.redeemId && { redeemId: params.redeemId }), + ...(params.asset && { asset: params.asset }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.current && { current: params.current }), + ...(params.size && { size: params.size }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📜 Locked Redemption Records\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `📜 Locked Redemption Records\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get redemption records: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to get redemption records: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/simple-earn/locked/getSubscriptionRecord.ts b/src/modules/simple-earn/locked/getSubscriptionRecord.ts index 5a9f4a65..d2032293 100644 --- a/src/modules/simple-earn/locked/getSubscriptionRecord.ts +++ b/src/modules/simple-earn/locked/getSubscriptionRecord.ts @@ -5,53 +5,60 @@ * @license Apache-2.0 */ // src/modules/simple-earn/locked/getSubscriptionRecord.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { simpleEarnClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { simpleEarnClient } from "../../../config/binanceClient.js" export function registerSimpleEarnLockedSubscriptionRecord(server: McpServer) { - server.tool( - "BinanceSimpleEarnLockedSubscriptionRecord", - "Get your locked product subscription history. Shows all past subscriptions with amounts, dates, and status.", - { - purchaseId: z.string().optional().describe("Filter by purchase ID"), - asset: z.string().optional().describe("Filter by asset"), - startTime: z.number().int().optional().describe("Start time in ms"), - endTime: z.number().int().optional().describe("End time in ms"), - current: z.number().int().min(1).default(1).optional().describe("Page number"), - size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await simpleEarnClient.restAPI.getLockedSubscriptionRecord({ - ...(params.purchaseId && { purchaseId: params.purchaseId }), - ...(params.asset && { asset: params.asset }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.current && { current: params.current }), - ...(params.size && { size: params.size }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSimpleEarnLockedSubscriptionRecord", + "Get your locked product subscription history. Shows all past subscriptions with amounts, dates, and status.", + { + purchaseId: z.string().optional().describe("Filter by purchase ID"), + asset: z.string().optional().describe("Filter by asset"), + startTime: z.number().int().optional().describe("Start time in ms"), + endTime: z.number().int().optional().describe("End time in ms"), + current: z.number().int().min(1).default(1).optional().describe("Page number"), + size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await simpleEarnClient.restAPI.getLockedSubscriptionRecord({ + ...(params.purchaseId && { purchaseId: params.purchaseId }), + ...(params.asset && { asset: params.asset }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.current && { current: params.current }), + ...(params.size && { size: params.size }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📜 Locked Subscription Records\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `📜 Locked Subscription Records\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to get subscription records: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to get subscription records: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/simple-earn/locked/index.ts b/src/modules/simple-earn/locked/index.ts index aa52a9c2..bea4c81c 100644 --- a/src/modules/simple-earn/locked/index.ts +++ b/src/modules/simple-earn/locked/index.ts @@ -5,25 +5,26 @@ * @license Apache-2.0 */ // src/modules/simple-earn/locked/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerSimpleEarnLockedProductList } from "./getLockedProductList.js"; -import { registerSimpleEarnSubscribeLocked } from "./subscribeLocked.js"; -import { registerSimpleEarnRedeemLocked } from "./redeemLocked.js"; -import { registerSimpleEarnLockedPosition } from "./getLockedPosition.js"; -import { registerSimpleEarnLockedSubscriptionPreview } from "./getLockedSubscriptionPreview.js"; -import { registerSimpleEarnSetAutoSubscribe } from "./setAutoSubscribe.js"; -import { registerSimpleEarnLockedPersonalQuota } from "./getLockedPersonalQuota.js"; -import { registerSimpleEarnLockedSubscriptionRecord } from "./getSubscriptionRecord.js"; -import { registerSimpleEarnLockedRedemptionRecord } from "./getRedemptionRecord.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerSimpleEarnLockedPersonalQuota } from "./getLockedPersonalQuota.js" +import { registerSimpleEarnLockedPosition } from "./getLockedPosition.js" +import { registerSimpleEarnLockedProductList } from "./getLockedProductList.js" +import { registerSimpleEarnLockedSubscriptionPreview } from "./getLockedSubscriptionPreview.js" +import { registerSimpleEarnLockedRedemptionRecord } from "./getRedemptionRecord.js" +import { registerSimpleEarnLockedSubscriptionRecord } from "./getSubscriptionRecord.js" +import { registerSimpleEarnRedeemLocked } from "./redeemLocked.js" +import { registerSimpleEarnSetAutoSubscribe } from "./setAutoSubscribe.js" +import { registerSimpleEarnSubscribeLocked } from "./subscribeLocked.js" export function registerSimpleEarnLockedTools(server: McpServer) { - registerSimpleEarnLockedProductList(server); - registerSimpleEarnSubscribeLocked(server); - registerSimpleEarnRedeemLocked(server); - registerSimpleEarnLockedPosition(server); - registerSimpleEarnLockedSubscriptionPreview(server); - registerSimpleEarnSetAutoSubscribe(server); - registerSimpleEarnLockedPersonalQuota(server); - registerSimpleEarnLockedSubscriptionRecord(server); - registerSimpleEarnLockedRedemptionRecord(server); + registerSimpleEarnLockedProductList(server) + registerSimpleEarnSubscribeLocked(server) + registerSimpleEarnRedeemLocked(server) + registerSimpleEarnLockedPosition(server) + registerSimpleEarnLockedSubscriptionPreview(server) + registerSimpleEarnSetAutoSubscribe(server) + registerSimpleEarnLockedPersonalQuota(server) + registerSimpleEarnLockedSubscriptionRecord(server) + registerSimpleEarnLockedRedemptionRecord(server) } diff --git a/src/modules/simple-earn/locked/redeemLocked.ts b/src/modules/simple-earn/locked/redeemLocked.ts index ab790156..e9a88b57 100644 --- a/src/modules/simple-earn/locked/redeemLocked.ts +++ b/src/modules/simple-earn/locked/redeemLocked.ts @@ -5,43 +5,50 @@ * @license Apache-2.0 */ // src/modules/simple-earn/locked/redeemLocked.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { simpleEarnClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { simpleEarnClient } from "../../../config/binanceClient.js" export function registerSimpleEarnRedeemLocked(server: McpServer) { - server.tool( - "BinanceSimpleEarnLockedRedeem", - "Redeem from a Simple Earn Locked product. ⚠️ Early redemption may forfeit rewards. Check product terms first.", - { - positionId: z.string().describe("Position ID to redeem"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await simpleEarnClient.restAPI.redeemLockedProduct({ - positionId: params.positionId, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSimpleEarnLockedRedeem", + "Redeem from a Simple Earn Locked product. ⚠️ Early redemption may forfeit rewards. Check product terms first.", + { + positionId: z.string().describe("Position ID to redeem"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await simpleEarnClient.restAPI.redeemLockedProduct({ + positionId: params.positionId, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Locked Product Redemption Initiated!\n\nPosition ID: ${params.positionId}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `✅ Locked Product Redemption Initiated!\n\nPosition ID: ${params.positionId}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to redeem locked product: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to redeem locked product: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/simple-earn/locked/setAutoSubscribe.ts b/src/modules/simple-earn/locked/setAutoSubscribe.ts index 88daaa0a..046d9ab1 100644 --- a/src/modules/simple-earn/locked/setAutoSubscribe.ts +++ b/src/modules/simple-earn/locked/setAutoSubscribe.ts @@ -5,45 +5,52 @@ * @license Apache-2.0 */ // src/modules/simple-earn/locked/setAutoSubscribe.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { simpleEarnClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { simpleEarnClient } from "../../../config/binanceClient.js" export function registerSimpleEarnSetAutoSubscribe(server: McpServer) { - server.tool( - "BinanceSimpleEarnLockedSetAutoSubscribe", - "Enable or disable auto-subscribe for a locked position. When enabled, funds automatically re-subscribe when the lock period ends.", - { - positionId: z.string().describe("Position ID to update"), - autoSubscribe: z.boolean().describe("Enable (true) or disable (false) auto-subscribe"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await simpleEarnClient.restAPI.setLockedAutoSubscribe({ - positionId: params.positionId, - autoSubscribe: params.autoSubscribe, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSimpleEarnLockedSetAutoSubscribe", + "Enable or disable auto-subscribe for a locked position. When enabled, funds automatically re-subscribe when the lock period ends.", + { + positionId: z.string().describe("Position ID to update"), + autoSubscribe: z.boolean().describe("Enable (true) or disable (false) auto-subscribe"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await simpleEarnClient.restAPI.setLockedAutoSubscribe({ + positionId: params.positionId, + autoSubscribe: params.autoSubscribe, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Auto-Subscribe Updated!\n\nPosition ID: ${params.positionId}\nAuto-Subscribe: ${params.autoSubscribe ? "Enabled" : "Disabled"}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `✅ Auto-Subscribe Updated!\n\nPosition ID: ${params.positionId}\nAuto-Subscribe: ${params.autoSubscribe ? 'Enabled' : 'Disabled'}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to update auto-subscribe: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to update auto-subscribe: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/simple-earn/locked/subscribeLocked.ts b/src/modules/simple-earn/locked/subscribeLocked.ts index e288bdc3..95112435 100644 --- a/src/modules/simple-earn/locked/subscribeLocked.ts +++ b/src/modules/simple-earn/locked/subscribeLocked.ts @@ -5,50 +5,59 @@ * @license Apache-2.0 */ // src/modules/simple-earn/locked/subscribeLocked.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { simpleEarnClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { simpleEarnClient } from "../../../config/binanceClient.js" export function registerSimpleEarnSubscribeLocked(server: McpServer) { - server.tool( - "BinanceSimpleEarnLockedSubscribe", - "Subscribe to a Simple Earn Locked product. ⚠️ Funds will be locked for the specified duration. Higher APR than flexible products!", - { - projectId: z.string().describe("Locked product project ID"), - amount: z.number().positive().describe("Amount to subscribe"), - autoSubscribe: z.boolean().optional().describe("Auto-resubscribe when position matures"), - sourceAccount: z.enum(["SPOT", "FUND", "ALL"]).optional() - .describe("Source account for funds (default: SPOT)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await simpleEarnClient.restAPI.subscribeLockedProduct({ - projectId: params.projectId, - amount: params.amount, - ...(params.autoSubscribe !== undefined && { autoSubscribe: params.autoSubscribe }), - ...(params.sourceAccount && { sourceAccount: params.sourceAccount }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSimpleEarnLockedSubscribe", + "Subscribe to a Simple Earn Locked product. ⚠️ Funds will be locked for the specified duration. Higher APR than flexible products!", + { + projectId: z.string().describe("Locked product project ID"), + amount: z.number().positive().describe("Amount to subscribe"), + autoSubscribe: z.boolean().optional().describe("Auto-resubscribe when position matures"), + sourceAccount: z + .enum(["SPOT", "FUND", "ALL"]) + .optional() + .describe("Source account for funds (default: SPOT)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await simpleEarnClient.restAPI.subscribeLockedProduct({ + projectId: params.projectId, + amount: params.amount, + ...(params.autoSubscribe !== undefined && { autoSubscribe: params.autoSubscribe }), + ...(params.sourceAccount && { sourceAccount: params.sourceAccount }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Locked Product Subscription Successful!\n\nProject ID: ${params.projectId}\nAmount: ${params.amount}\nPosition ID: ${data.positionId || "N/A"}\n\n⚠️ Your funds are now locked. Rewards will be distributed based on the product terms.`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `✅ Locked Product Subscription Successful!\n\nProject ID: ${params.projectId}\nAmount: ${params.amount}\nPosition ID: ${data.positionId || 'N/A'}\n\n⚠️ Your funds are now locked. Rewards will be distributed based on the product terms.` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to subscribe to locked product: ${errorMessage}` - }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `❌ Failed to subscribe to locked product: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/spot/account-api/accountCommission.ts b/src/modules/spot/account-api/accountCommission.ts index 399bebdd..f4a179c2 100644 --- a/src/modules/spot/account-api/accountCommission.ts +++ b/src/modules/spot/account-api/accountCommission.ts @@ -1,43 +1,45 @@ // src/tools/binance-spot/account-api/accountCommission.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceAccountCommission(server: McpServer) { - server.tool( - "BinanceAccountCommission", - "Get account commission rates for a specific symbol.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ symbol, recvWindow }) => { - try { - const params: any = { symbol }; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await spotClient.restAPI.accountCommission(params); + server.tool( + "BinanceAccountCommission", + "Get account commission rates for a specific symbol.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ symbol, recvWindow }) => { + try { + const params: any = { symbol } + if (recvWindow !== undefined) params.recvWindow = recvWindow + const response = await spotClient.restAPI.accountCommission(params) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved account commission rates for ${symbol}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved account commission rates for ${symbol}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve account commission rates: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve account commission rates: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/spot/account-api/getAccount.ts b/src/modules/spot/account-api/getAccount.ts index c1339fa9..556a3e19 100644 --- a/src/modules/spot/account-api/getAccount.ts +++ b/src/modules/spot/account-api/getAccount.ts @@ -1,42 +1,44 @@ // src/tools/binance-spot/account-api/getAccount.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceGetAccount(server: McpServer) { - server.tool( - "BinanceGetAccount", - "Get current account information.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: any = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await spotClient.restAPI.getAccount(params); + server.tool( + "BinanceGetAccount", + "Get current account information.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: any = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + const response = await spotClient.restAPI.getAccount(params) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved account information. Account contains ${data.balances?.length || 0} balances. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved account information. Account contains ${data.balances?.length || 0} balances. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve account information: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve account information: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/spot/account-api/index.ts b/src/modules/spot/account-api/index.ts index 6b1c4c10..2be3a54f 100644 --- a/src/modules/spot/account-api/index.ts +++ b/src/modules/spot/account-api/index.ts @@ -1,17 +1,18 @@ // src/tools/binance-spot/account-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceMyPreventedMatches } from "./myPreventedMatches.js"; -import { registerBinanceGetAccount } from "./getAccount.js"; -import { registerBinanceMyAllocations } from "./myAllocations.js"; -import { registerBinanceRateLimitOrder } from "./rateLimitOrder.js"; -import { registerBinanceAccountCommission } from "./accountCommission.js"; -import { registerBinanceMyTrades } from "./myTrades.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceAccountCommission } from "./accountCommission.js" +import { registerBinanceGetAccount } from "./getAccount.js" +import { registerBinanceMyAllocations } from "./myAllocations.js" +import { registerBinanceMyPreventedMatches } from "./myPreventedMatches.js" +import { registerBinanceMyTrades } from "./myTrades.js" +import { registerBinanceRateLimitOrder } from "./rateLimitOrder.js" export function registerBinanceAccountApiTools(server: McpServer) { - registerBinanceMyPreventedMatches(server); - registerBinanceGetAccount(server); - registerBinanceMyAllocations(server); - registerBinanceRateLimitOrder(server); - registerBinanceAccountCommission(server); - registerBinanceMyTrades(server); + registerBinanceMyPreventedMatches(server) + registerBinanceGetAccount(server) + registerBinanceMyAllocations(server) + registerBinanceRateLimitOrder(server) + registerBinanceAccountCommission(server) + registerBinanceMyTrades(server) } diff --git a/src/modules/spot/account-api/myAllocations.ts b/src/modules/spot/account-api/myAllocations.ts index 9d2bde83..81a00914 100644 --- a/src/modules/spot/account-api/myAllocations.ts +++ b/src/modules/spot/account-api/myAllocations.ts @@ -1,52 +1,52 @@ // src/tools/binance-spot/account-api/myAllocations.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceMyAllocations(server: McpServer) { - server.tool( - "BinanceMyAllocations", - "Get SOR allocations for Self-Trade Prevention.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - allocationId: z.number().optional().describe("Allocation ID"), - orderId: z.number().optional().describe("Order ID"), - fromAllocationId: z.number().optional().describe("Allocation ID to fetch from"), - limit: z.number().optional().describe("Default 500; max 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ symbol, allocationId, orderId, fromAllocationId, limit, recvWindow }) => { - try { - const params: any = { symbol }; - - if (allocationId !== undefined) params.allocationId = allocationId; - if (orderId !== undefined) params.orderId = orderId; - if (fromAllocationId !== undefined) params.fromAllocationId = fromAllocationId; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await spotClient.restAPI.myAllocations(params); - - - const data = await response.data(); - - return { - content: [ - { - type: "text", - text: `Retrieved SOR allocations for ${symbol}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve SOR allocations: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceMyAllocations", + "Get SOR allocations for Self-Trade Prevention.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + allocationId: z.number().optional().describe("Allocation ID"), + orderId: z.number().optional().describe("Order ID"), + fromAllocationId: z.number().optional().describe("Allocation ID to fetch from"), + limit: z.number().optional().describe("Default 500; max 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ symbol, allocationId, orderId, fromAllocationId, limit, recvWindow }) => { + try { + const params: any = { symbol } + + if (allocationId !== undefined) params.allocationId = allocationId + if (orderId !== undefined) params.orderId = orderId + if (fromAllocationId !== undefined) params.fromAllocationId = fromAllocationId + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await spotClient.restAPI.myAllocations(params) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved SOR allocations for ${symbol}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to retrieve SOR allocations: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/spot/account-api/myPreventedMatches.ts b/src/modules/spot/account-api/myPreventedMatches.ts index c1ed4732..61403e30 100644 --- a/src/modules/spot/account-api/myPreventedMatches.ts +++ b/src/modules/spot/account-api/myPreventedMatches.ts @@ -1,51 +1,54 @@ // src/tools/binance-spot/account-api/myPreventedMatches.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceMyPreventedMatches(server: McpServer) { - server.tool( - "BinanceMyPreventedMatches", - "Get prevented matches for Self-Trade Prevention.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - preventedMatchId: z.number().optional().describe("Prevented match ID"), - orderId: z.number().optional().describe("Order ID"), - fromPreventedMatchId: z.number().optional().describe("Prevented match ID to fetch from"), - limit: z.number().optional().describe("Default 500; max 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ symbol, preventedMatchId, orderId, fromPreventedMatchId, limit, recvWindow }) => { - try { - const params: any = { symbol }; - - if (preventedMatchId !== undefined) params.preventedMatchId = preventedMatchId; - if (orderId !== undefined) params.orderId = orderId; - if (fromPreventedMatchId !== undefined) params.fromPreventedMatchId = fromPreventedMatchId; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await spotClient.restAPI.myPreventedMatches(params); - - const data = await response.data(); - - return { - content: [ - { - type: "text", - text: `Retrieved prevented matches for ${symbol}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve prevented matches: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceMyPreventedMatches", + "Get prevented matches for Self-Trade Prevention.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + preventedMatchId: z.number().optional().describe("Prevented match ID"), + orderId: z.number().optional().describe("Order ID"), + fromPreventedMatchId: z.number().optional().describe("Prevented match ID to fetch from"), + limit: z.number().optional().describe("Default 500; max 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ symbol, preventedMatchId, orderId, fromPreventedMatchId, limit, recvWindow }) => { + try { + const params: any = { symbol } + + if (preventedMatchId !== undefined) params.preventedMatchId = preventedMatchId + if (orderId !== undefined) params.orderId = orderId + if (fromPreventedMatchId !== undefined) params.fromPreventedMatchId = fromPreventedMatchId + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await spotClient.restAPI.myPreventedMatches(params) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved prevented matches for ${symbol}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to retrieve prevented matches: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/spot/account-api/myTrades.ts b/src/modules/spot/account-api/myTrades.ts index 450ffd23..bfe95f19 100644 --- a/src/modules/spot/account-api/myTrades.ts +++ b/src/modules/spot/account-api/myTrades.ts @@ -1,54 +1,54 @@ // src/tools/binance-spot/account-api/myTrades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceMyTrades(server: McpServer) { - server.tool( - "BinanceMyTrades", - "Get trades for a specific account and symbol.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - orderId: z.number().optional().describe("Order ID"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - fromId: z.number().optional().describe("Trade ID to fetch from"), - limit: z.number().optional().describe("Default 500; max 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ symbol, orderId, startTime, endTime, fromId, limit, recvWindow }) => { - try { - const params: any = { symbol }; - - if (orderId !== undefined) params.orderId = orderId; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (fromId !== undefined) params.fromId = fromId; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await spotClient.restAPI.myTrades(params); - - - const data = await response.data(); - - return { - content: [ - { - type: "text", - text: `Retrieved trades for ${symbol}. Total trades: ${data.length}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve account trades: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceMyTrades", + "Get trades for a specific account and symbol.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + orderId: z.number().optional().describe("Order ID"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + fromId: z.number().optional().describe("Trade ID to fetch from"), + limit: z.number().optional().describe("Default 500; max 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ symbol, orderId, startTime, endTime, fromId, limit, recvWindow }) => { + try { + const params: any = { symbol } + + if (orderId !== undefined) params.orderId = orderId + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (fromId !== undefined) params.fromId = fromId + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await spotClient.restAPI.myTrades(params) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved trades for ${symbol}. Total trades: ${data.length}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to retrieve account trades: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/spot/account-api/rateLimitOrder.ts b/src/modules/spot/account-api/rateLimitOrder.ts index a7886d3e..bd415e83 100644 --- a/src/modules/spot/account-api/rateLimitOrder.ts +++ b/src/modules/spot/account-api/rateLimitOrder.ts @@ -1,42 +1,44 @@ // src/tools/binance-spot/account-api/rateLimitOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceRateLimitOrder(server: McpServer) { - server.tool( - "BinanceRateLimitOrder", - "Get current order count usage for each rate limit.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: any = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await spotClient.restAPI.rateLimitOrder(params); + server.tool( + "BinanceRateLimitOrder", + "Get current order count usage for each rate limit.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: any = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + const response = await spotClient.restAPI.rateLimitOrder(params) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved current order count usage. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved current order count usage. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve order count usage: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve order count usage: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/spot/general-api/exchangeInfo.ts b/src/modules/spot/general-api/exchangeInfo.ts index 0c869f15..9967eebe 100644 --- a/src/modules/spot/general-api/exchangeInfo.ts +++ b/src/modules/spot/general-api/exchangeInfo.ts @@ -1,49 +1,52 @@ // src/tools/binance-spot/general-api/exchangeInfo.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceExchangeInfo(server: McpServer) { - server.tool( - "BinanceExchangeInfo", - "Get exchange information including rate limits, symbol configs, etc.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - symbols: z.array(z.string()).optional().describe("Array of symbols to get info for"), - permissions: z.array(z.string()).optional().describe("Array of permissions to filter by") - }, - async ({ symbol, symbols, permissions }) => { - try { - const params: any = {}; - - if (symbol) params.symbol = symbol; - if (symbols) params.symbols = symbols; - if (permissions) params.permissions = permissions; - - const response = await spotClient.restAPI.exchangeInfo(params); - - const data = await response.data(); - - const symbolCount = data.symbols?.length || 0; - const exchangeFiltersCount = data.exchangeFilters?.length || 0; - - return { - content: [ - { - type: "text", - text: `Retrieved exchange information. Total symbols: ${symbolCount}, Exchange filters: ${exchangeFiltersCount}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve exchange information: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceExchangeInfo", + "Get exchange information including rate limits, symbol configs, etc.", + { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + symbols: z.array(z.string()).optional().describe("Array of symbols to get info for"), + permissions: z.array(z.string()).optional().describe("Array of permissions to filter by"), + }, + async ({ symbol, symbols, permissions }) => { + try { + const params: any = {} + + if (symbol) params.symbol = symbol + if (symbols) params.symbols = symbols + if (permissions) params.permissions = permissions + + const response = await spotClient.restAPI.exchangeInfo(params) + + const data = await response.data() + + const symbolCount = data.symbols?.length || 0 + const exchangeFiltersCount = data.exchangeFilters?.length || 0 + + return { + content: [ + { + type: "text", + text: `Retrieved exchange information. Total symbols: ${symbolCount}, Exchange filters: ${exchangeFiltersCount}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to retrieve exchange information: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/spot/general-api/index.ts b/src/modules/spot/general-api/index.ts index 5ba8ee07..471676d4 100644 --- a/src/modules/spot/general-api/index.ts +++ b/src/modules/spot/general-api/index.ts @@ -1,12 +1,12 @@ // src/tools/binance-spot/general-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinancePing } from "./ping.js"; -import { registerBinanceTime } from "./time.js"; -import { registerBinanceExchangeInfo } from "./exchangeInfo.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceExchangeInfo } from "./exchangeInfo.js" +import { registerBinancePing } from "./ping.js" +import { registerBinanceTime } from "./time.js" export function registerBinanceGeneralApiTools(server: McpServer) { - registerBinancePing(server); - registerBinanceTime(server); - registerBinanceExchangeInfo(server); - + registerBinancePing(server) + registerBinanceTime(server) + registerBinanceExchangeInfo(server) } diff --git a/src/modules/spot/general-api/ping.ts b/src/modules/spot/general-api/ping.ts index ee57842a..1e0aa465 100644 --- a/src/modules/spot/general-api/ping.ts +++ b/src/modules/spot/general-api/ping.ts @@ -1,37 +1,30 @@ // src/tools/binance-spot/general-api/ping.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinancePing(server: McpServer) { - server.tool( - "BinancePing", - "Test connectivity to the Binance API.", - {}, - async () => { - try { - const response = await spotClient.restAPI.ping(); + server.tool("BinancePing", "Test connectivity to the Binance API.", {}, async () => { + try { + const response = await spotClient.restAPI.ping() + const data = await response.data() - const data = await response.data(); + return { + content: [ + { + type: "text", + text: `Successfully pinged Binance API. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully pinged Binance API. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to ping Binance API: ${errorMessage}` } - ], - isError: true - }; - } - } - ); + return { + content: [{ type: "text", text: `Failed to ping Binance API: ${errorMessage}` }], + isError: true, + } + } + }) } diff --git a/src/modules/spot/general-api/time.ts b/src/modules/spot/general-api/time.ts index cd6b4d18..3c0aa903 100644 --- a/src/modules/spot/general-api/time.ts +++ b/src/modules/spot/general-api/time.ts @@ -1,34 +1,35 @@ // src/tools/binance-spot/general-api/time.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceTime(server: McpServer) { - server.tool("BinanceTime", "Get the current server time from Binance API.", {}, async () => { - try { - const response = await spotClient.restAPI.time(); + server.tool("BinanceTime", "Get the current server time from Binance API.", {}, async () => { + try { + const response = await spotClient.restAPI.time() + + const data = await response.data() + + // @ts-expect-error - serverTime not in generated type definition + const serverTime = new Date(data.serverTime).toISOString() - const data = await response.data(); - - //@ts-ignore - const serverTime = new Date(data.serverTime).toISOString(); + return { + content: [ + { + type: "text", + text: `Current Binance server time: ${serverTime} (${ + data.serverTime + }). Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Current Binance server time: ${serverTime} (${ - data.serverTime - }). Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to retrieve server time: ${errorMessage}` }], - isError: true - }; - } - }); + return { + content: [{ type: "text", text: `Failed to retrieve server time: ${errorMessage}` }], + isError: true, + } + } + }) } diff --git a/src/modules/spot/index.ts b/src/modules/spot/index.ts index a9adb7c3..6b58ea53 100644 --- a/src/modules/spot/index.ts +++ b/src/modules/spot/index.ts @@ -1,28 +1,28 @@ // src/tools/binance-spot/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceMarketApiTools } from "./market-api/index.js"; -import { registerBinanceTradeApiTools } from "./trade-api/index.js"; -import { registerBinanceAccountApiTools } from "./account-api/index.js"; -import { registerBinanceUserDataStreamApiTools } from "./userdatastream-api/index.js"; -import { registerBinanceGeneralApiTools } from "./general-api/index.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceAccountApiTools } from "./account-api/index.js" +import { registerBinanceGeneralApiTools } from "./general-api/index.js" +import { registerBinanceMarketApiTools } from "./market-api/index.js" +import { registerBinanceTradeApiTools } from "./trade-api/index.js" +import { registerBinanceUserDataStreamApiTools } from "./userdatastream-api/index.js" export function registerBinanceSpotTools(server: McpServer) { - // Trade API tools - registerBinanceTradeApiTools(server); - - // Market API tools - registerBinanceMarketApiTools(server); - - // Account API tools - registerBinanceAccountApiTools(server); - - // User Data Stream API tools - registerBinanceUserDataStreamApiTools(server); - - // General API tools - registerBinanceGeneralApiTools(server); - + // Trade API tools + registerBinanceTradeApiTools(server) + + // Market API tools + registerBinanceMarketApiTools(server) + + // Account API tools + registerBinanceAccountApiTools(server) + + // User Data Stream API tools + registerBinanceUserDataStreamApiTools(server) + + // General API tools + registerBinanceGeneralApiTools(server) } // Alias for binance.ts compatibility -export { registerBinanceSpotTools as registerSpot }; +export { registerBinanceSpotTools as registerSpot } diff --git a/src/modules/spot/market-api/aggTrades.ts b/src/modules/spot/market-api/aggTrades.ts index 8c14bed9..3a1a49ef 100644 --- a/src/modules/spot/market-api/aggTrades.ts +++ b/src/modules/spot/market-api/aggTrades.ts @@ -1,50 +1,50 @@ // src/tools/binance-spot/market-api/aggTrades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceAggTrades(server: McpServer) { - server.tool( - "BinanceAggTrades", - "Get compressed, aggregate trades for a specific trading pair.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - fromId: z.number().optional().describe("ID to get aggregate trades from"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1000") - }, - async ({ symbol, fromId, startTime, endTime, limit }) => { - try { - const params: any = { symbol }; - - if (fromId !== undefined) params.fromId = fromId; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; - - const response = await spotClient.restAPI.aggTrades(params); - - - const data = await response.data(); - - return { - content: [ - { - type: "text", - text: `Retrieved aggregate trades for ${symbol}. Total trades: ${data.length}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve aggregate trades: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceAggTrades", + "Get compressed, aggregate trades for a specific trading pair.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + fromId: z.number().optional().describe("ID to get aggregate trades from"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1000"), + }, + async ({ symbol, fromId, startTime, endTime, limit }) => { + try { + const params: any = { symbol } + + if (fromId !== undefined) params.fromId = fromId + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit + + const response = await spotClient.restAPI.aggTrades(params) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved aggregate trades for ${symbol}. Total trades: ${data.length}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to retrieve aggregate trades: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/spot/market-api/avgPrice.ts b/src/modules/spot/market-api/avgPrice.ts index 16107b77..80ed5102 100644 --- a/src/modules/spot/market-api/avgPrice.ts +++ b/src/modules/spot/market-api/avgPrice.ts @@ -1,41 +1,41 @@ // src/tools/binance-spot/market-api/avgPrice.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceAvgPrice(server: McpServer) { - server.tool( - "BinanceAvgPrice", - "Get current average price for a trading pair.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)") - }, - async ({ symbol }) => { - try { - const response = await spotClient.restAPI.avgPrice({ - symbol: symbol - }); + server.tool( + "BinanceAvgPrice", + "Get current average price for a trading pair.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, + async ({ symbol }) => { + try { + const response = await spotClient.restAPI.avgPrice({ + symbol: symbol, + }) + const data = await response.data() - const data = await response.data(); + return { + content: [ + { + type: "text", + text: `Retrieved current average price for ${symbol}. Average price: ${data.price}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved current average price for ${symbol}. Average price: ${data.price}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve average price: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve average price: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/spot/market-api/depth.ts b/src/modules/spot/market-api/depth.ts index b83f84d5..6df7e4b5 100644 --- a/src/modules/spot/market-api/depth.ts +++ b/src/modules/spot/market-api/depth.ts @@ -1,43 +1,43 @@ // src/tools/binance-spot/market-api/depth.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceDepth(server: McpServer) { - server.tool( - "BinanceDepth", - "Get order book depth data for a specific trading pair.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - limit: z.number().optional().describe("Depth of the order book. Default 100; max 5000.") - }, - async ({ symbol, limit }) => { - try { - const params: any = { symbol }; - if (limit !== undefined) params.limit = limit; - - const response = await spotClient.restAPI.depth(params); + server.tool( + "BinanceDepth", + "Get order book depth data for a specific trading pair.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + limit: z.number().optional().describe("Depth of the order book. Default 100; max 5000."), + }, + async ({ symbol, limit }) => { + try { + const params: any = { symbol } + if (limit !== undefined) params.limit = limit + const response = await spotClient.restAPI.depth(params) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved order book depth for ${symbol}. Bids: ${data.bids?.length || 0}, Asks: ${data.asks?.length || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved order book depth for ${symbol}. Bids: ${data.bids?.length || 0}, Asks: ${data.asks?.length || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve order book depth: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve order book depth: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/spot/market-api/getTrades.ts b/src/modules/spot/market-api/getTrades.ts index 7c885045..6f65b5e4 100644 --- a/src/modules/spot/market-api/getTrades.ts +++ b/src/modules/spot/market-api/getTrades.ts @@ -1,43 +1,44 @@ // src/tools/binance-spot/market-api/getTrades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceGetTrades(server: McpServer) { - server.tool( - "BinanceGetTrades", - "Get recent trades for a specific trading pair.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - limit: z.number().optional().describe("Default 500; max 1000") - }, - async ({ symbol, limit }) => { - try { - const params: any = { symbol }; - - if (limit !== undefined) params.limit = limit; - - const response = await spotClient.restAPI.getTrades(params); - - const data = await response.data(); - - return { - content: [ - { - type: "text", - text: `Retrieved recent trades for ${symbol}. Total trades: ${data.length}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve recent trades: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceGetTrades", + "Get recent trades for a specific trading pair.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + limit: z.number().optional().describe("Default 500; max 1000"), + }, + async ({ symbol, limit }) => { + try { + const params: any = { symbol } + + if (limit !== undefined) params.limit = limit + + const response = await spotClient.restAPI.getTrades(params) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved recent trades for ${symbol}. Total trades: ${data.length}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to retrieve recent trades: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/spot/market-api/historicalTrades.ts b/src/modules/spot/market-api/historicalTrades.ts index cefd0378..ca14bb87 100644 --- a/src/modules/spot/market-api/historicalTrades.ts +++ b/src/modules/spot/market-api/historicalTrades.ts @@ -1,45 +1,48 @@ // src/tools/binance-spot/market-api/historicalTrades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceHistoricalTrades(server: McpServer) { - server.tool( - "BinanceHistoricalTrades", - "Get older historical trades for a specific trading pair.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - limit: z.number().optional().describe("Default 500; max 1000"), - fromId: z.number().optional().describe("Trade ID to fetch from") - }, - async ({ symbol, limit, fromId }) => { - try { - const params: any = { symbol }; - - if (limit !== undefined) params.limit = limit; - if (fromId !== undefined) params.fromId = fromId; - - const response = await spotClient.restAPI.historicalTrades(params); - - const data = await response.data(); - - return { - content: [ - { - type: "text", - text: `Retrieved historical trades for ${symbol}. Total trades: ${data.length}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve historical trades: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceHistoricalTrades", + "Get older historical trades for a specific trading pair.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + limit: z.number().optional().describe("Default 500; max 1000"), + fromId: z.number().optional().describe("Trade ID to fetch from"), + }, + async ({ symbol, limit, fromId }) => { + try { + const params: any = { symbol } + + if (limit !== undefined) params.limit = limit + if (fromId !== undefined) params.fromId = fromId + + const response = await spotClient.restAPI.historicalTrades(params) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved historical trades for ${symbol}. Total trades: ${data.length}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to retrieve historical trades: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/spot/market-api/index.ts b/src/modules/spot/market-api/index.ts index b0730073..4ccede7d 100644 --- a/src/modules/spot/market-api/index.ts +++ b/src/modules/spot/market-api/index.ts @@ -1,30 +1,30 @@ // src/tools/binance-spot/market-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceKlines } from "./klines.js"; -import { registerBinanceTicker24hr } from "./ticker24hr.js"; -import { registerBinanceDepth } from "./depth.js"; -import { registerBinanceAggTrades } from "./aggTrades.js"; -import { registerBinanceTickerTradingDay } from "./tickerTradingDay.js"; -import { registerBinanceUiKlines } from "./uiKlines.js"; -import { registerBinanceTickerBookTicker } from "./tickerBookTicker.js"; -import { registerBinanceAvgPrice } from "./avgPrice.js"; -import { registerBinanceTickerPrice } from "./tickerPrice.js"; -import { registerBinanceTicker } from "./ticker.js"; -import { registerBinanceHistoricalTrades } from "./historicalTrades.js"; -import { registerBinanceGetTrades } from "./getTrades.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceAggTrades } from "./aggTrades.js" +import { registerBinanceAvgPrice } from "./avgPrice.js" +import { registerBinanceDepth } from "./depth.js" +import { registerBinanceGetTrades } from "./getTrades.js" +import { registerBinanceHistoricalTrades } from "./historicalTrades.js" +import { registerBinanceKlines } from "./klines.js" +import { registerBinanceTicker24hr } from "./ticker24hr.js" +import { registerBinanceTicker } from "./ticker.js" +import { registerBinanceTickerBookTicker } from "./tickerBookTicker.js" +import { registerBinanceTickerPrice } from "./tickerPrice.js" +import { registerBinanceTickerTradingDay } from "./tickerTradingDay.js" +import { registerBinanceUiKlines } from "./uiKlines.js" export function registerBinanceMarketApiTools(server: McpServer) { - registerBinanceKlines(server); - registerBinanceTicker24hr(server); - registerBinanceDepth(server); - registerBinanceAggTrades(server); - registerBinanceTickerTradingDay(server); - registerBinanceUiKlines(server); - registerBinanceTickerBookTicker(server); - registerBinanceAvgPrice(server); - registerBinanceTickerPrice(server); - registerBinanceTicker(server); - registerBinanceHistoricalTrades(server); - registerBinanceGetTrades(server); - -} \ No newline at end of file + registerBinanceKlines(server) + registerBinanceTicker24hr(server) + registerBinanceDepth(server) + registerBinanceAggTrades(server) + registerBinanceTickerTradingDay(server) + registerBinanceUiKlines(server) + registerBinanceTickerBookTicker(server) + registerBinanceAvgPrice(server) + registerBinanceTickerPrice(server) + registerBinanceTicker(server) + registerBinanceHistoricalTrades(server) + registerBinanceGetTrades(server) +} diff --git a/src/modules/spot/market-api/klines.ts b/src/modules/spot/market-api/klines.ts index 53e3fcf5..1eb9eb49 100644 --- a/src/modules/spot/market-api/klines.ts +++ b/src/modules/spot/market-api/klines.ts @@ -1,53 +1,70 @@ // src/tools/binance-spot/market-api/klines.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceKlines(server: McpServer) { - server.tool( - "BinanceKlines", - "Get candlestick data (klines) for a specific trading pair and interval.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - interval: z.enum([ - "1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "8h", "12h", "1d", "3d", "1w", "1M" - ]).describe("Kline interval"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1000") - }, - async ({ symbol, interval, startTime, endTime, limit }) => { - try { - const params: any = { - symbol, - interval - }; - - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; - - const response = await spotClient.restAPI.klines(params); - - const data = await response.data(); - - return { - content: [ - { - type: "text", - text: `Retrieved klines for ${symbol} with ${interval} interval. Total candles: ${data.length}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve klines: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceKlines", + "Get candlestick data (klines) for a specific trading pair and interval.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1000"), + }, + async ({ symbol, interval, startTime, endTime, limit }) => { + try { + const params: any = { + symbol, + interval, + } + + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit + + const response = await spotClient.restAPI.klines(params) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved klines for ${symbol} with ${interval} interval. Total candles: ${data.length}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to retrieve klines: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/spot/market-api/ticker.ts b/src/modules/spot/market-api/ticker.ts index 12e44187..05d15f05 100644 --- a/src/modules/spot/market-api/ticker.ts +++ b/src/modules/spot/market-api/ticker.ts @@ -1,49 +1,54 @@ // src/tools/binance-spot/market-api/ticker.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceTicker(server: McpServer) { - server.tool( - "BinanceTicker", - "Get 24-hour rolling window price change statistics for a symbol or all symbols.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - windowSize: z.string().optional().describe("Defaults to 1d. Valid values: 1d, 2d, 3d, 4d, 5d, 6d, 7d") - }, - async ({ symbol, windowSize }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - if (windowSize) params.windowSize = windowSize; - - const response = await spotClient.restAPI.ticker(params); - - - const data = await response.data(); - - const isArray = Array.isArray(data); - const responseText = isArray - ? `Retrieved ticker statistics for all symbols${windowSize ? ` with window size ${windowSize}` : ''}. Total items: ${data.length}.` - : `Retrieved ticker statistics for ${symbol}${windowSize ? ` with window size ${windowSize}` : ''}.`; - - return { - content: [ - { - type: "text", - text: `${responseText} Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve ticker statistics: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceTicker", + "Get 24-hour rolling window price change statistics for a symbol or all symbols.", + { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + windowSize: z + .string() + .optional() + .describe("Defaults to 1d. Valid values: 1d, 2d, 3d, 4d, 5d, 6d, 7d"), + }, + async ({ symbol, windowSize }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + if (windowSize) params.windowSize = windowSize + + const response = await spotClient.restAPI.ticker(params) + + const data = await response.data() + + const isArray = Array.isArray(data) + const responseText = isArray + ? `Retrieved ticker statistics for all symbols${windowSize ? ` with window size ${windowSize}` : ""}. Total items: ${data.length}.` + : `Retrieved ticker statistics for ${symbol}${windowSize ? ` with window size ${windowSize}` : ""}.` + + return { + content: [ + { + type: "text", + text: `${responseText} Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to retrieve ticker statistics: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/spot/market-api/ticker24hr.ts b/src/modules/spot/market-api/ticker24hr.ts index 12ddce0d..58f1d5ed 100644 --- a/src/modules/spot/market-api/ticker24hr.ts +++ b/src/modules/spot/market-api/ticker24hr.ts @@ -1,47 +1,47 @@ // src/tools/binance-spot/market-api/ticker24hr.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceTicker24hr(server: McpServer) { - server.tool( - "BinanceTicker24hr", - "Get 24-hour price change statistics for a symbol or all symbols.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)") - }, - async ({ symbol }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - - const response = await spotClient.restAPI.ticker24hr(params); - - - const data = await response.data(); - - const isArray = Array.isArray(data); - const responseText = isArray - ? `Retrieved 24hr statistics for all symbols. Total items: ${data.length}.` - : `Retrieved 24hr statistics for ${symbol}.`; - - return { - content: [ - { - type: "text", - text: `${responseText} Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve 24hr ticker: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceTicker24hr", + "Get 24-hour price change statistics for a symbol or all symbols.", + { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, + async ({ symbol }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + + const response = await spotClient.restAPI.ticker24hr(params) + + const data = await response.data() + + const isArray = Array.isArray(data) + const responseText = isArray + ? `Retrieved 24hr statistics for all symbols. Total items: ${data.length}.` + : `Retrieved 24hr statistics for ${symbol}.` + + return { + content: [ + { + type: "text", + text: `${responseText} Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to retrieve 24hr ticker: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/spot/market-api/tickerBookTicker.ts b/src/modules/spot/market-api/tickerBookTicker.ts index 44a28791..9fede0b8 100644 --- a/src/modules/spot/market-api/tickerBookTicker.ts +++ b/src/modules/spot/market-api/tickerBookTicker.ts @@ -1,47 +1,47 @@ // src/tools/binance-spot/market-api/tickerBookTicker.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceTickerBookTicker(server: McpServer) { - server.tool( - "BinanceTickerBookTicker", - "Get best price/quantity on the order book for a symbol or all symbols.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)") - }, - async ({ symbol }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - - const response = await spotClient.restAPI.tickerBookTicker(params); - - - const data = await response.data(); - - const isArray = Array.isArray(data); - const responseText = isArray - ? `Retrieved best price/quantity on the order book for all symbols. Total items: ${data.length}.` - : `Retrieved best price/quantity on the order book for ${symbol}.`; - - return { - content: [ - { - type: "text", - text: `${responseText} Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve book ticker: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceTickerBookTicker", + "Get best price/quantity on the order book for a symbol or all symbols.", + { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, + async ({ symbol }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + + const response = await spotClient.restAPI.tickerBookTicker(params) + + const data = await response.data() + + const isArray = Array.isArray(data) + const responseText = isArray + ? `Retrieved best price/quantity on the order book for all symbols. Total items: ${data.length}.` + : `Retrieved best price/quantity on the order book for ${symbol}.` + + return { + content: [ + { + type: "text", + text: `${responseText} Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to retrieve book ticker: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/spot/market-api/tickerPrice.ts b/src/modules/spot/market-api/tickerPrice.ts index 98313726..d57a9323 100644 --- a/src/modules/spot/market-api/tickerPrice.ts +++ b/src/modules/spot/market-api/tickerPrice.ts @@ -1,47 +1,47 @@ // src/tools/binance-spot/market-api/tickerPrice.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceTickerPrice(server: McpServer) { - server.tool( - "BinanceTickerPrice", - "Get latest price for a symbol or all symbols.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)") - }, - async ({ symbol }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - - const response = await spotClient.restAPI.tickerPrice(params); - - - const data = await response.data(); - - const isArray = Array.isArray(data); - const responseText = isArray - ? `Retrieved latest prices for all symbols. Total items: ${data.length}.` - : `Retrieved latest price for ${symbol}: ${data.price}.`; - - return { - content: [ - { - type: "text", - text: `${responseText} Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve ticker price: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceTickerPrice", + "Get latest price for a symbol or all symbols.", + { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, + async ({ symbol }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + + const response = await spotClient.restAPI.tickerPrice(params) + + const data = await response.data() + + const isArray = Array.isArray(data) + const responseText = isArray + ? `Retrieved latest prices for all symbols. Total items: ${data.length}.` + : `Retrieved latest price for ${symbol}: ${data.price}.` + + return { + content: [ + { + type: "text", + text: `${responseText} Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to retrieve ticker price: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/spot/market-api/tickerTradingDay.ts b/src/modules/spot/market-api/tickerTradingDay.ts index 7d96249e..9e21de6f 100644 --- a/src/modules/spot/market-api/tickerTradingDay.ts +++ b/src/modules/spot/market-api/tickerTradingDay.ts @@ -1,47 +1,49 @@ // src/tools/binance-spot/market-api/tickerTradingDay.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceTickerTradingDay(server: McpServer) { - server.tool( - "BinanceTickerTradingDay", - "Get statistics for the current trading day for a symbol or all symbols.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)") - }, - async ({ symbol }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - - const response = await spotClient.restAPI.tickerTradingDay(params); - - - const data = await response.data(); - - const isArray = Array.isArray(data); - const responseText = isArray - ? `Retrieved trading day statistics for all symbols. Total items: ${data.length}.` - : `Retrieved trading day statistics for ${symbol}.`; - - return { - content: [ - { - type: "text", - text: `${responseText} Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve trading day statistics: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceTickerTradingDay", + "Get statistics for the current trading day for a symbol or all symbols.", + { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, + async ({ symbol }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + + const response = await spotClient.restAPI.tickerTradingDay(params) + + const data = await response.data() + + const isArray = Array.isArray(data) + const responseText = isArray + ? `Retrieved trading day statistics for all symbols. Total items: ${data.length}.` + : `Retrieved trading day statistics for ${symbol}.` + + return { + content: [ + { + type: "text", + text: `${responseText} Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to retrieve trading day statistics: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/spot/market-api/uiKlines.ts b/src/modules/spot/market-api/uiKlines.ts index 96100d2b..886a3d75 100644 --- a/src/modules/spot/market-api/uiKlines.ts +++ b/src/modules/spot/market-api/uiKlines.ts @@ -1,53 +1,70 @@ // src/tools/binance-spot/market-api/uiKlines.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceUiKlines(server: McpServer) { - server.tool( - "BinanceUiKlines", - "Get UI-optimized candlestick data for a specific trading pair and interval.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - interval: z.enum([ - "1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "8h", "12h", "1d", "3d", "1w", "1M" - ]).describe("Kline interval"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1000") - }, - async ({ symbol, interval, startTime, endTime, limit }) => { - try { - const params: any = { - symbol, - interval - }; - - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; - - const response = await spotClient.restAPI.uiKlines(params); - - const data = await response.data(); - - return { - content: [ - { - type: "text", - text: `Retrieved UI klines for ${symbol} with ${interval} interval. Total candles: ${data.length}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve UI klines: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceUiKlines", + "Get UI-optimized candlestick data for a specific trading pair and interval.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1000"), + }, + async ({ symbol, interval, startTime, endTime, limit }) => { + try { + const params: any = { + symbol, + interval, + } + + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit + + const response = await spotClient.restAPI.uiKlines(params) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved UI klines for ${symbol} with ${interval} interval. Total candles: ${data.length}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to retrieve UI klines: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/spot/trade-api/allOrders.ts b/src/modules/spot/trade-api/allOrders.ts index d94ac840..1a4b3f19 100644 --- a/src/modules/spot/trade-api/allOrders.ts +++ b/src/modules/spot/trade-api/allOrders.ts @@ -1,49 +1,53 @@ // src/tools/binance-spot/trade-api/allOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceAllOrders(server: McpServer) { - server.tool( - "BinanceAllOrders", - "Get all account orders for a specific symbol; active, canceled, or filled.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - orderId: z.number().optional().describe("Order ID to start from"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Maximum number of orders to return (default 500, max 1000)") - }, - async ({ symbol, orderId, startTime, endTime, limit }) => { - try { - const params: any = { symbol }; - - if (orderId !== undefined) params.orderId = orderId; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; - - const response = await spotClient.restAPI.allOrders(params); - - const data = await response.data(); - - return { - content: [ - { - type: "text", - text: `Retrieved all orders for ${symbol}. Total orders: ${data.length}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve all orders: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceAllOrders", + "Get all account orders for a specific symbol; active, canceled, or filled.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + orderId: z.number().optional().describe("Order ID to start from"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z + .number() + .optional() + .describe("Maximum number of orders to return (default 500, max 1000)"), + }, + async ({ symbol, orderId, startTime, endTime, limit }) => { + try { + const params: any = { symbol } + + if (orderId !== undefined) params.orderId = orderId + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit + + const response = await spotClient.restAPI.allOrders(params) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved all orders for ${symbol}. Total orders: ${data.length}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to retrieve all orders: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/spot/trade-api/deleteOpenOrders.ts b/src/modules/spot/trade-api/deleteOpenOrders.ts index 1cdaca3f..95920e81 100644 --- a/src/modules/spot/trade-api/deleteOpenOrders.ts +++ b/src/modules/spot/trade-api/deleteOpenOrders.ts @@ -1,40 +1,41 @@ // src/tools/binance-spot/trade-api/deleteOpenOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceDeleteOpenOrders(server: McpServer) { - server.tool( - "BinanceDeleteOpenOrders", - "Cancel all open orders on Binance for a specific symbol.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)") - }, - async ({ symbol }) => { - try { - const response = await spotClient.restAPI.deleteOpenOrders({ - symbol: symbol - }); + server.tool( + "BinanceDeleteOpenOrders", + "Cancel all open orders on Binance for a specific symbol.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, + async ({ symbol }) => { + try { + const response = await spotClient.restAPI.deleteOpenOrders({ + symbol: symbol, + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully canceled all open orders for ${symbol}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully canceled all open orders for ${symbol}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to cancel open orders: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to cancel open orders: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/spot/trade-api/deleteOrder.ts b/src/modules/spot/trade-api/deleteOrder.ts index 027bdde0..cbf5490d 100644 --- a/src/modules/spot/trade-api/deleteOrder.ts +++ b/src/modules/spot/trade-api/deleteOrder.ts @@ -1,45 +1,46 @@ // src/tools/binance-spot/trade-api/deleteOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceDeleteOrder(server: McpServer) { - server.tool( - "BinanceDeleteOrder", - "Cancel an active order on Binance for a specific trading pair.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - orderId: z.string().optional().describe("The order ID to cancel"), - origClientOrderId: z.string().optional().describe("Original client order ID") - }, - async ({ symbol, orderId, origClientOrderId }) => { - try { - const params: any = { symbol }; - - if (orderId) params.orderId = orderId; - if (origClientOrderId) params.origClientOrderId = origClientOrderId; - - const response = await spotClient.restAPI.deleteOrder(params); - - const data = await response.data(); - - return { - content: [ - { - type: "text", - text: `Order successfully canceled. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to cancel order: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceDeleteOrder", + "Cancel an active order on Binance for a specific trading pair.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + orderId: z.string().optional().describe("The order ID to cancel"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + }, + async ({ symbol, orderId, origClientOrderId }) => { + try { + const params: any = { symbol } + + if (orderId) params.orderId = orderId + if (origClientOrderId) params.origClientOrderId = origClientOrderId + + const response = await spotClient.restAPI.deleteOrder(params) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Order successfully canceled. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to cancel order: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/spot/trade-api/getOpenOrders.ts b/src/modules/spot/trade-api/getOpenOrders.ts index 0f129727..70e079a7 100644 --- a/src/modules/spot/trade-api/getOpenOrders.ts +++ b/src/modules/spot/trade-api/getOpenOrders.ts @@ -1,41 +1,42 @@ // src/tools/binance-spot/trade-api/getOpenOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceGetOpenOrders(server: McpServer) { - server.tool( - "BinanceGetOpenOrders", - "Get all open orders on Binance for a specific symbol or all symbols.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)") - }, - async ({ symbol }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - - const response = await spotClient.restAPI.getOpenOrders(params); + server.tool( + "BinanceGetOpenOrders", + "Get all open orders on Binance for a specific symbol or all symbols.", + { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, + async ({ symbol }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + + const response = await spotClient.restAPI.getOpenOrders(params) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved open orders${symbol ? ` for ${symbol}` : ""}. Total open orders: ${data.length}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved open orders${symbol ? ` for ${symbol}` : ''}. Total open orders: ${data.length}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve open orders: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve open orders: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/spot/trade-api/getOrder.ts b/src/modules/spot/trade-api/getOrder.ts index e7647207..1c83ac75 100644 --- a/src/modules/spot/trade-api/getOrder.ts +++ b/src/modules/spot/trade-api/getOrder.ts @@ -1,45 +1,48 @@ // src/tools/binance-spot/trade-api/getOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceGetOrder(server: McpServer) { - server.tool( - "BinanceGetOrder", - "Check an order's status on Binance for a specific trading pair.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - orderId: z.string().optional().describe("The order ID to query"), - origClientOrderId: z.string().optional().describe("Original client order ID") - }, - async ({ symbol, orderId, origClientOrderId }) => { - try { - const params: any = { symbol }; - - if (orderId) params.orderId = orderId; - if (origClientOrderId) params.origClientOrderId = origClientOrderId; - - const response = await spotClient.restAPI.getOrder(params); - - const data = await response.data(); - - return { - content: [ - { - type: "text", - text: `Order information retrieved successfully. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve order information: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceGetOrder", + "Check an order's status on Binance for a specific trading pair.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + orderId: z.string().optional().describe("The order ID to query"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + }, + async ({ symbol, orderId, origClientOrderId }) => { + try { + const params: any = { symbol } + + if (orderId) params.orderId = orderId + if (origClientOrderId) params.origClientOrderId = origClientOrderId + + const response = await spotClient.restAPI.getOrder(params) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Order information retrieved successfully. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to retrieve order information: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/spot/trade-api/index.ts b/src/modules/spot/trade-api/index.ts index 1478bdd3..d7dc679c 100644 --- a/src/modules/spot/trade-api/index.ts +++ b/src/modules/spot/trade-api/index.ts @@ -1,22 +1,22 @@ // src/tools/binance-spot/trade-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceDeleteOrder } from "./deleteOrder.js"; -import { registerBinanceAllOrders } from "./allOrders.js"; -import { registerBinanceOpenOrderList } from "./openOrderList.js"; -import { registerBinanceNewOrder } from "./newOrder.js"; -import { registerBinanceGetOrder } from "./getOrder.js"; -import { registerBinanceGetOpenOrders } from "./getOpenOrders.js"; -import { registerBinanceDeleteOpenOrders } from "./deleteOpenOrders.js"; -import { registerBinanceOrderOco } from "./orderOco.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceAllOrders } from "./allOrders.js" +import { registerBinanceDeleteOpenOrders } from "./deleteOpenOrders.js" +import { registerBinanceDeleteOrder } from "./deleteOrder.js" +import { registerBinanceGetOpenOrders } from "./getOpenOrders.js" +import { registerBinanceGetOrder } from "./getOrder.js" +import { registerBinanceNewOrder } from "./newOrder.js" +import { registerBinanceOpenOrderList } from "./openOrderList.js" +import { registerBinanceOrderOco } from "./orderOco.js" export function registerBinanceTradeApiTools(server: McpServer) { - registerBinanceDeleteOrder(server); - registerBinanceAllOrders(server); - registerBinanceOpenOrderList(server); - registerBinanceNewOrder(server); - registerBinanceGetOrder(server); - registerBinanceGetOpenOrders(server); - registerBinanceDeleteOpenOrders(server); - registerBinanceOrderOco(server); - -} \ No newline at end of file + registerBinanceDeleteOrder(server) + registerBinanceAllOrders(server) + registerBinanceOpenOrderList(server) + registerBinanceNewOrder(server) + registerBinanceGetOrder(server) + registerBinanceGetOpenOrders(server) + registerBinanceDeleteOpenOrders(server) + registerBinanceOrderOco(server) +} diff --git a/src/modules/spot/trade-api/newOrder.ts b/src/modules/spot/trade-api/newOrder.ts index 1b01cfe5..9080a015 100644 --- a/src/modules/spot/trade-api/newOrder.ts +++ b/src/modules/spot/trade-api/newOrder.ts @@ -1,63 +1,86 @@ // src/tools/binance-spot/trade-api/newOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceNewOrder(server: McpServer) { - server.tool( - "BinanceNewOrder", - "Create a new order on Binance for a specific trading pair.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Order side: BUY or SELL"), - type: z.enum(["LIMIT", "MARKET", "STOP_LOSS", "STOP_LOSS_LIMIT", "TAKE_PROFIT", "TAKE_PROFIT_LIMIT", "LIMIT_MAKER"]).describe("Order type"), - timeInForce: z.enum(["GTC", "IOC", "FOK"]).optional().describe("Time in force"), - quantity: z.number().describe("Order quantity"), - quoteOrderQty: z.number().optional().describe("Quote order quantity"), - price: z.number().optional().describe("Order price"), - newClientOrderId: z.string().optional().describe("Client order ID"), - stopPrice: z.number().optional().describe("Stop price"), - icebergQty: z.number().optional().describe("Iceberg quantity"), - newOrderRespType: z.enum(["ACK", "RESULT", "FULL"]).optional().describe("Response type") - }, - async ({ symbol, side, type, timeInForce, quantity, quoteOrderQty, price, newClientOrderId, stopPrice, icebergQty, newOrderRespType }) => { - try { - const params: any = { - symbol, - side, - type, - quantity - }; - - if (timeInForce) params.timeInForce = timeInForce; - if (quoteOrderQty !== undefined) params.quoteOrderQty = quoteOrderQty; - if (price !== undefined) params.price = price; - if (newClientOrderId) params.newClientOrderId = newClientOrderId; - if (stopPrice !== undefined) params.stopPrice = stopPrice; - if (icebergQty !== undefined) params.icebergQty = icebergQty; - if (newOrderRespType) params.newOrderRespType = newOrderRespType; - - const response = await spotClient.restAPI.newOrder(params); - - const data = await response.data(); - - return { - content: [ - { - type: "text", - text: `New order successfully created. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to create new order: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceNewOrder", + "Create a new order on Binance for a specific trading pair.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Order side: BUY or SELL"), + type: z + .enum([ + "LIMIT", + "MARKET", + "STOP_LOSS", + "STOP_LOSS_LIMIT", + "TAKE_PROFIT", + "TAKE_PROFIT_LIMIT", + "LIMIT_MAKER", + ]) + .describe("Order type"), + timeInForce: z.enum(["GTC", "IOC", "FOK"]).optional().describe("Time in force"), + quantity: z.number().describe("Order quantity"), + quoteOrderQty: z.number().optional().describe("Quote order quantity"), + price: z.number().optional().describe("Order price"), + newClientOrderId: z.string().optional().describe("Client order ID"), + stopPrice: z.number().optional().describe("Stop price"), + icebergQty: z.number().optional().describe("Iceberg quantity"), + newOrderRespType: z.enum(["ACK", "RESULT", "FULL"]).optional().describe("Response type"), + }, + async ({ + symbol, + side, + type, + timeInForce, + quantity, + quoteOrderQty, + price, + newClientOrderId, + stopPrice, + icebergQty, + newOrderRespType, + }) => { + try { + const params: any = { + symbol, + side, + type, + quantity, + } + + if (timeInForce) params.timeInForce = timeInForce + if (quoteOrderQty !== undefined) params.quoteOrderQty = quoteOrderQty + if (price !== undefined) params.price = price + if (newClientOrderId) params.newClientOrderId = newClientOrderId + if (stopPrice !== undefined) params.stopPrice = stopPrice + if (icebergQty !== undefined) params.icebergQty = icebergQty + if (newOrderRespType) params.newOrderRespType = newOrderRespType + + const response = await spotClient.restAPI.newOrder(params) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `New order successfully created. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to create new order: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/spot/trade-api/openOrderList.ts b/src/modules/spot/trade-api/openOrderList.ts index 7c6134f5..1ba07a57 100644 --- a/src/modules/spot/trade-api/openOrderList.ts +++ b/src/modules/spot/trade-api/openOrderList.ts @@ -1,41 +1,42 @@ // src/tools/binance-spot/trade-api/openOrderList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceOpenOrderList(server: McpServer) { - server.tool( - "BinanceOpenOrderList", - "Query open OCO orders for a specific account or symbol.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)") - }, - async ({ symbol }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - - const response = await spotClient.restAPI.openOrderList(params); + server.tool( + "BinanceOpenOrderList", + "Query open OCO orders for a specific account or symbol.", + { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, + async ({ symbol }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + + const response = await spotClient.restAPI.openOrderList(params) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved open OCO orders${symbol ? ` for ${symbol}` : ""}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved open OCO orders${symbol ? ` for ${symbol}` : ''}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve open OCO orders: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve open OCO orders: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/spot/trade-api/orderOco.ts b/src/modules/spot/trade-api/orderOco.ts index b758bf40..bfca8250 100644 --- a/src/modules/spot/trade-api/orderOco.ts +++ b/src/modules/spot/trade-api/orderOco.ts @@ -1,63 +1,79 @@ // src/tools/binance-spot/trade-api/orderOco.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceOrderOco(server: McpServer) { - server.tool( - "BinanceOrderOco", - "Send a new OCO (One-Cancels-the-Other) order on Binance.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Order side: BUY or SELL"), - quantity: z.number().describe("Order quantity"), - price: z.number().describe("Order price"), - stopPrice: z.number().describe("Stop price"), - stopLimitPrice: z.number().optional().describe("Stop limit price"), - stopLimitTimeInForce: z.enum(["GTC", "IOC", "FOK"]).optional().describe("Stop limit time in force"), - newClientOrderId: z.string().optional().describe("Client order ID for the limit order"), - stopClientOrderId: z.string().optional().describe("Client order ID for the stop order"), - limitIcebergQty: z.number().optional().describe("Limit iceberg quantity"), - stopIcebergQty: z.number().optional().describe("Stop iceberg quantity") - }, - async ({ symbol, side, quantity, price, stopPrice, stopLimitPrice, stopLimitTimeInForce, newClientOrderId, stopClientOrderId, limitIcebergQty, stopIcebergQty }) => { - try { - const params: any = { - symbol, - side, - quantity, - price, - stopPrice - }; - - if (stopLimitPrice !== undefined) params.stopLimitPrice = stopLimitPrice; - if (stopLimitTimeInForce) params.stopLimitTimeInForce = stopLimitTimeInForce; - if (newClientOrderId) params.newClientOrderId = newClientOrderId; - if (stopClientOrderId) params.stopClientOrderId = stopClientOrderId; - if (limitIcebergQty !== undefined) params.limitIcebergQty = limitIcebergQty; - if (stopIcebergQty !== undefined) params.stopIcebergQty = stopIcebergQty; - - const response = await spotClient.restAPI.orderOco(params); - - const data = await response.data(); - - return { - content: [ - { - type: "text", - text: `OCO order successfully created. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to create OCO order: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceOrderOco", + "Send a new OCO (One-Cancels-the-Other) order on Binance.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Order side: BUY or SELL"), + quantity: z.number().describe("Order quantity"), + price: z.number().describe("Order price"), + stopPrice: z.number().describe("Stop price"), + stopLimitPrice: z.number().optional().describe("Stop limit price"), + stopLimitTimeInForce: z + .enum(["GTC", "IOC", "FOK"]) + .optional() + .describe("Stop limit time in force"), + newClientOrderId: z.string().optional().describe("Client order ID for the limit order"), + stopClientOrderId: z.string().optional().describe("Client order ID for the stop order"), + limitIcebergQty: z.number().optional().describe("Limit iceberg quantity"), + stopIcebergQty: z.number().optional().describe("Stop iceberg quantity"), + }, + async ({ + symbol, + side, + quantity, + price, + stopPrice, + stopLimitPrice, + stopLimitTimeInForce, + newClientOrderId, + stopClientOrderId, + limitIcebergQty, + stopIcebergQty, + }) => { + try { + const params: any = { + symbol, + side, + quantity, + price, + stopPrice, + } + + if (stopLimitPrice !== undefined) params.stopLimitPrice = stopLimitPrice + if (stopLimitTimeInForce) params.stopLimitTimeInForce = stopLimitTimeInForce + if (newClientOrderId) params.newClientOrderId = newClientOrderId + if (stopClientOrderId) params.stopClientOrderId = stopClientOrderId + if (limitIcebergQty !== undefined) params.limitIcebergQty = limitIcebergQty + if (stopIcebergQty !== undefined) params.stopIcebergQty = stopIcebergQty + + const response = await spotClient.restAPI.orderOco(params) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `OCO order successfully created. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to create OCO order: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/spot/userdatastream-api/deleteUserDataStream.ts b/src/modules/spot/userdatastream-api/deleteUserDataStream.ts index 7f6001f4..45f9c877 100644 --- a/src/modules/spot/userdatastream-api/deleteUserDataStream.ts +++ b/src/modules/spot/userdatastream-api/deleteUserDataStream.ts @@ -1,40 +1,41 @@ // src/tools/binance-spot/userdatastream-api/deleteUserDataStream.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceDeleteUserDataStream(server: McpServer) { - server.tool( - "BinanceDeleteUserDataStream", - "Close a user data stream by invalidating the listen key.", - { - listenKey: z.string().describe("Listen key to close") - }, - async ({ listenKey }) => { - try { - const response = await spotClient.restAPI.deleteUserDataStream({ - listenKey: listenKey - }); + server.tool( + "BinanceDeleteUserDataStream", + "Close a user data stream by invalidating the listen key.", + { + listenKey: z.string().describe("Listen key to close"), + }, + async ({ listenKey }) => { + try { + const response = await spotClient.restAPI.deleteUserDataStream({ + listenKey: listenKey, + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully closed user data stream with listen key: ${listenKey}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully closed user data stream with listen key: ${listenKey}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to close user data stream: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to close user data stream: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/spot/userdatastream-api/index.ts b/src/modules/spot/userdatastream-api/index.ts index f6e3f61c..a321fb5d 100644 --- a/src/modules/spot/userdatastream-api/index.ts +++ b/src/modules/spot/userdatastream-api/index.ts @@ -1,12 +1,12 @@ // src/tools/binance-spot/userdatastream-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceNewUserDataStream } from "./newUserDataStream.js"; -import { registerBinanceDeleteUserDataStream } from "./deleteUserDataStream.js"; -import { registerBinancePutUserDataStream } from "./putUserDataStream.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceDeleteUserDataStream } from "./deleteUserDataStream.js" +import { registerBinanceNewUserDataStream } from "./newUserDataStream.js" +import { registerBinancePutUserDataStream } from "./putUserDataStream.js" export function registerBinanceUserDataStreamApiTools(server: McpServer) { - registerBinanceNewUserDataStream(server); - registerBinanceDeleteUserDataStream(server); - registerBinancePutUserDataStream(server); - + registerBinanceNewUserDataStream(server) + registerBinanceDeleteUserDataStream(server) + registerBinancePutUserDataStream(server) } diff --git a/src/modules/spot/userdatastream-api/newUserDataStream.ts b/src/modules/spot/userdatastream-api/newUserDataStream.ts index 767167dd..e01448e8 100644 --- a/src/modules/spot/userdatastream-api/newUserDataStream.ts +++ b/src/modules/spot/userdatastream-api/newUserDataStream.ts @@ -1,36 +1,35 @@ // src/tools/binance-spot/userdatastream-api/newUserDataStream.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceNewUserDataStream(server: McpServer) { - server.tool( - "BinanceNewUserDataStream", - "Create a new user data stream to receive account updates via WebSocket.", - {}, - async () => { - try { - const response = await spotClient.restAPI.newUserDataStream(); + server.tool( + "BinanceNewUserDataStream", + "Create a new user data stream to receive account updates via WebSocket.", + {}, + async () => { + try { + const response = await spotClient.restAPI.newUserDataStream() + + const data = await response.data() - const data = await response.data(); + return { + content: [ + { + type: "text", + text: `Created new listen key for user data stream. Listen key: ${data.listenKey}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Created new listen key for user data stream. Listen key: ${data.listenKey}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to create user data stream: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to create user data stream: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/spot/userdatastream-api/putUserDataStream.ts b/src/modules/spot/userdatastream-api/putUserDataStream.ts index 4e05e565..4f054acd 100644 --- a/src/modules/spot/userdatastream-api/putUserDataStream.ts +++ b/src/modules/spot/userdatastream-api/putUserDataStream.ts @@ -1,40 +1,43 @@ // src/tools/binance-spot/userdatastream-api/putUserDataStream.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinancePutUserDataStream(server: McpServer) { - server.tool( - "BinancePutUserDataStream", - "Extend the validity of a user data stream listen key.", - { - listenKey: z.string().describe("Listen key to keep alive") - }, - async ({ listenKey }) => { - try { - const response = await spotClient.restAPI.putUserDataStream({ - listenKey: listenKey - }); + server.tool( + "BinancePutUserDataStream", + "Extend the validity of a user data stream listen key.", + { + listenKey: z.string().describe("Listen key to keep alive"), + }, + async ({ listenKey }) => { + try { + const response = await spotClient.restAPI.putUserDataStream({ + listenKey: listenKey, + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully extended validity of listen key: ${listenKey}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully extended validity of listen key: ${listenKey}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to extend listen key validity: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to extend listen key validity: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/staking/ETH-staking-api/ethStakingAccount.ts b/src/modules/staking/ETH-staking-api/ethStakingAccount.ts index aeff9941..f2c6820f 100644 --- a/src/modules/staking/ETH-staking-api/ethStakingAccount.ts +++ b/src/modules/staking/ETH-staking-api/ethStakingAccount.ts @@ -1,45 +1,48 @@ // src/tools/binance-staking/ETH-staking-api/ethStakingAccount.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceEthStakingAccount(server: McpServer) { - server.tool( - "BinanceEthStakingAccount", - "ETH Staking Account API allows users to retrieve their current ETH staking holdings and 30-day profit details, including amounts from WBETH and BETH", - { - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.ethStakingAccount({ - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceEthStakingAccount", + "ETH Staking Account API allows users to retrieve their current ETH staking holdings and 30-day profit details, including amounts from WBETH and BETH", + { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.ethStakingAccount({ + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved current ETH staking holdings . Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved current ETH staking holdings . Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve ETH staking holdings . ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve ETH staking holdings . ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/staking/ETH-staking-api/getCurrentEthStakingQuota.ts b/src/modules/staking/ETH-staking-api/getCurrentEthStakingQuota.ts index ed542bda..f64b1532 100644 --- a/src/modules/staking/ETH-staking-api/getCurrentEthStakingQuota.ts +++ b/src/modules/staking/ETH-staking-api/getCurrentEthStakingQuota.ts @@ -1,45 +1,48 @@ // src/tools/binance-staking/ETH-staking-api/getCurrentEthStakingQuota.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceGetCurrentEthStakingQuota(server: McpServer) { - server.tool( - "BinanceGetCurrentEthStakingQuota", - "Get Current ETH Staking Quota API allows users to retrieve their available ETH staking and redemption quotas, reflecting personal and daily limits.", - { - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.getCurrentEthStakingQuota({ - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetCurrentEthStakingQuota", + "Get Current ETH Staking Quota API allows users to retrieve their available ETH staking and redemption quotas, reflecting personal and daily limits.", + { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.getCurrentEthStakingQuota({ + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved current ETH Staking Quota API allows users. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved current ETH Staking Quota API allows users. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve current ETH Staking Quota API allows users. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve current ETH Staking Quota API allows users. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/staking/ETH-staking-api/getEthRedemptionHistory.ts b/src/modules/staking/ETH-staking-api/getEthRedemptionHistory.ts index 4f86c09c..4e47b3ee 100644 --- a/src/modules/staking/ETH-staking-api/getEthRedemptionHistory.ts +++ b/src/modules/staking/ETH-staking-api/getEthRedemptionHistory.ts @@ -1,66 +1,77 @@ // src/tools/binance-staking/ETH-staking-api/getEthRedemptionHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceGetEthRedemptionHistory(server: McpServer) { - server.tool( - "BinanceGetEthRedemptionHistory", - "Get ETH Redemption History API allows users to retrieve their historical ETH staking redemption records, including details like asset type, amount, status, and time of redemption.", - { - startTime: z.number().int().optional().describe("Start time in milliseconds (e.g., 1641522717552)"), - endTime: z.number().int().optional().describe("End time in milliseconds (e.g., 1641522526562)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page, start from 1. Default is 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page, Default is 10, Max is 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.getCurrentEthStakingQuota({ - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - ...(params.startTime !== undefined && { startTime: params.startTime }), - ...(params.endTime !== undefined && { endTime: params.endTime }), - ...(params.current !== undefined && { current: params.current }), - ...(params.size !== undefined && { size: params.size }) - }); + server.tool( + "BinanceGetEthRedemptionHistory", + "Get ETH Redemption History API allows users to retrieve their historical ETH staking redemption records, including details like asset type, amount, status, and time of redemption.", + { + startTime: z + .number() + .int() + .optional() + .describe("Start time in milliseconds (e.g., 1641522717552)"), + endTime: z + .number() + .int() + .optional() + .describe("End time in milliseconds (e.g., 1641522526562)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page, start from 1. Default is 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page, Default is 10, Max is 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.getCurrentEthStakingQuota({ + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + ...(params.startTime !== undefined && { startTime: params.startTime }), + ...(params.endTime !== undefined && { endTime: params.endTime }), + ...(params.current !== undefined && { current: params.current }), + ...(params.size !== undefined && { size: params.size }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved history API allows users to retrieve their historical ETH staking redemption records. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved history API allows users to retrieve their historical ETH staking redemption records. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve history API allows users to retrieve their historical ETH staking redemption records. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve history API allows users to retrieve their historical ETH staking redemption records. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/staking/ETH-staking-api/getEthStakingHistory.ts b/src/modules/staking/ETH-staking-api/getEthStakingHistory.ts index e93d94d9..80d93ebb 100644 --- a/src/modules/staking/ETH-staking-api/getEthStakingHistory.ts +++ b/src/modules/staking/ETH-staking-api/getEthStakingHistory.ts @@ -1,66 +1,77 @@ // src/tools/binance-staking/ETH-staking-api/getEthStakingHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceGetEthStakingHistory(server: McpServer) { - server.tool( - "registerBinanceGetEthStakingHistory", - "Get ETH Staking History API allows users to retrieve their historical ETH staking records, including details like asset type, amount, status, and time of staking", - { - startTime: z.number().int().optional().describe("Start time in milliseconds (e.g., 1641522717552)"), - endTime: z.number().int().optional().describe("End time in milliseconds (e.g., 1641522526562)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default is 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default is 10, Max is 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.getEthStakingHistory({ - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - ...(params.startTime !== undefined && { startTime: params.startTime }), - ...(params.endTime !== undefined && { endTime: params.endTime }), - ...(params.current !== undefined && { current: params.current }), - ...(params.size !== undefined && { size: params.size }) - }); + server.tool( + "registerBinanceGetEthStakingHistory", + "Get ETH Staking History API allows users to retrieve their historical ETH staking records, including details like asset type, amount, status, and time of staking", + { + startTime: z + .number() + .int() + .optional() + .describe("Start time in milliseconds (e.g., 1641522717552)"), + endTime: z + .number() + .int() + .optional() + .describe("End time in milliseconds (e.g., 1641522526562)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default is 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default is 10, Max is 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.getEthStakingHistory({ + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + ...(params.startTime !== undefined && { startTime: params.startTime }), + ...(params.endTime !== undefined && { endTime: params.endTime }), + ...(params.current !== undefined && { current: params.current }), + ...(params.size !== undefined && { size: params.size }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved ETH Staking History API allows users to retrieve their historical ETH staking records. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved ETH Staking History API allows users to retrieve their historical ETH staking records. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve ETH Staking History API allows users to retrieve their historical ETH staking records. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve ETH Staking History API allows users to retrieve their historical ETH staking records. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/staking/ETH-staking-api/getWbethRateHistory.ts b/src/modules/staking/ETH-staking-api/getWbethRateHistory.ts index d54febd0..a9c69bef 100644 --- a/src/modules/staking/ETH-staking-api/getWbethRateHistory.ts +++ b/src/modules/staking/ETH-staking-api/getWbethRateHistory.ts @@ -1,67 +1,74 @@ // src/tools/binance-staking/ETH-staking-api/getWbethRateHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceGetWbethRateHistory(server: McpServer) { - server.tool( - "BinanceGetWbethRateHistory", - "Get WBETH Rate History API allows users to retrieve historical WBETH exchange rates and BETH annual percentage rates (APR) within a specified time range.", - { - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Starts from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), + server.tool( + "BinanceGetWbethRateHistory", + "Get WBETH Rate History API allows users to retrieve historical WBETH exchange rates and BETH annual percentage rates (APR) within a specified time range.", + { + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Starts from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity (in milliseconds)") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.getWbethRateHistory({ - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - ...(params.startTime !== undefined && { startTime: params.startTime }), - ...(params.endTime !== undefined && { endTime: params.endTime }), - ...(params.current !== undefined && { current: params.current }), - ...(params.size !== undefined && { size: params.size }) - }); + recvWindow: z + .number() + .int() + .optional() + .describe("Time window for request validity (in milliseconds)"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.getWbethRateHistory({ + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + ...(params.startTime !== undefined && { startTime: params.startTime }), + ...(params.endTime !== undefined && { endTime: params.endTime }), + ...(params.current !== undefined && { current: params.current }), + ...(params.size !== undefined && { size: params.size }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved historical WBETH exchange rates and BETH annual percentage rates. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved historical WBETH exchange rates and BETH annual percentage rates. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve historical WBETH exchange rates and BETH annual percentage rates. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve historical WBETH exchange rates and BETH annual percentage rates. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/staking/ETH-staking-api/getWbethRewardsHistory.ts b/src/modules/staking/ETH-staking-api/getWbethRewardsHistory.ts index e0c06400..79a83b5a 100644 --- a/src/modules/staking/ETH-staking-api/getWbethRewardsHistory.ts +++ b/src/modules/staking/ETH-staking-api/getWbethRewardsHistory.ts @@ -1,66 +1,77 @@ // src/tools/binance-staking/ETH-staking-api/getWbethRewardsHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceGetWbethRewardsHistory(server: McpServer) { - server.tool( - "BinanceGetWbethRewardsHistory", - "Get WBETH Rewards History API allows users to retrieve historical reward data earned from WBETH holdings, including estimated rewards in ETH, holding amounts, and APR details.", - { - startTime: z.number().int().optional().describe("Start time in milliseconds (e.g., 1641522717552)"), - endTime: z.number().int().optional().describe("End time in milliseconds (e.g., 1641522720000)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.getWbethRewardsHistory({ - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - ...(params.startTime !== undefined && { startTime: params.startTime }), - ...(params.endTime !== undefined && { endTime: params.endTime }), - ...(params.current !== undefined && { current: params.current }), - ...(params.size !== undefined && { size: params.size }) - }); + server.tool( + "BinanceGetWbethRewardsHistory", + "Get WBETH Rewards History API allows users to retrieve historical reward data earned from WBETH holdings, including estimated rewards in ETH, holding amounts, and APR details.", + { + startTime: z + .number() + .int() + .optional() + .describe("Start time in milliseconds (e.g., 1641522717552)"), + endTime: z + .number() + .int() + .optional() + .describe("End time in milliseconds (e.g., 1641522720000)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.getWbethRewardsHistory({ + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + ...(params.startTime !== undefined && { startTime: params.startTime }), + ...(params.endTime !== undefined && { endTime: params.endTime }), + ...(params.current !== undefined && { current: params.current }), + ...(params.size !== undefined && { size: params.size }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved historical reward data earned from WBETH holdings. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved historical reward data earned from WBETH holdings. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve historical reward data earned from WBETH holdings. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve historical reward data earned from WBETH holdings. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/staking/ETH-staking-api/getWbethUnwrapHistory.ts b/src/modules/staking/ETH-staking-api/getWbethUnwrapHistory.ts index 9167ac06..7bdf1f01 100644 --- a/src/modules/staking/ETH-staking-api/getWbethUnwrapHistory.ts +++ b/src/modules/staking/ETH-staking-api/getWbethUnwrapHistory.ts @@ -1,66 +1,73 @@ // src/tools/binance-staking/ETH-staking-api/getWbethUnwrapHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceGetWbethUnwrapHistory(server: McpServer) { - server.tool( - "BinanceGetWbethUnwrapHistory", - "Get WBETH Unwrap History API allows users to retrieve historical records of WBETH unwrap operations, including asset conversion details, exchange rates, and transaction status.", - { - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity (in milliseconds)") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.getWbethUnwrapHistory({ - ...(params.startTime !== undefined && { startTime: params.startTime }), - ...(params.endTime !== undefined && { endTime: params.endTime }), - ...(params.current !== undefined && { current: params.current }), - ...(params.size !== undefined && { size: params.size }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetWbethUnwrapHistory", + "Get WBETH Unwrap History API allows users to retrieve historical records of WBETH unwrap operations, including asset conversion details, exchange rates, and transaction status.", + { + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z + .number() + .int() + .optional() + .describe("Time window for request validity (in milliseconds)"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.getWbethUnwrapHistory({ + ...(params.startTime !== undefined && { startTime: params.startTime }), + ...(params.endTime !== undefined && { endTime: params.endTime }), + ...(params.current !== undefined && { current: params.current }), + ...(params.size !== undefined && { size: params.size }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved historical records of WBETH unwrap operations. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved historical records of WBETH unwrap operations. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve historical records of WBETH unwrap operations. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve historical records of WBETH unwrap operations. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/staking/ETH-staking-api/getWbethWrapHistory.ts b/src/modules/staking/ETH-staking-api/getWbethWrapHistory.ts index e6295b81..0901f741 100644 --- a/src/modules/staking/ETH-staking-api/getWbethWrapHistory.ts +++ b/src/modules/staking/ETH-staking-api/getWbethWrapHistory.ts @@ -1,66 +1,69 @@ // src/tools/binance-staking/ETH-staking-api/getWbethWrapHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceGetWbethWrapHistory(server: McpServer) { - server.tool( - "BinanceGetWbethWrapHistory", - "Get WBETH Wrap History API allows users to retrieve historical records of WBETH wrap operations, including asset conversion details, exchange rates, and transaction status.", - { - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.getWbethWrapHistory({ - ...(params.startTime !== undefined && { startTime: params.startTime }), - ...(params.endTime !== undefined && { endTime: params.endTime }), - ...(params.current !== undefined && { current: params.current }), - ...(params.size !== undefined && { size: params.size }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetWbethWrapHistory", + "Get WBETH Wrap History API allows users to retrieve historical records of WBETH wrap operations, including asset conversion details, exchange rates, and transaction status.", + { + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.getWbethWrapHistory({ + ...(params.startTime !== undefined && { startTime: params.startTime }), + ...(params.endTime !== undefined && { endTime: params.endTime }), + ...(params.current !== undefined && { current: params.current }), + ...(params.size !== undefined && { size: params.size }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved historical records of WBETH wrap operations. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved historical records of WBETH wrap operations. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve historical records of WBETH wrap operations. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve historical records of WBETH wrap operations. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/staking/ETH-staking-api/index.ts b/src/modules/staking/ETH-staking-api/index.ts index f2641ade..ce933182 100644 --- a/src/modules/staking/ETH-staking-api/index.ts +++ b/src/modules/staking/ETH-staking-api/index.ts @@ -1,27 +1,28 @@ // src/tools/binance-staking/ETH-staking-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceEthStakingAccount } from "./ethStakingAccount.js"; -import { registerBinanceGetCurrentEthStakingQuota } from "./getCurrentEthStakingQuota.js"; -import { registerBinanceGetEthRedemptionHistory } from "./getEthRedemptionHistory.js"; -import { registerBinanceGetEthStakingHistory } from "./getEthStakingHistory.js"; -import { registerBinanceGetWbethRateHistory } from "./getWbethRateHistory.js"; -import { registerBinanceGetWbethRewardsHistory } from "./getWbethRewardsHistory.js"; -import { registerBinanceGetWbethUnwrapHistory } from "./getWbethUnwrapHistory.js"; -import { registerBinanceGetWbethWrapHistory } from "./getWbethWrapHistory.js"; -import { registerBinanceRedeemEth } from "./redeemEth.js"; -import { registerBinanceSubscribeEthStaking } from "./subscribeEthStaking.js"; -import { registerBinanceWrapBeth } from "./wrapBeth.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceEthStakingAccount } from "./ethStakingAccount.js" +import { registerBinanceGetCurrentEthStakingQuota } from "./getCurrentEthStakingQuota.js" +import { registerBinanceGetEthRedemptionHistory } from "./getEthRedemptionHistory.js" +import { registerBinanceGetEthStakingHistory } from "./getEthStakingHistory.js" +import { registerBinanceGetWbethRateHistory } from "./getWbethRateHistory.js" +import { registerBinanceGetWbethRewardsHistory } from "./getWbethRewardsHistory.js" +import { registerBinanceGetWbethUnwrapHistory } from "./getWbethUnwrapHistory.js" +import { registerBinanceGetWbethWrapHistory } from "./getWbethWrapHistory.js" +import { registerBinanceRedeemEth } from "./redeemEth.js" +import { registerBinanceSubscribeEthStaking } from "./subscribeEthStaking.js" +import { registerBinanceWrapBeth } from "./wrapBeth.js" export function registerBinanceETHStakingApiTools(server: McpServer) { - registerBinanceEthStakingAccount(server); - registerBinanceGetCurrentEthStakingQuota(server); - registerBinanceGetEthRedemptionHistory(server); - registerBinanceGetEthStakingHistory(server); - registerBinanceGetWbethRateHistory(server); - registerBinanceGetWbethRewardsHistory(server); - registerBinanceGetWbethUnwrapHistory(server); - registerBinanceGetWbethWrapHistory(server); - registerBinanceRedeemEth(server); - registerBinanceSubscribeEthStaking(server); - registerBinanceWrapBeth(server); + registerBinanceEthStakingAccount(server) + registerBinanceGetCurrentEthStakingQuota(server) + registerBinanceGetEthRedemptionHistory(server) + registerBinanceGetEthStakingHistory(server) + registerBinanceGetWbethRateHistory(server) + registerBinanceGetWbethRewardsHistory(server) + registerBinanceGetWbethUnwrapHistory(server) + registerBinanceGetWbethWrapHistory(server) + registerBinanceRedeemEth(server) + registerBinanceSubscribeEthStaking(server) + registerBinanceWrapBeth(server) } diff --git a/src/modules/staking/ETH-staking-api/redeemEth.ts b/src/modules/staking/ETH-staking-api/redeemEth.ts index 20dc7b60..33fc2e31 100644 --- a/src/modules/staking/ETH-staking-api/redeemEth.ts +++ b/src/modules/staking/ETH-staking-api/redeemEth.ts @@ -1,47 +1,54 @@ // src/tools/binance-staking/ETH-staking-api/redeemEth.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceRedeemEth(server: McpServer) { - server.tool( - "BinanceRedeemEth", - "Redeem ETH API allows users to redeem WBETH or BETH for ETH, providing the amount, conversion ratio, and arrival time details.", - { - amount: z.number().min(0).describe("Amount in BETH, limit 8 decimals (mandatory)"), - asset: z.string().optional().default("BETH").describe("Asset type, either WBETH or BETH. Default: BETH"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.redeemEth({ - amount: params.amount, - asset: params.asset, - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceRedeemEth", + "Redeem ETH API allows users to redeem WBETH or BETH for ETH, providing the amount, conversion ratio, and arrival time details.", + { + amount: z.number().min(0).describe("Amount in BETH, limit 8 decimals (mandatory)"), + asset: z + .string() + .optional() + .default("BETH") + .describe("Asset type, either WBETH or BETH. Default: BETH"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.redeemEth({ + amount: params.amount, + asset: params.asset, + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully redeemed WBETH or BETH for ETH. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully redeemed WBETH or BETH for ETH. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to redeem WBETH or BETH for ETH. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to redeem WBETH or BETH for ETH. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/staking/ETH-staking-api/subscribeEthStaking.ts b/src/modules/staking/ETH-staking-api/subscribeEthStaking.ts index b10e1946..f288528d 100644 --- a/src/modules/staking/ETH-staking-api/subscribeEthStaking.ts +++ b/src/modules/staking/ETH-staking-api/subscribeEthStaking.ts @@ -1,45 +1,48 @@ // src/tools/binance-staking/ETH-staking-api/subscribeEthStaking.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceSubscribeEthStaking(server: McpServer) { - server.tool( - "BinanceSubscribeEthStaking", - "Subscribe ETH Staking API allows users to stake ETH and receive WBETH, providing the staked amount and the conversion ratio for ETH to WBETH.", - { - amount: z.number().min(0).describe("Amount in BETH, limit 4 decimals (mandatory)"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.subscribeEthStaking({ - amount: params.amount, - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSubscribeEthStaking", + "Subscribe ETH Staking API allows users to stake ETH and receive WBETH, providing the staked amount and the conversion ratio for ETH to WBETH.", + { + amount: z.number().min(0).describe("Amount in BETH, limit 4 decimals (mandatory)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.subscribeEthStaking({ + amount: params.amount, + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully staked ETH and receive WBETH. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully staked ETH and receive WBETH. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to stake ETH and receive WBETH. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to stake ETH and receive WBETH. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/staking/ETH-staking-api/wrapBeth.ts b/src/modules/staking/ETH-staking-api/wrapBeth.ts index c753711a..01845a0c 100644 --- a/src/modules/staking/ETH-staking-api/wrapBeth.ts +++ b/src/modules/staking/ETH-staking-api/wrapBeth.ts @@ -1,45 +1,48 @@ // src/tools/binance-staking/ETHStaking-api/wrapBeth.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceWrapBeth(server: McpServer) { - server.tool( - "BinanceWrapBeth", - "Wrap BETH API allows users to convert BETH into WBETH, providing the wrapped WBETH amount and the exchange rate from BETH to WBETH.", - { - amount: z.number().min(0).describe("Amount in BETH, limit 4 decimals (mandatory)"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.wrapBeth({ - amount: params.amount, - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceWrapBeth", + "Wrap BETH API allows users to convert BETH into WBETH, providing the wrapped WBETH amount and the exchange rate from BETH to WBETH.", + { + amount: z.number().min(0).describe("Amount in BETH, limit 4 decimals (mandatory)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.wrapBeth({ + amount: params.amount, + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully convert BETH into WBETH. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully convert BETH into WBETH. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to convert BETH into WBETH. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to convert BETH into WBETH. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/staking/SOL-staking-api/claimBoostRewards.ts b/src/modules/staking/SOL-staking-api/claimBoostRewards.ts index fbb1eaaf..2cb0f0d9 100644 --- a/src/modules/staking/SOL-staking-api/claimBoostRewards.ts +++ b/src/modules/staking/SOL-staking-api/claimBoostRewards.ts @@ -1,45 +1,48 @@ // src/tools/binance-staking/SOL-staking-api/claimBoostRewards.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceClaimBoostRewards(server: McpServer) { - server.tool( - "BinanceClaimBoostRewards", - "Claim Boost Rewards API allows users to claim their Boost APR airdrop rewards for staking.", - { - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.claimBoostRewards({ - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceClaimBoostRewards", + "Claim Boost Rewards API allows users to claim their Boost APR airdrop rewards for staking.", + { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.claimBoostRewards({ + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully claim Boost APR airdrop rewards for staking. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully claim Boost APR airdrop rewards for staking. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to claim Boost APR airdrop rewards. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to claim Boost APR airdrop rewards. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/staking/SOL-staking-api/getBnsolRateHistory.ts b/src/modules/staking/SOL-staking-api/getBnsolRateHistory.ts index 8d3c5a97..7ee8fbc6 100644 --- a/src/modules/staking/SOL-staking-api/getBnsolRateHistory.ts +++ b/src/modules/staking/SOL-staking-api/getBnsolRateHistory.ts @@ -1,66 +1,69 @@ // src/tools/binance-staking/SOL-staking-api/getBnsolRateHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceGetBnsolRateHistory(server: McpServer) { - server.tool( - "registerBinanceGetBnsolRateHistory", - " Get BNSOL Rate History API allows users to retrieve the historical data of the BNSOL staking rate, including APR and exchange rates for SOL to BNSOL.", - { - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.getBnsolRateHistory({ - ...(params.startTime !== undefined && { startTime: params.startTime }), - ...(params.endTime !== undefined && { endTime: params.endTime }), - ...(params.current !== undefined && { current: params.current }), - ...(params.size !== undefined && { size: params.size }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "registerBinanceGetBnsolRateHistory", + " Get BNSOL Rate History API allows users to retrieve the historical data of the BNSOL staking rate, including APR and exchange rates for SOL to BNSOL.", + { + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.getBnsolRateHistory({ + ...(params.startTime !== undefined && { startTime: params.startTime }), + ...(params.endTime !== undefined && { endTime: params.endTime }), + ...(params.current !== undefined && { current: params.current }), + ...(params.size !== undefined && { size: params.size }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved the historical data of the BNSOL staking rate. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved the historical data of the BNSOL staking rate. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve the historical data of the BNSOL staking rate. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve the historical data of the BNSOL staking rate. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/staking/SOL-staking-api/getBnsolRewardsHistory.ts b/src/modules/staking/SOL-staking-api/getBnsolRewardsHistory.ts index 360311b2..277f7189 100644 --- a/src/modules/staking/SOL-staking-api/getBnsolRewardsHistory.ts +++ b/src/modules/staking/SOL-staking-api/getBnsolRewardsHistory.ts @@ -1,71 +1,74 @@ // src/tools/binance-staking/SOL-staking-api/getBnsolRewardsHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceGetBnsolRewardsHistory(server: McpServer) { - server.tool( - "BinanceGetBnsolRewardsHistory", - "Get Boost Rewards History API allows users to retrieve their historical boost rewards data for staking, including the amount of rewards, token type (e.g., SOL), and status of the rewards (e.g., CLAIM, DISTRIBUTE).", - { - type: z - .enum(["CLAIM", "DISTRIBUTE"]) - .default("CLAIM") - .describe('Type of action. Must be "CLAIM" or "DISTRIBUTE". Default: "CLAIM"'), - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.getBnsolRewardsHistory({ - ...(params.startTime !== undefined && { startTime: params.startTime }), - ...(params.endTime !== undefined && { endTime: params.endTime }), - ...(params.current !== undefined && { current: params.current }), - ...(params.size !== undefined && { size: params.size }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - ...(params.type && { type: params.type }) - }); + server.tool( + "BinanceGetBnsolRewardsHistory", + "Get Boost Rewards History API allows users to retrieve their historical boost rewards data for staking, including the amount of rewards, token type (e.g., SOL), and status of the rewards (e.g., CLAIM, DISTRIBUTE).", + { + type: z + .enum(["CLAIM", "DISTRIBUTE"]) + .default("CLAIM") + .describe('Type of action. Must be "CLAIM" or "DISTRIBUTE". Default: "CLAIM"'), + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.getBnsolRewardsHistory({ + ...(params.startTime !== undefined && { startTime: params.startTime }), + ...(params.endTime !== undefined && { endTime: params.endTime }), + ...(params.current !== undefined && { current: params.current }), + ...(params.size !== undefined && { size: params.size }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + ...(params.type && { type: params.type }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved historical boost rewards data for staking. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved historical boost rewards data for staking. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve historical boost rewards data for staking. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve historical boost rewards data for staking. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/staking/SOL-staking-api/getBoostRewardsHistory.ts b/src/modules/staking/SOL-staking-api/getBoostRewardsHistory.ts index 790b2f0e..b4659629 100644 --- a/src/modules/staking/SOL-staking-api/getBoostRewardsHistory.ts +++ b/src/modules/staking/SOL-staking-api/getBoostRewardsHistory.ts @@ -1,70 +1,73 @@ // src/tools/binance-staking/SOL-staking-api/getBoostRewardsHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceGetBoostRewardsHistory(server: McpServer) { - server.tool( - "BinanceGetBoostRewardsHistory", - "Get Boost Rewards History API allows users to retrieve their boost rewards history for staking activities. This includes the amount of rewards received, the token type (e.g., SOL), and the status of the rewards (e.g., CLAIM or DISTRIBUTE).", - { - type: z - .enum(["CLAIM", "DISTRIBUTE"]) - .default("CLAIM") - .describe('Type of action. Must be "CLAIM" or "DISTRIBUTE". Default: "CLAIM"'), - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.getBoostRewardsHistory({ - type: params.type, - ...(params.startTime !== undefined && { startTime: params.startTime }), - ...(params.endTime !== undefined && { endTime: params.endTime }), - ...(params.current !== undefined && { current: params.current }), - ...(params.size !== undefined && { size: params.size }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); + server.tool( + "BinanceGetBoostRewardsHistory", + "Get Boost Rewards History API allows users to retrieve their boost rewards history for staking activities. This includes the amount of rewards received, the token type (e.g., SOL), and the status of the rewards (e.g., CLAIM or DISTRIBUTE).", + { + type: z + .enum(["CLAIM", "DISTRIBUTE"]) + .default("CLAIM") + .describe('Type of action. Must be "CLAIM" or "DISTRIBUTE". Default: "CLAIM"'), + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.getBoostRewardsHistory({ + type: params.type, + ...(params.startTime !== undefined && { startTime: params.startTime }), + ...(params.endTime !== undefined && { endTime: params.endTime }), + ...(params.current !== undefined && { current: params.current }), + ...(params.size !== undefined && { size: params.size }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved boost rewards history for staking activities. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved boost rewards history for staking activities. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve boost rewards history for staking activities. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve boost rewards history for staking activities. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/staking/SOL-staking-api/getSolRedemptionHistory.ts b/src/modules/staking/SOL-staking-api/getSolRedemptionHistory.ts index 009a340c..03e91757 100644 --- a/src/modules/staking/SOL-staking-api/getSolRedemptionHistory.ts +++ b/src/modules/staking/SOL-staking-api/getSolRedemptionHistory.ts @@ -1,64 +1,67 @@ // src/tools/binance-staking/SOL-staking-api/getSolRedemptionHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceGetSolRedemptionHistory(server: McpServer) { - server.tool( - "BinanceGetSolRedemptionHistory", - "Get SOL Redemption History API allows users to retrieve their SOL redemption history, detailing the amount of BNSOL redeemed for SOL and the exchange rate.", - { - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.getSolRedemptionHistory({ - ...(params.startTime !== undefined && { startTime: params.startTime }), - ...(params.endTime !== undefined && { endTime: params.endTime }), - ...(params.current !== undefined && { current: params.current }), - ...(params.size !== undefined && { size: params.size }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetSolRedemptionHistory", + "Get SOL Redemption History API allows users to retrieve their SOL redemption history, detailing the amount of BNSOL redeemed for SOL and the exchange rate.", + { + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.getSolRedemptionHistory({ + ...(params.startTime !== undefined && { startTime: params.startTime }), + ...(params.endTime !== undefined && { endTime: params.endTime }), + ...(params.current !== undefined && { current: params.current }), + ...(params.size !== undefined && { size: params.size }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved SOL redemption history. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved SOL redemption history. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve SOL redemption history. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve SOL redemption history. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/staking/SOL-staking-api/getSolStakingHistory.ts b/src/modules/staking/SOL-staking-api/getSolStakingHistory.ts index cb8f4ec9..e20e2c7c 100644 --- a/src/modules/staking/SOL-staking-api/getSolStakingHistory.ts +++ b/src/modules/staking/SOL-staking-api/getSolStakingHistory.ts @@ -1,64 +1,67 @@ // src/tools/binance-staking/SOL-staking-api/getSolStakingHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceGetSolStakingHistory(server: McpServer) { - server.tool( - "BinanceGetSolStakingHistory", - "Get SOL Staking History API allows users to retrieve their SOL staking history, including details about the amount of SOL staked, the equivalent BNSOL amount distributed, the exchange rate, and the status of each staking.", - { - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.getSolStakingHistory({ - ...(params.startTime !== undefined && { startTime: params.startTime }), - ...(params.endTime !== undefined && { endTime: params.endTime }), - ...(params.current !== undefined && { current: params.current }), - ...(params.size !== undefined && { size: params.size }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetSolStakingHistory", + "Get SOL Staking History API allows users to retrieve their SOL staking history, including details about the amount of SOL staked, the equivalent BNSOL amount distributed, the exchange rate, and the status of each staking.", + { + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.getSolStakingHistory({ + ...(params.startTime !== undefined && { startTime: params.startTime }), + ...(params.endTime !== undefined && { endTime: params.endTime }), + ...(params.current !== undefined && { current: params.current }), + ...(params.size !== undefined && { size: params.size }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved SOL staking history. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved SOL staking history. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve SOL staking history. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve SOL staking history. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/staking/SOL-staking-api/getSolStakingQuotaDetails.ts b/src/modules/staking/SOL-staking-api/getSolStakingQuotaDetails.ts index ce5df6e9..84ed7ce3 100644 --- a/src/modules/staking/SOL-staking-api/getSolStakingQuotaDetails.ts +++ b/src/modules/staking/SOL-staking-api/getSolStakingQuotaDetails.ts @@ -1,43 +1,46 @@ // src/tools/binance-staking/SOL-staking-api/getSolStakingQuotaDetails.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceGetSolStakingQuotaDetails(server: McpServer) { - server.tool( - "getSolStakingQuotaDetails", - "Get SOL Staking Quota API allows users to retrieve their current SOL staking quota, including information such as the remaining staking and redemption limits, minimum staking and redeem amounts, commission fees, and the status of staking and redemption availability.", - { - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.getSolStakingQuotaDetails({ - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "getSolStakingQuotaDetails", + "Get SOL Staking Quota API allows users to retrieve their current SOL staking quota, including information such as the remaining staking and redemption limits, minimum staking and redeem amounts, commission fees, and the status of staking and redemption availability.", + { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.getSolStakingQuotaDetails({ + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved current SOL staking quota. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved current SOL staking quota. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve current SOL staking quota. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve current SOL staking quota. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/staking/SOL-staking-api/getUnclaimedRewards.ts b/src/modules/staking/SOL-staking-api/getUnclaimedRewards.ts index 67bee5c5..93687ff9 100644 --- a/src/modules/staking/SOL-staking-api/getUnclaimedRewards.ts +++ b/src/modules/staking/SOL-staking-api/getUnclaimedRewards.ts @@ -1,45 +1,48 @@ // src/tools/binance-staking/SOL-staking-api/getUnclaimedRewards.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceGetUnclaimedRewards(server: McpServer) { - server.tool( - "BinanceGetUnclaimedRewards", - "Get Unclaimed Rewards API allows users to retrieve information about unclaimed rewards from their SOL staking activities.", - { - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.getUnclaimedRewards({ - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetUnclaimedRewards", + "Get Unclaimed Rewards API allows users to retrieve information about unclaimed rewards from their SOL staking activities.", + { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.getUnclaimedRewards({ + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved information about unclaimed rewards. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved information about unclaimed rewards. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve information about unclaimed rewards. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve information about unclaimed rewards. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/staking/SOL-staking-api/index.ts b/src/modules/staking/SOL-staking-api/index.ts index cd12159d..117dd8e1 100644 --- a/src/modules/staking/SOL-staking-api/index.ts +++ b/src/modules/staking/SOL-staking-api/index.ts @@ -1,27 +1,28 @@ // src/tools/binance-staking/SOL-staking-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceClaimBoostRewards } from "./claimBoostRewards.js"; -import { registerBinanceGetBnsolRateHistory } from "./getBnsolRateHistory.js"; -import { registerBinanceGetBnsolRewardsHistory } from "./getBnsolRewardsHistory.js"; -import { registerBinanceGetBoostRewardsHistory } from "./getBoostRewardsHistory.js"; -import { registerBinanceGetSolRedemptionHistory } from "./getSolRedemptionHistory.js"; -import { registerBinanceGetSolStakingHistory } from "./getSolStakingHistory.js"; -import { registerBinanceGetSolStakingQuotaDetails } from "./getSolStakingQuotaDetails.js"; -import { registerBinanceGetUnclaimedRewards } from "./getUnclaimedRewards.js"; -import { registerBinanceRedeemSol } from "./redeemSol.js"; -import { registerBinanceSolStakingAccount } from "./solStakingAccount.js"; -import { registerBinanceSubscribeSolStaking } from "./subscribeSolStaking.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceClaimBoostRewards } from "./claimBoostRewards.js" +import { registerBinanceGetBnsolRateHistory } from "./getBnsolRateHistory.js" +import { registerBinanceGetBnsolRewardsHistory } from "./getBnsolRewardsHistory.js" +import { registerBinanceGetBoostRewardsHistory } from "./getBoostRewardsHistory.js" +import { registerBinanceGetSolRedemptionHistory } from "./getSolRedemptionHistory.js" +import { registerBinanceGetSolStakingHistory } from "./getSolStakingHistory.js" +import { registerBinanceGetSolStakingQuotaDetails } from "./getSolStakingQuotaDetails.js" +import { registerBinanceGetUnclaimedRewards } from "./getUnclaimedRewards.js" +import { registerBinanceRedeemSol } from "./redeemSol.js" +import { registerBinanceSolStakingAccount } from "./solStakingAccount.js" +import { registerBinanceSubscribeSolStaking } from "./subscribeSolStaking.js" export function registerBinanceSOLStakingApiTools(server: McpServer) { - registerBinanceClaimBoostRewards(server); - registerBinanceGetBnsolRateHistory(server); - registerBinanceGetBnsolRewardsHistory(server); - registerBinanceGetBoostRewardsHistory(server); - registerBinanceGetSolRedemptionHistory(server); - registerBinanceGetSolStakingHistory(server); - registerBinanceGetSolStakingQuotaDetails(server); - registerBinanceGetUnclaimedRewards(server); - registerBinanceRedeemSol(server); - registerBinanceSolStakingAccount(server); - registerBinanceSubscribeSolStaking(server); + registerBinanceClaimBoostRewards(server) + registerBinanceGetBnsolRateHistory(server) + registerBinanceGetBnsolRewardsHistory(server) + registerBinanceGetBoostRewardsHistory(server) + registerBinanceGetSolRedemptionHistory(server) + registerBinanceGetSolStakingHistory(server) + registerBinanceGetSolStakingQuotaDetails(server) + registerBinanceGetUnclaimedRewards(server) + registerBinanceRedeemSol(server) + registerBinanceSolStakingAccount(server) + registerBinanceSubscribeSolStaking(server) } diff --git a/src/modules/staking/SOL-staking-api/redeemSol.ts b/src/modules/staking/SOL-staking-api/redeemSol.ts index fa98b3b1..ef2d7608 100644 --- a/src/modules/staking/SOL-staking-api/redeemSol.ts +++ b/src/modules/staking/SOL-staking-api/redeemSol.ts @@ -1,47 +1,54 @@ // src/tools/binance-staking/SOL-staking-api/getUnclaimedRewards.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceRedeemSol(server: McpServer) { - server.tool( - "registerBinanceRedeemSol", - " Redeem SOL API allows users to redeem BNSOL and receive SOL in exchange. It enables the conversion of BNSOL tokens into SOL based on the specified amount", - { - amount: z.number().min(0).max(99999999).describe("Amount in BNSOL, limit to 8 decimals (mandatory)"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.redeemSol({ - amount: params.amount, - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "registerBinanceRedeemSol", + " Redeem SOL API allows users to redeem BNSOL and receive SOL in exchange. It enables the conversion of BNSOL tokens into SOL based on the specified amount", + { + amount: z + .number() + .min(0) + .max(99999999) + .describe("Amount in BNSOL, limit to 8 decimals (mandatory)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.redeemSol({ + amount: params.amount, + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully redeem BNSOL and receive SOL in exchange. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully redeem BNSOL and receive SOL in exchange. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to redeem BNSOL and receive SOL in exchange. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to redeem BNSOL and receive SOL in exchange. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/staking/SOL-staking-api/solStakingAccount.ts b/src/modules/staking/SOL-staking-api/solStakingAccount.ts index 17506fb6..9674b5e3 100644 --- a/src/modules/staking/SOL-staking-api/solStakingAccount.ts +++ b/src/modules/staking/SOL-staking-api/solStakingAccount.ts @@ -1,43 +1,46 @@ // src/tools/binance-staking/SOL-staking-api/solStakingAccount.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceSolStakingAccount(server: McpServer) { - server.tool( - "registerBinanceSolStakingAccount", - "SOL Staking Account API allows users to view their SOL staking account details, including their current BNSOL holdings, equivalent SOL balance, and the profit in SOL over the past 30 days.", - { - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.solStakingAccount({ - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "registerBinanceSolStakingAccount", + "SOL Staking Account API allows users to view their SOL staking account details, including their current BNSOL holdings, equivalent SOL balance, and the profit in SOL over the past 30 days.", + { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.solStakingAccount({ + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieve SOL staking account details: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieve SOL staking account details: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve SOL staking account details. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve SOL staking account details. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/staking/SOL-staking-api/subscribeSolStaking.ts b/src/modules/staking/SOL-staking-api/subscribeSolStaking.ts index 65fded66..81b31bf7 100644 --- a/src/modules/staking/SOL-staking-api/subscribeSolStaking.ts +++ b/src/modules/staking/SOL-staking-api/subscribeSolStaking.ts @@ -1,45 +1,48 @@ // src/tools/binance-staking/SOL-staking-api/subscribeSolStaking.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceSubscribeSolStaking(server: McpServer) { - server.tool( - "BinanceSubscribeSolStaking", - "Subscribe SOL Staking API allows users to stake SOL and receive BNSOL in return. This endpoint requires specifying the amount of SOL to stake, and the response includes the equivalent BNSOL amount and exchange rate for SOL to BNSOL.", - { - amount: z.number().min(0).describe("Amount in SOL (mandatory)"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.subscribeSolStaking({ - amount: params.amount, - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSubscribeSolStaking", + "Subscribe SOL Staking API allows users to stake SOL and receive BNSOL in return. This endpoint requires specifying the amount of SOL to stake, and the response includes the equivalent BNSOL amount and exchange rate for SOL to BNSOL.", + { + amount: z.number().min(0).describe("Amount in SOL (mandatory)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.subscribeSolStaking({ + amount: params.amount, + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully stake SOL and receive BNSOL in return: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully stake SOL and receive BNSOL in return: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to stake SOL. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to stake SOL. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/staking/index.ts b/src/modules/staking/index.ts index e95ed99e..24764d95 100644 --- a/src/modules/staking/index.ts +++ b/src/modules/staking/index.ts @@ -1,12 +1,13 @@ // src/tools/binance-staking/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceETHStakingApiTools } from "./ETH-staking-api/index.js"; -import { registerBinanceSOLStakingApiTools } from "./SOL-staking-api/index.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceETHStakingApiTools } from "./ETH-staking-api/index.js" +import { registerBinanceSOLStakingApiTools } from "./SOL-staking-api/index.js" export function registerBinanceStakingTools(server: McpServer) { - registerBinanceETHStakingApiTools(server); - registerBinanceSOLStakingApiTools(server); + registerBinanceETHStakingApiTools(server) + registerBinanceSOLStakingApiTools(server) } // Alias for binance.ts compatibility -export { registerBinanceStakingTools as registerStaking }; +export { registerBinanceStakingTools as registerStaking } diff --git a/src/modules/sub-account/index.ts b/src/modules/sub-account/index.ts index f1fc6d63..65954ee2 100644 --- a/src/modules/sub-account/index.ts +++ b/src/modules/sub-account/index.ts @@ -1,7 +1,8 @@ // src/modules/sub-account/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceSubAccountTools } from "../../tools/binance-sub-account/index.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceSubAccountTools } from "../../tools/binance-sub-account/index.js" export function registerSubAccount(server: McpServer) { - registerBinanceSubAccountTools(server); + registerBinanceSubAccountTools(server) } diff --git a/src/modules/vip-loan/index.ts b/src/modules/vip-loan/index.ts index 60395c22..64a53cad 100644 --- a/src/modules/vip-loan/index.ts +++ b/src/modules/vip-loan/index.ts @@ -1,14 +1,15 @@ // src/tools/binance-vip-loan/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceVipLoanMarketApiTools } from "./market-api/index.js"; -import { registerBinanceVipLoanTradeApiTools } from "./trade-api/index.js"; -import { registerBinanceVipLoanUserInformationApiTools } from "./userInformation-api/index.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceVipLoanMarketApiTools } from "./market-api/index.js" +import { registerBinanceVipLoanTradeApiTools } from "./trade-api/index.js" +import { registerBinanceVipLoanUserInformationApiTools } from "./userInformation-api/index.js" export function registerBinanceVipLoanTools(server: McpServer) { - registerBinanceVipLoanMarketApiTools(server); - registerBinanceVipLoanTradeApiTools(server); - registerBinanceVipLoanUserInformationApiTools(server); + registerBinanceVipLoanMarketApiTools(server) + registerBinanceVipLoanTradeApiTools(server) + registerBinanceVipLoanUserInformationApiTools(server) } // Alias for binance.ts compatibility -export { registerBinanceVipLoanTools as registerVipLoan }; +export { registerBinanceVipLoanTools as registerVipLoan } diff --git a/src/modules/vip-loan/market-api/getBorrowInterestRate.ts b/src/modules/vip-loan/market-api/getBorrowInterestRate.ts index 51888e73..bececb1b 100644 --- a/src/modules/vip-loan/market-api/getBorrowInterestRate.ts +++ b/src/modules/vip-loan/market-api/getBorrowInterestRate.ts @@ -1,47 +1,50 @@ // src/tools/binance-vip-loan/market-api/getBorrowInterestRate.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { vipLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { vipLoanClient } from "../../../config/binanceClient.js" export function registerBinanceGetBorrowInterestRate(server: McpServer) { - server.tool( - "BinanceGetBorrowInterestRate", - "Retrieves the interest rates for borrowing assets. It provides both daily and yearly interest rates for multiple assets (e.g., BUSD, BTC). You can specify the assets by using a comma-separated list.", - { - loanCoin: z.string().min(1).describe("Max 10 assets, multiple split by ','"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await vipLoanClient.restAPI.getBorrowInterestRate({ - loanCoin: params.loanCoin, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetBorrowInterestRate", + "Retrieves the interest rates for borrowing assets. It provides both daily and yearly interest rates for multiple assets (e.g., BUSD, BTC). You can specify the assets by using a comma-separated list.", + { + loanCoin: z.string().min(1).describe("Max 10 assets, multiple split by ','"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await vipLoanClient.restAPI.getBorrowInterestRate({ + loanCoin: params.loanCoin, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved the interest rates for borrowing assets. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved the interest rates for borrowing assets. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve the interest rates for borrowing assets. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve the interest rates for borrowing assets. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/vip-loan/market-api/getCollateralAssetData.ts b/src/modules/vip-loan/market-api/getCollateralAssetData.ts index 5f9c7a34..b3ac53ff 100644 --- a/src/modules/vip-loan/market-api/getCollateralAssetData.ts +++ b/src/modules/vip-loan/market-api/getCollateralAssetData.ts @@ -1,47 +1,50 @@ // src/tools/binance-vip-loan/market-api/getCollateralAssetData.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { vipLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { vipLoanClient } from "../../../config/binanceClient.js" export function registerBinanceGetCollateralAssetData(server: McpServer) { - server.tool( - "BinanceGetCollateralAssetData", - "Retrieves information about collateral assets, including collateral ratios and range values for different tiers of collateral. The ratios are used to determine the collateral requirement for various levels of borrowing.", - { - collateralCoin: z.string().optional().describe("Optional: Coin used as collateral"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await vipLoanClient.restAPI.getCollateralAssetData({ - ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetCollateralAssetData", + "Retrieves information about collateral assets, including collateral ratios and range values for different tiers of collateral. The ratios are used to determine the collateral requirement for various levels of borrowing.", + { + collateralCoin: z.string().optional().describe("Optional: Coin used as collateral"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await vipLoanClient.restAPI.getCollateralAssetData({ + ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved information about collateral assets. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved information about collateral assets. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve information about collateral assets. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve information about collateral assets. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/vip-loan/market-api/getLoanableAssetsData.ts b/src/modules/vip-loan/market-api/getLoanableAssetsData.ts index 5c256508..69acff8d 100644 --- a/src/modules/vip-loan/market-api/getLoanableAssetsData.ts +++ b/src/modules/vip-loan/market-api/getLoanableAssetsData.ts @@ -1,49 +1,56 @@ // src/tools/binance-vip-loan/market-api/getLoanableAssetsData.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { vipLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { vipLoanClient } from "../../../config/binanceClient.js" export function registerBinanceGetLoanableAssetsData(server: McpServer) { - server.tool( - "BinanceGetLoanableAssetsData", - "Retrieves interest rates and borrowing limits for loanable assets. The borrow limit is expressed in USD. You can request information for specific assets or leave it empty to query all available assets.", - { - loanCoin: z.string().optional().describe("Optional: Coin for the loan"), - vipLevel: z.number().int().optional().describe("Optional: User's VIP level (default is user's vip level)"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await vipLoanClient.restAPI.getLoanableAssetsData({ - ...(params.loanCoin && { loanCoin: params.loanCoin }), - ...(params.vipLevel && { vipLevel: params.vipLevel }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetLoanableAssetsData", + "Retrieves interest rates and borrowing limits for loanable assets. The borrow limit is expressed in USD. You can request information for specific assets or leave it empty to query all available assets.", + { + loanCoin: z.string().optional().describe("Optional: Coin for the loan"), + vipLevel: z + .number() + .int() + .optional() + .describe("Optional: User's VIP level (default is user's vip level)"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await vipLoanClient.restAPI.getLoanableAssetsData({ + ...(params.loanCoin && { loanCoin: params.loanCoin }), + ...(params.vipLevel && { vipLevel: params.vipLevel }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved interest rates and borrowing limits for loanable assets. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved interest rates and borrowing limits for loanable assets. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve interest rates and borrowing limits for loanable assets. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve interest rates and borrowing limits for loanable assets. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/vip-loan/market-api/index.ts b/src/modules/vip-loan/market-api/index.ts index 3e0ee81a..ffc74390 100644 --- a/src/modules/vip-loan/market-api/index.ts +++ b/src/modules/vip-loan/market-api/index.ts @@ -1,11 +1,12 @@ // src/tools/binance-vip-loan/market-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetBorrowInterestRate } from "./getBorrowInterestRate.js"; -import { registerBinanceGetLoanableAssetsData } from "./getLoanableAssetsData.js"; -import { registerBinanceGetCollateralAssetData } from "./getCollateralAssetData.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceGetBorrowInterestRate } from "./getBorrowInterestRate.js" +import { registerBinanceGetCollateralAssetData } from "./getCollateralAssetData.js" +import { registerBinanceGetLoanableAssetsData } from "./getLoanableAssetsData.js" export function registerBinanceVipLoanMarketApiTools(server: McpServer) { - registerBinanceGetBorrowInterestRate(server); - registerBinanceGetCollateralAssetData(server); - registerBinanceGetLoanableAssetsData(server); + registerBinanceGetBorrowInterestRate(server) + registerBinanceGetCollateralAssetData(server) + registerBinanceGetLoanableAssetsData(server) } diff --git a/src/modules/vip-loan/trade-api/index.ts b/src/modules/vip-loan/trade-api/index.ts index 7395b3ff..85a97036 100644 --- a/src/modules/vip-loan/trade-api/index.ts +++ b/src/modules/vip-loan/trade-api/index.ts @@ -1,11 +1,12 @@ // src/tools/binance-vip-loan/trade-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceVipLoanRenew } from "./vipLoanRenew.js"; -import { registerBinanceVipLoanRepay } from "./vipLoanRepay.js"; -import { registerBinanceVipLoanBorrow } from "./vipLoanBorrow.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceVipLoanBorrow } from "./vipLoanBorrow.js" +import { registerBinanceVipLoanRenew } from "./vipLoanRenew.js" +import { registerBinanceVipLoanRepay } from "./vipLoanRepay.js" export function registerBinanceVipLoanTradeApiTools(server: McpServer) { - registerBinanceVipLoanRenew(server); - registerBinanceVipLoanRepay(server); - registerBinanceVipLoanBorrow(server); + registerBinanceVipLoanRenew(server) + registerBinanceVipLoanRepay(server) + registerBinanceVipLoanBorrow(server) } diff --git a/src/modules/vip-loan/trade-api/vipLoanBorrow.ts b/src/modules/vip-loan/trade-api/vipLoanBorrow.ts index 2dc82b5f..032e83c4 100644 --- a/src/modules/vip-loan/trade-api/vipLoanBorrow.ts +++ b/src/modules/vip-loan/trade-api/vipLoanBorrow.ts @@ -1,59 +1,69 @@ // src/tools/binance-vip-loan/trade-api/vipLoanBorrow.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { vipLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { vipLoanClient } from "../../../config/binanceClient.js" export function registerBinanceVipLoanBorrow(server: McpServer) { - server.tool( - "BinanceVipLoanBorrow", - "Allow users (master account only) to apply for a loan by pledging collateral. Users specify the coin they want to borrow, the amount, and the collateral details.", - { - loanAccountId: z.number().int().describe("Loan account ID"), - loanCoin: z.string().min(1).describe("Loan coin (e.g., BTC, ETH)"), - loanAmount: z.number().describe("Loan amount as decimal"), - collateralAccountId: z.string().min(1).describe("Collateral account IDs, separated by commas"), - collateralCoin: z.string().min(1).describe("Collateral coins, separated by commas"), - isFlexibleRate: z.boolean().describe("TRUE: flexible rate, FALSE: fixed rate. Default: TRUE"), - loanTerm: z.number().int().optional().describe("Loan term (only required if fixed rate, e.g., 30/60 days)"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await vipLoanClient.restAPI.vipLoanBorrow({ - loanAccountId: params.loanAccountId, - loanCoin: params.loanCoin, - loanAmount: params.loanAmount, - collateralAccountId: params.collateralAccountId, - collateralCoin: params.collateralCoin, - isFlexibleRate: params.isFlexibleRate, - ...(params.loanTerm !== undefined && { loanTerm: params.loanTerm }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceVipLoanBorrow", + "Allow users (master account only) to apply for a loan by pledging collateral. Users specify the coin they want to borrow, the amount, and the collateral details.", + { + loanAccountId: z.number().int().describe("Loan account ID"), + loanCoin: z.string().min(1).describe("Loan coin (e.g., BTC, ETH)"), + loanAmount: z.number().describe("Loan amount as decimal"), + collateralAccountId: z + .string() + .min(1) + .describe("Collateral account IDs, separated by commas"), + collateralCoin: z.string().min(1).describe("Collateral coins, separated by commas"), + isFlexibleRate: z.boolean().describe("TRUE: flexible rate, FALSE: fixed rate. Default: TRUE"), + loanTerm: z + .number() + .int() + .optional() + .describe("Loan term (only required if fixed rate, e.g., 30/60 days)"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await vipLoanClient.restAPI.vipLoanBorrow({ + loanAccountId: params.loanAccountId, + loanCoin: params.loanCoin, + loanAmount: params.loanAmount, + collateralAccountId: params.collateralAccountId, + collateralCoin: params.collateralCoin, + isFlexibleRate: params.isFlexibleRate, + ...(params.loanTerm !== undefined && { loanTerm: params.loanTerm }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully apply for a loan by pledging collateral. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully apply for a loan by pledging collateral. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to apply for a loan by pledging collateral. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to apply for a loan by pledging collateral. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/vip-loan/trade-api/vipLoanRenew.ts b/src/modules/vip-loan/trade-api/vipLoanRenew.ts index 50e7491c..2699fbb4 100644 --- a/src/modules/vip-loan/trade-api/vipLoanRenew.ts +++ b/src/modules/vip-loan/trade-api/vipLoanRenew.ts @@ -1,46 +1,55 @@ // src/tools/binance-vip-loan/trade-api/vipLoanRenew.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { vipLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { vipLoanClient } from "../../../config/binanceClient.js" export function registerBinanceVipLoanRenew(server: McpServer) { - server.tool( - "BinanceVipLoanRenew", - "Allow VIP users to renew an existing VIP loan for a specified term, either 30 or 60 days.", - { - orderId: z.number().int().describe("The order ID for the loan request"), - loanTerm: z.union([z.literal(30), z.literal(60)]).describe("Loan term in days, either 30 or 60"), - recvWindow: z.number().int().optional().describe("Optional: Time window for request validity") - }, - async (params) => { - try { - const response = await vipLoanClient.restAPI.vipLoanRenew({ - orderId: params.orderId, - loanTerm: params.loanTerm, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); + server.tool( + "BinanceVipLoanRenew", + "Allow VIP users to renew an existing VIP loan for a specified term, either 30 or 60 days.", + { + orderId: z.number().int().describe("The order ID for the loan request"), + loanTerm: z + .union([z.literal(30), z.literal(60)]) + .describe("Loan term in days, either 30 or 60"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional: Time window for request validity"), + }, + async (params) => { + try { + const response = await vipLoanClient.restAPI.vipLoanRenew({ + orderId: params.orderId, + loanTerm: params.loanTerm, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully renew an existing VIP loan. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully renew an existing VIP loan. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to renew an existing VIP loan. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to renew an existing VIP loan. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/vip-loan/trade-api/vipLoanRepay.ts b/src/modules/vip-loan/trade-api/vipLoanRepay.ts index e6389ef0..8f8d7041 100644 --- a/src/modules/vip-loan/trade-api/vipLoanRepay.ts +++ b/src/modules/vip-loan/trade-api/vipLoanRepay.ts @@ -1,47 +1,50 @@ // src/tools/binance-vip-loan/trade-api/vipLoanRepay.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { vipLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { vipLoanClient } from "../../../config/binanceClient.js" export function registerBinanceVipLoanRepay(server: McpServer) { - server.tool( - "BinanceVipLoanRepay", - "Allow VIP users to repay a specified amount of their active loan, partially or fully. It updates the remaining principal and interest, and provides the repayment status.", - { - orderId: z.number().int().describe("Order ID of the loan request"), - amount: z.number().describe("Amount to be processed (decimal allowed)"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await vipLoanClient.restAPI.vipLoanRepay({ - orderId: params.orderId, - amount: params.amount, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceVipLoanRepay", + "Allow VIP users to repay a specified amount of their active loan, partially or fully. It updates the remaining principal and interest, and provides the repayment status.", + { + orderId: z.number().int().describe("Order ID of the loan request"), + amount: z.number().describe("Amount to be processed (decimal allowed)"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await vipLoanClient.restAPI.vipLoanRepay({ + orderId: params.orderId, + amount: params.amount, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully repay the active loan. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully repay the active loan. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to repay the active loan. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to repay the active loan. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/vip-loan/userInformation-api/checkVIPLoanCollateralAccount.ts b/src/modules/vip-loan/userInformation-api/checkVIPLoanCollateralAccount.ts index 841d583e..ca85b235 100644 --- a/src/modules/vip-loan/userInformation-api/checkVIPLoanCollateralAccount.ts +++ b/src/modules/vip-loan/userInformation-api/checkVIPLoanCollateralAccount.ts @@ -1,51 +1,54 @@ // src/tools/binance-vip-loan/userInformation-api/checkVIPLoanCollateralAccount.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { vipLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { vipLoanClient } from "../../../config/binanceClient.js" export function registerBinanceCheckVIPLoanCollateralAccount(server: McpServer) { - server.tool( - "BinanceCheckVIPLoanCollateralAccount", - "Allow users to check their collateral accounts and the coins held as collateral. If the logged-in account is a loan account, it will return all associated collateral accounts. If it's a collateral account, it returns details of the current account only.", - { - orderId: z.number().int().optional().describe("Optional order ID"), - collateralAccountId: z.number().int().optional().describe("Optional collateral account ID"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await vipLoanClient.restAPI.checkVIPLoanCollateralAccount({ - ...(params.orderId !== undefined && { orderId: params.orderId }), - ...(params.collateralAccountId !== undefined && { - collateralAccountId: params.collateralAccountId - }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCheckVIPLoanCollateralAccount", + "Allow users to check their collateral accounts and the coins held as collateral. If the logged-in account is a loan account, it will return all associated collateral accounts. If it's a collateral account, it returns details of the current account only.", + { + orderId: z.number().int().optional().describe("Optional order ID"), + collateralAccountId: z.number().int().optional().describe("Optional collateral account ID"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await vipLoanClient.restAPI.checkVIPLoanCollateralAccount({ + ...(params.orderId !== undefined && { orderId: params.orderId }), + ...(params.collateralAccountId !== undefined && { + collateralAccountId: params.collateralAccountId, + }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved collateral accounts and the coins held as collateral. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved collateral accounts and the coins held as collateral. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve collateral accounts and the coins held as collateral. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve collateral accounts and the coins held as collateral. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/vip-loan/userInformation-api/getVIPLoanOngoingOrders.ts b/src/modules/vip-loan/userInformation-api/getVIPLoanOngoingOrders.ts index 70c69c6f..4effee4e 100644 --- a/src/modules/vip-loan/userInformation-api/getVIPLoanOngoingOrders.ts +++ b/src/modules/vip-loan/userInformation-api/getVIPLoanOngoingOrders.ts @@ -1,59 +1,74 @@ // src/tools/binance-vip-loan/userInformation-api/getVIPLoanOngoingOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { vipLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { vipLoanClient } from "../../../config/binanceClient.js" export function registerBinanceGetVIPLoanOngoingOrders(server: McpServer) { - server.tool( - "BinanceGetVIPLoanOngoingOrders", - "Allows VIP users to retrieve a list of their current active loan orders. Users can filter results by loan coin, collateral coin, order ID, or collateral account ID.", - { - orderId: z.number().int().optional().describe("Optional order ID"), - collateralAccountId: z.number().int().optional().describe("Optional collateral account ID"), - loanCoin: z.string().optional().describe("Optional loan coin"), - collateralCoin: z.string().optional().describe("Optional collateral coin"), - current: z.number().int().min(1).max(1000).optional().describe("Current page, start from 1, max 1000"), - limit: z.number().int().min(1).max(100).optional().describe("Results per page, default 10, max 100"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await vipLoanClient.restAPI.getVIPLoanOngoingOrders({ - ...(params.orderId !== undefined && { orderId: params.orderId }), - ...(params.collateralAccountId !== undefined && { - collateralAccountId: params.collateralAccountId - }), - ...(params.loanCoin !== undefined && { loanCoin: params.loanCoin }), - ...(params.collateralCoin !== undefined && { collateralCoin: params.collateralCoin }), - ...(params.current !== undefined && { current: params.current }), - ...(params.limit !== undefined && { limit: params.limit }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetVIPLoanOngoingOrders", + "Allows VIP users to retrieve a list of their current active loan orders. Users can filter results by loan coin, collateral coin, order ID, or collateral account ID.", + { + orderId: z.number().int().optional().describe("Optional order ID"), + collateralAccountId: z.number().int().optional().describe("Optional collateral account ID"), + loanCoin: z.string().optional().describe("Optional loan coin"), + collateralCoin: z.string().optional().describe("Optional collateral coin"), + current: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .describe("Current page, start from 1, max 1000"), + limit: z + .number() + .int() + .min(1) + .max(100) + .optional() + .describe("Results per page, default 10, max 100"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await vipLoanClient.restAPI.getVIPLoanOngoingOrders({ + ...(params.orderId !== undefined && { orderId: params.orderId }), + ...(params.collateralAccountId !== undefined && { + collateralAccountId: params.collateralAccountId, + }), + ...(params.loanCoin !== undefined && { loanCoin: params.loanCoin }), + ...(params.collateralCoin !== undefined && { collateralCoin: params.collateralCoin }), + ...(params.current !== undefined && { current: params.current }), + ...(params.limit !== undefined && { limit: params.limit }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved list of their current active loan orders. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved list of their current active loan orders. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve list of their current active loan orders. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve list of their current active loan orders. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/vip-loan/userInformation-api/index.ts b/src/modules/vip-loan/userInformation-api/index.ts index 58bad6e4..82cd64ab 100644 --- a/src/modules/vip-loan/userInformation-api/index.ts +++ b/src/modules/vip-loan/userInformation-api/index.ts @@ -1,11 +1,12 @@ // src/tools/binance-vip-loan/userInformation-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceCheckVIPLoanCollateralAccount } from "./checkVIPLoanCollateralAccount.js"; -import { registerBinanceGetVIPLoanOngoingOrders } from "./getVIPLoanOngoingOrders.js"; -import { registerBinanceQueryApplicationStatus } from "./queryApplicationStatus.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceCheckVIPLoanCollateralAccount } from "./checkVIPLoanCollateralAccount.js" +import { registerBinanceGetVIPLoanOngoingOrders } from "./getVIPLoanOngoingOrders.js" +import { registerBinanceQueryApplicationStatus } from "./queryApplicationStatus.js" export function registerBinanceVipLoanUserInformationApiTools(server: McpServer) { - registerBinanceCheckVIPLoanCollateralAccount(server); - registerBinanceGetVIPLoanOngoingOrders(server); - registerBinanceQueryApplicationStatus(server); + registerBinanceCheckVIPLoanCollateralAccount(server) + registerBinanceGetVIPLoanOngoingOrders(server) + registerBinanceQueryApplicationStatus(server) } diff --git a/src/modules/vip-loan/userInformation-api/queryApplicationStatus.ts b/src/modules/vip-loan/userInformation-api/queryApplicationStatus.ts index 7d5e5a05..aa8a6295 100644 --- a/src/modules/vip-loan/userInformation-api/queryApplicationStatus.ts +++ b/src/modules/vip-loan/userInformation-api/queryApplicationStatus.ts @@ -1,55 +1,58 @@ // src/tools/binance-vip-loan/userInformation-api/queryApplicationStatus.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { vipLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { vipLoanClient } from "../../../config/binanceClient.js" export function registerBinanceQueryApplicationStatus(server: McpServer) { - server.tool( - "BinanceQueryApplicationStatus", - "Allows VIP users to check the status of their loan applications. It returns a list of loan requests with details such as loan coin, amount, term, collateral details, and current application status", - { - current: z - .number() - .int() - .min(1) - .max(1000) - .optional() - .describe("Currently querying page. Start from 1, default 1, max 1000"), - limit: z.number().int().min(1).max(100).optional().describe("Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await vipLoanClient.restAPI.queryApplicationStatus({ - ...(params.current !== undefined && { current: params.current }), - ...(params.limit !== undefined && { limit: params.limit }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceQueryApplicationStatus", + "Allows VIP users to check the status of their loan applications. It returns a list of loan requests with details such as loan coin, amount, term, collateral details, and current application status", + { + current: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .describe("Currently querying page. Start from 1, default 1, max 1000"), + limit: z.number().int().min(1).max(100).optional().describe("Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await vipLoanClient.restAPI.queryApplicationStatus({ + ...(params.current !== undefined && { current: params.current }), + ...(params.limit !== undefined && { limit: params.limit }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved status of their loan applications. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved status of their loan applications. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve status of their loan applications.. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve status of their loan applications.. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/modules/wallet/account-api/accountApiTradingStatus.ts b/src/modules/wallet/account-api/accountApiTradingStatus.ts index d5ed7e7b..c24c0226 100644 --- a/src/modules/wallet/account-api/accountApiTradingStatus.ts +++ b/src/modules/wallet/account-api/accountApiTradingStatus.ts @@ -1,40 +1,46 @@ // src/tools/binance-wallet/account-api/accountApiTradingStatus.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletAccountApiTradingStatus(server: McpServer) { - server.tool( - "BinanceWalletAccountApiTradingStatus", - "Get account API trading status.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: any = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.accountApiTradingStatus(params); - const data = await response.data(); + server.tool( + "BinanceWalletAccountApiTradingStatus", + "Get account API trading status.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: any = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.accountApiTradingStatus(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved account API trading status. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved account API trading status. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve account API trading status: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve account API trading status: ${errorMessage}`, + }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/account-api/accountInfo.ts b/src/modules/wallet/account-api/accountInfo.ts index 4b426dc4..39b964df 100644 --- a/src/modules/wallet/account-api/accountInfo.ts +++ b/src/modules/wallet/account-api/accountInfo.ts @@ -1,40 +1,46 @@ // src/tools/binance-wallet/account-api/accountInfo.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletAccountInfo(server: McpServer) { - server.tool( - "BinanceWalletAccountInfo", - "Get Binance Wallet account information.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: any = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.accountInfo(params); - const data = await response.data(); + server.tool( + "BinanceWalletAccountInfo", + "Get Binance Wallet account information.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: any = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.accountInfo(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved wallet account information. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved wallet account information. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve wallet account information: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve wallet account information: ${errorMessage}`, + }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/account-api/accountStatus.ts b/src/modules/wallet/account-api/accountStatus.ts index e5efdcec..4cefe42b 100644 --- a/src/modules/wallet/account-api/accountStatus.ts +++ b/src/modules/wallet/account-api/accountStatus.ts @@ -1,40 +1,43 @@ // src/tools/binance-wallet/account-api/accountStatus.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletAccountStatus(server: McpServer) { - server.tool( - "BinanceWalletAccountStatus", - "Get Binance Wallet account status.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: any = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.accountStatus(params); - const data = await response.data(); + server.tool( + "BinanceWalletAccountStatus", + "Get Binance Wallet account status.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: any = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.accountStatus(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved wallet account status. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved wallet account status. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve wallet account status: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve wallet account status: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/account-api/dailyAccountSnapshot.ts b/src/modules/wallet/account-api/dailyAccountSnapshot.ts index 8bfde6f8..145e3db8 100644 --- a/src/modules/wallet/account-api/dailyAccountSnapshot.ts +++ b/src/modules/wallet/account-api/dailyAccountSnapshot.ts @@ -1,47 +1,50 @@ // src/tools/binance-wallet/account-api/dailyAccountSnapshot.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletDailyAccountSnapshot(server: McpServer) { - server.tool( - "BinanceWalletDailyAccountSnapshot", - "Get daily account snapshot.", - { - type: z.string().describe("The account type (e.g., SPOT, MARGIN, FUTURES)"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 7, max 30"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ type, startTime, endTime, limit, recvWindow }) => { - try { - const params: any = { type }; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.dailyAccountSnapshot(params); - const data = await response.data(); + server.tool( + "BinanceWalletDailyAccountSnapshot", + "Get daily account snapshot.", + { + type: z.string().describe("The account type (e.g., SPOT, MARGIN, FUTURES)"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 7, max 30"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ type, startTime, endTime, limit, recvWindow }) => { + try { + const params: any = { type } + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.dailyAccountSnapshot(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved daily account snapshot for ${type}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved daily account snapshot for ${type}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve daily account snapshot: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve daily account snapshot: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/account-api/disableFastWithdrawSwitch.ts b/src/modules/wallet/account-api/disableFastWithdrawSwitch.ts index 5e0e8106..f348aaa2 100644 --- a/src/modules/wallet/account-api/disableFastWithdrawSwitch.ts +++ b/src/modules/wallet/account-api/disableFastWithdrawSwitch.ts @@ -1,40 +1,43 @@ // src/tools/binance-wallet/account-api/disableFastWithdrawSwitch.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletDisableFastWithdrawSwitch(server: McpServer) { - server.tool( - "BinanceWalletDisableFastWithdrawSwitch", - "Disable fast withdraw switch.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: any = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.disableFastWithdrawSwitch(params); - const data = await response.data(); + server.tool( + "BinanceWalletDisableFastWithdrawSwitch", + "Disable fast withdraw switch.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: any = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.disableFastWithdrawSwitch(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Disabled fast withdraw switch. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Disabled fast withdraw switch. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to disable fast withdraw switch: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to disable fast withdraw switch: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/account-api/enableFastWithdrawSwitch.ts b/src/modules/wallet/account-api/enableFastWithdrawSwitch.ts index d6679332..08b0430f 100644 --- a/src/modules/wallet/account-api/enableFastWithdrawSwitch.ts +++ b/src/modules/wallet/account-api/enableFastWithdrawSwitch.ts @@ -1,40 +1,43 @@ // src/tools/binance-wallet/account-api/enableFastWithdrawSwitch.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletEnableFastWithdrawSwitch(server: McpServer) { - server.tool( - "BinanceWalletEnableFastWithdrawSwitch", - "Enable fast withdraw switch.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: any = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.enableFastWithdrawSwitch(params); - const data = await response.data(); + server.tool( + "BinanceWalletEnableFastWithdrawSwitch", + "Enable fast withdraw switch.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: any = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.enableFastWithdrawSwitch(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Enabled fast withdraw switch. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Enabled fast withdraw switch. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to enable fast withdraw switch: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to enable fast withdraw switch: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/account-api/getApiKeyPermission.ts b/src/modules/wallet/account-api/getApiKeyPermission.ts index 773e8175..782053fb 100644 --- a/src/modules/wallet/account-api/getApiKeyPermission.ts +++ b/src/modules/wallet/account-api/getApiKeyPermission.ts @@ -1,40 +1,43 @@ // src/tools/binance-wallet/account-api/getApiKeyPermission.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletGetApiKeyPermission(server: McpServer) { - server.tool( - "BinanceWalletGetApiKeyPermission", - "Get API key permission.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: any = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.getApiKeyPermission(params); - const data = await response.data(); + server.tool( + "BinanceWalletGetApiKeyPermission", + "Get API key permission.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: any = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.getApiKeyPermission(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved API key permission. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved API key permission. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve API key permission: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve API key permission: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/account-api/index.ts b/src/modules/wallet/account-api/index.ts index 0b8cfdf0..c01341a4 100644 --- a/src/modules/wallet/account-api/index.ts +++ b/src/modules/wallet/account-api/index.ts @@ -1,20 +1,20 @@ // src/tools/binance-wallet/account-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceWalletDailyAccountSnapshot } from "./dailyAccountSnapshot.js"; -import { registerBinanceWalletGetApiKeyPermission } from "./getApiKeyPermission.js"; -import { registerBinanceWalletAccountInfo } from "./accountInfo.js"; -import { registerBinanceWalletAccountStatus } from "./accountStatus.js"; -import { registerBinanceWalletAccountApiTradingStatus } from "./accountApiTradingStatus.js"; -import { registerBinanceWalletEnableFastWithdrawSwitch } from "./enableFastWithdrawSwitch.js"; -import { registerBinanceWalletDisableFastWithdrawSwitch } from "./disableFastWithdrawSwitch.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceWalletAccountApiTradingStatus } from "./accountApiTradingStatus.js" +import { registerBinanceWalletAccountInfo } from "./accountInfo.js" +import { registerBinanceWalletAccountStatus } from "./accountStatus.js" +import { registerBinanceWalletDailyAccountSnapshot } from "./dailyAccountSnapshot.js" +import { registerBinanceWalletDisableFastWithdrawSwitch } from "./disableFastWithdrawSwitch.js" +import { registerBinanceWalletEnableFastWithdrawSwitch } from "./enableFastWithdrawSwitch.js" +import { registerBinanceWalletGetApiKeyPermission } from "./getApiKeyPermission.js" export function registerBinanceWalletAccountApiTools(server: McpServer) { - registerBinanceWalletDailyAccountSnapshot(server); - registerBinanceWalletGetApiKeyPermission(server); - registerBinanceWalletAccountInfo(server); - registerBinanceWalletAccountStatus(server); - registerBinanceWalletAccountApiTradingStatus(server); - registerBinanceWalletEnableFastWithdrawSwitch(server); - registerBinanceWalletDisableFastWithdrawSwitch(server); - -} \ No newline at end of file + registerBinanceWalletDailyAccountSnapshot(server) + registerBinanceWalletGetApiKeyPermission(server) + registerBinanceWalletAccountInfo(server) + registerBinanceWalletAccountStatus(server) + registerBinanceWalletAccountApiTradingStatus(server) + registerBinanceWalletEnableFastWithdrawSwitch(server) + registerBinanceWalletDisableFastWithdrawSwitch(server) +} diff --git a/src/modules/wallet/asset-api/assetDetail.ts b/src/modules/wallet/asset-api/assetDetail.ts index 8eabf38b..33f3dd6b 100644 --- a/src/modules/wallet/asset-api/assetDetail.ts +++ b/src/modules/wallet/asset-api/assetDetail.ts @@ -1,42 +1,43 @@ // src/tools/binance-wallet/asset-api/assetDetail.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletAssetDetail(server: McpServer) { - server.tool( - "BinanceWalletAssetDetail", - "Get asset details.", - { - asset: z.string().optional().describe("Asset symbol"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ asset, recvWindow }) => { - try { - const params: any = {}; - if (asset !== undefined) params.asset = asset; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.assetDetail(params); - const data = await response.data(); + server.tool( + "BinanceWalletAssetDetail", + "Get asset details.", + { + asset: z.string().optional().describe("Asset symbol"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ asset, recvWindow }) => { + try { + const params: any = {} + if (asset !== undefined) params.asset = asset + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.assetDetail(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved asset details. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved asset details. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve asset details: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve asset details: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/asset-api/assetDividendRecord.ts b/src/modules/wallet/asset-api/assetDividendRecord.ts index c24cff7d..038cf6aa 100644 --- a/src/modules/wallet/asset-api/assetDividendRecord.ts +++ b/src/modules/wallet/asset-api/assetDividendRecord.ts @@ -1,48 +1,51 @@ // src/tools/binance-wallet/asset-api/assetDividendRecord.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletAssetDividendRecord(server: McpServer) { - server.tool( - "BinanceWalletAssetDividendRecord", - "Get asset dividend record.", - { - asset: z.string().optional().describe("Asset symbol"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 20, max 500"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ asset, startTime, endTime, limit, recvWindow }) => { - try { - const params: any = {}; - if (asset !== undefined) params.asset = asset; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.assetDividendRecord(params); - const data = await response.data(); + server.tool( + "BinanceWalletAssetDividendRecord", + "Get asset dividend record.", + { + asset: z.string().optional().describe("Asset symbol"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 20, max 500"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ asset, startTime, endTime, limit, recvWindow }) => { + try { + const params: any = {} + if (asset !== undefined) params.asset = asset + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.assetDividendRecord(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved asset dividend record. Total records: ${data.total || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved asset dividend record. Total records: ${data.total || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve asset dividend record: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve asset dividend record: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/asset-api/dustTransfer.ts b/src/modules/wallet/asset-api/dustTransfer.ts index 74d7b520..bc1ebf68 100644 --- a/src/modules/wallet/asset-api/dustTransfer.ts +++ b/src/modules/wallet/asset-api/dustTransfer.ts @@ -1,42 +1,42 @@ - // src/tools/binance-wallet/asset-api/dustTransfer.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletDustTransfer(server: McpServer) { - server.tool( - "BinanceWalletDustTransfer", - "Convert dust assets to BNB.", - { - asset: z.array(z.string()).describe("Array of asset symbols to convert"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ asset, recvWindow }) => { - try { - const params: any = { asset }; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.dustTransfer(params); - const data = await response.data(); + server.tool( + "BinanceWalletDustTransfer", + "Convert dust assets to BNB.", + { + asset: z.array(z.string()).describe("Array of asset symbols to convert"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ asset, recvWindow }) => { + try { + const params: any = { asset } + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.dustTransfer(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Dust transfer completed. Total BNB received: ${data.totalServiceCharge || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Dust transfer completed. Total BNB received: ${data.totalServiceCharge || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to process dust transfer: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to process dust transfer: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/asset-api/dustlog.ts b/src/modules/wallet/asset-api/dustlog.ts index 9ad92947..f86dd243 100644 --- a/src/modules/wallet/asset-api/dustlog.ts +++ b/src/modules/wallet/asset-api/dustlog.ts @@ -1,44 +1,45 @@ // src/tools/binance-wallet/asset-api/dustlog.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletDustlog(server: McpServer) { - server.tool( - "BinanceWalletDustlog", - "Get dust log (history of dust transfers).", - { - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ startTime, endTime, recvWindow }) => { - try { - const params: any = {}; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.dustlog(params); - const data = await response.data(); + server.tool( + "BinanceWalletDustlog", + "Get dust log (history of dust transfers).", + { + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ startTime, endTime, recvWindow }) => { + try { + const params: any = {} + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.dustlog(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved dust log. Total transfers: ${data.total || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved dust log. Total transfers: ${data.total || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve dust log: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve dust log: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/asset-api/fundingWallet.ts b/src/modules/wallet/asset-api/fundingWallet.ts index 0a08c73f..28ecfab4 100644 --- a/src/modules/wallet/asset-api/fundingWallet.ts +++ b/src/modules/wallet/asset-api/fundingWallet.ts @@ -1,44 +1,47 @@ // src/tools/binance-wallet/asset-api/fundingWallet.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletFundingWallet(server: McpServer) { - server.tool( - "BinanceWalletFundingWallet", - "Get funding wallet balance.", - { - asset: z.string().optional().describe("Asset symbol"), - needBtcValuation: z.boolean().optional().describe("Whether to include BTC valuation"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ asset, needBtcValuation, recvWindow }) => { - try { - const params: any = {}; - if (asset !== undefined) params.asset = asset; - if (needBtcValuation !== undefined) params.needBtcValuation = needBtcValuation; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.fundingWallet(params); - const data = await response.data(); + server.tool( + "BinanceWalletFundingWallet", + "Get funding wallet balance.", + { + asset: z.string().optional().describe("Asset symbol"), + needBtcValuation: z.boolean().optional().describe("Whether to include BTC valuation"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ asset, needBtcValuation, recvWindow }) => { + try { + const params: any = {} + if (asset !== undefined) params.asset = asset + if (needBtcValuation !== undefined) params.needBtcValuation = needBtcValuation + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.fundingWallet(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved funding wallet balance. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved funding wallet balance. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve funding wallet balance: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve funding wallet balance: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts b/src/modules/wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts index 8c5a3ef1..aa233936 100644 --- a/src/modules/wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts +++ b/src/modules/wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts @@ -1,40 +1,43 @@ // src/tools/binance-wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletGetAssetsThatCanBeConvertedIntoBnb(server: McpServer) { - server.tool( - "BinanceWalletGetAssetsThatCanBeConvertedIntoBnb", - "Get assets that can be converted to BNB.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: any = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.getAssetsThatCanBeConvertedIntoBnb(params); - const data = await response.data(); + server.tool( + "BinanceWalletGetAssetsThatCanBeConvertedIntoBnb", + "Get assets that can be converted to BNB.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: any = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.getAssetsThatCanBeConvertedIntoBnb(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved assets that can be converted to BNB. Total: ${data.details?.length || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved assets that can be converted to BNB. Total: ${data.details?.length || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve convertible assets: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve convertible assets: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts b/src/modules/wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts index d8317c6b..52652ef4 100644 --- a/src/modules/wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts +++ b/src/modules/wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts @@ -1,49 +1,52 @@ // src/tools/binance-wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletGetCloudMiningPaymentAndRefundHistory(server: McpServer) { - server.tool( - "BinanceWalletGetCloudMiningPaymentAndRefundHistory", - "Get cloud mining payment and refund history.", - { - startTime: z.number().describe("Start time in milliseconds"), - endTime: z.number().describe("End time in milliseconds"), - page: z.number().optional().describe("Page number"), - pageSize: z.number().optional().describe("Page size"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ startTime, endTime, page, pageSize, recvWindow }) => { - try { - const params: any = { - startTime, - endTime - }; - if (page !== undefined) params.page = page; - if (pageSize !== undefined) params.pageSize = pageSize; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.getCloudMiningPaymentAndRefundHistory(params); - const data = await response.data(); + server.tool( + "BinanceWalletGetCloudMiningPaymentAndRefundHistory", + "Get cloud mining payment and refund history.", + { + startTime: z.number().describe("Start time in milliseconds"), + endTime: z.number().describe("End time in milliseconds"), + page: z.number().optional().describe("Page number"), + pageSize: z.number().optional().describe("Page size"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ startTime, endTime, page, pageSize, recvWindow }) => { + try { + const params: any = { + startTime, + endTime, + } + if (page !== undefined) params.page = page + if (pageSize !== undefined) params.pageSize = pageSize + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.getCloudMiningPaymentAndRefundHistory(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved cloud mining payment and refund history. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved cloud mining payment and refund history. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve cloud mining history: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve cloud mining history: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/asset-api/getOpenSymbolList.ts b/src/modules/wallet/asset-api/getOpenSymbolList.ts index dee5dbcf..f79ebab2 100644 --- a/src/modules/wallet/asset-api/getOpenSymbolList.ts +++ b/src/modules/wallet/asset-api/getOpenSymbolList.ts @@ -1,35 +1,29 @@ // src/tools/binance-wallet/asset-api/getOpenSymbolList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletGetOpenSymbolList(server: McpServer) { - server.tool( - "BinanceWalletGetOpenSymbolList", - "Get open symbol list.", - {}, - async () => { - try { - const response = await walletClient.restAPI.getOpenSymbolList(); - const data = await response.data(); + server.tool("BinanceWalletGetOpenSymbolList", "Get open symbol list.", {}, async () => { + try { + const response = await walletClient.restAPI.getOpenSymbolList() + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved open symbol list. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved open symbol list. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve open symbol list: ${errorMessage}` } - ], - isError: true - }; - } - } - ); -} \ No newline at end of file + return { + content: [{ type: "text", text: `Failed to retrieve open symbol list: ${errorMessage}` }], + isError: true, + } + } + }) +} diff --git a/src/modules/wallet/asset-api/index.ts b/src/modules/wallet/asset-api/index.ts index c3d59031..e736e603 100644 --- a/src/modules/wallet/asset-api/index.ts +++ b/src/modules/wallet/asset-api/index.ts @@ -1,35 +1,36 @@ // src/tools/binance-wallet/asset-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceWalletUserAsset } from "./userAsset.js"; -import { registerBinanceWalletFundingWallet } from "./fundingWallet.js"; -import { registerBinanceWalletAssetDetail } from "./assetDetail.js"; -import { registerBinanceWalletTradeFee } from "./tradeFee.js"; -import { registerBinanceWalletUserUniversalTransfer } from "./userUniversalTransfer.js"; -import { registerBinanceWalletQueryUserUniversalTransferHistory } from "./queryUserUniversalTransferHistory.js"; -import { registerBinanceWalletDustTransfer } from "./dustTransfer.js"; -import { registerBinanceWalletDustlog } from "./dustlog.js"; -import { registerBinanceWalletAssetDividendRecord } from "./assetDividendRecord.js"; -import { registerBinanceWalletGetAssetsThatCanBeConvertedIntoBnb } from "./getAssetsThatCanBeConvertedIntoBnb.js"; -import { registerBinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest } from "./toggleBnbBurnOnSpotTradeAndMarginInterest.js"; -import { registerBinanceWalletGetCloudMiningPaymentAndRefundHistory } from "./getCloudMiningPaymentAndRefundHistory.js"; -import { registerBinanceWalletQueryUserDelegationHistory } from "./queryUserDelegationHistory.js"; -import { registerBinanceWalletGetOpenSymbolList } from "./getOpenSymbolList.js"; -import { registerBinanceWalletQueryUserWalletBalance } from "./queryUserWalletBalance.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceWalletAssetDetail } from "./assetDetail.js" +import { registerBinanceWalletAssetDividendRecord } from "./assetDividendRecord.js" +import { registerBinanceWalletDustlog } from "./dustlog.js" +import { registerBinanceWalletDustTransfer } from "./dustTransfer.js" +import { registerBinanceWalletFundingWallet } from "./fundingWallet.js" +import { registerBinanceWalletGetAssetsThatCanBeConvertedIntoBnb } from "./getAssetsThatCanBeConvertedIntoBnb.js" +import { registerBinanceWalletGetCloudMiningPaymentAndRefundHistory } from "./getCloudMiningPaymentAndRefundHistory.js" +import { registerBinanceWalletGetOpenSymbolList } from "./getOpenSymbolList.js" +import { registerBinanceWalletQueryUserDelegationHistory } from "./queryUserDelegationHistory.js" +import { registerBinanceWalletQueryUserUniversalTransferHistory } from "./queryUserUniversalTransferHistory.js" +import { registerBinanceWalletQueryUserWalletBalance } from "./queryUserWalletBalance.js" +import { registerBinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest } from "./toggleBnbBurnOnSpotTradeAndMarginInterest.js" +import { registerBinanceWalletTradeFee } from "./tradeFee.js" +import { registerBinanceWalletUserAsset } from "./userAsset.js" +import { registerBinanceWalletUserUniversalTransfer } from "./userUniversalTransfer.js" export function registerBinanceWalletAssetApiTools(server: McpServer) { - registerBinanceWalletUserAsset(server); - registerBinanceWalletFundingWallet(server); - registerBinanceWalletAssetDetail(server); - registerBinanceWalletTradeFee(server); - registerBinanceWalletUserUniversalTransfer(server); - registerBinanceWalletQueryUserUniversalTransferHistory(server); - registerBinanceWalletDustTransfer(server); - registerBinanceWalletDustlog(server); - registerBinanceWalletAssetDividendRecord(server); - registerBinanceWalletGetAssetsThatCanBeConvertedIntoBnb(server); - registerBinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest(server); - registerBinanceWalletGetCloudMiningPaymentAndRefundHistory(server); - registerBinanceWalletQueryUserDelegationHistory(server); - registerBinanceWalletGetOpenSymbolList(server); - registerBinanceWalletQueryUserWalletBalance(server); -} \ No newline at end of file + registerBinanceWalletUserAsset(server) + registerBinanceWalletFundingWallet(server) + registerBinanceWalletAssetDetail(server) + registerBinanceWalletTradeFee(server) + registerBinanceWalletUserUniversalTransfer(server) + registerBinanceWalletQueryUserUniversalTransferHistory(server) + registerBinanceWalletDustTransfer(server) + registerBinanceWalletDustlog(server) + registerBinanceWalletAssetDividendRecord(server) + registerBinanceWalletGetAssetsThatCanBeConvertedIntoBnb(server) + registerBinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest(server) + registerBinanceWalletGetCloudMiningPaymentAndRefundHistory(server) + registerBinanceWalletQueryUserDelegationHistory(server) + registerBinanceWalletGetOpenSymbolList(server) + registerBinanceWalletQueryUserWalletBalance(server) +} diff --git a/src/modules/wallet/asset-api/queryUserDelegationHistory.ts b/src/modules/wallet/asset-api/queryUserDelegationHistory.ts index 02075a79..733e68ec 100644 --- a/src/modules/wallet/asset-api/queryUserDelegationHistory.ts +++ b/src/modules/wallet/asset-api/queryUserDelegationHistory.ts @@ -1,51 +1,54 @@ // src/tools/binance-wallet/asset-api/queryUserDelegationHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletQueryUserDelegationHistory(server: McpServer) { - server.tool( - "BinanceWalletQueryUserDelegationHistory", - "Query user delegation history.", - { - email: z.string().describe("Email address"), - startTime: z.number().describe("Start time in milliseconds"), - endTime: z.number().describe("End time in milliseconds"), - page: z.number().optional().describe("Page number"), - limit: z.number().optional().describe("Results per page"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ email, startTime, endTime, page, limit, recvWindow }) => { - try { - const params: any = { - email, - startTime, - endTime - }; - if (page !== undefined) params.page = page; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.queryUserDelegationHistory(params); - const data = await response.data(); + server.tool( + "BinanceWalletQueryUserDelegationHistory", + "Query user delegation history.", + { + email: z.string().describe("Email address"), + startTime: z.number().describe("Start time in milliseconds"), + endTime: z.number().describe("End time in milliseconds"), + page: z.number().optional().describe("Page number"), + limit: z.number().optional().describe("Results per page"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ email, startTime, endTime, page, limit, recvWindow }) => { + try { + const params: any = { + email, + startTime, + endTime, + } + if (page !== undefined) params.page = page + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.queryUserDelegationHistory(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved user delegation history. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved user delegation history. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve user delegation history: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve user delegation history: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/asset-api/queryUserUniversalTransferHistory.ts b/src/modules/wallet/asset-api/queryUserUniversalTransferHistory.ts index 59e3fca7..f8c0bb20 100644 --- a/src/modules/wallet/asset-api/queryUserUniversalTransferHistory.ts +++ b/src/modules/wallet/asset-api/queryUserUniversalTransferHistory.ts @@ -1,53 +1,59 @@ // src/tools/binance-wallet/asset-api/queryUserUniversalTransferHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletQueryUserUniversalTransferHistory(server: McpServer) { - server.tool( - "BinanceWalletQueryUserUniversalTransferHistory", - "Query universal transfer history.", - { - type: z.string().describe("Transfer type"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - current: z.number().optional().describe("Current page"), - size: z.number().optional().describe("Page size"), - fromSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), - toSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ type, startTime, endTime, current, size, fromSymbol, toSymbol, recvWindow }) => { - try { - const params: any = { type }; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (current !== undefined) params.current = current; - if (size !== undefined) params.size = size; - if (fromSymbol !== undefined) params.fromSymbol = fromSymbol; - if (toSymbol !== undefined) params.toSymbol = toSymbol; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.queryUserUniversalTransferHistory(params); - const data = await response.data(); + server.tool( + "BinanceWalletQueryUserUniversalTransferHistory", + "Query universal transfer history.", + { + type: z.string().describe("Transfer type"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + current: z.number().optional().describe("Current page"), + size: z.number().optional().describe("Page size"), + fromSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), + toSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ type, startTime, endTime, current, size, fromSymbol, toSymbol, recvWindow }) => { + try { + const params: any = { type } + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (current !== undefined) params.current = current + if (size !== undefined) params.size = size + if (fromSymbol !== undefined) params.fromSymbol = fromSymbol + if (toSymbol !== undefined) params.toSymbol = toSymbol + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.queryUserUniversalTransferHistory(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved universal transfer history. Total: ${data.total || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved universal transfer history. Total: ${data.total || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve universal transfer history: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve universal transfer history: ${errorMessage}`, + }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/asset-api/queryUserWalletBalance.ts b/src/modules/wallet/asset-api/queryUserWalletBalance.ts index b386a6d5..bc5791bf 100644 --- a/src/modules/wallet/asset-api/queryUserWalletBalance.ts +++ b/src/modules/wallet/asset-api/queryUserWalletBalance.ts @@ -1,40 +1,43 @@ // src/tools/binance-wallet/asset-api/queryUserWalletBalance.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletQueryUserWalletBalance(server: McpServer) { - server.tool( - "BinanceWalletQueryUserWalletBalance", - "Query user wallet balance.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: any = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.queryUserWalletBalance(params); - const data = await response.data(); + server.tool( + "BinanceWalletQueryUserWalletBalance", + "Query user wallet balance.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: any = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.queryUserWalletBalance(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved user wallet balance. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved user wallet balance. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve user wallet balance: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve user wallet balance: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts b/src/modules/wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts index bf05c09b..adfe18ed 100644 --- a/src/modules/wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts +++ b/src/modules/wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts @@ -1,44 +1,46 @@ // src/tools/binance-wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest(server: McpServer) { - server.tool( - "BinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest", - "Toggle BNB burn on spot trade and margin interest.", - { - spotBNBBurn: z.string().optional().describe("'true' or 'false' for spot trade"), - interestBNBBurn: z.string().optional().describe("'true' or 'false' for margin interest"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ spotBNBBurn, interestBNBBurn, recvWindow }) => { - try { - const params: any = {}; - if (spotBNBBurn !== undefined) params.spotBNBBurn = spotBNBBurn; - if (interestBNBBurn !== undefined) params.interestBNBBurn = interestBNBBurn; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.toggleBnbBurnOnSpotTradeAndMarginInterest(params); - const data = await response.data(); + server.tool( + "BinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest", + "Toggle BNB burn on spot trade and margin interest.", + { + spotBNBBurn: z.string().optional().describe("'true' or 'false' for spot trade"), + interestBNBBurn: z.string().optional().describe("'true' or 'false' for margin interest"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ spotBNBBurn, interestBNBBurn, recvWindow }) => { + try { + const params: any = {} + if (spotBNBBurn !== undefined) params.spotBNBBurn = spotBNBBurn + if (interestBNBBurn !== undefined) params.interestBNBBurn = interestBNBBurn + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = + await walletClient.restAPI.toggleBnbBurnOnSpotTradeAndMarginInterest(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `BNB burn settings updated. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `BNB burn settings updated. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to update BNB burn settings: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to update BNB burn settings: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/asset-api/tradeFee.ts b/src/modules/wallet/asset-api/tradeFee.ts index e1a613a0..026f68ec 100644 --- a/src/modules/wallet/asset-api/tradeFee.ts +++ b/src/modules/wallet/asset-api/tradeFee.ts @@ -1,42 +1,45 @@ // src/tools/binance-wallet/asset-api/tradeFee.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletTradeFee(server: McpServer) { - server.tool( - "BinanceWalletTradeFee", - "Get trade fee.", - { - symbol: z.string().optional().describe("Trading pair symbol"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ symbol, recvWindow }) => { - try { - const params: any = {}; - if (symbol !== undefined) params.symbol = symbol; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.tradeFee(params); - const data = await response.data(); + server.tool( + "BinanceWalletTradeFee", + "Get trade fee.", + { + symbol: z.string().optional().describe("Trading pair symbol"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ symbol, recvWindow }) => { + try { + const params: any = {} + if (symbol !== undefined) params.symbol = symbol + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.tradeFee(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved trade fee information. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved trade fee information. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve trade fee information: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve trade fee information: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/asset-api/userAsset.ts b/src/modules/wallet/asset-api/userAsset.ts index f0d373e6..69f73322 100644 --- a/src/modules/wallet/asset-api/userAsset.ts +++ b/src/modules/wallet/asset-api/userAsset.ts @@ -1,42 +1,43 @@ // src/tools/binance-wallet/asset-api/userAsset.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletUserAsset(server: McpServer) { - server.tool( - "BinanceWalletUserAsset", - "Get user assets.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), - needBtcValuation: z.boolean().optional().describe("Whether to include BTC valuation") - }, - async ({ recvWindow, needBtcValuation }) => { - try { - const params: any = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - if (needBtcValuation !== undefined) params.needBtcValuation = needBtcValuation; - - const response = await walletClient.restAPI.userAsset(params); - const data = await response.data(); + server.tool( + "BinanceWalletUserAsset", + "Get user assets.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + needBtcValuation: z.boolean().optional().describe("Whether to include BTC valuation"), + }, + async ({ recvWindow, needBtcValuation }) => { + try { + const params: any = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + if (needBtcValuation !== undefined) params.needBtcValuation = needBtcValuation + + const response = await walletClient.restAPI.userAsset(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved user assets. Number of assets: ${data.length || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved user assets. Number of assets: ${data.length || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve user assets: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve user assets: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/asset-api/userUniversalTransfer.ts b/src/modules/wallet/asset-api/userUniversalTransfer.ts index 3f9cf173..fc9def86 100644 --- a/src/modules/wallet/asset-api/userUniversalTransfer.ts +++ b/src/modules/wallet/asset-api/userUniversalTransfer.ts @@ -1,52 +1,54 @@ - // src/tools/binance-wallet/asset-api/userUniversalTransfer.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletUserUniversalTransfer(server: McpServer) { - server.tool( - "BinanceWalletUserUniversalTransfer", - "Make universal transfer between different accounts.", - { - type: z.string().describe("Transfer type"), - asset: z.string().describe("Asset symbol"), - amount: z.number().describe("Transfer amount"), - fromSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), - toSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ type, asset, amount, fromSymbol, toSymbol, recvWindow }) => { - try { - const params: any = { - type, - asset, - amount - }; - if (fromSymbol !== undefined) params.fromSymbol = fromSymbol; - if (toSymbol !== undefined) params.toSymbol = toSymbol; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.userUniversalTransfer(params); - const data = await response.data(); + server.tool( + "BinanceWalletUserUniversalTransfer", + "Make universal transfer between different accounts.", + { + type: z.string().describe("Transfer type"), + asset: z.string().describe("Asset symbol"), + amount: z.number().describe("Transfer amount"), + fromSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), + toSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ type, asset, amount, fromSymbol, toSymbol, recvWindow }) => { + try { + const params: any = { + type, + asset, + amount, + } + if (fromSymbol !== undefined) params.fromSymbol = fromSymbol + if (toSymbol !== undefined) params.toSymbol = toSymbol + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.userUniversalTransfer(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Universal transfer completed. Transfer ID: ${data.tranId}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Universal transfer completed. Transfer ID: ${data.tranId}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to process universal transfer: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to process universal transfer: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/capital-api/allCoinsInformation.ts b/src/modules/wallet/capital-api/allCoinsInformation.ts index 1dc48aad..af4fcb32 100644 --- a/src/modules/wallet/capital-api/allCoinsInformation.ts +++ b/src/modules/wallet/capital-api/allCoinsInformation.ts @@ -1,40 +1,41 @@ // src/tools/binance-wallet/capital-api/allCoinsInformation.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletAllCoinsInformation(server: McpServer) { - server.tool( - "BinanceWalletAllCoinsInformation", - "Get information for all coins.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: any = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.allCoinsInformation(params); - const data = await response.data(); + server.tool( + "BinanceWalletAllCoinsInformation", + "Get information for all coins.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: any = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.allCoinsInformation(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved information for all coins. Total coins: ${data.length || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved information for all coins. Total coins: ${data.length || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve coin information: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve coin information: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/capital-api/depositAddress.ts b/src/modules/wallet/capital-api/depositAddress.ts index cbcc2d66..2899d1db 100644 --- a/src/modules/wallet/capital-api/depositAddress.ts +++ b/src/modules/wallet/capital-api/depositAddress.ts @@ -1,43 +1,44 @@ // src/tools/binance-wallet/capital-api/depositAddress.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletDepositAddress(server: McpServer) { - server.tool( - "BinanceWalletDepositAddress", - "Get deposit address for a specific coin.", - { - coin: z.string().describe("Coin symbol"), - network: z.string().optional().describe("Network"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ coin, network, recvWindow }) => { - try { - const params: any = { coin }; - if (network !== undefined) params.network = network; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.depositAddress(params); - const data = await response.data(); + server.tool( + "BinanceWalletDepositAddress", + "Get deposit address for a specific coin.", + { + coin: z.string().describe("Coin symbol"), + network: z.string().optional().describe("Network"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ coin, network, recvWindow }) => { + try { + const params: any = { coin } + if (network !== undefined) params.network = network + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.depositAddress(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved deposit address for ${coin}. Address: ${data.address}${data.tag ? `, Tag: ${data.tag}` : ""}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved deposit address for ${coin}. Address: ${data.address}${data.tag ? `, Tag: ${data.tag}` : ''}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve deposit address: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve deposit address: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/capital-api/depositHistory.ts b/src/modules/wallet/capital-api/depositHistory.ts index 20c3ed33..c46eafe0 100644 --- a/src/modules/wallet/capital-api/depositHistory.ts +++ b/src/modules/wallet/capital-api/depositHistory.ts @@ -1,52 +1,53 @@ // src/tools/binance-wallet/capital-api/depositHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletDepositHistory(server: McpServer) { - server.tool( - "BinanceWalletDepositHistory", - "Get deposit history.", - { - coin: z.string().optional().describe("Coin symbol"), - status: z.number().optional().describe("Deposit status"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - offset: z.number().optional().describe("Pagination offset"), - limit: z.number().optional().describe("Number of records to return"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { - try { - const params: any = {}; - if (coin !== undefined) params.coin = coin; - if (status !== undefined) params.status = status; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (offset !== undefined) params.offset = offset; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; + server.tool( + "BinanceWalletDepositHistory", + "Get deposit history.", + { + coin: z.string().optional().describe("Coin symbol"), + status: z.number().optional().describe("Deposit status"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + offset: z.number().optional().describe("Pagination offset"), + limit: z.number().optional().describe("Number of records to return"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { + try { + const params: any = {} + if (coin !== undefined) params.coin = coin + if (status !== undefined) params.status = status + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (offset !== undefined) params.offset = offset + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow - const response = await walletClient.restAPI.depositHistory(params); - const data = await response.data(); + const response = await walletClient.restAPI.depositHistory(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved deposit history. Total deposits: ${data.length || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved deposit history. Total deposits: ${data.length || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve deposit history: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve deposit history: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/capital-api/fetchDepositAddressListWithNetwork.ts b/src/modules/wallet/capital-api/fetchDepositAddressListWithNetwork.ts index a9b87324..e924cdbe 100644 --- a/src/modules/wallet/capital-api/fetchDepositAddressListWithNetwork.ts +++ b/src/modules/wallet/capital-api/fetchDepositAddressListWithNetwork.ts @@ -1,43 +1,46 @@ // src/tools/binance-wallet/capital-api/fetchDepositAddressListWithNetwork.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletFetchDepositAddressListWithNetwork(server: McpServer) { - server.tool( - "BinanceWalletFetchDepositAddressListWithNetwork", - "Fetch deposit address with network.", - { - coin: z.string().describe("Coin symbol"), - network: z.string().optional().describe("Network"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ coin, network, recvWindow }) => { - try { - const params: any = { coin }; - if (network !== undefined) params.network = network; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.fetchDepositAddressListWithNetwork(params); - const data = await response.data(); + server.tool( + "BinanceWalletFetchDepositAddressListWithNetwork", + "Fetch deposit address with network.", + { + coin: z.string().describe("Coin symbol"), + network: z.string().optional().describe("Network"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ coin, network, recvWindow }) => { + try { + const params: any = { coin } + if (network !== undefined) params.network = network + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.fetchDepositAddressListWithNetwork(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved deposit addresses for ${coin}. Total addresses: ${data.length || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved deposit addresses for ${coin}. Total addresses: ${data.length || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve deposit addresses: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve deposit addresses: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/capital-api/fetchWithdrawAddressList.ts b/src/modules/wallet/capital-api/fetchWithdrawAddressList.ts index 1aa56a22..ae2946c2 100644 --- a/src/modules/wallet/capital-api/fetchWithdrawAddressList.ts +++ b/src/modules/wallet/capital-api/fetchWithdrawAddressList.ts @@ -1,37 +1,36 @@ // src/tools/binance-wallet/capital-api/fetchWithdrawAddressList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletFetchWithdrawAddressList(server: McpServer) { - server.tool( - "BinanceWalletFetchWithdrawAddressList", - "Fetch withdraw address list.", - { - }, - async () => { - try { - - const response = await walletClient.restAPI.fetchWithdrawAddressList(); - const data = await response.data(); + server.tool( + "BinanceWalletFetchWithdrawAddressList", + "Fetch withdraw address list.", + {}, + async () => { + try { + const response = await walletClient.restAPI.fetchWithdrawAddressList() + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved withdraw address list. Total addresses: ${data || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved withdraw address list. Total addresses: ${data || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve withdraw address list: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve withdraw address list: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/capital-api/index.ts b/src/modules/wallet/capital-api/index.ts index be8c1ac1..694efb2d 100644 --- a/src/modules/wallet/capital-api/index.ts +++ b/src/modules/wallet/capital-api/index.ts @@ -1,21 +1,22 @@ // src/tools/binance-wallet/capital-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceWalletAllCoinsInformation } from "./allCoinsInformation.js"; -import { registerBinanceWalletDepositAddress } from "./depositAddress.js"; -import { registerBinanceWalletDepositHistory } from "./depositHistory.js"; -import { registerBinanceWalletWithdrawHistory } from "./withdrawHistory.js"; -import { registerBinanceWalletWithdraw } from "./withdraw.js"; -import { registerBinanceWalletFetchDepositAddressListWithNetwork } from "./fetchDepositAddressListWithNetwork.js"; -import { registerBinanceWalletFetchWithdrawAddressList } from "./fetchWithdrawAddressList.js"; -import { registerBinanceWalletOneClickArrivalDepositApply } from "./oneClickArrivalDepositApply.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceWalletAllCoinsInformation } from "./allCoinsInformation.js" +import { registerBinanceWalletDepositAddress } from "./depositAddress.js" +import { registerBinanceWalletDepositHistory } from "./depositHistory.js" +import { registerBinanceWalletFetchDepositAddressListWithNetwork } from "./fetchDepositAddressListWithNetwork.js" +import { registerBinanceWalletFetchWithdrawAddressList } from "./fetchWithdrawAddressList.js" +import { registerBinanceWalletOneClickArrivalDepositApply } from "./oneClickArrivalDepositApply.js" +import { registerBinanceWalletWithdraw } from "./withdraw.js" +import { registerBinanceWalletWithdrawHistory } from "./withdrawHistory.js" export function registerBinanceWalletCapitalApiTools(server: McpServer) { - registerBinanceWalletAllCoinsInformation(server); - registerBinanceWalletDepositAddress(server); - registerBinanceWalletDepositHistory(server); - registerBinanceWalletWithdrawHistory(server); - registerBinanceWalletWithdraw(server); - registerBinanceWalletFetchDepositAddressListWithNetwork(server); - registerBinanceWalletFetchWithdrawAddressList(server); - registerBinanceWalletOneClickArrivalDepositApply(server); -} \ No newline at end of file + registerBinanceWalletAllCoinsInformation(server) + registerBinanceWalletDepositAddress(server) + registerBinanceWalletDepositHistory(server) + registerBinanceWalletWithdrawHistory(server) + registerBinanceWalletWithdraw(server) + registerBinanceWalletFetchDepositAddressListWithNetwork(server) + registerBinanceWalletFetchWithdrawAddressList(server) + registerBinanceWalletOneClickArrivalDepositApply(server) +} diff --git a/src/modules/wallet/capital-api/oneClickArrivalDepositApply.ts b/src/modules/wallet/capital-api/oneClickArrivalDepositApply.ts index 8ecc17ed..13e562ba 100644 --- a/src/modules/wallet/capital-api/oneClickArrivalDepositApply.ts +++ b/src/modules/wallet/capital-api/oneClickArrivalDepositApply.ts @@ -1,42 +1,48 @@ // src/tools/binance-wallet/capital-api/oneClickArrivalDepositApply.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletOneClickArrivalDepositApply(server: McpServer) { - server.tool( - "BinanceWalletOneClickArrivalDepositApply", - "Apply for one-click arrival deposit.", - { - subAccountId: z.string().optional().describe("Sub-account ID"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ subAccountId, recvWindow }) => { - try { - const params: any = {}; - if (subAccountId !== undefined) params.subAccountId = subAccountId; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.oneClickArrivalDepositApply(params); - const data = await response.data(); + server.tool( + "BinanceWalletOneClickArrivalDepositApply", + "Apply for one-click arrival deposit.", + { + subAccountId: z.string().optional().describe("Sub-account ID"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ subAccountId, recvWindow }) => { + try { + const params: any = {} + if (subAccountId !== undefined) params.subAccountId = subAccountId + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.oneClickArrivalDepositApply(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Applied for one-click arrival deposit. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Applied for one-click arrival deposit. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to apply for one-click arrival deposit: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to apply for one-click arrival deposit: ${errorMessage}`, + }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/capital-api/withdraw.ts b/src/modules/wallet/capital-api/withdraw.ts index 50e4c1a6..3619a467 100644 --- a/src/modules/wallet/capital-api/withdraw.ts +++ b/src/modules/wallet/capital-api/withdraw.ts @@ -1,59 +1,71 @@ // src/tools/binance-wallet/capital-api/withdraw.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletWithdraw(server: McpServer) { - server.tool( - "BinanceWalletWithdraw", - "Submit a withdraw request.", - { - coin: z.string().describe("Coin symbol"), - address: z.string().describe("Withdrawal address"), - amount: z.number().describe("Withdrawal amount"), - withdrawOrderId: z.string().optional().describe("Client order id"), - network: z.string().optional().describe("Network"), - addressTag: z.string().optional().describe("Secondary address identifier (tag/memo)"), - name: z.string().optional().describe("Address name"), - walletType: z.number().optional().describe("Wallet type"), - transactionFeeFlag: z.boolean().optional().describe("Pay fee with BNB"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ coin, address, amount, withdrawOrderId, network, addressTag, name, walletType, transactionFeeFlag, recvWindow }) => { - try { - const params: any = { - coin, - address, - amount - }; - if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId; - if (network !== undefined) params.network = network; - if (addressTag !== undefined) params.addressTag = addressTag; - if (name !== undefined) params.name = name; - if (walletType !== undefined) params.walletType = walletType; - if (transactionFeeFlag !== undefined) params.transactionFeeFlag = transactionFeeFlag; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.withdraw(params); - const data = await response.data(); + server.tool( + "BinanceWalletWithdraw", + "Submit a withdraw request.", + { + coin: z.string().describe("Coin symbol"), + address: z.string().describe("Withdrawal address"), + amount: z.number().describe("Withdrawal amount"), + withdrawOrderId: z.string().optional().describe("Client order id"), + network: z.string().optional().describe("Network"), + addressTag: z.string().optional().describe("Secondary address identifier (tag/memo)"), + name: z.string().optional().describe("Address name"), + walletType: z.number().optional().describe("Wallet type"), + transactionFeeFlag: z.boolean().optional().describe("Pay fee with BNB"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ + coin, + address, + amount, + withdrawOrderId, + network, + addressTag, + name, + walletType, + transactionFeeFlag, + recvWindow, + }) => { + try { + const params: any = { + coin, + address, + amount, + } + if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId + if (network !== undefined) params.network = network + if (addressTag !== undefined) params.addressTag = addressTag + if (name !== undefined) params.name = name + if (walletType !== undefined) params.walletType = walletType + if (transactionFeeFlag !== undefined) params.transactionFeeFlag = transactionFeeFlag + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.withdraw(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Withdraw request submitted. Withdrawal ID: ${data.id}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Withdraw request submitted. Withdrawal ID: ${data.id}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to submit withdraw request: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to submit withdraw request: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/capital-api/withdrawHistory.ts b/src/modules/wallet/capital-api/withdrawHistory.ts index f846925c..63f0e692 100644 --- a/src/modules/wallet/capital-api/withdrawHistory.ts +++ b/src/modules/wallet/capital-api/withdrawHistory.ts @@ -1,54 +1,55 @@ // src/tools/binance-wallet/capital-api/withdrawHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletWithdrawHistory(server: McpServer) { - server.tool( - "BinanceWalletWithdrawHistory", - "Get withdraw history.", - { - coin: z.string().optional().describe("Coin symbol"), - withdrawOrderId: z.string().optional().describe("Withdraw order ID"), - status: z.number().optional().describe("Withdraw status"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - offset: z.number().optional().describe("Pagination offset"), - limit: z.number().optional().describe("Number of records to return"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ coin, withdrawOrderId, status, startTime, endTime, offset, limit, recvWindow }) => { - try { - const params: any = {}; - if (coin !== undefined) params.coin = coin; - if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId; - if (status !== undefined) params.status = status; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (offset !== undefined) params.offset = offset; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.withdrawHistory(params); - const data = await response.data(); + server.tool( + "BinanceWalletWithdrawHistory", + "Get withdraw history.", + { + coin: z.string().optional().describe("Coin symbol"), + withdrawOrderId: z.string().optional().describe("Withdraw order ID"), + status: z.number().optional().describe("Withdraw status"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + offset: z.number().optional().describe("Pagination offset"), + limit: z.number().optional().describe("Number of records to return"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ coin, withdrawOrderId, status, startTime, endTime, offset, limit, recvWindow }) => { + try { + const params: any = {} + if (coin !== undefined) params.coin = coin + if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId + if (status !== undefined) params.status = status + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (offset !== undefined) params.offset = offset + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.withdrawHistory(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved withdraw history. Total withdrawals: ${data.length || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved withdraw history. Total withdrawals: ${data.length || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve withdraw history: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve withdraw history: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/index.ts b/src/modules/wallet/index.ts index 42703575..4b94fe4e 100644 --- a/src/modules/wallet/index.ts +++ b/src/modules/wallet/index.ts @@ -1,27 +1,28 @@ // src/tools/binance-wallet/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceWalletAccountApiTools } from "./account-api/index.js"; -import { registerBinanceWalletOthersApiTools } from "./others-api/index.js"; -import { registerBinanceWalletTravelRuleApiTools } from "./travel-rule-api/index.js"; -import { registerBinanceWalletAssetApiTools } from "./asset-api/index.js"; -import { registerBinanceWalletCapitalApiTools } from "./capital-api/index.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceWalletAccountApiTools } from "./account-api/index.js" +import { registerBinanceWalletAssetApiTools } from "./asset-api/index.js" +import { registerBinanceWalletCapitalApiTools } from "./capital-api/index.js" +import { registerBinanceWalletOthersApiTools } from "./others-api/index.js" +import { registerBinanceWalletTravelRuleApiTools } from "./travel-rule-api/index.js" export function registerBinanceWalletTools(server: McpServer) { - // Account API tools - registerBinanceWalletAccountApiTools(server); - - // Others API tools - registerBinanceWalletOthersApiTools(server); - - // Travel Rule API tools - registerBinanceWalletTravelRuleApiTools(server); - - // Asset API tools - registerBinanceWalletAssetApiTools(server); - - // Capital API tools - registerBinanceWalletCapitalApiTools(server); + // Account API tools + registerBinanceWalletAccountApiTools(server) + + // Others API tools + registerBinanceWalletOthersApiTools(server) + + // Travel Rule API tools + registerBinanceWalletTravelRuleApiTools(server) + + // Asset API tools + registerBinanceWalletAssetApiTools(server) + + // Capital API tools + registerBinanceWalletCapitalApiTools(server) } // Alias for binance.ts compatibility -export { registerBinanceWalletTools as registerWallet }; \ No newline at end of file +export { registerBinanceWalletTools as registerWallet } diff --git a/src/modules/wallet/others-api/getSymbolsDelistScheduleForSpot.ts b/src/modules/wallet/others-api/getSymbolsDelistScheduleForSpot.ts index f1c4f0f6..8ac0a258 100644 --- a/src/modules/wallet/others-api/getSymbolsDelistScheduleForSpot.ts +++ b/src/modules/wallet/others-api/getSymbolsDelistScheduleForSpot.ts @@ -1,34 +1,34 @@ // src/tools/binance-wallet/others-api/getSymbolsDelistScheduleForSpot.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletGetSymbolsDelistScheduleForSpot(server: McpServer) { - server.tool( - "BinanceWalletGetSymbolsDelistScheduleForSpot", - "Get delist schedule for spot symbols.", - {}, - async () => { - try { - const response = await walletClient.restAPI.getSymbolsDelistScheduleForSpot(); - const data = await response.data(); + server.tool( + "BinanceWalletGetSymbolsDelistScheduleForSpot", + "Get delist schedule for spot symbols.", + {}, + async () => { + try { + const response = await walletClient.restAPI.getSymbolsDelistScheduleForSpot() + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved delist schedule for spot symbols. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved delist schedule for spot symbols. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve delist schedule: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve delist schedule: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/others-api/index.ts b/src/modules/wallet/others-api/index.ts index d0ca0559..3b6520d6 100644 --- a/src/modules/wallet/others-api/index.ts +++ b/src/modules/wallet/others-api/index.ts @@ -1,10 +1,10 @@ //src/tools/binance-wallet/others-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceWalletSystemStatus } from "./systemStatus.js"; -import { registerBinanceWalletGetSymbolsDelistScheduleForSpot } from "./getSymbolsDelistScheduleForSpot.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceWalletGetSymbolsDelistScheduleForSpot } from "./getSymbolsDelistScheduleForSpot.js" +import { registerBinanceWalletSystemStatus } from "./systemStatus.js" export function registerBinanceWalletOthersApiTools(server: McpServer) { - registerBinanceWalletSystemStatus(server); - registerBinanceWalletGetSymbolsDelistScheduleForSpot(server); - -} \ No newline at end of file + registerBinanceWalletSystemStatus(server) + registerBinanceWalletGetSymbolsDelistScheduleForSpot(server) +} diff --git a/src/modules/wallet/others-api/systemStatus.ts b/src/modules/wallet/others-api/systemStatus.ts index 57e4133e..f2bcc1b3 100644 --- a/src/modules/wallet/others-api/systemStatus.ts +++ b/src/modules/wallet/others-api/systemStatus.ts @@ -1,34 +1,29 @@ // src/tools/binance-wallet/others-api/systemStatus.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletSystemStatus(server: McpServer) { - server.tool( - "BinanceWalletSystemStatus", - "Get Binance Wallet system status.", - {}, - async () => { - try { - const response = await walletClient.restAPI.systemStatus(); - const data = await response.data(); + server.tool("BinanceWalletSystemStatus", "Get Binance Wallet system status.", {}, async () => { + try { + const response = await walletClient.restAPI.systemStatus() + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved system status. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved system status. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve system status: ${errorMessage}` } - ], - isError: true - }; - } - } - ); -} \ No newline at end of file + return { + content: [{ type: "text", text: `Failed to retrieve system status: ${errorMessage}` }], + isError: true, + } + } + }) +} diff --git a/src/modules/wallet/travel-rule-api/brokerWithdraw.ts b/src/modules/wallet/travel-rule-api/brokerWithdraw.ts index 08be01e6..f28f42ec 100644 --- a/src/modules/wallet/travel-rule-api/brokerWithdraw.ts +++ b/src/modules/wallet/travel-rule-api/brokerWithdraw.ts @@ -1,63 +1,79 @@ // src/tools/binance-wallet/travel-rule-api/brokerWithdraw.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletBrokerWithdraw(server: McpServer) { - server.tool( - "BinanceWalletBrokerWithdraw", - "Initiate broker withdrawal with travel rule compliance.", - { - subAccountId: z.string().describe("Sub-account ID"), - address: z.string().describe("Withdrawal address"), - coin: z.string().describe("Coin symbol"), - amount: z.number().describe("Withdrawal amount"), - withdrawOrderId: z.string().describe("Client order id"), - questionnaire: z.string().describe("Travel rule questionnaire"), - originatorPii: z.string().describe("Originator PII information"), - signature: z.string().describe("Signature"), - network: z.string().optional().describe("Network"), - addressTag: z.string().optional().describe("Secondary address identifier"), - name: z.string().optional().describe("Address name"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ subAccountId, address, coin, amount, withdrawOrderId, questionnaire, originatorPii, signature, network, addressTag, name, recvWindow }) => { - try { - const params: any = { - subAccountId, - address, - coin, - amount, - withdrawOrderId, - questionnaire, - originatorPii, - signature - }; - if (network !== undefined) params.network = network; - if (addressTag !== undefined) params.addressTag = addressTag; - if (name !== undefined) params.name = name; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.brokerWithdraw(params); - const data = await response.data(); + server.tool( + "BinanceWalletBrokerWithdraw", + "Initiate broker withdrawal with travel rule compliance.", + { + subAccountId: z.string().describe("Sub-account ID"), + address: z.string().describe("Withdrawal address"), + coin: z.string().describe("Coin symbol"), + amount: z.number().describe("Withdrawal amount"), + withdrawOrderId: z.string().describe("Client order id"), + questionnaire: z.string().describe("Travel rule questionnaire"), + originatorPii: z.string().describe("Originator PII information"), + signature: z.string().describe("Signature"), + network: z.string().optional().describe("Network"), + addressTag: z.string().optional().describe("Secondary address identifier"), + name: z.string().optional().describe("Address name"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ + subAccountId, + address, + coin, + amount, + withdrawOrderId, + questionnaire, + originatorPii, + signature, + network, + addressTag, + name, + recvWindow, + }) => { + try { + const params: any = { + subAccountId, + address, + coin, + amount, + withdrawOrderId, + questionnaire, + originatorPii, + signature, + } + if (network !== undefined) params.network = network + if (addressTag !== undefined) params.addressTag = addressTag + if (name !== undefined) params.name = name + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.brokerWithdraw(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Broker withdraw request submitted. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Broker withdraw request submitted. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to submit broker withdraw request: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to submit broker withdraw request: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/travel-rule-api/depositHistoryTravelRule.ts b/src/modules/wallet/travel-rule-api/depositHistoryTravelRule.ts index e86c7efa..9e1d7ef7 100644 --- a/src/modules/wallet/travel-rule-api/depositHistoryTravelRule.ts +++ b/src/modules/wallet/travel-rule-api/depositHistoryTravelRule.ts @@ -1,52 +1,53 @@ // src/tools/binance-wallet/travel-rule-api/depositHistoryTravelRule.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletDepositHistoryTravelRule(server: McpServer) { - server.tool( - "BinanceWalletDepositHistoryTravelRule", - "Get deposit history for travel rule.", - { - coin: z.string().optional().describe("Coin symbol"), - status: z.number().optional().describe("Deposit status"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - offset: z.number().optional().describe("Default 0"), - limit: z.number().optional().describe("Default 1000, max 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { - try { - const params: any = {}; - if (coin !== undefined) params.coin = coin; - if (status !== undefined) params.status = status; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (offset !== undefined) params.offset = offset; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.depositHistoryTravelRule(params); - const data = await response.data(); + server.tool( + "BinanceWalletDepositHistoryTravelRule", + "Get deposit history for travel rule.", + { + coin: z.string().optional().describe("Coin symbol"), + status: z.number().optional().describe("Deposit status"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + offset: z.number().optional().describe("Default 0"), + limit: z.number().optional().describe("Default 1000, max 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { + try { + const params: any = {} + if (coin !== undefined) params.coin = coin + if (status !== undefined) params.status = status + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (offset !== undefined) params.offset = offset + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.depositHistoryTravelRule(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved deposit history for travel rule. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved deposit history for travel rule. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve deposit history: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve deposit history: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/travel-rule-api/index.ts b/src/modules/wallet/travel-rule-api/index.ts index 5cafccd8..9e76b47d 100644 --- a/src/modules/wallet/travel-rule-api/index.ts +++ b/src/modules/wallet/travel-rule-api/index.ts @@ -1,22 +1,22 @@ //src/tools/binance-wallet/travel-rule-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceWalletBrokerWithdraw } from "./brokerWithdraw.js"; -import { registerBinanceWalletOnboardedVaspList } from "./onboardedVaspList.js"; -import { registerBinanceWalletSubmitDepositQuestionnaire } from "./submitDepositQuestionnaire.js"; -import { registerBinanceWalletWithdrawHistoryV1 } from "./withdrawHistoryV1.js"; -import { registerBinanceWalletDepositHistoryTravelRule } from "./depositHistoryTravelRule.js"; -import { registerBinanceWalletWithdrawHistoryV2 } from "./withdrawHistoryV2.js"; -import { registerBinanceWalletWithdrawTravelRule } from "./withdrawTravelRule.js"; -import { registerBinanceWalletSubmitDepositQuestionnaireTravelRule } from "./submitDepositQuestionnaireTravelRule.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceWalletBrokerWithdraw } from "./brokerWithdraw.js" +import { registerBinanceWalletDepositHistoryTravelRule } from "./depositHistoryTravelRule.js" +import { registerBinanceWalletOnboardedVaspList } from "./onboardedVaspList.js" +import { registerBinanceWalletSubmitDepositQuestionnaire } from "./submitDepositQuestionnaire.js" +import { registerBinanceWalletSubmitDepositQuestionnaireTravelRule } from "./submitDepositQuestionnaireTravelRule.js" +import { registerBinanceWalletWithdrawHistoryV1 } from "./withdrawHistoryV1.js" +import { registerBinanceWalletWithdrawHistoryV2 } from "./withdrawHistoryV2.js" +import { registerBinanceWalletWithdrawTravelRule } from "./withdrawTravelRule.js" export function registerBinanceWalletTravelRuleApiTools(server: McpServer) { - registerBinanceWalletBrokerWithdraw(server); - registerBinanceWalletOnboardedVaspList(server); - registerBinanceWalletSubmitDepositQuestionnaire(server); - registerBinanceWalletWithdrawHistoryV1(server); - registerBinanceWalletDepositHistoryTravelRule(server); - registerBinanceWalletWithdrawHistoryV2(server); - registerBinanceWalletWithdrawTravelRule(server); - registerBinanceWalletSubmitDepositQuestionnaireTravelRule(server); - -} \ No newline at end of file + registerBinanceWalletBrokerWithdraw(server) + registerBinanceWalletOnboardedVaspList(server) + registerBinanceWalletSubmitDepositQuestionnaire(server) + registerBinanceWalletWithdrawHistoryV1(server) + registerBinanceWalletDepositHistoryTravelRule(server) + registerBinanceWalletWithdrawHistoryV2(server) + registerBinanceWalletWithdrawTravelRule(server) + registerBinanceWalletSubmitDepositQuestionnaireTravelRule(server) +} diff --git a/src/modules/wallet/travel-rule-api/onboardedVaspList.ts b/src/modules/wallet/travel-rule-api/onboardedVaspList.ts index d78089c6..c6d74c32 100644 --- a/src/modules/wallet/travel-rule-api/onboardedVaspList.ts +++ b/src/modules/wallet/travel-rule-api/onboardedVaspList.ts @@ -1,35 +1,36 @@ // src/tools/binance-wallet/travel-rule-api/onboardedVaspList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletOnboardedVaspList(server: McpServer) { - server.tool( - "BinanceWalletOnboardedVaspList", - "Get list of onboarded VASPs (Virtual Asset Service Providers).", - {}, - async () => { - try { - const response = await walletClient.restAPI.onboardedVaspList(); - const data = await response.data(); + server.tool( + "BinanceWalletOnboardedVaspList", + "Get list of onboarded VASPs (Virtual Asset Service Providers).", + {}, + async () => { + try { + const response = await walletClient.restAPI.onboardedVaspList() + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved onboarded VASP list. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved onboarded VASP list. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve onboarded VASP list: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve onboarded VASP list: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/travel-rule-api/submitDepositQuestionnaire.ts b/src/modules/wallet/travel-rule-api/submitDepositQuestionnaire.ts index 37ef2dc6..76a8e0ba 100644 --- a/src/modules/wallet/travel-rule-api/submitDepositQuestionnaire.ts +++ b/src/modules/wallet/travel-rule-api/submitDepositQuestionnaire.ts @@ -1,51 +1,54 @@ // src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaire.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletSubmitDepositQuestionnaire(server: McpServer) { - server.tool( - "BinanceWalletSubmitDepositQuestionnaire", - "Submit deposit questionnaire for broker deposit.", - { - subAccountId: z.string().describe("Sub-account ID"), - depositId: z.string().describe("Deposit ID"), - questionnaire: z.string().describe("Travel rule questionnaire"), - beneficiaryPii: z.string().describe("Beneficiary PII information"), - signature: z.string().describe("Signature"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ subAccountId, depositId, questionnaire, beneficiaryPii, signature, recvWindow }) => { - try { - const params: any = { - subAccountId, - depositId, - questionnaire, - beneficiaryPii, - signature - }; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.submitDepositQuestionnaire(params); - const data = await response.data(); + server.tool( + "BinanceWalletSubmitDepositQuestionnaire", + "Submit deposit questionnaire for broker deposit.", + { + subAccountId: z.string().describe("Sub-account ID"), + depositId: z.string().describe("Deposit ID"), + questionnaire: z.string().describe("Travel rule questionnaire"), + beneficiaryPii: z.string().describe("Beneficiary PII information"), + signature: z.string().describe("Signature"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ subAccountId, depositId, questionnaire, beneficiaryPii, signature, recvWindow }) => { + try { + const params: any = { + subAccountId, + depositId, + questionnaire, + beneficiaryPii, + signature, + } + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.submitDepositQuestionnaire(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Submitted deposit questionnaire for broker deposit. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Submitted deposit questionnaire for broker deposit. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to submit deposit questionnaire: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to submit deposit questionnaire: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts b/src/modules/wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts index 4d2f4f9e..1160d5c9 100644 --- a/src/modules/wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts +++ b/src/modules/wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts @@ -1,45 +1,48 @@ // src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletSubmitDepositQuestionnaireTravelRule(server: McpServer) { - server.tool( - "BinanceWalletSubmitDepositQuestionnaireTravelRule", - "Submit deposit questionnaire for travel rule.", - { - tranId: z.number().describe("Transaction ID"), - questionnaire: z.string().describe("Travel rule questionnaire"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ tranId, questionnaire, recvWindow }) => { - try { - const params: any = { - tranId, - questionnaire - }; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.submitDepositQuestionnaireTravelRule(params); - const data = await response.data(); + server.tool( + "BinanceWalletSubmitDepositQuestionnaireTravelRule", + "Submit deposit questionnaire for travel rule.", + { + tranId: z.number().describe("Transaction ID"), + questionnaire: z.string().describe("Travel rule questionnaire"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ tranId, questionnaire, recvWindow }) => { + try { + const params: any = { + tranId, + questionnaire, + } + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.submitDepositQuestionnaireTravelRule(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Submitted deposit questionnaire for travel rule. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Submitted deposit questionnaire for travel rule. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to submit deposit questionnaire: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to submit deposit questionnaire: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/travel-rule-api/withdrawHistoryV1.ts b/src/modules/wallet/travel-rule-api/withdrawHistoryV1.ts index 4cf980f9..a1beb2c2 100644 --- a/src/modules/wallet/travel-rule-api/withdrawHistoryV1.ts +++ b/src/modules/wallet/travel-rule-api/withdrawHistoryV1.ts @@ -1,52 +1,53 @@ // src/tools/binance-wallet/travel-rule-api/withdrawHistoryV1.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletWithdrawHistoryV1(server: McpServer) { - server.tool( - "BinanceWalletWithdrawHistoryV1", - "Get withdraw history (v1).", - { - coin: z.string().optional().describe("Coin symbol"), - status: z.number().optional().describe("Withdraw status"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - offset: z.number().optional().describe("Default 0"), - limit: z.number().optional().describe("Default 1000, max 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { - try { - const params: any = {}; - if (coin !== undefined) params.coin = coin; - if (status !== undefined) params.status = status; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (offset !== undefined) params.offset = offset; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.withdrawHistoryV1(params); - const data = await response.data(); + server.tool( + "BinanceWalletWithdrawHistoryV1", + "Get withdraw history (v1).", + { + coin: z.string().optional().describe("Coin symbol"), + status: z.number().optional().describe("Withdraw status"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + offset: z.number().optional().describe("Default 0"), + limit: z.number().optional().describe("Default 1000, max 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { + try { + const params: any = {} + if (coin !== undefined) params.coin = coin + if (status !== undefined) params.status = status + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (offset !== undefined) params.offset = offset + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.withdrawHistoryV1(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved withdraw history v1. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved withdraw history v1. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve withdraw history: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve withdraw history: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/travel-rule-api/withdrawHistoryV2.ts b/src/modules/wallet/travel-rule-api/withdrawHistoryV2.ts index 2b20d3a2..fac53e5d 100644 --- a/src/modules/wallet/travel-rule-api/withdrawHistoryV2.ts +++ b/src/modules/wallet/travel-rule-api/withdrawHistoryV2.ts @@ -1,52 +1,53 @@ // src/tools/binance-wallet/travel-rule-api/withdrawHistoryV2.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletWithdrawHistoryV2(server: McpServer) { - server.tool( - "BinanceWalletWithdrawHistoryV2", - "Get withdraw history (v2).", - { - coin: z.string().optional().describe("Coin symbol"), - status: z.number().optional().describe("Withdraw status"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - offset: z.number().optional().describe("Default 0"), - limit: z.number().optional().describe("Default 1000, max 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { - try { - const params: any = {}; - if (coin !== undefined) params.coin = coin; - if (status !== undefined) params.status = status; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (offset !== undefined) params.offset = offset; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.withdrawHistoryV2(params); - const data = await response.data(); + server.tool( + "BinanceWalletWithdrawHistoryV2", + "Get withdraw history (v2).", + { + coin: z.string().optional().describe("Coin symbol"), + status: z.number().optional().describe("Withdraw status"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + offset: z.number().optional().describe("Default 0"), + limit: z.number().optional().describe("Default 1000, max 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { + try { + const params: any = {} + if (coin !== undefined) params.coin = coin + if (status !== undefined) params.status = status + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (offset !== undefined) params.offset = offset + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.withdrawHistoryV2(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved withdraw history v2. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved withdraw history v2. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve withdraw history: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve withdraw history: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/modules/wallet/travel-rule-api/withdrawTravelRule.ts b/src/modules/wallet/travel-rule-api/withdrawTravelRule.ts index 5d7bd8bf..b9e385ec 100644 --- a/src/modules/wallet/travel-rule-api/withdrawTravelRule.ts +++ b/src/modules/wallet/travel-rule-api/withdrawTravelRule.ts @@ -1,57 +1,73 @@ // src/tools/binance-wallet/travel-rule-api/withdrawTravelRule.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletWithdrawTravelRule(server: McpServer) { - server.tool( - "BinanceWalletWithdrawTravelRule", - "Withdraw with travel rule compliance.", - { - coin: z.string().describe("Coin symbol"), - address: z.string().describe("Withdrawal address"), - amount: z.number().describe("Withdrawal amount"), - withdrawOrderId: z.string().optional().describe("Client order id"), - network: z.string().optional().describe("Network"), - addressTag: z.string().optional().describe("Secondary address identifier"), - name: z.string().optional().describe("Address name"), - questionnaire: z.string().describe("Travel rule questionnaire"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ coin, address, amount, withdrawOrderId, network, addressTag, name, questionnaire, recvWindow }) => { - try { - const params: any = { - coin, - address, - amount, - questionnaire - }; - if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId; - if (network !== undefined) params.network = network; - if (addressTag !== undefined) params.addressTag = addressTag; - if (name !== undefined) params.name = name; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.withdrawTravelRule(params); - const data = await response.data(); + server.tool( + "BinanceWalletWithdrawTravelRule", + "Withdraw with travel rule compliance.", + { + coin: z.string().describe("Coin symbol"), + address: z.string().describe("Withdrawal address"), + amount: z.number().describe("Withdrawal amount"), + withdrawOrderId: z.string().optional().describe("Client order id"), + network: z.string().optional().describe("Network"), + addressTag: z.string().optional().describe("Secondary address identifier"), + name: z.string().optional().describe("Address name"), + questionnaire: z.string().describe("Travel rule questionnaire"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ + coin, + address, + amount, + withdrawOrderId, + network, + addressTag, + name, + questionnaire, + recvWindow, + }) => { + try { + const params: any = { + coin, + address, + amount, + questionnaire, + } + if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId + if (network !== undefined) params.network = network + if (addressTag !== undefined) params.addressTag = addressTag + if (name !== undefined) params.name = name + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.withdrawTravelRule(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Withdraw travel rule request submitted. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Withdraw travel rule request submitted. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to submit withdraw travel rule request: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to submit withdraw travel rule request: ${errorMessage}`, + }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/server/base.ts b/src/server/base.ts index 9c5193e8..df0289c3 100644 --- a/src/server/base.ts +++ b/src/server/base.ts @@ -11,11 +11,13 @@ export const startServer = () => { const server = new McpServer({ name: "binance-mcp", version: "1.0.0", - description: "MCP server for Binance exchange - spot trading, staking, wallet, NFT, pay, mining, and more" + description: + "MCP server for Binance exchange - spot trading, staking, wallet, NFT, pay, mining, and more", }) // Register all Binance modules registerBinance(server) + return server } catch (error) { Logger.error("Failed to initialize server:", error) diff --git a/src/server/sse.ts b/src/server/sse.ts index d3463db9..63389146 100644 --- a/src/server/sse.ts +++ b/src/server/sse.ts @@ -1,13 +1,14 @@ -// src/server/sse.ts -import "dotenv/config" - import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js" -import express from "express" import cors from "cors" +import express from "express" import Logger from "../utils/logger.js" + import { startServer } from "./base.js" +// src/server/sse.ts +import "dotenv/config" + const PORT = process.env.PORT || 3002 // Start the server in SSE mode @@ -18,19 +19,19 @@ export const startSSEServer = async () => { app.use(express.json()) const server = startServer() - + // Store active transports - const transports: Map = new Map() + const transports = new Map() // SSE endpoint app.get("/sse", async (req, res) => { - const sessionId = req.query.sessionId as string || crypto.randomUUID() - + const sessionId = (req.query.sessionId as string) || crypto.randomUUID() + Logger.info(`New SSE connection: ${sessionId}`) - + const transport = new SSEServerTransport("/message", res) transports.set(sessionId, transport) - + res.on("close", () => { Logger.info(`SSE connection closed: ${sessionId}`) transports.delete(sessionId) @@ -43,9 +44,10 @@ export const startSSEServer = async () => { app.post("/message", async (req, res) => { const sessionId = req.query.sessionId as string const transport = transports.get(sessionId) - + if (!transport) { res.status(404).json({ error: "Session not found" }) + return } diff --git a/src/server/stdio.ts b/src/server/stdio.ts index 3bc6e96e..2af2cbed 100644 --- a/src/server/stdio.ts +++ b/src/server/stdio.ts @@ -1,17 +1,18 @@ -// src/server/stdio.ts -import "dotenv/config" - import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js" import Logger from "../utils/logger.js" + import { startServer } from "./base.js" +// src/server/stdio.ts +import "dotenv/config" + // Start the server in stdio mode export const startStdioServer = async () => { try { const server = startServer() const transport = new StdioServerTransport() - + Logger.info("Binance MCP Server running on stdio mode") transport.onmessage = (message) => { @@ -25,6 +26,7 @@ export const startStdioServer = async () => { } await server.connect(transport) + return server } catch (error) { Logger.error("Error starting Binance MCP Stdio server:", error) diff --git a/src/tools/account/index.ts b/src/tools/account/index.ts index cb3731a7..2c037adf 100644 --- a/src/tools/account/index.ts +++ b/src/tools/account/index.ts @@ -1,11 +1,13 @@ // src/tools/account/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { makeSignedRequest } from "../../config/binanceUsClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { makeSignedRequest } from "../../config/binanceUsClient.js" /** * Register all Account-related tools for Binance.US - * + * * Account endpoints provide access to: * - Account balances and permissions * - Trade history @@ -14,199 +16,228 @@ import { makeSignedRequest } from "../../config/binanceUsClient.js"; * - 30-day trading volume */ export function registerAccountTools(server: McpServer) { - // ===================================================== - // binance_us_account_info - // GET /api/v3/account - // ===================================================== - server.tool( - "binance_us_account_info", - "Get current account information including balances and permissions. Returns all asset balances (free and locked), account permissions, and trading status.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000. Default: 5000"), - }, - async ({ recvWindow }) => { - try { - const params: Record = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await makeSignedRequest("GET", "/api/v3/account", params); - - // Format balances for readability - const nonZeroBalances = data.balances?.filter( - (b: { free: string; locked: string }) => - parseFloat(b.free) > 0 || parseFloat(b.locked) > 0 - ) || []; - - return { - content: [{ - type: "text", - text: JSON.stringify({ - makerCommission: data.makerCommission, - takerCommission: data.takerCommission, - buyerCommission: data.buyerCommission, - sellerCommission: data.sellerCommission, - canTrade: data.canTrade, - canWithdraw: data.canWithdraw, - canDeposit: data.canDeposit, - updateTime: data.updateTime, - accountType: data.accountType, - balances: nonZeroBalances, - permissions: data.permissions - }, null, 2) - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get account info: ${errorMessage}` }], - isError: true - }; - } + // ===================================================== + // binance_us_account_info + // GET /api/v3/account + // ===================================================== + server.tool( + "binance_us_account_info", + "Get current account information including balances and permissions. Returns all asset balances (free and locked), account permissions, and trading status.", + { + recvWindow: z + .number() + .optional() + .describe("The value cannot be greater than 60000. Default: 5000"), + }, + async ({ recvWindow }) => { + try { + const params: Record = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await makeSignedRequest("GET", "/api/v3/account", params) + + // Format balances for readability + const nonZeroBalances = + data.balances?.filter( + (b: { free: string; locked: string }) => + parseFloat(b.free) > 0 || parseFloat(b.locked) > 0, + ) || [] + + return { + content: [ + { + type: "text", + text: JSON.stringify( + { + makerCommission: data.makerCommission, + takerCommission: data.takerCommission, + buyerCommission: data.buyerCommission, + sellerCommission: data.sellerCommission, + canTrade: data.canTrade, + canWithdraw: data.canWithdraw, + canDeposit: data.canDeposit, + updateTime: data.updateTime, + accountType: data.accountType, + balances: nonZeroBalances, + permissions: data.permissions, + }, + null, + 2, + ), + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get account info: ${errorMessage}` }], + isError: true, } - ); - - // ===================================================== - // binance_us_my_trades - // GET /api/v3/myTrades - // ===================================================== - server.tool( - "binance_us_my_trades", - "Get trade history for a specific trading pair. Returns executed trades including price, quantity, commission, and timestamps.", - { - symbol: z.string().describe("Trading pair symbol, e.g., BTCUSD, ETHUSD"), - orderId: z.number().optional().describe("Filter by order ID"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - fromId: z.number().optional().describe("Trade ID to fetch from. Default gets most recent trades."), - limit: z.number().optional().describe("Number of trades to return. Default: 500, Max: 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), - }, - async ({ symbol, orderId, startTime, endTime, fromId, limit, recvWindow }) => { - try { - const params: Record = { symbol }; - if (orderId !== undefined) params.orderId = orderId; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (fromId !== undefined) params.fromId = fromId; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await makeSignedRequest("GET", "/api/v3/myTrades", params); - - return { - content: [{ - type: "text", - text: `Trade history for ${symbol}:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get trade history: ${errorMessage}` }], - isError: true - }; - } + } + }, + ) + + // ===================================================== + // binance_us_my_trades + // GET /api/v3/myTrades + // ===================================================== + server.tool( + "binance_us_my_trades", + "Get trade history for a specific trading pair. Returns executed trades including price, quantity, commission, and timestamps.", + { + symbol: z.string().describe("Trading pair symbol, e.g., BTCUSD, ETHUSD"), + orderId: z.number().optional().describe("Filter by order ID"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + fromId: z + .number() + .optional() + .describe("Trade ID to fetch from. Default gets most recent trades."), + limit: z.number().optional().describe("Number of trades to return. Default: 500, Max: 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ symbol, orderId, startTime, endTime, fromId, limit, recvWindow }) => { + try { + const params: Record = { symbol } + if (orderId !== undefined) params.orderId = orderId + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (fromId !== undefined) params.fromId = fromId + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await makeSignedRequest("GET", "/api/v3/myTrades", params) + + return { + content: [ + { + type: "text", + text: `Trade history for ${symbol}:\n${JSON.stringify(data, null, 2)}`, + }, + ], } - ); - - // ===================================================== - // binance_us_rate_limits - // GET /api/v3/rateLimit/order - // ===================================================== - server.tool( - "binance_us_rate_limits", - "Get current trade order count rate limits for all time intervals. Shows how many orders you can place within each interval.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), - }, - async ({ recvWindow }) => { - try { - const params: Record = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await makeSignedRequest("GET", "/api/v3/rateLimit/order", params); - - return { - content: [{ - type: "text", - text: `Order Rate Limits:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get rate limits: ${errorMessage}` }], - isError: true - }; - } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get trade history: ${errorMessage}` }], + isError: true, } - ); - - // ===================================================== - // binance_us_trade_fee - // GET /sapi/v1/asset/query/trading-fee - // ===================================================== - server.tool( - "binance_us_trade_fee", - "Get your current maker & taker fee rates for spot trading based on your VIP level. BNB fee discount (25% off) is not factored in.", - { - symbol: z.string().optional().describe("Trading pair symbol. If not specified, returns fees for all symbols."), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), - }, - async ({ symbol, recvWindow }) => { - try { - const params: Record = {}; - if (symbol !== undefined) params.symbol = symbol; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await makeSignedRequest("GET", "/sapi/v1/asset/query/trading-fee", params); - - return { - content: [{ - type: "text", - text: `Trading Fees:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get trading fees: ${errorMessage}` }], - isError: true - }; - } + } + }, + ) + + // ===================================================== + // binance_us_rate_limits + // GET /api/v3/rateLimit/order + // ===================================================== + server.tool( + "binance_us_rate_limits", + "Get current trade order count rate limits for all time intervals. Shows how many orders you can place within each interval.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: Record = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await makeSignedRequest("GET", "/api/v3/rateLimit/order", params) + + return { + content: [ + { + type: "text", + text: `Order Rate Limits:\n${JSON.stringify(data, null, 2)}`, + }, + ], } - ); - - // ===================================================== - // binance_us_trade_volume - // GET /sapi/v1/asset/query/trading-volume - // ===================================================== - server.tool( - "binance_us_trade_volume", - "Get total trade volume for the past 30 days. Volume is calculated on a rolling basis every day at 0:00 AM (UTC).", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), - }, - async ({ recvWindow }) => { - try { - const params: Record = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await makeSignedRequest("GET", "/sapi/v1/asset/query/trading-volume", params); - - return { - content: [{ - type: "text", - text: `Past 30 Days Trading Volume: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get trading volume: ${errorMessage}` }], - isError: true - }; - } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get rate limits: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================== + // binance_us_trade_fee + // GET /sapi/v1/asset/query/trading-fee + // ===================================================== + server.tool( + "binance_us_trade_fee", + "Get your current maker & taker fee rates for spot trading based on your VIP level. BNB fee discount (25% off) is not factored in.", + { + symbol: z + .string() + .optional() + .describe("Trading pair symbol. If not specified, returns fees for all symbols."), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ symbol, recvWindow }) => { + try { + const params: Record = {} + if (symbol !== undefined) params.symbol = symbol + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await makeSignedRequest("GET", "/sapi/v1/asset/query/trading-fee", params) + + return { + content: [ + { + type: "text", + text: `Trading Fees:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get trading fees: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================== + // binance_us_trade_volume + // GET /sapi/v1/asset/query/trading-volume + // ===================================================== + server.tool( + "binance_us_trade_volume", + "Get total trade volume for the past 30 days. Volume is calculated on a rolling basis every day at 0:00 AM (UTC).", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: Record = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await makeSignedRequest("GET", "/sapi/v1/asset/query/trading-volume", params) + + return { + content: [ + { + type: "text", + text: `Past 30 Days Trading Volume: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get trading volume: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-algo/future-algo/TwapNewTrade.ts b/src/tools/binance-algo/future-algo/TwapNewTrade.ts index 2bae1220..4be4e66d 100644 --- a/src/tools/binance-algo/future-algo/TwapNewTrade.ts +++ b/src/tools/binance-algo/future-algo/TwapNewTrade.ts @@ -1,81 +1,92 @@ // src/tools/binance-algo/future-algo/TwapNewTrade.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { algoClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { algoClient } from "../../../config/binanceClient.js" export function registerBinanceTwapNewTrade(server: McpServer) { - server.tool( - "BinanceTimeWeightedAveragePriceNewOrder", - "The Time-Weighted Average Price (TWAP) New Order API allows users to place a TWAP order on USDⓈ-M Contracts in Binance Futures. TWAP orders execute gradually over a specified duration to achieve a better average execution price while minimizing market impact.", - { - symbol: z.string().describe("Trading symbol (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Trading side (BUY or SELL)"), - positionSide: z - .enum(["BOTH", "LONG", "SHORT"]) - .optional() - .describe("Default BOTH for One-way Mode; LONG or SHORT for Hedge Mode. Must be sent in Hedge Mode."), - quantity: z - .number() - .positive() - .min(1000) - .max(1000000) - .describe("Quantity of base asset; Notional must be between 1,000 and 1,000,000 USDT"), - duration: z - .number() - .int() - .min(300) - .max(86400) - .describe("Duration for TWAP orders in seconds. Must be between 300 and 86400"), - clientAlgoId: z.string().length(32).optional().describe("A unique 32-character ID among Algo orders"), - reduceOnly: z - .boolean() - .optional() - .describe("true or false. Default false; Cannot be sent in Hedge Mode or when opening a position"), - limitPrice: z - .number() - .positive() - .optional() - .describe("Limit price of the order; Defaults to market price if not sent"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await algoClient.restAPI.timeWeightedAveragePriceFutureAlgo({ - symbol: params.symbol, - side: params.side, - quantity: params.quantity, - duration: params.duration, - ...(params.positionSide && { positionSide: params.positionSide }), - ...(params.clientAlgoId && { clientAlgoId: params.clientAlgoId }), - ...(params.reduceOnly !== undefined && { reduceOnly: params.reduceOnly }), - ...(params.limitPrice !== undefined && { limitPrice: params.limitPrice }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceTimeWeightedAveragePriceNewOrder", + "The Time-Weighted Average Price (TWAP) New Order API allows users to place a TWAP order on USDⓈ-M Contracts in Binance Futures. TWAP orders execute gradually over a specified duration to achieve a better average execution price while minimizing market impact.", + { + symbol: z.string().describe("Trading symbol (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Trading side (BUY or SELL)"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe( + "Default BOTH for One-way Mode; LONG or SHORT for Hedge Mode. Must be sent in Hedge Mode.", + ), + quantity: z + .number() + .positive() + .min(1000) + .max(1000000) + .describe("Quantity of base asset; Notional must be between 1,000 and 1,000,000 USDT"), + duration: z + .number() + .int() + .min(300) + .max(86400) + .describe("Duration for TWAP orders in seconds. Must be between 300 and 86400"), + clientAlgoId: z + .string() + .length(32) + .optional() + .describe("A unique 32-character ID among Algo orders"), + reduceOnly: z + .boolean() + .optional() + .describe( + "true or false. Default false; Cannot be sent in Hedge Mode or when opening a position", + ), + limitPrice: z + .number() + .positive() + .optional() + .describe("Limit price of the order; Defaults to market price if not sent"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await algoClient.restAPI.timeWeightedAveragePriceFutureAlgo({ + symbol: params.symbol, + side: params.side, + quantity: params.quantity, + duration: params.duration, + ...(params.positionSide && { positionSide: params.positionSide }), + ...(params.clientAlgoId && { clientAlgoId: params.clientAlgoId }), + ...(params.reduceOnly !== undefined && { reduceOnly: params.reduceOnly }), + ...(params.limitPrice !== undefined && { limitPrice: params.limitPrice }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `TWAP order on USDⓈ-M Contracts placed successfully for ${ + params.symbol + }. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `TWAP order on USDⓈ-M Contracts placed successfully for ${ - params.symbol - }. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to place a TWAP order on: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to place a TWAP order on: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-algo/future-algo/VPNewTrade.ts b/src/tools/binance-algo/future-algo/VPNewTrade.ts index 904623be..d9ab7294 100644 --- a/src/tools/binance-algo/future-algo/VPNewTrade.ts +++ b/src/tools/binance-algo/future-algo/VPNewTrade.ts @@ -1,78 +1,87 @@ // src/tools/binance-algo/future-algo/VPNewTrade.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { algoClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { algoClient } from "../../../config/binanceClient.js" export function registerBinanceVPNewTrade(server: McpServer) { - server.tool( - "BinanceVolumeParticipationNewTrade", - "The Volume Participation (VP) New Order API allows users to place a VP order on USDⓈ-M Contracts in Binance Futures.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Trading side (BUY or SELL)"), - positionSide: z - .enum(["BOTH", "LONG", "SHORT"]) - .optional() - .describe( - "Default BOTH for One-way Mode; LONG or SHORT for Hedge Mode. It must be sent in Hedge Mode." - ), - quantity: z - .number() - .positive() - .min(10000) - .max(1000000) - .describe("Quantity of base asset; Notional must be between 10,000 and 1,000,000 USDT"), - urgency: z.enum(["LOW", "MEDIUM", "HIGH"]).describe("Execution speed: LOW, MEDIUM, HIGH"), - clientAlgoId: z.string().length(32).optional().describe("A unique 32-character ID among Algo orders"), - reduceOnly: z - .boolean() - .optional() - .describe("true or false. Default false; Cannot be sent in Hedge Mode or when opening a position"), - limitPrice: z - .number() - .positive() - .optional() - .describe("Limit price of the order; Defaults to market price if not sent"), - recvWindow: z.number().int().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await algoClient.restAPI.volumeParticipationFutureAlgo({ - symbol: params.symbol, - side: params.side, - quantity: params.quantity, - urgency: params.urgency, - ...(params.positionSide && { positionSide: params.positionSide }), - ...(params.clientAlgoId && { clientAlgoId: params.clientAlgoId }), - ...(params.reduceOnly !== undefined && { reduceOnly: params.reduceOnly }), - ...(params.limitPrice !== undefined && { limitPrice: params.limitPrice }), - recvWindow: params.recvWindow - }); + server.tool( + "BinanceVolumeParticipationNewTrade", + "The Volume Participation (VP) New Order API allows users to place a VP order on USDⓈ-M Contracts in Binance Futures.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Trading side (BUY or SELL)"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe( + "Default BOTH for One-way Mode; LONG or SHORT for Hedge Mode. It must be sent in Hedge Mode.", + ), + quantity: z + .number() + .positive() + .min(10000) + .max(1000000) + .describe("Quantity of base asset; Notional must be between 10,000 and 1,000,000 USDT"), + urgency: z.enum(["LOW", "MEDIUM", "HIGH"]).describe("Execution speed: LOW, MEDIUM, HIGH"), + clientAlgoId: z + .string() + .length(32) + .optional() + .describe("A unique 32-character ID among Algo orders"), + reduceOnly: z + .boolean() + .optional() + .describe( + "true or false. Default false; Cannot be sent in Hedge Mode or when opening a position", + ), + limitPrice: z + .number() + .positive() + .optional() + .describe("Limit price of the order; Defaults to market price if not sent"), + recvWindow: z.number().int().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await algoClient.restAPI.volumeParticipationFutureAlgo({ + symbol: params.symbol, + side: params.side, + quantity: params.quantity, + urgency: params.urgency, + ...(params.positionSide && { positionSide: params.positionSide }), + ...(params.clientAlgoId && { clientAlgoId: params.clientAlgoId }), + ...(params.reduceOnly !== undefined && { reduceOnly: params.reduceOnly }), + ...(params.limitPrice !== undefined && { limitPrice: params.limitPrice }), + recvWindow: params.recvWindow, + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `VP order on USDⓈ-M Contracts placed successfully for ${ + params.symbol + }. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `VP order on USDⓈ-M Contracts placed successfully for ${ - params.symbol - }. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to place a VP order: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to place a VP order: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-algo/future-algo/cancelAlgoOrder.ts b/src/tools/binance-algo/future-algo/cancelAlgoOrder.ts index cc80a4a3..e068f8bb 100644 --- a/src/tools/binance-algo/future-algo/cancelAlgoOrder.ts +++ b/src/tools/binance-algo/future-algo/cancelAlgoOrder.ts @@ -1,45 +1,48 @@ // src/tools/binance-algo/future-algo/cancelAlgoOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { algoClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { algoClient } from "../../../config/binanceClient.js" export function registerBinanceFutureCancelAlgoOrder(server: McpServer) { - server.tool( - "BinanceFutureCancelAlgoOrder", - "The Cancel Algo Order API allows users to cancel an active algorithmic order on USDⓈ-M Contracts in Binance Futures.", - { - algoId: z.number().int().describe("Algo order ID (e.g., 14511)"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await algoClient.restAPI.cancelAlgoOrderFutureAlgo({ - algoId: params.algoId, - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceFutureCancelAlgoOrder", + "The Cancel Algo Order API allows users to cancel an active algorithmic order on USDⓈ-M Contracts in Binance Futures.", + { + algoId: z.number().int().describe("Algo order ID (e.g., 14511)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await algoClient.restAPI.cancelAlgoOrderFutureAlgo({ + algoId: params.algoId, + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Algo order ${params.algoId} canceled successfully. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Algo order ${params.algoId} canceled successfully. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to cancel Algo Order: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to cancel Algo Order: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-algo/future-algo/currentAlgoOpenOrders.ts b/src/tools/binance-algo/future-algo/currentAlgoOpenOrders.ts index 14a2de89..39890130 100644 --- a/src/tools/binance-algo/future-algo/currentAlgoOpenOrders.ts +++ b/src/tools/binance-algo/future-algo/currentAlgoOpenOrders.ts @@ -1,43 +1,46 @@ // src/tools/binance-algo/future-algo/currentAlgoOpenOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { algoClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { algoClient } from "../../../config/binanceClient.js" export function registerBinanceFutureCurrentAlgoOpenOrders(server: McpServer) { - server.tool( - "BinanceFutureCurrentAlgoOpenOrders", - "The Query Current Algo Open Orders API retrieves a list of currently active algorithmic orders for USDⓈ-M Contracts in Binance Futures.", - { - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await algoClient.restAPI.queryCurrentAlgoOpenOrdersFutureAlgo({ - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceFutureCurrentAlgoOpenOrders", + "The Query Current Algo Open Orders API retrieves a list of currently active algorithmic orders for USDⓈ-M Contracts in Binance Futures.", + { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await algoClient.restAPI.queryCurrentAlgoOpenOrdersFutureAlgo({ + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Currently active algorithmic orders. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Currently active algorithmic orders. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to Query Current Algo Open Orders: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to Query Current Algo Open Orders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-algo/future-algo/historicalAlgoOrder.ts b/src/tools/binance-algo/future-algo/historicalAlgoOrder.ts index bf3f942d..50583309 100644 --- a/src/tools/binance-algo/future-algo/historicalAlgoOrder.ts +++ b/src/tools/binance-algo/future-algo/historicalAlgoOrder.ts @@ -1,62 +1,73 @@ // src/tools/binance-algo/future-algo/historicalAlgoOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { algoClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { algoClient } from "../../../config/binanceClient.js" export function registerBinanceFutureHistoricalAlgoOrder(server: McpServer) { - server.tool( - "BinanceFutureHistoricalAlgoOrder", - "The Query Historical Algo Orders API retrieves a list of past algorithmic orders for USDⓈ-M Contracts in Binance Futures.", - { - symbol: z.string().optional().describe("Trading symbol (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).optional().describe("Trading side (BUY or SELL)"), - startTime: z.number().int().optional().describe("Start time in milliseconds (e.g., 1641522717552)"), - endTime: z.number().int().optional().describe("End time in milliseconds (e.g., 1641522526562)"), - page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), - pageSize: z - .number() - .int() - .min(1) - .max(100) - .default(100) - .optional() - .describe("Number of results per page, MIN 1, MAX 100, default is 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await algoClient.restAPI.queryHistoricalAlgoOrdersFutureAlgo({ - ...(params.symbol !== undefined && { symbol: params.symbol }), - ...(params.side !== undefined && { side: params.side }), - ...(params.startTime !== undefined && { startTime: params.startTime }), - ...(params.endTime !== undefined && { endTime: params.endTime }), - ...(params.page !== undefined && { page: params.page }), - ...(params.pageSize !== undefined && { pageSize: params.pageSize }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceFutureHistoricalAlgoOrder", + "The Query Historical Algo Orders API retrieves a list of past algorithmic orders for USDⓈ-M Contracts in Binance Futures.", + { + symbol: z.string().optional().describe("Trading symbol (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).optional().describe("Trading side (BUY or SELL)"), + startTime: z + .number() + .int() + .optional() + .describe("Start time in milliseconds (e.g., 1641522717552)"), + endTime: z + .number() + .int() + .optional() + .describe("End time in milliseconds (e.g., 1641522526562)"), + page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), + pageSize: z + .number() + .int() + .min(1) + .max(100) + .default(100) + .optional() + .describe("Number of results per page, MIN 1, MAX 100, default is 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await algoClient.restAPI.queryHistoricalAlgoOrdersFutureAlgo({ + ...(params.symbol !== undefined && { symbol: params.symbol }), + ...(params.side !== undefined && { side: params.side }), + ...(params.startTime !== undefined && { startTime: params.startTime }), + ...(params.endTime !== undefined && { endTime: params.endTime }), + ...(params.page !== undefined && { page: params.page }), + ...(params.pageSize !== undefined && { pageSize: params.pageSize }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Historical Algo Orders retrieves successfully. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Historical Algo Orders retrieves successfully. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to Query Historical Algo Orders: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to Query Historical Algo Orders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-algo/future-algo/index.ts b/src/tools/binance-algo/future-algo/index.ts index 9dfdc703..4369d2aa 100644 --- a/src/tools/binance-algo/future-algo/index.ts +++ b/src/tools/binance-algo/future-algo/index.ts @@ -1,28 +1,29 @@ // src/tools/binance-spot/market-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceVPNewTrade } from "./VPNewTrade.js"; -import { registerBinanceFutureHistoricalAlgoOrder } from "./historicalAlgoOrder.js"; -import { registerBinanceFutureCancelAlgoOrder } from "./cancelAlgoOrder.js"; -import { registerBinanceFutureCurrentAlgoOpenOrders } from "./currentAlgoOpenOrders.js"; -import { registerBinanceFutureSubOrders } from "./subOrders.js"; -import { registerBinanceTwapNewTrade } from "./TwapNewTrade.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceFutureCancelAlgoOrder } from "./cancelAlgoOrder.js" +import { registerBinanceFutureCurrentAlgoOpenOrders } from "./currentAlgoOpenOrders.js" +import { registerBinanceFutureHistoricalAlgoOrder } from "./historicalAlgoOrder.js" +import { registerBinanceFutureSubOrders } from "./subOrders.js" +import { registerBinanceTwapNewTrade } from "./TwapNewTrade.js" +import { registerBinanceVPNewTrade } from "./VPNewTrade.js" export function registerBinanceAlgoFutureApiTools(server: McpServer) { - // Registers a new VP (Volume Participation) trade - registerBinanceVPNewTrade(server); + // Registers a new VP (Volume Participation) trade + registerBinanceVPNewTrade(server) - // Registers a new TWAP (Time-Weighted Average Price) trade - registerBinanceTwapNewTrade(server); + // Registers a new TWAP (Time-Weighted Average Price) trade + registerBinanceTwapNewTrade(server) - // Registers functionality to cancel an algorithmic order - registerBinanceFutureCancelAlgoOrder(server); + // Registers functionality to cancel an algorithmic order + registerBinanceFutureCancelAlgoOrder(server) - // Registers API to query sub-orders of an algorithmic order - registerBinanceFutureSubOrders(server); + // Registers API to query sub-orders of an algorithmic order + registerBinanceFutureSubOrders(server) - // Registers API to retrieve currently open algorithmic orders - registerBinanceFutureCurrentAlgoOpenOrders(server); + // Registers API to retrieve currently open algorithmic orders + registerBinanceFutureCurrentAlgoOpenOrders(server) - // Registers API to fetch historical algorithmic orders - registerBinanceFutureHistoricalAlgoOrder(server); + // Registers API to fetch historical algorithmic orders + registerBinanceFutureHistoricalAlgoOrder(server) } diff --git a/src/tools/binance-algo/future-algo/subOrders.ts b/src/tools/binance-algo/future-algo/subOrders.ts index cb334943..4a46a1d7 100644 --- a/src/tools/binance-algo/future-algo/subOrders.ts +++ b/src/tools/binance-algo/future-algo/subOrders.ts @@ -1,58 +1,61 @@ // src/tools/binance-algo/future-algo/subOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { algoClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { algoClient } from "../../../config/binanceClient.js" export function registerBinanceFutureSubOrders(server: McpServer) { - server.tool( - "BinanceFutureSubOrders", - "The Sub Orders API retrieves sub-orders associated with a specified algoId for USDⓈ-M Contracts in Binance Futures.", - { - algoId: z.number().int().describe("Algo order ID"), - page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), - pageSize: z - .number() - .int() - .min(1) - .max(100) - .default(100) - .optional() - .describe("Number of results per page, MIN 1, MAX 100, default is 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await algoClient.restAPI.querySubOrdersFutureAlgo({ - algoId: params.algoId, - page: params.page, - pageSize: params.pageSize, - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceFutureSubOrders", + "The Sub Orders API retrieves sub-orders associated with a specified algoId for USDⓈ-M Contracts in Binance Futures.", + { + algoId: z.number().int().describe("Algo order ID"), + page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), + pageSize: z + .number() + .int() + .min(1) + .max(100) + .default(100) + .optional() + .describe("Number of results per page, MIN 1, MAX 100, default is 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await algoClient.restAPI.querySubOrdersFutureAlgo({ + algoId: params.algoId, + page: params.page, + pageSize: params.pageSize, + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Sub Orders retrieved successfully for id ${ + params.algoId + }. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Sub Orders retrieved successfully for id ${ - params.algoId - }. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve retrieve sub-orders: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve retrieve sub-orders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-algo/index.ts b/src/tools/binance-algo/index.ts index ebbeb993..8de0688e 100644 --- a/src/tools/binance-algo/index.ts +++ b/src/tools/binance-algo/index.ts @@ -1,10 +1,11 @@ // src/tools/binance-spot/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceAlgoFutureApiTools } from "./future-algo/index.js"; -import { registerBinanceAlgoSpotApiTools } from "./spot-algo/index.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceAlgoFutureApiTools } from "./future-algo/index.js" +import { registerBinanceAlgoSpotApiTools } from "./spot-algo/index.js" export function registerBinanceAlgoTools(server: McpServer) { - // Algo API tools - registerBinanceAlgoFutureApiTools(server); - registerBinanceAlgoSpotApiTools(server); + // Algo API tools + registerBinanceAlgoFutureApiTools(server) + registerBinanceAlgoSpotApiTools(server) } diff --git a/src/tools/binance-algo/spot-algo/cancelOpenTWAPOrder.ts b/src/tools/binance-algo/spot-algo/cancelOpenTWAPOrder.ts index d69c2904..3517999e 100644 --- a/src/tools/binance-algo/spot-algo/cancelOpenTWAPOrder.ts +++ b/src/tools/binance-algo/spot-algo/cancelOpenTWAPOrder.ts @@ -1,45 +1,48 @@ // src/tools/binance-algo/spot-algo/cancelOpenTWAPOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { algoClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { algoClient } from "../../../config/binanceClient.js" export function registerBinanceSpotCancelOpenTWAPOrder(server: McpServer) { - server.tool( - "BinanceSpotCancelOpenTWAPOrder", - "The Cancel Algo Order API allows users to cancel an open TWAP algorithmic order for spot trading on Binance.", - { - algoId: z.number().int().describe("Algo order ID (e.g., 14511)"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await algoClient.restAPI.cancelAlgoOrderSpotAlgo({ - algoId: params.algoId, - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSpotCancelOpenTWAPOrder", + "The Cancel Algo Order API allows users to cancel an open TWAP algorithmic order for spot trading on Binance.", + { + algoId: z.number().int().describe("Algo order ID (e.g., 14511)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await algoClient.restAPI.cancelAlgoOrderSpotAlgo({ + algoId: params.algoId, + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Algo order ${params.algoId} canceled successfully. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Algo order ${params.algoId} canceled successfully. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to Cancel Algo Order: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to Cancel Algo Order: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-algo/spot-algo/currentAlgoOpenOrders.ts b/src/tools/binance-algo/spot-algo/currentAlgoOpenOrders.ts index c47bc2cc..14b6d6cc 100644 --- a/src/tools/binance-algo/spot-algo/currentAlgoOpenOrders.ts +++ b/src/tools/binance-algo/spot-algo/currentAlgoOpenOrders.ts @@ -1,45 +1,48 @@ // src/tools/binance-algo/spot-algo/currentAlgoOpenOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { algoClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { algoClient } from "../../../config/binanceClient.js" export function registerBinanceSpotCurrentAlgoOpenOrders(server: McpServer) { - server.tool( - "BinanceSpotCurrentAlgoOpenOrders", - "This API retrieves all open SPOT TWAP (Time-Weighted Average Price) orders on Binance.", - { - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await algoClient.restAPI.queryCurrentAlgoOpenOrdersSpotAlgo({ - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSpotCurrentAlgoOpenOrders", + "This API retrieves all open SPOT TWAP (Time-Weighted Average Price) orders on Binance.", + { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await algoClient.restAPI.queryCurrentAlgoOpenOrdersSpotAlgo({ + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieve all open SPOT TWAP (Time-Weighted Average Price) orders. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieve all open SPOT TWAP (Time-Weighted Average Price) orders. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieves all open SPOT TWAP: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieves all open SPOT TWAP: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-algo/spot-algo/historicalAlgoOrders.ts b/src/tools/binance-algo/spot-algo/historicalAlgoOrders.ts index aa95a22e..543a9c62 100644 --- a/src/tools/binance-algo/spot-algo/historicalAlgoOrders.ts +++ b/src/tools/binance-algo/spot-algo/historicalAlgoOrders.ts @@ -1,64 +1,75 @@ // src/tools/binance-algo/spot-algo/historicalAlgoOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { algoClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { algoClient } from "../../../config/binanceClient.js" export function registerBinanceSpotHistoricalAlgoOrders(server: McpServer) { - server.tool( - "BinanceSpotHistoricalAlgoOrders", - "This API retrieves all historical SPOT TWAP (Time-Weighted Average Price) orders from Binance.", - { - symbol: z.string().optional().describe("Trading symbol (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).optional().describe("Trading side (BUY or SELL)"), - startTime: z.number().int().optional().describe("Start time in milliseconds (e.g., 1641522717552)"), - endTime: z.number().int().optional().describe("End time in milliseconds (e.g., 1641522526562)"), - page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), - pageSize: z - .number() - .int() - .min(1) - .max(100) - .default(100) - .optional() - .describe("Number of results per page, MIN 1, MAX 100, default is 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await algoClient.restAPI.queryHistoricalAlgoOrdersSpotAlgo({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.side && { side: params.side }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.page && { page: params.page }), - ...(params.pageSize && { pageSize: params.pageSize }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSpotHistoricalAlgoOrders", + "This API retrieves all historical SPOT TWAP (Time-Weighted Average Price) orders from Binance.", + { + symbol: z.string().optional().describe("Trading symbol (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).optional().describe("Trading side (BUY or SELL)"), + startTime: z + .number() + .int() + .optional() + .describe("Start time in milliseconds (e.g., 1641522717552)"), + endTime: z + .number() + .int() + .optional() + .describe("End time in milliseconds (e.g., 1641522526562)"), + page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), + pageSize: z + .number() + .int() + .min(1) + .max(100) + .default(100) + .optional() + .describe("Number of results per page, MIN 1, MAX 100, default is 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await algoClient.restAPI.queryHistoricalAlgoOrdersSpotAlgo({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.side && { side: params.side }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.page && { page: params.page }), + ...(params.pageSize && { pageSize: params.pageSize }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieves all historical SPOT TWAP (Time-Weighted Average Price) orders from Binance. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieves all historical SPOT TWAP (Time-Weighted Average Price) orders from Binance. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve all historical SPOT TWAP: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve all historical SPOT TWAP: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-algo/spot-algo/index.ts b/src/tools/binance-algo/spot-algo/index.ts index d43c1f94..a8f1e420 100644 --- a/src/tools/binance-algo/spot-algo/index.ts +++ b/src/tools/binance-algo/spot-algo/index.ts @@ -1,24 +1,25 @@ // src/tools/binance-spot/market-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceSpotTwapNewTrade } from "./spotTWAPOrder.js"; -import { registerBinanceSpotCancelOpenTWAPOrder } from "./cancelOpenTWAPOrder.js"; -import { registerBinanceSpotSubOrders } from "./subOrders.js"; -import { registerBinanceSpotCurrentAlgoOpenOrders } from "./currentAlgoOpenOrders.js"; -import { registerBinanceSpotHistoricalAlgoOrders } from "./historicalAlgoOrders.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceSpotCancelOpenTWAPOrder } from "./cancelOpenTWAPOrder.js" +import { registerBinanceSpotCurrentAlgoOpenOrders } from "./currentAlgoOpenOrders.js" +import { registerBinanceSpotHistoricalAlgoOrders } from "./historicalAlgoOrders.js" +import { registerBinanceSpotTwapNewTrade } from "./spotTWAPOrder.js" +import { registerBinanceSpotSubOrders } from "./subOrders.js" export function registerBinanceAlgoSpotApiTools(server: McpServer) { - // Register the TWAP (Time-Weighted Average Price) tool for placing new spot algo orders - registerBinanceSpotTwapNewTrade(server); + // Register the TWAP (Time-Weighted Average Price) tool for placing new spot algo orders + registerBinanceSpotTwapNewTrade(server) - // Register the tool for canceling open TWAP spot algo orders - registerBinanceSpotCancelOpenTWAPOrder(server); + // Register the tool for canceling open TWAP spot algo orders + registerBinanceSpotCancelOpenTWAPOrder(server) - // Register the tool to handle sub-orders created under a parent algo order - registerBinanceSpotSubOrders(server); + // Register the tool to handle sub-orders created under a parent algo order + registerBinanceSpotSubOrders(server) - // Register the tool to fetch currently open algo orders for spot trading - registerBinanceSpotCurrentAlgoOpenOrders(server); + // Register the tool to fetch currently open algo orders for spot trading + registerBinanceSpotCurrentAlgoOpenOrders(server) - // Register the tool to fetch historical algo orders for spot trading - registerBinanceSpotHistoricalAlgoOrders(server); + // Register the tool to fetch historical algo orders for spot trading + registerBinanceSpotHistoricalAlgoOrders(server) } diff --git a/src/tools/binance-algo/spot-algo/spotTWAPOrder.ts b/src/tools/binance-algo/spot-algo/spotTWAPOrder.ts index 60b6f055..03510e6c 100644 --- a/src/tools/binance-algo/spot-algo/spotTWAPOrder.ts +++ b/src/tools/binance-algo/spot-algo/spotTWAPOrder.ts @@ -1,73 +1,78 @@ // src/tools/binance-algo/spot-algo/spotTwapNewTrade.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { algoClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { algoClient } from "../../../config/binanceClient.js" export function registerBinanceSpotTwapNewTrade(server: McpServer) { - server.tool( - "BinanceSpotTimeWeightedAveragePriceNewOrder", - "The TWAP (Time-Weighted Average Price) New Order API allows users to place TWAP algorithmic orders for USDⓈ-M Futures on Binance.", - { - symbol: z.string().describe("Trading symbol (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Trading side (BUY or SELL)"), - quantity: z - .number() - .positive() - .describe( - "Quantity of base asset; Maximum notional per order is 200k, 2mm, or 10mm, depending on the symbol" - ), - duration: z - .number() - .int() - .min(300) - .max(86400) - .describe("Duration for TWAP orders in seconds. Must be between 300 and 86400"), - clientAlgoId: z - .string() - .length(32) - .optional() - .describe("A unique 32-character ID among Algo orders. If not sent, a default value will be assigned"), - limitPrice: z - .number() - .positive() - .optional() - .describe("Limit price of the order; Defaults to market price if not sent") - }, - async (params) => { - try { - const response = await algoClient.restAPI.timeWeightedAveragePriceSpotAlgo({ - symbol: params.symbol, - side: params.side, - quantity: params.quantity, - duration: params.duration, - ...(params.clientAlgoId !== undefined && { clientAlgoId: params.clientAlgoId }), - ...(params.limitPrice !== undefined && { limitPrice: params.limitPrice }) - }); + server.tool( + "BinanceSpotTimeWeightedAveragePriceNewOrder", + "The TWAP (Time-Weighted Average Price) New Order API allows users to place TWAP algorithmic orders for USDⓈ-M Futures on Binance.", + { + symbol: z.string().describe("Trading symbol (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Trading side (BUY or SELL)"), + quantity: z + .number() + .positive() + .describe( + "Quantity of base asset; Maximum notional per order is 200k, 2mm, or 10mm, depending on the symbol", + ), + duration: z + .number() + .int() + .min(300) + .max(86400) + .describe("Duration for TWAP orders in seconds. Must be between 300 and 86400"), + clientAlgoId: z + .string() + .length(32) + .optional() + .describe( + "A unique 32-character ID among Algo orders. If not sent, a default value will be assigned", + ), + limitPrice: z + .number() + .positive() + .optional() + .describe("Limit price of the order; Defaults to market price if not sent"), + }, + async (params) => { + try { + const response = await algoClient.restAPI.timeWeightedAveragePriceSpotAlgo({ + symbol: params.symbol, + side: params.side, + quantity: params.quantity, + duration: params.duration, + ...(params.clientAlgoId !== undefined && { clientAlgoId: params.clientAlgoId }), + ...(params.limitPrice !== undefined && { limitPrice: params.limitPrice }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `TWAP order on USDⓈ-M Contracts placed successfully for ${ + params.symbol + }. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `TWAP order on USDⓈ-M Contracts placed successfully for ${ - params.symbol - }. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to place TWAP algorithmic orders for USDⓈ-M Futures on Binance: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to place TWAP algorithmic orders for USDⓈ-M Futures on Binance: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-algo/spot-algo/subOrders.ts b/src/tools/binance-algo/spot-algo/subOrders.ts index 6836d7b4..2c7ac0c4 100644 --- a/src/tools/binance-algo/spot-algo/subOrders.ts +++ b/src/tools/binance-algo/spot-algo/subOrders.ts @@ -1,58 +1,61 @@ // src/tools/binance-algo/spot-algo/subOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { algoClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { algoClient } from "../../../config/binanceClient.js" export function registerBinanceSpotSubOrders(server: McpServer) { - server.tool( - "BinanceSpotSubOrders", - "The Query Sub Orders API retrieves details of sub-orders associated with a specific algorithmic (Algo) order for spot trading on Binance.", - { - algoId: z.number().int().describe("Algo order ID"), - page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), - pageSize: z - .number() - .int() - .min(1) - .max(100) - .default(100) - .optional() - .describe("Number of results per page, MIN 1, MAX 100, default is 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await algoClient.restAPI.querySubOrdersSpotAlgo({ - algoId: params.algoId, - ...(params.page !== undefined && { page: params.page }), - ...(params.pageSize !== undefined && { pageSize: params.pageSize }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSpotSubOrders", + "The Query Sub Orders API retrieves details of sub-orders associated with a specific algorithmic (Algo) order for spot trading on Binance.", + { + algoId: z.number().int().describe("Algo order ID"), + page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), + pageSize: z + .number() + .int() + .min(1) + .max(100) + .default(100) + .optional() + .describe("Number of results per page, MIN 1, MAX 100, default is 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await algoClient.restAPI.querySubOrdersSpotAlgo({ + algoId: params.algoId, + ...(params.page !== undefined && { page: params.page }), + ...(params.pageSize !== undefined && { pageSize: params.pageSize }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Sub Orders retrieved successfully for id${params.algoId}. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Sub Orders retrieved successfully for id${params.algoId}. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to Query Sub Orders: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to Query Sub Orders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-auto-invest/changeIndexPlanStatus.ts b/src/tools/binance-auto-invest/changeIndexPlanStatus.ts index 39b62f77..39dfbfc5 100644 --- a/src/tools/binance-auto-invest/changeIndexPlanStatus.ts +++ b/src/tools/binance-auto-invest/changeIndexPlanStatus.ts @@ -5,40 +5,46 @@ * @license Apache-2.0 */ // src/tools/binance-auto-invest/changeIndexPlanStatus.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { autoInvestClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerBinanceAutoInvestChangeIndexPlanStatus(server: McpServer) { - server.tool( - "BinanceAutoInvestChangeIndexPlanStatus", - "Change the status of an index-linked auto-invest plan (pause/resume).", - { - indexId: z.number().int().describe("Index ID"), - status: z.enum(["PAUSED", "ONGOING"]).describe("New plan status"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await autoInvestClient.restAPI.changeIndexPlanStatus({ - indexId: params.indexId, - status: params.status, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `✅ Index plan status changed to ${params.status}\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to change index plan status: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceAutoInvestChangeIndexPlanStatus", + "Change the status of an index-linked auto-invest plan (pause/resume).", + { + indexId: z.number().int().describe("Index ID"), + status: z.enum(["PAUSED", "ONGOING"]).describe("New plan status"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await autoInvestClient.restAPI.changeIndexPlanStatus({ + indexId: params.indexId, + status: params.status, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Index plan status changed to ${params.status}\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to change index plan status: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-auto-invest/changePlanStatus.ts b/src/tools/binance-auto-invest/changePlanStatus.ts index 3e189745..aea225ba 100644 --- a/src/tools/binance-auto-invest/changePlanStatus.ts +++ b/src/tools/binance-auto-invest/changePlanStatus.ts @@ -1,39 +1,41 @@ // src/tools/binance-auto-invest/changePlanStatus.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerBinanceAutoInvestChangePlanStatus(server: McpServer) { - server.tool( - "BinanceAutoInvestChangePlanStatus", - "Change plan status (pause/resume) for auto-invest.", - { - planId: z.number().describe("Plan ID"), - status: z.enum(["ONGOING", "PAUSED", "REMOVED"]).describe("New plan status") - }, - async ({ planId, status }) => { - try { - const params: any = { planId, status }; - - const response = await autoInvestClient.restAPI.changePlanStatus(params); - const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Plan status changed successfully. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to change plan status: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceAutoInvestChangePlanStatus", + "Change plan status (pause/resume) for auto-invest.", + { + planId: z.number().describe("Plan ID"), + status: z.enum(["ONGOING", "PAUSED", "REMOVED"]).describe("New plan status"), + }, + async ({ planId, status }) => { + try { + const params: any = { planId, status } + + const response = await autoInvestClient.restAPI.changePlanStatus(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Plan status changed successfully. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to change plan status: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-auto-invest/createPlan.ts b/src/tools/binance-auto-invest/createPlan.ts index ef065873..abdffe20 100644 --- a/src/tools/binance-auto-invest/createPlan.ts +++ b/src/tools/binance-auto-invest/createPlan.ts @@ -1,54 +1,72 @@ // src/tools/binance-auto-invest/createPlan.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerBinanceAutoInvestCreatePlan(server: McpServer) { - server.tool( - "BinanceAutoInvestCreatePlan", - "Create an investment plan for auto-invest.", - { - sourceType: z.enum(["MAIN_SITE", "TR"]).describe("Source type"), - planType: z.enum(["SINGLE", "PORTFOLIO", "INDEX"]).describe("Plan type"), - subscriptionAmount: z.number().describe("Subscription amount"), - subscriptionCycle: z.enum(["H1", "H4", "H8", "H12", "WEEKLY", "DAILY", "MONTHLY", "BI_WEEKLY"]).describe("Subscription cycle"), - subscriptionStartTime: z.string().describe("Subscription start time"), - sourceAsset: z.string().describe("Source asset (e.g., USDT)"), - flexibleAllowedToUse: z.boolean().optional().describe("Whether flexible products are allowed to use"), - details: z.string().describe("JSON array of plan details including targetAsset and percentage") - }, - async ({ sourceType, planType, subscriptionAmount, subscriptionCycle, subscriptionStartTime, sourceAsset, flexibleAllowedToUse, details }) => { - try { - const params: any = { - sourceType, - planType, - subscriptionAmount, - subscriptionCycle, - subscriptionStartTime, - sourceAsset, - details - }; - if (flexibleAllowedToUse !== undefined) params.flexibleAllowedToUse = flexibleAllowedToUse; - - const response = await autoInvestClient.restAPI.investmentPlanCreation(params); - const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Investment plan created successfully. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to create plan: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceAutoInvestCreatePlan", + "Create an investment plan for auto-invest.", + { + sourceType: z.enum(["MAIN_SITE", "TR"]).describe("Source type"), + planType: z.enum(["SINGLE", "PORTFOLIO", "INDEX"]).describe("Plan type"), + subscriptionAmount: z.number().describe("Subscription amount"), + subscriptionCycle: z + .enum(["H1", "H4", "H8", "H12", "WEEKLY", "DAILY", "MONTHLY", "BI_WEEKLY"]) + .describe("Subscription cycle"), + subscriptionStartTime: z.string().describe("Subscription start time"), + sourceAsset: z.string().describe("Source asset (e.g., USDT)"), + flexibleAllowedToUse: z + .boolean() + .optional() + .describe("Whether flexible products are allowed to use"), + details: z + .string() + .describe("JSON array of plan details including targetAsset and percentage"), + }, + async ({ + sourceType, + planType, + subscriptionAmount, + subscriptionCycle, + subscriptionStartTime, + sourceAsset, + flexibleAllowedToUse, + details, + }) => { + try { + const params: any = { + sourceType, + planType, + subscriptionAmount, + subscriptionCycle, + subscriptionStartTime, + sourceAsset, + details, + } + if (flexibleAllowedToUse !== undefined) params.flexibleAllowedToUse = flexibleAllowedToUse + + const response = await autoInvestClient.restAPI.investmentPlanCreation(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Investment plan created successfully. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to create plan: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-auto-invest/editPlan.ts b/src/tools/binance-auto-invest/editPlan.ts index fb820ff3..0f257fac 100644 --- a/src/tools/binance-auto-invest/editPlan.ts +++ b/src/tools/binance-auto-invest/editPlan.ts @@ -1,50 +1,69 @@ // src/tools/binance-auto-invest/editPlan.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerBinanceAutoInvestEditPlan(server: McpServer) { - server.tool( - "BinanceAutoInvestEditPlan", - "Edit an existing investment plan for auto-invest.", - { - planId: z.number().describe("Plan ID to edit"), - subscriptionAmount: z.number().optional().describe("Subscription amount"), - subscriptionCycle: z.enum(["H1", "H4", "H8", "H12", "WEEKLY", "DAILY", "MONTHLY", "BI_WEEKLY"]).optional().describe("Subscription cycle"), - subscriptionStartTime: z.string().optional().describe("Subscription start time"), - sourceAsset: z.string().optional().describe("Source asset (e.g., USDT)"), - flexibleAllowedToUse: z.boolean().optional().describe("Whether flexible products are allowed to use"), - details: z.string().optional().describe("JSON array of plan details including targetAsset and percentage") - }, - async ({ planId, subscriptionAmount, subscriptionCycle, subscriptionStartTime, sourceAsset, flexibleAllowedToUse, details }) => { - try { - const params: any = { planId }; - if (subscriptionAmount !== undefined) params.subscriptionAmount = subscriptionAmount; - if (subscriptionCycle) params.subscriptionCycle = subscriptionCycle; - if (subscriptionStartTime) params.subscriptionStartTime = subscriptionStartTime; - if (sourceAsset) params.sourceAsset = sourceAsset; - if (flexibleAllowedToUse !== undefined) params.flexibleAllowedToUse = flexibleAllowedToUse; - if (details) params.details = details; - - const response = await autoInvestClient.restAPI.investmentPlanAdjustment(params); - const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Investment plan edited successfully. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to edit plan: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceAutoInvestEditPlan", + "Edit an existing investment plan for auto-invest.", + { + planId: z.number().describe("Plan ID to edit"), + subscriptionAmount: z.number().optional().describe("Subscription amount"), + subscriptionCycle: z + .enum(["H1", "H4", "H8", "H12", "WEEKLY", "DAILY", "MONTHLY", "BI_WEEKLY"]) + .optional() + .describe("Subscription cycle"), + subscriptionStartTime: z.string().optional().describe("Subscription start time"), + sourceAsset: z.string().optional().describe("Source asset (e.g., USDT)"), + flexibleAllowedToUse: z + .boolean() + .optional() + .describe("Whether flexible products are allowed to use"), + details: z + .string() + .optional() + .describe("JSON array of plan details including targetAsset and percentage"), + }, + async ({ + planId, + subscriptionAmount, + subscriptionCycle, + subscriptionStartTime, + sourceAsset, + flexibleAllowedToUse, + details, + }) => { + try { + const params: any = { planId } + if (subscriptionAmount !== undefined) params.subscriptionAmount = subscriptionAmount + if (subscriptionCycle) params.subscriptionCycle = subscriptionCycle + if (subscriptionStartTime) params.subscriptionStartTime = subscriptionStartTime + if (sourceAsset) params.sourceAsset = sourceAsset + if (flexibleAllowedToUse !== undefined) params.flexibleAllowedToUse = flexibleAllowedToUse + if (details) params.details = details + + const response = await autoInvestClient.restAPI.investmentPlanAdjustment(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Investment plan edited successfully. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to edit plan: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-auto-invest/getHistoryList.ts b/src/tools/binance-auto-invest/getHistoryList.ts index fe478468..c6d90aef 100644 --- a/src/tools/binance-auto-invest/getHistoryList.ts +++ b/src/tools/binance-auto-invest/getHistoryList.ts @@ -5,52 +5,60 @@ * @license Apache-2.0 */ // src/tools/binance-auto-invest/getHistoryList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { autoInvestClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerBinanceAutoInvestGetHistoryList(server: McpServer) { - server.tool( - "BinanceAutoInvestGetHistoryList", - "Get auto-invest transaction history. View all past purchases and investments.", - { - planId: z.number().int().optional().describe("Filter by plan ID"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - targetAsset: z.string().optional().describe("Filter by target asset"), - planType: z.enum(["SINGLE", "PORTFOLIO", "INDEX", "ALL"]).optional().describe("Filter by plan type"), - size: z.number().int().max(100).optional().describe("Number of results. Default 10, max 100"), - current: z.number().int().optional().describe("Current page. Default 1"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await autoInvestClient.restAPI.getHistoryList({ - ...(params.planId && { planId: params.planId }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.targetAsset && { targetAsset: params.targetAsset }), - ...(params.planType && { planType: params.planType }), - ...(params.size && { size: params.size }), - ...(params.current && { current: params.current }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `Auto-invest history:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get history: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceAutoInvestGetHistoryList", + "Get auto-invest transaction history. View all past purchases and investments.", + { + planId: z.number().int().optional().describe("Filter by plan ID"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + targetAsset: z.string().optional().describe("Filter by target asset"), + planType: z + .enum(["SINGLE", "PORTFOLIO", "INDEX", "ALL"]) + .optional() + .describe("Filter by plan type"), + size: z.number().int().max(100).optional().describe("Number of results. Default 10, max 100"), + current: z.number().int().optional().describe("Current page. Default 1"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await autoInvestClient.restAPI.getHistoryList({ + ...(params.planId && { planId: params.planId }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.targetAsset && { targetAsset: params.targetAsset }), + ...(params.planType && { planType: params.planType }), + ...(params.size && { size: params.size }), + ...(params.current && { current: params.current }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Auto-invest history:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get history: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-auto-invest/getIndexInfo.ts b/src/tools/binance-auto-invest/getIndexInfo.ts index 623aacb1..37ac8966 100644 --- a/src/tools/binance-auto-invest/getIndexInfo.ts +++ b/src/tools/binance-auto-invest/getIndexInfo.ts @@ -5,38 +5,44 @@ * @license Apache-2.0 */ // src/tools/binance-auto-invest/getIndexInfo.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { autoInvestClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerBinanceAutoInvestGetIndexInfo(server: McpServer) { - server.tool( - "BinanceAutoInvestGetIndexInfo", - "Get information about auto-invest index portfolios. Index portfolios are pre-built diversified portfolios.", - { - indexId: z.number().int().optional().describe("Specific index ID to query"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await autoInvestClient.restAPI.getIndexInfo({ - ...(params.indexId && { indexId: params.indexId }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Index portfolio info:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get index info: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceAutoInvestGetIndexInfo", + "Get information about auto-invest index portfolios. Index portfolios are pre-built diversified portfolios.", + { + indexId: z.number().int().optional().describe("Specific index ID to query"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await autoInvestClient.restAPI.getIndexInfo({ + ...(params.indexId && { indexId: params.indexId }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Index portfolio info:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get index info: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-auto-invest/getIndexLinkedPlanPositionDetails.ts b/src/tools/binance-auto-invest/getIndexLinkedPlanPositionDetails.ts index 6cbb4ac9..286f12d2 100644 --- a/src/tools/binance-auto-invest/getIndexLinkedPlanPositionDetails.ts +++ b/src/tools/binance-auto-invest/getIndexLinkedPlanPositionDetails.ts @@ -5,38 +5,44 @@ * @license Apache-2.0 */ // src/tools/binance-auto-invest/getIndexLinkedPlanPositionDetails.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { autoInvestClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerBinanceAutoInvestGetIndexLinkedPlanPositionDetails(server: McpServer) { - server.tool( - "BinanceAutoInvestGetIndexLinkedPlanPositionDetails", - "Get position details for an index-linked auto-invest plan.", - { - indexId: z.number().int().describe("Index ID"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await autoInvestClient.restAPI.getIndexLinkedPlanPositionDetails({ - indexId: params.indexId, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Index-linked plan position details:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get position details: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceAutoInvestGetIndexLinkedPlanPositionDetails", + "Get position details for an index-linked auto-invest plan.", + { + indexId: z.number().int().describe("Index ID"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await autoInvestClient.restAPI.getIndexLinkedPlanPositionDetails({ + indexId: params.indexId, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Index-linked plan position details:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get position details: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-auto-invest/getIndexLinkedPlanPositionList.ts b/src/tools/binance-auto-invest/getIndexLinkedPlanPositionList.ts index a5d3d26d..dcc75de2 100644 --- a/src/tools/binance-auto-invest/getIndexLinkedPlanPositionList.ts +++ b/src/tools/binance-auto-invest/getIndexLinkedPlanPositionList.ts @@ -1,38 +1,45 @@ // src/tools/binance-auto-invest/getIndexLinkedPlanPositionList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerBinanceAutoInvestGetIndexLinkedPlanPositionList(server: McpServer) { - server.tool( - "BinanceAutoInvestGetIndexLinkedPlanPositionList", - "Query index linked plan position details for auto-invest.", - { - indexId: z.number().describe("Index ID") - }, - async ({ indexId }) => { - try { - const params: any = { indexId }; - - const response = await autoInvestClient.restAPI.queryIndexLinkedPlanPositionDetails(params); - const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Index linked plan position list retrieved. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get index linked plan position list: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceAutoInvestGetIndexLinkedPlanPositionList", + "Query index linked plan position details for auto-invest.", + { + indexId: z.number().describe("Index ID"), + }, + async ({ indexId }) => { + try { + const params: any = { indexId } + + const response = await autoInvestClient.restAPI.queryIndexLinkedPlanPositionDetails(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Index linked plan position list retrieved. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `Failed to get index linked plan position list: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-auto-invest/getIndexLinkedPlanRebalanceHistory.ts b/src/tools/binance-auto-invest/getIndexLinkedPlanRebalanceHistory.ts index 8c528c1a..b928f34e 100644 --- a/src/tools/binance-auto-invest/getIndexLinkedPlanRebalanceHistory.ts +++ b/src/tools/binance-auto-invest/getIndexLinkedPlanRebalanceHistory.ts @@ -1,46 +1,53 @@ // src/tools/binance-auto-invest/getIndexLinkedPlanRebalanceHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerBinanceAutoInvestGetIndexLinkedPlanRebalanceHistory(server: McpServer) { - server.tool( - "BinanceAutoInvestGetIndexLinkedPlanRebalanceHistory", - "Query index linked plan rebalance history for auto-invest.", - { - indexId: z.number().describe("Index ID"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - current: z.number().optional().describe("Current page"), - size: z.number().optional().describe("Page size") - }, - async ({ indexId, startTime, endTime, current, size }) => { - try { - const params: any = { indexId }; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (current !== undefined) params.current = current; - if (size !== undefined) params.size = size; - - const response = await autoInvestClient.restAPI.indexLinkedPlanRebalanceDetails(params); - const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Index linked plan rebalance history retrieved. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get index linked plan rebalance history: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceAutoInvestGetIndexLinkedPlanRebalanceHistory", + "Query index linked plan rebalance history for auto-invest.", + { + indexId: z.number().describe("Index ID"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + current: z.number().optional().describe("Current page"), + size: z.number().optional().describe("Page size"), + }, + async ({ indexId, startTime, endTime, current, size }) => { + try { + const params: any = { indexId } + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (current !== undefined) params.current = current + if (size !== undefined) params.size = size + + const response = await autoInvestClient.restAPI.indexLinkedPlanRebalanceDetails(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Index linked plan rebalance history retrieved. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `Failed to get index linked plan rebalance history: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-auto-invest/getIndexUserSummary.ts b/src/tools/binance-auto-invest/getIndexUserSummary.ts index c17cc034..4d56633d 100644 --- a/src/tools/binance-auto-invest/getIndexUserSummary.ts +++ b/src/tools/binance-auto-invest/getIndexUserSummary.ts @@ -5,38 +5,44 @@ * @license Apache-2.0 */ // src/tools/binance-auto-invest/getIndexUserSummary.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { autoInvestClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerBinanceAutoInvestGetIndexUserSummary(server: McpServer) { - server.tool( - "BinanceAutoInvestGetIndexUserSummary", - "Get user's index-linked plan summary including total invested and current value.", - { - indexId: z.number().int().describe("Index ID to query"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await autoInvestClient.restAPI.getIndexUserSummary({ - indexId: params.indexId, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Index user summary for index ${params.indexId}:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get index user summary: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceAutoInvestGetIndexUserSummary", + "Get user's index-linked plan summary including total invested and current value.", + { + indexId: z.number().int().describe("Index ID to query"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await autoInvestClient.restAPI.getIndexUserSummary({ + indexId: params.indexId, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Index user summary for index ${params.indexId}:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get index user summary: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-auto-invest/getOneTimePlans.ts b/src/tools/binance-auto-invest/getOneTimePlans.ts index d66567e7..08530602 100644 --- a/src/tools/binance-auto-invest/getOneTimePlans.ts +++ b/src/tools/binance-auto-invest/getOneTimePlans.ts @@ -1,40 +1,42 @@ // src/tools/binance-auto-invest/getOneTimePlans.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerBinanceAutoInvestGetOneTimePlans(server: McpServer) { - server.tool( - "BinanceAutoInvestGetOneTimePlans", - "Query holding details of the plan.", - { - planId: z.number().describe("Plan ID"), - requestId: z.string().optional().describe("Request ID") - }, - async ({ planId, requestId }) => { - try { - const params: any = { planId }; - if (requestId) params.requestId = requestId; - - const response = await autoInvestClient.restAPI.queryOneTimeTransactionStatus(params); - const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Plan details retrieved. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get plan details: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceAutoInvestGetOneTimePlans", + "Query holding details of the plan.", + { + planId: z.number().describe("Plan ID"), + requestId: z.string().optional().describe("Request ID"), + }, + async ({ planId, requestId }) => { + try { + const params: any = { planId } + if (requestId) params.requestId = requestId + + const response = await autoInvestClient.restAPI.queryOneTimeTransactionStatus(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Plan details retrieved. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get plan details: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-auto-invest/getPlanList.ts b/src/tools/binance-auto-invest/getPlanList.ts index a57082bf..157fdc2b 100644 --- a/src/tools/binance-auto-invest/getPlanList.ts +++ b/src/tools/binance-auto-invest/getPlanList.ts @@ -1,39 +1,41 @@ // src/tools/binance-auto-invest/getPlanList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerBinanceAutoInvestGetPlanList(server: McpServer) { - server.tool( - "BinanceAutoInvestGetPlanList", - "Query auto-invest plan list.", - { - planType: z.enum(["SINGLE", "PORTFOLIO", "INDEX"]).optional().describe("Plan type") - }, - async ({ planType }) => { - try { - const params: any = {}; - if (planType) params.planType = planType; - - const response = await autoInvestClient.restAPI.getListOfPlans(params); - const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Plan list retrieved. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get plan list: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceAutoInvestGetPlanList", + "Query auto-invest plan list.", + { + planType: z.enum(["SINGLE", "PORTFOLIO", "INDEX"]).optional().describe("Plan type"), + }, + async ({ planType }) => { + try { + const params: any = {} + if (planType) params.planType = planType + + const response = await autoInvestClient.restAPI.getListOfPlans(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Plan list retrieved. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get plan list: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-auto-invest/getSourceAssetList.ts b/src/tools/binance-auto-invest/getSourceAssetList.ts index 5c96d9da..9e919d2d 100644 --- a/src/tools/binance-auto-invest/getSourceAssetList.ts +++ b/src/tools/binance-auto-invest/getSourceAssetList.ts @@ -1,45 +1,50 @@ // src/tools/binance-auto-invest/getSourceAssetList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerBinanceAutoInvestGetSourceAssetList(server: McpServer) { - server.tool( - "BinanceAutoInvestGetSourceAssetList", - "Get source asset list for auto-invest.", - { - usageType: z.string().optional().describe("Usage type"), - targetAsset: z.string().optional().describe("Target asset (e.g., BTC)"), - indexId: z.number().optional().describe("Index ID"), - flexibleAllowedToUse: z.boolean().optional().describe("Whether flexible products are allowed to use") - }, - async ({ usageType, targetAsset, indexId, flexibleAllowedToUse }) => { - try { - const params: any = {}; - if (usageType) params.usageType = usageType; - if (targetAsset) params.targetAsset = targetAsset; - if (indexId !== undefined) params.indexId = indexId; - if (flexibleAllowedToUse !== undefined) params.flexibleAllowedToUse = flexibleAllowedToUse; - - const response = await autoInvestClient.restAPI.querySourceAssetList(params); - const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Source asset list retrieved. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get source asset list: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceAutoInvestGetSourceAssetList", + "Get source asset list for auto-invest.", + { + usageType: z.string().optional().describe("Usage type"), + targetAsset: z.string().optional().describe("Target asset (e.g., BTC)"), + indexId: z.number().optional().describe("Index ID"), + flexibleAllowedToUse: z + .boolean() + .optional() + .describe("Whether flexible products are allowed to use"), + }, + async ({ usageType, targetAsset, indexId, flexibleAllowedToUse }) => { + try { + const params: any = {} + if (usageType) params.usageType = usageType + if (targetAsset) params.targetAsset = targetAsset + if (indexId !== undefined) params.indexId = indexId + if (flexibleAllowedToUse !== undefined) params.flexibleAllowedToUse = flexibleAllowedToUse + + const response = await autoInvestClient.restAPI.querySourceAssetList(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Source asset list retrieved. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get source asset list: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-auto-invest/getSubscriptionHistory.ts b/src/tools/binance-auto-invest/getSubscriptionHistory.ts index 0a9288d9..4e01c9aa 100644 --- a/src/tools/binance-auto-invest/getSubscriptionHistory.ts +++ b/src/tools/binance-auto-invest/getSubscriptionHistory.ts @@ -1,51 +1,53 @@ // src/tools/binance-auto-invest/getSubscriptionHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerBinanceAutoInvestGetSubscriptionHistory(server: McpServer) { - server.tool( - "BinanceAutoInvestGetSubscriptionHistory", - "Query subscription transaction history for auto-invest.", - { - planId: z.number().optional().describe("Plan ID"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - targetAsset: z.string().optional().describe("Target asset (e.g., BTC)"), - planType: z.enum(["SINGLE", "PORTFOLIO", "INDEX"]).optional().describe("Plan type"), - current: z.number().optional().describe("Current page"), - size: z.number().optional().describe("Page size") - }, - async ({ planId, startTime, endTime, targetAsset, planType, current, size }) => { - try { - const params: any = {}; - if (planId !== undefined) params.planId = planId; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (targetAsset) params.targetAsset = targetAsset; - if (planType) params.planType = planType; - if (current !== undefined) params.current = current; - if (size !== undefined) params.size = size; - - const response = await autoInvestClient.restAPI.querySubscriptionTransactionHistory(params); - const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Subscription history retrieved. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get subscription history: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceAutoInvestGetSubscriptionHistory", + "Query subscription transaction history for auto-invest.", + { + planId: z.number().optional().describe("Plan ID"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + targetAsset: z.string().optional().describe("Target asset (e.g., BTC)"), + planType: z.enum(["SINGLE", "PORTFOLIO", "INDEX"]).optional().describe("Plan type"), + current: z.number().optional().describe("Current page"), + size: z.number().optional().describe("Page size"), + }, + async ({ planId, startTime, endTime, targetAsset, planType, current, size }) => { + try { + const params: any = {} + if (planId !== undefined) params.planId = planId + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (targetAsset) params.targetAsset = targetAsset + if (planType) params.planType = planType + if (current !== undefined) params.current = current + if (size !== undefined) params.size = size + + const response = await autoInvestClient.restAPI.querySubscriptionTransactionHistory(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Subscription history retrieved. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get subscription history: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-auto-invest/getTargetAssetList.ts b/src/tools/binance-auto-invest/getTargetAssetList.ts index f49b174d..69389726 100644 --- a/src/tools/binance-auto-invest/getTargetAssetList.ts +++ b/src/tools/binance-auto-invest/getTargetAssetList.ts @@ -1,43 +1,45 @@ // src/tools/binance-auto-invest/getTargetAssetList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerBinanceAutoInvestGetTargetAssetList(server: McpServer) { - server.tool( - "BinanceAutoInvestGetTargetAssetList", - "Get target asset list for auto-invest.", - { - targetAsset: z.string().optional().describe("Target asset (e.g., BTC)"), - size: z.number().optional().describe("Page size"), - current: z.number().optional().describe("Current page") - }, - async ({ targetAsset, size, current }) => { - try { - const params: any = {}; - if (targetAsset) params.targetAsset = targetAsset; - if (size !== undefined) params.size = size; - if (current !== undefined) params.current = current; - - const response = await autoInvestClient.restAPI.getTargetAssetList(params); - const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Target asset list retrieved. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get target asset list: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceAutoInvestGetTargetAssetList", + "Get target asset list for auto-invest.", + { + targetAsset: z.string().optional().describe("Target asset (e.g., BTC)"), + size: z.number().optional().describe("Page size"), + current: z.number().optional().describe("Current page"), + }, + async ({ targetAsset, size, current }) => { + try { + const params: any = {} + if (targetAsset) params.targetAsset = targetAsset + if (size !== undefined) params.size = size + if (current !== undefined) params.current = current + + const response = await autoInvestClient.restAPI.getTargetAssetList(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Target asset list retrieved. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get target asset list: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-auto-invest/getTargetAssetROI.ts b/src/tools/binance-auto-invest/getTargetAssetROI.ts index 1410dd66..439de6b4 100644 --- a/src/tools/binance-auto-invest/getTargetAssetROI.ts +++ b/src/tools/binance-auto-invest/getTargetAssetROI.ts @@ -1,39 +1,43 @@ // src/tools/binance-auto-invest/getTargetAssetROI.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerBinanceAutoInvestGetTargetAssetROI(server: McpServer) { - server.tool( - "BinanceAutoInvestGetTargetAssetROI", - "Get target asset ROI data for auto-invest.", - { - targetAsset: z.string().describe("Target asset (e.g., BTC)"), - hisRoiType: z.enum(["FIVE_YEAR", "THREE_YEAR", "ONE_YEAR", "SIX_MONTH", "THREE_MONTH", "ONE_MONTH"]).describe("Historical ROI type") - }, - async ({ targetAsset, hisRoiType }) => { - try { - const params: any = { targetAsset, hisRoiType }; - - const response = await autoInvestClient.restAPI.getTargetAssetRoiData(params); - const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Target asset ROI data retrieved. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get target asset ROI: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceAutoInvestGetTargetAssetROI", + "Get target asset ROI data for auto-invest.", + { + targetAsset: z.string().describe("Target asset (e.g., BTC)"), + hisRoiType: z + .enum(["FIVE_YEAR", "THREE_YEAR", "ONE_YEAR", "SIX_MONTH", "THREE_MONTH", "ONE_MONTH"]) + .describe("Historical ROI type"), + }, + async ({ targetAsset, hisRoiType }) => { + try { + const params: any = { targetAsset, hisRoiType } + + const response = await autoInvestClient.restAPI.getTargetAssetRoiData(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Target asset ROI data retrieved. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get target asset ROI: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-auto-invest/getTargetAssetRoiData.ts b/src/tools/binance-auto-invest/getTargetAssetRoiData.ts index 5f17b651..8d5490d3 100644 --- a/src/tools/binance-auto-invest/getTargetAssetRoiData.ts +++ b/src/tools/binance-auto-invest/getTargetAssetRoiData.ts @@ -5,40 +5,48 @@ * @license Apache-2.0 */ // src/tools/binance-auto-invest/getTargetAssetRoiData.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { autoInvestClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerBinanceAutoInvestGetTargetAssetRoiData(server: McpServer) { - server.tool( - "BinanceAutoInvestGetTargetAssetRoiData", - "Get ROI (Return on Investment) data for auto-invest target assets. Shows historical performance.", - { - targetAsset: z.string().describe("Target asset (e.g., 'BTC', 'ETH')"), - hisRoiType: z.enum(["FIVE_YEAR", "THREE_YEAR", "ONE_YEAR", "SIX_MONTH", "THREE_MONTH", "SEVEN_DAY"]).describe("Historical ROI period"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await autoInvestClient.restAPI.getTargetAssetRoiData({ - targetAsset: params.targetAsset, - hisRoiType: params.hisRoiType, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `ROI data for ${params.targetAsset} (${params.hisRoiType}):\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get ROI data: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceAutoInvestGetTargetAssetRoiData", + "Get ROI (Return on Investment) data for auto-invest target assets. Shows historical performance.", + { + targetAsset: z.string().describe("Target asset (e.g., 'BTC', 'ETH')"), + hisRoiType: z + .enum(["FIVE_YEAR", "THREE_YEAR", "ONE_YEAR", "SIX_MONTH", "THREE_MONTH", "SEVEN_DAY"]) + .describe("Historical ROI period"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await autoInvestClient.restAPI.getTargetAssetRoiData({ + targetAsset: params.targetAsset, + hisRoiType: params.hisRoiType, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `ROI data for ${params.targetAsset} (${params.hisRoiType}):\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get ROI data: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-auto-invest/index.ts b/src/tools/binance-auto-invest/index.ts index 4e4afa14..e820a14d 100644 --- a/src/tools/binance-auto-invest/index.ts +++ b/src/tools/binance-auto-invest/index.ts @@ -1,30 +1,30 @@ // src/tools/binance-auto-invest/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" -import { registerBinanceAutoInvestGetTargetAssetList } from "./getTargetAssetList.js"; -import { registerBinanceAutoInvestGetSourceAssetList } from "./getSourceAssetList.js"; -import { registerBinanceAutoInvestGetTargetAssetROI } from "./getTargetAssetROI.js"; -import { registerBinanceAutoInvestGetPlanList } from "./getPlanList.js"; -import { registerBinanceAutoInvestGetOneTimePlans } from "./getOneTimePlans.js"; -import { registerBinanceAutoInvestCreatePlan } from "./createPlan.js"; -import { registerBinanceAutoInvestEditPlan } from "./editPlan.js"; -import { registerBinanceAutoInvestChangePlanStatus } from "./changePlanStatus.js"; -import { registerBinanceAutoInvestGetIndexLinkedPlanPositionList } from "./getIndexLinkedPlanPositionList.js"; -import { registerBinanceAutoInvestGetIndexLinkedPlanRebalanceHistory } from "./getIndexLinkedPlanRebalanceHistory.js"; -import { registerBinanceAutoInvestGetSubscriptionHistory } from "./getSubscriptionHistory.js"; -import { registerBinanceAutoInvestRedeemIndexLinkedPlan } from "./redeemIndexLinkedPlan.js"; +import { registerBinanceAutoInvestChangePlanStatus } from "./changePlanStatus.js" +import { registerBinanceAutoInvestCreatePlan } from "./createPlan.js" +import { registerBinanceAutoInvestEditPlan } from "./editPlan.js" +import { registerBinanceAutoInvestGetIndexLinkedPlanPositionList } from "./getIndexLinkedPlanPositionList.js" +import { registerBinanceAutoInvestGetIndexLinkedPlanRebalanceHistory } from "./getIndexLinkedPlanRebalanceHistory.js" +import { registerBinanceAutoInvestGetOneTimePlans } from "./getOneTimePlans.js" +import { registerBinanceAutoInvestGetPlanList } from "./getPlanList.js" +import { registerBinanceAutoInvestGetSourceAssetList } from "./getSourceAssetList.js" +import { registerBinanceAutoInvestGetSubscriptionHistory } from "./getSubscriptionHistory.js" +import { registerBinanceAutoInvestGetTargetAssetList } from "./getTargetAssetList.js" +import { registerBinanceAutoInvestGetTargetAssetROI } from "./getTargetAssetROI.js" +import { registerBinanceAutoInvestRedeemIndexLinkedPlan } from "./redeemIndexLinkedPlan.js" export function registerBinanceAutoInvestTools(server: McpServer) { - registerBinanceAutoInvestGetTargetAssetList(server); - registerBinanceAutoInvestGetSourceAssetList(server); - registerBinanceAutoInvestGetTargetAssetROI(server); - registerBinanceAutoInvestGetPlanList(server); - registerBinanceAutoInvestGetOneTimePlans(server); - registerBinanceAutoInvestCreatePlan(server); - registerBinanceAutoInvestEditPlan(server); - registerBinanceAutoInvestChangePlanStatus(server); - registerBinanceAutoInvestGetIndexLinkedPlanPositionList(server); - registerBinanceAutoInvestGetIndexLinkedPlanRebalanceHistory(server); - registerBinanceAutoInvestGetSubscriptionHistory(server); - registerBinanceAutoInvestRedeemIndexLinkedPlan(server); + registerBinanceAutoInvestGetTargetAssetList(server) + registerBinanceAutoInvestGetSourceAssetList(server) + registerBinanceAutoInvestGetTargetAssetROI(server) + registerBinanceAutoInvestGetPlanList(server) + registerBinanceAutoInvestGetOneTimePlans(server) + registerBinanceAutoInvestCreatePlan(server) + registerBinanceAutoInvestEditPlan(server) + registerBinanceAutoInvestChangePlanStatus(server) + registerBinanceAutoInvestGetIndexLinkedPlanPositionList(server) + registerBinanceAutoInvestGetIndexLinkedPlanRebalanceHistory(server) + registerBinanceAutoInvestGetSubscriptionHistory(server) + registerBinanceAutoInvestRedeemIndexLinkedPlan(server) } diff --git a/src/tools/binance-auto-invest/oneTimeTransaction.ts b/src/tools/binance-auto-invest/oneTimeTransaction.ts index 34515e33..cdcf7388 100644 --- a/src/tools/binance-auto-invest/oneTimeTransaction.ts +++ b/src/tools/binance-auto-invest/oneTimeTransaction.ts @@ -5,58 +5,72 @@ * @license Apache-2.0 */ // src/tools/binance-auto-invest/oneTimeTransaction.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { autoInvestClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerBinanceAutoInvestOneTimeTransaction(server: McpServer) { - server.tool( - "BinanceAutoInvestOneTimeTransaction", - "Execute a one-time auto-invest purchase. Buy crypto instantly without creating a recurring plan.", - { - sourceType: z.enum(["MAIN_SITE", "TR"]).describe("Source type"), - subscriptionAmount: z.string().describe("Amount to invest in source asset"), - sourceAsset: z.string().describe("Source asset (e.g., 'USDT')"), - flexibleAllowedToUse: z.boolean().optional().describe("Allow using Flexible Savings balance"), - planId: z.number().int().optional().describe("Plan ID if investing in existing plan"), - indexId: z.number().int().optional().describe("Index ID for index portfolio"), - details: z.array(z.object({ - targetAsset: z.string().describe("Target asset to purchase"), - percentage: z.number().min(0).max(100).describe("Allocation percentage") - })).optional().describe("Target assets and allocations (for ad-hoc purchase)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await autoInvestClient.restAPI.oneTimeTransaction({ - sourceType: params.sourceType, - subscriptionAmount: params.subscriptionAmount, - sourceAsset: params.sourceAsset, - ...(params.flexibleAllowedToUse !== undefined && { flexibleAllowedToUse: params.flexibleAllowedToUse }), - ...(params.planId && { planId: params.planId }), - ...(params.indexId && { indexId: params.indexId }), - ...(params.details && { details: JSON.stringify(params.details) }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ One-time investment executed!\n\nTransaction ID: ${data.transactionId || 'N/A'}\nAmount: ${params.subscriptionAmount} ${params.sourceAsset}\n\nDetails:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to execute one-time transaction: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceAutoInvestOneTimeTransaction", + "Execute a one-time auto-invest purchase. Buy crypto instantly without creating a recurring plan.", + { + sourceType: z.enum(["MAIN_SITE", "TR"]).describe("Source type"), + subscriptionAmount: z.string().describe("Amount to invest in source asset"), + sourceAsset: z.string().describe("Source asset (e.g., 'USDT')"), + flexibleAllowedToUse: z.boolean().optional().describe("Allow using Flexible Savings balance"), + planId: z.number().int().optional().describe("Plan ID if investing in existing plan"), + indexId: z.number().int().optional().describe("Index ID for index portfolio"), + details: z + .array( + z.object({ + targetAsset: z.string().describe("Target asset to purchase"), + percentage: z.number().min(0).max(100).describe("Allocation percentage"), + }), + ) + .optional() + .describe("Target assets and allocations (for ad-hoc purchase)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await autoInvestClient.restAPI.oneTimeTransaction({ + sourceType: params.sourceType, + subscriptionAmount: params.subscriptionAmount, + sourceAsset: params.sourceAsset, + ...(params.flexibleAllowedToUse !== undefined && { + flexibleAllowedToUse: params.flexibleAllowedToUse, + }), + ...(params.planId && { planId: params.planId }), + ...(params.indexId && { indexId: params.indexId }), + ...(params.details && { details: JSON.stringify(params.details) }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ One-time investment executed!\n\nTransaction ID: ${data.transactionId || "N/A"}\nAmount: ${params.subscriptionAmount} ${params.sourceAsset}\n\nDetails:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to execute one-time transaction: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-auto-invest/rebalanceHistory.ts b/src/tools/binance-auto-invest/rebalanceHistory.ts index 17a0ef15..4ff104c5 100644 --- a/src/tools/binance-auto-invest/rebalanceHistory.ts +++ b/src/tools/binance-auto-invest/rebalanceHistory.ts @@ -5,46 +5,51 @@ * @license Apache-2.0 */ // src/tools/binance-auto-invest/rebalanceHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { autoInvestClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerBinanceAutoInvestRebalanceHistory(server: McpServer) { - server.tool( - "BinanceAutoInvestRebalanceHistory", - "Get rebalance history for portfolio/index plans. Shows when and how allocations were rebalanced.", - { - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - size: z.number().int().max(100).optional().describe("Number of results. Default 10, max 100"), - current: z.number().int().optional().describe("Current page. Default 1"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await autoInvestClient.restAPI.getRebalanceHistory({ - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.size && { size: params.size }), - ...(params.current && { current: params.current }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `Rebalance history:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get rebalance history: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceAutoInvestRebalanceHistory", + "Get rebalance history for portfolio/index plans. Shows when and how allocations were rebalanced.", + { + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + size: z.number().int().max(100).optional().describe("Number of results. Default 10, max 100"), + current: z.number().int().optional().describe("Current page. Default 1"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await autoInvestClient.restAPI.getRebalanceHistory({ + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.size && { size: params.size }), + ...(params.current && { current: params.current }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Rebalance history:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get rebalance history: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-auto-invest/redeemIndexLinkedPlan.ts b/src/tools/binance-auto-invest/redeemIndexLinkedPlan.ts index 667ca7bf..3b666c27 100644 --- a/src/tools/binance-auto-invest/redeemIndexLinkedPlan.ts +++ b/src/tools/binance-auto-invest/redeemIndexLinkedPlan.ts @@ -1,41 +1,43 @@ // src/tools/binance-auto-invest/redeemIndexLinkedPlan.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerBinanceAutoInvestRedeemIndexLinkedPlan(server: McpServer) { - server.tool( - "BinanceAutoInvestRedeemIndexLinkedPlan", - "Redeem index linked plan for auto-invest.", - { - indexId: z.number().describe("Index ID"), - redemptionPercentage: z.number().describe("Redemption percentage (0-100)"), - requestId: z.string().optional().describe("Request ID for idempotency") - }, - async ({ indexId, redemptionPercentage, requestId }) => { - try { - const params: any = { indexId, redemptionPercentage }; - if (requestId) params.requestId = requestId; - - const response = await autoInvestClient.restAPI.indexLinkedPlanRedemption(params); - const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Index linked plan redeemed successfully. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to redeem index linked plan: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceAutoInvestRedeemIndexLinkedPlan", + "Redeem index linked plan for auto-invest.", + { + indexId: z.number().describe("Index ID"), + redemptionPercentage: z.number().describe("Redemption percentage (0-100)"), + requestId: z.string().optional().describe("Request ID for idempotency"), + }, + async ({ indexId, redemptionPercentage, requestId }) => { + try { + const params: any = { indexId, redemptionPercentage } + if (requestId) params.requestId = requestId + + const response = await autoInvestClient.restAPI.indexLinkedPlanRedemption(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Index linked plan redeemed successfully. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to redeem index linked plan: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-auto-invest/redemption.ts b/src/tools/binance-auto-invest/redemption.ts index 15a7824a..90cf0ac4 100644 --- a/src/tools/binance-auto-invest/redemption.ts +++ b/src/tools/binance-auto-invest/redemption.ts @@ -5,45 +5,56 @@ * @license Apache-2.0 */ // src/tools/binance-auto-invest/redemption.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { autoInvestClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { autoInvestClient } from "../../config/binanceClient.js" export function registerBinanceAutoInvestRedemption(server: McpServer) { - server.tool( - "BinanceAutoInvestRedemption", - "Redeem (sell) holdings from an auto-invest index-linked plan.", - { - indexId: z.number().int().describe("Index ID to redeem from"), - redemptionPercentage: z.number().min(0).max(100).describe("Percentage of holdings to redeem (0-100)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await autoInvestClient.restAPI.redemption({ - indexId: params.indexId, - redemptionPercentage: params.redemptionPercentage, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Redemption executed!\n\nRedeemed ${params.redemptionPercentage}% from index ${params.indexId}\n\nDetails:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to redeem: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceAutoInvestRedemption", + "Redeem (sell) holdings from an auto-invest index-linked plan.", + { + indexId: z.number().int().describe("Index ID to redeem from"), + redemptionPercentage: z + .number() + .min(0) + .max(100) + .describe("Percentage of holdings to redeem (0-100)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await autoInvestClient.restAPI.redemption({ + indexId: params.indexId, + redemptionPercentage: params.redemptionPercentage, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Redemption executed!\n\nRedeemed ${params.redemptionPercentage}% from index ${params.indexId}\n\nDetails:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to redeem: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-c2c/C2C/getC2CTradeHistory.ts b/src/tools/binance-c2c/C2C/getC2CTradeHistory.ts index 1570b7ad..d3fac5ea 100644 --- a/src/tools/binance-c2c/C2C/getC2CTradeHistory.ts +++ b/src/tools/binance-c2c/C2C/getC2CTradeHistory.ts @@ -1,48 +1,51 @@ // src/tools/binance-c2c/getC2CTradeHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { c2cClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { c2cClient } from "../../../config/binanceClient.js" export function registerBinanceGetC2CTradeHistory(server: McpServer) { - server.tool( - "BinanceGetC2CTradeHistory", - "Allows the user to retrieve their own past C2C trades, including details such as asset type, trade direction (BUY/SELL), fiat currency used, trade status, and more.", - { - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - page: z.number().int().optional().describe("Page number, default is 1"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await c2cClient.restAPI.getC2CTradeHistory({ - ...(params.startTime !== undefined && { startTime: params.startTime }), - ...(params.endTime !== undefined && { endTime: params.endTime }), - ...(params.page !== undefined && { page: params.page }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); + server.tool( + "BinanceGetC2CTradeHistory", + "Allows the user to retrieve their own past C2C trades, including details such as asset type, trade direction (BUY/SELL), fiat currency used, trade status, and more.", + { + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + page: z.number().int().optional().describe("Page number, default is 1"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await c2cClient.restAPI.getC2CTradeHistory({ + ...(params.startTime !== undefined && { startTime: params.startTime }), + ...(params.endTime !== undefined && { endTime: params.endTime }), + ...(params.page !== undefined && { page: params.page }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved the past C2C trades. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved the past C2C trades. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve users past C2C trades: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve users past C2C trades: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-c2c/index.ts b/src/tools/binance-c2c/index.ts index 782b9c95..40576490 100644 --- a/src/tools/binance-c2c/index.ts +++ b/src/tools/binance-c2c/index.ts @@ -1,7 +1,8 @@ // src/tools/binance-c2c/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetC2CTradeHistory } from "./C2C/getC2CTradeHistory.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceGetC2CTradeHistory } from "./C2C/getC2CTradeHistory.js" export function registerBinanceC2CTradeHistoryTools(server: McpServer) { - registerBinanceGetC2CTradeHistory(server); + registerBinanceGetC2CTradeHistory(server) } diff --git a/src/tools/binance-convert/index.ts b/src/tools/binance-convert/index.ts index 2ad2bf25..df48a488 100644 --- a/src/tools/binance-convert/index.ts +++ b/src/tools/binance-convert/index.ts @@ -1,12 +1,13 @@ // src/tools/binance-convert/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceConvertTradeTools } from "./trade-api/index.js"; -import { registerBinanceConvertMarketDataTools } from "./market-data-api/index.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceConvertMarketDataTools } from "./market-data-api/index.js" +import { registerBinanceConvertTradeTools } from "./trade-api/index.js" export function registerBinanceConvertTools(server: McpServer) { - // Register tools for accessing market data from Binance Convert - registerBinanceConvertMarketDataTools(server); + // Register tools for accessing market data from Binance Convert + registerBinanceConvertMarketDataTools(server) - // Register tools for performing trades on Binance Convert - registerBinanceConvertTradeTools(server); + // Register tools for performing trades on Binance Convert + registerBinanceConvertTradeTools(server) } diff --git a/src/tools/binance-convert/market-data-api/index.ts b/src/tools/binance-convert/market-data-api/index.ts index 923f432b..c9bcf504 100644 --- a/src/tools/binance-convert/market-data-api/index.ts +++ b/src/tools/binance-convert/market-data-api/index.ts @@ -1,12 +1,13 @@ // src/tools/binance-convert/market-data-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceConvertQueryOrderQuantityPrecisionPerAsset } from "./queryOrderQuantityPrecisionPerAsset.js"; -import { registerBinanceConvertGetListAllConvertPairs } from "./listAllConvertPairs.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceConvertGetListAllConvertPairs } from "./listAllConvertPairs.js" +import { registerBinanceConvertQueryOrderQuantityPrecisionPerAsset } from "./queryOrderQuantityPrecisionPerAsset.js" export function registerBinanceConvertMarketDataTools(server: McpServer) { - // Register the route to get a list of all supported convert trading pairs - registerBinanceConvertGetListAllConvertPairs(server); + // Register the route to get a list of all supported convert trading pairs + registerBinanceConvertGetListAllConvertPairs(server) - // Register the route to get quantity precision details for each asset - registerBinanceConvertQueryOrderQuantityPrecisionPerAsset(server); + // Register the route to get quantity precision details for each asset + registerBinanceConvertQueryOrderQuantityPrecisionPerAsset(server) } diff --git a/src/tools/binance-convert/market-data-api/listAllConvertPairs.ts b/src/tools/binance-convert/market-data-api/listAllConvertPairs.ts index 6f130319..845a72b6 100644 --- a/src/tools/binance-convert/market-data-api/listAllConvertPairs.ts +++ b/src/tools/binance-convert/market-data-api/listAllConvertPairs.ts @@ -1,45 +1,48 @@ // src/tools/binance-convert/market-data-api/listAllConvertPairs.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { convertClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { convertClient } from "../../../config/binanceClient.js" export function registerBinanceConvertGetListAllConvertPairs(server: McpServer) { - server.tool( - "BinanceConvertGetListAllConvertPairs", - "Query available conversion pairs (like BTC to USDT), and shows the minimum and maximum allowed amounts for both the source and destination tokens.", - { - fromAsset: z.string().optional().describe("User spends coin"), - toAsset: z.string().optional().describe("User receives coin") - }, - async (params) => { - try { - const response = await convertClient.restAPI.listAllConvertPairs({ - ...(params.fromAsset && { fromAsset: params.fromAsset }), - ...(params.toAsset && { toAsset: params.toAsset }) - }); + server.tool( + "BinanceConvertGetListAllConvertPairs", + "Query available conversion pairs (like BTC to USDT), and shows the minimum and maximum allowed amounts for both the source and destination tokens.", + { + fromAsset: z.string().optional().describe("User spends coin"), + toAsset: z.string().optional().describe("User receives coin"), + }, + async (params) => { + try { + const response = await convertClient.restAPI.listAllConvertPairs({ + ...(params.fromAsset && { fromAsset: params.fromAsset }), + ...(params.toAsset && { toAsset: params.toAsset }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully queried available conversion pairs. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully queried available conversion pairs. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to query available conversion pairs: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to query available conversion pairs: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-convert/market-data-api/queryOrderQuantityPrecisionPerAsset.ts b/src/tools/binance-convert/market-data-api/queryOrderQuantityPrecisionPerAsset.ts index 27c59705..dc097eb2 100644 --- a/src/tools/binance-convert/market-data-api/queryOrderQuantityPrecisionPerAsset.ts +++ b/src/tools/binance-convert/market-data-api/queryOrderQuantityPrecisionPerAsset.ts @@ -1,50 +1,53 @@ // src/tools/binance-convert/market-data-api/queryOrderQuantityPrecisionPerAsset.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { convertClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { convertClient } from "../../../config/binanceClient.js" export function registerBinanceConvertQueryOrderQuantityPrecisionPerAsset(server: McpServer) { - server.tool( - "BinanceConvertQueryOrderQuantityPrecisionPerAsset", - "Retrieve decimal precision (fraction) information for each supported asset in the Convert feature.", - { - recvWindow: z - .number() - .int() - .max(60000, "recvWindow cannot be greater than 60000") - .optional() - .describe("The value cannot be greater than 60000") - }, - async (params) => { - try { - const response = await convertClient.restAPI.queryOrderQuantityPrecisionPerAsset({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceConvertQueryOrderQuantityPrecisionPerAsset", + "Retrieve decimal precision (fraction) information for each supported asset in the Convert feature.", + { + recvWindow: z + .number() + .int() + .max(60000, "recvWindow cannot be greater than 60000") + .optional() + .describe("The value cannot be greater than 60000"), + }, + async (params) => { + try { + const response = await convertClient.restAPI.queryOrderQuantityPrecisionPerAsset({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved decimal precision information for each supported asset. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved decimal precision information for each supported asset. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve decimal precision (fraction) information: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve decimal precision (fraction) information: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-convert/trade-api/acceptQuote.ts b/src/tools/binance-convert/trade-api/acceptQuote.ts index 50189a97..b7ff1b5a 100644 --- a/src/tools/binance-convert/trade-api/acceptQuote.ts +++ b/src/tools/binance-convert/trade-api/acceptQuote.ts @@ -1,49 +1,52 @@ // src/tools/binance-convert/trade-api/acceptQuote.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { convertClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { convertClient } from "../../../config/binanceClient.js" export function registerBinanceConvertAcceptQuote(server: McpServer) { - server.tool( - "BinanceConvertAcceptQuote", - "The API confirms and executes a token conversion using a previously received quote ID.", - { - quoteId: z.string().describe("Quote ID"), - recvWindow: z - .number() - .int() - .max(60000, "recvWindow cannot be greater than 60000") - .optional() - .describe("The value cannot be greater than 60000") - }, - async (params) => { - try { - const response = await convertClient.restAPI.acceptQuote({ - quoteId: params.quoteId, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); + server.tool( + "BinanceConvertAcceptQuote", + "The API confirms and executes a token conversion using a previously received quote ID.", + { + quoteId: z.string().describe("Quote ID"), + recvWindow: z + .number() + .int() + .max(60000, "recvWindow cannot be greater than 60000") + .optional() + .describe("The value cannot be greater than 60000"), + }, + async (params) => { + try { + const response = await convertClient.restAPI.acceptQuote({ + quoteId: params.quoteId, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully executed the token conversion. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully executed the token conversion. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to execute a token conversion : ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to execute a token conversion : ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-convert/trade-api/cancelLimitOrder.ts b/src/tools/binance-convert/trade-api/cancelLimitOrder.ts index 0e960cc2..1a097a79 100644 --- a/src/tools/binance-convert/trade-api/cancelLimitOrder.ts +++ b/src/tools/binance-convert/trade-api/cancelLimitOrder.ts @@ -1,49 +1,52 @@ // src/tools/binance-convert/trade-api/cancelLimitOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { convertClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { convertClient } from "../../../config/binanceClient.js" export function registerBinanceConvertCancelLimitOrder(server: McpServer) { - server.tool( - "BinanceConvertCancelLimitOrder", - "Cancels a previously placed limit order using the orderId and returns the cancellation status along with the orderId.", - { - orderId: z.number().int().describe("The orderId from placeOrder API"), - recvWindow: z - .number() - .int() - .max(60000, "recvWindow cannot be greater than 60000") - .optional() - .describe("Time window for request validity") - }, - async (params) => { - try { - const response = await convertClient.restAPI.cancelLimitOrder({ - orderId: params.orderId, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); + server.tool( + "BinanceConvertCancelLimitOrder", + "Cancels a previously placed limit order using the orderId and returns the cancellation status along with the orderId.", + { + orderId: z.number().int().describe("The orderId from placeOrder API"), + recvWindow: z + .number() + .int() + .max(60000, "recvWindow cannot be greater than 60000") + .optional() + .describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await convertClient.restAPI.cancelLimitOrder({ + orderId: params.orderId, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Canceled the placed limit order. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Canceled the placed limit order. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to placed limit order: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to placed limit order: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-convert/trade-api/getConvertTradeHistory.ts b/src/tools/binance-convert/trade-api/getConvertTradeHistory.ts index 6da43a22..458bba40 100644 --- a/src/tools/binance-convert/trade-api/getConvertTradeHistory.ts +++ b/src/tools/binance-convert/trade-api/getConvertTradeHistory.ts @@ -1,56 +1,59 @@ // src/tools/binance-convert/trade-api/getConvertTradeHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { convertClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { convertClient } from "../../../config/binanceClient.js" export function registerBinanceGetConvertTradeHistory(server: McpServer) { - server.tool( - "BinanceGetConvertTradeHistory", - "The API retrieves your token conversion trade history within a specified time range, with support for pagination using the limit parameter (up to 1000 records).", - { - startTime: z.number().int().describe("Start time in milliseconds"), - endTime: z.number().int().describe("End time in milliseconds"), - limit: z - .number() - .int() - .max(1000, "Limit cannot be greater than 1000") - .optional() - .describe("Default 100, Max 1000"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await convertClient.restAPI.getConvertTradeHistory({ - startTime: params.startTime, - endTime: params.endTime, - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetConvertTradeHistory", + "The API retrieves your token conversion trade history within a specified time range, with support for pagination using the limit parameter (up to 1000 records).", + { + startTime: z.number().int().describe("Start time in milliseconds"), + endTime: z.number().int().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(1000, "Limit cannot be greater than 1000") + .optional() + .describe("Default 100, Max 1000"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await convertClient.restAPI.getConvertTradeHistory({ + startTime: params.startTime, + endTime: params.endTime, + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved your token conversion trade history. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved your token conversion trade history. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve your token conversion: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve your token conversion: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-convert/trade-api/index.ts b/src/tools/binance-convert/trade-api/index.ts index a7efa11e..3b5e9db9 100644 --- a/src/tools/binance-convert/trade-api/index.ts +++ b/src/tools/binance-convert/trade-api/index.ts @@ -1,32 +1,33 @@ // src/tools/binance-convert/trade-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceConvertAcceptQuote } from "./acceptQuote.js"; -import { registerBinanceConvertCancelLimitOrder } from "./cancelLimitOrder.js"; -import { registerBinanceGetConvertTradeHistory } from "./getConvertTradeHistory.js"; -import { registerBinanceConvertOrderStatus } from "./orderStatus.js"; -import { registerBinanceConvertPlaceLimitOrder } from "./placeLimitOrder.js"; -import { registerBinanceConvertQueryLimitOpenOrders } from "./queryLimitOpenOrders.js"; -import { registerBinanceConvertSendQuoteRequest } from "./sendQuoteRequest.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceConvertAcceptQuote } from "./acceptQuote.js" +import { registerBinanceConvertCancelLimitOrder } from "./cancelLimitOrder.js" +import { registerBinanceGetConvertTradeHistory } from "./getConvertTradeHistory.js" +import { registerBinanceConvertOrderStatus } from "./orderStatus.js" +import { registerBinanceConvertPlaceLimitOrder } from "./placeLimitOrder.js" +import { registerBinanceConvertQueryLimitOpenOrders } from "./queryLimitOpenOrders.js" +import { registerBinanceConvertSendQuoteRequest } from "./sendQuoteRequest.js" export function registerBinanceConvertTradeTools(server: McpServer) { - // Register the route to accept a quote for a convert trade - registerBinanceConvertAcceptQuote(server); + // Register the route to accept a quote for a convert trade + registerBinanceConvertAcceptQuote(server) - // Register the route to cancel an existing convert limit order - registerBinanceConvertCancelLimitOrder(server); + // Register the route to cancel an existing convert limit order + registerBinanceConvertCancelLimitOrder(server) - // Register the route to get the convert trade history - registerBinanceGetConvertTradeHistory(server); + // Register the route to get the convert trade history + registerBinanceGetConvertTradeHistory(server) - // Register the route to check the status of a convert order - registerBinanceConvertOrderStatus(server); + // Register the route to check the status of a convert order + registerBinanceConvertOrderStatus(server) - // Register the route to place a new convert limit order - registerBinanceConvertPlaceLimitOrder(server); + // Register the route to place a new convert limit order + registerBinanceConvertPlaceLimitOrder(server) - // Register the route to query currently open convert limit orders - registerBinanceConvertQueryLimitOpenOrders(server); + // Register the route to query currently open convert limit orders + registerBinanceConvertQueryLimitOpenOrders(server) - // Register the route to send a quote request for a convert trade - registerBinanceConvertSendQuoteRequest(server); + // Register the route to send a quote request for a convert trade + registerBinanceConvertSendQuoteRequest(server) } diff --git a/src/tools/binance-convert/trade-api/orderStatus.ts b/src/tools/binance-convert/trade-api/orderStatus.ts index 72d4b323..2a6521a6 100644 --- a/src/tools/binance-convert/trade-api/orderStatus.ts +++ b/src/tools/binance-convert/trade-api/orderStatus.ts @@ -1,47 +1,50 @@ // src/tools/binance-convert/trade-api/orderStatus.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { convertClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { convertClient } from "../../../config/binanceClient.js" export function registerBinanceConvertOrderStatus(server: McpServer) { - server.tool( - "BinanceConvertOrderStatus", - "The API checks the status of a token conversion order using either the orderId or quoteId, and returns details like conversion status, assets involved, amounts, exchange rate, and order creation time.", - { - orderId: z.string().optional().describe("Order ID (either this or quoteId is required)"), - quoteId: z.string().optional().describe("Quote ID (either this or orderId is required)") - }, - async (params) => { - try { - const response = await convertClient.restAPI.orderStatus({ - ...(params.orderId && { orderId: params.orderId }), - ...(params.quoteId && { quoteId: params.quoteId }) - }); + server.tool( + "BinanceConvertOrderStatus", + "The API checks the status of a token conversion order using either the orderId or quoteId, and returns details like conversion status, assets involved, amounts, exchange rate, and order creation time.", + { + orderId: z.string().optional().describe("Order ID (either this or quoteId is required)"), + quoteId: z.string().optional().describe("Quote ID (either this or orderId is required)"), + }, + async (params) => { + try { + const response = await convertClient.restAPI.orderStatus({ + ...(params.orderId && { orderId: params.orderId }), + ...(params.quoteId && { quoteId: params.quoteId }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully get the status of a token conversion . Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully get the status of a token conversion . Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to check the status: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to check the status: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-convert/trade-api/placeLimitOrder.ts b/src/tools/binance-convert/trade-api/placeLimitOrder.ts index 42fb17f1..775c1b66 100644 --- a/src/tools/binance-convert/trade-api/placeLimitOrder.ts +++ b/src/tools/binance-convert/trade-api/placeLimitOrder.ts @@ -1,77 +1,83 @@ // src/tools/binance-convert/trade-api/placeLimitOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { convertClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { convertClient } from "../../../config/binanceClient.js" export function registerBinanceConvertPlaceLimitOrder(server: McpServer) { - server.tool( - "BinanceConvertPlaceLimitOrder", - "Places a limit order to convert between two tokens at a specified price, using either base or quote amount, with options for wallet type and order expiry.", - { - baseAsset: z.string().describe("Base asset (from `fromIsBase` in /exchangeInfo API)"), - quoteAsset: z.string().describe("Quote asset"), - limitPrice: z.number().positive().describe("Symbol limit price (from baseAsset to quoteAsset)"), - baseAmount: z - .number() - .positive() - .optional() - .describe("Base asset amount (either this or quoteAmount is required)"), - quoteAmount: z - .number() - .positive() - .optional() - .describe("Quote asset amount (either this or baseAmount is required)"), - side: z.enum(["BUY", "SELL"]).describe("BUY or SELL"), - walletType: z - .enum(["SPOT", "FUNDING", "SPOT_FUNDING"]) - .optional() - .describe("Type of assets used: SPOT, FUNDING, or SPOT_FUNDING. Default is SPOT"), - expiredType: z - .enum(["1_D", "3_D", "7_D", "30_D"]) - .describe("Expiration type: 1_D, 3_D, 7_D, or 30_D (D = days)"), - recvWindow: z - .number() - .int() - .max(60000, "recvWindow cannot be greater than 60000") - .optional() - .describe("Time window for request validity") - }, - async (params) => { - try { - const response = await convertClient.restAPI.placeLimitOrder({ - baseAsset: params.baseAsset, - quoteAsset: params.quoteAsset, - limitPrice: params.limitPrice, - side: params.side, - expiredType: params.expiredType, - ...(params.baseAmount !== undefined && { baseAmount: params.baseAmount }), - ...(params.quoteAmount !== undefined && { quoteAmount: params.quoteAmount }), - ...(params.walletType && { walletType: params.walletType }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceConvertPlaceLimitOrder", + "Places a limit order to convert between two tokens at a specified price, using either base or quote amount, with options for wallet type and order expiry.", + { + baseAsset: z.string().describe("Base asset (from `fromIsBase` in /exchangeInfo API)"), + quoteAsset: z.string().describe("Quote asset"), + limitPrice: z + .number() + .positive() + .describe("Symbol limit price (from baseAsset to quoteAsset)"), + baseAmount: z + .number() + .positive() + .optional() + .describe("Base asset amount (either this or quoteAmount is required)"), + quoteAmount: z + .number() + .positive() + .optional() + .describe("Quote asset amount (either this or baseAmount is required)"), + side: z.enum(["BUY", "SELL"]).describe("BUY or SELL"), + walletType: z + .enum(["SPOT", "FUNDING", "SPOT_FUNDING"]) + .optional() + .describe("Type of assets used: SPOT, FUNDING, or SPOT_FUNDING. Default is SPOT"), + expiredType: z + .enum(["1_D", "3_D", "7_D", "30_D"]) + .describe("Expiration type: 1_D, 3_D, 7_D, or 30_D (D = days)"), + recvWindow: z + .number() + .int() + .max(60000, "recvWindow cannot be greater than 60000") + .optional() + .describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await convertClient.restAPI.placeLimitOrder({ + baseAsset: params.baseAsset, + quoteAsset: params.quoteAsset, + limitPrice: params.limitPrice, + side: params.side, + expiredType: params.expiredType, + ...(params.baseAmount !== undefined && { baseAmount: params.baseAmount }), + ...(params.quoteAmount !== undefined && { quoteAmount: params.quoteAmount }), + ...(params.walletType && { walletType: params.walletType }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully placed the limit order. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully placed the limit order. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to places a limit order: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to places a limit order: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-convert/trade-api/queryLimitOpenOrders.ts b/src/tools/binance-convert/trade-api/queryLimitOpenOrders.ts index c397279c..84e405af 100644 --- a/src/tools/binance-convert/trade-api/queryLimitOpenOrders.ts +++ b/src/tools/binance-convert/trade-api/queryLimitOpenOrders.ts @@ -1,50 +1,53 @@ // src/tools/binance-convert/trade-api/queryLimitOpenOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { convertClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { convertClient } from "../../../config/binanceClient.js" export function registerBinanceConvertQueryLimitOpenOrders(server: McpServer) { - server.tool( - "BinanceConvertQueryLimitOpenOrders", - "Retrieves all your open limit orders for token conversions, showing details like assets, amounts, exchange rate, order status, and expiration time.", - { - recvWindow: z - .number() - .int() - .max(60000, "recvWindow must not be greater than 60000") - .optional() - .describe("This value must not exceed 60000") - }, - async (params) => { - try { - const response = await convertClient.restAPI.queryLimitOpenOrders({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceConvertQueryLimitOpenOrders", + "Retrieves all your open limit orders for token conversions, showing details like assets, amounts, exchange rate, order status, and expiration time.", + { + recvWindow: z + .number() + .int() + .max(60000, "recvWindow must not be greater than 60000") + .optional() + .describe("This value must not exceed 60000"), + }, + async (params) => { + try { + const response = await convertClient.restAPI.queryLimitOpenOrders({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved all the open limit orders for token conversions. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved all the open limit orders for token conversions. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve all your open limit orders : ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve all your open limit orders : ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-convert/trade-api/sendQuoteRequest.ts b/src/tools/binance-convert/trade-api/sendQuoteRequest.ts index d3594f0c..8b7c40c7 100644 --- a/src/tools/binance-convert/trade-api/sendQuoteRequest.ts +++ b/src/tools/binance-convert/trade-api/sendQuoteRequest.ts @@ -1,65 +1,75 @@ // src/tools/binance-convert/trade-api/sendQuoteRequest.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { convertClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { convertClient } from "../../../config/binanceClient.js" export function registerBinanceConvertSendQuoteRequest(server: McpServer) { - server.tool( - "BinanceConvertSendQuoteRequest", - "Get a real-time quote to convert one token to another, including rate and amount, if you have enough funds.", - { - fromAsset: z.string().describe("Asset you will spend (required)"), - toAsset: z.string().describe("Asset you will receive (required)"), - fromAmount: z.number().positive().optional().describe("Amount to be debited after conversion"), - toAmount: z.number().positive().optional().describe("Amount to be credited after conversion"), - walletType: z.enum(["SPOT", "FUNDING"]).optional().describe("SPOT or FUNDING. Default is SPOT"), - validTime: z - .enum(["10s", "30s", "1m"]) - .optional() - .describe("Quote validity duration: 10s, 30s, 1m; default is 10s"), - recvWindow: z - .number() - .int() - .max(60000, "recvWindow cannot be greater than 60000") - .optional() - .describe("The value cannot be greater than 60000") - }, - async (params) => { - try { - const response = await convertClient.restAPI.sendQuoteRequest({ - fromAsset: params.fromAsset, - toAsset: params.toAsset, - ...(params.fromAmount && { fromAmount: params.fromAmount }), - ...(params.toAmount && { toAmount: params.toAmount }), - ...(params.walletType && { walletType: params.walletType }), - ...(params.validTime && { validTime: params.validTime }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceConvertSendQuoteRequest", + "Get a real-time quote to convert one token to another, including rate and amount, if you have enough funds.", + { + fromAsset: z.string().describe("Asset you will spend (required)"), + toAsset: z.string().describe("Asset you will receive (required)"), + fromAmount: z + .number() + .positive() + .optional() + .describe("Amount to be debited after conversion"), + toAmount: z.number().positive().optional().describe("Amount to be credited after conversion"), + walletType: z + .enum(["SPOT", "FUNDING"]) + .optional() + .describe("SPOT or FUNDING. Default is SPOT"), + validTime: z + .enum(["10s", "30s", "1m"]) + .optional() + .describe("Quote validity duration: 10s, 30s, 1m; default is 10s"), + recvWindow: z + .number() + .int() + .max(60000, "recvWindow cannot be greater than 60000") + .optional() + .describe("The value cannot be greater than 60000"), + }, + async (params) => { + try { + const response = await convertClient.restAPI.sendQuoteRequest({ + fromAsset: params.fromAsset, + toAsset: params.toAsset, + ...(params.fromAmount && { fromAmount: params.fromAmount }), + ...(params.toAmount && { toAmount: params.toAmount }), + ...(params.walletType && { walletType: params.walletType }), + ...(params.validTime && { validTime: params.validTime }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved real-time quote to convert one token to another. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved real-time quote to convert one token to another. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to get a real-time quote to convert: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to get a real-time quote to convert: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/followTrader.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/followTrader.ts index f219f523..87894903 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/followTrader.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/followTrader.ts @@ -1,52 +1,65 @@ // src/tools/binance-copy-trading/FutureCopyTrading-api/followTrader.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { copyTradingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { copyTradingClient } from "../../../config/binanceClient.js" export function registerBinanceCopyTradingFollow(server: McpServer) { - server.tool( - "BinanceCopyTradingFollow", - "Start following a lead trader in copy trading. ⚠️ WARNING: This will automatically copy their trades. You are trusting another trader with your capital. Past performance does not guarantee future results.", - { - portfolioId: z.string() - .describe("Lead trader's portfolio ID to follow"), - copyRatio: z.number().min(0.1).max(10).optional() - .describe("Copy ratio multiplier (0.1-10x, default 1x)"), - stopLossRatio: z.number().min(0.01).max(1).optional() - .describe("Stop loss ratio (e.g., 0.1 = 10% loss triggers stop)"), - takeProfitRatio: z.number().min(0.01).optional() - .describe("Take profit ratio (e.g., 0.5 = 50% profit triggers exit)"), - fixedAmount: z.string().optional() - .describe("Fixed amount per trade instead of ratio"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await copyTradingClient.restAPI.followLeadTrader({ - portfolioId: params.portfolioId, - ...(params.copyRatio && { copyRatio: params.copyRatio }), - ...(params.stopLossRatio && { stopLossRatio: params.stopLossRatio }), - ...(params.takeProfitRatio && { takeProfitRatio: params.takeProfitRatio }), - ...(params.fixedAmount && { fixedAmount: params.fixedAmount }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCopyTradingFollow", + "Start following a lead trader in copy trading. ⚠️ WARNING: This will automatically copy their trades. You are trusting another trader with your capital. Past performance does not guarantee future results.", + { + portfolioId: z.string().describe("Lead trader's portfolio ID to follow"), + copyRatio: z + .number() + .min(0.1) + .max(10) + .optional() + .describe("Copy ratio multiplier (0.1-10x, default 1x)"), + stopLossRatio: z + .number() + .min(0.01) + .max(1) + .optional() + .describe("Stop loss ratio (e.g., 0.1 = 10% loss triggers stop)"), + takeProfitRatio: z + .number() + .min(0.01) + .optional() + .describe("Take profit ratio (e.g., 0.5 = 50% profit triggers exit)"), + fixedAmount: z.string().optional().describe("Fixed amount per trade instead of ratio"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await copyTradingClient.restAPI.followLeadTrader({ + portfolioId: params.portfolioId, + ...(params.copyRatio && { copyRatio: params.copyRatio }), + ...(params.stopLossRatio && { stopLossRatio: params.stopLossRatio }), + ...(params.takeProfitRatio && { takeProfitRatio: params.takeProfitRatio }), + ...(params.fixedAmount && { fixedAmount: params.fixedAmount }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Now following trader ${params.portfolioId}!\n\nCopy Ratio: ${params.copyRatio || 1}x\nStop Loss: ${params.stopLossRatio ? params.stopLossRatio * 100 + "%" : "Not set"}\nTake Profit: ${params.takeProfitRatio ? params.takeProfitRatio * 100 + "%" : "Not set"}\n\n⚠️ Monitor your positions regularly.\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `✅ Now following trader ${params.portfolioId}!\n\nCopy Ratio: ${params.copyRatio || 1}x\nStop Loss: ${params.stopLossRatio ? (params.stopLossRatio * 100) + '%' : 'Not set'}\nTake Profit: ${params.takeProfitRatio ? (params.takeProfitRatio * 100) + '%' : 'Not set'}\n\n⚠️ Monitor your positions regularly.\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to follow trader: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to follow trader: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyOrders.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyOrders.ts index 1e2c07fe..6a833546 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyOrders.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyOrders.ts @@ -1,55 +1,53 @@ // src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { copyTradingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { copyTradingClient } from "../../../config/binanceClient.js" export function registerBinanceCopyTradingGetOrders(server: McpServer) { - server.tool( - "BinanceCopyTradingGetOrders", - "Get copy trading orders. Shows orders that were placed as a result of following lead traders.", - { - portfolioId: z.string().optional() - .describe("Filter by specific lead trader portfolio ID"), - symbol: z.string().optional() - .describe("Filter by trading symbol"), - startTime: z.number().int().optional() - .describe("Start timestamp in ms"), - endTime: z.number().int().optional() - .describe("End timestamp in ms"), - pageNumber: z.number().int().min(1).optional() - .describe("Page number"), - pageSize: z.number().int().min(1).max(100).optional() - .describe("Results per page"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await copyTradingClient.restAPI.getCopyTradingOrders({ - ...(params.portfolioId && { portfolioId: params.portfolioId }), - ...(params.symbol && { symbol: params.symbol }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.pageNumber && { pageNumber: params.pageNumber }), - ...(params.pageSize && { pageSize: params.pageSize }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCopyTradingGetOrders", + "Get copy trading orders. Shows orders that were placed as a result of following lead traders.", + { + portfolioId: z.string().optional().describe("Filter by specific lead trader portfolio ID"), + symbol: z.string().optional().describe("Filter by trading symbol"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + pageNumber: z.number().int().min(1).optional().describe("Page number"), + pageSize: z.number().int().min(1).max(100).optional().describe("Results per page"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await copyTradingClient.restAPI.getCopyTradingOrders({ + ...(params.portfolioId && { portfolioId: params.portfolioId }), + ...(params.symbol && { symbol: params.symbol }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.pageNumber && { pageNumber: params.pageNumber }), + ...(params.pageSize && { pageSize: params.pageSize }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Copy Trading Orders:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Copy Trading Orders:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get copy orders: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to get copy orders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyPositions.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyPositions.ts index 0bfc1ca5..afed5f1f 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyPositions.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyPositions.ts @@ -1,43 +1,45 @@ // src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyPositions.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { copyTradingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { copyTradingClient } from "../../../config/binanceClient.js" export function registerBinanceCopyTradingGetPositions(server: McpServer) { - server.tool( - "BinanceCopyTradingGetPositions", - "Get current copy trading positions. Shows open positions from following lead traders.", - { - portfolioId: z.string().optional() - .describe("Filter by specific lead trader portfolio ID"), - symbol: z.string().optional() - .describe("Filter by trading symbol"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await copyTradingClient.restAPI.getCopyTradingPositions({ - ...(params.portfolioId && { portfolioId: params.portfolioId }), - ...(params.symbol && { symbol: params.symbol }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCopyTradingGetPositions", + "Get current copy trading positions. Shows open positions from following lead traders.", + { + portfolioId: z.string().optional().describe("Filter by specific lead trader portfolio ID"), + symbol: z.string().optional().describe("Filter by trading symbol"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await copyTradingClient.restAPI.getCopyTradingPositions({ + ...(params.portfolioId && { portfolioId: params.portfolioId }), + ...(params.symbol && { symbol: params.symbol }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Copy Trading Positions:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Copy Trading Positions:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get copy positions: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to get copy positions: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/getFollowingTraders.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/getFollowingTraders.ts index bd9504a2..710d4226 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/getFollowingTraders.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/getFollowingTraders.ts @@ -1,37 +1,41 @@ // src/tools/binance-copy-trading/FutureCopyTrading-api/getFollowingTraders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { copyTradingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { copyTradingClient } from "../../../config/binanceClient.js" export function registerBinanceCopyTradingGetFollowing(server: McpServer) { - server.tool( - "BinanceCopyTradingGetFollowing", - "Get list of traders you are currently following in copy trading.", - { - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await copyTradingClient.restAPI.getFollowingTraders({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCopyTradingGetFollowing", + "Get list of traders you are currently following in copy trading.", + { + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await copyTradingClient.restAPI.getFollowingTraders({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Traders You're Following:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Traders You're Following:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get following traders: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to get following traders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts index def3b5f3..57786147 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts @@ -1,45 +1,48 @@ // src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { copyTradingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { copyTradingClient } from "../../../config/binanceClient.js" export function registerBinanceGetFuturesLeadTraderStatus(server: McpServer) { - server.tool( - "BinanceGetFuturesLeadTraderStatus", - "Checks and returns whether the user is currently a Futures Lead Trader in Binance Copy Trading, along with the timestamp of the status check.", - { - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await copyTradingClient.restAPI.getFuturesLeadTraderStatus({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetFuturesLeadTraderStatus", + "Checks and returns whether the user is currently a Futures Lead Trader in Binance Copy Trading, along with the timestamp of the status check.", + { + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await copyTradingClient.restAPI.getFuturesLeadTraderStatus({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved user futures trading details. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved user futures trading details. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to Check and return whether the user is currently a Futures Lead Trader in Binance Copy Trading: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to Check and return whether the user is currently a Futures Lead Trader in Binance Copy Trading: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts index 09399375..925b449f 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts @@ -1,43 +1,46 @@ // src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { copyTradingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { copyTradingClient } from "../../../config/binanceClient.js" export function registerBinanceGetFuturesLeadTradingSymbolWhitelist(server: McpServer) { - server.tool( - "BinanceGetFuturesLeadTradingSymbolWhitelist", - "Whitelist of trading pairs (symbols) that are allowed for Futures Lead Traders in copy trading, including base and quote assets.", - { - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await copyTradingClient.restAPI.getFuturesLeadTradingSymbolWhitelist({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetFuturesLeadTradingSymbolWhitelist", + "Whitelist of trading pairs (symbols) that are allowed for Futures Lead Traders in copy trading, including base and quote assets.", + { + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await copyTradingClient.restAPI.getFuturesLeadTradingSymbolWhitelist({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved trading pairs. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved trading pairs. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to whitelist of trading pairs: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to whitelist of trading pairs: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/getLeadTraders.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/getLeadTraders.ts index 97848a5e..a6c96d1d 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/getLeadTraders.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/getLeadTraders.ts @@ -5,45 +5,47 @@ * @license Apache-2.0 */ // src/tools/binance-copy-trading/FutureCopyTrading-api/getLeadTraders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { copyTradingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { copyTradingClient } from "../../../config/binanceClient.js" export function registerBinanceCopyTradingGetLeaders(server: McpServer) { - server.tool( - "BinanceCopyTradingGetLeaders", - "Get a list of lead traders available for copy trading. Shows their performance metrics and follower count.", - { - pageNumber: z.number().int().min(1).optional() - .describe("Page number for pagination"), - pageSize: z.number().int().min(1).max(100).optional() - .describe("Results per page (max 100)"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await copyTradingClient.restAPI.getLeadTraders({ - ...(params.pageNumber && { pageNumber: params.pageNumber }), - ...(params.pageSize && { pageSize: params.pageSize }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCopyTradingGetLeaders", + "Get a list of lead traders available for copy trading. Shows their performance metrics and follower count.", + { + pageNumber: z.number().int().min(1).optional().describe("Page number for pagination"), + pageSize: z.number().int().min(1).max(100).optional().describe("Results per page (max 100)"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await copyTradingClient.restAPI.getLeadTraders({ + ...(params.pageNumber && { pageNumber: params.pageNumber }), + ...(params.pageSize && { pageSize: params.pageSize }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Lead Traders:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Lead Traders:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get lead traders: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to get lead traders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/getTraderPerformance.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/getTraderPerformance.ts index 9fc35e1b..6e3aa340 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/getTraderPerformance.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/getTraderPerformance.ts @@ -1,40 +1,43 @@ // src/tools/binance-copy-trading/FutureCopyTrading-api/getTraderPerformance.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { copyTradingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { copyTradingClient } from "../../../config/binanceClient.js" export function registerBinanceCopyTradingGetPerformance(server: McpServer) { - server.tool( - "BinanceCopyTradingGetPerformance", - "Get detailed performance statistics for a specific lead trader. Includes ROI, win rate, PnL history.", - { - portfolioId: z.string() - .describe("Lead trader's portfolio ID"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await copyTradingClient.restAPI.getLeadTraderPerformance({ - portfolioId: params.portfolioId, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCopyTradingGetPerformance", + "Get detailed performance statistics for a specific lead trader. Includes ROI, win rate, PnL history.", + { + portfolioId: z.string().describe("Lead trader's portfolio ID"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await copyTradingClient.restAPI.getLeadTraderPerformance({ + portfolioId: params.portfolioId, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Trader Performance for ${params.portfolioId}:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Trader Performance for ${params.portfolioId}:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get trader performance: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to get trader performance: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/index.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/index.ts index 486470c3..c7be5c17 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/index.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/index.ts @@ -1,13 +1,14 @@ // src/tools/binance-copy-trading/FutureCopyTrading-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetFuturesLeadTraderStatus } from "./getFuturesLeadTraderStatus.js"; -import { registerBinanceGetFuturesLeadTradingSymbolWhitelist } from "./getFuturesLeadTradingSymbolWhitelist.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceGetFuturesLeadTraderStatus } from "./getFuturesLeadTraderStatus.js" +import { registerBinanceGetFuturesLeadTradingSymbolWhitelist } from "./getFuturesLeadTradingSymbolWhitelist.js" // Registers Binance Futures Copy Trading API tools with the MCP server. export function registerBinanceFutureCopyTradingApiTools(server: McpServer) { - // Registers an endpoint to get the status of a lead trader in futures copy trading - registerBinanceGetFuturesLeadTraderStatus(server); + // Registers an endpoint to get the status of a lead trader in futures copy trading + registerBinanceGetFuturesLeadTraderStatus(server) - // Registers an endpoint to get the whitelist of symbols available for futures copy trading - registerBinanceGetFuturesLeadTradingSymbolWhitelist(server); + // Registers an endpoint to get the whitelist of symbols available for futures copy trading + registerBinanceGetFuturesLeadTradingSymbolWhitelist(server) } diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/unfollowTrader.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/unfollowTrader.ts index 08772d08..778e9f58 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/unfollowTrader.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/unfollowTrader.ts @@ -1,40 +1,43 @@ // src/tools/binance-copy-trading/FutureCopyTrading-api/unfollowTrader.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { copyTradingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { copyTradingClient } from "../../../config/binanceClient.js" export function registerBinanceCopyTradingUnfollow(server: McpServer) { - server.tool( - "BinanceCopyTradingUnfollow", - "Stop following a lead trader. This will stop copying their trades but won't close existing positions.", - { - portfolioId: z.string() - .describe("Lead trader's portfolio ID to unfollow"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await copyTradingClient.restAPI.unfollowLeadTrader({ - portfolioId: params.portfolioId, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCopyTradingUnfollow", + "Stop following a lead trader. This will stop copying their trades but won't close existing positions.", + { + portfolioId: z.string().describe("Lead trader's portfolio ID to unfollow"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await copyTradingClient.restAPI.unfollowLeadTrader({ + portfolioId: params.portfolioId, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Stopped following trader ${params.portfolioId}\n\n📝 Note: Existing copied positions remain open. Close them manually if needed.\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `✅ Stopped following trader ${params.portfolioId}\n\n📝 Note: Existing copied positions remain open. Close them manually if needed.\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to unfollow trader: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to unfollow trader: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-copy-trading/index.ts b/src/tools/binance-copy-trading/index.ts index cf3b9ae0..5dc0e672 100644 --- a/src/tools/binance-copy-trading/index.ts +++ b/src/tools/binance-copy-trading/index.ts @@ -1,9 +1,10 @@ // src/tools/binance-copy-trading/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceFutureCopyTradingApiTools } from "./FutureCopyTrading-api/index.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceFutureCopyTradingApiTools } from "./FutureCopyTrading-api/index.js" // Registers all Binance Copy Trading related tools with the MCP server. export function registerBinanceCopyTradingTools(server: McpServer) { - // Register the Binance Futures Copy Trading API tools with the given server. - registerBinanceFutureCopyTradingApiTools(server); + // Register the Binance Futures Copy Trading API tools with the given server. + registerBinanceFutureCopyTradingApiTools(server) } diff --git a/src/tools/binance-crypto-loans/fixed-api/adjustLTV.ts b/src/tools/binance-crypto-loans/fixed-api/adjustLTV.ts index 433a090e..a9199c4a 100644 --- a/src/tools/binance-crypto-loans/fixed-api/adjustLTV.ts +++ b/src/tools/binance-crypto-loans/fixed-api/adjustLTV.ts @@ -5,49 +5,53 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/fixed-api/adjustLTV.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { cryptoLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../../config/binanceClient.js" export function registerBinanceCryptoLoansFixedAdjustLTV(server: McpServer) { - server.tool( - "BinanceCryptoLoansFixedAdjustLTV", - "Adjust LTV for a fixed-term loan by adding or removing collateral.", - { - orderId: z.number().int() - .describe("Loan order ID"), - amount: z.string() - .describe("Amount of collateral to add or remove"), - direction: z.enum(["ADDITIONAL", "REDUCED"]) - .describe("Direction: ADDITIONAL to add collateral, REDUCED to remove"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await cryptoLoanClient.restAPI.cryptoLoanAdjustLtv({ - orderId: params.orderId, - amount: params.amount, - direction: params.direction, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCryptoLoansFixedAdjustLTV", + "Adjust LTV for a fixed-term loan by adding or removing collateral.", + { + orderId: z.number().int().describe("Loan order ID"), + amount: z.string().describe("Amount of collateral to add or remove"), + direction: z + .enum(["ADDITIONAL", "REDUCED"]) + .describe("Direction: ADDITIONAL to add collateral, REDUCED to remove"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await cryptoLoanClient.restAPI.cryptoLoanAdjustLtv({ + orderId: params.orderId, + amount: params.amount, + direction: params.direction, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() - const data = await response.data(); + const action = params.direction === "ADDITIONAL" ? "added" : "removed" + + return { + content: [ + { + type: "text", + text: `✅ LTV Adjusted!\n\nOrder ID: ${params.orderId}\nCollateral ${action}: ${params.amount}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - const action = params.direction === "ADDITIONAL" ? "added" : "removed"; - return { - content: [{ - type: "text", - text: `✅ LTV Adjusted!\n\nOrder ID: ${params.orderId}\nCollateral ${action}: ${params.amount}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to adjust LTV: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to adjust LTV: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/fixed-api/borrow.ts b/src/tools/binance-crypto-loans/fixed-api/borrow.ts index 45ffa855..155ffea5 100644 --- a/src/tools/binance-crypto-loans/fixed-api/borrow.ts +++ b/src/tools/binance-crypto-loans/fixed-api/borrow.ts @@ -5,61 +5,68 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/fixed-api/borrow.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { cryptoLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../../config/binanceClient.js" export function registerBinanceCryptoLoansFixedBorrow(server: McpServer) { - server.tool( - "BinanceCryptoLoansFixedBorrow", - "Borrow crypto using a fixed-term loan. ⚠️ WARNING: Fixed loans have a specific term. Your collateral is locked until repayment. Failure to repay may result in liquidation.", - { - loanCoin: z.string() - .describe("Coin to borrow (e.g., 'USDT')"), - collateralCoin: z.string() - .describe("Collateral coin (e.g., 'BTC')"), - loanTerm: z.number().int() - .describe("Loan term in days (7, 14, 30, 90, 180)"), - loanAmount: z.string().optional() - .describe("Amount to borrow (provide either loanAmount or collateralAmount)"), - collateralAmount: z.string().optional() - .describe("Collateral amount (provide either loanAmount or collateralAmount)"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - if (!params.loanAmount && !params.collateralAmount) { - return { - content: [{ type: "text", text: "❌ Either loanAmount or collateralAmount must be provided" }], - isError: true - }; - } + server.tool( + "BinanceCryptoLoansFixedBorrow", + "Borrow crypto using a fixed-term loan. ⚠️ WARNING: Fixed loans have a specific term. Your collateral is locked until repayment. Failure to repay may result in liquidation.", + { + loanCoin: z.string().describe("Coin to borrow (e.g., 'USDT')"), + collateralCoin: z.string().describe("Collateral coin (e.g., 'BTC')"), + loanTerm: z.number().int().describe("Loan term in days (7, 14, 30, 90, 180)"), + loanAmount: z + .string() + .optional() + .describe("Amount to borrow (provide either loanAmount or collateralAmount)"), + collateralAmount: z + .string() + .optional() + .describe("Collateral amount (provide either loanAmount or collateralAmount)"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + if (!params.loanAmount && !params.collateralAmount) { + return { + content: [ + { type: "text", text: "❌ Either loanAmount or collateralAmount must be provided" }, + ], + isError: true, + } + } - const response = await cryptoLoanClient.restAPI.cryptoLoanBorrow({ - loanCoin: params.loanCoin, - collateralCoin: params.collateralCoin, - loanTerm: params.loanTerm, - ...(params.loanAmount && { loanAmount: params.loanAmount }), - ...(params.collateralAmount && { collateralAmount: params.collateralAmount }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + const response = await cryptoLoanClient.restAPI.cryptoLoanBorrow({ + loanCoin: params.loanCoin, + collateralCoin: params.collateralCoin, + loanTerm: params.loanTerm, + ...(params.loanAmount && { loanAmount: params.loanAmount }), + ...(params.collateralAmount && { collateralAmount: params.collateralAmount }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Fixed-Term Loan Created!\n\nLoan Coin: ${params.loanCoin}\nCollateral: ${params.collateralCoin}\nTerm: ${params.loanTerm} days\n\n⚠️ Remember to repay before the term ends to avoid liquidation.\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `✅ Fixed-Term Loan Created!\n\nLoan Coin: ${params.loanCoin}\nCollateral: ${params.collateralCoin}\nTerm: ${params.loanTerm} days\n\n⚠️ Remember to repay before the term ends to avoid liquidation.\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to borrow: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to borrow: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/fixed-api/checkCollateralRate.ts b/src/tools/binance-crypto-loans/fixed-api/checkCollateralRate.ts index 5a36932c..c6fe8dfe 100644 --- a/src/tools/binance-crypto-loans/fixed-api/checkCollateralRate.ts +++ b/src/tools/binance-crypto-loans/fixed-api/checkCollateralRate.ts @@ -5,48 +5,49 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/fixed-api/checkCollateralRate.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { cryptoLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../../config/binanceClient.js" export function registerBinanceCryptoLoansFixedCollateralRate(server: McpServer) { - server.tool( - "BinanceCryptoLoansFixedCollateralRate", - "Check the collateral repay rate for a specific loan and collateral pair. Useful for planning repayments.", - { - loanCoin: z.string() - .describe("Loan coin (e.g., 'USDT')"), - collateralCoin: z.string() - .describe("Collateral coin (e.g., 'BTC')"), - repayAmount: z.string() - .describe("Amount to repay"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await cryptoLoanClient.restAPI.checkCollateralRepayRate({ - loanCoin: params.loanCoin, - collateralCoin: params.collateralCoin, - repayAmount: params.repayAmount, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCryptoLoansFixedCollateralRate", + "Check the collateral repay rate for a specific loan and collateral pair. Useful for planning repayments.", + { + loanCoin: z.string().describe("Loan coin (e.g., 'USDT')"), + collateralCoin: z.string().describe("Collateral coin (e.g., 'BTC')"), + repayAmount: z.string().describe("Amount to repay"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await cryptoLoanClient.restAPI.checkCollateralRepayRate({ + loanCoin: params.loanCoin, + collateralCoin: params.collateralCoin, + repayAmount: params.repayAmount, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Collateral Repay Rate:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Collateral Repay Rate:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to check collateral rate: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to check collateral rate: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/fixed-api/customizeMarginCall.ts b/src/tools/binance-crypto-loans/fixed-api/customizeMarginCall.ts index 3fb13426..12deda63 100644 --- a/src/tools/binance-crypto-loans/fixed-api/customizeMarginCall.ts +++ b/src/tools/binance-crypto-loans/fixed-api/customizeMarginCall.ts @@ -5,45 +5,47 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/fixed-api/customizeMarginCall.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { cryptoLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../../config/binanceClient.js" export function registerBinanceCryptoLoansFixedMarginCall(server: McpServer) { - server.tool( - "BinanceCryptoLoansFixedMarginCall", - "Customize margin call threshold for a loan. Set when you want to be notified about LTV changes.", - { - orderId: z.number().int() - .describe("Loan order ID"), - marginCall: z.number() - .describe("Margin call LTV threshold (e.g., 0.8 for 80%)"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await cryptoLoanClient.restAPI.customizeMarginCall({ - orderId: params.orderId, - marginCall: params.marginCall, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCryptoLoansFixedMarginCall", + "Customize margin call threshold for a loan. Set when you want to be notified about LTV changes.", + { + orderId: z.number().int().describe("Loan order ID"), + marginCall: z.number().describe("Margin call LTV threshold (e.g., 0.8 for 80%)"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await cryptoLoanClient.restAPI.customizeMarginCall({ + orderId: params.orderId, + marginCall: params.marginCall, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Margin call threshold updated!\n\nOrder ID: ${params.orderId}\nNew Threshold: ${params.marginCall * 100}%\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `✅ Margin call threshold updated!\n\nOrder ID: ${params.orderId}\nNew Threshold: ${params.marginCall * 100}%\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to customize margin call: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to customize margin call: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/fixed-api/getBorrowHistory.ts b/src/tools/binance-crypto-loans/fixed-api/getBorrowHistory.ts index d044955e..2dec742f 100644 --- a/src/tools/binance-crypto-loans/fixed-api/getBorrowHistory.ts +++ b/src/tools/binance-crypto-loans/fixed-api/getBorrowHistory.ts @@ -5,60 +5,57 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/fixed-api/getBorrowHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { cryptoLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../../config/binanceClient.js" export function registerBinanceCryptoLoansFixedBorrowHistory(server: McpServer) { - server.tool( - "BinanceCryptoLoansFixedBorrowHistory", - "Get borrow history for fixed-term loans.", - { - orderId: z.number().int().optional() - .describe("Filter by specific order ID"), - loanCoin: z.string().optional() - .describe("Filter by loan coin"), - collateralCoin: z.string().optional() - .describe("Filter by collateral coin"), - startTime: z.number().int().optional() - .describe("Start timestamp in ms"), - endTime: z.number().int().optional() - .describe("End timestamp in ms"), - current: z.number().int().min(1).optional() - .describe("Current page"), - limit: z.number().int().min(1).max(100).optional() - .describe("Results per page (max 100)"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await cryptoLoanClient.restAPI.getLoanBorrowHistory({ - ...(params.orderId && { orderId: params.orderId }), - ...(params.loanCoin && { loanCoin: params.loanCoin }), - ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.current && { current: params.current }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCryptoLoansFixedBorrowHistory", + "Get borrow history for fixed-term loans.", + { + orderId: z.number().int().optional().describe("Filter by specific order ID"), + loanCoin: z.string().optional().describe("Filter by loan coin"), + collateralCoin: z.string().optional().describe("Filter by collateral coin"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + current: z.number().int().min(1).optional().describe("Current page"), + limit: z.number().int().min(1).max(100).optional().describe("Results per page (max 100)"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await cryptoLoanClient.restAPI.getLoanBorrowHistory({ + ...(params.orderId && { orderId: params.orderId }), + ...(params.loanCoin && { loanCoin: params.loanCoin }), + ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.current && { current: params.current }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Fixed Loan Borrow History:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Fixed Loan Borrow History:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get borrow history: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to get borrow history: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/fixed-api/getFixedCollateralData.ts b/src/tools/binance-crypto-loans/fixed-api/getFixedCollateralData.ts index 077cfb40..897f2f93 100644 --- a/src/tools/binance-crypto-loans/fixed-api/getFixedCollateralData.ts +++ b/src/tools/binance-crypto-loans/fixed-api/getFixedCollateralData.ts @@ -5,45 +5,47 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/fixed-api/getFixedCollateralData.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { cryptoLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../../config/binanceClient.js" export function registerBinanceCryptoLoansFixedCollateral(server: McpServer) { - server.tool( - "BinanceCryptoLoansFixedCollateral", - "Get list of collateral assets for fixed-term loans. Shows LTV ratios and limits.", - { - collateralCoin: z.string().optional() - .describe("Filter by specific collateral coin"), - vipLevel: z.number().int().min(0).max(9).optional() - .describe("VIP level"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await cryptoLoanClient.restAPI.getCollateralAssetsData({ - ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), - ...(params.vipLevel !== undefined && { vipLevel: params.vipLevel }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCryptoLoansFixedCollateral", + "Get list of collateral assets for fixed-term loans. Shows LTV ratios and limits.", + { + collateralCoin: z.string().optional().describe("Filter by specific collateral coin"), + vipLevel: z.number().int().min(0).max(9).optional().describe("VIP level"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await cryptoLoanClient.restAPI.getCollateralAssetsData({ + ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), + ...(params.vipLevel !== undefined && { vipLevel: params.vipLevel }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Fixed Loan Collateral Assets:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Fixed Loan Collateral Assets:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get collateral data: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to get collateral data: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/fixed-api/getFixedLoanData.ts b/src/tools/binance-crypto-loans/fixed-api/getFixedLoanData.ts index 5fb61d72..a908e6fa 100644 --- a/src/tools/binance-crypto-loans/fixed-api/getFixedLoanData.ts +++ b/src/tools/binance-crypto-loans/fixed-api/getFixedLoanData.ts @@ -5,45 +5,53 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/fixed-api/getFixedLoanData.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { cryptoLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../../config/binanceClient.js" export function registerBinanceCryptoLoansFixedAssets(server: McpServer) { - server.tool( - "BinanceCryptoLoansFixedAssets", - "Get list of assets available for fixed-term crypto loans. Shows borrowable assets with interest rates, terms, and limits.", - { - loanCoin: z.string().optional() - .describe("Filter by specific loan coin"), - vipLevel: z.number().int().min(0).max(9).optional() - .describe("VIP level for rate calculation"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await cryptoLoanClient.restAPI.getLoanableAssetsData({ - ...(params.loanCoin && { loanCoin: params.loanCoin }), - ...(params.vipLevel !== undefined && { vipLevel: params.vipLevel }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCryptoLoansFixedAssets", + "Get list of assets available for fixed-term crypto loans. Shows borrowable assets with interest rates, terms, and limits.", + { + loanCoin: z.string().optional().describe("Filter by specific loan coin"), + vipLevel: z + .number() + .int() + .min(0) + .max(9) + .optional() + .describe("VIP level for rate calculation"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await cryptoLoanClient.restAPI.getLoanableAssetsData({ + ...(params.loanCoin && { loanCoin: params.loanCoin }), + ...(params.vipLevel !== undefined && { vipLevel: params.vipLevel }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Fixed Loan Assets:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Fixed Loan Assets:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get fixed loan assets: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to get fixed loan assets: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/fixed-api/getOngoingOrders.ts b/src/tools/binance-crypto-loans/fixed-api/getOngoingOrders.ts index edec9a94..8a76066c 100644 --- a/src/tools/binance-crypto-loans/fixed-api/getOngoingOrders.ts +++ b/src/tools/binance-crypto-loans/fixed-api/getOngoingOrders.ts @@ -5,54 +5,53 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/fixed-api/getOngoingOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { cryptoLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../../config/binanceClient.js" export function registerBinanceCryptoLoansFixedOngoing(server: McpServer) { - server.tool( - "BinanceCryptoLoansFixedOngoing", - "Get ongoing fixed-term loan orders. Shows current loans with term, principal, interest, and LTV.", - { - orderId: z.number().int().optional() - .describe("Filter by specific order ID"), - loanCoin: z.string().optional() - .describe("Filter by loan coin"), - collateralCoin: z.string().optional() - .describe("Filter by collateral coin"), - current: z.number().int().min(1).optional() - .describe("Current page"), - limit: z.number().int().min(1).max(100).optional() - .describe("Results per page (max 100)"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await cryptoLoanClient.restAPI.getLoanOngoingOrders({ - ...(params.orderId && { orderId: params.orderId }), - ...(params.loanCoin && { loanCoin: params.loanCoin }), - ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), - ...(params.current && { current: params.current }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCryptoLoansFixedOngoing", + "Get ongoing fixed-term loan orders. Shows current loans with term, principal, interest, and LTV.", + { + orderId: z.number().int().optional().describe("Filter by specific order ID"), + loanCoin: z.string().optional().describe("Filter by loan coin"), + collateralCoin: z.string().optional().describe("Filter by collateral coin"), + current: z.number().int().min(1).optional().describe("Current page"), + limit: z.number().int().min(1).max(100).optional().describe("Results per page (max 100)"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await cryptoLoanClient.restAPI.getLoanOngoingOrders({ + ...(params.orderId && { orderId: params.orderId }), + ...(params.loanCoin && { loanCoin: params.loanCoin }), + ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), + ...(params.current && { current: params.current }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Ongoing Fixed Loans:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Ongoing Fixed Loans:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get ongoing orders: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to get ongoing orders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/fixed-api/getRepayHistory.ts b/src/tools/binance-crypto-loans/fixed-api/getRepayHistory.ts index fe6b17c4..2f10f889 100644 --- a/src/tools/binance-crypto-loans/fixed-api/getRepayHistory.ts +++ b/src/tools/binance-crypto-loans/fixed-api/getRepayHistory.ts @@ -5,60 +5,57 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/fixed-api/getRepayHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { cryptoLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../../config/binanceClient.js" export function registerBinanceCryptoLoansFixedRepayHistory(server: McpServer) { - server.tool( - "BinanceCryptoLoansFixedRepayHistory", - "Get repayment history for fixed-term loans.", - { - orderId: z.number().int().optional() - .describe("Filter by specific order ID"), - loanCoin: z.string().optional() - .describe("Filter by loan coin"), - collateralCoin: z.string().optional() - .describe("Filter by collateral coin"), - startTime: z.number().int().optional() - .describe("Start timestamp in ms"), - endTime: z.number().int().optional() - .describe("End timestamp in ms"), - current: z.number().int().min(1).optional() - .describe("Current page"), - limit: z.number().int().min(1).max(100).optional() - .describe("Results per page (max 100)"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await cryptoLoanClient.restAPI.getLoanRepaymentHistory({ - ...(params.orderId && { orderId: params.orderId }), - ...(params.loanCoin && { loanCoin: params.loanCoin }), - ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.current && { current: params.current }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCryptoLoansFixedRepayHistory", + "Get repayment history for fixed-term loans.", + { + orderId: z.number().int().optional().describe("Filter by specific order ID"), + loanCoin: z.string().optional().describe("Filter by loan coin"), + collateralCoin: z.string().optional().describe("Filter by collateral coin"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + current: z.number().int().min(1).optional().describe("Current page"), + limit: z.number().int().min(1).max(100).optional().describe("Results per page (max 100)"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await cryptoLoanClient.restAPI.getLoanRepaymentHistory({ + ...(params.orderId && { orderId: params.orderId }), + ...(params.loanCoin && { loanCoin: params.loanCoin }), + ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.current && { current: params.current }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Fixed Loan Repay History:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Fixed Loan Repay History:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get repay history: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to get repay history: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/fixed-api/index.ts b/src/tools/binance-crypto-loans/fixed-api/index.ts index 25b7c7d9..5f5ae38a 100644 --- a/src/tools/binance-crypto-loans/fixed-api/index.ts +++ b/src/tools/binance-crypto-loans/fixed-api/index.ts @@ -5,27 +5,28 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/fixed-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceCryptoLoansFixedAssets } from "./getFixedLoanData.js"; -import { registerBinanceCryptoLoansFixedCollateral } from "./getFixedCollateralData.js"; -import { registerBinanceCryptoLoansFixedBorrow } from "./borrow.js"; -import { registerBinanceCryptoLoansFixedRepay } from "./repay.js"; -import { registerBinanceCryptoLoansFixedAdjustLTV } from "./adjustLTV.js"; -import { registerBinanceCryptoLoansFixedOngoing } from "./getOngoingOrders.js"; -import { registerBinanceCryptoLoansFixedBorrowHistory } from "./getBorrowHistory.js"; -import { registerBinanceCryptoLoansFixedRepayHistory } from "./getRepayHistory.js"; -import { registerBinanceCryptoLoansFixedCollateralRate } from "./checkCollateralRate.js"; -import { registerBinanceCryptoLoansFixedMarginCall } from "./customizeMarginCall.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceCryptoLoansFixedAdjustLTV } from "./adjustLTV.js" +import { registerBinanceCryptoLoansFixedBorrow } from "./borrow.js" +import { registerBinanceCryptoLoansFixedCollateralRate } from "./checkCollateralRate.js" +import { registerBinanceCryptoLoansFixedMarginCall } from "./customizeMarginCall.js" +import { registerBinanceCryptoLoansFixedBorrowHistory } from "./getBorrowHistory.js" +import { registerBinanceCryptoLoansFixedCollateral } from "./getFixedCollateralData.js" +import { registerBinanceCryptoLoansFixedAssets } from "./getFixedLoanData.js" +import { registerBinanceCryptoLoansFixedOngoing } from "./getOngoingOrders.js" +import { registerBinanceCryptoLoansFixedRepayHistory } from "./getRepayHistory.js" +import { registerBinanceCryptoLoansFixedRepay } from "./repay.js" export function registerBinanceCryptoLoansFixedTools(server: McpServer) { - registerBinanceCryptoLoansFixedAssets(server); - registerBinanceCryptoLoansFixedCollateral(server); - registerBinanceCryptoLoansFixedCollateralRate(server); - registerBinanceCryptoLoansFixedMarginCall(server); - registerBinanceCryptoLoansFixedBorrow(server); - registerBinanceCryptoLoansFixedRepay(server); - registerBinanceCryptoLoansFixedAdjustLTV(server); - registerBinanceCryptoLoansFixedOngoing(server); - registerBinanceCryptoLoansFixedBorrowHistory(server); - registerBinanceCryptoLoansFixedRepayHistory(server); + registerBinanceCryptoLoansFixedAssets(server) + registerBinanceCryptoLoansFixedCollateral(server) + registerBinanceCryptoLoansFixedCollateralRate(server) + registerBinanceCryptoLoansFixedMarginCall(server) + registerBinanceCryptoLoansFixedBorrow(server) + registerBinanceCryptoLoansFixedRepay(server) + registerBinanceCryptoLoansFixedAdjustLTV(server) + registerBinanceCryptoLoansFixedOngoing(server) + registerBinanceCryptoLoansFixedBorrowHistory(server) + registerBinanceCryptoLoansFixedRepayHistory(server) } diff --git a/src/tools/binance-crypto-loans/fixed-api/repay.ts b/src/tools/binance-crypto-loans/fixed-api/repay.ts index ac5a88bf..7d73773a 100644 --- a/src/tools/binance-crypto-loans/fixed-api/repay.ts +++ b/src/tools/binance-crypto-loans/fixed-api/repay.ts @@ -5,51 +5,59 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/fixed-api/repay.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { cryptoLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../../config/binanceClient.js" export function registerBinanceCryptoLoansFixedRepay(server: McpServer) { - server.tool( - "BinanceCryptoLoansFixedRepay", - "Repay a fixed-term crypto loan. Repaying unlocks your collateral.", - { - orderId: z.number().int() - .describe("Loan order ID to repay"), - amount: z.string() - .describe("Amount to repay"), - type: z.enum(["1", "2"]).optional() - .describe("Repay type: 1 = repay with borrowed coin, 2 = repay with collateral"), - collateralReturn: z.boolean().optional() - .describe("Whether to return collateral after full repayment"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await cryptoLoanClient.restAPI.cryptoLoanRepay({ - orderId: params.orderId, - amount: params.amount, - ...(params.type && { type: params.type }), - ...(params.collateralReturn !== undefined && { collateralReturn: params.collateralReturn }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCryptoLoansFixedRepay", + "Repay a fixed-term crypto loan. Repaying unlocks your collateral.", + { + orderId: z.number().int().describe("Loan order ID to repay"), + amount: z.string().describe("Amount to repay"), + type: z + .enum(["1", "2"]) + .optional() + .describe("Repay type: 1 = repay with borrowed coin, 2 = repay with collateral"), + collateralReturn: z + .boolean() + .optional() + .describe("Whether to return collateral after full repayment"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await cryptoLoanClient.restAPI.cryptoLoanRepay({ + orderId: params.orderId, + amount: params.amount, + ...(params.type && { type: params.type }), + ...(params.collateralReturn !== undefined && { + collateralReturn: params.collateralReturn, + }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Loan Repayment Successful!\n\nOrder ID: ${params.orderId}\nAmount Repaid: ${params.amount}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `✅ Loan Repayment Successful!\n\nOrder ID: ${params.orderId}\nAmount Repaid: ${params.amount}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to repay loan: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to repay loan: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/flexible-api/adjustLTV.ts b/src/tools/binance-crypto-loans/flexible-api/adjustLTV.ts index 693a5792..8479854e 100644 --- a/src/tools/binance-crypto-loans/flexible-api/adjustLTV.ts +++ b/src/tools/binance-crypto-loans/flexible-api/adjustLTV.ts @@ -5,52 +5,57 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/flexible-api/adjustLTV.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { cryptoLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../../config/binanceClient.js" export function registerBinanceCryptoLoansFlexibleAdjustLTV(server: McpServer) { - server.tool( - "BinanceCryptoLoansFlexibleAdjustLTV", - "Adjust LTV (Loan-to-Value) ratio by adding or removing collateral. Lower LTV reduces liquidation risk.", - { - loanCoin: z.string() - .describe("Loan coin (e.g., 'USDT')"), - collateralCoin: z.string() - .describe("Collateral coin (e.g., 'BTC')"), - adjustmentAmount: z.string() - .describe("Amount of collateral to add or remove"), - direction: z.enum(["ADDITIONAL", "REDUCED"]) - .describe("Direction: ADDITIONAL to add collateral (lower LTV), REDUCED to remove collateral (higher LTV)"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await cryptoLoanClient.restAPI.flexibleLoanAdjustLtv({ - loanCoin: params.loanCoin, - collateralCoin: params.collateralCoin, - adjustmentAmount: params.adjustmentAmount, - direction: params.direction, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCryptoLoansFlexibleAdjustLTV", + "Adjust LTV (Loan-to-Value) ratio by adding or removing collateral. Lower LTV reduces liquidation risk.", + { + loanCoin: z.string().describe("Loan coin (e.g., 'USDT')"), + collateralCoin: z.string().describe("Collateral coin (e.g., 'BTC')"), + adjustmentAmount: z.string().describe("Amount of collateral to add or remove"), + direction: z + .enum(["ADDITIONAL", "REDUCED"]) + .describe( + "Direction: ADDITIONAL to add collateral (lower LTV), REDUCED to remove collateral (higher LTV)", + ), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await cryptoLoanClient.restAPI.flexibleLoanAdjustLtv({ + loanCoin: params.loanCoin, + collateralCoin: params.collateralCoin, + adjustmentAmount: params.adjustmentAmount, + direction: params.direction, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() - const data = await response.data(); + const action = params.direction === "ADDITIONAL" ? "added" : "removed" + + return { + content: [ + { + type: "text", + text: `✅ LTV Adjusted!\n\nCollateral ${action}: ${params.adjustmentAmount} ${params.collateralCoin}\n\n${params.direction === "ADDITIONAL" ? "Your liquidation risk is now lower." : "⚠️ Your liquidation risk may have increased."}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - const action = params.direction === "ADDITIONAL" ? "added" : "removed"; - return { - content: [{ - type: "text", - text: `✅ LTV Adjusted!\n\nCollateral ${action}: ${params.adjustmentAmount} ${params.collateralCoin}\n\n${params.direction === "ADDITIONAL" ? "Your liquidation risk is now lower." : "⚠️ Your liquidation risk may have increased."}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to adjust LTV: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to adjust LTV: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/flexible-api/borrow.ts b/src/tools/binance-crypto-loans/flexible-api/borrow.ts index ce3b5414..69be92f0 100644 --- a/src/tools/binance-crypto-loans/flexible-api/borrow.ts +++ b/src/tools/binance-crypto-loans/flexible-api/borrow.ts @@ -5,59 +5,67 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/flexible-api/borrow.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { cryptoLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../../config/binanceClient.js" export function registerBinanceCryptoLoansFlexibleBorrow(server: McpServer) { - server.tool( - "BinanceCryptoLoansFlexibleBorrow", - "Borrow crypto using a flexible loan. ⚠️ WARNING: Your collateral will be locked. Interest accrues daily. If LTV ratio exceeds threshold, liquidation may occur.", - { - loanCoin: z.string() - .describe("Coin to borrow (e.g., 'USDT', 'BUSD')"), - collateralCoin: z.string() - .describe("Collateral coin (e.g., 'BTC', 'ETH')"), - loanAmount: z.string().optional() - .describe("Amount to borrow (provide either loanAmount or collateralAmount)"), - collateralAmount: z.string().optional() - .describe("Collateral amount (provide either loanAmount or collateralAmount)"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - // Validate that either loanAmount or collateralAmount is provided - if (!params.loanAmount && !params.collateralAmount) { - return { - content: [{ type: "text", text: "❌ Either loanAmount or collateralAmount must be provided" }], - isError: true - }; - } + server.tool( + "BinanceCryptoLoansFlexibleBorrow", + "Borrow crypto using a flexible loan. ⚠️ WARNING: Your collateral will be locked. Interest accrues daily. If LTV ratio exceeds threshold, liquidation may occur.", + { + loanCoin: z.string().describe("Coin to borrow (e.g., 'USDT', 'BUSD')"), + collateralCoin: z.string().describe("Collateral coin (e.g., 'BTC', 'ETH')"), + loanAmount: z + .string() + .optional() + .describe("Amount to borrow (provide either loanAmount or collateralAmount)"), + collateralAmount: z + .string() + .optional() + .describe("Collateral amount (provide either loanAmount or collateralAmount)"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + // Validate that either loanAmount or collateralAmount is provided + if (!params.loanAmount && !params.collateralAmount) { + return { + content: [ + { type: "text", text: "❌ Either loanAmount or collateralAmount must be provided" }, + ], + isError: true, + } + } - const response = await cryptoLoanClient.restAPI.flexibleLoanBorrow({ - loanCoin: params.loanCoin, - collateralCoin: params.collateralCoin, - ...(params.loanAmount && { loanAmount: params.loanAmount }), - ...(params.collateralAmount && { collateralAmount: params.collateralAmount }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + const response = await cryptoLoanClient.restAPI.flexibleLoanBorrow({ + loanCoin: params.loanCoin, + collateralCoin: params.collateralCoin, + ...(params.loanAmount && { loanAmount: params.loanAmount }), + ...(params.collateralAmount && { collateralAmount: params.collateralAmount }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Flexible Loan Borrowed!\n\nLoan Coin: ${params.loanCoin}\nCollateral: ${params.collateralCoin}\n\n⚠️ Monitor your LTV ratio regularly to avoid liquidation.\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `✅ Flexible Loan Borrowed!\n\nLoan Coin: ${params.loanCoin}\nCollateral: ${params.collateralCoin}\n\n⚠️ Monitor your LTV ratio regularly to avoid liquidation.\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to borrow: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to borrow: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/flexible-api/getBorrowHistory.ts b/src/tools/binance-crypto-loans/flexible-api/getBorrowHistory.ts index 859079b1..645e003a 100644 --- a/src/tools/binance-crypto-loans/flexible-api/getBorrowHistory.ts +++ b/src/tools/binance-crypto-loans/flexible-api/getBorrowHistory.ts @@ -5,57 +5,55 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/flexible-api/getBorrowHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { cryptoLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../../config/binanceClient.js" export function registerBinanceCryptoLoansFlexibleBorrowHistory(server: McpServer) { - server.tool( - "BinanceCryptoLoansFlexibleBorrowHistory", - "Get borrow history for flexible loans. Shows all past and current borrow transactions.", - { - loanCoin: z.string().optional() - .describe("Filter by loan coin"), - collateralCoin: z.string().optional() - .describe("Filter by collateral coin"), - startTime: z.number().int().optional() - .describe("Start timestamp in ms"), - endTime: z.number().int().optional() - .describe("End timestamp in ms"), - current: z.number().int().min(1).optional() - .describe("Current page (default 1)"), - limit: z.number().int().min(1).max(100).optional() - .describe("Results per page (max 100)"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await cryptoLoanClient.restAPI.getFlexibleLoanBorrowHistory({ - ...(params.loanCoin && { loanCoin: params.loanCoin }), - ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.current && { current: params.current }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCryptoLoansFlexibleBorrowHistory", + "Get borrow history for flexible loans. Shows all past and current borrow transactions.", + { + loanCoin: z.string().optional().describe("Filter by loan coin"), + collateralCoin: z.string().optional().describe("Filter by collateral coin"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + current: z.number().int().min(1).optional().describe("Current page (default 1)"), + limit: z.number().int().min(1).max(100).optional().describe("Results per page (max 100)"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await cryptoLoanClient.restAPI.getFlexibleLoanBorrowHistory({ + ...(params.loanCoin && { loanCoin: params.loanCoin }), + ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.current && { current: params.current }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Flexible Loan Borrow History:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Flexible Loan Borrow History:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get borrow history: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to get borrow history: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/flexible-api/getFlexibleCollateralAssets.ts b/src/tools/binance-crypto-loans/flexible-api/getFlexibleCollateralAssets.ts index f732678e..d1a1d190 100644 --- a/src/tools/binance-crypto-loans/flexible-api/getFlexibleCollateralAssets.ts +++ b/src/tools/binance-crypto-loans/flexible-api/getFlexibleCollateralAssets.ts @@ -5,42 +5,48 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/flexible-api/getFlexibleCollateralAssets.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { cryptoLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../../config/binanceClient.js" export function registerBinanceCryptoLoansFlexibleCollateral(server: McpServer) { - server.tool( - "BinanceCryptoLoansFlexibleCollateral", - "Get list of assets that can be used as collateral for flexible loans. Shows LTV ratios and collateral limits.", - { - collateralCoin: z.string().optional() - .describe("Filter by specific collateral coin (e.g., 'BTC', 'ETH')"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await cryptoLoanClient.restAPI.getFlexibleLoanCollateralAssetsData({ - ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCryptoLoansFlexibleCollateral", + "Get list of assets that can be used as collateral for flexible loans. Shows LTV ratios and collateral limits.", + { + collateralCoin: z + .string() + .optional() + .describe("Filter by specific collateral coin (e.g., 'BTC', 'ETH')"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await cryptoLoanClient.restAPI.getFlexibleLoanCollateralAssetsData({ + ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Flexible Loan Collateral Assets:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Flexible Loan Collateral Assets:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get collateral assets: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to get collateral assets: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/flexible-api/getFlexibleLoanAssets.ts b/src/tools/binance-crypto-loans/flexible-api/getFlexibleLoanAssets.ts index f9d0fcdc..8d443bce 100644 --- a/src/tools/binance-crypto-loans/flexible-api/getFlexibleLoanAssets.ts +++ b/src/tools/binance-crypto-loans/flexible-api/getFlexibleLoanAssets.ts @@ -5,42 +5,48 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/flexible-api/getFlexibleLoanAssets.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { cryptoLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../../config/binanceClient.js" export function registerBinanceCryptoLoansFlexibleAssets(server: McpServer) { - server.tool( - "BinanceCryptoLoansFlexibleAssets", - "Get list of assets available for flexible crypto loans. Shows borrowable assets with interest rates and limits.", - { - loanCoin: z.string().optional() - .describe("Filter by specific loan coin (e.g., 'USDT', 'BUSD')"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await cryptoLoanClient.restAPI.getFlexibleLoanAssetsData({ - ...(params.loanCoin && { loanCoin: params.loanCoin }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCryptoLoansFlexibleAssets", + "Get list of assets available for flexible crypto loans. Shows borrowable assets with interest rates and limits.", + { + loanCoin: z + .string() + .optional() + .describe("Filter by specific loan coin (e.g., 'USDT', 'BUSD')"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await cryptoLoanClient.restAPI.getFlexibleLoanAssetsData({ + ...(params.loanCoin && { loanCoin: params.loanCoin }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Flexible Loan Assets:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Flexible Loan Assets:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get loan assets: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to get loan assets: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/flexible-api/getOngoingOrders.ts b/src/tools/binance-crypto-loans/flexible-api/getOngoingOrders.ts index c359d376..93c5b1ea 100644 --- a/src/tools/binance-crypto-loans/flexible-api/getOngoingOrders.ts +++ b/src/tools/binance-crypto-loans/flexible-api/getOngoingOrders.ts @@ -5,51 +5,51 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/flexible-api/getOngoingOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { cryptoLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../../config/binanceClient.js" export function registerBinanceCryptoLoansFlexibleOngoing(server: McpServer) { - server.tool( - "BinanceCryptoLoansFlexibleOngoing", - "Get all ongoing flexible loan orders. Shows current loans with principal, interest, collateral, and LTV information.", - { - loanCoin: z.string().optional() - .describe("Filter by loan coin"), - collateralCoin: z.string().optional() - .describe("Filter by collateral coin"), - current: z.number().int().min(1).optional() - .describe("Current page (default 1)"), - limit: z.number().int().min(1).max(100).optional() - .describe("Results per page (max 100)"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await cryptoLoanClient.restAPI.getFlexibleLoanOngoingOrders({ - ...(params.loanCoin && { loanCoin: params.loanCoin }), - ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), - ...(params.current && { current: params.current }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCryptoLoansFlexibleOngoing", + "Get all ongoing flexible loan orders. Shows current loans with principal, interest, collateral, and LTV information.", + { + loanCoin: z.string().optional().describe("Filter by loan coin"), + collateralCoin: z.string().optional().describe("Filter by collateral coin"), + current: z.number().int().min(1).optional().describe("Current page (default 1)"), + limit: z.number().int().min(1).max(100).optional().describe("Results per page (max 100)"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await cryptoLoanClient.restAPI.getFlexibleLoanOngoingOrders({ + ...(params.loanCoin && { loanCoin: params.loanCoin }), + ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), + ...(params.current && { current: params.current }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Ongoing Flexible Loans:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Ongoing Flexible Loans:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get ongoing orders: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to get ongoing orders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/flexible-api/getRepayHistory.ts b/src/tools/binance-crypto-loans/flexible-api/getRepayHistory.ts index 85d65eb0..5d024f67 100644 --- a/src/tools/binance-crypto-loans/flexible-api/getRepayHistory.ts +++ b/src/tools/binance-crypto-loans/flexible-api/getRepayHistory.ts @@ -5,57 +5,55 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/flexible-api/getRepayHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { cryptoLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../../config/binanceClient.js" export function registerBinanceCryptoLoansFlexibleRepayHistory(server: McpServer) { - server.tool( - "BinanceCryptoLoansFlexibleRepayHistory", - "Get repayment history for flexible loans. Shows all past repayment transactions.", - { - loanCoin: z.string().optional() - .describe("Filter by loan coin"), - collateralCoin: z.string().optional() - .describe("Filter by collateral coin"), - startTime: z.number().int().optional() - .describe("Start timestamp in ms"), - endTime: z.number().int().optional() - .describe("End timestamp in ms"), - current: z.number().int().min(1).optional() - .describe("Current page (default 1)"), - limit: z.number().int().min(1).max(100).optional() - .describe("Results per page (max 100)"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await cryptoLoanClient.restAPI.getFlexibleLoanRepaymentHistory({ - ...(params.loanCoin && { loanCoin: params.loanCoin }), - ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.current && { current: params.current }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCryptoLoansFlexibleRepayHistory", + "Get repayment history for flexible loans. Shows all past repayment transactions.", + { + loanCoin: z.string().optional().describe("Filter by loan coin"), + collateralCoin: z.string().optional().describe("Filter by collateral coin"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + current: z.number().int().min(1).optional().describe("Current page (default 1)"), + limit: z.number().int().min(1).max(100).optional().describe("Results per page (max 100)"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await cryptoLoanClient.restAPI.getFlexibleLoanRepaymentHistory({ + ...(params.loanCoin && { loanCoin: params.loanCoin }), + ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.current && { current: params.current }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Flexible Loan Repay History:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Flexible Loan Repay History:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get repay history: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to get repay history: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/flexible-api/index.ts b/src/tools/binance-crypto-loans/flexible-api/index.ts index d8689ec3..c6e86e31 100644 --- a/src/tools/binance-crypto-loans/flexible-api/index.ts +++ b/src/tools/binance-crypto-loans/flexible-api/index.ts @@ -5,23 +5,24 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/flexible-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceCryptoLoansFlexibleAssets } from "./getFlexibleLoanAssets.js"; -import { registerBinanceCryptoLoansFlexibleCollateral } from "./getFlexibleCollateralAssets.js"; -import { registerBinanceCryptoLoansFlexibleBorrow } from "./borrow.js"; -import { registerBinanceCryptoLoansFlexibleRepay } from "./repay.js"; -import { registerBinanceCryptoLoansFlexibleAdjustLTV } from "./adjustLTV.js"; -import { registerBinanceCryptoLoansFlexibleOngoing } from "./getOngoingOrders.js"; -import { registerBinanceCryptoLoansFlexibleBorrowHistory } from "./getBorrowHistory.js"; -import { registerBinanceCryptoLoansFlexibleRepayHistory } from "./getRepayHistory.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceCryptoLoansFlexibleAdjustLTV } from "./adjustLTV.js" +import { registerBinanceCryptoLoansFlexibleBorrow } from "./borrow.js" +import { registerBinanceCryptoLoansFlexibleBorrowHistory } from "./getBorrowHistory.js" +import { registerBinanceCryptoLoansFlexibleCollateral } from "./getFlexibleCollateralAssets.js" +import { registerBinanceCryptoLoansFlexibleAssets } from "./getFlexibleLoanAssets.js" +import { registerBinanceCryptoLoansFlexibleOngoing } from "./getOngoingOrders.js" +import { registerBinanceCryptoLoansFlexibleRepayHistory } from "./getRepayHistory.js" +import { registerBinanceCryptoLoansFlexibleRepay } from "./repay.js" export function registerBinanceCryptoLoansFlexibleTools(server: McpServer) { - registerBinanceCryptoLoansFlexibleAssets(server); - registerBinanceCryptoLoansFlexibleCollateral(server); - registerBinanceCryptoLoansFlexibleBorrow(server); - registerBinanceCryptoLoansFlexibleRepay(server); - registerBinanceCryptoLoansFlexibleAdjustLTV(server); - registerBinanceCryptoLoansFlexibleOngoing(server); - registerBinanceCryptoLoansFlexibleBorrowHistory(server); - registerBinanceCryptoLoansFlexibleRepayHistory(server); + registerBinanceCryptoLoansFlexibleAssets(server) + registerBinanceCryptoLoansFlexibleCollateral(server) + registerBinanceCryptoLoansFlexibleBorrow(server) + registerBinanceCryptoLoansFlexibleRepay(server) + registerBinanceCryptoLoansFlexibleAdjustLTV(server) + registerBinanceCryptoLoansFlexibleOngoing(server) + registerBinanceCryptoLoansFlexibleBorrowHistory(server) + registerBinanceCryptoLoansFlexibleRepayHistory(server) } diff --git a/src/tools/binance-crypto-loans/flexible-api/repay.ts b/src/tools/binance-crypto-loans/flexible-api/repay.ts index 138070e7..50fab9be 100644 --- a/src/tools/binance-crypto-loans/flexible-api/repay.ts +++ b/src/tools/binance-crypto-loans/flexible-api/repay.ts @@ -5,54 +5,58 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/flexible-api/repay.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { cryptoLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../../config/binanceClient.js" export function registerBinanceCryptoLoansFlexibleRepay(server: McpServer) { - server.tool( - "BinanceCryptoLoansFlexibleRepay", - "Repay a flexible crypto loan. Repaying reduces your debt and unlocks collateral proportionally.", - { - loanCoin: z.string() - .describe("Loan coin to repay (e.g., 'USDT')"), - collateralCoin: z.string() - .describe("Collateral coin used for the loan (e.g., 'BTC')"), - repayAmount: z.string() - .describe("Amount to repay"), - collateralReturn: z.boolean().optional() - .describe("Whether to return collateral after full repayment (default: true)"), - fullRepayment: z.boolean().optional() - .describe("Whether this is a full repayment"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await cryptoLoanClient.restAPI.flexibleLoanRepay({ - loanCoin: params.loanCoin, - collateralCoin: params.collateralCoin, - repayAmount: params.repayAmount, - ...(params.collateralReturn !== undefined && { collateralReturn: params.collateralReturn }), - ...(params.fullRepayment !== undefined && { fullRepayment: params.fullRepayment }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCryptoLoansFlexibleRepay", + "Repay a flexible crypto loan. Repaying reduces your debt and unlocks collateral proportionally.", + { + loanCoin: z.string().describe("Loan coin to repay (e.g., 'USDT')"), + collateralCoin: z.string().describe("Collateral coin used for the loan (e.g., 'BTC')"), + repayAmount: z.string().describe("Amount to repay"), + collateralReturn: z + .boolean() + .optional() + .describe("Whether to return collateral after full repayment (default: true)"), + fullRepayment: z.boolean().optional().describe("Whether this is a full repayment"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await cryptoLoanClient.restAPI.flexibleLoanRepay({ + loanCoin: params.loanCoin, + collateralCoin: params.collateralCoin, + repayAmount: params.repayAmount, + ...(params.collateralReturn !== undefined && { + collateralReturn: params.collateralReturn, + }), + ...(params.fullRepayment !== undefined && { fullRepayment: params.fullRepayment }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Loan Repayment Successful!\n\nRepaid: ${params.repayAmount} ${params.loanCoin}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `✅ Loan Repayment Successful!\n\nRepaid: ${params.repayAmount} ${params.loanCoin}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to repay loan: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to repay loan: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/flexibleLoanAdjustLTV.ts b/src/tools/binance-crypto-loans/flexibleLoanAdjustLTV.ts index 0539fe8c..b56bdf52 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanAdjustLTV.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanAdjustLTV.ts @@ -1,41 +1,45 @@ // src/tools/binance-crypto-loans/flexibleLoanAdjustLTV.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { cryptoLoanClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../config/binanceClient.js" export function registerBinanceCryptoLoanFlexibleLoanAdjustLTV(server: McpServer) { - server.tool( - "BinanceCryptoLoanFlexibleLoanAdjustLTV", - "Flexible loan adjust LTV (Loan-to-Value).", - { - loanCoin: z.string().describe("Loan coin (e.g., USDT)"), - collateralCoin: z.string().describe("Collateral coin (e.g., BTC)"), - adjustmentAmount: z.number().describe("Adjustment amount"), - direction: z.enum(["ADDITIONAL", "REDUCED"]).describe("Direction: ADDITIONAL = add collateral, REDUCED = reduce collateral") - }, - async ({ loanCoin, collateralCoin, adjustmentAmount, direction }) => { - try { - const params: any = { loanCoin, collateralCoin, adjustmentAmount, direction }; - - const response = await cryptoLoanClient.restAPI.flexibleLoanAdjustLtv(params); - const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Flexible loan LTV adjusted successfully. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to adjust flexible loan LTV: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceCryptoLoanFlexibleLoanAdjustLTV", + "Flexible loan adjust LTV (Loan-to-Value).", + { + loanCoin: z.string().describe("Loan coin (e.g., USDT)"), + collateralCoin: z.string().describe("Collateral coin (e.g., BTC)"), + adjustmentAmount: z.number().describe("Adjustment amount"), + direction: z + .enum(["ADDITIONAL", "REDUCED"]) + .describe("Direction: ADDITIONAL = add collateral, REDUCED = reduce collateral"), + }, + async ({ loanCoin, collateralCoin, adjustmentAmount, direction }) => { + try { + const params: any = { loanCoin, collateralCoin, adjustmentAmount, direction } + + const response = await cryptoLoanClient.restAPI.flexibleLoanAdjustLtv(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Flexible loan LTV adjusted successfully. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to adjust flexible loan LTV: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/flexibleLoanBorrow.ts b/src/tools/binance-crypto-loans/flexibleLoanBorrow.ts index b7c7c20d..092ab391 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanBorrow.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanBorrow.ts @@ -1,43 +1,45 @@ // src/tools/binance-crypto-loans/flexibleLoanBorrow.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { cryptoLoanClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../config/binanceClient.js" export function registerBinanceCryptoLoanFlexibleLoanBorrow(server: McpServer) { - server.tool( - "BinanceCryptoLoanFlexibleLoanBorrow", - "Flexible loan borrow.", - { - loanCoin: z.string().describe("Loan coin (e.g., USDT)"), - collateralCoin: z.string().describe("Collateral coin (e.g., BTC)"), - loanAmount: z.number().optional().describe("Loan amount"), - collateralAmount: z.number().optional().describe("Collateral amount") - }, - async ({ loanCoin, collateralCoin, loanAmount, collateralAmount }) => { - try { - const params: any = { loanCoin, collateralCoin }; - if (loanAmount !== undefined) params.loanAmount = loanAmount; - if (collateralAmount !== undefined) params.collateralAmount = collateralAmount; - - const response = await cryptoLoanClient.restAPI.flexibleLoanBorrow(params); - const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Flexible loan borrowed successfully. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to borrow flexible loan: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceCryptoLoanFlexibleLoanBorrow", + "Flexible loan borrow.", + { + loanCoin: z.string().describe("Loan coin (e.g., USDT)"), + collateralCoin: z.string().describe("Collateral coin (e.g., BTC)"), + loanAmount: z.number().optional().describe("Loan amount"), + collateralAmount: z.number().optional().describe("Collateral amount"), + }, + async ({ loanCoin, collateralCoin, loanAmount, collateralAmount }) => { + try { + const params: any = { loanCoin, collateralCoin } + if (loanAmount !== undefined) params.loanAmount = loanAmount + if (collateralAmount !== undefined) params.collateralAmount = collateralAmount + + const response = await cryptoLoanClient.restAPI.flexibleLoanBorrow(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Flexible loan borrowed successfully. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to borrow flexible loan: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/flexibleLoanBorrowHistory.ts b/src/tools/binance-crypto-loans/flexibleLoanBorrowHistory.ts index 88aff89f..2e931072 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanBorrowHistory.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanBorrowHistory.ts @@ -1,49 +1,53 @@ // src/tools/binance-crypto-loans/flexibleLoanBorrowHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { cryptoLoanClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../config/binanceClient.js" export function registerBinanceCryptoLoanFlexibleLoanBorrowHistory(server: McpServer) { - server.tool( - "BinanceCryptoLoanFlexibleLoanBorrowHistory", - "Get flexible loan borrow history.", - { - loanCoin: z.string().optional().describe("Loan coin (e.g., USDT)"), - collateralCoin: z.string().optional().describe("Collateral coin (e.g., BTC)"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - current: z.number().optional().describe("Current page"), - limit: z.number().optional().describe("Page size, max 100") - }, - async ({ loanCoin, collateralCoin, startTime, endTime, current, limit }) => { - try { - const params: any = {}; - if (loanCoin) params.loanCoin = loanCoin; - if (collateralCoin) params.collateralCoin = collateralCoin; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (current !== undefined) params.current = current; - if (limit !== undefined) params.limit = limit; - - const response = await cryptoLoanClient.restAPI.flexibleLoanBorrowHistory(params); - const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Flexible loan borrow history retrieved. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get flexible loan borrow history: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceCryptoLoanFlexibleLoanBorrowHistory", + "Get flexible loan borrow history.", + { + loanCoin: z.string().optional().describe("Loan coin (e.g., USDT)"), + collateralCoin: z.string().optional().describe("Collateral coin (e.g., BTC)"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + current: z.number().optional().describe("Current page"), + limit: z.number().optional().describe("Page size, max 100"), + }, + async ({ loanCoin, collateralCoin, startTime, endTime, current, limit }) => { + try { + const params: any = {} + if (loanCoin) params.loanCoin = loanCoin + if (collateralCoin) params.collateralCoin = collateralCoin + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (current !== undefined) params.current = current + if (limit !== undefined) params.limit = limit + + const response = await cryptoLoanClient.restAPI.flexibleLoanBorrowHistory(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Flexible loan borrow history retrieved. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to get flexible loan borrow history: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/flexibleLoanCollateralAssets.ts b/src/tools/binance-crypto-loans/flexibleLoanCollateralAssets.ts index 5bcf949f..d737df5a 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanCollateralAssets.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanCollateralAssets.ts @@ -1,39 +1,46 @@ // src/tools/binance-crypto-loans/flexibleLoanCollateralAssets.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { cryptoLoanClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../config/binanceClient.js" export function registerBinanceCryptoLoanFlexibleLoanCollateralAssets(server: McpServer) { - server.tool( - "BinanceCryptoLoanFlexibleLoanCollateralAssets", - "Get flexible loan collateral assets.", - { - collateralCoin: z.string().optional().describe("Collateral coin (e.g., BTC)") - }, - async ({ collateralCoin }) => { - try { - const params: any = {}; - if (collateralCoin) params.collateralCoin = collateralCoin; - - const response = await cryptoLoanClient.restAPI.getFlexibleLoanCollateralAssetsData(params); - const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Flexible loan collateral assets retrieved. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get flexible loan collateral assets: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceCryptoLoanFlexibleLoanCollateralAssets", + "Get flexible loan collateral assets.", + { + collateralCoin: z.string().optional().describe("Collateral coin (e.g., BTC)"), + }, + async ({ collateralCoin }) => { + try { + const params: any = {} + if (collateralCoin) params.collateralCoin = collateralCoin + + const response = await cryptoLoanClient.restAPI.getFlexibleLoanCollateralAssetsData(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Flexible loan collateral assets retrieved. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `Failed to get flexible loan collateral assets: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/flexibleLoanLTVAdjustmentHistory.ts b/src/tools/binance-crypto-loans/flexibleLoanLTVAdjustmentHistory.ts index 822c7020..caee4efb 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanLTVAdjustmentHistory.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanLTVAdjustmentHistory.ts @@ -1,49 +1,56 @@ // src/tools/binance-crypto-loans/flexibleLoanLTVAdjustmentHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { cryptoLoanClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../config/binanceClient.js" export function registerBinanceCryptoLoanFlexibleLoanLTVAdjustmentHistory(server: McpServer) { - server.tool( - "BinanceCryptoLoanFlexibleLoanLTVAdjustmentHistory", - "Get flexible loan LTV adjustment history.", - { - loanCoin: z.string().optional().describe("Loan coin (e.g., USDT)"), - collateralCoin: z.string().optional().describe("Collateral coin (e.g., BTC)"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - current: z.number().optional().describe("Current page"), - limit: z.number().optional().describe("Page size, max 100") - }, - async ({ loanCoin, collateralCoin, startTime, endTime, current, limit }) => { - try { - const params: any = {}; - if (loanCoin) params.loanCoin = loanCoin; - if (collateralCoin) params.collateralCoin = collateralCoin; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (current !== undefined) params.current = current; - if (limit !== undefined) params.limit = limit; - - const response = await cryptoLoanClient.restAPI.getFlexibleLoanLtvAdjustmentHistory(params); - const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Flexible loan LTV adjustment history retrieved. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get flexible loan LTV adjustment history: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceCryptoLoanFlexibleLoanLTVAdjustmentHistory", + "Get flexible loan LTV adjustment history.", + { + loanCoin: z.string().optional().describe("Loan coin (e.g., USDT)"), + collateralCoin: z.string().optional().describe("Collateral coin (e.g., BTC)"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + current: z.number().optional().describe("Current page"), + limit: z.number().optional().describe("Page size, max 100"), + }, + async ({ loanCoin, collateralCoin, startTime, endTime, current, limit }) => { + try { + const params: any = {} + if (loanCoin) params.loanCoin = loanCoin + if (collateralCoin) params.collateralCoin = collateralCoin + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (current !== undefined) params.current = current + if (limit !== undefined) params.limit = limit + + const response = await cryptoLoanClient.restAPI.getFlexibleLoanLtvAdjustmentHistory(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Flexible loan LTV adjustment history retrieved. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `Failed to get flexible loan LTV adjustment history: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/flexibleLoanLoanableAssets.ts b/src/tools/binance-crypto-loans/flexibleLoanLoanableAssets.ts index d7fb8897..1c2d6268 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanLoanableAssets.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanLoanableAssets.ts @@ -1,33 +1,41 @@ // src/tools/binance-crypto-loans/flexibleLoanLoanableAssets.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { cryptoLoanClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../config/binanceClient.js" export function registerBinanceCryptoLoanFlexibleLoanableAssets(server: McpServer) { - server.tool( - "BinanceCryptoLoanFlexibleLoanableAssets", - "Get flexible loan loanable assets data.", - { - loanCoin: z.string().optional().describe("Loan coin"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await cryptoLoanClient.restAPI.getFlexibleLoanAssets({ - ...(params.loanCoin && { loanCoin: params.loanCoin }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); - return { - content: [{ type: "text", text: `Flexible loan loanable assets: ${JSON.stringify(data)}` }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get flexible loan loanable assets: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceCryptoLoanFlexibleLoanableAssets", + "Get flexible loan loanable assets data.", + { + loanCoin: z.string().optional().describe("Loan coin"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await cryptoLoanClient.restAPI.getFlexibleLoanAssets({ + ...(params.loanCoin && { loanCoin: params.loanCoin }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { type: "text", text: `Flexible loan loanable assets: ${JSON.stringify(data)}` }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to get flexible loan loanable assets: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/flexibleLoanOngoingOrders.ts b/src/tools/binance-crypto-loans/flexibleLoanOngoingOrders.ts index 87b3dab8..4916268e 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanOngoingOrders.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanOngoingOrders.ts @@ -1,45 +1,49 @@ // src/tools/binance-crypto-loans/flexibleLoanOngoingOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { cryptoLoanClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../config/binanceClient.js" export function registerBinanceCryptoLoanFlexibleLoanOngoingOrders(server: McpServer) { - server.tool( - "BinanceCryptoLoanFlexibleLoanOngoingOrders", - "Get flexible loan ongoing orders.", - { - loanCoin: z.string().optional().describe("Loan coin (e.g., USDT)"), - collateralCoin: z.string().optional().describe("Collateral coin (e.g., BTC)"), - current: z.number().optional().describe("Current page"), - limit: z.number().optional().describe("Page size, max 100") - }, - async ({ loanCoin, collateralCoin, current, limit }) => { - try { - const params: any = {}; - if (loanCoin) params.loanCoin = loanCoin; - if (collateralCoin) params.collateralCoin = collateralCoin; - if (current !== undefined) params.current = current; - if (limit !== undefined) params.limit = limit; - - const response = await cryptoLoanClient.restAPI.flexibleLoanOngoingOrders(params); - const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Flexible loan ongoing orders retrieved. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get flexible loan ongoing orders: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceCryptoLoanFlexibleLoanOngoingOrders", + "Get flexible loan ongoing orders.", + { + loanCoin: z.string().optional().describe("Loan coin (e.g., USDT)"), + collateralCoin: z.string().optional().describe("Collateral coin (e.g., BTC)"), + current: z.number().optional().describe("Current page"), + limit: z.number().optional().describe("Page size, max 100"), + }, + async ({ loanCoin, collateralCoin, current, limit }) => { + try { + const params: any = {} + if (loanCoin) params.loanCoin = loanCoin + if (collateralCoin) params.collateralCoin = collateralCoin + if (current !== undefined) params.current = current + if (limit !== undefined) params.limit = limit + + const response = await cryptoLoanClient.restAPI.flexibleLoanOngoingOrders(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Flexible loan ongoing orders retrieved. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to get flexible loan ongoing orders: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/flexibleLoanRepay.ts b/src/tools/binance-crypto-loans/flexibleLoanRepay.ts index 2c69ffa1..e854bfa9 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanRepay.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanRepay.ts @@ -1,44 +1,46 @@ // src/tools/binance-crypto-loans/flexibleLoanRepay.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { cryptoLoanClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../config/binanceClient.js" export function registerBinanceCryptoLoanFlexibleLoanRepay(server: McpServer) { - server.tool( - "BinanceCryptoLoanFlexibleLoanRepay", - "Flexible loan repay.", - { - loanCoin: z.string().describe("Loan coin (e.g., USDT)"), - collateralCoin: z.string().describe("Collateral coin (e.g., BTC)"), - repayAmount: z.number().describe("Repay amount"), - collateralReturn: z.boolean().optional().describe("Whether to return collateral"), - fullRepayment: z.boolean().optional().describe("Whether to do full repayment") - }, - async ({ loanCoin, collateralCoin, repayAmount, collateralReturn, fullRepayment }) => { - try { - const params: any = { loanCoin, collateralCoin, repayAmount }; - if (collateralReturn !== undefined) params.collateralReturn = collateralReturn; - if (fullRepayment !== undefined) params.fullRepayment = fullRepayment; - - const response = await cryptoLoanClient.restAPI.flexibleLoanRepay(params); - const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Flexible loan repaid successfully. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to repay flexible loan: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceCryptoLoanFlexibleLoanRepay", + "Flexible loan repay.", + { + loanCoin: z.string().describe("Loan coin (e.g., USDT)"), + collateralCoin: z.string().describe("Collateral coin (e.g., BTC)"), + repayAmount: z.number().describe("Repay amount"), + collateralReturn: z.boolean().optional().describe("Whether to return collateral"), + fullRepayment: z.boolean().optional().describe("Whether to do full repayment"), + }, + async ({ loanCoin, collateralCoin, repayAmount, collateralReturn, fullRepayment }) => { + try { + const params: any = { loanCoin, collateralCoin, repayAmount } + if (collateralReturn !== undefined) params.collateralReturn = collateralReturn + if (fullRepayment !== undefined) params.fullRepayment = fullRepayment + + const response = await cryptoLoanClient.restAPI.flexibleLoanRepay(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Flexible loan repaid successfully. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to repay flexible loan: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/flexibleLoanRepayHistory.ts b/src/tools/binance-crypto-loans/flexibleLoanRepayHistory.ts index 8f81bc33..92f1a8cd 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanRepayHistory.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanRepayHistory.ts @@ -1,49 +1,53 @@ // src/tools/binance-crypto-loans/flexibleLoanRepayHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { cryptoLoanClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../config/binanceClient.js" export function registerBinanceCryptoLoanFlexibleLoanRepayHistory(server: McpServer) { - server.tool( - "BinanceCryptoLoanFlexibleLoanRepayHistory", - "Get flexible loan repayment history.", - { - loanCoin: z.string().optional().describe("Loan coin (e.g., USDT)"), - collateralCoin: z.string().optional().describe("Collateral coin (e.g., BTC)"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - current: z.number().optional().describe("Current page"), - limit: z.number().optional().describe("Page size, max 100") - }, - async ({ loanCoin, collateralCoin, startTime, endTime, current, limit }) => { - try { - const params: any = {}; - if (loanCoin) params.loanCoin = loanCoin; - if (collateralCoin) params.collateralCoin = collateralCoin; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (current !== undefined) params.current = current; - if (limit !== undefined) params.limit = limit; - - const response = await cryptoLoanClient.restAPI.flexibleLoanRepaymentHistory(params); - const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Flexible loan repay history retrieved. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get flexible loan repay history: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceCryptoLoanFlexibleLoanRepayHistory", + "Get flexible loan repayment history.", + { + loanCoin: z.string().optional().describe("Loan coin (e.g., USDT)"), + collateralCoin: z.string().optional().describe("Collateral coin (e.g., BTC)"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + current: z.number().optional().describe("Current page"), + limit: z.number().optional().describe("Page size, max 100"), + }, + async ({ loanCoin, collateralCoin, startTime, endTime, current, limit }) => { + try { + const params: any = {} + if (loanCoin) params.loanCoin = loanCoin + if (collateralCoin) params.collateralCoin = collateralCoin + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (current !== undefined) params.current = current + if (limit !== undefined) params.limit = limit + + const response = await cryptoLoanClient.restAPI.flexibleLoanRepaymentHistory(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Flexible loan repay history retrieved. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to get flexible loan repay history: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/getCollateralAssetsData.ts b/src/tools/binance-crypto-loans/getCollateralAssetsData.ts index 186ffa3f..a386428e 100644 --- a/src/tools/binance-crypto-loans/getCollateralAssetsData.ts +++ b/src/tools/binance-crypto-loans/getCollateralAssetsData.ts @@ -1,41 +1,45 @@ // src/tools/binance-crypto-loans/getCollateralAssetsData.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { cryptoLoanClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../config/binanceClient.js" export function registerBinanceCryptoLoanGetCollateralAssetsDataV2(server: McpServer) { - server.tool( - "BinanceCryptoLoanGetCollateralAssetsDataV2", - "Get collateral assets data V2 for flexible crypto loans.", - { - collateralCoin: z.string().optional().describe("Collateral coin (e.g., BTC)"), - vipLevel: z.number().optional().describe("VIP level") - }, - async ({ collateralCoin, vipLevel }) => { - try { - const params: any = {}; - if (collateralCoin) params.collateralCoin = collateralCoin; - if (vipLevel !== undefined) params.vipLevel = vipLevel; - - const response = await cryptoLoanClient.restAPI.getFlexibleLoanCollateralAssetsData(params); - const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Collateral assets data V2 retrieved. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get collateral assets data V2: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceCryptoLoanGetCollateralAssetsDataV2", + "Get collateral assets data V2 for flexible crypto loans.", + { + collateralCoin: z.string().optional().describe("Collateral coin (e.g., BTC)"), + vipLevel: z.number().optional().describe("VIP level"), + }, + async ({ collateralCoin, vipLevel }) => { + try { + const params: any = {} + if (collateralCoin) params.collateralCoin = collateralCoin + if (vipLevel !== undefined) params.vipLevel = vipLevel + + const response = await cryptoLoanClient.restAPI.getFlexibleLoanCollateralAssetsData(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Collateral assets data V2 retrieved. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to get collateral assets data V2: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/getCollateralRepayRate.ts b/src/tools/binance-crypto-loans/getCollateralRepayRate.ts index 7bf37688..6fdbbf37 100644 --- a/src/tools/binance-crypto-loans/getCollateralRepayRate.ts +++ b/src/tools/binance-crypto-loans/getCollateralRepayRate.ts @@ -1,40 +1,42 @@ // src/tools/binance-crypto-loans/getCollateralRepayRate.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { cryptoLoanClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../config/binanceClient.js" export function registerBinanceCryptoLoanGetCollateralRepayRate(server: McpServer) { - server.tool( - "BinanceCryptoLoanGetCollateralRepayRate", - "Check collateral repay rate for crypto loans.", - { - loanCoin: z.string().describe("Loan coin (e.g., USDT)"), - collateralCoin: z.string().describe("Collateral coin (e.g., BTC)"), - repayAmount: z.number().describe("Repay amount") - }, - async ({ loanCoin, collateralCoin, repayAmount }) => { - try { - const params: any = { loanCoin, collateralCoin, repayAmount }; - - const response = await cryptoLoanClient.restAPI.checkCollateralRepayRate(params); - const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Collateral repay rate retrieved. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get collateral repay rate: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceCryptoLoanGetCollateralRepayRate", + "Check collateral repay rate for crypto loans.", + { + loanCoin: z.string().describe("Loan coin (e.g., USDT)"), + collateralCoin: z.string().describe("Collateral coin (e.g., BTC)"), + repayAmount: z.number().describe("Repay amount"), + }, + async ({ loanCoin, collateralCoin, repayAmount }) => { + try { + const params: any = { loanCoin, collateralCoin, repayAmount } + + const response = await cryptoLoanClient.restAPI.checkCollateralRepayRate(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Collateral repay rate retrieved. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get collateral repay rate: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/getLoanableAssetsData.ts b/src/tools/binance-crypto-loans/getLoanableAssetsData.ts index 3201bb41..3e0939f7 100644 --- a/src/tools/binance-crypto-loans/getLoanableAssetsData.ts +++ b/src/tools/binance-crypto-loans/getLoanableAssetsData.ts @@ -1,41 +1,45 @@ // src/tools/binance-crypto-loans/getLoanableAssetsData.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { cryptoLoanClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { cryptoLoanClient } from "../../config/binanceClient.js" export function registerBinanceCryptoLoanGetLoanableAssetsDataV2(server: McpServer) { - server.tool( - "BinanceCryptoLoanGetLoanableAssetsDataV2", - "Get loanable assets data V2 for flexible crypto loans.", - { - loanCoin: z.string().optional().describe("Loan coin (e.g., USDT)"), - vipLevel: z.number().optional().describe("VIP level") - }, - async ({ loanCoin, vipLevel }) => { - try { - const params: any = {}; - if (loanCoin) params.loanCoin = loanCoin; - if (vipLevel !== undefined) params.vipLevel = vipLevel; - - const response = await cryptoLoanClient.restAPI.getFlexibleLoanAssetsData(params); - const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Loanable assets data V2 retrieved. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get loanable assets data V2: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceCryptoLoanGetLoanableAssetsDataV2", + "Get loanable assets data V2 for flexible crypto loans.", + { + loanCoin: z.string().optional().describe("Loan coin (e.g., USDT)"), + vipLevel: z.number().optional().describe("VIP level"), + }, + async ({ loanCoin, vipLevel }) => { + try { + const params: any = {} + if (loanCoin) params.loanCoin = loanCoin + if (vipLevel !== undefined) params.vipLevel = vipLevel + + const response = await cryptoLoanClient.restAPI.getFlexibleLoanAssetsData(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Loanable assets data V2 retrieved. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to get loanable assets data V2: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-crypto-loans/index.ts b/src/tools/binance-crypto-loans/index.ts index d9fffb47..708155b9 100644 --- a/src/tools/binance-crypto-loans/index.ts +++ b/src/tools/binance-crypto-loans/index.ts @@ -1,40 +1,38 @@ // src/tools/binance-crypto-loans/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; - -// Crypto Loans - Info -import { registerBinanceCryptoLoanGetCollateralRepayRate } from "./getCollateralRepayRate.js"; -import { registerBinanceCryptoLoanGetLoanableAssetsDataV2 } from "./getLoanableAssetsData.js"; -import { registerBinanceCryptoLoanGetCollateralAssetsDataV2 } from "./getCollateralAssetsData.js"; -import { registerBinanceCryptoLoanFlexibleLoanCollateralAssets } from "./flexibleLoanCollateralAssets.js"; -import { registerBinanceCryptoLoanFlexibleLoanableAssets } from "./flexibleLoanLoanableAssets.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import { registerBinanceCryptoLoanFlexibleLoanAdjustLTV } from "./flexibleLoanAdjustLTV.js" // Crypto Loans - Trading -import { registerBinanceCryptoLoanFlexibleLoanBorrow } from "./flexibleLoanBorrow.js"; -import { registerBinanceCryptoLoanFlexibleLoanRepay } from "./flexibleLoanRepay.js"; -import { registerBinanceCryptoLoanFlexibleLoanAdjustLTV } from "./flexibleLoanAdjustLTV.js"; - +import { registerBinanceCryptoLoanFlexibleLoanBorrow } from "./flexibleLoanBorrow.js" +import { registerBinanceCryptoLoanFlexibleLoanBorrowHistory } from "./flexibleLoanBorrowHistory.js" +import { registerBinanceCryptoLoanFlexibleLoanCollateralAssets } from "./flexibleLoanCollateralAssets.js" +import { registerBinanceCryptoLoanFlexibleLoanableAssets } from "./flexibleLoanLoanableAssets.js" +import { registerBinanceCryptoLoanFlexibleLoanLTVAdjustmentHistory } from "./flexibleLoanLTVAdjustmentHistory.js" // Crypto Loans - History -import { registerBinanceCryptoLoanFlexibleLoanOngoingOrders } from "./flexibleLoanOngoingOrders.js"; -import { registerBinanceCryptoLoanFlexibleLoanBorrowHistory } from "./flexibleLoanBorrowHistory.js"; -import { registerBinanceCryptoLoanFlexibleLoanRepayHistory } from "./flexibleLoanRepayHistory.js"; -import { registerBinanceCryptoLoanFlexibleLoanLTVAdjustmentHistory } from "./flexibleLoanLTVAdjustmentHistory.js"; +import { registerBinanceCryptoLoanFlexibleLoanOngoingOrders } from "./flexibleLoanOngoingOrders.js" +import { registerBinanceCryptoLoanFlexibleLoanRepay } from "./flexibleLoanRepay.js" +import { registerBinanceCryptoLoanFlexibleLoanRepayHistory } from "./flexibleLoanRepayHistory.js" +import { registerBinanceCryptoLoanGetCollateralAssetsDataV2 } from "./getCollateralAssetsData.js" +// Crypto Loans - Info +import { registerBinanceCryptoLoanGetCollateralRepayRate } from "./getCollateralRepayRate.js" +import { registerBinanceCryptoLoanGetLoanableAssetsDataV2 } from "./getLoanableAssetsData.js" export function registerBinanceCryptoLoansTools(server: McpServer) { - // Crypto Loans - Info - registerBinanceCryptoLoanGetCollateralRepayRate(server); - registerBinanceCryptoLoanGetLoanableAssetsDataV2(server); - registerBinanceCryptoLoanGetCollateralAssetsDataV2(server); - registerBinanceCryptoLoanFlexibleLoanCollateralAssets(server); - registerBinanceCryptoLoanFlexibleLoanableAssets(server); - - // Crypto Loans - Trading - registerBinanceCryptoLoanFlexibleLoanBorrow(server); - registerBinanceCryptoLoanFlexibleLoanRepay(server); - registerBinanceCryptoLoanFlexibleLoanAdjustLTV(server); - - // Crypto Loans - History - registerBinanceCryptoLoanFlexibleLoanOngoingOrders(server); - registerBinanceCryptoLoanFlexibleLoanBorrowHistory(server); - registerBinanceCryptoLoanFlexibleLoanRepayHistory(server); - registerBinanceCryptoLoanFlexibleLoanLTVAdjustmentHistory(server); + // Crypto Loans - Info + registerBinanceCryptoLoanGetCollateralRepayRate(server) + registerBinanceCryptoLoanGetLoanableAssetsDataV2(server) + registerBinanceCryptoLoanGetCollateralAssetsDataV2(server) + registerBinanceCryptoLoanFlexibleLoanCollateralAssets(server) + registerBinanceCryptoLoanFlexibleLoanableAssets(server) + + // Crypto Loans - Trading + registerBinanceCryptoLoanFlexibleLoanBorrow(server) + registerBinanceCryptoLoanFlexibleLoanRepay(server) + registerBinanceCryptoLoanFlexibleLoanAdjustLTV(server) + + // Crypto Loans - History + registerBinanceCryptoLoanFlexibleLoanOngoingOrders(server) + registerBinanceCryptoLoanFlexibleLoanBorrowHistory(server) + registerBinanceCryptoLoanFlexibleLoanRepayHistory(server) + registerBinanceCryptoLoanFlexibleLoanLTVAdjustmentHistory(server) } diff --git a/src/tools/binance-dual-investment/index.ts b/src/tools/binance-dual-investment/index.ts index 47e151ea..94c1369c 100644 --- a/src/tools/binance-dual-investment/index.ts +++ b/src/tools/binance-dual-investment/index.ts @@ -1,9 +1,10 @@ // src/tools/binance-dual-investment/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceDualInvestmentTradeApiTools } from "./trade-api/index.js"; -import { registerBinanceDualInvestmentMarketApiTools } from "./market-api/index.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceDualInvestmentMarketApiTools } from "./market-api/index.js" +import { registerBinanceDualInvestmentTradeApiTools } from "./trade-api/index.js" export function registerBinanceDualInvestmentTools(server: McpServer) { - registerBinanceDualInvestmentTradeApiTools(server); - registerBinanceDualInvestmentMarketApiTools(server); + registerBinanceDualInvestmentTradeApiTools(server) + registerBinanceDualInvestmentMarketApiTools(server) } diff --git a/src/tools/binance-dual-investment/market-api/getDualInvestmentProductList.ts b/src/tools/binance-dual-investment/market-api/getDualInvestmentProductList.ts index 048f342d..b9d20a31 100644 --- a/src/tools/binance-dual-investment/market-api/getDualInvestmentProductList.ts +++ b/src/tools/binance-dual-investment/market-api/getDualInvestmentProductList.ts @@ -1,66 +1,69 @@ // src/tools/binance-dual-investment/market-api/getDualInvestmentProductList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { dualInvestmentClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { dualInvestmentClient } from "../../../config/binanceClient.js" export function registerBinanceGetDualInvestmentProductList(server: McpServer) { - server.tool( - "BinanceGetDualInvestmentProductList", - "Retrieve available Dual Investment products (CALL or PUT options), specifying invest and exercised coins, to view details like APR, strike price, duration, and purchase availability.", - { - optionType: z.enum(["CALL", "PUT"]).describe("Input CALL or PUT"), - exercisedCoin: z.string().describe("Target exercised asset, e.g., USDT or BNB"), - investCoin: z.string().describe("Asset used for subscribing, e.g., BNB or USDT"), - pageSize: z - .number() - .int() - .max(100, "Maximum pageSize is 100") - .default(10) - .optional() - .describe("Number of records per page, default 10, max 100"), - pageIndex: z.number().int().default(1).optional().describe("Page index, default is 1"), - recvWindow: z - .number() - .int() - .max(60000, "recvWindow cannot be greater than 60000") - .optional() - .describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await dualInvestmentClient.restAPI.getDualInvestmentProductList({ - optionType: params.optionType, - exercisedCoin: params.exercisedCoin, - investCoin: params.investCoin, - ...(params.pageSize && { pageSize: params.pageSize }), - ...(params.pageIndex && { pageIndex: params.pageIndex }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetDualInvestmentProductList", + "Retrieve available Dual Investment products (CALL or PUT options), specifying invest and exercised coins, to view details like APR, strike price, duration, and purchase availability.", + { + optionType: z.enum(["CALL", "PUT"]).describe("Input CALL or PUT"), + exercisedCoin: z.string().describe("Target exercised asset, e.g., USDT or BNB"), + investCoin: z.string().describe("Asset used for subscribing, e.g., BNB or USDT"), + pageSize: z + .number() + .int() + .max(100, "Maximum pageSize is 100") + .default(10) + .optional() + .describe("Number of records per page, default 10, max 100"), + pageIndex: z.number().int().default(1).optional().describe("Page index, default is 1"), + recvWindow: z + .number() + .int() + .max(60000, "recvWindow cannot be greater than 60000") + .optional() + .describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await dualInvestmentClient.restAPI.getDualInvestmentProductList({ + optionType: params.optionType, + exercisedCoin: params.exercisedCoin, + investCoin: params.investCoin, + ...(params.pageSize && { pageSize: params.pageSize }), + ...(params.pageIndex && { pageIndex: params.pageIndex }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved available Dual Investment products. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved available Dual Investment products. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve available Dual Investment products: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve available Dual Investment products: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-dual-investment/market-api/index.ts b/src/tools/binance-dual-investment/market-api/index.ts index 5b6b81f2..b2d90200 100644 --- a/src/tools/binance-dual-investment/market-api/index.ts +++ b/src/tools/binance-dual-investment/market-api/index.ts @@ -1,7 +1,8 @@ // src/tools/binance-dual-investment/market-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetDualInvestmentProductList } from "./getDualInvestmentProductList.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceGetDualInvestmentProductList } from "./getDualInvestmentProductList.js" export function registerBinanceDualInvestmentMarketApiTools(server: McpServer) { - registerBinanceGetDualInvestmentProductList(server); + registerBinanceGetDualInvestmentProductList(server) } diff --git a/src/tools/binance-dual-investment/trade-api/changeAutoCompoundStatus.ts b/src/tools/binance-dual-investment/trade-api/changeAutoCompoundStatus.ts index 8904f7b9..b47051eb 100644 --- a/src/tools/binance-dual-investment/trade-api/changeAutoCompoundStatus.ts +++ b/src/tools/binance-dual-investment/trade-api/changeAutoCompoundStatus.ts @@ -1,57 +1,60 @@ // src/tools/binance-dual-investment/trade-api/changeAutoCompoundStatus.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { dualInvestmentClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { dualInvestmentClient } from "../../../config/binanceClient.js" export function registerBinanceChangeAutoCompoundStatus(server: McpServer) { - server.tool( - "registerBinanceChangeAutoCompoundStatus", - "Change the Auto-Compound plan for a Dual Investment position to NONE, STANDARD, or ADVANCED using the position ID.", - { - positionId: z.string().describe("Get positionId from /sapi/v1/dci/product/positions"), - autoCompoundPlan: z - .enum(["NONE", "STANDARD", "ADVANCED"]) - .optional() - .describe("Auto compound plan: NONE, STANDARD, or ADVANCED"), - recvWindow: z - .number() - .int() - .max(60000) - .optional() - .describe("Optional time window for request validity (max 60000)") - }, - async (params) => { - try { - const response = await dualInvestmentClient.restAPI.changeAutoCompoundStatus({ - positionId: params.positionId, - autoCompoundPlan: params.autoCompoundPlan, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "registerBinanceChangeAutoCompoundStatus", + "Change the Auto-Compound plan for a Dual Investment position to NONE, STANDARD, or ADVANCED using the position ID.", + { + positionId: z.string().describe("Get positionId from /sapi/v1/dci/product/positions"), + autoCompoundPlan: z + .enum(["NONE", "STANDARD", "ADVANCED"]) + .optional() + .describe("Auto compound plan: NONE, STANDARD, or ADVANCED"), + recvWindow: z + .number() + .int() + .max(60000) + .optional() + .describe("Optional time window for request validity (max 60000)"), + }, + async (params) => { + try { + const response = await dualInvestmentClient.restAPI.changeAutoCompoundStatus({ + positionId: params.positionId, + autoCompoundPlan: params.autoCompoundPlan, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully Changed the Auto-Compound plan for a Dual Investment position. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully Changed the Auto-Compound plan for a Dual Investment position. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to change the Auto-Compound plan for a Dual Investment position: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to change the Auto-Compound plan for a Dual Investment position: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-dual-investment/trade-api/checkDualInvestmentAccounts.ts b/src/tools/binance-dual-investment/trade-api/checkDualInvestmentAccounts.ts index 0026a009..a37c71f5 100644 --- a/src/tools/binance-dual-investment/trade-api/checkDualInvestmentAccounts.ts +++ b/src/tools/binance-dual-investment/trade-api/checkDualInvestmentAccounts.ts @@ -1,50 +1,53 @@ // src/tools/binance-dual-investment/trade-api/checkDualInvestmentAccounts.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { dualInvestmentClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { dualInvestmentClient } from "../../../config/binanceClient.js" export function registerBinanceCheckDualInvestmentAccounts(server: McpServer) { - server.tool( - "BinanceCheckDualInvestmentAccounts", - "Retrieve Dual Investment account balances, including total value in BTC and USDT equivalents.", - { - recvWindow: z - .number() - .int() - .max(60000) - .optional() - .describe("Optional time window for request validity (max 60000)") - }, - async (params) => { - try { - const response = await dualInvestmentClient.restAPI.checkDualInvestmentAccounts({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCheckDualInvestmentAccounts", + "Retrieve Dual Investment account balances, including total value in BTC and USDT equivalents.", + { + recvWindow: z + .number() + .int() + .max(60000) + .optional() + .describe("Optional time window for request validity (max 60000)"), + }, + async (params) => { + try { + const response = await dualInvestmentClient.restAPI.checkDualInvestmentAccounts({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieve Dual Investment account balances, including total value in BTC and USDT equivalents. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieve Dual Investment account balances, including total value in BTC and USDT equivalents. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve Dual Investment account balances: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve Dual Investment account balances: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-dual-investment/trade-api/getDualInvestmentPositions.ts b/src/tools/binance-dual-investment/trade-api/getDualInvestmentPositions.ts index 824c169e..8a24b7b8 100644 --- a/src/tools/binance-dual-investment/trade-api/getDualInvestmentPositions.ts +++ b/src/tools/binance-dual-investment/trade-api/getDualInvestmentPositions.ts @@ -1,75 +1,78 @@ // src/tools/binance-dual-investment/trade-api/getDualInvestmentPositions.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { dualInvestmentClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { dualInvestmentClient } from "../../../config/binanceClient.js" export function registerBinanceGetDualInvestmentPositions(server: McpServer) { - server.tool( - "BinanceGetDualInvestmentPositions", - "Fetch Dual Investment positions in batch, including status, subscription details, APR, and settlement info. Filter by status or paginate results.", - { - status: z - .enum([ - "PENDING", - "PURCHASE_SUCCESS", - "SETTLED", - "PURCHASE_FAIL", - "REFUNDING", - "REFUND_SUCCESS", - "SETTLING" - ]) - .optional() - .describe( - "Position status: PENDING (awaiting results), PURCHASE_SUCCESS, SETTLED, PURCHASE_FAIL, REFUNDING, REFUND_SUCCESS, or SETTLING. If not provided, returns all." - ), - pageSize: z - .number() - .int() - .min(1) - .max(100) - .optional() - .describe("Number of items per page, default 10, max 100"), - pageIndex: z.number().int().min(1).optional().describe("Page index, default 1"), - recvWindow: z - .number() - .int() - .max(60000) - .optional() - .describe("Optional time window for request validity (max 60000)") - }, - async (params) => { - try { - const response = await dualInvestmentClient.restAPI.getDualInvestmentPositions({ - ...(params.status && { status: params.status }), - ...(params.pageSize && { pageSize: params.pageSize }), - ...(params.pageIndex && { pageIndex: params.pageIndex }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetDualInvestmentPositions", + "Fetch Dual Investment positions in batch, including status, subscription details, APR, and settlement info. Filter by status or paginate results.", + { + status: z + .enum([ + "PENDING", + "PURCHASE_SUCCESS", + "SETTLED", + "PURCHASE_FAIL", + "REFUNDING", + "REFUND_SUCCESS", + "SETTLING", + ]) + .optional() + .describe( + "Position status: PENDING (awaiting results), PURCHASE_SUCCESS, SETTLED, PURCHASE_FAIL, REFUNDING, REFUND_SUCCESS, or SETTLING. If not provided, returns all.", + ), + pageSize: z + .number() + .int() + .min(1) + .max(100) + .optional() + .describe("Number of items per page, default 10, max 100"), + pageIndex: z.number().int().min(1).optional().describe("Page index, default 1"), + recvWindow: z + .number() + .int() + .max(60000) + .optional() + .describe("Optional time window for request validity (max 60000)"), + }, + async (params) => { + try { + const response = await dualInvestmentClient.restAPI.getDualInvestmentPositions({ + ...(params.status && { status: params.status }), + ...(params.pageSize && { pageSize: params.pageSize }), + ...(params.pageIndex && { pageIndex: params.pageIndex }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully Fetched Dual Investment positions in batch, including status, subscription details, APR, and settlement info. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully Fetched Dual Investment positions in batch, including status, subscription details, APR, and settlement info. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to fetch dual investment positions: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to fetch dual investment positions: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-dual-investment/trade-api/index.ts b/src/tools/binance-dual-investment/trade-api/index.ts index 5e0692bf..157890bc 100644 --- a/src/tools/binance-dual-investment/trade-api/index.ts +++ b/src/tools/binance-dual-investment/trade-api/index.ts @@ -1,13 +1,14 @@ // src/tools/binance-dual-investment/trade-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceSubscribeDualInvestmentProducts } from "./subscribeDualInvestmentProducts.js"; -import { registerBinanceCheckDualInvestmentAccounts } from "./checkDualInvestmentAccounts.js"; -import { registerBinanceGetDualInvestmentPositions } from "./getDualInvestmentPositions.js"; -import { registerBinanceChangeAutoCompoundStatus } from "./changeAutoCompoundStatus.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceChangeAutoCompoundStatus } from "./changeAutoCompoundStatus.js" +import { registerBinanceCheckDualInvestmentAccounts } from "./checkDualInvestmentAccounts.js" +import { registerBinanceGetDualInvestmentPositions } from "./getDualInvestmentPositions.js" +import { registerBinanceSubscribeDualInvestmentProducts } from "./subscribeDualInvestmentProducts.js" export function registerBinanceDualInvestmentTradeApiTools(server: McpServer) { - registerBinanceSubscribeDualInvestmentProducts(server); - registerBinanceCheckDualInvestmentAccounts(server); - registerBinanceGetDualInvestmentPositions(server); - registerBinanceChangeAutoCompoundStatus(server); + registerBinanceSubscribeDualInvestmentProducts(server) + registerBinanceCheckDualInvestmentAccounts(server) + registerBinanceGetDualInvestmentPositions(server) + registerBinanceChangeAutoCompoundStatus(server) } diff --git a/src/tools/binance-dual-investment/trade-api/subscribeDualInvestmentProducts.ts b/src/tools/binance-dual-investment/trade-api/subscribeDualInvestmentProducts.ts index 36fa6626..41221ba1 100644 --- a/src/tools/binance-dual-investment/trade-api/subscribeDualInvestmentProducts.ts +++ b/src/tools/binance-dual-investment/trade-api/subscribeDualInvestmentProducts.ts @@ -1,60 +1,63 @@ // src/tools/binance-dual-investment/trade-api/subscribeDualInvestmentProducts.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { dualInvestmentClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { dualInvestmentClient } from "../../../config/binanceClient.js" export function registerBinanceSubscribeDualInvestmentProducts(server: McpServer) { - server.tool( - "BinanceSubscribeDualInvestmentProducts", - "Subscribe to Dual Investment products by providing product ID, order ID, deposit amount, and auto compound plan to initiate investment with specified terms.", - { - id: z.string().describe("Product ID from /sapi/v1/dci/product/list"), - orderId: z.string().describe("Order ID from /sapi/v1/dci/product/list"), - depositAmount: z.number().positive().describe("The amount for subscribing"), - autoCompoundPlan: z - .enum(["NONE", "STANDARD", "ADVANCED"]) - .describe("Auto-compound plan: NONE (off), STANDARD, or ADVANCED"), - recvWindow: z - .number() - .int() - .max(60000, "recvWindow cannot be greater than 60000") - .optional() - .describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await dualInvestmentClient.restAPI.subscribeDualInvestmentProducts({ - id: params.id, - orderId: params.orderId, - depositAmount: params.depositAmount, - autoCompoundPlan: params.autoCompoundPlan, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSubscribeDualInvestmentProducts", + "Subscribe to Dual Investment products by providing product ID, order ID, deposit amount, and auto compound plan to initiate investment with specified terms.", + { + id: z.string().describe("Product ID from /sapi/v1/dci/product/list"), + orderId: z.string().describe("Order ID from /sapi/v1/dci/product/list"), + depositAmount: z.number().positive().describe("The amount for subscribing"), + autoCompoundPlan: z + .enum(["NONE", "STANDARD", "ADVANCED"]) + .describe("Auto-compound plan: NONE (off), STANDARD, or ADVANCED"), + recvWindow: z + .number() + .int() + .max(60000, "recvWindow cannot be greater than 60000") + .optional() + .describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await dualInvestmentClient.restAPI.subscribeDualInvestmentProducts({ + id: params.id, + orderId: params.orderId, + depositAmount: params.depositAmount, + autoCompoundPlan: params.autoCompoundPlan, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully subscribed to Dual Investment products. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully subscribed to Dual Investment products. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to subscribe to dual investment products: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to subscribe to dual investment products: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-fiat/fiat-api/getFiatDepositWithdrawHistory.ts b/src/tools/binance-fiat/fiat-api/getFiatDepositWithdrawHistory.ts index feff9fbb..bb1dd8d2 100644 --- a/src/tools/binance-fiat/fiat-api/getFiatDepositWithdrawHistory.ts +++ b/src/tools/binance-fiat/fiat-api/getFiatDepositWithdrawHistory.ts @@ -1,60 +1,65 @@ // src/tools/binance-fiat/fiat-api/getFiatDepositWithdrawHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { fiatClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { fiatClient } from "../../../config/binanceClient.js" export function registerBinanceGetFiatDepositWithdrawHistory(server: McpServer) { - server.tool( - "BinanceGetFiatDepositWithdrawHistory", - "Fetches fiat deposit or withdrawal history, showing transaction details like amount, currency, method, status, and timestamps.", - { - transactionType: z.enum(["0", "1"]).describe("Transaction type: 0 for deposit, 1 for withdraw"), - beginTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - page: z.number().int().optional().describe("Page number, default is 1"), - rows: z - .number() - .int() - .max(500, "Rows cannot be greater than 500") - .optional() - .describe("Number of records per page, default 100, max 500"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await fiatClient.restAPI.getFiatDepositWithdrawHistory({ - transactionType: params.transactionType, - ...(params.beginTime && { beginTime: params.beginTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.page && { page: params.page }), - ...(params.rows && { rows: params.rows }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetFiatDepositWithdrawHistory", + "Fetches fiat deposit or withdrawal history, showing transaction details like amount, currency, method, status, and timestamps.", + { + transactionType: z + .enum(["0", "1"]) + .describe("Transaction type: 0 for deposit, 1 for withdraw"), + beginTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + page: z.number().int().optional().describe("Page number, default is 1"), + rows: z + .number() + .int() + .max(500, "Rows cannot be greater than 500") + .optional() + .describe("Number of records per page, default 100, max 500"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await fiatClient.restAPI.getFiatDepositWithdrawHistory({ + transactionType: params.transactionType, + ...(params.beginTime && { beginTime: params.beginTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.page && { page: params.page }), + ...(params.rows && { rows: params.rows }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully fetched fiat deposit or withdrawal history. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully fetched fiat deposit or withdrawal history. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to fetches fiat deposit or withdrawal history: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to fetches fiat deposit or withdrawal history: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-fiat/fiat-api/getFiatPaymentsHistory.ts b/src/tools/binance-fiat/fiat-api/getFiatPaymentsHistory.ts index 330a61a3..952e542f 100644 --- a/src/tools/binance-fiat/fiat-api/getFiatPaymentsHistory.ts +++ b/src/tools/binance-fiat/fiat-api/getFiatPaymentsHistory.ts @@ -1,60 +1,63 @@ // src/tools/binance-fiat/fiat-api/getFiatPaymentsHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { fiatClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { fiatClient } from "../../../config/binanceClient.js" export function registerBinanceGetFiatPaymentsHistory(server: McpServer) { - server.tool( - "BinanceGetFiatPaymentsHistory", - "Retrieves fiat buy/sell payment history, including trade amount, currency, crypto received, fees, status, payment method, and timestamps.", - { - transactionType: z.enum(["0", "1"]).describe("Transaction type: 0 for buy, 1 for sell"), - beginTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - page: z.number().int().optional().describe("Page number, default is 1"), - rows: z - .number() - .int() - .max(500, "Rows cannot be greater than 500") - .optional() - .describe("Number of records per page, default 100, max 500"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await fiatClient.restAPI.getFiatPaymentsHistory({ - transactionType: params.transactionType, - ...(params.beginTime && { beginTime: params.beginTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.page && { page: params.page }), - ...(params.rows && { rows: params.rows }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetFiatPaymentsHistory", + "Retrieves fiat buy/sell payment history, including trade amount, currency, crypto received, fees, status, payment method, and timestamps.", + { + transactionType: z.enum(["0", "1"]).describe("Transaction type: 0 for buy, 1 for sell"), + beginTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + page: z.number().int().optional().describe("Page number, default is 1"), + rows: z + .number() + .int() + .max(500, "Rows cannot be greater than 500") + .optional() + .describe("Number of records per page, default 100, max 500"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await fiatClient.restAPI.getFiatPaymentsHistory({ + transactionType: params.transactionType, + ...(params.beginTime && { beginTime: params.beginTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.page && { page: params.page }), + ...(params.rows && { rows: params.rows }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved fiat buy/sell payment history. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved fiat buy/sell payment history. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve fiat buy/sell payment history: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve fiat buy/sell payment history: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-fiat/index.ts b/src/tools/binance-fiat/index.ts index d5556812..8681309f 100644 --- a/src/tools/binance-fiat/index.ts +++ b/src/tools/binance-fiat/index.ts @@ -1,9 +1,10 @@ // src/tools/binance-fiat/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetFiatDepositWithdrawHistory } from "./fiat-api/getFiatDepositWithdrawHistory.js"; -import { registerBinanceGetFiatPaymentsHistory } from "./fiat-api/getFiatPaymentsHistory.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceGetFiatDepositWithdrawHistory } from "./fiat-api/getFiatDepositWithdrawHistory.js" +import { registerBinanceGetFiatPaymentsHistory } from "./fiat-api/getFiatPaymentsHistory.js" export function registerBinanceFiatDepositWithdrawHistoryTools(server: McpServer) { - registerBinanceGetFiatDepositWithdrawHistory(server); - registerBinanceGetFiatPaymentsHistory(server); + registerBinanceGetFiatDepositWithdrawHistory(server) + registerBinanceGetFiatPaymentsHistory(server) } diff --git a/src/tools/binance-futures-coinm/account-api/account.ts b/src/tools/binance-futures-coinm/account-api/account.ts index c52dfda5..1ce4205f 100644 --- a/src/tools/binance-futures-coinm/account-api/account.ts +++ b/src/tools/binance-futures-coinm/account-api/account.ts @@ -5,38 +5,43 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/account-api/account.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryAccount(server: McpServer) { - server.tool( - "BinanceDeliveryAccount", - "Get current COIN-M Futures account information including assets, positions, and risk metrics.", - { - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.account({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `📊 COIN-M Futures Account Information\n\nCan Trade: ${data.canTrade}\nCan Deposit: ${data.canDeposit}\nCan Withdraw: ${data.canWithdraw}\nUpdate Time: ${new Date(data.updateTime).toISOString()}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get account info: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryAccount", + "Get current COIN-M Futures account information including assets, positions, and risk metrics.", + { + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.account({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📊 COIN-M Futures Account Information\n\nCan Trade: ${data.canTrade}\nCan Deposit: ${data.canDeposit}\nCan Withdraw: ${data.canWithdraw}\nUpdate Time: ${new Date(data.updateTime).toISOString()}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get account info: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/account-api/adlQuantile.ts b/src/tools/binance-futures-coinm/account-api/adlQuantile.ts index 38d674f0..09058f09 100644 --- a/src/tools/binance-futures-coinm/account-api/adlQuantile.ts +++ b/src/tools/binance-futures-coinm/account-api/adlQuantile.ts @@ -5,40 +5,45 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/account-api/adlQuantile.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryAdlQuantile(server: McpServer) { - server.tool( - "BinanceDeliveryAdlQuantile", - "Get ADL (Auto-Deleveraging) quantile estimation for COIN-M Futures positions. Higher values indicate higher priority for deleveraging.", - { - symbol: z.string().optional().describe("Contract symbol filter"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.adlQuantile({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `⚠️ COIN-M ADL Quantile${params.symbol ? ` for ${params.symbol}` : ''}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get ADL quantile: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryAdlQuantile", + "Get ADL (Auto-Deleveraging) quantile estimation for COIN-M Futures positions. Higher values indicate higher priority for deleveraging.", + { + symbol: z.string().optional().describe("Contract symbol filter"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.adlQuantile({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `⚠️ COIN-M ADL Quantile${params.symbol ? ` for ${params.symbol}` : ""}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get ADL quantile: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/account-api/balance.ts b/src/tools/binance-futures-coinm/account-api/balance.ts index d1b213fa..9059400f 100644 --- a/src/tools/binance-futures-coinm/account-api/balance.ts +++ b/src/tools/binance-futures-coinm/account-api/balance.ts @@ -5,38 +5,43 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/account-api/balance.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryBalance(server: McpServer) { - server.tool( - "BinanceDeliveryBalance", - "Get current COIN-M Futures account balance.", - { - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.balance({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `💰 COIN-M Futures Balance\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get balance: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryBalance", + "Get current COIN-M Futures account balance.", + { + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.balance({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `💰 COIN-M Futures Balance\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get balance: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/account-api/commissionRate.ts b/src/tools/binance-futures-coinm/account-api/commissionRate.ts index 9c64531d..4e6c435a 100644 --- a/src/tools/binance-futures-coinm/account-api/commissionRate.ts +++ b/src/tools/binance-futures-coinm/account-api/commissionRate.ts @@ -5,40 +5,45 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/account-api/commissionRate.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryCommissionRate(server: McpServer) { - server.tool( - "BinanceDeliveryCommissionRate", - "Get user's COIN-M Futures commission rate for a symbol.", - { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.commissionRate({ - symbol: params.symbol, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `💰 COIN-M Commission Rate for ${params.symbol}\n\nMaker: ${data.makerCommissionRate}\nTaker: ${data.takerCommissionRate}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get commission rate: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryCommissionRate", + "Get user's COIN-M Futures commission rate for a symbol.", + { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.commissionRate({ + symbol: params.symbol, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `💰 COIN-M Commission Rate for ${params.symbol}\n\nMaker: ${data.makerCommissionRate}\nTaker: ${data.takerCommissionRate}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get commission rate: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/account-api/forceOrders.ts b/src/tools/binance-futures-coinm/account-api/forceOrders.ts index 56517c4a..e9f96fc1 100644 --- a/src/tools/binance-futures-coinm/account-api/forceOrders.ts +++ b/src/tools/binance-futures-coinm/account-api/forceOrders.ts @@ -5,48 +5,53 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/account-api/forceOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryForceOrders(server: McpServer) { - server.tool( - "BinanceDeliveryForceOrders", - "Get user's COIN-M Futures force (liquidation) order history.", - { - symbol: z.string().optional().describe("Contract symbol filter"), - autoCloseType: z.enum(["LIQUIDATION", "ADL"]).optional().describe("LIQUIDATION or ADL"), - startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().int().optional().describe("End timestamp in milliseconds"), - limit: z.number().int().optional().describe("Number of results (default 50, max 100)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.forceOrders({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.autoCloseType && { autoCloseType: params.autoCloseType }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `⚠️ COIN-M Force Orders (Liquidations)\n\nOrders: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get force orders: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryForceOrders", + "Get user's COIN-M Futures force (liquidation) order history.", + { + symbol: z.string().optional().describe("Contract symbol filter"), + autoCloseType: z.enum(["LIQUIDATION", "ADL"]).optional().describe("LIQUIDATION or ADL"), + startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().int().optional().describe("End timestamp in milliseconds"), + limit: z.number().int().optional().describe("Number of results (default 50, max 100)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.forceOrders({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.autoCloseType && { autoCloseType: params.autoCloseType }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `⚠️ COIN-M Force Orders (Liquidations)\n\nOrders: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get force orders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/account-api/income.ts b/src/tools/binance-futures-coinm/account-api/income.ts index 59e69fff..10b603c8 100644 --- a/src/tools/binance-futures-coinm/account-api/income.ts +++ b/src/tools/binance-futures-coinm/account-api/income.ts @@ -5,52 +5,68 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/account-api/income.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryIncome(server: McpServer) { - server.tool( - "BinanceDeliveryIncome", - "Get COIN-M Futures income history including realized PnL, funding fees, commissions, etc.", - { - symbol: z.string().optional().describe("Contract symbol filter"), - incomeType: z.enum([ - "TRANSFER", "WELCOME_BONUS", "REALIZED_PNL", "FUNDING_FEE", - "COMMISSION", "INSURANCE_CLEAR", "REFERRAL_KICKBACK", - "COMMISSION_REBATE", "DELIVERED_SETTELMENT", "COIN_SWAP_DEPOSIT", "COIN_SWAP_WITHDRAW" - ]).optional().describe("Income type filter"), - startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().int().optional().describe("End timestamp in milliseconds"), - limit: z.number().int().optional().describe("Number of results (default 100, max 1000)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.income({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.incomeType && { incomeType: params.incomeType }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `💵 COIN-M Income History\n\nRecords: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get income history: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryIncome", + "Get COIN-M Futures income history including realized PnL, funding fees, commissions, etc.", + { + symbol: z.string().optional().describe("Contract symbol filter"), + incomeType: z + .enum([ + "TRANSFER", + "WELCOME_BONUS", + "REALIZED_PNL", + "FUNDING_FEE", + "COMMISSION", + "INSURANCE_CLEAR", + "REFERRAL_KICKBACK", + "COMMISSION_REBATE", + "DELIVERED_SETTELMENT", + "COIN_SWAP_DEPOSIT", + "COIN_SWAP_WITHDRAW", + ]) + .optional() + .describe("Income type filter"), + startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().int().optional().describe("End timestamp in milliseconds"), + limit: z.number().int().optional().describe("Number of results (default 100, max 1000)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.income({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.incomeType && { incomeType: params.incomeType }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `💵 COIN-M Income History\n\nRecords: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get income history: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/account-api/index.ts b/src/tools/binance-futures-coinm/account-api/index.ts index 2a0af311..4de5622e 100644 --- a/src/tools/binance-futures-coinm/account-api/index.ts +++ b/src/tools/binance-futures-coinm/account-api/index.ts @@ -5,34 +5,35 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/account-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceDeliveryAccount } from "./account.js"; -import { registerBinanceDeliveryBalance } from "./balance.js"; -import { registerBinanceDeliveryPositionRisk } from "./positionRisk.js"; -import { registerBinanceDeliveryUserTrades } from "./userTrades.js"; -import { registerBinanceDeliveryIncome } from "./income.js"; -import { registerBinanceDeliveryLeverageBracket } from "./leverageBracket.js"; -import { registerBinanceDeliveryAdlQuantile } from "./adlQuantile.js"; -import { registerBinanceDeliveryForceOrders } from "./forceOrders.js"; -import { registerBinanceDeliveryCommissionRate } from "./commissionRate.js"; -import { registerBinanceDeliveryPositionMode } from "./positionMode.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceDeliveryAccount } from "./account.js" +import { registerBinanceDeliveryAdlQuantile } from "./adlQuantile.js" +import { registerBinanceDeliveryBalance } from "./balance.js" +import { registerBinanceDeliveryCommissionRate } from "./commissionRate.js" +import { registerBinanceDeliveryForceOrders } from "./forceOrders.js" +import { registerBinanceDeliveryIncome } from "./income.js" +import { registerBinanceDeliveryLeverageBracket } from "./leverageBracket.js" +import { registerBinanceDeliveryPositionMode } from "./positionMode.js" +import { registerBinanceDeliveryPositionRisk } from "./positionRisk.js" +import { registerBinanceDeliveryUserTrades } from "./userTrades.js" export function registerBinanceDeliveryAccountApiTools(server: McpServer) { - // Account Information - registerBinanceDeliveryAccount(server); - registerBinanceDeliveryBalance(server); - registerBinanceDeliveryPositionRisk(server); - - // Trade History - registerBinanceDeliveryUserTrades(server); - registerBinanceDeliveryIncome(server); - - // Leverage & Risk - registerBinanceDeliveryLeverageBracket(server); - registerBinanceDeliveryAdlQuantile(server); - registerBinanceDeliveryForceOrders(server); - - // Account Settings - registerBinanceDeliveryCommissionRate(server); - registerBinanceDeliveryPositionMode(server); + // Account Information + registerBinanceDeliveryAccount(server) + registerBinanceDeliveryBalance(server) + registerBinanceDeliveryPositionRisk(server) + + // Trade History + registerBinanceDeliveryUserTrades(server) + registerBinanceDeliveryIncome(server) + + // Leverage & Risk + registerBinanceDeliveryLeverageBracket(server) + registerBinanceDeliveryAdlQuantile(server) + registerBinanceDeliveryForceOrders(server) + + // Account Settings + registerBinanceDeliveryCommissionRate(server) + registerBinanceDeliveryPositionMode(server) } diff --git a/src/tools/binance-futures-coinm/account-api/leverageBracket.ts b/src/tools/binance-futures-coinm/account-api/leverageBracket.ts index c135c290..5a8550ac 100644 --- a/src/tools/binance-futures-coinm/account-api/leverageBracket.ts +++ b/src/tools/binance-futures-coinm/account-api/leverageBracket.ts @@ -5,40 +5,45 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/account-api/leverageBracket.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryLeverageBracket(server: McpServer) { - server.tool( - "BinanceDeliveryLeverageBracket", - "Get notional and leverage bracket information for COIN-M Futures. Shows max leverage at different position sizes.", - { - pair: z.string().optional().describe("Filter by underlying pair (e.g., BTCUSD)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.leverageBracket({ - ...(params.pair && { pair: params.pair }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `📊 COIN-M Leverage Brackets${params.pair ? ` for ${params.pair}` : ''}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get leverage brackets: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryLeverageBracket", + "Get notional and leverage bracket information for COIN-M Futures. Shows max leverage at different position sizes.", + { + pair: z.string().optional().describe("Filter by underlying pair (e.g., BTCUSD)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.leverageBracket({ + ...(params.pair && { pair: params.pair }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📊 COIN-M Leverage Brackets${params.pair ? ` for ${params.pair}` : ""}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get leverage brackets: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/account-api/positionMode.ts b/src/tools/binance-futures-coinm/account-api/positionMode.ts index 4bb7521f..8d0bebfe 100644 --- a/src/tools/binance-futures-coinm/account-api/positionMode.ts +++ b/src/tools/binance-futures-coinm/account-api/positionMode.ts @@ -5,39 +5,44 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/account-api/positionMode.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryPositionMode(server: McpServer) { - server.tool( - "BinanceDeliveryPositionMode", - "Get current COIN-M Futures position mode (Hedge Mode or One-way Mode).", - { - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.getPositionMode({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - const mode = data.dualSidePosition ? "Hedge Mode (LONG/SHORT)" : "One-way Mode (BOTH)"; - - return { - content: [{ - type: "text", - text: `⚙️ COIN-M Position Mode\n\nCurrent Mode: ${mode}\ndualSidePosition: ${data.dualSidePosition}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get position mode: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryPositionMode", + "Get current COIN-M Futures position mode (Hedge Mode or One-way Mode).", + { + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.getPositionMode({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + const mode = data.dualSidePosition ? "Hedge Mode (LONG/SHORT)" : "One-way Mode (BOTH)" + + return { + content: [ + { + type: "text", + text: `⚙️ COIN-M Position Mode\n\nCurrent Mode: ${mode}\ndualSidePosition: ${data.dualSidePosition}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get position mode: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/account-api/positionRisk.ts b/src/tools/binance-futures-coinm/account-api/positionRisk.ts index 4ffd35f9..e15bdeb6 100644 --- a/src/tools/binance-futures-coinm/account-api/positionRisk.ts +++ b/src/tools/binance-futures-coinm/account-api/positionRisk.ts @@ -5,42 +5,47 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/account-api/positionRisk.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryPositionRisk(server: McpServer) { - server.tool( - "BinanceDeliveryPositionRisk", - "Get current COIN-M Futures position information including unrealized PnL and liquidation price.", - { - marginAsset: z.string().optional().describe("Filter by margin asset (e.g., BTC)"), - pair: z.string().optional().describe("Filter by trading pair (e.g., BTCUSD)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.positionRisk({ - ...(params.marginAsset && { marginAsset: params.marginAsset }), - ...(params.pair && { pair: params.pair }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `📊 COIN-M Position Risk\n\nPositions: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get position risk: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryPositionRisk", + "Get current COIN-M Futures position information including unrealized PnL and liquidation price.", + { + marginAsset: z.string().optional().describe("Filter by margin asset (e.g., BTC)"), + pair: z.string().optional().describe("Filter by trading pair (e.g., BTCUSD)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.positionRisk({ + ...(params.marginAsset && { marginAsset: params.marginAsset }), + ...(params.pair && { pair: params.pair }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📊 COIN-M Position Risk\n\nPositions: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get position risk: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/account-api/userTrades.ts b/src/tools/binance-futures-coinm/account-api/userTrades.ts index 1202e24b..37055924 100644 --- a/src/tools/binance-futures-coinm/account-api/userTrades.ts +++ b/src/tools/binance-futures-coinm/account-api/userTrades.ts @@ -5,50 +5,55 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/account-api/userTrades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryUserTrades(server: McpServer) { - server.tool( - "BinanceDeliveryUserTrades", - "Get COIN-M Futures account trade history for a symbol.", - { - symbol: z.string().optional().describe("Contract symbol (e.g., BTCUSD_PERP)"), - pair: z.string().optional().describe("Filter by underlying pair (e.g., BTCUSD)"), - startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().int().optional().describe("End timestamp in milliseconds"), - fromId: z.number().int().optional().describe("Trade ID to fetch from"), - limit: z.number().int().optional().describe("Number of results (default 50, max 1000)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.userTrades({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.pair && { pair: params.pair }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.fromId && { fromId: params.fromId }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `📈 COIN-M Trade History\n\nTrades: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get user trades: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryUserTrades", + "Get COIN-M Futures account trade history for a symbol.", + { + symbol: z.string().optional().describe("Contract symbol (e.g., BTCUSD_PERP)"), + pair: z.string().optional().describe("Filter by underlying pair (e.g., BTCUSD)"), + startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().int().optional().describe("End timestamp in milliseconds"), + fromId: z.number().int().optional().describe("Trade ID to fetch from"), + limit: z.number().int().optional().describe("Number of results (default 50, max 1000)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.userTrades({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.pair && { pair: params.pair }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.fromId && { fromId: params.fromId }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📈 COIN-M Trade History\n\nTrades: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get user trades: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/account.ts b/src/tools/binance-futures-coinm/account.ts index 60a4b842..52167185 100644 --- a/src/tools/binance-futures-coinm/account.ts +++ b/src/tools/binance-futures-coinm/account.ts @@ -1,31 +1,34 @@ // src/tools/binance-futures-coinm/account.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMAccount(server: McpServer) { - server.tool( - "BinanceFuturesCOINMAccount", - "Get current COIN-M futures account information.", - { - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await deliveryClient.getAccount({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - return { - content: [{ type: "text", text: `COIN-M account info: ${JSON.stringify(data)}` }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get COIN-M account: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesCOINMAccount", + "Get current COIN-M futures account information.", + { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await deliveryClient.getAccount({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [{ type: "text", text: `COIN-M account info: ${JSON.stringify(data)}` }], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get COIN-M account: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/adlQuantile.ts b/src/tools/binance-futures-coinm/adlQuantile.ts index 49ab4fb3..9f085658 100644 --- a/src/tools/binance-futures-coinm/adlQuantile.ts +++ b/src/tools/binance-futures-coinm/adlQuantile.ts @@ -1,40 +1,50 @@ // src/tools/binance-futures-coinm/adlQuantile.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMADLQuantile(server: McpServer) { - server.tool( - "BinanceFuturesCOINMADLQuantile", - "Get position ADL (Auto-Deleveraging) quantile estimate for COIN-M Futures.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSD_PERP). If not provided, returns all positions") - }, - async ({ symbol }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; + server.tool( + "BinanceFuturesCOINMADLQuantile", + "Get position ADL (Auto-Deleveraging) quantile estimate for COIN-M Futures.", + { + symbol: z + .string() + .optional() + .describe( + "Symbol of the trading pair (e.g., BTCUSD_PERP). If not provided, returns all positions", + ), + }, + async ({ symbol }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol - const data = await deliveryClient.adlQuantile(params); - + const data = await deliveryClient.adlQuantile(params) + + return { + content: [ + { + type: "text", + text: `Retrieved COIN-M Futures ADL quantile${symbol ? ` for ${symbol}` : " for all positions"}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved COIN-M Futures ADL quantile${symbol ? ` for ${symbol}` : ' for all positions'}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve COIN-M Futures ADL quantile: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve COIN-M Futures ADL quantile: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/aggTrades.ts b/src/tools/binance-futures-coinm/aggTrades.ts index 47a14995..2a68b793 100644 --- a/src/tools/binance-futures-coinm/aggTrades.ts +++ b/src/tools/binance-futures-coinm/aggTrades.ts @@ -1,47 +1,58 @@ // src/tools/binance-futures-coinm/aggTrades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMAggTrades(server: McpServer) { - server.tool( - "BinanceFuturesCOINMAggTrades", - "Get compressed, aggregate trades for a specific COIN-M Futures trading pair.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), - fromId: z.number().optional().describe("ID to get aggregate trades from INCLUSIVE"), - startTime: z.number().optional().describe("Timestamp in ms to get aggregate trades from INCLUSIVE"), - endTime: z.number().optional().describe("Timestamp in ms to get aggregate trades until INCLUSIVE"), - limit: z.number().optional().describe("Default 500; max 1000") - }, - async ({ symbol, fromId, startTime, endTime, limit }) => { - try { - const params: any = { symbol }; - if (fromId !== undefined) params.fromId = fromId; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; + server.tool( + "BinanceFuturesCOINMAggTrades", + "Get compressed, aggregate trades for a specific COIN-M Futures trading pair.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + fromId: z.number().optional().describe("ID to get aggregate trades from INCLUSIVE"), + startTime: z + .number() + .optional() + .describe("Timestamp in ms to get aggregate trades from INCLUSIVE"), + endTime: z + .number() + .optional() + .describe("Timestamp in ms to get aggregate trades until INCLUSIVE"), + limit: z.number().optional().describe("Default 500; max 1000"), + }, + async ({ symbol, fromId, startTime, endTime, limit }) => { + try { + const params: any = { symbol } + if (fromId !== undefined) params.fromId = fromId + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit - const data = await deliveryClient.aggTrades(params); - + const data = await deliveryClient.aggTrades(params) + + return { + content: [ + { + type: "text", + text: `Retrieved ${data.length || 0} aggregated trades for COIN-M Futures ${symbol}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved ${data.length || 0} aggregated trades for COIN-M Futures ${symbol}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve COIN-M Futures aggregated trades: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve COIN-M Futures aggregated trades: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/allOrders.ts b/src/tools/binance-futures-coinm/allOrders.ts index 26f44480..00d17859 100644 --- a/src/tools/binance-futures-coinm/allOrders.ts +++ b/src/tools/binance-futures-coinm/allOrders.ts @@ -1,51 +1,52 @@ // src/tools/binance-futures-coinm/allOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMAllOrders(server: McpServer) { - server.tool( - "BinanceFuturesCOINMAllOrders", - "Get all orders (active, canceled, or filled) for COIN-M Futures.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), - pair: z.string().optional().describe("Trading pair (e.g., BTCUSD)"), - orderId: z.number().optional().describe("Order ID to start from"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1000") - }, - async ({ symbol, pair, orderId, startTime, endTime, limit }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - if (pair) params.pair = pair; - if (orderId !== undefined) params.orderId = orderId; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; + server.tool( + "BinanceFuturesCOINMAllOrders", + "Get all orders (active, canceled, or filled) for COIN-M Futures.", + { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + pair: z.string().optional().describe("Trading pair (e.g., BTCUSD)"), + orderId: z.number().optional().describe("Order ID to start from"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1000"), + }, + async ({ symbol, pair, orderId, startTime, endTime, limit }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + if (pair) params.pair = pair + if (orderId !== undefined) params.orderId = orderId + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit - const data = await deliveryClient.allOrders(params); - + const data = await deliveryClient.allOrders(params) - return { - content: [ - { - type: "text", - text: `Retrieved ${data.length || 0} COIN-M Futures orders. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve COIN-M Futures all orders: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Retrieved ${data.length || 0} COIN-M Futures orders. Response: ${JSON.stringify(data)}`, + }, + ], } - ); -} + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + return { + content: [ + { type: "text", text: `Failed to retrieve COIN-M Futures all orders: ${errorMessage}` }, + ], + isError: true, + } + } + }, + ) +} diff --git a/src/tools/binance-futures-coinm/balance.ts b/src/tools/binance-futures-coinm/balance.ts index 4c461629..dfe02747 100644 --- a/src/tools/binance-futures-coinm/balance.ts +++ b/src/tools/binance-futures-coinm/balance.ts @@ -1,31 +1,34 @@ // src/tools/binance-futures-coinm/balance.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMBalance(server: McpServer) { - server.tool( - "BinanceFuturesCOINMBalance", - "Get COIN-M futures account balance.", - { - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await deliveryClient.getBalance({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - return { - content: [{ type: "text", text: `COIN-M balance: ${JSON.stringify(data)}` }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get COIN-M balance: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesCOINMBalance", + "Get COIN-M futures account balance.", + { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await deliveryClient.getBalance({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [{ type: "text", text: `COIN-M balance: ${JSON.stringify(data)}` }], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get COIN-M balance: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/batchOrders.ts b/src/tools/binance-futures-coinm/batchOrders.ts index e78847a5..c34a9c1d 100644 --- a/src/tools/binance-futures-coinm/batchOrders.ts +++ b/src/tools/binance-futures-coinm/batchOrders.ts @@ -1,37 +1,43 @@ // src/tools/binance-futures-coinm/batchOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMBatchOrders(server: McpServer) { - server.tool( - "BinanceFuturesCOINMBatchOrders", - "Place multiple orders for COIN-M Futures (max 5 orders).", - { - batchOrders: z.string().describe("JSON string of order list. Max 5 orders. Each order has: symbol, side, type, and optional parameters") - }, - async ({ batchOrders }) => { - try { - const data = await deliveryClient.batchOrders({ batchOrders }); - + server.tool( + "BinanceFuturesCOINMBatchOrders", + "Place multiple orders for COIN-M Futures (max 5 orders).", + { + batchOrders: z + .string() + .describe( + "JSON string of order list. Max 5 orders. Each order has: symbol, side, type, and optional parameters", + ), + }, + async ({ batchOrders }) => { + try { + const data = await deliveryClient.batchOrders({ batchOrders }) + + return { + content: [ + { + type: "text", + text: `COIN-M Futures batch orders created. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `COIN-M Futures batch orders created. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to create COIN-M Futures batch orders: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to create COIN-M Futures batch orders: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/bookTicker.ts b/src/tools/binance-futures-coinm/bookTicker.ts index 991f6830..2ccbb0df 100644 --- a/src/tools/binance-futures-coinm/bookTicker.ts +++ b/src/tools/binance-futures-coinm/bookTicker.ts @@ -1,42 +1,52 @@ // src/tools/binance-futures-coinm/bookTicker.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMBookTicker(server: McpServer) { - server.tool( - "BinanceFuturesCOINMBookTicker", - "Get best price/qty on the order book for a symbol or symbols for COIN-M Futures.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSD_PERP). If not provided, returns all symbols"), - pair: z.string().optional().describe("Trading pair (e.g., BTCUSD)") - }, - async ({ symbol, pair }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - if (pair) params.pair = pair; + server.tool( + "BinanceFuturesCOINMBookTicker", + "Get best price/qty on the order book for a symbol or symbols for COIN-M Futures.", + { + symbol: z + .string() + .optional() + .describe( + "Symbol of the trading pair (e.g., BTCUSD_PERP). If not provided, returns all symbols", + ), + pair: z.string().optional().describe("Trading pair (e.g., BTCUSD)"), + }, + async ({ symbol, pair }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + if (pair) params.pair = pair - const data = await deliveryClient.tickerBookTicker(params); - + const data = await deliveryClient.tickerBookTicker(params) + + return { + content: [ + { + type: "text", + text: `Retrieved COIN-M Futures book ticker${symbol ? ` for ${symbol}` : pair ? ` for pair ${pair}` : " for all symbols"}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved COIN-M Futures book ticker${symbol ? ` for ${symbol}` : pair ? ` for pair ${pair}` : ' for all symbols'}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve COIN-M Futures book ticker: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve COIN-M Futures book ticker: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/cancelAllOrders.ts b/src/tools/binance-futures-coinm/cancelAllOrders.ts index bf557e06..f439f06a 100644 --- a/src/tools/binance-futures-coinm/cancelAllOrders.ts +++ b/src/tools/binance-futures-coinm/cancelAllOrders.ts @@ -1,33 +1,36 @@ // src/tools/binance-futures-coinm/cancelAllOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMCancelAllOrders(server: McpServer) { - server.tool( - "BinanceFuturesCOINMCancelAllOrders", - "Cancel all open COIN-M futures orders for a symbol.", - { - symbol: z.string().describe("Trading symbol"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await deliveryClient.cancelAllOpenOrders({ - symbol: params.symbol, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - return { - content: [{ type: "text", text: `All COIN-M orders cancelled: ${JSON.stringify(data)}` }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to cancel all COIN-M orders: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesCOINMCancelAllOrders", + "Cancel all open COIN-M futures orders for a symbol.", + { + symbol: z.string().describe("Trading symbol"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await deliveryClient.cancelAllOpenOrders({ + symbol: params.symbol, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [{ type: "text", text: `All COIN-M orders cancelled: ${JSON.stringify(data)}` }], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to cancel all COIN-M orders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/cancelBatchOrders.ts b/src/tools/binance-futures-coinm/cancelBatchOrders.ts index aba7a71a..ed49bf15 100644 --- a/src/tools/binance-futures-coinm/cancelBatchOrders.ts +++ b/src/tools/binance-futures-coinm/cancelBatchOrders.ts @@ -1,43 +1,48 @@ // src/tools/binance-futures-coinm/cancelBatchOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMCancelBatchOrders(server: McpServer) { - server.tool( - "BinanceFuturesCOINMCancelBatchOrders", - "Cancel multiple orders for COIN-M Futures.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), - orderIdList: z.string().optional().describe("Comma-separated list of order IDs (max 10)"), - origClientOrderIdList: z.string().optional().describe("Comma-separated list of client order IDs (max 10)") - }, - async ({ symbol, orderIdList, origClientOrderIdList }) => { - try { - const params: any = { symbol }; - if (orderIdList) params.orderIdList = orderIdList; - if (origClientOrderIdList) params.origClientOrderIdList = origClientOrderIdList; + server.tool( + "BinanceFuturesCOINMCancelBatchOrders", + "Cancel multiple orders for COIN-M Futures.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + orderIdList: z.string().optional().describe("Comma-separated list of order IDs (max 10)"), + origClientOrderIdList: z + .string() + .optional() + .describe("Comma-separated list of client order IDs (max 10)"), + }, + async ({ symbol, orderIdList, origClientOrderIdList }) => { + try { + const params: any = { symbol } + if (orderIdList) params.orderIdList = orderIdList + if (origClientOrderIdList) params.origClientOrderIdList = origClientOrderIdList - const data = await deliveryClient.cancelBatchOrders(params); - + const data = await deliveryClient.cancelBatchOrders(params) + + return { + content: [ + { + type: "text", + text: `COIN-M Futures batch orders cancelled. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `COIN-M Futures batch orders cancelled. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to cancel COIN-M Futures batch orders: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to cancel COIN-M Futures batch orders: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/cancelOrder.ts b/src/tools/binance-futures-coinm/cancelOrder.ts index 2a715ed6..56062e77 100644 --- a/src/tools/binance-futures-coinm/cancelOrder.ts +++ b/src/tools/binance-futures-coinm/cancelOrder.ts @@ -1,37 +1,40 @@ // src/tools/binance-futures-coinm/cancelOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMCancelOrder(server: McpServer) { - server.tool( - "BinanceFuturesCOINMCancelOrder", - "Cancel a COIN-M futures order.", - { - symbol: z.string().describe("Trading symbol"), - orderId: z.number().int().optional().describe("Order ID"), - origClientOrderId: z.string().optional().describe("Original client order ID"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await deliveryClient.cancelOrder({ - symbol: params.symbol, - ...(params.orderId && { orderId: params.orderId }), - ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - return { - content: [{ type: "text", text: `COIN-M order cancelled: ${JSON.stringify(data)}` }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to cancel COIN-M order: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesCOINMCancelOrder", + "Cancel a COIN-M futures order.", + { + symbol: z.string().describe("Trading symbol"), + orderId: z.number().int().optional().describe("Order ID"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await deliveryClient.cancelOrder({ + symbol: params.symbol, + ...(params.orderId && { orderId: params.orderId }), + ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [{ type: "text", text: `COIN-M order cancelled: ${JSON.stringify(data)}` }], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to cancel COIN-M order: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/commissionRate.ts b/src/tools/binance-futures-coinm/commissionRate.ts index 1698183c..248f5f69 100644 --- a/src/tools/binance-futures-coinm/commissionRate.ts +++ b/src/tools/binance-futures-coinm/commissionRate.ts @@ -1,37 +1,42 @@ // src/tools/binance-futures-coinm/commissionRate.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMCommissionRate(server: McpServer) { - server.tool( - "BinanceFuturesCOINMCommissionRate", - "Get user commission rate for COIN-M Futures.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)") - }, - async ({ symbol }) => { - try { - const data = await deliveryClient.commissionRate({ symbol }); - + server.tool( + "BinanceFuturesCOINMCommissionRate", + "Get user commission rate for COIN-M Futures.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + }, + async ({ symbol }) => { + try { + const data = await deliveryClient.commissionRate({ symbol }) + + return { + content: [ + { + type: "text", + text: `Retrieved COIN-M Futures commission rate for ${symbol}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved COIN-M Futures commission rate for ${symbol}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve COIN-M Futures commission rate: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve COIN-M Futures commission rate: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/continuousKlines.ts b/src/tools/binance-futures-coinm/continuousKlines.ts index 57850e5e..f225841e 100644 --- a/src/tools/binance-futures-coinm/continuousKlines.ts +++ b/src/tools/binance-futures-coinm/continuousKlines.ts @@ -1,49 +1,72 @@ // src/tools/binance-futures-coinm/continuousKlines.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMContinuousKlines(server: McpServer) { - server.tool( - "BinanceFuturesCOINMContinuousKlines", - "Get continuous contract Kline/candlestick data for COIN-M Futures.", - { - pair: z.string().describe("Trading pair (e.g., BTCUSD)"), - contractType: z.enum(["PERPETUAL", "CURRENT_QUARTER", "NEXT_QUARTER"]).describe("Contract type"), - interval: z.enum([ - "1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "8h", "12h", "1d", "3d", "1w", "1M" - ]).describe("Kline interval"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1500") - }, - async ({ pair, contractType, interval, startTime, endTime, limit }) => { - try { - const params: any = { pair, contractType, interval }; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; + server.tool( + "BinanceFuturesCOINMContinuousKlines", + "Get continuous contract Kline/candlestick data for COIN-M Futures.", + { + pair: z.string().describe("Trading pair (e.g., BTCUSD)"), + contractType: z + .enum(["PERPETUAL", "CURRENT_QUARTER", "NEXT_QUARTER"]) + .describe("Contract type"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1500"), + }, + async ({ pair, contractType, interval, startTime, endTime, limit }) => { + try { + const params: any = { pair, contractType, interval } + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit - const data = await deliveryClient.continuousKlines(params); - + const data = await deliveryClient.continuousKlines(params) + + return { + content: [ + { + type: "text", + text: `Retrieved ${data.length || 0} continuous klines for COIN-M Futures ${pair} ${contractType} with ${interval} interval. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved ${data.length || 0} continuous klines for COIN-M Futures ${pair} ${contractType} with ${interval} interval. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve COIN-M Futures continuous klines: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve COIN-M Futures continuous klines: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/depth.ts b/src/tools/binance-futures-coinm/depth.ts index d51a2a79..d0ade0a9 100644 --- a/src/tools/binance-futures-coinm/depth.ts +++ b/src/tools/binance-futures-coinm/depth.ts @@ -1,41 +1,51 @@ // src/tools/binance-futures-coinm/depth.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMDepth(server: McpServer) { - server.tool( - "BinanceFuturesCOINMDepth", - "Get order book depth data for a specific COIN-M Futures trading pair.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), - limit: z.number().optional().describe("Depth of the order book. Default 500; max 1000. Valid limits: [5, 10, 20, 50, 100, 500, 1000]") - }, - async ({ symbol, limit }) => { - try { - const params: any = { symbol }; - if (limit !== undefined) params.limit = limit; + server.tool( + "BinanceFuturesCOINMDepth", + "Get order book depth data for a specific COIN-M Futures trading pair.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + limit: z + .number() + .optional() + .describe( + "Depth of the order book. Default 500; max 1000. Valid limits: [5, 10, 20, 50, 100, 500, 1000]", + ), + }, + async ({ symbol, limit }) => { + try { + const params: any = { symbol } + if (limit !== undefined) params.limit = limit - const data = await deliveryClient.depth(params); - + const data = await deliveryClient.depth(params) + + return { + content: [ + { + type: "text", + text: `Retrieved COIN-M Futures order book depth for ${symbol}. Bids: ${data.bids?.length || 0}, Asks: ${data.asks?.length || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved COIN-M Futures order book depth for ${symbol}. Bids: ${data.bids?.length || 0}, Asks: ${data.asks?.length || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve COIN-M Futures order book depth: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve COIN-M Futures order book depth: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/exchangeInfo.ts b/src/tools/binance-futures-coinm/exchangeInfo.ts index db6709c3..80ab2029 100644 --- a/src/tools/binance-futures-coinm/exchangeInfo.ts +++ b/src/tools/binance-futures-coinm/exchangeInfo.ts @@ -1,33 +1,35 @@ // src/tools/binance-futures-coinm/exchangeInfo.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMExchangeInfo(server: McpServer) { - server.tool( - "BinanceFuturesCOINMExchangeInfo", - "Get current exchange trading rules and symbol information for COIN-M Futures.", - {}, - async () => { - try { - const data = await deliveryClient.exchangeInfo(); - - return { - content: [ - { - type: "text", - text: `COIN-M Futures exchange info retrieved. Symbols count: ${data.symbols?.length || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get COIN-M Futures exchange info: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceFuturesCOINMExchangeInfo", + "Get current exchange trading rules and symbol information for COIN-M Futures.", + {}, + async () => { + try { + const data = await deliveryClient.exchangeInfo() + + return { + content: [ + { + type: "text", + text: `COIN-M Futures exchange info retrieved. Symbols count: ${data.symbols?.length || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to get COIN-M Futures exchange info: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/forceOrders.ts b/src/tools/binance-futures-coinm/forceOrders.ts index ed563c1f..8cdff2b8 100644 --- a/src/tools/binance-futures-coinm/forceOrders.ts +++ b/src/tools/binance-futures-coinm/forceOrders.ts @@ -1,48 +1,56 @@ // src/tools/binance-futures-coinm/forceOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMForceOrders(server: McpServer) { - server.tool( - "BinanceFuturesCOINMForceOrders", - "Get user force orders (liquidation orders) for COIN-M Futures.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), - autoCloseType: z.enum(["LIQUIDATION", "ADL"]).optional().describe("Auto close type: LIQUIDATION or ADL"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 50; max 100") - }, - async ({ symbol, autoCloseType, startTime, endTime, limit }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - if (autoCloseType) params.autoCloseType = autoCloseType; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; + server.tool( + "BinanceFuturesCOINMForceOrders", + "Get user force orders (liquidation orders) for COIN-M Futures.", + { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + autoCloseType: z + .enum(["LIQUIDATION", "ADL"]) + .optional() + .describe("Auto close type: LIQUIDATION or ADL"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 50; max 100"), + }, + async ({ symbol, autoCloseType, startTime, endTime, limit }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + if (autoCloseType) params.autoCloseType = autoCloseType + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit - const data = await deliveryClient.forceOrders(params); - + const data = await deliveryClient.forceOrders(params) + + return { + content: [ + { + type: "text", + text: `Retrieved ${data.length || 0} COIN-M Futures force orders. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved ${data.length || 0} COIN-M Futures force orders. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve COIN-M Futures force orders: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve COIN-M Futures force orders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/fundingRate.ts b/src/tools/binance-futures-coinm/fundingRate.ts index 880fd15c..9ac3ba08 100644 --- a/src/tools/binance-futures-coinm/fundingRate.ts +++ b/src/tools/binance-futures-coinm/fundingRate.ts @@ -1,46 +1,51 @@ // src/tools/binance-futures-coinm/fundingRate.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMFundingRate(server: McpServer) { - server.tool( - "BinanceFuturesCOINMFundingRate", - "Get funding rate history for COIN-M Futures.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 100; max 1000") - }, - async ({ symbol, startTime, endTime, limit }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; + server.tool( + "BinanceFuturesCOINMFundingRate", + "Get funding rate history for COIN-M Futures.", + { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 100; max 1000"), + }, + async ({ symbol, startTime, endTime, limit }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit - const data = await deliveryClient.fundingRate(params); - + const data = await deliveryClient.fundingRate(params) + + return { + content: [ + { + type: "text", + text: `Retrieved ${data.length || 0} funding rate records for COIN-M Futures${symbol ? ` ${symbol}` : ""}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved ${data.length || 0} funding rate records for COIN-M Futures${symbol ? ` ${symbol}` : ''}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve COIN-M Futures funding rate: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve COIN-M Futures funding rate: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/getOrder.ts b/src/tools/binance-futures-coinm/getOrder.ts index b529445d..47d95ebb 100644 --- a/src/tools/binance-futures-coinm/getOrder.ts +++ b/src/tools/binance-futures-coinm/getOrder.ts @@ -1,37 +1,40 @@ // src/tools/binance-futures-coinm/getOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMGetOrder(server: McpServer) { - server.tool( - "BinanceFuturesCOINMGetOrder", - "Query a COIN-M futures order.", - { - symbol: z.string().describe("Trading symbol"), - orderId: z.number().int().optional().describe("Order ID"), - origClientOrderId: z.string().optional().describe("Original client order ID"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await deliveryClient.getOrder({ - symbol: params.symbol, - ...(params.orderId && { orderId: params.orderId }), - ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - return { - content: [{ type: "text", text: `COIN-M order: ${JSON.stringify(data)}` }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get COIN-M order: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesCOINMGetOrder", + "Query a COIN-M futures order.", + { + symbol: z.string().describe("Trading symbol"), + orderId: z.number().int().optional().describe("Order ID"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await deliveryClient.getOrder({ + symbol: params.symbol, + ...(params.orderId && { orderId: params.orderId }), + ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [{ type: "text", text: `COIN-M order: ${JSON.stringify(data)}` }], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get COIN-M order: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/historicalTrades.ts b/src/tools/binance-futures-coinm/historicalTrades.ts index bf366215..cdd42e6e 100644 --- a/src/tools/binance-futures-coinm/historicalTrades.ts +++ b/src/tools/binance-futures-coinm/historicalTrades.ts @@ -1,43 +1,51 @@ // src/tools/binance-futures-coinm/historicalTrades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMHistoricalTrades(server: McpServer) { - server.tool( - "BinanceFuturesCOINMHistoricalTrades", - "Get older market historical trades for a specific COIN-M Futures trading pair.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), - limit: z.number().optional().describe("Number of trades to return. Default 500; max 1000"), - fromId: z.number().optional().describe("Trade ID to fetch from. Default gets most recent trades") - }, - async ({ symbol, limit, fromId }) => { - try { - const params: any = { symbol }; - if (limit !== undefined) params.limit = limit; - if (fromId !== undefined) params.fromId = fromId; + server.tool( + "BinanceFuturesCOINMHistoricalTrades", + "Get older market historical trades for a specific COIN-M Futures trading pair.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + limit: z.number().optional().describe("Number of trades to return. Default 500; max 1000"), + fromId: z + .number() + .optional() + .describe("Trade ID to fetch from. Default gets most recent trades"), + }, + async ({ symbol, limit, fromId }) => { + try { + const params: any = { symbol } + if (limit !== undefined) params.limit = limit + if (fromId !== undefined) params.fromId = fromId - const data = await deliveryClient.historicalTrades(params); - + const data = await deliveryClient.historicalTrades(params) + + return { + content: [ + { + type: "text", + text: `Retrieved ${data.length || 0} historical trades for COIN-M Futures ${symbol}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved ${data.length || 0} historical trades for COIN-M Futures ${symbol}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve COIN-M Futures historical trades: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve COIN-M Futures historical trades: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/income.ts b/src/tools/binance-futures-coinm/income.ts index a2925850..3f136937 100644 --- a/src/tools/binance-futures-coinm/income.ts +++ b/src/tools/binance-futures-coinm/income.ts @@ -1,48 +1,65 @@ // src/tools/binance-futures-coinm/income.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMIncome(server: McpServer) { - server.tool( - "BinanceFuturesCOINMIncome", - "Get income history for COIN-M Futures.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), - incomeType: z.enum(["TRANSFER", "WELCOME_BONUS", "REALIZED_PNL", "FUNDING_FEE", "COMMISSION", "INSURANCE_CLEAR", "REFERRAL_KICKBACK", "COMMISSION_REBATE", "DELIVERED_SETTELMENT", "COIN_SWAP_DEPOSIT", "COIN_SWAP_WITHDRAW"]).optional().describe("Income type"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 100; max 1000") - }, - async ({ symbol, incomeType, startTime, endTime, limit }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - if (incomeType) params.incomeType = incomeType; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; + server.tool( + "BinanceFuturesCOINMIncome", + "Get income history for COIN-M Futures.", + { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + incomeType: z + .enum([ + "TRANSFER", + "WELCOME_BONUS", + "REALIZED_PNL", + "FUNDING_FEE", + "COMMISSION", + "INSURANCE_CLEAR", + "REFERRAL_KICKBACK", + "COMMISSION_REBATE", + "DELIVERED_SETTELMENT", + "COIN_SWAP_DEPOSIT", + "COIN_SWAP_WITHDRAW", + ]) + .optional() + .describe("Income type"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 100; max 1000"), + }, + async ({ symbol, incomeType, startTime, endTime, limit }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + if (incomeType) params.incomeType = incomeType + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit - const data = await deliveryClient.income(params); - + const data = await deliveryClient.income(params) + + return { + content: [ + { + type: "text", + text: `Retrieved ${data.length || 0} COIN-M Futures income records. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved ${data.length || 0} COIN-M Futures income records. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve COIN-M Futures income: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve COIN-M Futures income: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/index.ts b/src/tools/binance-futures-coinm/index.ts index 5d4d0755..cf79cbdf 100644 --- a/src/tools/binance-futures-coinm/index.ts +++ b/src/tools/binance-futures-coinm/index.ts @@ -1,94 +1,96 @@ // src/tools/binance-futures-coinm/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; - -// Market Data -import { registerBinanceFuturesCOINMPing } from "./ping.js"; -import { registerBinanceFuturesCOINMTime } from "./time.js"; -import { registerBinanceFuturesCOINMExchangeInfo } from "./exchangeInfo.js"; -import { registerBinanceFuturesCOINMDepth } from "./depth.js"; -import { registerBinanceFuturesCOINMTrades } from "./trades.js"; -import { registerBinanceFuturesCOINMHistoricalTrades } from "./historicalTrades.js"; -import { registerBinanceFuturesCOINMAggTrades } from "./aggTrades.js"; -import { registerBinanceFuturesCOINMKlines } from "./klines.js"; -import { registerBinanceFuturesCOINMContinuousKlines } from "./continuousKlines.js"; -import { registerBinanceFuturesCOINMIndexPriceKlines } from "./indexPriceKlines.js"; -import { registerBinanceFuturesCOINMMarkPriceKlines } from "./markPriceKlines.js"; -import { registerBinanceFuturesCOINMPremiumIndex } from "./premiumIndex.js"; -import { registerBinanceFuturesCOINMFundingRate } from "./fundingRate.js"; -import { registerBinanceFuturesCOINMTicker24hr } from "./ticker24hr.js"; -import { registerBinanceFuturesCOINMTickerPrice } from "./tickerPrice.js"; -import { registerBinanceFuturesCOINMBookTicker } from "./bookTicker.js"; -import { registerBinanceFuturesCOINMOpenInterest } from "./openInterest.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" // Account & Trading -import { registerBinanceFuturesCOINMAccount } from "./account.js"; -import { registerBinanceFuturesCOINMBalance } from "./balance.js"; -import { registerBinanceFuturesCOINMPositionRisk } from "./positionRisk.js"; -import { registerBinanceFuturesCOINMNewOrder } from "./newOrder.js"; -import { registerBinanceFuturesCOINMBatchOrders } from "./batchOrders.js"; -import { registerBinanceFuturesCOINMGetOrder } from "./getOrder.js"; -import { registerBinanceFuturesCOINMCancelOrder } from "./cancelOrder.js"; -import { registerBinanceFuturesCOINMCancelAllOrders } from "./cancelAllOrders.js"; -import { registerBinanceFuturesCOINMCancelBatchOrders } from "./cancelBatchOrders.js"; -import { registerBinanceFuturesCOINMOpenOrders } from "./openOrders.js"; -import { registerBinanceFuturesCOINMAllOrders } from "./allOrders.js"; -import { registerBinanceFuturesCOINMUserTrades } from "./userTrades.js"; -import { registerBinanceFuturesCOINMIncome } from "./income.js"; -import { registerBinanceFuturesCOINMLeverage } from "./leverage.js"; -import { registerBinanceFuturesCOINMMarginType } from "./marginType.js"; -import { registerBinanceFuturesCOINMPositionMargin } from "./positionMargin.js"; -import { registerBinanceFuturesCOINMPositionMode } from "./positionMode.js"; -import { registerBinanceFuturesCOINMCommissionRate } from "./commissionRate.js"; -import { registerBinanceFuturesCOINMForceOrders } from "./forceOrders.js"; -import { registerBinanceFuturesCOINMADLQuantile } from "./adlQuantile.js"; - +import { registerBinanceFuturesCOINMAccount } from "./account.js" +import { registerBinanceFuturesCOINMADLQuantile } from "./adlQuantile.js" +import { registerBinanceFuturesCOINMAggTrades } from "./aggTrades.js" +import { registerBinanceFuturesCOINMAllOrders } from "./allOrders.js" +import { registerBinanceFuturesCOINMBalance } from "./balance.js" +import { registerBinanceFuturesCOINMBatchOrders } from "./batchOrders.js" +import { registerBinanceFuturesCOINMBookTicker } from "./bookTicker.js" +import { registerBinanceFuturesCOINMCancelAllOrders } from "./cancelAllOrders.js" +import { registerBinanceFuturesCOINMCancelBatchOrders } from "./cancelBatchOrders.js" +import { registerBinanceFuturesCOINMCancelOrder } from "./cancelOrder.js" +import { registerBinanceFuturesCOINMCommissionRate } from "./commissionRate.js" +import { registerBinanceFuturesCOINMContinuousKlines } from "./continuousKlines.js" +import { registerBinanceFuturesCOINMDepth } from "./depth.js" +import { registerBinanceFuturesCOINMExchangeInfo } from "./exchangeInfo.js" +import { registerBinanceFuturesCOINMForceOrders } from "./forceOrders.js" +import { registerBinanceFuturesCOINMFundingRate } from "./fundingRate.js" +import { registerBinanceFuturesCOINMGetOrder } from "./getOrder.js" +import { registerBinanceFuturesCOINMHistoricalTrades } from "./historicalTrades.js" +import { registerBinanceFuturesCOINMIncome } from "./income.js" +import { registerBinanceFuturesCOINMIndexPriceKlines } from "./indexPriceKlines.js" +import { registerBinanceFuturesCOINMKlines } from "./klines.js" +import { registerBinanceFuturesCOINMLeverage } from "./leverage.js" // User Data Stream -import { registerBinanceFuturesCOINMListenKeyCreate, registerBinanceFuturesCOINMListenKeyRenew, registerBinanceFuturesCOINMListenKeyClose } from "./listenKey.js"; +import { + registerBinanceFuturesCOINMListenKeyClose, + registerBinanceFuturesCOINMListenKeyCreate, + registerBinanceFuturesCOINMListenKeyRenew, +} from "./listenKey.js" +import { registerBinanceFuturesCOINMMarginType } from "./marginType.js" +import { registerBinanceFuturesCOINMMarkPriceKlines } from "./markPriceKlines.js" +import { registerBinanceFuturesCOINMNewOrder } from "./newOrder.js" +import { registerBinanceFuturesCOINMOpenInterest } from "./openInterest.js" +import { registerBinanceFuturesCOINMOpenOrders } from "./openOrders.js" +// Market Data +import { registerBinanceFuturesCOINMPing } from "./ping.js" +import { registerBinanceFuturesCOINMPositionMargin } from "./positionMargin.js" +import { registerBinanceFuturesCOINMPositionMode } from "./positionMode.js" +import { registerBinanceFuturesCOINMPositionRisk } from "./positionRisk.js" +import { registerBinanceFuturesCOINMPremiumIndex } from "./premiumIndex.js" +import { registerBinanceFuturesCOINMTicker24hr } from "./ticker24hr.js" +import { registerBinanceFuturesCOINMTickerPrice } from "./tickerPrice.js" +import { registerBinanceFuturesCOINMTime } from "./time.js" +import { registerBinanceFuturesCOINMTrades } from "./trades.js" +import { registerBinanceFuturesCOINMUserTrades } from "./userTrades.js" export function registerBinanceFuturesCOINMTools(server: McpServer) { - // Market Data - registerBinanceFuturesCOINMPing(server); - registerBinanceFuturesCOINMTime(server); - registerBinanceFuturesCOINMExchangeInfo(server); - registerBinanceFuturesCOINMDepth(server); - registerBinanceFuturesCOINMTrades(server); - registerBinanceFuturesCOINMHistoricalTrades(server); - registerBinanceFuturesCOINMAggTrades(server); - registerBinanceFuturesCOINMKlines(server); - registerBinanceFuturesCOINMContinuousKlines(server); - registerBinanceFuturesCOINMIndexPriceKlines(server); - registerBinanceFuturesCOINMMarkPriceKlines(server); - registerBinanceFuturesCOINMPremiumIndex(server); - registerBinanceFuturesCOINMFundingRate(server); - registerBinanceFuturesCOINMTicker24hr(server); - registerBinanceFuturesCOINMTickerPrice(server); - registerBinanceFuturesCOINMBookTicker(server); - registerBinanceFuturesCOINMOpenInterest(server); + // Market Data + registerBinanceFuturesCOINMPing(server) + registerBinanceFuturesCOINMTime(server) + registerBinanceFuturesCOINMExchangeInfo(server) + registerBinanceFuturesCOINMDepth(server) + registerBinanceFuturesCOINMTrades(server) + registerBinanceFuturesCOINMHistoricalTrades(server) + registerBinanceFuturesCOINMAggTrades(server) + registerBinanceFuturesCOINMKlines(server) + registerBinanceFuturesCOINMContinuousKlines(server) + registerBinanceFuturesCOINMIndexPriceKlines(server) + registerBinanceFuturesCOINMMarkPriceKlines(server) + registerBinanceFuturesCOINMPremiumIndex(server) + registerBinanceFuturesCOINMFundingRate(server) + registerBinanceFuturesCOINMTicker24hr(server) + registerBinanceFuturesCOINMTickerPrice(server) + registerBinanceFuturesCOINMBookTicker(server) + registerBinanceFuturesCOINMOpenInterest(server) - // Account & Trading - registerBinanceFuturesCOINMAccount(server); - registerBinanceFuturesCOINMBalance(server); - registerBinanceFuturesCOINMPositionRisk(server); - registerBinanceFuturesCOINMNewOrder(server); - registerBinanceFuturesCOINMBatchOrders(server); - registerBinanceFuturesCOINMGetOrder(server); - registerBinanceFuturesCOINMCancelOrder(server); - registerBinanceFuturesCOINMCancelAllOrders(server); - registerBinanceFuturesCOINMCancelBatchOrders(server); - registerBinanceFuturesCOINMOpenOrders(server); - registerBinanceFuturesCOINMAllOrders(server); - registerBinanceFuturesCOINMUserTrades(server); - registerBinanceFuturesCOINMIncome(server); - registerBinanceFuturesCOINMLeverage(server); - registerBinanceFuturesCOINMMarginType(server); - registerBinanceFuturesCOINMPositionMargin(server); - registerBinanceFuturesCOINMPositionMode(server); - registerBinanceFuturesCOINMCommissionRate(server); - registerBinanceFuturesCOINMForceOrders(server); - registerBinanceFuturesCOINMADLQuantile(server); + // Account & Trading + registerBinanceFuturesCOINMAccount(server) + registerBinanceFuturesCOINMBalance(server) + registerBinanceFuturesCOINMPositionRisk(server) + registerBinanceFuturesCOINMNewOrder(server) + registerBinanceFuturesCOINMBatchOrders(server) + registerBinanceFuturesCOINMGetOrder(server) + registerBinanceFuturesCOINMCancelOrder(server) + registerBinanceFuturesCOINMCancelAllOrders(server) + registerBinanceFuturesCOINMCancelBatchOrders(server) + registerBinanceFuturesCOINMOpenOrders(server) + registerBinanceFuturesCOINMAllOrders(server) + registerBinanceFuturesCOINMUserTrades(server) + registerBinanceFuturesCOINMIncome(server) + registerBinanceFuturesCOINMLeverage(server) + registerBinanceFuturesCOINMMarginType(server) + registerBinanceFuturesCOINMPositionMargin(server) + registerBinanceFuturesCOINMPositionMode(server) + registerBinanceFuturesCOINMCommissionRate(server) + registerBinanceFuturesCOINMForceOrders(server) + registerBinanceFuturesCOINMADLQuantile(server) - // User Data Stream - registerBinanceFuturesCOINMListenKeyCreate(server); - registerBinanceFuturesCOINMListenKeyRenew(server); - registerBinanceFuturesCOINMListenKeyClose(server); + // User Data Stream + registerBinanceFuturesCOINMListenKeyCreate(server) + registerBinanceFuturesCOINMListenKeyRenew(server) + registerBinanceFuturesCOINMListenKeyClose(server) } diff --git a/src/tools/binance-futures-coinm/indexPriceKlines.ts b/src/tools/binance-futures-coinm/indexPriceKlines.ts index 656f10ff..497a663c 100644 --- a/src/tools/binance-futures-coinm/indexPriceKlines.ts +++ b/src/tools/binance-futures-coinm/indexPriceKlines.ts @@ -1,48 +1,69 @@ // src/tools/binance-futures-coinm/indexPriceKlines.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMIndexPriceKlines(server: McpServer) { - server.tool( - "BinanceFuturesCOINMIndexPriceKlines", - "Get index price Kline/candlestick data for COIN-M Futures.", - { - pair: z.string().describe("Trading pair (e.g., BTCUSD)"), - interval: z.enum([ - "1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "8h", "12h", "1d", "3d", "1w", "1M" - ]).describe("Kline interval"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1500") - }, - async ({ pair, interval, startTime, endTime, limit }) => { - try { - const params: any = { pair, interval }; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; + server.tool( + "BinanceFuturesCOINMIndexPriceKlines", + "Get index price Kline/candlestick data for COIN-M Futures.", + { + pair: z.string().describe("Trading pair (e.g., BTCUSD)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1500"), + }, + async ({ pair, interval, startTime, endTime, limit }) => { + try { + const params: any = { pair, interval } + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit - const data = await deliveryClient.indexPriceKlines(params); - + const data = await deliveryClient.indexPriceKlines(params) + + return { + content: [ + { + type: "text", + text: `Retrieved ${data.length || 0} index price klines for COIN-M Futures ${pair} with ${interval} interval. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved ${data.length || 0} index price klines for COIN-M Futures ${pair} with ${interval} interval. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve COIN-M Futures index price klines: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve COIN-M Futures index price klines: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/klines.ts b/src/tools/binance-futures-coinm/klines.ts index aa440b0f..27e3e605 100644 --- a/src/tools/binance-futures-coinm/klines.ts +++ b/src/tools/binance-futures-coinm/klines.ts @@ -1,48 +1,66 @@ // src/tools/binance-futures-coinm/klines.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMKlines(server: McpServer) { - server.tool( - "BinanceFuturesCOINMKlines", - "Get Kline/candlestick bars for a specific COIN-M Futures trading pair.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), - interval: z.enum([ - "1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "8h", "12h", "1d", "3d", "1w", "1M" - ]).describe("Kline interval"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1500") - }, - async ({ symbol, interval, startTime, endTime, limit }) => { - try { - const params: any = { symbol, interval }; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; + server.tool( + "BinanceFuturesCOINMKlines", + "Get Kline/candlestick bars for a specific COIN-M Futures trading pair.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1500"), + }, + async ({ symbol, interval, startTime, endTime, limit }) => { + try { + const params: any = { symbol, interval } + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit - const data = await deliveryClient.klines(params); - + const data = await deliveryClient.klines(params) + + return { + content: [ + { + type: "text", + text: `Retrieved ${data.length || 0} klines for COIN-M Futures ${symbol} with ${interval} interval. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved ${data.length || 0} klines for COIN-M Futures ${symbol} with ${interval} interval. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve COIN-M Futures klines: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve COIN-M Futures klines: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/leverage.ts b/src/tools/binance-futures-coinm/leverage.ts index f422613e..7f20581d 100644 --- a/src/tools/binance-futures-coinm/leverage.ts +++ b/src/tools/binance-futures-coinm/leverage.ts @@ -1,35 +1,38 @@ // src/tools/binance-futures-coinm/leverage.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMLeverage(server: McpServer) { - server.tool( - "BinanceFuturesCOINMLeverage", - "Change initial leverage for COIN-M futures symbol.", - { - symbol: z.string().describe("Trading symbol"), - leverage: z.number().int().min(1).max(125).describe("Target leverage (1-125)"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await deliveryClient.changeInitialLeverage({ - symbol: params.symbol, - leverage: params.leverage, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - return { - content: [{ type: "text", text: `COIN-M leverage changed: ${JSON.stringify(data)}` }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to change COIN-M leverage: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesCOINMLeverage", + "Change initial leverage for COIN-M futures symbol.", + { + symbol: z.string().describe("Trading symbol"), + leverage: z.number().int().min(1).max(125).describe("Target leverage (1-125)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await deliveryClient.changeInitialLeverage({ + symbol: params.symbol, + leverage: params.leverage, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [{ type: "text", text: `COIN-M leverage changed: ${JSON.stringify(data)}` }], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to change COIN-M leverage: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/listenKey.ts b/src/tools/binance-futures-coinm/listenKey.ts index eb0ffe21..2e3f878d 100644 --- a/src/tools/binance-futures-coinm/listenKey.ts +++ b/src/tools/binance-futures-coinm/listenKey.ts @@ -1,96 +1,97 @@ // src/tools/binance-futures-coinm/listenKey.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMListenKeyCreate(server: McpServer) { - server.tool( - "BinanceFuturesCOINMListenKeyCreate", - "Start a new user data stream for COIN-M Futures. Returns a listenKey for WebSocket connection.", - {}, - async () => { - try { - const data = await deliveryClient.createListenKey(); - + server.tool( + "BinanceFuturesCOINMListenKeyCreate", + "Start a new user data stream for COIN-M Futures. Returns a listenKey for WebSocket connection.", + {}, + async () => { + try { + const data = await deliveryClient.createListenKey() + + return { + content: [ + { + type: "text", + text: `COIN-M Futures listen key created. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `COIN-M Futures listen key created. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to create COIN-M Futures listen key: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to create COIN-M Futures listen key: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } export function registerBinanceFuturesCOINMListenKeyRenew(server: McpServer) { - server.tool( - "BinanceFuturesCOINMListenKeyRenew", - "Keepalive a user data stream to prevent timeout for COIN-M Futures.", - {}, - async () => { - try { - const data = await deliveryClient.keepAliveListenKey(); - + server.tool( + "BinanceFuturesCOINMListenKeyRenew", + "Keepalive a user data stream to prevent timeout for COIN-M Futures.", + {}, + async () => { + try { + const data = await deliveryClient.keepAliveListenKey() - return { - content: [ - { - type: "text", - text: `COIN-M Futures listen key renewed. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to renew COIN-M Futures listen key: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `COIN-M Futures listen key renewed. Response: ${JSON.stringify(data)}`, + }, + ], } - ); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to renew COIN-M Futures listen key: ${errorMessage}` }, + ], + isError: true, + } + } + }, + ) } export function registerBinanceFuturesCOINMListenKeyClose(server: McpServer) { - server.tool( - "BinanceFuturesCOINMListenKeyClose", - "Close a user data stream for COIN-M Futures.", - {}, - async () => { - try { - const data = await deliveryClient.closeListenKey(); - + server.tool( + "BinanceFuturesCOINMListenKeyClose", + "Close a user data stream for COIN-M Futures.", + {}, + async () => { + try { + const data = await deliveryClient.closeListenKey() + + return { + content: [ + { + type: "text", + text: `COIN-M Futures listen key closed. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `COIN-M Futures listen key closed. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to close COIN-M Futures listen key: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to close COIN-M Futures listen key: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/marginType.ts b/src/tools/binance-futures-coinm/marginType.ts index 96c0d318..363e035d 100644 --- a/src/tools/binance-futures-coinm/marginType.ts +++ b/src/tools/binance-futures-coinm/marginType.ts @@ -1,39 +1,40 @@ // src/tools/binance-futures-coinm/marginType.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMMarginType(server: McpServer) { - server.tool( - "BinanceFuturesCOINMMarginType", - "Change margin type for a symbol in COIN-M Futures.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), - marginType: z.enum(["ISOLATED", "CROSSED"]).describe("Margin type: ISOLATED or CROSSED") - }, - async ({ symbol, marginType }) => { - try { - const data = await deliveryClient.marginType({ symbol, marginType }); - + server.tool( + "BinanceFuturesCOINMMarginType", + "Change margin type for a symbol in COIN-M Futures.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + marginType: z.enum(["ISOLATED", "CROSSED"]).describe("Margin type: ISOLATED or CROSSED"), + }, + async ({ symbol, marginType }) => { + try { + const data = await deliveryClient.marginType({ symbol, marginType }) - return { - content: [ - { - type: "text", - text: `COIN-M Futures margin type changed to ${marginType} for ${symbol}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to change COIN-M Futures margin type: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `COIN-M Futures margin type changed to ${marginType} for ${symbol}. Response: ${JSON.stringify(data)}`, + }, + ], } - ); -} + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + return { + content: [ + { type: "text", text: `Failed to change COIN-M Futures margin type: ${errorMessage}` }, + ], + isError: true, + } + } + }, + ) +} diff --git a/src/tools/binance-futures-coinm/markPriceKlines.ts b/src/tools/binance-futures-coinm/markPriceKlines.ts index adf46edd..5fbda9c4 100644 --- a/src/tools/binance-futures-coinm/markPriceKlines.ts +++ b/src/tools/binance-futures-coinm/markPriceKlines.ts @@ -1,48 +1,69 @@ // src/tools/binance-futures-coinm/markPriceKlines.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMMarkPriceKlines(server: McpServer) { - server.tool( - "BinanceFuturesCOINMMarkPriceKlines", - "Get mark price Kline/candlestick data for COIN-M Futures.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), - interval: z.enum([ - "1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "8h", "12h", "1d", "3d", "1w", "1M" - ]).describe("Kline interval"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1500") - }, - async ({ symbol, interval, startTime, endTime, limit }) => { - try { - const params: any = { symbol, interval }; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; + server.tool( + "BinanceFuturesCOINMMarkPriceKlines", + "Get mark price Kline/candlestick data for COIN-M Futures.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1500"), + }, + async ({ symbol, interval, startTime, endTime, limit }) => { + try { + const params: any = { symbol, interval } + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit - const data = await deliveryClient.markPriceKlines(params); - + const data = await deliveryClient.markPriceKlines(params) + + return { + content: [ + { + type: "text", + text: `Retrieved ${data.length || 0} mark price klines for COIN-M Futures ${symbol} with ${interval} interval. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved ${data.length || 0} mark price klines for COIN-M Futures ${symbol} with ${interval} interval. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve COIN-M Futures mark price klines: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve COIN-M Futures mark price klines: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/market-api/aggTrades.ts b/src/tools/binance-futures-coinm/market-api/aggTrades.ts index e8569751..5a7e9ead 100644 --- a/src/tools/binance-futures-coinm/market-api/aggTrades.ts +++ b/src/tools/binance-futures-coinm/market-api/aggTrades.ts @@ -5,46 +5,51 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/aggTrades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryAggTrades(server: McpServer) { - server.tool( - "BinanceDeliveryAggTrades", - "Get compressed/aggregate trades for a COIN-M Futures symbol. Trades that fill at the same time, from the same order, with the same price will be aggregated.", - { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - fromId: z.number().int().optional().describe("ID to get aggregate trades from INCLUSIVE"), - startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().int().optional().describe("End timestamp in milliseconds"), - limit: z.number().int().optional().describe("Number of trades (default 500, max 1000)") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.aggTrades({ - symbol: params.symbol, - ...(params.fromId && { fromId: params.fromId }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `📊 Aggregate Trades for ${params.symbol}\n\nTrades: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get aggregate trades: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryAggTrades", + "Get compressed/aggregate trades for a COIN-M Futures symbol. Trades that fill at the same time, from the same order, with the same price will be aggregated.", + { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + fromId: z.number().int().optional().describe("ID to get aggregate trades from INCLUSIVE"), + startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().int().optional().describe("End timestamp in milliseconds"), + limit: z.number().int().optional().describe("Number of trades (default 500, max 1000)"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.aggTrades({ + symbol: params.symbol, + ...(params.fromId && { fromId: params.fromId }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📊 Aggregate Trades for ${params.symbol}\n\nTrades: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get aggregate trades: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/market-api/bookTicker.ts b/src/tools/binance-futures-coinm/market-api/bookTicker.ts index 1e66e306..2d606de7 100644 --- a/src/tools/binance-futures-coinm/market-api/bookTicker.ts +++ b/src/tools/binance-futures-coinm/market-api/bookTicker.ts @@ -5,40 +5,48 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/bookTicker.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryTickerBookTicker(server: McpServer) { - server.tool( - "BinanceDeliveryTickerBookTicker", - "Get best bid/ask price and quantity for COIN-M Futures symbol(s).", - { - symbol: z.string().optional().describe("Contract symbol (e.g., BTCUSD_PERP). If not provided, returns all symbols"), - pair: z.string().optional().describe("Filter by underlying pair (e.g., BTCUSD)") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.tickerBookTicker({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.pair && { pair: params.pair }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `📖 Book Ticker${params.symbol ? ` for ${params.symbol}` : ''}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get book ticker: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryTickerBookTicker", + "Get best bid/ask price and quantity for COIN-M Futures symbol(s).", + { + symbol: z + .string() + .optional() + .describe("Contract symbol (e.g., BTCUSD_PERP). If not provided, returns all symbols"), + pair: z.string().optional().describe("Filter by underlying pair (e.g., BTCUSD)"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.tickerBookTicker({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.pair && { pair: params.pair }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📖 Book Ticker${params.symbol ? ` for ${params.symbol}` : ""}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get book ticker: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/market-api/continuousKlines.ts b/src/tools/binance-futures-coinm/market-api/continuousKlines.ts index 393f8bad..120f00d3 100644 --- a/src/tools/binance-futures-coinm/market-api/continuousKlines.ts +++ b/src/tools/binance-futures-coinm/market-api/continuousKlines.ts @@ -5,52 +5,73 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/continuousKlines.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryContinuousKlines(server: McpServer) { - server.tool( - "BinanceDeliveryContinuousKlines", - "Get continuous contract kline/candlestick data for a COIN-M Futures pair. Continuous contract uses the price of the current delivery period contract.", - { - pair: z.string().describe("Underlying pair (e.g., BTCUSD)"), - contractType: z.enum(["PERPETUAL", "CURRENT_QUARTER", "NEXT_QUARTER"]).describe("Contract type"), - interval: z.enum([ - "1m", "3m", "5m", "15m", "30m", - "1h", "2h", "4h", "6h", "8h", "12h", - "1d", "3d", "1w", "1M" - ]).describe("Kline interval"), - startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().int().optional().describe("End timestamp in milliseconds"), - limit: z.number().int().optional().describe("Number of klines (default 500, max 1500)") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.continuousKlines({ - pair: params.pair, - contractType: params.contractType, - interval: params.interval, - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `🕯️ Continuous Klines for ${params.pair} ${params.contractType} (${params.interval})\n\nCandles: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get continuous klines: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryContinuousKlines", + "Get continuous contract kline/candlestick data for a COIN-M Futures pair. Continuous contract uses the price of the current delivery period contract.", + { + pair: z.string().describe("Underlying pair (e.g., BTCUSD)"), + contractType: z + .enum(["PERPETUAL", "CURRENT_QUARTER", "NEXT_QUARTER"]) + .describe("Contract type"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().int().optional().describe("End timestamp in milliseconds"), + limit: z.number().int().optional().describe("Number of klines (default 500, max 1500)"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.continuousKlines({ + pair: params.pair, + contractType: params.contractType, + interval: params.interval, + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `🕯️ Continuous Klines for ${params.pair} ${params.contractType} (${params.interval})\n\nCandles: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get continuous klines: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/market-api/depth.ts b/src/tools/binance-futures-coinm/market-api/depth.ts index 94bdfd6f..5c9dcf8f 100644 --- a/src/tools/binance-futures-coinm/market-api/depth.ts +++ b/src/tools/binance-futures-coinm/market-api/depth.ts @@ -5,40 +5,49 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/depth.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryDepth(server: McpServer) { - server.tool( - "BinanceDeliveryDepth", - "Get COIN-M Futures order book depth for a symbol.", - { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP, BTCUSD_230630)"), - limit: z.number().int().optional().describe("Depth limit: 5, 10, 20, 50, 100, 500, 1000 (default 500)") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.depth({ - symbol: params.symbol, - ...(params.limit && { limit: params.limit }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `📚 Order Book for ${params.symbol}\n\nLast Update ID: ${data.lastUpdateId}\nBids: ${data.bids?.length || 0}\nAsks: ${data.asks?.length || 0}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get order book: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryDepth", + "Get COIN-M Futures order book depth for a symbol.", + { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP, BTCUSD_230630)"), + limit: z + .number() + .int() + .optional() + .describe("Depth limit: 5, 10, 20, 50, 100, 500, 1000 (default 500)"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.depth({ + symbol: params.symbol, + ...(params.limit && { limit: params.limit }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📚 Order Book for ${params.symbol}\n\nLast Update ID: ${data.lastUpdateId}\nBids: ${data.bids?.length || 0}\nAsks: ${data.asks?.length || 0}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get order book: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/market-api/exchangeInfo.ts b/src/tools/binance-futures-coinm/market-api/exchangeInfo.ts index f5fb6341..48b5b9c3 100644 --- a/src/tools/binance-futures-coinm/market-api/exchangeInfo.ts +++ b/src/tools/binance-futures-coinm/market-api/exchangeInfo.ts @@ -5,34 +5,38 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/exchangeInfo.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryExchangeInfo(server: McpServer) { - server.tool( - "BinanceDeliveryExchangeInfo", - "Get COIN-M Futures exchange information including trading rules, symbol info, and rate limits.", - {}, - async () => { - try { - const response = await deliveryClient.restAPI.exchangeInfo(); - const data = await response.data(); - - const symbolCount = data.symbols?.length || 0; - - return { - content: [{ - type: "text", - text: `📊 COIN-M Futures Exchange Info\n\nTimezone: ${data.timezone}\nServer Time: ${new Date(data.serverTime).toISOString()}\nTotal Symbols: ${symbolCount}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get exchange info: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryExchangeInfo", + "Get COIN-M Futures exchange information including trading rules, symbol info, and rate limits.", + {}, + async () => { + try { + const response = await deliveryClient.restAPI.exchangeInfo() + const data = await response.data() + + const symbolCount = data.symbols?.length || 0 + + return { + content: [ + { + type: "text", + text: `📊 COIN-M Futures Exchange Info\n\nTimezone: ${data.timezone}\nServer Time: ${new Date(data.serverTime).toISOString()}\nTotal Symbols: ${symbolCount}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get exchange info: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/market-api/fundingRate.ts b/src/tools/binance-futures-coinm/market-api/fundingRate.ts index b91749e0..6f3d66a0 100644 --- a/src/tools/binance-futures-coinm/market-api/fundingRate.ts +++ b/src/tools/binance-futures-coinm/market-api/fundingRate.ts @@ -5,44 +5,49 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/fundingRate.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryFundingRate(server: McpServer) { - server.tool( - "BinanceDeliveryFundingRate", - "Get funding rate history for a COIN-M Futures perpetual contract.", - { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().int().optional().describe("End timestamp in milliseconds"), - limit: z.number().int().optional().describe("Number of results (default 100, max 1000)") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.fundingRate({ - symbol: params.symbol, - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `📊 Funding Rate History for ${params.symbol}\n\nRecords: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get funding rate: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryFundingRate", + "Get funding rate history for a COIN-M Futures perpetual contract.", + { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().int().optional().describe("End timestamp in milliseconds"), + limit: z.number().int().optional().describe("Number of results (default 100, max 1000)"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.fundingRate({ + symbol: params.symbol, + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📊 Funding Rate History for ${params.symbol}\n\nRecords: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get funding rate: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/market-api/historicalTrades.ts b/src/tools/binance-futures-coinm/market-api/historicalTrades.ts index 1a82fcdc..17d2dd84 100644 --- a/src/tools/binance-futures-coinm/market-api/historicalTrades.ts +++ b/src/tools/binance-futures-coinm/market-api/historicalTrades.ts @@ -5,42 +5,47 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/historicalTrades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryHistoricalTrades(server: McpServer) { - server.tool( - "BinanceDeliveryHistoricalTrades", - "Get older market historical trades for a COIN-M Futures symbol. Requires API key.", - { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - limit: z.number().int().optional().describe("Number of trades (default 500, max 1000)"), - fromId: z.number().int().optional().describe("Trade ID to fetch from (older trades)") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.historicalTrades({ - symbol: params.symbol, - ...(params.limit && { limit: params.limit }), - ...(params.fromId && { fromId: params.fromId }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `📜 Historical Trades for ${params.symbol}\n\nTrades: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get historical trades: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryHistoricalTrades", + "Get older market historical trades for a COIN-M Futures symbol. Requires API key.", + { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + limit: z.number().int().optional().describe("Number of trades (default 500, max 1000)"), + fromId: z.number().int().optional().describe("Trade ID to fetch from (older trades)"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.historicalTrades({ + symbol: params.symbol, + ...(params.limit && { limit: params.limit }), + ...(params.fromId && { fromId: params.fromId }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📜 Historical Trades for ${params.symbol}\n\nTrades: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get historical trades: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/market-api/index.ts b/src/tools/binance-futures-coinm/market-api/index.ts index 04119655..52f41911 100644 --- a/src/tools/binance-futures-coinm/market-api/index.ts +++ b/src/tools/binance-futures-coinm/market-api/index.ts @@ -5,54 +5,55 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceDeliveryPing } from "./ping.js"; -import { registerBinanceDeliveryTime } from "./time.js"; -import { registerBinanceDeliveryExchangeInfo } from "./exchangeInfo.js"; -import { registerBinanceDeliveryDepth } from "./depth.js"; -import { registerBinanceDeliveryTrades } from "./trades.js"; -import { registerBinanceDeliveryHistoricalTrades } from "./historicalTrades.js"; -import { registerBinanceDeliveryAggTrades } from "./aggTrades.js"; -import { registerBinanceDeliveryKlines } from "./klines.js"; -import { registerBinanceDeliveryContinuousKlines } from "./continuousKlines.js"; -import { registerBinanceDeliveryIndexPriceKlines } from "./indexPriceKlines.js"; -import { registerBinanceDeliveryMarkPriceKlines } from "./markPriceKlines.js"; -import { registerBinanceDeliveryPremiumIndex } from "./premiumIndex.js"; -import { registerBinanceDeliveryFundingRate } from "./fundingRate.js"; -import { registerBinanceDelivery24hrTicker } from "./ticker24hr.js"; -import { registerBinanceDeliveryTickerPrice } from "./tickerPrice.js"; -import { registerBinanceDeliveryTickerBookTicker } from "./bookTicker.js"; -import { registerBinanceDeliveryOpenInterest } from "./openInterest.js"; -import { registerBinanceDeliveryOpenInterestHist } from "./openInterestHist.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceDeliveryAggTrades } from "./aggTrades.js" +import { registerBinanceDeliveryTickerBookTicker } from "./bookTicker.js" +import { registerBinanceDeliveryContinuousKlines } from "./continuousKlines.js" +import { registerBinanceDeliveryDepth } from "./depth.js" +import { registerBinanceDeliveryExchangeInfo } from "./exchangeInfo.js" +import { registerBinanceDeliveryFundingRate } from "./fundingRate.js" +import { registerBinanceDeliveryHistoricalTrades } from "./historicalTrades.js" +import { registerBinanceDeliveryIndexPriceKlines } from "./indexPriceKlines.js" +import { registerBinanceDeliveryKlines } from "./klines.js" +import { registerBinanceDeliveryMarkPriceKlines } from "./markPriceKlines.js" +import { registerBinanceDeliveryOpenInterest } from "./openInterest.js" +import { registerBinanceDeliveryOpenInterestHist } from "./openInterestHist.js" +import { registerBinanceDeliveryPing } from "./ping.js" +import { registerBinanceDeliveryPremiumIndex } from "./premiumIndex.js" +import { registerBinanceDelivery24hrTicker } from "./ticker24hr.js" +import { registerBinanceDeliveryTickerPrice } from "./tickerPrice.js" +import { registerBinanceDeliveryTime } from "./time.js" +import { registerBinanceDeliveryTrades } from "./trades.js" export function registerBinanceDeliveryMarketApiTools(server: McpServer) { - // System Status - registerBinanceDeliveryPing(server); - registerBinanceDeliveryTime(server); - registerBinanceDeliveryExchangeInfo(server); - - // Order Book & Trades - registerBinanceDeliveryDepth(server); - registerBinanceDeliveryTrades(server); - registerBinanceDeliveryHistoricalTrades(server); - registerBinanceDeliveryAggTrades(server); - - // Klines/Candlesticks - registerBinanceDeliveryKlines(server); - registerBinanceDeliveryContinuousKlines(server); - registerBinanceDeliveryIndexPriceKlines(server); - registerBinanceDeliveryMarkPriceKlines(server); - - // Pricing & Funding - registerBinanceDeliveryPremiumIndex(server); - registerBinanceDeliveryFundingRate(server); - - // Tickers - registerBinanceDelivery24hrTicker(server); - registerBinanceDeliveryTickerPrice(server); - registerBinanceDeliveryTickerBookTicker(server); - - // Open Interest - registerBinanceDeliveryOpenInterest(server); - registerBinanceDeliveryOpenInterestHist(server); + // System Status + registerBinanceDeliveryPing(server) + registerBinanceDeliveryTime(server) + registerBinanceDeliveryExchangeInfo(server) + + // Order Book & Trades + registerBinanceDeliveryDepth(server) + registerBinanceDeliveryTrades(server) + registerBinanceDeliveryHistoricalTrades(server) + registerBinanceDeliveryAggTrades(server) + + // Klines/Candlesticks + registerBinanceDeliveryKlines(server) + registerBinanceDeliveryContinuousKlines(server) + registerBinanceDeliveryIndexPriceKlines(server) + registerBinanceDeliveryMarkPriceKlines(server) + + // Pricing & Funding + registerBinanceDeliveryPremiumIndex(server) + registerBinanceDeliveryFundingRate(server) + + // Tickers + registerBinanceDelivery24hrTicker(server) + registerBinanceDeliveryTickerPrice(server) + registerBinanceDeliveryTickerBookTicker(server) + + // Open Interest + registerBinanceDeliveryOpenInterest(server) + registerBinanceDeliveryOpenInterestHist(server) } diff --git a/src/tools/binance-futures-coinm/market-api/indexPriceKlines.ts b/src/tools/binance-futures-coinm/market-api/indexPriceKlines.ts index e7f5d024..c30a4096 100644 --- a/src/tools/binance-futures-coinm/market-api/indexPriceKlines.ts +++ b/src/tools/binance-futures-coinm/market-api/indexPriceKlines.ts @@ -5,50 +5,69 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/indexPriceKlines.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryIndexPriceKlines(server: McpServer) { - server.tool( - "BinanceDeliveryIndexPriceKlines", - "Get index price kline/candlestick data for a COIN-M Futures pair.", - { - pair: z.string().describe("Underlying pair (e.g., BTCUSD)"), - interval: z.enum([ - "1m", "3m", "5m", "15m", "30m", - "1h", "2h", "4h", "6h", "8h", "12h", - "1d", "3d", "1w", "1M" - ]).describe("Kline interval"), - startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().int().optional().describe("End timestamp in milliseconds"), - limit: z.number().int().optional().describe("Number of klines (default 500, max 1500)") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.indexPriceKlines({ - pair: params.pair, - interval: params.interval, - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `📈 Index Price Klines for ${params.pair} (${params.interval})\n\nCandles: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get index price klines: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryIndexPriceKlines", + "Get index price kline/candlestick data for a COIN-M Futures pair.", + { + pair: z.string().describe("Underlying pair (e.g., BTCUSD)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().int().optional().describe("End timestamp in milliseconds"), + limit: z.number().int().optional().describe("Number of klines (default 500, max 1500)"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.indexPriceKlines({ + pair: params.pair, + interval: params.interval, + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📈 Index Price Klines for ${params.pair} (${params.interval})\n\nCandles: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get index price klines: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/market-api/klines.ts b/src/tools/binance-futures-coinm/market-api/klines.ts index 000201d6..9697cf30 100644 --- a/src/tools/binance-futures-coinm/market-api/klines.ts +++ b/src/tools/binance-futures-coinm/market-api/klines.ts @@ -5,50 +5,69 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/klines.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryKlines(server: McpServer) { - server.tool( - "BinanceDeliveryKlines", - "Get kline/candlestick data for a COIN-M Futures symbol.", - { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - interval: z.enum([ - "1m", "3m", "5m", "15m", "30m", - "1h", "2h", "4h", "6h", "8h", "12h", - "1d", "3d", "1w", "1M" - ]).describe("Kline interval"), - startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().int().optional().describe("End timestamp in milliseconds"), - limit: z.number().int().optional().describe("Number of klines (default 500, max 1500)") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.klines({ - symbol: params.symbol, - interval: params.interval, - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `🕯️ Klines for ${params.symbol} (${params.interval})\n\nCandles: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get klines: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryKlines", + "Get kline/candlestick data for a COIN-M Futures symbol.", + { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().int().optional().describe("End timestamp in milliseconds"), + limit: z.number().int().optional().describe("Number of klines (default 500, max 1500)"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.klines({ + symbol: params.symbol, + interval: params.interval, + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `🕯️ Klines for ${params.symbol} (${params.interval})\n\nCandles: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get klines: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/market-api/markPriceKlines.ts b/src/tools/binance-futures-coinm/market-api/markPriceKlines.ts index 84197832..96051698 100644 --- a/src/tools/binance-futures-coinm/market-api/markPriceKlines.ts +++ b/src/tools/binance-futures-coinm/market-api/markPriceKlines.ts @@ -5,50 +5,69 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/markPriceKlines.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryMarkPriceKlines(server: McpServer) { - server.tool( - "BinanceDeliveryMarkPriceKlines", - "Get mark price kline/candlestick data for a COIN-M Futures symbol. Mark price is used for liquidation calculations.", - { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - interval: z.enum([ - "1m", "3m", "5m", "15m", "30m", - "1h", "2h", "4h", "6h", "8h", "12h", - "1d", "3d", "1w", "1M" - ]).describe("Kline interval"), - startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().int().optional().describe("End timestamp in milliseconds"), - limit: z.number().int().optional().describe("Number of klines (default 500, max 1500)") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.markPriceKlines({ - symbol: params.symbol, - interval: params.interval, - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `📊 Mark Price Klines for ${params.symbol} (${params.interval})\n\nCandles: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get mark price klines: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryMarkPriceKlines", + "Get mark price kline/candlestick data for a COIN-M Futures symbol. Mark price is used for liquidation calculations.", + { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().int().optional().describe("End timestamp in milliseconds"), + limit: z.number().int().optional().describe("Number of klines (default 500, max 1500)"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.markPriceKlines({ + symbol: params.symbol, + interval: params.interval, + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📊 Mark Price Klines for ${params.symbol} (${params.interval})\n\nCandles: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get mark price klines: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/market-api/openInterest.ts b/src/tools/binance-futures-coinm/market-api/openInterest.ts index 047515cb..1e93ca2f 100644 --- a/src/tools/binance-futures-coinm/market-api/openInterest.ts +++ b/src/tools/binance-futures-coinm/market-api/openInterest.ts @@ -5,38 +5,43 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/openInterest.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryOpenInterest(server: McpServer) { - server.tool( - "BinanceDeliveryOpenInterest", - "Get present open interest for a specific COIN-M Futures contract.", - { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.openInterest({ - symbol: params.symbol - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `📊 Open Interest for ${params.symbol}\n\nOpen Interest: ${data.openInterest}\nSymbol: ${data.symbol}\nPair: ${data.pair}\nContract Type: ${data.contractType}\nTime: ${new Date(data.time).toISOString()}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get open interest: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryOpenInterest", + "Get present open interest for a specific COIN-M Futures contract.", + { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.openInterest({ + symbol: params.symbol, + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📊 Open Interest for ${params.symbol}\n\nOpen Interest: ${data.openInterest}\nSymbol: ${data.symbol}\nPair: ${data.pair}\nContract Type: ${data.contractType}\nTime: ${new Date(data.time).toISOString()}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get open interest: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/market-api/openInterestHist.ts b/src/tools/binance-futures-coinm/market-api/openInterestHist.ts index fc14c28c..c990fa0a 100644 --- a/src/tools/binance-futures-coinm/market-api/openInterestHist.ts +++ b/src/tools/binance-futures-coinm/market-api/openInterestHist.ts @@ -5,48 +5,59 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/openInterestHist.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryOpenInterestHist(server: McpServer) { - server.tool( - "BinanceDeliveryOpenInterestHist", - "Get historical open interest for a COIN-M Futures pair. Requires VIP 2+ or higher.", - { - pair: z.string().describe("Underlying pair (e.g., BTCUSD)"), - contractType: z.enum(["ALL", "PERPETUAL", "CURRENT_QUARTER", "NEXT_QUARTER"]).describe("Contract type"), - period: z.enum(["5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d"]).describe("Time period"), - startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().int().optional().describe("End timestamp in milliseconds"), - limit: z.number().int().optional().describe("Number of results (default 30, max 500)") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.openInterestHist({ - pair: params.pair, - contractType: params.contractType, - period: params.period, - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `📈 Historical Open Interest for ${params.pair} ${params.contractType}\n\nPeriod: ${params.period}\nRecords: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get open interest history: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryOpenInterestHist", + "Get historical open interest for a COIN-M Futures pair. Requires VIP 2+ or higher.", + { + pair: z.string().describe("Underlying pair (e.g., BTCUSD)"), + contractType: z + .enum(["ALL", "PERPETUAL", "CURRENT_QUARTER", "NEXT_QUARTER"]) + .describe("Contract type"), + period: z + .enum(["5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d"]) + .describe("Time period"), + startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().int().optional().describe("End timestamp in milliseconds"), + limit: z.number().int().optional().describe("Number of results (default 30, max 500)"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.openInterestHist({ + pair: params.pair, + contractType: params.contractType, + period: params.period, + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📈 Historical Open Interest for ${params.pair} ${params.contractType}\n\nPeriod: ${params.period}\nRecords: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `❌ Failed to get open interest history: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/market-api/ping.ts b/src/tools/binance-futures-coinm/market-api/ping.ts index cc26e15a..9c9c0271 100644 --- a/src/tools/binance-futures-coinm/market-api/ping.ts +++ b/src/tools/binance-futures-coinm/market-api/ping.ts @@ -5,32 +5,36 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/ping.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryPing(server: McpServer) { - server.tool( - "BinanceDeliveryPing", - "Test connectivity to the COIN-M Futures API. Returns empty object if successful.", - {}, - async () => { - try { - const response = await deliveryClient.restAPI.ping(); - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ COIN-M Futures API is reachable\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ COIN-M Futures API ping failed: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryPing", + "Test connectivity to the COIN-M Futures API. Returns empty object if successful.", + {}, + async () => { + try { + const response = await deliveryClient.restAPI.ping() + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ COIN-M Futures API is reachable\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ COIN-M Futures API ping failed: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/market-api/premiumIndex.ts b/src/tools/binance-futures-coinm/market-api/premiumIndex.ts index 8e328825..4c42b9ee 100644 --- a/src/tools/binance-futures-coinm/market-api/premiumIndex.ts +++ b/src/tools/binance-futures-coinm/market-api/premiumIndex.ts @@ -5,38 +5,46 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/premiumIndex.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryPremiumIndex(server: McpServer) { - server.tool( - "BinanceDeliveryPremiumIndex", - "Get mark price and funding rate for COIN-M Futures contracts.", - { - symbol: z.string().optional().describe("Contract symbol (e.g., BTCUSD_PERP). If not provided, returns all symbols") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.premiumIndex({ - ...(params.symbol && { symbol: params.symbol }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `💰 Premium Index${params.symbol ? ` for ${params.symbol}` : ''}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get premium index: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryPremiumIndex", + "Get mark price and funding rate for COIN-M Futures contracts.", + { + symbol: z + .string() + .optional() + .describe("Contract symbol (e.g., BTCUSD_PERP). If not provided, returns all symbols"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.premiumIndex({ + ...(params.symbol && { symbol: params.symbol }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `💰 Premium Index${params.symbol ? ` for ${params.symbol}` : ""}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get premium index: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/market-api/ticker24hr.ts b/src/tools/binance-futures-coinm/market-api/ticker24hr.ts index 2edb153f..a1b1d705 100644 --- a/src/tools/binance-futures-coinm/market-api/ticker24hr.ts +++ b/src/tools/binance-futures-coinm/market-api/ticker24hr.ts @@ -5,40 +5,48 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/ticker24hr.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDelivery24hrTicker(server: McpServer) { - server.tool( - "BinanceDelivery24hrTicker", - "Get 24hr rolling window price change statistics for COIN-M Futures.", - { - symbol: z.string().optional().describe("Contract symbol (e.g., BTCUSD_PERP). If not provided, returns all symbols"), - pair: z.string().optional().describe("Filter by underlying pair (e.g., BTCUSD)") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.ticker24hr({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.pair && { pair: params.pair }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `📊 24hr Ticker${params.symbol ? ` for ${params.symbol}` : ''}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get 24hr ticker: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDelivery24hrTicker", + "Get 24hr rolling window price change statistics for COIN-M Futures.", + { + symbol: z + .string() + .optional() + .describe("Contract symbol (e.g., BTCUSD_PERP). If not provided, returns all symbols"), + pair: z.string().optional().describe("Filter by underlying pair (e.g., BTCUSD)"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.ticker24hr({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.pair && { pair: params.pair }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📊 24hr Ticker${params.symbol ? ` for ${params.symbol}` : ""}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get 24hr ticker: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/market-api/tickerPrice.ts b/src/tools/binance-futures-coinm/market-api/tickerPrice.ts index be696481..26531c32 100644 --- a/src/tools/binance-futures-coinm/market-api/tickerPrice.ts +++ b/src/tools/binance-futures-coinm/market-api/tickerPrice.ts @@ -5,40 +5,48 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/tickerPrice.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryTickerPrice(server: McpServer) { - server.tool( - "BinanceDeliveryTickerPrice", - "Get latest price for COIN-M Futures symbol(s).", - { - symbol: z.string().optional().describe("Contract symbol (e.g., BTCUSD_PERP). If not provided, returns all symbols"), - pair: z.string().optional().describe("Filter by underlying pair (e.g., BTCUSD)") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.tickerPrice({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.pair && { pair: params.pair }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `💰 Symbol Price${params.symbol ? ` for ${params.symbol}` : ''}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get ticker price: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryTickerPrice", + "Get latest price for COIN-M Futures symbol(s).", + { + symbol: z + .string() + .optional() + .describe("Contract symbol (e.g., BTCUSD_PERP). If not provided, returns all symbols"), + pair: z.string().optional().describe("Filter by underlying pair (e.g., BTCUSD)"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.tickerPrice({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.pair && { pair: params.pair }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `💰 Symbol Price${params.symbol ? ` for ${params.symbol}` : ""}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get ticker price: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/market-api/time.ts b/src/tools/binance-futures-coinm/market-api/time.ts index a6a93a31..343bb9b1 100644 --- a/src/tools/binance-futures-coinm/market-api/time.ts +++ b/src/tools/binance-futures-coinm/market-api/time.ts @@ -5,32 +5,36 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/time.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryTime(server: McpServer) { - server.tool( - "BinanceDeliveryTime", - "Get the current server time from COIN-M Futures API.", - {}, - async () => { - try { - const response = await deliveryClient.restAPI.time(); - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `🕐 COIN-M Futures Server Time\n\nTimestamp: ${data.serverTime}\nDate: ${new Date(data.serverTime).toISOString()}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get server time: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryTime", + "Get the current server time from COIN-M Futures API.", + {}, + async () => { + try { + const response = await deliveryClient.restAPI.time() + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `🕐 COIN-M Futures Server Time\n\nTimestamp: ${data.serverTime}\nDate: ${new Date(data.serverTime).toISOString()}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get server time: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/market-api/trades.ts b/src/tools/binance-futures-coinm/market-api/trades.ts index 1c539134..c0920643 100644 --- a/src/tools/binance-futures-coinm/market-api/trades.ts +++ b/src/tools/binance-futures-coinm/market-api/trades.ts @@ -5,40 +5,45 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/trades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryTrades(server: McpServer) { - server.tool( - "BinanceDeliveryTrades", - "Get recent trades for a COIN-M Futures symbol.", - { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - limit: z.number().int().optional().describe("Number of trades (default 500, max 1000)") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.trades({ - symbol: params.symbol, - ...(params.limit && { limit: params.limit }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `📈 Recent Trades for ${params.symbol}\n\nTrades: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get trades: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryTrades", + "Get recent trades for a COIN-M Futures symbol.", + { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + limit: z.number().int().optional().describe("Number of trades (default 500, max 1000)"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.trades({ + symbol: params.symbol, + ...(params.limit && { limit: params.limit }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📈 Recent Trades for ${params.symbol}\n\nTrades: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get trades: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/newOrder.ts b/src/tools/binance-futures-coinm/newOrder.ts index f856c65c..b3072263 100644 --- a/src/tools/binance-futures-coinm/newOrder.ts +++ b/src/tools/binance-futures-coinm/newOrder.ts @@ -1,51 +1,67 @@ // src/tools/binance-futures-coinm/newOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMNewOrder(server: McpServer) { - server.tool( - "BinanceFuturesCOINMNewOrder", - "Send a new COIN-M futures order.", - { - symbol: z.string().describe("Trading symbol (e.g., BTCUSD_PERP)"), - side: z.enum(["BUY", "SELL"]).describe("Order side"), - type: z.enum(["LIMIT", "MARKET", "STOP", "STOP_MARKET", "TAKE_PROFIT", "TAKE_PROFIT_MARKET", "TRAILING_STOP_MARKET"]).describe("Order type"), - positionSide: z.enum(["BOTH", "LONG", "SHORT"]).optional().describe("Position side for hedge mode"), - quantity: z.number().optional().describe("Order quantity"), - price: z.number().optional().describe("Order price (required for LIMIT orders)"), - stopPrice: z.number().optional().describe("Stop price for stop orders"), - timeInForce: z.enum(["GTC", "IOC", "FOK", "GTX"]).optional().describe("Time in force"), - reduceOnly: z.boolean().optional().describe("Reduce only order"), - newClientOrderId: z.string().optional().describe("Client order ID"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await deliveryClient.newOrder({ - symbol: params.symbol, - side: params.side, - type: params.type, - ...(params.positionSide && { positionSide: params.positionSide }), - ...(params.quantity && { quantity: params.quantity }), - ...(params.price && { price: params.price }), - ...(params.stopPrice && { stopPrice: params.stopPrice }), - ...(params.timeInForce && { timeInForce: params.timeInForce }), - ...(params.reduceOnly !== undefined && { reduceOnly: params.reduceOnly }), - ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - return { - content: [{ type: "text", text: `COIN-M order placed: ${JSON.stringify(data)}` }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to place COIN-M order: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesCOINMNewOrder", + "Send a new COIN-M futures order.", + { + symbol: z.string().describe("Trading symbol (e.g., BTCUSD_PERP)"), + side: z.enum(["BUY", "SELL"]).describe("Order side"), + type: z + .enum([ + "LIMIT", + "MARKET", + "STOP", + "STOP_MARKET", + "TAKE_PROFIT", + "TAKE_PROFIT_MARKET", + "TRAILING_STOP_MARKET", + ]) + .describe("Order type"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe("Position side for hedge mode"), + quantity: z.number().optional().describe("Order quantity"), + price: z.number().optional().describe("Order price (required for LIMIT orders)"), + stopPrice: z.number().optional().describe("Stop price for stop orders"), + timeInForce: z.enum(["GTC", "IOC", "FOK", "GTX"]).optional().describe("Time in force"), + reduceOnly: z.boolean().optional().describe("Reduce only order"), + newClientOrderId: z.string().optional().describe("Client order ID"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await deliveryClient.newOrder({ + symbol: params.symbol, + side: params.side, + type: params.type, + ...(params.positionSide && { positionSide: params.positionSide }), + ...(params.quantity && { quantity: params.quantity }), + ...(params.price && { price: params.price }), + ...(params.stopPrice && { stopPrice: params.stopPrice }), + ...(params.timeInForce && { timeInForce: params.timeInForce }), + ...(params.reduceOnly !== undefined && { reduceOnly: params.reduceOnly }), + ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [{ type: "text", text: `COIN-M order placed: ${JSON.stringify(data)}` }], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to place COIN-M order: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/openInterest.ts b/src/tools/binance-futures-coinm/openInterest.ts index a201e6a5..8b48a784 100644 --- a/src/tools/binance-futures-coinm/openInterest.ts +++ b/src/tools/binance-futures-coinm/openInterest.ts @@ -1,37 +1,42 @@ // src/tools/binance-futures-coinm/openInterest.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMOpenInterest(server: McpServer) { - server.tool( - "BinanceFuturesCOINMOpenInterest", - "Get present open interest of a specific symbol for COIN-M Futures.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)") - }, - async ({ symbol }) => { - try { - const data = await deliveryClient.openInterest({ symbol }); - + server.tool( + "BinanceFuturesCOINMOpenInterest", + "Get present open interest of a specific symbol for COIN-M Futures.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + }, + async ({ symbol }) => { + try { + const data = await deliveryClient.openInterest({ symbol }) + + return { + content: [ + { + type: "text", + text: `Retrieved COIN-M Futures open interest for ${symbol}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved COIN-M Futures open interest for ${symbol}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve COIN-M Futures open interest: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve COIN-M Futures open interest: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/openOrders.ts b/src/tools/binance-futures-coinm/openOrders.ts index b6dc3e8b..63ca65bd 100644 --- a/src/tools/binance-futures-coinm/openOrders.ts +++ b/src/tools/binance-futures-coinm/openOrders.ts @@ -1,35 +1,38 @@ // src/tools/binance-futures-coinm/openOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMOpenOrders(server: McpServer) { - server.tool( - "BinanceFuturesCOINMOpenOrders", - "Get current COIN-M futures open orders.", - { - symbol: z.string().optional().describe("Trading symbol (optional)"), - pair: z.string().optional().describe("Trading pair"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await deliveryClient.openOrders({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.pair && { pair: params.pair }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - return { - content: [{ type: "text", text: `COIN-M open orders: ${JSON.stringify(data)}` }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get COIN-M open orders: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesCOINMOpenOrders", + "Get current COIN-M futures open orders.", + { + symbol: z.string().optional().describe("Trading symbol (optional)"), + pair: z.string().optional().describe("Trading pair"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await deliveryClient.openOrders({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.pair && { pair: params.pair }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [{ type: "text", text: `COIN-M open orders: ${JSON.stringify(data)}` }], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get COIN-M open orders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/ping.ts b/src/tools/binance-futures-coinm/ping.ts index a40095ec..6addb900 100644 --- a/src/tools/binance-futures-coinm/ping.ts +++ b/src/tools/binance-futures-coinm/ping.ts @@ -1,33 +1,33 @@ // src/tools/binance-futures-coinm/ping.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMPing(server: McpServer) { - server.tool( - "BinanceFuturesCOINMPing", - "Test connectivity to the COIN-M Futures REST API.", - {}, - async () => { - try { - const data = await deliveryClient.ping(); - - return { - content: [ - { - type: "text", - text: `COIN-M Futures API connectivity test successful. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to ping COIN-M Futures API: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceFuturesCOINMPing", + "Test connectivity to the COIN-M Futures REST API.", + {}, + async () => { + try { + const data = await deliveryClient.ping() + + return { + content: [ + { + type: "text", + text: `COIN-M Futures API connectivity test successful. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to ping COIN-M Futures API: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/positionMargin.ts b/src/tools/binance-futures-coinm/positionMargin.ts index 51706e64..e7207502 100644 --- a/src/tools/binance-futures-coinm/positionMargin.ts +++ b/src/tools/binance-futures-coinm/positionMargin.ts @@ -1,44 +1,51 @@ // src/tools/binance-futures-coinm/positionMargin.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMPositionMargin(server: McpServer) { - server.tool( - "BinanceFuturesCOINMPositionMargin", - "Modify isolated position margin for COIN-M Futures.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), - positionSide: z.enum(["BOTH", "LONG", "SHORT"]).optional().describe("Position side. Default BOTH for One-way Mode"), - amount: z.number().describe("Amount to add or remove"), - type: z.number().describe("1: Add margin, 2: Remove margin") - }, - async ({ symbol, positionSide, amount, type }) => { - try { - const params: any = { symbol, amount, type }; - if (positionSide) params.positionSide = positionSide; + server.tool( + "BinanceFuturesCOINMPositionMargin", + "Modify isolated position margin for COIN-M Futures.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe("Position side. Default BOTH for One-way Mode"), + amount: z.number().describe("Amount to add or remove"), + type: z.number().describe("1: Add margin, 2: Remove margin"), + }, + async ({ symbol, positionSide, amount, type }) => { + try { + const params: any = { symbol, amount, type } + if (positionSide) params.positionSide = positionSide - const data = await deliveryClient.positionMargin(params); - + const data = await deliveryClient.positionMargin(params) - return { - content: [ - { - type: "text", - text: `COIN-M Futures position margin modified for ${symbol}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to modify COIN-M Futures position margin: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `COIN-M Futures position margin modified for ${symbol}. Response: ${JSON.stringify(data)}`, + }, + ], } - ); -} + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + return { + content: [ + { + type: "text", + text: `Failed to modify COIN-M Futures position margin: ${errorMessage}`, + }, + ], + isError: true, + } + } + }, + ) +} diff --git a/src/tools/binance-futures-coinm/positionMode.ts b/src/tools/binance-futures-coinm/positionMode.ts index 06da8f34..8b0c5d12 100644 --- a/src/tools/binance-futures-coinm/positionMode.ts +++ b/src/tools/binance-futures-coinm/positionMode.ts @@ -1,37 +1,44 @@ // src/tools/binance-futures-coinm/positionMode.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMPositionMode(server: McpServer) { - server.tool( - "BinanceFuturesCOINMPositionMode", - "Change position mode for COIN-M Futures (One-way or Hedge Mode).", - { - dualSidePosition: z.boolean().describe("true: Hedge Mode, false: One-way Mode") - }, - async ({ dualSidePosition }) => { - try { - const data = await deliveryClient.positionSideDual({ dualSidePosition: dualSidePosition ? "true" : "false" }); - + server.tool( + "BinanceFuturesCOINMPositionMode", + "Change position mode for COIN-M Futures (One-way or Hedge Mode).", + { + dualSidePosition: z.boolean().describe("true: Hedge Mode, false: One-way Mode"), + }, + async ({ dualSidePosition }) => { + try { + const data = await deliveryClient.positionSideDual({ + dualSidePosition: dualSidePosition ? "true" : "false", + }) + + return { + content: [ + { + type: "text", + text: `COIN-M Futures position mode changed to ${dualSidePosition ? "Hedge Mode" : "One-way Mode"}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `COIN-M Futures position mode changed to ${dualSidePosition ? 'Hedge Mode' : 'One-way Mode'}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to change COIN-M Futures position mode: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to change COIN-M Futures position mode: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/positionRisk.ts b/src/tools/binance-futures-coinm/positionRisk.ts index e035ad17..bc262749 100644 --- a/src/tools/binance-futures-coinm/positionRisk.ts +++ b/src/tools/binance-futures-coinm/positionRisk.ts @@ -1,35 +1,38 @@ // src/tools/binance-futures-coinm/positionRisk.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMPositionRisk(server: McpServer) { - server.tool( - "BinanceFuturesCOINMPositionRisk", - "Get COIN-M futures position information.", - { - marginAsset: z.string().optional().describe("Margin asset"), - pair: z.string().optional().describe("Trading pair"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await deliveryClient.getPositionRisk({ - ...(params.marginAsset && { marginAsset: params.marginAsset }), - ...(params.pair && { pair: params.pair }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - return { - content: [{ type: "text", text: `COIN-M position risk: ${JSON.stringify(data)}` }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get COIN-M position risk: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesCOINMPositionRisk", + "Get COIN-M futures position information.", + { + marginAsset: z.string().optional().describe("Margin asset"), + pair: z.string().optional().describe("Trading pair"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await deliveryClient.getPositionRisk({ + ...(params.marginAsset && { marginAsset: params.marginAsset }), + ...(params.pair && { pair: params.pair }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [{ type: "text", text: `COIN-M position risk: ${JSON.stringify(data)}` }], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get COIN-M position risk: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/premiumIndex.ts b/src/tools/binance-futures-coinm/premiumIndex.ts index 382bf906..5f364ec1 100644 --- a/src/tools/binance-futures-coinm/premiumIndex.ts +++ b/src/tools/binance-futures-coinm/premiumIndex.ts @@ -1,40 +1,50 @@ // src/tools/binance-futures-coinm/premiumIndex.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMPremiumIndex(server: McpServer) { - server.tool( - "BinanceFuturesCOINMPremiumIndex", - "Get mark price and funding rate for COIN-M Futures.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSD_PERP). If not provided, returns all symbols") - }, - async ({ symbol }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; + server.tool( + "BinanceFuturesCOINMPremiumIndex", + "Get mark price and funding rate for COIN-M Futures.", + { + symbol: z + .string() + .optional() + .describe( + "Symbol of the trading pair (e.g., BTCUSD_PERP). If not provided, returns all symbols", + ), + }, + async ({ symbol }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol - const data = await deliveryClient.premiumIndex(params); - + const data = await deliveryClient.premiumIndex(params) + + return { + content: [ + { + type: "text", + text: `Retrieved COIN-M Futures premium index${symbol ? ` for ${symbol}` : " for all symbols"}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved COIN-M Futures premium index${symbol ? ` for ${symbol}` : ' for all symbols'}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve COIN-M Futures premium index: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve COIN-M Futures premium index: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/ticker24hr.ts b/src/tools/binance-futures-coinm/ticker24hr.ts index f813d372..d830e387 100644 --- a/src/tools/binance-futures-coinm/ticker24hr.ts +++ b/src/tools/binance-futures-coinm/ticker24hr.ts @@ -1,42 +1,52 @@ // src/tools/binance-futures-coinm/ticker24hr.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMTicker24hr(server: McpServer) { - server.tool( - "BinanceFuturesCOINMTicker24hr", - "Get 24-hour rolling window price change statistics for COIN-M Futures.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSD_PERP). If not provided, returns all symbols"), - pair: z.string().optional().describe("Trading pair (e.g., BTCUSD)") - }, - async ({ symbol, pair }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - if (pair) params.pair = pair; + server.tool( + "BinanceFuturesCOINMTicker24hr", + "Get 24-hour rolling window price change statistics for COIN-M Futures.", + { + symbol: z + .string() + .optional() + .describe( + "Symbol of the trading pair (e.g., BTCUSD_PERP). If not provided, returns all symbols", + ), + pair: z.string().optional().describe("Trading pair (e.g., BTCUSD)"), + }, + async ({ symbol, pair }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + if (pair) params.pair = pair - const data = await deliveryClient.ticker24hr(params); - + const data = await deliveryClient.ticker24hr(params) + + return { + content: [ + { + type: "text", + text: `Retrieved COIN-M Futures 24hr ticker${symbol ? ` for ${symbol}` : pair ? ` for pair ${pair}` : " for all symbols"}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved COIN-M Futures 24hr ticker${symbol ? ` for ${symbol}` : pair ? ` for pair ${pair}` : ' for all symbols'}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve COIN-M Futures 24hr ticker: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve COIN-M Futures 24hr ticker: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/tickerPrice.ts b/src/tools/binance-futures-coinm/tickerPrice.ts index 2197ea1a..03c01a1c 100644 --- a/src/tools/binance-futures-coinm/tickerPrice.ts +++ b/src/tools/binance-futures-coinm/tickerPrice.ts @@ -1,42 +1,52 @@ // src/tools/binance-futures-coinm/tickerPrice.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMTickerPrice(server: McpServer) { - server.tool( - "BinanceFuturesCOINMTickerPrice", - "Get latest price for a symbol or symbols for COIN-M Futures.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSD_PERP). If not provided, returns all symbols"), - pair: z.string().optional().describe("Trading pair (e.g., BTCUSD)") - }, - async ({ symbol, pair }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - if (pair) params.pair = pair; + server.tool( + "BinanceFuturesCOINMTickerPrice", + "Get latest price for a symbol or symbols for COIN-M Futures.", + { + symbol: z + .string() + .optional() + .describe( + "Symbol of the trading pair (e.g., BTCUSD_PERP). If not provided, returns all symbols", + ), + pair: z.string().optional().describe("Trading pair (e.g., BTCUSD)"), + }, + async ({ symbol, pair }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + if (pair) params.pair = pair - const data = await deliveryClient.tickerPrice(params); - + const data = await deliveryClient.tickerPrice(params) + + return { + content: [ + { + type: "text", + text: `Retrieved COIN-M Futures ticker price${symbol ? ` for ${symbol}` : pair ? ` for pair ${pair}` : " for all symbols"}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved COIN-M Futures ticker price${symbol ? ` for ${symbol}` : pair ? ` for pair ${pair}` : ' for all symbols'}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve COIN-M Futures ticker price: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve COIN-M Futures ticker price: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/time.ts b/src/tools/binance-futures-coinm/time.ts index 64627f51..8d1c16b2 100644 --- a/src/tools/binance-futures-coinm/time.ts +++ b/src/tools/binance-futures-coinm/time.ts @@ -1,33 +1,35 @@ // src/tools/binance-futures-coinm/time.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMTime(server: McpServer) { - server.tool( - "BinanceFuturesCOINMTime", - "Get the current server time from the COIN-M Futures API.", - {}, - async () => { - try { - const data = await deliveryClient.time(); - - return { - content: [ - { - type: "text", - text: `COIN-M Futures server time: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get COIN-M Futures server time: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceFuturesCOINMTime", + "Get the current server time from the COIN-M Futures API.", + {}, + async () => { + try { + const data = await deliveryClient.time() + + return { + content: [ + { + type: "text", + text: `COIN-M Futures server time: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to get COIN-M Futures server time: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/trade-api/allOrders.ts b/src/tools/binance-futures-coinm/trade-api/allOrders.ts index 42c7f12a..90d45eb8 100644 --- a/src/tools/binance-futures-coinm/trade-api/allOrders.ts +++ b/src/tools/binance-futures-coinm/trade-api/allOrders.ts @@ -5,50 +5,55 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/allOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryAllOrders(server: McpServer) { - server.tool( - "BinanceDeliveryAllOrders", - "Get all COIN-M Futures account orders (active, canceled, or filled).", - { - symbol: z.string().optional().describe("Contract symbol filter"), - pair: z.string().optional().describe("Filter by underlying pair"), - orderId: z.number().int().optional().describe("Return orders >= this orderId"), - startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().int().optional().describe("End timestamp in milliseconds"), - limit: z.number().int().optional().describe("Number of results (default 500, max 1000)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.allOrders({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.pair && { pair: params.pair }), - ...(params.orderId && { orderId: params.orderId }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `📋 All Orders\n\nCount: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get all orders: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryAllOrders", + "Get all COIN-M Futures account orders (active, canceled, or filled).", + { + symbol: z.string().optional().describe("Contract symbol filter"), + pair: z.string().optional().describe("Filter by underlying pair"), + orderId: z.number().int().optional().describe("Return orders >= this orderId"), + startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().int().optional().describe("End timestamp in milliseconds"), + limit: z.number().int().optional().describe("Number of results (default 500, max 1000)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.allOrders({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.pair && { pair: params.pair }), + ...(params.orderId && { orderId: params.orderId }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📋 All Orders\n\nCount: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get all orders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/trade-api/batchOrders.ts b/src/tools/binance-futures-coinm/trade-api/batchOrders.ts index 35ee426e..5624e0b5 100644 --- a/src/tools/binance-futures-coinm/trade-api/batchOrders.ts +++ b/src/tools/binance-futures-coinm/trade-api/batchOrders.ts @@ -5,44 +5,51 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/batchOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryBatchOrders(server: McpServer) { - server.tool( - "BinanceDeliveryBatchOrders", - "Place multiple COIN-M Futures orders in batch (max 5 orders).", - { - batchOrders: z.string().describe("JSON string array of orders. Each order must have: symbol, side, type") - }, - async (params) => { - try { - const orders = JSON.parse(params.batchOrders); - - if (!Array.isArray(orders) || orders.length === 0 || orders.length > 5) { - return { - content: [{ type: "text", text: "Error: batchOrders must be an array of 1-5 orders" }], - isError: true - }; - } + server.tool( + "BinanceDeliveryBatchOrders", + "Place multiple COIN-M Futures orders in batch (max 5 orders).", + { + batchOrders: z + .string() + .describe("JSON string array of orders. Each order must have: symbol, side, type"), + }, + async (params) => { + try { + const orders = JSON.parse(params.batchOrders) + + if (!Array.isArray(orders) || orders.length === 0 || orders.length > 5) { + return { + content: [{ type: "text", text: "Error: batchOrders must be an array of 1-5 orders" }], + isError: true, + } + } + + const response = await deliveryClient.restAPI.placeMultipleOrders({ batchOrders: orders }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Batch orders placed!\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - const response = await deliveryClient.restAPI.placeMultipleOrders({ batchOrders: orders }); - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Batch orders placed!\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to place batch orders: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to place batch orders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/trade-api/cancelAllOrders.ts b/src/tools/binance-futures-coinm/trade-api/cancelAllOrders.ts index 1f11d3e9..0a88ca52 100644 --- a/src/tools/binance-futures-coinm/trade-api/cancelAllOrders.ts +++ b/src/tools/binance-futures-coinm/trade-api/cancelAllOrders.ts @@ -5,40 +5,45 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/cancelAllOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryCancelAllOrders(server: McpServer) { - server.tool( - "BinanceDeliveryCancelAllOrders", - "Cancel all open COIN-M Futures orders for a symbol. ⚠️ Use with caution!", - { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.cancelAllOpenOrders({ - symbol: params.symbol, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ All orders cancelled for ${params.symbol}!\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to cancel all orders: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryCancelAllOrders", + "Cancel all open COIN-M Futures orders for a symbol. ⚠️ Use with caution!", + { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.cancelAllOpenOrders({ + symbol: params.symbol, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ All orders cancelled for ${params.symbol}!\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to cancel all orders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/trade-api/cancelBatchOrders.ts b/src/tools/binance-futures-coinm/trade-api/cancelBatchOrders.ts index b8640bcf..45a3f521 100644 --- a/src/tools/binance-futures-coinm/trade-api/cancelBatchOrders.ts +++ b/src/tools/binance-futures-coinm/trade-api/cancelBatchOrders.ts @@ -5,51 +5,63 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/cancelBatchOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryCancelBatchOrders(server: McpServer) { - server.tool( - "BinanceDeliveryCancelBatchOrders", - "Cancel multiple COIN-M Futures orders in batch (max 10).", - { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - orderIdList: z.string().optional().describe("JSON array of order IDs to cancel"), - origClientOrderIdList: z.string().optional().describe("JSON array of client order IDs"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - if (!params.orderIdList && !params.origClientOrderIdList) { - return { - content: [{ type: "text", text: "Error: Either orderIdList or origClientOrderIdList must be provided" }], - isError: true - }; - } - - const response = await deliveryClient.restAPI.cancelMultipleOrders({ - symbol: params.symbol, - ...(params.orderIdList && { orderIdList: JSON.parse(params.orderIdList) }), - ...(params.origClientOrderIdList && { origClientOrderIdList: JSON.parse(params.origClientOrderIdList) }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Batch orders cancelled!\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to cancel batch orders: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryCancelBatchOrders", + "Cancel multiple COIN-M Futures orders in batch (max 10).", + { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + orderIdList: z.string().optional().describe("JSON array of order IDs to cancel"), + origClientOrderIdList: z.string().optional().describe("JSON array of client order IDs"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + if (!params.orderIdList && !params.origClientOrderIdList) { + return { + content: [ + { + type: "text", + text: "Error: Either orderIdList or origClientOrderIdList must be provided", + }, + ], + isError: true, + } + } + + const response = await deliveryClient.restAPI.cancelMultipleOrders({ + symbol: params.symbol, + ...(params.orderIdList && { orderIdList: JSON.parse(params.orderIdList) }), + ...(params.origClientOrderIdList && { + origClientOrderIdList: JSON.parse(params.origClientOrderIdList), + }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Batch orders cancelled!\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to cancel batch orders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/trade-api/cancelOrder.ts b/src/tools/binance-futures-coinm/trade-api/cancelOrder.ts index 5521e3b9..2afba823 100644 --- a/src/tools/binance-futures-coinm/trade-api/cancelOrder.ts +++ b/src/tools/binance-futures-coinm/trade-api/cancelOrder.ts @@ -5,51 +5,58 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/cancelOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryCancelOrder(server: McpServer) { - server.tool( - "BinanceDeliveryCancelOrder", - "Cancel an active COIN-M Futures order.", - { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - orderId: z.number().int().optional().describe("Order ID to cancel"), - origClientOrderId: z.string().optional().describe("Original client order ID"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - if (!params.orderId && !params.origClientOrderId) { - return { - content: [{ type: "text", text: "Error: Either orderId or origClientOrderId must be provided" }], - isError: true - }; - } - - const response = await deliveryClient.restAPI.cancelOrder({ - symbol: params.symbol, - ...(params.orderId && { orderId: params.orderId }), - ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Order cancelled!\n\nSymbol: ${data.symbol}\nOrder ID: ${data.orderId}\nStatus: ${data.status}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to cancel order: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryCancelOrder", + "Cancel an active COIN-M Futures order.", + { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + orderId: z.number().int().optional().describe("Order ID to cancel"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + if (!params.orderId && !params.origClientOrderId) { + return { + content: [ + { type: "text", text: "Error: Either orderId or origClientOrderId must be provided" }, + ], + isError: true, + } + } + + const response = await deliveryClient.restAPI.cancelOrder({ + symbol: params.symbol, + ...(params.orderId && { orderId: params.orderId }), + ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Order cancelled!\n\nSymbol: ${data.symbol}\nOrder ID: ${data.orderId}\nStatus: ${data.status}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to cancel order: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/trade-api/changeLeverage.ts b/src/tools/binance-futures-coinm/trade-api/changeLeverage.ts index 5c9a3a6a..e8bd17c3 100644 --- a/src/tools/binance-futures-coinm/trade-api/changeLeverage.ts +++ b/src/tools/binance-futures-coinm/trade-api/changeLeverage.ts @@ -5,42 +5,47 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/changeLeverage.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryChangeLeverage(server: McpServer) { - server.tool( - "BinanceDeliveryChangeLeverage", - "Change initial leverage for a COIN-M Futures symbol. ⚠️ Higher leverage = higher risk.", - { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - leverage: z.number().int().min(1).max(125).describe("Target leverage (1-125)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.changeInitialLeverage({ - symbol: params.symbol, - leverage: params.leverage, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Leverage changed!\n\nSymbol: ${data.symbol}\nNew Leverage: ${data.leverage}x\nMax Notional: ${data.maxQty}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to change leverage: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryChangeLeverage", + "Change initial leverage for a COIN-M Futures symbol. ⚠️ Higher leverage = higher risk.", + { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + leverage: z.number().int().min(1).max(125).describe("Target leverage (1-125)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.changeInitialLeverage({ + symbol: params.symbol, + leverage: params.leverage, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Leverage changed!\n\nSymbol: ${data.symbol}\nNew Leverage: ${data.leverage}x\nMax Notional: ${data.maxQty}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to change leverage: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/trade-api/changeMarginType.ts b/src/tools/binance-futures-coinm/trade-api/changeMarginType.ts index f20025fa..b79152ed 100644 --- a/src/tools/binance-futures-coinm/trade-api/changeMarginType.ts +++ b/src/tools/binance-futures-coinm/trade-api/changeMarginType.ts @@ -5,42 +5,47 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/changeMarginType.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryChangeMarginType(server: McpServer) { - server.tool( - "BinanceDeliveryChangeMarginType", - "Change margin type between ISOLATED and CROSSED for COIN-M Futures.", - { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - marginType: z.enum(["ISOLATED", "CROSSED"]).describe("Margin type"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.changeMarginType({ - symbol: params.symbol, - marginType: params.marginType, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Margin type changed to ${params.marginType}!\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to change margin type: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryChangeMarginType", + "Change margin type between ISOLATED and CROSSED for COIN-M Futures.", + { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + marginType: z.enum(["ISOLATED", "CROSSED"]).describe("Margin type"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.changeMarginType({ + symbol: params.symbol, + marginType: params.marginType, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Margin type changed to ${params.marginType}!\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to change margin type: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/trade-api/changePositionMode.ts b/src/tools/binance-futures-coinm/trade-api/changePositionMode.ts index 601eb3ca..815f88fe 100644 --- a/src/tools/binance-futures-coinm/trade-api/changePositionMode.ts +++ b/src/tools/binance-futures-coinm/trade-api/changePositionMode.ts @@ -5,41 +5,46 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/changePositionMode.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryChangePositionMode(server: McpServer) { - server.tool( - "BinanceDeliveryChangePositionMode", - "Change COIN-M Futures position mode between Hedge Mode and One-way Mode.", - { - dualSidePosition: z.boolean().describe("true = Hedge Mode, false = One-way Mode"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.changePositionMode({ - dualSidePosition: params.dualSidePosition, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - const mode = params.dualSidePosition ? "Hedge Mode" : "One-way Mode"; - - return { - content: [{ - type: "text", - text: `✅ Position mode changed to ${mode}!\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to change position mode: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryChangePositionMode", + "Change COIN-M Futures position mode between Hedge Mode and One-way Mode.", + { + dualSidePosition: z.boolean().describe("true = Hedge Mode, false = One-way Mode"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.changePositionMode({ + dualSidePosition: params.dualSidePosition, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + const mode = params.dualSidePosition ? "Hedge Mode" : "One-way Mode" + + return { + content: [ + { + type: "text", + text: `✅ Position mode changed to ${mode}!\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to change position mode: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/trade-api/countdownCancelAll.ts b/src/tools/binance-futures-coinm/trade-api/countdownCancelAll.ts index 83ba5f4b..2e395230 100644 --- a/src/tools/binance-futures-coinm/trade-api/countdownCancelAll.ts +++ b/src/tools/binance-futures-coinm/trade-api/countdownCancelAll.ts @@ -5,44 +5,50 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/countdownCancelAll.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryCountdownCancelAll(server: McpServer) { - server.tool( - "BinanceDeliveryCountdownCancelAll", - "Set countdown timer to cancel all COIN-M orders. Dead man's switch. Set to 0 to cancel.", - { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - countdownTime: z.number().int().describe("Countdown in milliseconds. 0 to cancel. Min 10000"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.autoCancelAllOpenOrders({ - symbol: params.symbol, - countdownTime: params.countdownTime, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: params.countdownTime === 0 - ? `✅ Countdown cancelled!\n\n${JSON.stringify(data, null, 2)}` - : `⏱️ Countdown set! Orders will cancel in ${params.countdownTime / 1000}s\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to set countdown: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryCountdownCancelAll", + "Set countdown timer to cancel all COIN-M orders. Dead man's switch. Set to 0 to cancel.", + { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + countdownTime: z.number().int().describe("Countdown in milliseconds. 0 to cancel. Min 10000"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.autoCancelAllOpenOrders({ + symbol: params.symbol, + countdownTime: params.countdownTime, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: + params.countdownTime === 0 + ? `✅ Countdown cancelled!\n\n${JSON.stringify(data, null, 2)}` + : `⏱️ Countdown set! Orders will cancel in ${params.countdownTime / 1000}s\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to set countdown: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/trade-api/getAllOrders.ts b/src/tools/binance-futures-coinm/trade-api/getAllOrders.ts index bbce5cc3..4e58c48f 100644 --- a/src/tools/binance-futures-coinm/trade-api/getAllOrders.ts +++ b/src/tools/binance-futures-coinm/trade-api/getAllOrders.ts @@ -5,55 +5,64 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/getAllOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryGetAllOrders(server: McpServer) { - server.tool( - "BinanceDeliveryGetAllOrders", - "Get all COIN-M Futures orders (active, canceled, filled) for a symbol.", - { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - pair: z.string().optional().describe("Contract pair (e.g., BTCUSD)"), - orderId: z.number().int().optional().describe("Order ID to start from"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - limit: z.number().int().optional().describe("Number of orders (default 500, max 1000)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.allOrders({ - symbol: params.symbol, - ...(params.pair && { pair: params.pair }), - ...(params.orderId && { orderId: params.orderId }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceDeliveryGetAllOrders", + "Get all COIN-M Futures orders (active, canceled, filled) for a symbol.", + { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + pair: z.string().optional().describe("Contract pair (e.g., BTCUSD)"), + orderId: z.number().int().optional().describe("Order ID to start from"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + limit: z.number().int().optional().describe("Number of orders (default 500, max 1000)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.allOrders({ + symbol: params.symbol, + ...(params.pair && { pair: params.pair }), + ...(params.orderId && { orderId: params.orderId }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); - const orders = Array.isArray(data) ? data : [data]; + const data = await response.data() + const orders = Array.isArray(data) ? data : [data] - const summary = orders.slice(0, 10).map((o: any) => - `${o.symbol}: ${o.side} ${o.type} ${o.origQty} @ ${o.price || 'MARKET'} - ${o.status}` - ).join('\n'); + const summary = orders + .slice(0, 10) + .map( + (o: any) => + `${o.symbol}: ${o.side} ${o.type} ${o.origQty} @ ${o.price || "MARKET"} - ${o.status}`, + ) + .join("\n") + + return { + content: [ + { + type: "text", + text: `📋 All Orders for ${params.symbol} (${orders.length} total)\n\n${summary}\n\nFull data: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `📋 All Orders for ${params.symbol} (${orders.length} total)\n\n${summary}\n\nFull data: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get all orders: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to get all orders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/trade-api/getOrder.ts b/src/tools/binance-futures-coinm/trade-api/getOrder.ts index c394d70c..6f57e367 100644 --- a/src/tools/binance-futures-coinm/trade-api/getOrder.ts +++ b/src/tools/binance-futures-coinm/trade-api/getOrder.ts @@ -5,51 +5,58 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/getOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryGetOrder(server: McpServer) { - server.tool( - "BinanceDeliveryGetOrder", - "Query a specific COIN-M Futures order's status.", - { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - orderId: z.number().int().optional().describe("Order ID"), - origClientOrderId: z.string().optional().describe("Original client order ID"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - if (!params.orderId && !params.origClientOrderId) { - return { - content: [{ type: "text", text: "Error: Either orderId or origClientOrderId must be provided" }], - isError: true - }; - } - - const response = await deliveryClient.restAPI.queryOrder({ - symbol: params.symbol, - ...(params.orderId && { orderId: params.orderId }), - ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `📋 Order Details\n\nSymbol: ${data.symbol}\nOrder ID: ${data.orderId}\nStatus: ${data.status}\nSide: ${data.side}\nType: ${data.type}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get order: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryGetOrder", + "Query a specific COIN-M Futures order's status.", + { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + orderId: z.number().int().optional().describe("Order ID"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + if (!params.orderId && !params.origClientOrderId) { + return { + content: [ + { type: "text", text: "Error: Either orderId or origClientOrderId must be provided" }, + ], + isError: true, + } + } + + const response = await deliveryClient.restAPI.queryOrder({ + symbol: params.symbol, + ...(params.orderId && { orderId: params.orderId }), + ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📋 Order Details\n\nSymbol: ${data.symbol}\nOrder ID: ${data.orderId}\nStatus: ${data.status}\nSide: ${data.side}\nType: ${data.type}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get order: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/trade-api/index.ts b/src/tools/binance-futures-coinm/trade-api/index.ts index 8f635876..773fe2e2 100644 --- a/src/tools/binance-futures-coinm/trade-api/index.ts +++ b/src/tools/binance-futures-coinm/trade-api/index.ts @@ -5,44 +5,45 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceDeliveryNewOrder } from "./newOrder.js"; -import { registerBinanceDeliveryBatchOrders } from "./batchOrders.js"; -import { registerBinanceDeliveryGetOrder } from "./getOrder.js"; -import { registerBinanceDeliveryCancelOrder } from "./cancelOrder.js"; -import { registerBinanceDeliveryCancelAllOrders } from "./cancelAllOrders.js"; -import { registerBinanceDeliveryCancelBatchOrders } from "./cancelBatchOrders.js"; -import { registerBinanceDeliveryCountdownCancelAll } from "./countdownCancelAll.js"; -import { registerBinanceDeliveryOpenOrder } from "./openOrder.js"; -import { registerBinanceDeliveryOpenOrders } from "./openOrders.js"; -import { registerBinanceDeliveryAllOrders } from "./allOrders.js"; -import { registerBinanceDeliveryChangeLeverage } from "./changeLeverage.js"; -import { registerBinanceDeliveryChangeMarginType } from "./changeMarginType.js"; -import { registerBinanceDeliveryModifyIsolatedPositionMargin } from "./modifyIsolatedPositionMargin.js"; -import { registerBinanceDeliveryChangePositionMode } from "./changePositionMode.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceDeliveryAllOrders } from "./allOrders.js" +import { registerBinanceDeliveryBatchOrders } from "./batchOrders.js" +import { registerBinanceDeliveryCancelAllOrders } from "./cancelAllOrders.js" +import { registerBinanceDeliveryCancelBatchOrders } from "./cancelBatchOrders.js" +import { registerBinanceDeliveryCancelOrder } from "./cancelOrder.js" +import { registerBinanceDeliveryChangeLeverage } from "./changeLeverage.js" +import { registerBinanceDeliveryChangeMarginType } from "./changeMarginType.js" +import { registerBinanceDeliveryChangePositionMode } from "./changePositionMode.js" +import { registerBinanceDeliveryCountdownCancelAll } from "./countdownCancelAll.js" +import { registerBinanceDeliveryGetOrder } from "./getOrder.js" +import { registerBinanceDeliveryModifyIsolatedPositionMargin } from "./modifyIsolatedPositionMargin.js" +import { registerBinanceDeliveryNewOrder } from "./newOrder.js" +import { registerBinanceDeliveryOpenOrder } from "./openOrder.js" +import { registerBinanceDeliveryOpenOrders } from "./openOrders.js" export function registerBinanceDeliveryTradeApiTools(server: McpServer) { - // Order Placement - registerBinanceDeliveryNewOrder(server); - registerBinanceDeliveryBatchOrders(server); - - // Order Query - registerBinanceDeliveryGetOrder(server); - registerBinanceDeliveryOpenOrder(server); - registerBinanceDeliveryOpenOrders(server); - registerBinanceDeliveryAllOrders(server); - - // Order Cancellation - registerBinanceDeliveryCancelOrder(server); - registerBinanceDeliveryCancelAllOrders(server); - registerBinanceDeliveryCancelBatchOrders(server); - registerBinanceDeliveryCountdownCancelAll(server); - - // Leverage & Margin - registerBinanceDeliveryChangeLeverage(server); - registerBinanceDeliveryChangeMarginType(server); - registerBinanceDeliveryModifyIsolatedPositionMargin(server); - - // Position Mode - registerBinanceDeliveryChangePositionMode(server); + // Order Placement + registerBinanceDeliveryNewOrder(server) + registerBinanceDeliveryBatchOrders(server) + + // Order Query + registerBinanceDeliveryGetOrder(server) + registerBinanceDeliveryOpenOrder(server) + registerBinanceDeliveryOpenOrders(server) + registerBinanceDeliveryAllOrders(server) + + // Order Cancellation + registerBinanceDeliveryCancelOrder(server) + registerBinanceDeliveryCancelAllOrders(server) + registerBinanceDeliveryCancelBatchOrders(server) + registerBinanceDeliveryCountdownCancelAll(server) + + // Leverage & Margin + registerBinanceDeliveryChangeLeverage(server) + registerBinanceDeliveryChangeMarginType(server) + registerBinanceDeliveryModifyIsolatedPositionMargin(server) + + // Position Mode + registerBinanceDeliveryChangePositionMode(server) } diff --git a/src/tools/binance-futures-coinm/trade-api/modifyIsolatedPositionMargin.ts b/src/tools/binance-futures-coinm/trade-api/modifyIsolatedPositionMargin.ts index e94d37bf..ecb4aa7c 100644 --- a/src/tools/binance-futures-coinm/trade-api/modifyIsolatedPositionMargin.ts +++ b/src/tools/binance-futures-coinm/trade-api/modifyIsolatedPositionMargin.ts @@ -5,47 +5,55 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/modifyIsolatedPositionMargin.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryModifyIsolatedPositionMargin(server: McpServer) { - server.tool( - "BinanceDeliveryModifyIsolatedPositionMargin", - "Add or reduce margin to/from an isolated COIN-M Futures position.", - { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - amount: z.string().describe("Amount of margin to add or reduce"), - type: z.enum(["1", "2"]).describe("1 = Add margin, 2 = Reduce margin"), - positionSide: z.enum(["BOTH", "LONG", "SHORT"]).optional().describe("Position side for Hedge Mode"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.modifyIsolatedPositionMargin({ - symbol: params.symbol, - amount: params.amount, - type: parseInt(params.type) as 1 | 2, - ...(params.positionSide && { positionSide: params.positionSide }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - const action = params.type === "1" ? "added to" : "reduced from"; - - return { - content: [{ - type: "text", - text: `✅ Margin ${action} position!\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to modify position margin: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryModifyIsolatedPositionMargin", + "Add or reduce margin to/from an isolated COIN-M Futures position.", + { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + amount: z.string().describe("Amount of margin to add or reduce"), + type: z.enum(["1", "2"]).describe("1 = Add margin, 2 = Reduce margin"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe("Position side for Hedge Mode"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.modifyIsolatedPositionMargin({ + symbol: params.symbol, + amount: params.amount, + type: parseInt(params.type) as 1 | 2, + ...(params.positionSide && { positionSide: params.positionSide }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + const action = params.type === "1" ? "added to" : "reduced from" + + return { + content: [ + { + type: "text", + text: `✅ Margin ${action} position!\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to modify position margin: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/trade-api/newOrder.ts b/src/tools/binance-futures-coinm/trade-api/newOrder.ts index 4a174655..3198b378 100644 --- a/src/tools/binance-futures-coinm/trade-api/newOrder.ts +++ b/src/tools/binance-futures-coinm/trade-api/newOrder.ts @@ -1,151 +1,96 @@ -/** - * @author nich - * @website x.com/nichxbt - * @github github.com/nirholas - * @license Apache-2.0 - */ -// src/tools/binance-futures-coinm/trade-api/newOrder.ts// src/tools/binance-futures-coinm/trade-api/newOrder.ts +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import { z } from "zod" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -} ); } } }; isError: true content: [{ type: "text", text: `❌ Failed to place order: ${errorMessage}` }], return { const errorMessage = error instanceof Error ? error.message : String(error); } catch (error) { }; }] text: `✅ COIN-M order placed successfully!\n\nOrder ID: ${data.orderId}\nSymbol: ${data.symbol}\nSide: ${data.side}\nType: ${data.type}\nQuantity: ${data.origQty}\nStatus: ${data.status}\n\n${JSON.stringify(data, null, 2)}` type: "text", content: [{ return { const data = await response.data(); }); ...(params.recvWindow && { recvWindow: params.recvWindow }) ...(params.newOrderRespType && { newOrderRespType: params.newOrderRespType }), ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), ...(params.priceProtect !== undefined && { priceProtect: params.priceProtect }), ...(params.workingType && { workingType: params.workingType }), ...(params.callbackRate && { callbackRate: params.callbackRate }), ...(params.activationPrice && { activationPrice: params.activationPrice }), ...(params.closePosition !== undefined && { closePosition: params.closePosition }), ...(params.reduceOnly !== undefined && { reduceOnly: params.reduceOnly }), ...(params.timeInForce && { timeInForce: params.timeInForce }), ...(params.stopPrice && { stopPrice: params.stopPrice }), ...(params.price && { price: params.price }), ...(params.quantity && { quantity: params.quantity }), ...(params.positionSide && { positionSide: params.positionSide }), type: params.type, side: params.side, symbol: params.symbol, const response = await deliveryClient.restAPI.newOrder({ try { async (params) => { }, recvWindow: z.number().int().optional().describe("Recv window in milliseconds") newOrderRespType: z.enum(["ACK", "RESULT"]).optional().describe("Response type"), newClientOrderId: z.string().optional().describe("Custom order ID"), priceProtect: z.boolean().optional().describe("Price protection"), workingType: z.enum(["MARK_PRICE", "CONTRACT_PRICE"]).optional().describe("Stop trigger type"), callbackRate: z.string().optional().describe("Callback rate for TRAILING_STOP_MARKET"), activationPrice: z.string().optional().describe("Activation price for TRAILING_STOP_MARKET"), closePosition: z.boolean().optional().describe("Close entire position"), reduceOnly: z.boolean().optional().describe("Reduce position only"), timeInForce: z.enum(["GTC", "IOC", "FOK", "GTX"]).optional().describe("Time in force"), stopPrice: z.string().optional().describe("Stop price for STOP/TAKE_PROFIT orders"), price: z.string().optional().describe("Limit price (required for LIMIT orders)"), quantity: z.string().optional().describe("Order quantity in contracts"), ]).describe("Order type"), "TAKE_PROFIT", "TAKE_PROFIT_MARKET", "TRAILING_STOP_MARKET" "LIMIT", "MARKET", "STOP", "STOP_MARKET", type: z.enum([ positionSide: z.enum(["BOTH", "LONG", "SHORT"]).optional().describe("Position side for Hedge Mode"), side: z.enum(["BUY", "SELL"]).describe("Order side"), symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), { "Place a new COIN-M Futures order. ⚠️ RISK: Futures trading involves leverage and liquidation risk.", "BinanceDeliveryNewOrder", server.tool(export function registerBinanceDeliveryNewOrder(server: McpServer) {import { z } from "zod";import { deliveryClient } from "../../../config/binanceClient.js";import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryNewOrder(server: McpServer) { - server.tool( - "BinanceDeliveryNewOrder", - "Place a new COIN-M Futures (Delivery) order. COIN-M futures are settled in the coin itself (e.g., BTC). ⚠️ RISK: Futures trading involves leverage and liquidation risk.", - { - symbol: z.string().describe("Delivery futures symbol (e.g., BTCUSD_PERP, BTCUSD_240329)"), - side: z.enum(["BUY", "SELL"]).describe("Order side"), - positionSide: z.enum(["BOTH", "LONG", "SHORT"]).optional().describe("Position side for Hedge Mode. Use BOTH for One-Way Mode"), - type: z.enum([ - "LIMIT", "MARKET", "STOP", "STOP_MARKET", - "TAKE_PROFIT", "TAKE_PROFIT_MARKET", "TRAILING_STOP_MARKET" - ]).describe("Order type"), - quantity: z.string().optional().describe("Order quantity in contracts"), - price: z.string().optional().describe("Limit price (required for LIMIT orders)"), - stopPrice: z.string().optional().describe("Stop price (required for STOP orders)"), - timeInForce: z.enum(["GTC", "IOC", "FOK", "GTX"]).optional().describe("Time in force"), - reduceOnly: z.boolean().optional().describe("Reduce position only"), - closePosition: z.boolean().optional().describe("Close entire position"), - activationPrice: z.string().optional().describe("Activation price for TRAILING_STOP_MARKET"), - callbackRate: z.string().optional().describe("Callback rate for TRAILING_STOP_MARKET (0.1% - 5%)"), - workingType: z.enum(["MARK_PRICE", "CONTRACT_PRICE"]).optional().describe("Stop price trigger type"), - priceProtect: z.boolean().optional().describe("Price protection"), - newClientOrderId: z.string().optional().describe("Custom order ID"), - newOrderRespType: z.enum(["ACK", "RESULT"]).optional().describe("Response type"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.newOrder({ - symbol: params.symbol, - side: params.side, - type: params.type, - ...(params.positionSide && { positionSide: params.positionSide }), - ...(params.quantity && { quantity: params.quantity }), - ...(params.price && { price: params.price }), - ...(params.stopPrice && { stopPrice: params.stopPrice }), - ...(params.timeInForce && { timeInForce: params.timeInForce }), - ...(params.reduceOnly !== undefined && { reduceOnly: params.reduceOnly }), - ...(params.closePosition !== undefined && { closePosition: params.closePosition }), - ...(params.activationPrice && { activationPrice: params.activationPrice }), - ...(params.callbackRate && { callbackRate: params.callbackRate }), - ...(params.workingType && { workingType: params.workingType }), - ...(params.priceProtect !== undefined && { priceProtect: params.priceProtect }), - ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), - ...(params.newOrderRespType && { newOrderRespType: params.newOrderRespType }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ COIN-M Futures order placed!\n\nOrder ID: ${data.orderId}\nSymbol: ${data.symbol}\nSide: ${data.side}\nType: ${data.type}\nQuantity: ${data.origQty}\nPrice: ${data.price || 'MARKET'}\nStatus: ${data.status}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to place COIN-M order: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceDeliveryNewOrder", + "Place a new COIN-M Futures (Delivery) order. COIN-M futures are settled in the coin itself (e.g., BTC). ⚠️ RISK: Futures trading involves leverage and liquidation risk.", + { + symbol: z.string().describe("Delivery futures symbol (e.g., BTCUSD_PERP, BTCUSD_240329)"), + side: z.enum(["BUY", "SELL"]).describe("Order side"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe("Position side for Hedge Mode. Use BOTH for One-Way Mode"), + type: z + .enum([ + "LIMIT", + "MARKET", + "STOP", + "STOP_MARKET", + "TAKE_PROFIT", + "TAKE_PROFIT_MARKET", + "TRAILING_STOP_MARKET", + ]) + .describe("Order type"), + quantity: z.string().optional().describe("Order quantity in contracts"), + price: z.string().optional().describe("Limit price (required for LIMIT orders)"), + stopPrice: z.string().optional().describe("Stop price (required for STOP orders)"), + timeInForce: z.enum(["GTC", "IOC", "FOK", "GTX"]).optional().describe("Time in force"), + reduceOnly: z.boolean().optional().describe("Reduce position only"), + closePosition: z.boolean().optional().describe("Close entire position"), + activationPrice: z.string().optional().describe("Activation price for TRAILING_STOP_MARKET"), + callbackRate: z + .string() + .optional() + .describe("Callback rate for TRAILING_STOP_MARKET (0.1% - 5%)"), + workingType: z + .enum(["MARK_PRICE", "CONTRACT_PRICE"]) + .optional() + .describe("Stop price trigger type"), + priceProtect: z.boolean().optional().describe("Price protection"), + newClientOrderId: z.string().optional().describe("Custom order ID"), + newOrderRespType: z.enum(["ACK", "RESULT"]).optional().describe("Response type"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.newOrder({ + symbol: params.symbol, + side: params.side, + type: params.type, + ...(params.positionSide && { positionSide: params.positionSide }), + ...(params.quantity && { quantity: params.quantity }), + ...(params.price && { price: params.price }), + ...(params.stopPrice && { stopPrice: params.stopPrice }), + ...(params.timeInForce && { timeInForce: params.timeInForce }), + ...(params.reduceOnly !== undefined && { reduceOnly: params.reduceOnly }), + ...(params.closePosition !== undefined && { closePosition: params.closePosition }), + ...(params.activationPrice && { activationPrice: params.activationPrice }), + ...(params.callbackRate && { callbackRate: params.callbackRate }), + ...(params.workingType && { workingType: params.workingType }), + ...(params.priceProtect !== undefined && { priceProtect: params.priceProtect }), + ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), + ...(params.newOrderRespType && { newOrderRespType: params.newOrderRespType }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ COIN-M Futures order placed!\n\nOrder ID: ${data.orderId}\nSymbol: ${data.symbol}\nSide: ${data.side}\nType: ${data.type}\nQuantity: ${data.origQty}\nPrice: ${data.price || "MARKET"}\nStatus: ${data.status}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to place COIN-M order: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/trade-api/openOrder.ts b/src/tools/binance-futures-coinm/trade-api/openOrder.ts index f94278a3..a72d5849 100644 --- a/src/tools/binance-futures-coinm/trade-api/openOrder.ts +++ b/src/tools/binance-futures-coinm/trade-api/openOrder.ts @@ -5,51 +5,58 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/openOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryOpenOrder(server: McpServer) { - server.tool( - "BinanceDeliveryOpenOrder", - "Query a single open COIN-M Futures order.", - { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - orderId: z.number().int().optional().describe("Order ID"), - origClientOrderId: z.string().optional().describe("Original client order ID"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - if (!params.orderId && !params.origClientOrderId) { - return { - content: [{ type: "text", text: "Error: Either orderId or origClientOrderId must be provided" }], - isError: true - }; - } - - const response = await deliveryClient.restAPI.currentOpenOrder({ - symbol: params.symbol, - ...(params.orderId && { orderId: params.orderId }), - ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `📋 Open Order\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get open order: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryOpenOrder", + "Query a single open COIN-M Futures order.", + { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + orderId: z.number().int().optional().describe("Order ID"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + if (!params.orderId && !params.origClientOrderId) { + return { + content: [ + { type: "text", text: "Error: Either orderId or origClientOrderId must be provided" }, + ], + isError: true, + } + } + + const response = await deliveryClient.restAPI.currentOpenOrder({ + symbol: params.symbol, + ...(params.orderId && { orderId: params.orderId }), + ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📋 Open Order\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get open order: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/trade-api/openOrders.ts b/src/tools/binance-futures-coinm/trade-api/openOrders.ts index b5a7cf60..aee96bf9 100644 --- a/src/tools/binance-futures-coinm/trade-api/openOrders.ts +++ b/src/tools/binance-futures-coinm/trade-api/openOrders.ts @@ -5,42 +5,47 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/openOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryOpenOrders(server: McpServer) { - server.tool( - "BinanceDeliveryOpenOrders", - "Get all current open COIN-M Futures orders.", - { - symbol: z.string().optional().describe("Contract symbol filter"), - pair: z.string().optional().describe("Filter by underlying pair"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.currentAllOpenOrders({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.pair && { pair: params.pair }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `📋 Open Orders\n\nCount: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get open orders: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryOpenOrders", + "Get all current open COIN-M Futures orders.", + { + symbol: z.string().optional().describe("Contract symbol filter"), + pair: z.string().optional().describe("Filter by underlying pair"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.currentAllOpenOrders({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.pair && { pair: params.pair }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📋 Open Orders\n\nCount: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get open orders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/trades.ts b/src/tools/binance-futures-coinm/trades.ts index 19dbb8e1..d7ec8f4e 100644 --- a/src/tools/binance-futures-coinm/trades.ts +++ b/src/tools/binance-futures-coinm/trades.ts @@ -1,41 +1,46 @@ // src/tools/binance-futures-coinm/trades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMTrades(server: McpServer) { - server.tool( - "BinanceFuturesCOINMTrades", - "Get recent trades for a specific COIN-M Futures trading pair.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), - limit: z.number().optional().describe("Number of trades to return. Default 500; max 1000") - }, - async ({ symbol, limit }) => { - try { - const params: any = { symbol }; - if (limit !== undefined) params.limit = limit; + server.tool( + "BinanceFuturesCOINMTrades", + "Get recent trades for a specific COIN-M Futures trading pair.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + limit: z.number().optional().describe("Number of trades to return. Default 500; max 1000"), + }, + async ({ symbol, limit }) => { + try { + const params: any = { symbol } + if (limit !== undefined) params.limit = limit - const data = await deliveryClient.trades(params); - + const data = await deliveryClient.trades(params) + + return { + content: [ + { + type: "text", + text: `Retrieved ${data.length || 0} recent trades for COIN-M Futures ${symbol}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved ${data.length || 0} recent trades for COIN-M Futures ${symbol}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve COIN-M Futures recent trades: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve COIN-M Futures recent trades: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/userTrades.ts b/src/tools/binance-futures-coinm/userTrades.ts index 320c9842..2d4919a9 100644 --- a/src/tools/binance-futures-coinm/userTrades.ts +++ b/src/tools/binance-futures-coinm/userTrades.ts @@ -1,53 +1,57 @@ // src/tools/binance-futures-coinm/userTrades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../config/binanceClient.js" export function registerBinanceFuturesCOINMUserTrades(server: McpServer) { - server.tool( - "BinanceFuturesCOINMUserTrades", - "Get account trade list for COIN-M Futures.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), - pair: z.string().optional().describe("Trading pair (e.g., BTCUSD)"), - orderId: z.number().optional().describe("Filter by order ID"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - fromId: z.number().optional().describe("Trade ID to start from"), - limit: z.number().optional().describe("Default 500; max 1000") - }, - async ({ symbol, pair, orderId, startTime, endTime, fromId, limit }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - if (pair) params.pair = pair; - if (orderId !== undefined) params.orderId = orderId; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (fromId !== undefined) params.fromId = fromId; - if (limit !== undefined) params.limit = limit; + server.tool( + "BinanceFuturesCOINMUserTrades", + "Get account trade list for COIN-M Futures.", + { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + pair: z.string().optional().describe("Trading pair (e.g., BTCUSD)"), + orderId: z.number().optional().describe("Filter by order ID"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + fromId: z.number().optional().describe("Trade ID to start from"), + limit: z.number().optional().describe("Default 500; max 1000"), + }, + async ({ symbol, pair, orderId, startTime, endTime, fromId, limit }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + if (pair) params.pair = pair + if (orderId !== undefined) params.orderId = orderId + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (fromId !== undefined) params.fromId = fromId + if (limit !== undefined) params.limit = limit - const data = await deliveryClient.userTrades(params); - + const data = await deliveryClient.userTrades(params) - return { - content: [ - { - type: "text", - text: `Retrieved ${data.length || 0} COIN-M Futures trades. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve COIN-M Futures user trades: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Retrieved ${data.length || 0} COIN-M Futures trades. Response: ${JSON.stringify(data)}`, + }, + ], } - ); -} + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + return { + content: [ + { + type: "text", + text: `Failed to retrieve COIN-M Futures user trades: ${errorMessage}`, + }, + ], + isError: true, + } + } + }, + ) +} diff --git a/src/tools/binance-futures-coinm/userdatastream-api/closeListenKey.ts b/src/tools/binance-futures-coinm/userdatastream-api/closeListenKey.ts index bef5c09b..dc7483be 100644 --- a/src/tools/binance-futures-coinm/userdatastream-api/closeListenKey.ts +++ b/src/tools/binance-futures-coinm/userdatastream-api/closeListenKey.ts @@ -5,40 +5,45 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/userdatastream-api/closeListenKey.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryCloseListenKey(server: McpServer) { - server.tool( - "BinanceDeliveryCloseListenKey", - "Close a COIN-M Futures user data stream listen key.", - { - listenKey: z.string().optional().describe("Listen key to close"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.closeListenKey({ - ...(params.listenKey && { listenKey: params.listenKey }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Listen Key Closed!\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to close listen key: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryCloseListenKey", + "Close a COIN-M Futures user data stream listen key.", + { + listenKey: z.string().optional().describe("Listen key to close"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.closeListenKey({ + ...(params.listenKey && { listenKey: params.listenKey }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Listen Key Closed!\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to close listen key: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/userdatastream-api/createListenKey.ts b/src/tools/binance-futures-coinm/userdatastream-api/createListenKey.ts index 3684098c..a15efd9a 100644 --- a/src/tools/binance-futures-coinm/userdatastream-api/createListenKey.ts +++ b/src/tools/binance-futures-coinm/userdatastream-api/createListenKey.ts @@ -5,38 +5,43 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/userdatastream-api/createListenKey.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryCreateListenKey(server: McpServer) { - server.tool( - "BinanceDeliveryCreateListenKey", - "Create a new COIN-M Futures user data stream listen key. The listen key is valid for 60 minutes and can be used to receive account updates via WebSocket.", - { - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.createListenKey({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ COIN-M Listen Key Created!\n\nListen Key: ${data.listenKey}\n\n⚠️ Important:\n- Valid for 60 minutes\n- Use keepAlive endpoint to extend validity\n\nWebSocket URL: wss://dstream.binance.com/ws/${data.listenKey}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to create listen key: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryCreateListenKey", + "Create a new COIN-M Futures user data stream listen key. The listen key is valid for 60 minutes and can be used to receive account updates via WebSocket.", + { + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.createListenKey({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ COIN-M Listen Key Created!\n\nListen Key: ${data.listenKey}\n\n⚠️ Important:\n- Valid for 60 minutes\n- Use keepAlive endpoint to extend validity\n\nWebSocket URL: wss://dstream.binance.com/ws/${data.listenKey}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to create listen key: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-coinm/userdatastream-api/index.ts b/src/tools/binance-futures-coinm/userdatastream-api/index.ts index 7f0d2084..87388739 100644 --- a/src/tools/binance-futures-coinm/userdatastream-api/index.ts +++ b/src/tools/binance-futures-coinm/userdatastream-api/index.ts @@ -5,14 +5,15 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/userdatastream-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceDeliveryCreateListenKey } from "./createListenKey.js"; -import { registerBinanceDeliveryKeepAliveListenKey } from "./keepAliveListenKey.js"; -import { registerBinanceDeliveryCloseListenKey } from "./closeListenKey.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceDeliveryCloseListenKey } from "./closeListenKey.js" +import { registerBinanceDeliveryCreateListenKey } from "./createListenKey.js" +import { registerBinanceDeliveryKeepAliveListenKey } from "./keepAliveListenKey.js" export function registerBinanceDeliveryUserDataStreamApiTools(server: McpServer) { - // User Data Stream (Listen Key) Management - registerBinanceDeliveryCreateListenKey(server); - registerBinanceDeliveryKeepAliveListenKey(server); - registerBinanceDeliveryCloseListenKey(server); + // User Data Stream (Listen Key) Management + registerBinanceDeliveryCreateListenKey(server) + registerBinanceDeliveryKeepAliveListenKey(server) + registerBinanceDeliveryCloseListenKey(server) } diff --git a/src/tools/binance-futures-coinm/userdatastream-api/keepAliveListenKey.ts b/src/tools/binance-futures-coinm/userdatastream-api/keepAliveListenKey.ts index e33c96ce..871b58a4 100644 --- a/src/tools/binance-futures-coinm/userdatastream-api/keepAliveListenKey.ts +++ b/src/tools/binance-futures-coinm/userdatastream-api/keepAliveListenKey.ts @@ -5,40 +5,45 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/userdatastream-api/keepAliveListenKey.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { deliveryClient } from "../../../config/binanceClient.js" export function registerBinanceDeliveryKeepAliveListenKey(server: McpServer) { - server.tool( - "BinanceDeliveryKeepAliveListenKey", - "Keep alive a COIN-M Futures user data stream listen key. Extends validity by 60 minutes. Should be called at least every 60 minutes to prevent timeout.", - { - listenKey: z.string().optional().describe("Listen key to keep alive"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await deliveryClient.restAPI.renewListenKey({ - ...(params.listenKey && { listenKey: params.listenKey }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Listen Key Extended!\n\nYour COIN-M Futures listen key has been renewed for another 60 minutes.` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to extend listen key: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceDeliveryKeepAliveListenKey", + "Keep alive a COIN-M Futures user data stream listen key. Extends validity by 60 minutes. Should be called at least every 60 minutes to prevent timeout.", + { + listenKey: z.string().optional().describe("Listen key to keep alive"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await deliveryClient.restAPI.renewListenKey({ + ...(params.listenKey && { listenKey: params.listenKey }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Listen Key Extended!\n\nYour COIN-M Futures listen key has been renewed for another 60 minutes.`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to extend listen key: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/account-api/account.ts b/src/tools/binance-futures-usdm/account-api/account.ts index 87dd49c0..5159a403 100644 --- a/src/tools/binance-futures-usdm/account-api/account.ts +++ b/src/tools/binance-futures-usdm/account-api/account.ts @@ -5,36 +5,42 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/account.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesAccount(server: McpServer) { - server.tool( - "BinanceFuturesAccount", - "Get current USD-M Futures account information including positions, balances, and unrealized PnL.", - { - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.account({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Futures Account: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get account info: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesAccount", + "Get current USD-M Futures account information including positions, balances, and unrealized PnL.", + { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.account({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Futures Account: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get account info: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/account-api/adlQuantile.ts b/src/tools/binance-futures-usdm/account-api/adlQuantile.ts index 660332ba..4f1452ea 100644 --- a/src/tools/binance-futures-usdm/account-api/adlQuantile.ts +++ b/src/tools/binance-futures-usdm/account-api/adlQuantile.ts @@ -5,38 +5,44 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/adlQuantile.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesADLQuantile(server: McpServer) { - server.tool( - "BinanceFuturesADLQuantile", - "Get Position ADL (Auto-Deleveraging) Quantile estimation for USD-M Futures.", - { - symbol: z.string().optional().describe("Futures symbol"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.adlQuantile({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `ADL Quantile: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get ADL quantile: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesADLQuantile", + "Get Position ADL (Auto-Deleveraging) Quantile estimation for USD-M Futures.", + { + symbol: z.string().optional().describe("Futures symbol"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.adlQuantile({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `ADL Quantile: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get ADL quantile: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/account-api/apiTradingStatus.ts b/src/tools/binance-futures-usdm/account-api/apiTradingStatus.ts index 052e84cb..c82bca27 100644 --- a/src/tools/binance-futures-usdm/account-api/apiTradingStatus.ts +++ b/src/tools/binance-futures-usdm/account-api/apiTradingStatus.ts @@ -5,38 +5,44 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/apiTradingStatus.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesApiTradingStatus(server: McpServer) { - server.tool( - "BinanceFuturesApiTradingStatus", - "Get API trading quantitative rules indicators for USD-M Futures.", - { - symbol: z.string().optional().describe("Futures symbol"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.apiTradingStatus({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `API Trading Status: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get API trading status: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesApiTradingStatus", + "Get API trading quantitative rules indicators for USD-M Futures.", + { + symbol: z.string().optional().describe("Futures symbol"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.apiTradingStatus({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `API Trading Status: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get API trading status: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/account-api/balance.ts b/src/tools/binance-futures-usdm/account-api/balance.ts index cfe28861..c8292673 100644 --- a/src/tools/binance-futures-usdm/account-api/balance.ts +++ b/src/tools/binance-futures-usdm/account-api/balance.ts @@ -5,36 +5,42 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/balance.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesBalance(server: McpServer) { - server.tool( - "BinanceFuturesBalance", - "Get current USD-M Futures account balance information.", - { - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.balance({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Futures Balance: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get balance: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesBalance", + "Get current USD-M Futures account balance information.", + { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.balance({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Futures Balance: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get balance: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/account-api/commissionRate.ts b/src/tools/binance-futures-usdm/account-api/commissionRate.ts index 23045013..7773d8ce 100644 --- a/src/tools/binance-futures-usdm/account-api/commissionRate.ts +++ b/src/tools/binance-futures-usdm/account-api/commissionRate.ts @@ -5,38 +5,44 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/commissionRate.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesCommissionRate(server: McpServer) { - server.tool( - "BinanceFuturesCommissionRate", - "Get user commission rate for a USD-M Futures symbol.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.commissionRate({ - symbol: params.symbol, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Commission Rate for ${params.symbol}: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get commission rate: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesCommissionRate", + "Get user commission rate for a USD-M Futures symbol.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.commissionRate({ + symbol: params.symbol, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Commission Rate for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get commission rate: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/account-api/downloadId.ts b/src/tools/binance-futures-usdm/account-api/downloadId.ts index 3564cad8..6ddedcae 100644 --- a/src/tools/binance-futures-usdm/account-api/downloadId.ts +++ b/src/tools/binance-futures-usdm/account-api/downloadId.ts @@ -5,40 +5,46 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/downloadId.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesDownloadIdForFuturesTransactionHistory(server: McpServer) { - server.tool( - "BinanceFuturesDownloadId", - "Get download ID for USD-M Futures transaction history.", - { - startTime: z.number().int().describe("Start timestamp in ms"), - endTime: z.number().int().describe("End timestamp in ms"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.downloadIdForFuturesTransactionHistory({ - startTime: params.startTime, - endTime: params.endTime, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Download ID: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get download ID: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesDownloadId", + "Get download ID for USD-M Futures transaction history.", + { + startTime: z.number().int().describe("Start timestamp in ms"), + endTime: z.number().int().describe("End timestamp in ms"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.downloadIdForFuturesTransactionHistory({ + startTime: params.startTime, + endTime: params.endTime, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Download ID: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get download ID: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/account-api/forceOrders.ts b/src/tools/binance-futures-usdm/account-api/forceOrders.ts index 8ca69f88..c0efc1d6 100644 --- a/src/tools/binance-futures-usdm/account-api/forceOrders.ts +++ b/src/tools/binance-futures-usdm/account-api/forceOrders.ts @@ -5,46 +5,52 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/forceOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesForceOrders(server: McpServer) { - server.tool( - "BinanceFuturesForceOrders", - "Get user's force orders (liquidation orders) for USD-M Futures.", - { - symbol: z.string().optional().describe("Futures symbol"), - autoCloseType: z.enum(["LIQUIDATION", "ADL"]).optional().describe("Type of force order"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - limit: z.number().int().optional().describe("Number of results. Default 50, max 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.forceOrders({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.autoCloseType && { autoCloseType: params.autoCloseType }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Force Orders: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get force orders: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesForceOrders", + "Get user's force orders (liquidation orders) for USD-M Futures.", + { + symbol: z.string().optional().describe("Futures symbol"), + autoCloseType: z.enum(["LIQUIDATION", "ADL"]).optional().describe("Type of force order"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + limit: z.number().int().optional().describe("Number of results. Default 50, max 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.forceOrders({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.autoCloseType && { autoCloseType: params.autoCloseType }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Force Orders: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get force orders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/account-api/income.ts b/src/tools/binance-futures-usdm/account-api/income.ts index f9e61e12..fe309e94 100644 --- a/src/tools/binance-futures-usdm/account-api/income.ts +++ b/src/tools/binance-futures-usdm/account-api/income.ts @@ -5,52 +5,75 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/income.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesIncome(server: McpServer) { - server.tool( - "BinanceFuturesIncome", - "Get income history for USD-M Futures account.", - { - symbol: z.string().optional().describe("Futures symbol"), - incomeType: z.enum([ - "TRANSFER", "WELCOME_BONUS", "REALIZED_PNL", "FUNDING_FEE", - "COMMISSION", "INSURANCE_CLEAR", "REFERRAL_KICKBACK", "COMMISSION_REBATE", - "API_REBATE", "CONTEST_REWARD", "CROSS_COLLATERAL_TRANSFER", "OPTIONS_PREMIUM_FEE", - "OPTIONS_SETTLE_PROFIT", "INTERNAL_TRANSFER", "AUTO_EXCHANGE", "DELIVERED_SETTELMENT", - "COIN_SWAP_DEPOSIT", "COIN_SWAP_WITHDRAW", "POSITION_LIMIT_INCREASE_FEE" - ]).optional().describe("Type of income"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - limit: z.number().int().optional().describe("Number of results. Default 100, max 1000"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.income({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.incomeType && { incomeType: params.incomeType }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Income History: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get income history: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesIncome", + "Get income history for USD-M Futures account.", + { + symbol: z.string().optional().describe("Futures symbol"), + incomeType: z + .enum([ + "TRANSFER", + "WELCOME_BONUS", + "REALIZED_PNL", + "FUNDING_FEE", + "COMMISSION", + "INSURANCE_CLEAR", + "REFERRAL_KICKBACK", + "COMMISSION_REBATE", + "API_REBATE", + "CONTEST_REWARD", + "CROSS_COLLATERAL_TRANSFER", + "OPTIONS_PREMIUM_FEE", + "OPTIONS_SETTLE_PROFIT", + "INTERNAL_TRANSFER", + "AUTO_EXCHANGE", + "DELIVERED_SETTELMENT", + "COIN_SWAP_DEPOSIT", + "COIN_SWAP_WITHDRAW", + "POSITION_LIMIT_INCREASE_FEE", + ]) + .optional() + .describe("Type of income"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + limit: z.number().int().optional().describe("Number of results. Default 100, max 1000"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.income({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.incomeType && { incomeType: params.incomeType }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Income History: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get income history: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/account-api/index.ts b/src/tools/binance-futures-usdm/account-api/index.ts index 907beb62..55001e5a 100644 --- a/src/tools/binance-futures-usdm/account-api/index.ts +++ b/src/tools/binance-futures-usdm/account-api/index.ts @@ -5,48 +5,49 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceFuturesAccount } from "./account.js"; -import { registerBinanceFuturesBalance } from "./balance.js"; -import { registerBinanceFuturesPositionRisk } from "./positionRisk.js"; -import { registerBinanceFuturesUserTrades } from "./userTrades.js"; -import { registerBinanceFuturesIncome } from "./income.js"; -import { registerBinanceFuturesLeverageBracket } from "./leverageBracket.js"; -import { registerBinanceFuturesADLQuantile } from "./adlQuantile.js"; -import { registerBinanceFuturesForceOrders } from "./forceOrders.js"; -import { registerBinanceFuturesApiTradingStatus } from "./apiTradingStatus.js"; -import { registerBinanceFuturesCommissionRate } from "./commissionRate.js"; -import { registerBinanceFuturesDownloadIdForFuturesTransactionHistory } from "./downloadId.js"; -import { registerBinanceFuturesPositionMode } from "./positionMode.js"; -import { registerBinanceFuturesMultiAssetsMode } from "./multiAssetsMode.js"; -import { registerBinanceFuturesLeverage } from "./leverage.js"; -import { registerBinanceFuturesMarginType } from "./marginType.js"; -import { registerBinanceFuturesPositionMargin } from "./positionMargin.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceFuturesAccount } from "./account.js" +import { registerBinanceFuturesADLQuantile } from "./adlQuantile.js" +import { registerBinanceFuturesApiTradingStatus } from "./apiTradingStatus.js" +import { registerBinanceFuturesBalance } from "./balance.js" +import { registerBinanceFuturesCommissionRate } from "./commissionRate.js" +import { registerBinanceFuturesDownloadIdForFuturesTransactionHistory } from "./downloadId.js" +import { registerBinanceFuturesForceOrders } from "./forceOrders.js" +import { registerBinanceFuturesIncome } from "./income.js" +import { registerBinanceFuturesLeverage } from "./leverage.js" +import { registerBinanceFuturesLeverageBracket } from "./leverageBracket.js" +import { registerBinanceFuturesMarginType } from "./marginType.js" +import { registerBinanceFuturesMultiAssetsMode } from "./multiAssetsMode.js" +import { registerBinanceFuturesPositionMargin } from "./positionMargin.js" +import { registerBinanceFuturesPositionMode } from "./positionMode.js" +import { registerBinanceFuturesPositionRisk } from "./positionRisk.js" +import { registerBinanceFuturesUserTrades } from "./userTrades.js" export function registerBinanceFuturesAccountApiTools(server: McpServer) { - // Account Info - registerBinanceFuturesAccount(server); - registerBinanceFuturesBalance(server); - registerBinanceFuturesPositionRisk(server); - registerBinanceFuturesPositionMode(server); - registerBinanceFuturesMultiAssetsMode(server); - - // Leverage & Margin - registerBinanceFuturesLeverage(server); - registerBinanceFuturesMarginType(server); - registerBinanceFuturesPositionMargin(server); - - // Trades & History - registerBinanceFuturesUserTrades(server); - registerBinanceFuturesIncome(server); - registerBinanceFuturesForceOrders(server); - registerBinanceFuturesDownloadIdForFuturesTransactionHistory(server); - - // Risk & Limits - registerBinanceFuturesLeverageBracket(server); - registerBinanceFuturesADLQuantile(server); - - // Status & Commission - registerBinanceFuturesApiTradingStatus(server); - registerBinanceFuturesCommissionRate(server); + // Account Info + registerBinanceFuturesAccount(server) + registerBinanceFuturesBalance(server) + registerBinanceFuturesPositionRisk(server) + registerBinanceFuturesPositionMode(server) + registerBinanceFuturesMultiAssetsMode(server) + + // Leverage & Margin + registerBinanceFuturesLeverage(server) + registerBinanceFuturesMarginType(server) + registerBinanceFuturesPositionMargin(server) + + // Trades & History + registerBinanceFuturesUserTrades(server) + registerBinanceFuturesIncome(server) + registerBinanceFuturesForceOrders(server) + registerBinanceFuturesDownloadIdForFuturesTransactionHistory(server) + + // Risk & Limits + registerBinanceFuturesLeverageBracket(server) + registerBinanceFuturesADLQuantile(server) + + // Status & Commission + registerBinanceFuturesApiTradingStatus(server) + registerBinanceFuturesCommissionRate(server) } diff --git a/src/tools/binance-futures-usdm/account-api/leverage.ts b/src/tools/binance-futures-usdm/account-api/leverage.ts index 1820abc3..a1006435 100644 --- a/src/tools/binance-futures-usdm/account-api/leverage.ts +++ b/src/tools/binance-futures-usdm/account-api/leverage.ts @@ -5,40 +5,51 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/leverage.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesLeverage(server: McpServer) { - server.tool( - "BinanceFuturesChangeLeverage", - "Change initial leverage for a USD-M Futures symbol. ⚠️ Leverage changes affect your liquidation price and margin requirements.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - leverage: z.number().int().min(1).max(125).describe("Target leverage (1-125, varies by symbol)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.changeInitialLeverage({ - symbol: params.symbol, - leverage: params.leverage, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `✅ Leverage changed for ${params.symbol}\nNew Leverage: ${data.leverage}x\nMax Notional Value: ${data.maxNotionalValue}\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to change leverage: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesChangeLeverage", + "Change initial leverage for a USD-M Futures symbol. ⚠️ Leverage changes affect your liquidation price and margin requirements.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + leverage: z + .number() + .int() + .min(1) + .max(125) + .describe("Target leverage (1-125, varies by symbol)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.changeInitialLeverage({ + symbol: params.symbol, + leverage: params.leverage, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Leverage changed for ${params.symbol}\nNew Leverage: ${data.leverage}x\nMax Notional Value: ${data.maxNotionalValue}\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to change leverage: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/account-api/leverageBracket.ts b/src/tools/binance-futures-usdm/account-api/leverageBracket.ts index 1f091764..a674d369 100644 --- a/src/tools/binance-futures-usdm/account-api/leverageBracket.ts +++ b/src/tools/binance-futures-usdm/account-api/leverageBracket.ts @@ -5,38 +5,44 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/leverageBracket.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesLeverageBracket(server: McpServer) { - server.tool( - "BinanceFuturesLeverageBracket", - "Get notional and leverage brackets for USD-M Futures symbols.", - { - symbol: z.string().optional().describe("Futures symbol. If omitted, returns all"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.leverageBracket({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Leverage Brackets: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get leverage brackets: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesLeverageBracket", + "Get notional and leverage brackets for USD-M Futures symbols.", + { + symbol: z.string().optional().describe("Futures symbol. If omitted, returns all"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.leverageBracket({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Leverage Brackets: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get leverage brackets: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/account-api/marginType.ts b/src/tools/binance-futures-usdm/account-api/marginType.ts index 9b283fb8..86c071d7 100644 --- a/src/tools/binance-futures-usdm/account-api/marginType.ts +++ b/src/tools/binance-futures-usdm/account-api/marginType.ts @@ -5,40 +5,46 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/marginType.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesMarginType(server: McpServer) { - server.tool( - "BinanceFuturesChangeMarginType", - "Change margin type between ISOLATED and CROSSED for a USD-M Futures symbol. ⚠️ Cannot change if you have existing positions or open orders.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - marginType: z.enum(["ISOLATED", "CROSSED"]).describe("Margin type: ISOLATED or CROSSED"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.changeMarginType({ - symbol: params.symbol, - marginType: params.marginType, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `✅ Margin type changed for ${params.symbol} to ${params.marginType}\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to change margin type: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesChangeMarginType", + "Change margin type between ISOLATED and CROSSED for a USD-M Futures symbol. ⚠️ Cannot change if you have existing positions or open orders.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + marginType: z.enum(["ISOLATED", "CROSSED"]).describe("Margin type: ISOLATED or CROSSED"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.changeMarginType({ + symbol: params.symbol, + marginType: params.marginType, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Margin type changed for ${params.symbol} to ${params.marginType}\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to change margin type: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/account-api/multiAssetsMode.ts b/src/tools/binance-futures-usdm/account-api/multiAssetsMode.ts index f6453d55..2207604b 100644 --- a/src/tools/binance-futures-usdm/account-api/multiAssetsMode.ts +++ b/src/tools/binance-futures-usdm/account-api/multiAssetsMode.ts @@ -5,36 +5,42 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/multiAssetsMode.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesMultiAssetsMode(server: McpServer) { - server.tool( - "BinanceFuturesGetMultiAssetsMode", - "Get current Multi-Assets Mode for USD-M Futures.", - { - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.getMultiAssetsMode({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Multi-Assets Mode: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get multi-assets mode: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesGetMultiAssetsMode", + "Get current Multi-Assets Mode for USD-M Futures.", + { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.getMultiAssetsMode({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Multi-Assets Mode: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get multi-assets mode: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/account-api/positionMargin.ts b/src/tools/binance-futures-usdm/account-api/positionMargin.ts index e4c6b518..fff6108c 100644 --- a/src/tools/binance-futures-usdm/account-api/positionMargin.ts +++ b/src/tools/binance-futures-usdm/account-api/positionMargin.ts @@ -5,84 +5,99 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/positionMargin.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesPositionMargin(server: McpServer) { - // Modify Isolated Position Margin - server.tool( - "BinanceFuturesModifyPositionMargin", - "Add or reduce margin for an isolated position in USD-M Futures.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - amount: z.string().describe("Amount of margin to add (positive) or remove (negative)"), - type: z.enum(["1", "2"]).describe("1: Add margin, 2: Reduce margin"), - positionSide: z.enum(["BOTH", "LONG", "SHORT"]).optional().describe("Position side for Hedge Mode"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.modifyIsolatedPositionMargin({ - symbol: params.symbol, - amount: params.amount, - type: parseInt(params.type), - ...(params.positionSide && { positionSide: params.positionSide }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `✅ Position margin modified for ${params.symbol}\nAmount: ${params.amount}\nType: ${params.type === "1" ? "Added" : "Reduced"}\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to modify position margin: ${errorMessage}` }], - isError: true - }; - } + // Modify Isolated Position Margin + server.tool( + "BinanceFuturesModifyPositionMargin", + "Add or reduce margin for an isolated position in USD-M Futures.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + amount: z.string().describe("Amount of margin to add (positive) or remove (negative)"), + type: z.enum(["1", "2"]).describe("1: Add margin, 2: Reduce margin"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe("Position side for Hedge Mode"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.modifyIsolatedPositionMargin({ + symbol: params.symbol, + amount: params.amount, + type: parseInt(params.type), + ...(params.positionSide && { positionSide: params.positionSide }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Position margin modified for ${params.symbol}\nAmount: ${params.amount}\nType: ${params.type === "1" ? "Added" : "Reduced"}\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to modify position margin: ${errorMessage}` }], + isError: true, } - ); - - // Get Position Margin Change History - server.tool( - "BinanceFuturesGetPositionMarginHistory", - "Get position margin change history for a USD-M Futures symbol.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - type: z.enum(["1", "2"]).optional().describe("1: Add margin, 2: Reduce margin"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z.number().int().max(500).optional().describe("Number of records. Default 500"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.getPositionMarginChangeHistory({ - symbol: params.symbol, - ...(params.type && { type: parseInt(params.type) }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Position margin history for ${params.symbol}: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get position margin history: ${errorMessage}` }], - isError: true - }; - } + } + }, + ) + + // Get Position Margin Change History + server.tool( + "BinanceFuturesGetPositionMarginHistory", + "Get position margin change history for a USD-M Futures symbol.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + type: z.enum(["1", "2"]).optional().describe("1: Add margin, 2: Reduce margin"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z.number().int().max(500).optional().describe("Number of records. Default 500"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.getPositionMarginChangeHistory({ + symbol: params.symbol, + ...(params.type && { type: parseInt(params.type) }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Position margin history for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to get position margin history: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/account-api/positionMode.ts b/src/tools/binance-futures-usdm/account-api/positionMode.ts index ac44d5ad..639dab0d 100644 --- a/src/tools/binance-futures-usdm/account-api/positionMode.ts +++ b/src/tools/binance-futures-usdm/account-api/positionMode.ts @@ -5,36 +5,42 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/positionMode.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesPositionMode(server: McpServer) { - server.tool( - "BinanceFuturesGetPositionMode", - "Get current position mode (Hedge Mode or One-way Mode) for USD-M Futures.", - { - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.getPositionMode({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Position Mode: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get position mode: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesGetPositionMode", + "Get current position mode (Hedge Mode or One-way Mode) for USD-M Futures.", + { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.getPositionMode({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Position Mode: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get position mode: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/account-api/positionRisk.ts b/src/tools/binance-futures-usdm/account-api/positionRisk.ts index 581c6930..58ebb738 100644 --- a/src/tools/binance-futures-usdm/account-api/positionRisk.ts +++ b/src/tools/binance-futures-usdm/account-api/positionRisk.ts @@ -5,38 +5,44 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/positionRisk.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesPositionRisk(server: McpServer) { - server.tool( - "BinanceFuturesPositionRisk", - "Get current position information for USD-M Futures.", - { - symbol: z.string().optional().describe("Futures symbol. If omitted, returns all positions"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.positionRisk({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Position Risk: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get position risk: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesPositionRisk", + "Get current position information for USD-M Futures.", + { + symbol: z.string().optional().describe("Futures symbol. If omitted, returns all positions"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.positionRisk({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Position Risk: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get position risk: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/account-api/userTrades.ts b/src/tools/binance-futures-usdm/account-api/userTrades.ts index 5d02d386..cea21a55 100644 --- a/src/tools/binance-futures-usdm/account-api/userTrades.ts +++ b/src/tools/binance-futures-usdm/account-api/userTrades.ts @@ -5,48 +5,54 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/userTrades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesUserTrades(server: McpServer) { - server.tool( - "BinanceFuturesUserTrades", - "Get trades for a specific USD-M Futures account and symbol.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - orderId: z.number().int().optional().describe("Order ID to filter trades"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - fromId: z.number().int().optional().describe("Trade ID to start from"), - limit: z.number().int().optional().describe("Number of results. Default 500, max 1000"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.userTrades({ - symbol: params.symbol, - ...(params.orderId !== undefined && { orderId: params.orderId }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.fromId !== undefined && { fromId: params.fromId }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `User Trades for ${params.symbol}: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get user trades: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesUserTrades", + "Get trades for a specific USD-M Futures account and symbol.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + orderId: z.number().int().optional().describe("Order ID to filter trades"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + fromId: z.number().int().optional().describe("Trade ID to start from"), + limit: z.number().int().optional().describe("Number of results. Default 500, max 1000"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.userTrades({ + symbol: params.symbol, + ...(params.orderId !== undefined && { orderId: params.orderId }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.fromId !== undefined && { fromId: params.fromId }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `User Trades for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get user trades: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/account.ts b/src/tools/binance-futures-usdm/account.ts index 5fa4ef7a..f274a602 100644 --- a/src/tools/binance-futures-usdm/account.ts +++ b/src/tools/binance-futures-usdm/account.ts @@ -1,33 +1,35 @@ // src/tools/binance-futures-usdm/account.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMAccount(server: McpServer) { - server.tool( - "BinanceFuturesUSDMAccount", - "Get current USD-M Futures account information including positions and balances.", - {}, - async () => { - try { - const data = await futuresClient.account(); + server.tool( + "BinanceFuturesUSDMAccount", + "Get current USD-M Futures account information including positions and balances.", + {}, + async () => { + try { + const data = await futuresClient.account() + + return { + content: [ + { + type: "text", + text: `Retrieved USD-M Futures account information. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved USD-M Futures account information. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve USD-M Futures account: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve USD-M Futures account: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/adlQuantile.ts b/src/tools/binance-futures-usdm/adlQuantile.ts index 3f743b0e..dceea8e5 100644 --- a/src/tools/binance-futures-usdm/adlQuantile.ts +++ b/src/tools/binance-futures-usdm/adlQuantile.ts @@ -1,39 +1,50 @@ // src/tools/binance-futures-usdm/adlQuantile.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMADLQuantile(server: McpServer) { - server.tool( - "BinanceFuturesUSDMADLQuantile", - "Get position ADL (Auto-Deleveraging) quantile estimate for USD-M Futures.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT). If not provided, returns all positions") - }, - async ({ symbol }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; + server.tool( + "BinanceFuturesUSDMADLQuantile", + "Get position ADL (Auto-Deleveraging) quantile estimate for USD-M Futures.", + { + symbol: z + .string() + .optional() + .describe( + "Symbol of the trading pair (e.g., BTCUSDT). If not provided, returns all positions", + ), + }, + async ({ symbol }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol - const data = await futuresClient.adlQuantile(params); + const data = await futuresClient.adlQuantile(params) + + return { + content: [ + { + type: "text", + text: `Retrieved USD-M Futures ADL quantile${symbol ? ` for ${symbol}` : " for all positions"}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved USD-M Futures ADL quantile${symbol ? ` for ${symbol}` : ' for all positions'}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve USD-M Futures ADL quantile: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve USD-M Futures ADL quantile: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/aggTrades.ts b/src/tools/binance-futures-usdm/aggTrades.ts index 6ea6bc9b..a9346e37 100644 --- a/src/tools/binance-futures-usdm/aggTrades.ts +++ b/src/tools/binance-futures-usdm/aggTrades.ts @@ -1,46 +1,58 @@ // src/tools/binance-futures-usdm/aggTrades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMAggTrades(server: McpServer) { - server.tool( - "BinanceFuturesUSDMAggTrades", - "Get compressed, aggregate trades for a specific USD-M Futures trading pair.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - fromId: z.number().optional().describe("ID to get aggregate trades from INCLUSIVE"), - startTime: z.number().optional().describe("Timestamp in ms to get aggregate trades from INCLUSIVE"), - endTime: z.number().optional().describe("Timestamp in ms to get aggregate trades until INCLUSIVE"), - limit: z.number().optional().describe("Default 500; max 1000") - }, - async ({ symbol, fromId, startTime, endTime, limit }) => { - try { - const params: any = { symbol }; - if (fromId !== undefined) params.fromId = fromId; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; + server.tool( + "BinanceFuturesUSDMAggTrades", + "Get compressed, aggregate trades for a specific USD-M Futures trading pair.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + fromId: z.number().optional().describe("ID to get aggregate trades from INCLUSIVE"), + startTime: z + .number() + .optional() + .describe("Timestamp in ms to get aggregate trades from INCLUSIVE"), + endTime: z + .number() + .optional() + .describe("Timestamp in ms to get aggregate trades until INCLUSIVE"), + limit: z.number().optional().describe("Default 500; max 1000"), + }, + async ({ symbol, fromId, startTime, endTime, limit }) => { + try { + const params: any = { symbol } + if (fromId !== undefined) params.fromId = fromId + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit - const data = await futuresClient.aggTrades(params); + const data = await futuresClient.aggTrades(params) + + return { + content: [ + { + type: "text", + text: `Retrieved ${data.length || 0} aggregated trades for USD-M Futures ${symbol}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved ${data.length || 0} aggregated trades for USD-M Futures ${symbol}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve USD-M Futures aggregated trades: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve USD-M Futures aggregated trades: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/allOrders.ts b/src/tools/binance-futures-usdm/allOrders.ts index 9b5bdeb3..97e4aa86 100644 --- a/src/tools/binance-futures-usdm/allOrders.ts +++ b/src/tools/binance-futures-usdm/allOrders.ts @@ -1,46 +1,49 @@ // src/tools/binance-futures-usdm/allOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMAllOrders(server: McpServer) { - server.tool( - "BinanceFuturesUSDMAllOrders", - "Get all orders (active, canceled, or filled) for USD-M Futures.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - orderId: z.number().optional().describe("Order ID to start from"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1000") - }, - async ({ symbol, orderId, startTime, endTime, limit }) => { - try { - const params: any = { symbol }; - if (orderId !== undefined) params.orderId = orderId; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; + server.tool( + "BinanceFuturesUSDMAllOrders", + "Get all orders (active, canceled, or filled) for USD-M Futures.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + orderId: z.number().optional().describe("Order ID to start from"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1000"), + }, + async ({ symbol, orderId, startTime, endTime, limit }) => { + try { + const params: any = { symbol } + if (orderId !== undefined) params.orderId = orderId + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit - const data = await futuresClient.allOrders(params); + const data = await futuresClient.allOrders(params) + + return { + content: [ + { + type: "text", + text: `Retrieved ${data.length || 0} USD-M Futures orders for ${symbol}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved ${data.length || 0} USD-M Futures orders for ${symbol}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve USD-M Futures all orders: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve USD-M Futures all orders: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/balance.ts b/src/tools/binance-futures-usdm/balance.ts index 9b6397e9..3f2b4bed 100644 --- a/src/tools/binance-futures-usdm/balance.ts +++ b/src/tools/binance-futures-usdm/balance.ts @@ -1,33 +1,35 @@ // src/tools/binance-futures-usdm/balance.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMBalance(server: McpServer) { - server.tool( - "BinanceFuturesUSDMBalance", - "Get current USD-M Futures account balance.", - {}, - async () => { - try { - const data = await futuresClient.balance(); + server.tool( + "BinanceFuturesUSDMBalance", + "Get current USD-M Futures account balance.", + {}, + async () => { + try { + const data = await futuresClient.balance() + + return { + content: [ + { + type: "text", + text: `Retrieved USD-M Futures account balance. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved USD-M Futures account balance. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve USD-M Futures balance: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve USD-M Futures balance: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/batchOrders.ts b/src/tools/binance-futures-usdm/batchOrders.ts index 181f6235..f1a90fa6 100644 --- a/src/tools/binance-futures-usdm/batchOrders.ts +++ b/src/tools/binance-futures-usdm/batchOrders.ts @@ -1,36 +1,43 @@ // src/tools/binance-futures-usdm/batchOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMBatchOrders(server: McpServer) { - server.tool( - "BinanceFuturesUSDMBatchOrders", - "Place multiple orders for USD-M Futures (max 5 orders).", - { - batchOrders: z.string().describe("JSON string of order list. Max 5 orders. Each order has: symbol, side, type, and optional parameters like positionSide, timeInForce, quantity, reduceOnly, price, newClientOrderId, stopPrice, activationPrice, callbackRate, workingType, priceProtect") - }, - async ({ batchOrders }) => { - try { - const data = await futuresClient.batchOrders({ batchOrders }); + server.tool( + "BinanceFuturesUSDMBatchOrders", + "Place multiple orders for USD-M Futures (max 5 orders).", + { + batchOrders: z + .string() + .describe( + "JSON string of order list. Max 5 orders. Each order has: symbol, side, type, and optional parameters like positionSide, timeInForce, quantity, reduceOnly, price, newClientOrderId, stopPrice, activationPrice, callbackRate, workingType, priceProtect", + ), + }, + async ({ batchOrders }) => { + try { + const data = await futuresClient.batchOrders({ batchOrders }) + + return { + content: [ + { + type: "text", + text: `USD-M Futures batch orders created. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `USD-M Futures batch orders created. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to create USD-M Futures batch orders: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to create USD-M Futures batch orders: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/bookTicker.ts b/src/tools/binance-futures-usdm/bookTicker.ts index 18581845..262c8f68 100644 --- a/src/tools/binance-futures-usdm/bookTicker.ts +++ b/src/tools/binance-futures-usdm/bookTicker.ts @@ -1,39 +1,47 @@ // src/tools/binance-futures-usdm/bookTicker.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMBookTicker(server: McpServer) { - server.tool( - "BinanceFuturesUSDMBookTicker", - "Get best price/qty on the order book for a symbol or symbols for USD-M Futures.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT). If not provided, returns all symbols") - }, - async ({ symbol }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; + server.tool( + "BinanceFuturesUSDMBookTicker", + "Get best price/qty on the order book for a symbol or symbols for USD-M Futures.", + { + symbol: z + .string() + .optional() + .describe( + "Symbol of the trading pair (e.g., BTCUSDT). If not provided, returns all symbols", + ), + }, + async ({ symbol }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol - const data = await futuresClient.bookTicker(params); + const data = await futuresClient.bookTicker(params) + + return { + content: [ + { + type: "text", + text: `Retrieved USD-M Futures book ticker${symbol ? ` for ${symbol}` : " for all symbols"}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved USD-M Futures book ticker${symbol ? ` for ${symbol}` : ' for all symbols'}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve USD-M Futures book ticker: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve USD-M Futures book ticker: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/cancelAllOrders.ts b/src/tools/binance-futures-usdm/cancelAllOrders.ts index 631fb095..083c67dd 100644 --- a/src/tools/binance-futures-usdm/cancelAllOrders.ts +++ b/src/tools/binance-futures-usdm/cancelAllOrders.ts @@ -1,36 +1,39 @@ // src/tools/binance-futures-usdm/cancelAllOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMCancelAllOrders(server: McpServer) { - server.tool( - "BinanceFuturesUSDMCancelAllOrders", - "Cancel all open orders for a symbol in USD-M Futures.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)") - }, - async ({ symbol }) => { - try { - const data = await futuresClient.cancelAllOpenOrders({ symbol }); + server.tool( + "BinanceFuturesUSDMCancelAllOrders", + "Cancel all open orders for a symbol in USD-M Futures.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, + async ({ symbol }) => { + try { + const data = await futuresClient.cancelAllOpenOrders({ symbol }) + + return { + content: [ + { + type: "text", + text: `All USD-M Futures open orders cancelled for ${symbol}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `All USD-M Futures open orders cancelled for ${symbol}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to cancel USD-M Futures open orders: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to cancel USD-M Futures open orders: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/cancelBatchOrders.ts b/src/tools/binance-futures-usdm/cancelBatchOrders.ts index 394847a1..510fa94c 100644 --- a/src/tools/binance-futures-usdm/cancelBatchOrders.ts +++ b/src/tools/binance-futures-usdm/cancelBatchOrders.ts @@ -1,42 +1,48 @@ // src/tools/binance-futures-usdm/cancelBatchOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMCancelBatchOrders(server: McpServer) { - server.tool( - "BinanceFuturesUSDMCancelBatchOrders", - "Cancel multiple orders for USD-M Futures.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - orderIdList: z.string().optional().describe("Comma-separated list of order IDs (max 10)"), - origClientOrderIdList: z.string().optional().describe("Comma-separated list of client order IDs (max 10)") - }, - async ({ symbol, orderIdList, origClientOrderIdList }) => { - try { - const params: any = { symbol }; - if (orderIdList) params.orderIdList = orderIdList; - if (origClientOrderIdList) params.origClientOrderIdList = origClientOrderIdList; + server.tool( + "BinanceFuturesUSDMCancelBatchOrders", + "Cancel multiple orders for USD-M Futures.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + orderIdList: z.string().optional().describe("Comma-separated list of order IDs (max 10)"), + origClientOrderIdList: z + .string() + .optional() + .describe("Comma-separated list of client order IDs (max 10)"), + }, + async ({ symbol, orderIdList, origClientOrderIdList }) => { + try { + const params: any = { symbol } + if (orderIdList) params.orderIdList = orderIdList + if (origClientOrderIdList) params.origClientOrderIdList = origClientOrderIdList - const data = await futuresClient.cancelBatchOrders(params); + const data = await futuresClient.cancelBatchOrders(params) + + return { + content: [ + { + type: "text", + text: `USD-M Futures batch orders cancelled. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `USD-M Futures batch orders cancelled. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to cancel USD-M Futures batch orders: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to cancel USD-M Futures batch orders: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/cancelOrder.ts b/src/tools/binance-futures-usdm/cancelOrder.ts index a4e3eb8e..56e0f578 100644 --- a/src/tools/binance-futures-usdm/cancelOrder.ts +++ b/src/tools/binance-futures-usdm/cancelOrder.ts @@ -1,42 +1,45 @@ // src/tools/binance-futures-usdm/cancelOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMCancelOrder(server: McpServer) { - server.tool( - "BinanceFuturesUSDMCancelOrder", - "Cancel an existing order for USD-M Futures.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - orderId: z.number().optional().describe("Order ID"), - origClientOrderId: z.string().optional().describe("Original client order ID") - }, - async ({ symbol, orderId, origClientOrderId }) => { - try { - const params: any = { symbol }; - if (orderId !== undefined) params.orderId = orderId; - if (origClientOrderId) params.origClientOrderId = origClientOrderId; + server.tool( + "BinanceFuturesUSDMCancelOrder", + "Cancel an existing order for USD-M Futures.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + orderId: z.number().optional().describe("Order ID"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + }, + async ({ symbol, orderId, origClientOrderId }) => { + try { + const params: any = { symbol } + if (orderId !== undefined) params.orderId = orderId + if (origClientOrderId) params.origClientOrderId = origClientOrderId - const data = await futuresClient.cancelOrder(params); + const data = await futuresClient.cancelOrder(params) + + return { + content: [ + { + type: "text", + text: `USD-M Futures order cancelled successfully. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `USD-M Futures order cancelled successfully. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to cancel USD-M Futures order: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to cancel USD-M Futures order: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/commissionRate.ts b/src/tools/binance-futures-usdm/commissionRate.ts index 328297c4..d30f8292 100644 --- a/src/tools/binance-futures-usdm/commissionRate.ts +++ b/src/tools/binance-futures-usdm/commissionRate.ts @@ -1,36 +1,42 @@ // src/tools/binance-futures-usdm/commissionRate.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMCommissionRate(server: McpServer) { - server.tool( - "BinanceFuturesUSDMCommissionRate", - "Get user commission rate for USD-M Futures.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)") - }, - async ({ symbol }) => { - try { - const data = await futuresClient.commissionRate({ symbol }); + server.tool( + "BinanceFuturesUSDMCommissionRate", + "Get user commission rate for USD-M Futures.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, + async ({ symbol }) => { + try { + const data = await futuresClient.commissionRate({ symbol }) + + return { + content: [ + { + type: "text", + text: `Retrieved USD-M Futures commission rate for ${symbol}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved USD-M Futures commission rate for ${symbol}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve USD-M Futures commission rate: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve USD-M Futures commission rate: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/continuousKlines.ts b/src/tools/binance-futures-usdm/continuousKlines.ts index 358f278c..ed9310c1 100644 --- a/src/tools/binance-futures-usdm/continuousKlines.ts +++ b/src/tools/binance-futures-usdm/continuousKlines.ts @@ -1,48 +1,72 @@ // src/tools/binance-futures-usdm/continuousKlines.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMContinuousKlines(server: McpServer) { - server.tool( - "BinanceFuturesUSDMContinuousKlines", - "Get continuous contract Kline/candlestick data for USD-M Futures.", - { - pair: z.string().describe("Trading pair (e.g., BTCUSDT)"), - contractType: z.enum(["PERPETUAL", "CURRENT_MONTH", "NEXT_MONTH", "CURRENT_QUARTER", "NEXT_QUARTER"]).describe("Contract type"), - interval: z.enum([ - "1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "8h", "12h", "1d", "3d", "1w", "1M" - ]).describe("Kline interval"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1500") - }, - async ({ pair, contractType, interval, startTime, endTime, limit }) => { - try { - const params: any = { pair, contractType, interval }; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; + server.tool( + "BinanceFuturesUSDMContinuousKlines", + "Get continuous contract Kline/candlestick data for USD-M Futures.", + { + pair: z.string().describe("Trading pair (e.g., BTCUSDT)"), + contractType: z + .enum(["PERPETUAL", "CURRENT_MONTH", "NEXT_MONTH", "CURRENT_QUARTER", "NEXT_QUARTER"]) + .describe("Contract type"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1500"), + }, + async ({ pair, contractType, interval, startTime, endTime, limit }) => { + try { + const params: any = { pair, contractType, interval } + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit - const data = await futuresClient.continuousKlines(params); + const data = await futuresClient.continuousKlines(params) + + return { + content: [ + { + type: "text", + text: `Retrieved ${data.length || 0} continuous klines for USD-M Futures ${pair} ${contractType} with ${interval} interval. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved ${data.length || 0} continuous klines for USD-M Futures ${pair} ${contractType} with ${interval} interval. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve USD-M Futures continuous klines: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve USD-M Futures continuous klines: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/depth.ts b/src/tools/binance-futures-usdm/depth.ts index f477687d..39a0ceec 100644 --- a/src/tools/binance-futures-usdm/depth.ts +++ b/src/tools/binance-futures-usdm/depth.ts @@ -1,40 +1,51 @@ // src/tools/binance-futures-usdm/depth.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMDepth(server: McpServer) { - server.tool( - "BinanceFuturesUSDMDepth", - "Get order book depth data for a specific USD-M Futures trading pair.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - limit: z.number().optional().describe("Depth of the order book. Default 500; max 1000. Valid limits: [5, 10, 20, 50, 100, 500, 1000]") - }, - async ({ symbol, limit }) => { - try { - const params: any = { symbol }; - if (limit !== undefined) params.limit = limit; + server.tool( + "BinanceFuturesUSDMDepth", + "Get order book depth data for a specific USD-M Futures trading pair.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + limit: z + .number() + .optional() + .describe( + "Depth of the order book. Default 500; max 1000. Valid limits: [5, 10, 20, 50, 100, 500, 1000]", + ), + }, + async ({ symbol, limit }) => { + try { + const params: any = { symbol } + if (limit !== undefined) params.limit = limit - const data = await futuresClient.depth(params); + const data = await futuresClient.depth(params) + + return { + content: [ + { + type: "text", + text: `Retrieved USD-M Futures order book depth for ${symbol}. Bids: ${data.bids?.length || 0}, Asks: ${data.asks?.length || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved USD-M Futures order book depth for ${symbol}. Bids: ${data.bids?.length || 0}, Asks: ${data.asks?.length || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve USD-M Futures order book depth: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve USD-M Futures order book depth: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/exchangeInfo.ts b/src/tools/binance-futures-usdm/exchangeInfo.ts index 12640958..a925a081 100644 --- a/src/tools/binance-futures-usdm/exchangeInfo.ts +++ b/src/tools/binance-futures-usdm/exchangeInfo.ts @@ -1,32 +1,35 @@ // src/tools/binance-futures-usdm/exchangeInfo.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMExchangeInfo(server: McpServer) { - server.tool( - "BinanceFuturesUSDMExchangeInfo", - "Get current exchange trading rules and symbol information for USD-M Futures.", - {}, - async () => { - try { - const data = await futuresClient.exchangeInfo(); - return { - content: [ - { - type: "text", - text: `USD-M Futures exchange info retrieved. Symbols count: ${data.symbols?.length || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get USD-M Futures exchange info: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceFuturesUSDMExchangeInfo", + "Get current exchange trading rules and symbol information for USD-M Futures.", + {}, + async () => { + try { + const data = await futuresClient.exchangeInfo() + + return { + content: [ + { + type: "text", + text: `USD-M Futures exchange info retrieved. Symbols count: ${data.symbols?.length || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to get USD-M Futures exchange info: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/forceOrders.ts b/src/tools/binance-futures-usdm/forceOrders.ts index d07e5f32..e7713cd5 100644 --- a/src/tools/binance-futures-usdm/forceOrders.ts +++ b/src/tools/binance-futures-usdm/forceOrders.ts @@ -1,47 +1,56 @@ // src/tools/binance-futures-usdm/forceOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMForceOrders(server: McpServer) { - server.tool( - "BinanceFuturesUSDMForceOrders", - "Get user force orders (liquidation orders) for USD-M Futures.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - autoCloseType: z.enum(["LIQUIDATION", "ADL"]).optional().describe("Auto close type: LIQUIDATION or ADL"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 50; max 100") - }, - async ({ symbol, autoCloseType, startTime, endTime, limit }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - if (autoCloseType) params.autoCloseType = autoCloseType; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; + server.tool( + "BinanceFuturesUSDMForceOrders", + "Get user force orders (liquidation orders) for USD-M Futures.", + { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + autoCloseType: z + .enum(["LIQUIDATION", "ADL"]) + .optional() + .describe("Auto close type: LIQUIDATION or ADL"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 50; max 100"), + }, + async ({ symbol, autoCloseType, startTime, endTime, limit }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + if (autoCloseType) params.autoCloseType = autoCloseType + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit - const data = await futuresClient.forceOrders(params); + const data = await futuresClient.forceOrders(params) + + return { + content: [ + { + type: "text", + text: `Retrieved ${data.length || 0} USD-M Futures force orders. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved ${data.length || 0} USD-M Futures force orders. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve USD-M Futures force orders: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve USD-M Futures force orders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/fundingRate.ts b/src/tools/binance-futures-usdm/fundingRate.ts index 7dcf18d6..8084e9d3 100644 --- a/src/tools/binance-futures-usdm/fundingRate.ts +++ b/src/tools/binance-futures-usdm/fundingRate.ts @@ -1,45 +1,51 @@ // src/tools/binance-futures-usdm/fundingRate.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMFundingRate(server: McpServer) { - server.tool( - "BinanceFuturesUSDMFundingRate", - "Get funding rate history for USD-M Futures.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 100; max 1000") - }, - async ({ symbol, startTime, endTime, limit }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; + server.tool( + "BinanceFuturesUSDMFundingRate", + "Get funding rate history for USD-M Futures.", + { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 100; max 1000"), + }, + async ({ symbol, startTime, endTime, limit }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit - const data = await futuresClient.fundingRate(params); + const data = await futuresClient.fundingRate(params) + + return { + content: [ + { + type: "text", + text: `Retrieved ${data.length || 0} funding rate records for USD-M Futures${symbol ? ` ${symbol}` : ""}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved ${data.length || 0} funding rate records for USD-M Futures${symbol ? ` ${symbol}` : ''}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve USD-M Futures funding rate: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve USD-M Futures funding rate: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/getOrder.ts b/src/tools/binance-futures-usdm/getOrder.ts index 08922276..136f0864 100644 --- a/src/tools/binance-futures-usdm/getOrder.ts +++ b/src/tools/binance-futures-usdm/getOrder.ts @@ -1,42 +1,45 @@ // src/tools/binance-futures-usdm/getOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMGetOrder(server: McpServer) { - server.tool( - "BinanceFuturesUSDMGetOrder", - "Query an existing order for USD-M Futures.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - orderId: z.number().optional().describe("Order ID"), - origClientOrderId: z.string().optional().describe("Original client order ID") - }, - async ({ symbol, orderId, origClientOrderId }) => { - try { - const params: any = { symbol }; - if (orderId !== undefined) params.orderId = orderId; - if (origClientOrderId) params.origClientOrderId = origClientOrderId; + server.tool( + "BinanceFuturesUSDMGetOrder", + "Query an existing order for USD-M Futures.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + orderId: z.number().optional().describe("Order ID"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + }, + async ({ symbol, orderId, origClientOrderId }) => { + try { + const params: any = { symbol } + if (orderId !== undefined) params.orderId = orderId + if (origClientOrderId) params.origClientOrderId = origClientOrderId - const data = await futuresClient.getOrder(params); + const data = await futuresClient.getOrder(params) + + return { + content: [ + { + type: "text", + text: `Retrieved USD-M Futures order. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved USD-M Futures order. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve USD-M Futures order: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve USD-M Futures order: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/historicalTrades.ts b/src/tools/binance-futures-usdm/historicalTrades.ts index 7035b792..b64b66ed 100644 --- a/src/tools/binance-futures-usdm/historicalTrades.ts +++ b/src/tools/binance-futures-usdm/historicalTrades.ts @@ -1,42 +1,51 @@ // src/tools/binance-futures-usdm/historicalTrades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMHistoricalTrades(server: McpServer) { - server.tool( - "BinanceFuturesUSDMHistoricalTrades", - "Get older market historical trades for a specific USD-M Futures trading pair.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - limit: z.number().optional().describe("Number of trades to return. Default 500; max 1000"), - fromId: z.number().optional().describe("Trade ID to fetch from. Default gets most recent trades") - }, - async ({ symbol, limit, fromId }) => { - try { - const params: any = { symbol }; - if (limit !== undefined) params.limit = limit; - if (fromId !== undefined) params.fromId = fromId; + server.tool( + "BinanceFuturesUSDMHistoricalTrades", + "Get older market historical trades for a specific USD-M Futures trading pair.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + limit: z.number().optional().describe("Number of trades to return. Default 500; max 1000"), + fromId: z + .number() + .optional() + .describe("Trade ID to fetch from. Default gets most recent trades"), + }, + async ({ symbol, limit, fromId }) => { + try { + const params: any = { symbol } + if (limit !== undefined) params.limit = limit + if (fromId !== undefined) params.fromId = fromId - const data = await futuresClient.historicalTrades(params); + const data = await futuresClient.historicalTrades(params) + + return { + content: [ + { + type: "text", + text: `Retrieved ${data.length || 0} historical trades for USD-M Futures ${symbol}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved ${data.length || 0} historical trades for USD-M Futures ${symbol}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve USD-M Futures historical trades: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve USD-M Futures historical trades: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/income.ts b/src/tools/binance-futures-usdm/income.ts index 6cd925d5..01c23c02 100644 --- a/src/tools/binance-futures-usdm/income.ts +++ b/src/tools/binance-futures-usdm/income.ts @@ -1,47 +1,73 @@ // src/tools/binance-futures-usdm/income.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMIncome(server: McpServer) { - server.tool( - "BinanceFuturesUSDMIncome", - "Get income history for USD-M Futures.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - incomeType: z.enum(["TRANSFER", "WELCOME_BONUS", "REALIZED_PNL", "FUNDING_FEE", "COMMISSION", "INSURANCE_CLEAR", "REFERRAL_KICKBACK", "COMMISSION_REBATE", "API_REBATE", "CONTEST_REWARD", "CROSS_COLLATERAL_TRANSFER", "OPTIONS_PREMIUM_FEE", "OPTIONS_SETTLE_PROFIT", "INTERNAL_TRANSFER", "AUTO_EXCHANGE", "DELIVERED_SETTELMENT", "COIN_SWAP_DEPOSIT", "COIN_SWAP_WITHDRAW", "POSITION_LIMIT_INCREASE_FEE"]).optional().describe("Income type"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 100; max 1000") - }, - async ({ symbol, incomeType, startTime, endTime, limit }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - if (incomeType) params.incomeType = incomeType; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; + server.tool( + "BinanceFuturesUSDMIncome", + "Get income history for USD-M Futures.", + { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + incomeType: z + .enum([ + "TRANSFER", + "WELCOME_BONUS", + "REALIZED_PNL", + "FUNDING_FEE", + "COMMISSION", + "INSURANCE_CLEAR", + "REFERRAL_KICKBACK", + "COMMISSION_REBATE", + "API_REBATE", + "CONTEST_REWARD", + "CROSS_COLLATERAL_TRANSFER", + "OPTIONS_PREMIUM_FEE", + "OPTIONS_SETTLE_PROFIT", + "INTERNAL_TRANSFER", + "AUTO_EXCHANGE", + "DELIVERED_SETTELMENT", + "COIN_SWAP_DEPOSIT", + "COIN_SWAP_WITHDRAW", + "POSITION_LIMIT_INCREASE_FEE", + ]) + .optional() + .describe("Income type"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 100; max 1000"), + }, + async ({ symbol, incomeType, startTime, endTime, limit }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + if (incomeType) params.incomeType = incomeType + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit - const data = await futuresClient.income(params); + const data = await futuresClient.income(params) + + return { + content: [ + { + type: "text", + text: `Retrieved ${data.length || 0} USD-M Futures income records. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved ${data.length || 0} USD-M Futures income records. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve USD-M Futures income: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve USD-M Futures income: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/index.ts b/src/tools/binance-futures-usdm/index.ts index 749790f4..66bd3ef4 100644 --- a/src/tools/binance-futures-usdm/index.ts +++ b/src/tools/binance-futures-usdm/index.ts @@ -1,96 +1,98 @@ // src/tools/binance-futures-usdm/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; - -// Market Data -import { registerBinanceFuturesUSDMPing } from "./ping.js"; -import { registerBinanceFuturesUSDMTime } from "./time.js"; -import { registerBinanceFuturesUSDMExchangeInfo } from "./exchangeInfo.js"; -import { registerBinanceFuturesUSDMDepth } from "./depth.js"; -import { registerBinanceFuturesUSDMTrades } from "./trades.js"; -import { registerBinanceFuturesUSDMHistoricalTrades } from "./historicalTrades.js"; -import { registerBinanceFuturesUSDMAggTrades } from "./aggTrades.js"; -import { registerBinanceFuturesUSDMKlines } from "./klines.js"; -import { registerBinanceFuturesUSDMContinuousKlines } from "./continuousKlines.js"; -import { registerBinanceFuturesUSDMIndexPriceKlines } from "./indexPriceKlines.js"; -import { registerBinanceFuturesUSDMMarkPriceKlines } from "./markPriceKlines.js"; -import { registerBinanceFuturesUSDMPremiumIndex } from "./premiumIndex.js"; -import { registerBinanceFuturesUSDMFundingRate } from "./fundingRate.js"; -import { registerBinanceFuturesUSDMTicker24hr } from "./ticker24hr.js"; -import { registerBinanceFuturesUSDMTickerPrice } from "./tickerPrice.js"; -import { registerBinanceFuturesUSDMBookTicker } from "./bookTicker.js"; -import { registerBinanceFuturesUSDMOpenInterest } from "./openInterest.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" // Account & Trading -import { registerBinanceFuturesUSDMAccount } from "./account.js"; -import { registerBinanceFuturesUSDMBalance } from "./balance.js"; -import { registerBinanceFuturesUSDMPositionRisk } from "./positionRisk.js"; -import { registerBinanceFuturesUSDMNewOrder } from "./newOrder.js"; -import { registerBinanceFuturesUSDMBatchOrders } from "./batchOrders.js"; -import { registerBinanceFuturesUSDMGetOrder } from "./getOrder.js"; -import { registerBinanceFuturesUSDMCancelOrder } from "./cancelOrder.js"; -import { registerBinanceFuturesUSDMCancelAllOrders } from "./cancelAllOrders.js"; -import { registerBinanceFuturesUSDMCancelBatchOrders } from "./cancelBatchOrders.js"; -import { registerBinanceFuturesUSDMOpenOrders } from "./openOrders.js"; -import { registerBinanceFuturesUSDMAllOrders } from "./allOrders.js"; -import { registerBinanceFuturesUSDMUserTrades } from "./userTrades.js"; -import { registerBinanceFuturesUSDMIncome } from "./income.js"; -import { registerBinanceFuturesUSDMLeverage } from "./leverage.js"; -import { registerBinanceFuturesUSDMMarginType } from "./marginType.js"; -import { registerBinanceFuturesUSDMPositionMargin } from "./positionMargin.js"; -import { registerBinanceFuturesUSDMPositionMode } from "./positionMode.js"; -import { registerBinanceFuturesUSDMMultiAssetsMode } from "./multiAssetsMode.js"; -import { registerBinanceFuturesUSDMCommissionRate } from "./commissionRate.js"; -import { registerBinanceFuturesUSDMForceOrders } from "./forceOrders.js"; -import { registerBinanceFuturesUSDMADLQuantile } from "./adlQuantile.js"; - +import { registerBinanceFuturesUSDMAccount } from "./account.js" +import { registerBinanceFuturesUSDMADLQuantile } from "./adlQuantile.js" +import { registerBinanceFuturesUSDMAggTrades } from "./aggTrades.js" +import { registerBinanceFuturesUSDMAllOrders } from "./allOrders.js" +import { registerBinanceFuturesUSDMBalance } from "./balance.js" +import { registerBinanceFuturesUSDMBatchOrders } from "./batchOrders.js" +import { registerBinanceFuturesUSDMBookTicker } from "./bookTicker.js" +import { registerBinanceFuturesUSDMCancelAllOrders } from "./cancelAllOrders.js" +import { registerBinanceFuturesUSDMCancelBatchOrders } from "./cancelBatchOrders.js" +import { registerBinanceFuturesUSDMCancelOrder } from "./cancelOrder.js" +import { registerBinanceFuturesUSDMCommissionRate } from "./commissionRate.js" +import { registerBinanceFuturesUSDMContinuousKlines } from "./continuousKlines.js" +import { registerBinanceFuturesUSDMDepth } from "./depth.js" +import { registerBinanceFuturesUSDMExchangeInfo } from "./exchangeInfo.js" +import { registerBinanceFuturesUSDMForceOrders } from "./forceOrders.js" +import { registerBinanceFuturesUSDMFundingRate } from "./fundingRate.js" +import { registerBinanceFuturesUSDMGetOrder } from "./getOrder.js" +import { registerBinanceFuturesUSDMHistoricalTrades } from "./historicalTrades.js" +import { registerBinanceFuturesUSDMIncome } from "./income.js" +import { registerBinanceFuturesUSDMIndexPriceKlines } from "./indexPriceKlines.js" +import { registerBinanceFuturesUSDMKlines } from "./klines.js" +import { registerBinanceFuturesUSDMLeverage } from "./leverage.js" // User Data Stream -import { registerBinanceFuturesUSDMListenKeyCreate, registerBinanceFuturesUSDMListenKeyRenew, registerBinanceFuturesUSDMListenKeyClose } from "./listenKey.js"; +import { + registerBinanceFuturesUSDMListenKeyClose, + registerBinanceFuturesUSDMListenKeyCreate, + registerBinanceFuturesUSDMListenKeyRenew, +} from "./listenKey.js" +import { registerBinanceFuturesUSDMMarginType } from "./marginType.js" +import { registerBinanceFuturesUSDMMarkPriceKlines } from "./markPriceKlines.js" +import { registerBinanceFuturesUSDMMultiAssetsMode } from "./multiAssetsMode.js" +import { registerBinanceFuturesUSDMNewOrder } from "./newOrder.js" +import { registerBinanceFuturesUSDMOpenInterest } from "./openInterest.js" +import { registerBinanceFuturesUSDMOpenOrders } from "./openOrders.js" +// Market Data +import { registerBinanceFuturesUSDMPing } from "./ping.js" +import { registerBinanceFuturesUSDMPositionMargin } from "./positionMargin.js" +import { registerBinanceFuturesUSDMPositionMode } from "./positionMode.js" +import { registerBinanceFuturesUSDMPositionRisk } from "./positionRisk.js" +import { registerBinanceFuturesUSDMPremiumIndex } from "./premiumIndex.js" +import { registerBinanceFuturesUSDMTicker24hr } from "./ticker24hr.js" +import { registerBinanceFuturesUSDMTickerPrice } from "./tickerPrice.js" +import { registerBinanceFuturesUSDMTime } from "./time.js" +import { registerBinanceFuturesUSDMTrades } from "./trades.js" +import { registerBinanceFuturesUSDMUserTrades } from "./userTrades.js" export function registerBinanceFuturesUSDMTools(server: McpServer) { - // Market Data - registerBinanceFuturesUSDMPing(server); - registerBinanceFuturesUSDMTime(server); - registerBinanceFuturesUSDMExchangeInfo(server); - registerBinanceFuturesUSDMDepth(server); - registerBinanceFuturesUSDMTrades(server); - registerBinanceFuturesUSDMHistoricalTrades(server); - registerBinanceFuturesUSDMAggTrades(server); - registerBinanceFuturesUSDMKlines(server); - registerBinanceFuturesUSDMContinuousKlines(server); - registerBinanceFuturesUSDMIndexPriceKlines(server); - registerBinanceFuturesUSDMMarkPriceKlines(server); - registerBinanceFuturesUSDMPremiumIndex(server); - registerBinanceFuturesUSDMFundingRate(server); - registerBinanceFuturesUSDMTicker24hr(server); - registerBinanceFuturesUSDMTickerPrice(server); - registerBinanceFuturesUSDMBookTicker(server); - registerBinanceFuturesUSDMOpenInterest(server); + // Market Data + registerBinanceFuturesUSDMPing(server) + registerBinanceFuturesUSDMTime(server) + registerBinanceFuturesUSDMExchangeInfo(server) + registerBinanceFuturesUSDMDepth(server) + registerBinanceFuturesUSDMTrades(server) + registerBinanceFuturesUSDMHistoricalTrades(server) + registerBinanceFuturesUSDMAggTrades(server) + registerBinanceFuturesUSDMKlines(server) + registerBinanceFuturesUSDMContinuousKlines(server) + registerBinanceFuturesUSDMIndexPriceKlines(server) + registerBinanceFuturesUSDMMarkPriceKlines(server) + registerBinanceFuturesUSDMPremiumIndex(server) + registerBinanceFuturesUSDMFundingRate(server) + registerBinanceFuturesUSDMTicker24hr(server) + registerBinanceFuturesUSDMTickerPrice(server) + registerBinanceFuturesUSDMBookTicker(server) + registerBinanceFuturesUSDMOpenInterest(server) - // Account & Trading - registerBinanceFuturesUSDMAccount(server); - registerBinanceFuturesUSDMBalance(server); - registerBinanceFuturesUSDMPositionRisk(server); - registerBinanceFuturesUSDMNewOrder(server); - registerBinanceFuturesUSDMBatchOrders(server); - registerBinanceFuturesUSDMGetOrder(server); - registerBinanceFuturesUSDMCancelOrder(server); - registerBinanceFuturesUSDMCancelAllOrders(server); - registerBinanceFuturesUSDMCancelBatchOrders(server); - registerBinanceFuturesUSDMOpenOrders(server); - registerBinanceFuturesUSDMAllOrders(server); - registerBinanceFuturesUSDMUserTrades(server); - registerBinanceFuturesUSDMIncome(server); - registerBinanceFuturesUSDMLeverage(server); - registerBinanceFuturesUSDMMarginType(server); - registerBinanceFuturesUSDMPositionMargin(server); - registerBinanceFuturesUSDMPositionMode(server); - registerBinanceFuturesUSDMMultiAssetsMode(server); - registerBinanceFuturesUSDMCommissionRate(server); - registerBinanceFuturesUSDMForceOrders(server); - registerBinanceFuturesUSDMADLQuantile(server); + // Account & Trading + registerBinanceFuturesUSDMAccount(server) + registerBinanceFuturesUSDMBalance(server) + registerBinanceFuturesUSDMPositionRisk(server) + registerBinanceFuturesUSDMNewOrder(server) + registerBinanceFuturesUSDMBatchOrders(server) + registerBinanceFuturesUSDMGetOrder(server) + registerBinanceFuturesUSDMCancelOrder(server) + registerBinanceFuturesUSDMCancelAllOrders(server) + registerBinanceFuturesUSDMCancelBatchOrders(server) + registerBinanceFuturesUSDMOpenOrders(server) + registerBinanceFuturesUSDMAllOrders(server) + registerBinanceFuturesUSDMUserTrades(server) + registerBinanceFuturesUSDMIncome(server) + registerBinanceFuturesUSDMLeverage(server) + registerBinanceFuturesUSDMMarginType(server) + registerBinanceFuturesUSDMPositionMargin(server) + registerBinanceFuturesUSDMPositionMode(server) + registerBinanceFuturesUSDMMultiAssetsMode(server) + registerBinanceFuturesUSDMCommissionRate(server) + registerBinanceFuturesUSDMForceOrders(server) + registerBinanceFuturesUSDMADLQuantile(server) - // User Data Stream - registerBinanceFuturesUSDMListenKeyCreate(server); - registerBinanceFuturesUSDMListenKeyRenew(server); - registerBinanceFuturesUSDMListenKeyClose(server); + // User Data Stream + registerBinanceFuturesUSDMListenKeyCreate(server) + registerBinanceFuturesUSDMListenKeyRenew(server) + registerBinanceFuturesUSDMListenKeyClose(server) } diff --git a/src/tools/binance-futures-usdm/indexPriceKlines.ts b/src/tools/binance-futures-usdm/indexPriceKlines.ts index 3a272f32..52c9661e 100644 --- a/src/tools/binance-futures-usdm/indexPriceKlines.ts +++ b/src/tools/binance-futures-usdm/indexPriceKlines.ts @@ -1,47 +1,69 @@ // src/tools/binance-futures-usdm/indexPriceKlines.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMIndexPriceKlines(server: McpServer) { - server.tool( - "BinanceFuturesUSDMIndexPriceKlines", - "Get index price Kline/candlestick data for USD-M Futures.", - { - pair: z.string().describe("Trading pair (e.g., BTCUSDT)"), - interval: z.enum([ - "1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "8h", "12h", "1d", "3d", "1w", "1M" - ]).describe("Kline interval"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1500") - }, - async ({ pair, interval, startTime, endTime, limit }) => { - try { - const params: any = { pair, interval }; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; + server.tool( + "BinanceFuturesUSDMIndexPriceKlines", + "Get index price Kline/candlestick data for USD-M Futures.", + { + pair: z.string().describe("Trading pair (e.g., BTCUSDT)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1500"), + }, + async ({ pair, interval, startTime, endTime, limit }) => { + try { + const params: any = { pair, interval } + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit - const data = await futuresClient.indexPriceKlines(params); + const data = await futuresClient.indexPriceKlines(params) + + return { + content: [ + { + type: "text", + text: `Retrieved ${data.length || 0} index price klines for USD-M Futures ${pair} with ${interval} interval. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved ${data.length || 0} index price klines for USD-M Futures ${pair} with ${interval} interval. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve USD-M Futures index price klines: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve USD-M Futures index price klines: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/klines.ts b/src/tools/binance-futures-usdm/klines.ts index 6b997b0c..5ee6bc96 100644 --- a/src/tools/binance-futures-usdm/klines.ts +++ b/src/tools/binance-futures-usdm/klines.ts @@ -1,48 +1,66 @@ // src/tools/binance-futures-usdm/klines.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMKlines(server: McpServer) { - server.tool( - "BinanceFuturesUSDMKlines", - "Get Kline/candlestick bars for a specific USD-M Futures trading pair.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - interval: z.enum([ - "1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "8h", "12h", "1d", "3d", "1w", "1M" - ]).describe("Kline interval"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1500") - }, - async ({ symbol, interval, startTime, endTime, limit }) => { - try { - const params: any = { symbol, interval }; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; + server.tool( + "BinanceFuturesUSDMKlines", + "Get Kline/candlestick bars for a specific USD-M Futures trading pair.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1500"), + }, + async ({ symbol, interval, startTime, endTime, limit }) => { + try { + const params: any = { symbol, interval } + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit - const data = await futuresClient.klines(params); - + const data = await futuresClient.klines(params) + + return { + content: [ + { + type: "text", + text: `Retrieved ${data.length || 0} klines for USD-M Futures ${symbol} with ${interval} interval. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved ${data.length || 0} klines for USD-M Futures ${symbol} with ${interval} interval. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve USD-M Futures klines: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve USD-M Futures klines: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/leverage.ts b/src/tools/binance-futures-usdm/leverage.ts index f3909099..899a6cb8 100644 --- a/src/tools/binance-futures-usdm/leverage.ts +++ b/src/tools/binance-futures-usdm/leverage.ts @@ -1,38 +1,40 @@ // src/tools/binance-futures-usdm/leverage.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMLeverage(server: McpServer) { - server.tool( - "BinanceFuturesUSDMLeverage", - "Change initial leverage for a symbol in USD-M Futures.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - leverage: z.number().describe("Target leverage (1-125)") - }, - async ({ symbol, leverage }) => { - try { - const data = await futuresClient.leverage({ symbol, leverage }); - + server.tool( + "BinanceFuturesUSDMLeverage", + "Change initial leverage for a symbol in USD-M Futures.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + leverage: z.number().describe("Target leverage (1-125)"), + }, + async ({ symbol, leverage }) => { + try { + const data = await futuresClient.leverage({ symbol, leverage }) + + return { + content: [ + { + type: "text", + text: `USD-M Futures leverage changed to ${leverage}x for ${symbol}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `USD-M Futures leverage changed to ${leverage}x for ${symbol}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to change USD-M Futures leverage: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to change USD-M Futures leverage: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/listenKey.ts b/src/tools/binance-futures-usdm/listenKey.ts index 8cbbd923..7787295e 100644 --- a/src/tools/binance-futures-usdm/listenKey.ts +++ b/src/tools/binance-futures-usdm/listenKey.ts @@ -1,97 +1,97 @@ // src/tools/binance-futures-usdm/listenKey.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMListenKeyCreate(server: McpServer) { - server.tool( - "BinanceFuturesUSDMListenKeyCreate", - "Start a new user data stream for USD-M Futures. Returns a listenKey for WebSocket connection.", - {}, - async () => { - try { - const data = await futuresClient.createListenKey(); - + server.tool( + "BinanceFuturesUSDMListenKeyCreate", + "Start a new user data stream for USD-M Futures. Returns a listenKey for WebSocket connection.", + {}, + async () => { + try { + const data = await futuresClient.createListenKey() + + return { + content: [ + { + type: "text", + text: `USD-M Futures listen key created. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `USD-M Futures listen key created. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to create USD-M Futures listen key: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to create USD-M Futures listen key: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } export function registerBinanceFuturesUSDMListenKeyRenew(server: McpServer) { - server.tool( - "BinanceFuturesUSDMListenKeyRenew", - "Keepalive a user data stream to prevent timeout for USD-M Futures.", - {}, - async () => { - try { - const data = await futuresClient.keepAliveListenKey(); - + server.tool( + "BinanceFuturesUSDMListenKeyRenew", + "Keepalive a user data stream to prevent timeout for USD-M Futures.", + {}, + async () => { + try { + const data = await futuresClient.keepAliveListenKey() - return { - content: [ - { - type: "text", - text: `USD-M Futures listen key renewed. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to renew USD-M Futures listen key: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `USD-M Futures listen key renewed. Response: ${JSON.stringify(data)}`, + }, + ], } - ); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to renew USD-M Futures listen key: ${errorMessage}` }, + ], + isError: true, + } + } + }, + ) } export function registerBinanceFuturesUSDMListenKeyClose(server: McpServer) { - server.tool( - "BinanceFuturesUSDMListenKeyClose", - "Close a user data stream for USD-M Futures.", - {}, - async () => { - try { - const data = await futuresClient.closeListenKey(); - + server.tool( + "BinanceFuturesUSDMListenKeyClose", + "Close a user data stream for USD-M Futures.", + {}, + async () => { + try { + const data = await futuresClient.closeListenKey() + + return { + content: [ + { + type: "text", + text: `USD-M Futures listen key closed. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `USD-M Futures listen key closed. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to close USD-M Futures listen key: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to close USD-M Futures listen key: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/marginType.ts b/src/tools/binance-futures-usdm/marginType.ts index b5a58ed3..b9ca93c8 100644 --- a/src/tools/binance-futures-usdm/marginType.ts +++ b/src/tools/binance-futures-usdm/marginType.ts @@ -1,38 +1,40 @@ // src/tools/binance-futures-usdm/marginType.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMMarginType(server: McpServer) { - server.tool( - "BinanceFuturesUSDMMarginType", - "Change margin type for a symbol in USD-M Futures.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - marginType: z.enum(["ISOLATED", "CROSSED"]).describe("Margin type: ISOLATED or CROSSED") - }, - async ({ symbol, marginType }) => { - try { - const data = await futuresClient.marginType({ symbol, marginType }); - + server.tool( + "BinanceFuturesUSDMMarginType", + "Change margin type for a symbol in USD-M Futures.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + marginType: z.enum(["ISOLATED", "CROSSED"]).describe("Margin type: ISOLATED or CROSSED"), + }, + async ({ symbol, marginType }) => { + try { + const data = await futuresClient.marginType({ symbol, marginType }) + + return { + content: [ + { + type: "text", + text: `USD-M Futures margin type changed to ${marginType} for ${symbol}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `USD-M Futures margin type changed to ${marginType} for ${symbol}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to change USD-M Futures margin type: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to change USD-M Futures margin type: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/markPriceKlines.ts b/src/tools/binance-futures-usdm/markPriceKlines.ts index 6ad0e22a..2c4e22c5 100644 --- a/src/tools/binance-futures-usdm/markPriceKlines.ts +++ b/src/tools/binance-futures-usdm/markPriceKlines.ts @@ -1,48 +1,69 @@ // src/tools/binance-futures-usdm/markPriceKlines.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMMarkPriceKlines(server: McpServer) { - server.tool( - "BinanceFuturesUSDMMarkPriceKlines", - "Get mark price Kline/candlestick data for USD-M Futures.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - interval: z.enum([ - "1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "8h", "12h", "1d", "3d", "1w", "1M" - ]).describe("Kline interval"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1500") - }, - async ({ symbol, interval, startTime, endTime, limit }) => { - try { - const params: any = { symbol, interval }; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; + server.tool( + "BinanceFuturesUSDMMarkPriceKlines", + "Get mark price Kline/candlestick data for USD-M Futures.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1500"), + }, + async ({ symbol, interval, startTime, endTime, limit }) => { + try { + const params: any = { symbol, interval } + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit - const data = await futuresClient.markPriceKlines(params); - + const data = await futuresClient.markPriceKlines(params) + + return { + content: [ + { + type: "text", + text: `Retrieved ${data.length || 0} mark price klines for USD-M Futures ${symbol} with ${interval} interval. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved ${data.length || 0} mark price klines for USD-M Futures ${symbol} with ${interval} interval. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve USD-M Futures mark price klines: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve USD-M Futures mark price klines: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/market-api/aggTrades.ts b/src/tools/binance-futures-usdm/market-api/aggTrades.ts index c8e772d4..04de252a 100644 --- a/src/tools/binance-futures-usdm/market-api/aggTrades.ts +++ b/src/tools/binance-futures-usdm/market-api/aggTrades.ts @@ -5,44 +5,50 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/aggTrades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesAggTrades(server: McpServer) { - server.tool( - "BinanceFuturesAggTrades", - "Get compressed aggregate trades for a USD-M Futures symbol.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - fromId: z.number().int().optional().describe("Trade ID to start from"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - limit: z.number().int().optional().describe("Number of trades. Default 500, max 1000") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.aggTrades({ - symbol: params.symbol, - ...(params.fromId !== undefined && { fromId: params.fromId }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Aggregate Trades for ${params.symbol}: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get aggregate trades: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesAggTrades", + "Get compressed aggregate trades for a USD-M Futures symbol.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + fromId: z.number().int().optional().describe("Trade ID to start from"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + limit: z.number().int().optional().describe("Number of trades. Default 500, max 1000"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.aggTrades({ + symbol: params.symbol, + ...(params.fromId !== undefined && { fromId: params.fromId }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Aggregate Trades for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get aggregate trades: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/market-api/assetIndex.ts b/src/tools/binance-futures-usdm/market-api/assetIndex.ts index ae4af796..e19a5ed3 100644 --- a/src/tools/binance-futures-usdm/market-api/assetIndex.ts +++ b/src/tools/binance-futures-usdm/market-api/assetIndex.ts @@ -5,36 +5,42 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/assetIndex.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesAssetIndex(server: McpServer) { - server.tool( - "BinanceFuturesAssetIndex", - "Get asset index for Multi-Asset margin mode.", - { - symbol: z.string().optional().describe("Symbol (e.g., BTCUSD)") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.assetIndex({ - ...(params.symbol && { symbol: params.symbol }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Asset index${params.symbol ? ` for ${params.symbol}` : ''}: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get asset index: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesAssetIndex", + "Get asset index for Multi-Asset margin mode.", + { + symbol: z.string().optional().describe("Symbol (e.g., BTCUSD)"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.assetIndex({ + ...(params.symbol && { symbol: params.symbol }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Asset index${params.symbol ? ` for ${params.symbol}` : ""}: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get asset index: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/market-api/continuousKlines.ts b/src/tools/binance-futures-usdm/market-api/continuousKlines.ts index 4bd3ce07..9f5d5c28 100644 --- a/src/tools/binance-futures-usdm/market-api/continuousKlines.ts +++ b/src/tools/binance-futures-usdm/market-api/continuousKlines.ts @@ -5,51 +5,72 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/continuousKlines.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesContinuousKlines(server: McpServer) { - server.tool( - "BinanceFuturesContinuousKlines", - "Get continuous contract kline data for USD-M Futures.", - { - pair: z.string().describe("Underlying pair (e.g., BTCUSDT)"), - contractType: z.enum(["PERPETUAL", "CURRENT_MONTH", "NEXT_MONTH", "CURRENT_QUARTER", "NEXT_QUARTER"]) - .describe("Contract type"), - interval: z.enum([ - "1m", "3m", "5m", "15m", "30m", - "1h", "2h", "4h", "6h", "8h", "12h", - "1d", "3d", "1w", "1M" - ]).describe("Kline interval"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - limit: z.number().int().optional().describe("Number of klines. Default 500, max 1500") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.continuousKlines({ - pair: params.pair, - contractType: params.contractType, - interval: params.interval, - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Continuous Klines for ${params.pair} ${params.contractType}: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get continuous klines: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesContinuousKlines", + "Get continuous contract kline data for USD-M Futures.", + { + pair: z.string().describe("Underlying pair (e.g., BTCUSDT)"), + contractType: z + .enum(["PERPETUAL", "CURRENT_MONTH", "NEXT_MONTH", "CURRENT_QUARTER", "NEXT_QUARTER"]) + .describe("Contract type"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + limit: z.number().int().optional().describe("Number of klines. Default 500, max 1500"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.continuousKlines({ + pair: params.pair, + contractType: params.contractType, + interval: params.interval, + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Continuous Klines for ${params.pair} ${params.contractType}: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get continuous klines: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/market-api/depth.ts b/src/tools/binance-futures-usdm/market-api/depth.ts index f2ecd2f0..5b31944c 100644 --- a/src/tools/binance-futures-usdm/market-api/depth.ts +++ b/src/tools/binance-futures-usdm/market-api/depth.ts @@ -5,38 +5,48 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/depth.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesDepth(server: McpServer) { - server.tool( - "BinanceFuturesDepth", - "Get order book depth data for a USD-M Futures symbol.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - limit: z.number().int().optional().describe("Depth limit: 5, 10, 20, 50, 100, 500, 1000. Default 500") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.depth({ - symbol: params.symbol, - ...(params.limit && { limit: params.limit }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Futures Order Book for ${params.symbol}: Bids: ${data.bids?.length || 0}, Asks: ${data.asks?.length || 0}. ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get depth: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesDepth", + "Get order book depth data for a USD-M Futures symbol.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + limit: z + .number() + .int() + .optional() + .describe("Depth limit: 5, 10, 20, 50, 100, 500, 1000. Default 500"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.depth({ + symbol: params.symbol, + ...(params.limit && { limit: params.limit }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Futures Order Book for ${params.symbol}: Bids: ${data.bids?.length || 0}, Asks: ${data.asks?.length || 0}. ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get depth: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/market-api/exchangeInfo.ts b/src/tools/binance-futures-usdm/market-api/exchangeInfo.ts index 01174b22..1b5bfe31 100644 --- a/src/tools/binance-futures-usdm/market-api/exchangeInfo.ts +++ b/src/tools/binance-futures-usdm/market-api/exchangeInfo.ts @@ -5,31 +5,36 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/exchangeInfo.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesExchangeInfo(server: McpServer) { - server.tool( - "BinanceFuturesExchangeInfo", - "Get current USD-M Futures exchange trading rules and symbol information.", - {}, - async () => { - try { - const response = await futuresClient.restAPI.exchangeInfo(); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Futures Exchange Info: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get exchange info: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesExchangeInfo", + "Get current USD-M Futures exchange trading rules and symbol information.", + {}, + async () => { + try { + const response = await futuresClient.restAPI.exchangeInfo() + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Futures Exchange Info: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get exchange info: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/market-api/fundingInfo.ts b/src/tools/binance-futures-usdm/market-api/fundingInfo.ts index c5faed0f..63a99417 100644 --- a/src/tools/binance-futures-usdm/market-api/fundingInfo.ts +++ b/src/tools/binance-futures-usdm/market-api/fundingInfo.ts @@ -5,31 +5,36 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/fundingInfo.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesFundingInfo(server: McpServer) { - server.tool( - "BinanceFuturesFundingInfo", - "Get funding rate info for all perpetual symbols on USD-M Futures.", - {}, - async () => { - try { - const response = await futuresClient.restAPI.fundingInfo(); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Funding Info: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get funding info: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesFundingInfo", + "Get funding rate info for all perpetual symbols on USD-M Futures.", + {}, + async () => { + try { + const response = await futuresClient.restAPI.fundingInfo() + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Funding Info: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get funding info: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/market-api/fundingRate.ts b/src/tools/binance-futures-usdm/market-api/fundingRate.ts index f063dafa..4c6080ff 100644 --- a/src/tools/binance-futures-usdm/market-api/fundingRate.ts +++ b/src/tools/binance-futures-usdm/market-api/fundingRate.ts @@ -5,42 +5,48 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/fundingRate.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesFundingRate(server: McpServer) { - server.tool( - "BinanceFuturesFundingRate", - "Get funding rate history for USD-M Futures.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - limit: z.number().int().optional().describe("Number of results. Default 100, max 1000") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.fundingRate({ - symbol: params.symbol, - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Funding Rate History for ${params.symbol}: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get funding rate: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesFundingRate", + "Get funding rate history for USD-M Futures.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + limit: z.number().int().optional().describe("Number of results. Default 100, max 1000"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.fundingRate({ + symbol: params.symbol, + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Funding Rate History for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get funding rate: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/market-api/globalLongShortAccountRatio.ts b/src/tools/binance-futures-usdm/market-api/globalLongShortAccountRatio.ts index 333c9836..dbbd4c25 100644 --- a/src/tools/binance-futures-usdm/market-api/globalLongShortAccountRatio.ts +++ b/src/tools/binance-futures-usdm/market-api/globalLongShortAccountRatio.ts @@ -5,44 +5,62 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/globalLongShortAccountRatio.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesGlobalLongShortAccountRatio(server: McpServer) { - server.tool( - "BinanceFuturesGlobalLongShortAccountRatio", - "Get global long/short account ratio for USD-M Futures.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - period: z.enum(["5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d"]).describe("Data period"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z.number().int().max(500).optional().describe("Number of records. Default 30, max 500") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.globalLongShortAccountRatio({ - symbol: params.symbol, - period: params.period, - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Global long/short account ratio for ${params.symbol} (${params.period}): ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get global long/short account ratio: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesGlobalLongShortAccountRatio", + "Get global long/short account ratio for USD-M Futures.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + period: z + .enum(["5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d"]) + .describe("Data period"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(500) + .optional() + .describe("Number of records. Default 30, max 500"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.globalLongShortAccountRatio({ + symbol: params.symbol, + period: params.period, + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Global long/short account ratio for ${params.symbol} (${params.period}): ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `Failed to get global long/short account ratio: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/market-api/historicalTrades.ts b/src/tools/binance-futures-usdm/market-api/historicalTrades.ts index bde5868d..30a46efa 100644 --- a/src/tools/binance-futures-usdm/market-api/historicalTrades.ts +++ b/src/tools/binance-futures-usdm/market-api/historicalTrades.ts @@ -5,40 +5,46 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/historicalTrades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesHistoricalTrades(server: McpServer) { - server.tool( - "BinanceFuturesHistoricalTrades", - "Get older trades for a USD-M Futures symbol.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - limit: z.number().int().optional().describe("Number of trades. Default 500, max 1000"), - fromId: z.number().int().optional().describe("Trade ID to start from") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.historicalTrades({ - symbol: params.symbol, - ...(params.limit && { limit: params.limit }), - ...(params.fromId !== undefined && { fromId: params.fromId }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Historical Futures Trades for ${params.symbol}: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get historical trades: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesHistoricalTrades", + "Get older trades for a USD-M Futures symbol.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + limit: z.number().int().optional().describe("Number of trades. Default 500, max 1000"), + fromId: z.number().int().optional().describe("Trade ID to start from"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.historicalTrades({ + symbol: params.symbol, + ...(params.limit && { limit: params.limit }), + ...(params.fromId !== undefined && { fromId: params.fromId }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Historical Futures Trades for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get historical trades: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/market-api/index.ts b/src/tools/binance-futures-usdm/market-api/index.ts index cc62faee..efd2f2e7 100644 --- a/src/tools/binance-futures-usdm/market-api/index.ts +++ b/src/tools/binance-futures-usdm/market-api/index.ts @@ -5,72 +5,73 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceFuturesPing } from "./ping.js"; -import { registerBinanceFuturesTime } from "./time.js"; -import { registerBinanceFuturesExchangeInfo } from "./exchangeInfo.js"; -import { registerBinanceFuturesDepth } from "./depth.js"; -import { registerBinanceFuturesTrades } from "./trades.js"; -import { registerBinanceFuturesHistoricalTrades } from "./historicalTrades.js"; -import { registerBinanceFuturesAggTrades } from "./aggTrades.js"; -import { registerBinanceFuturesKlines } from "./klines.js"; -import { registerBinanceFuturesContinuousKlines } from "./continuousKlines.js"; -import { registerBinanceFuturesIndexPriceKlines } from "./indexPriceKlines.js"; -import { registerBinanceFuturesMarkPriceKlines } from "./markPriceKlines.js"; -import { registerBinanceFuturesPremiumIndex } from "./premiumIndex.js"; -import { registerBinanceFuturesFundingRate } from "./fundingRate.js"; -import { registerBinanceFuturesFundingInfo } from "./fundingInfo.js"; -import { registerBinanceFuturesTicker24hr } from "./ticker24hr.js"; -import { registerBinanceFuturesTickerPrice } from "./tickerPrice.js"; -import { registerBinanceFuturesTickerBookTicker } from "./tickerBookTicker.js"; -import { registerBinanceFuturesOpenInterest } from "./openInterest.js"; -import { registerBinanceFuturesOpenInterestHist } from "./openInterestHist.js"; -import { registerBinanceFuturesTopLongShortAccountRatio } from "./topLongShortAccountRatio.js"; -import { registerBinanceFuturesTopLongShortPositionRatio } from "./topLongShortPositionRatio.js"; -import { registerBinanceFuturesGlobalLongShortAccountRatio } from "./globalLongShortAccountRatio.js"; -import { registerBinanceFuturesTakerLongShortRatio } from "./takerLongShortRatio.js"; -import { registerBinanceFuturesLvtKlines } from "./lvtKlines.js"; -import { registerBinanceFuturesIndexInfo } from "./indexInfo.js"; -import { registerBinanceFuturesAssetIndex } from "./assetIndex.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceFuturesAggTrades } from "./aggTrades.js" +import { registerBinanceFuturesAssetIndex } from "./assetIndex.js" +import { registerBinanceFuturesContinuousKlines } from "./continuousKlines.js" +import { registerBinanceFuturesDepth } from "./depth.js" +import { registerBinanceFuturesExchangeInfo } from "./exchangeInfo.js" +import { registerBinanceFuturesFundingInfo } from "./fundingInfo.js" +import { registerBinanceFuturesFundingRate } from "./fundingRate.js" +import { registerBinanceFuturesGlobalLongShortAccountRatio } from "./globalLongShortAccountRatio.js" +import { registerBinanceFuturesHistoricalTrades } from "./historicalTrades.js" +import { registerBinanceFuturesIndexInfo } from "./indexInfo.js" +import { registerBinanceFuturesIndexPriceKlines } from "./indexPriceKlines.js" +import { registerBinanceFuturesKlines } from "./klines.js" +import { registerBinanceFuturesLvtKlines } from "./lvtKlines.js" +import { registerBinanceFuturesMarkPriceKlines } from "./markPriceKlines.js" +import { registerBinanceFuturesOpenInterest } from "./openInterest.js" +import { registerBinanceFuturesOpenInterestHist } from "./openInterestHist.js" +import { registerBinanceFuturesPing } from "./ping.js" +import { registerBinanceFuturesPremiumIndex } from "./premiumIndex.js" +import { registerBinanceFuturesTakerLongShortRatio } from "./takerLongShortRatio.js" +import { registerBinanceFuturesTicker24hr } from "./ticker24hr.js" +import { registerBinanceFuturesTickerBookTicker } from "./tickerBookTicker.js" +import { registerBinanceFuturesTickerPrice } from "./tickerPrice.js" +import { registerBinanceFuturesTime } from "./time.js" +import { registerBinanceFuturesTopLongShortAccountRatio } from "./topLongShortAccountRatio.js" +import { registerBinanceFuturesTopLongShortPositionRatio } from "./topLongShortPositionRatio.js" +import { registerBinanceFuturesTrades } from "./trades.js" export function registerBinanceFuturesMarketApiTools(server: McpServer) { - // General - registerBinanceFuturesPing(server); - registerBinanceFuturesTime(server); - registerBinanceFuturesExchangeInfo(server); - - // Market Data - registerBinanceFuturesDepth(server); - registerBinanceFuturesTrades(server); - registerBinanceFuturesHistoricalTrades(server); - registerBinanceFuturesAggTrades(server); - - // Klines - registerBinanceFuturesKlines(server); - registerBinanceFuturesContinuousKlines(server); - registerBinanceFuturesIndexPriceKlines(server); - registerBinanceFuturesMarkPriceKlines(server); - - // Funding & Premium - registerBinanceFuturesPremiumIndex(server); - registerBinanceFuturesFundingRate(server); - registerBinanceFuturesFundingInfo(server); - - // Ticker - registerBinanceFuturesTicker24hr(server); - registerBinanceFuturesTickerPrice(server); - registerBinanceFuturesTickerBookTicker(server); - - // Open Interest & Analytics - registerBinanceFuturesOpenInterest(server); - registerBinanceFuturesOpenInterestHist(server); - registerBinanceFuturesTopLongShortAccountRatio(server); - registerBinanceFuturesTopLongShortPositionRatio(server); - registerBinanceFuturesGlobalLongShortAccountRatio(server); - registerBinanceFuturesTakerLongShortRatio(server); - - // Index - registerBinanceFuturesLvtKlines(server); - registerBinanceFuturesIndexInfo(server); - registerBinanceFuturesAssetIndex(server); + // General + registerBinanceFuturesPing(server) + registerBinanceFuturesTime(server) + registerBinanceFuturesExchangeInfo(server) + + // Market Data + registerBinanceFuturesDepth(server) + registerBinanceFuturesTrades(server) + registerBinanceFuturesHistoricalTrades(server) + registerBinanceFuturesAggTrades(server) + + // Klines + registerBinanceFuturesKlines(server) + registerBinanceFuturesContinuousKlines(server) + registerBinanceFuturesIndexPriceKlines(server) + registerBinanceFuturesMarkPriceKlines(server) + + // Funding & Premium + registerBinanceFuturesPremiumIndex(server) + registerBinanceFuturesFundingRate(server) + registerBinanceFuturesFundingInfo(server) + + // Ticker + registerBinanceFuturesTicker24hr(server) + registerBinanceFuturesTickerPrice(server) + registerBinanceFuturesTickerBookTicker(server) + + // Open Interest & Analytics + registerBinanceFuturesOpenInterest(server) + registerBinanceFuturesOpenInterestHist(server) + registerBinanceFuturesTopLongShortAccountRatio(server) + registerBinanceFuturesTopLongShortPositionRatio(server) + registerBinanceFuturesGlobalLongShortAccountRatio(server) + registerBinanceFuturesTakerLongShortRatio(server) + + // Index + registerBinanceFuturesLvtKlines(server) + registerBinanceFuturesIndexInfo(server) + registerBinanceFuturesAssetIndex(server) } diff --git a/src/tools/binance-futures-usdm/market-api/indexInfo.ts b/src/tools/binance-futures-usdm/market-api/indexInfo.ts index adbc2ee7..525de1d8 100644 --- a/src/tools/binance-futures-usdm/market-api/indexInfo.ts +++ b/src/tools/binance-futures-usdm/market-api/indexInfo.ts @@ -5,36 +5,42 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/indexInfo.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesIndexInfo(server: McpServer) { - server.tool( - "BinanceFuturesIndexInfo", - "Get composite index symbol information for USD-M Futures.", - { - symbol: z.string().optional().describe("Composite index symbol (e.g., DEFIUSDT)") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.indexInfo({ - ...(params.symbol && { symbol: params.symbol }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Index info${params.symbol ? ` for ${params.symbol}` : ''}: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get index info: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesIndexInfo", + "Get composite index symbol information for USD-M Futures.", + { + symbol: z.string().optional().describe("Composite index symbol (e.g., DEFIUSDT)"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.indexInfo({ + ...(params.symbol && { symbol: params.symbol }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Index info${params.symbol ? ` for ${params.symbol}` : ""}: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get index info: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/market-api/indexPriceKlines.ts b/src/tools/binance-futures-usdm/market-api/indexPriceKlines.ts index a24ee7eb..cb8db583 100644 --- a/src/tools/binance-futures-usdm/market-api/indexPriceKlines.ts +++ b/src/tools/binance-futures-usdm/market-api/indexPriceKlines.ts @@ -5,48 +5,68 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/indexPriceKlines.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesIndexPriceKlines(server: McpServer) { - server.tool( - "BinanceFuturesIndexPriceKlines", - "Get index price kline data for USD-M Futures.", - { - pair: z.string().describe("Underlying pair (e.g., BTCUSDT)"), - interval: z.enum([ - "1m", "3m", "5m", "15m", "30m", - "1h", "2h", "4h", "6h", "8h", "12h", - "1d", "3d", "1w", "1M" - ]).describe("Kline interval"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - limit: z.number().int().optional().describe("Number of klines. Default 500, max 1500") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.indexPriceKlines({ - pair: params.pair, - interval: params.interval, - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Index Price Klines for ${params.pair}: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get index price klines: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesIndexPriceKlines", + "Get index price kline data for USD-M Futures.", + { + pair: z.string().describe("Underlying pair (e.g., BTCUSDT)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + limit: z.number().int().optional().describe("Number of klines. Default 500, max 1500"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.indexPriceKlines({ + pair: params.pair, + interval: params.interval, + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Index Price Klines for ${params.pair}: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get index price klines: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/market-api/klines.ts b/src/tools/binance-futures-usdm/market-api/klines.ts index c3bdf693..d5360b4f 100644 --- a/src/tools/binance-futures-usdm/market-api/klines.ts +++ b/src/tools/binance-futures-usdm/market-api/klines.ts @@ -5,48 +5,68 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/klines.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesKlines(server: McpServer) { - server.tool( - "BinanceFuturesKlines", - "Get kline/candlestick data for a USD-M Futures symbol.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - interval: z.enum([ - "1m", "3m", "5m", "15m", "30m", - "1h", "2h", "4h", "6h", "8h", "12h", - "1d", "3d", "1w", "1M" - ]).describe("Kline interval"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - limit: z.number().int().optional().describe("Number of klines. Default 500, max 1500") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.klines({ - symbol: params.symbol, - interval: params.interval, - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Klines for ${params.symbol} (${params.interval}): ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get klines: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesKlines", + "Get kline/candlestick data for a USD-M Futures symbol.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + limit: z.number().int().optional().describe("Number of klines. Default 500, max 1500"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.klines({ + symbol: params.symbol, + interval: params.interval, + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Klines for ${params.symbol} (${params.interval}): ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get klines: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/market-api/lvtKlines.ts b/src/tools/binance-futures-usdm/market-api/lvtKlines.ts index ecd9648b..3c17df75 100644 --- a/src/tools/binance-futures-usdm/market-api/lvtKlines.ts +++ b/src/tools/binance-futures-usdm/market-api/lvtKlines.ts @@ -5,48 +5,73 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/lvtKlines.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesLvtKlines(server: McpServer) { - server.tool( - "BinanceFuturesLvtKlines", - "Get historical BLVT NAV Kline/candlestick data.", - { - symbol: z.string().describe("BLVT symbol (e.g., BTCDOWN, BTCUP)"), - interval: z.enum([ - "1m", "3m", "5m", "15m", "30m", - "1h", "2h", "4h", "6h", "8h", "12h", - "1d", "3d", "1w", "1M" - ]).describe("Kline interval"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z.number().int().max(1000).optional().describe("Number of klines. Default 500, max 1000") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.lvtKlines({ - symbol: params.symbol, - interval: params.interval, - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `LVT klines for ${params.symbol} (${params.interval}): ${Array.isArray(data) ? data.length : 0} candles. ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get LVT klines: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesLvtKlines", + "Get historical BLVT NAV Kline/candlestick data.", + { + symbol: z.string().describe("BLVT symbol (e.g., BTCDOWN, BTCUP)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(1000) + .optional() + .describe("Number of klines. Default 500, max 1000"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.lvtKlines({ + symbol: params.symbol, + interval: params.interval, + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `LVT klines for ${params.symbol} (${params.interval}): ${Array.isArray(data) ? data.length : 0} candles. ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get LVT klines: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/market-api/markPriceKlines.ts b/src/tools/binance-futures-usdm/market-api/markPriceKlines.ts index cb7af184..3c73a3ed 100644 --- a/src/tools/binance-futures-usdm/market-api/markPriceKlines.ts +++ b/src/tools/binance-futures-usdm/market-api/markPriceKlines.ts @@ -5,48 +5,68 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/markPriceKlines.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesMarkPriceKlines(server: McpServer) { - server.tool( - "BinanceFuturesMarkPriceKlines", - "Get mark price kline data for USD-M Futures.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - interval: z.enum([ - "1m", "3m", "5m", "15m", "30m", - "1h", "2h", "4h", "6h", "8h", "12h", - "1d", "3d", "1w", "1M" - ]).describe("Kline interval"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - limit: z.number().int().optional().describe("Number of klines. Default 500, max 1500") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.markPriceKlines({ - symbol: params.symbol, - interval: params.interval, - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Mark Price Klines for ${params.symbol}: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get mark price klines: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesMarkPriceKlines", + "Get mark price kline data for USD-M Futures.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + limit: z.number().int().optional().describe("Number of klines. Default 500, max 1500"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.markPriceKlines({ + symbol: params.symbol, + interval: params.interval, + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Mark Price Klines for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get mark price klines: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/market-api/openInterest.ts b/src/tools/binance-futures-usdm/market-api/openInterest.ts index 5487cb41..0cfcb290 100644 --- a/src/tools/binance-futures-usdm/market-api/openInterest.ts +++ b/src/tools/binance-futures-usdm/market-api/openInterest.ts @@ -5,36 +5,42 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/openInterest.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesOpenInterest(server: McpServer) { - server.tool( - "BinanceFuturesOpenInterest", - "Get current open interest for USD-M Futures symbol.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.openInterest({ - symbol: params.symbol - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Open interest for ${params.symbol}: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get open interest: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesOpenInterest", + "Get current open interest for USD-M Futures symbol.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.openInterest({ + symbol: params.symbol, + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Open interest for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get open interest: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/market-api/openInterestHist.ts b/src/tools/binance-futures-usdm/market-api/openInterestHist.ts index a93b42ed..060e1494 100644 --- a/src/tools/binance-futures-usdm/market-api/openInterestHist.ts +++ b/src/tools/binance-futures-usdm/market-api/openInterestHist.ts @@ -5,44 +5,57 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/openInterestHist.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesOpenInterestHist(server: McpServer) { - server.tool( - "BinanceFuturesOpenInterestHist", - "Get historical open interest statistics for USD-M Futures.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - period: z.enum(["5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d"]).describe("Data period"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z.number().int().max(500).optional().describe("Number of records. Default 30, max 500") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.openInterestHist({ - symbol: params.symbol, - period: params.period, - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Historical open interest for ${params.symbol} (${params.period}): ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get open interest history: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesOpenInterestHist", + "Get historical open interest statistics for USD-M Futures.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + period: z + .enum(["5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d"]) + .describe("Data period"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(500) + .optional() + .describe("Number of records. Default 30, max 500"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.openInterestHist({ + symbol: params.symbol, + period: params.period, + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Historical open interest for ${params.symbol} (${params.period}): ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get open interest history: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/market-api/ping.ts b/src/tools/binance-futures-usdm/market-api/ping.ts index 156afc7e..8f38b054 100644 --- a/src/tools/binance-futures-usdm/market-api/ping.ts +++ b/src/tools/binance-futures-usdm/market-api/ping.ts @@ -5,31 +5,36 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/ping.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesPing(server: McpServer) { - server.tool( - "BinanceFuturesPing", - "Test connectivity to the USD-M Futures REST API.", - {}, - async () => { - try { - const response = await futuresClient.restAPI.ping(); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Futures API connection successful: ${JSON.stringify(data)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Futures ping failed: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesPing", + "Test connectivity to the USD-M Futures REST API.", + {}, + async () => { + try { + const response = await futuresClient.restAPI.ping() + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Futures API connection successful: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Futures ping failed: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/market-api/premiumIndex.ts b/src/tools/binance-futures-usdm/market-api/premiumIndex.ts index bfec6054..ac98aa99 100644 --- a/src/tools/binance-futures-usdm/market-api/premiumIndex.ts +++ b/src/tools/binance-futures-usdm/market-api/premiumIndex.ts @@ -5,36 +5,45 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/premiumIndex.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesPremiumIndex(server: McpServer) { - server.tool( - "BinanceFuturesPremiumIndex", - "Get mark price and funding rate for USD-M Futures symbols.", - { - symbol: z.string().optional().describe("Futures symbol (e.g., BTCUSDT). If omitted, returns all symbols") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.premiumIndex({ - ...(params.symbol && { symbol: params.symbol }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Premium Index: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get premium index: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesPremiumIndex", + "Get mark price and funding rate for USD-M Futures symbols.", + { + symbol: z + .string() + .optional() + .describe("Futures symbol (e.g., BTCUSDT). If omitted, returns all symbols"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.premiumIndex({ + ...(params.symbol && { symbol: params.symbol }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Premium Index: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get premium index: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/market-api/takerLongShortRatio.ts b/src/tools/binance-futures-usdm/market-api/takerLongShortRatio.ts index cbbc5139..c14f0b0f 100644 --- a/src/tools/binance-futures-usdm/market-api/takerLongShortRatio.ts +++ b/src/tools/binance-futures-usdm/market-api/takerLongShortRatio.ts @@ -5,44 +5,59 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/takerLongShortRatio.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesTakerLongShortRatio(server: McpServer) { - server.tool( - "BinanceFuturesTakerLongShortRatio", - "Get taker long/short ratio (buy/sell volume) for USD-M Futures.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - period: z.enum(["5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d"]).describe("Data period"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z.number().int().max(500).optional().describe("Number of records. Default 30, max 500") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.takerlongshortRatio({ - symbol: params.symbol, - period: params.period, - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Taker long/short ratio for ${params.symbol} (${params.period}): ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get taker long/short ratio: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesTakerLongShortRatio", + "Get taker long/short ratio (buy/sell volume) for USD-M Futures.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + period: z + .enum(["5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d"]) + .describe("Data period"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(500) + .optional() + .describe("Number of records. Default 30, max 500"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.takerlongshortRatio({ + symbol: params.symbol, + period: params.period, + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Taker long/short ratio for ${params.symbol} (${params.period}): ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to get taker long/short ratio: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/market-api/ticker24hr.ts b/src/tools/binance-futures-usdm/market-api/ticker24hr.ts index 518ffa57..0b7e6e30 100644 --- a/src/tools/binance-futures-usdm/market-api/ticker24hr.ts +++ b/src/tools/binance-futures-usdm/market-api/ticker24hr.ts @@ -5,36 +5,42 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/ticker24hr.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesTicker24hr(server: McpServer) { - server.tool( - "BinanceFuturesTicker24hr", - "Get 24 hour rolling window price change statistics for USD-M Futures.", - { - symbol: z.string().optional().describe("Futures symbol. If omitted, returns all symbols") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.ticker24hr({ - ...(params.symbol && { symbol: params.symbol }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `24hr Ticker: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get 24hr ticker: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesTicker24hr", + "Get 24 hour rolling window price change statistics for USD-M Futures.", + { + symbol: z.string().optional().describe("Futures symbol. If omitted, returns all symbols"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.ticker24hr({ + ...(params.symbol && { symbol: params.symbol }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `24hr Ticker: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get 24hr ticker: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/market-api/tickerBookTicker.ts b/src/tools/binance-futures-usdm/market-api/tickerBookTicker.ts index 8299dc63..1be45af7 100644 --- a/src/tools/binance-futures-usdm/market-api/tickerBookTicker.ts +++ b/src/tools/binance-futures-usdm/market-api/tickerBookTicker.ts @@ -5,36 +5,45 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/tickerBookTicker.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesTickerBookTicker(server: McpServer) { - server.tool( - "BinanceFuturesTickerBookTicker", - "Get best price/qty on the order book for USD-M Futures symbol(s).", - { - symbol: z.string().optional().describe("Futures symbol (e.g., BTCUSDT). If not provided, returns all symbols") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.tickerBookTicker({ - ...(params.symbol && { symbol: params.symbol }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Book ticker${params.symbol ? ` for ${params.symbol}` : ''}: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get book ticker: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesTickerBookTicker", + "Get best price/qty on the order book for USD-M Futures symbol(s).", + { + symbol: z + .string() + .optional() + .describe("Futures symbol (e.g., BTCUSDT). If not provided, returns all symbols"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.tickerBookTicker({ + ...(params.symbol && { symbol: params.symbol }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Book ticker${params.symbol ? ` for ${params.symbol}` : ""}: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get book ticker: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/market-api/tickerPrice.ts b/src/tools/binance-futures-usdm/market-api/tickerPrice.ts index fe03246a..0ef5ec6e 100644 --- a/src/tools/binance-futures-usdm/market-api/tickerPrice.ts +++ b/src/tools/binance-futures-usdm/market-api/tickerPrice.ts @@ -5,36 +5,42 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/tickerPrice.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesTickerPrice(server: McpServer) { - server.tool( - "BinanceFuturesTickerPrice", - "Get latest price for a USD-M Futures symbol or all symbols.", - { - symbol: z.string().optional().describe("Futures symbol. If omitted, returns all symbols") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.tickerPrice({ - ...(params.symbol && { symbol: params.symbol }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Price Ticker: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get price ticker: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesTickerPrice", + "Get latest price for a USD-M Futures symbol or all symbols.", + { + symbol: z.string().optional().describe("Futures symbol. If omitted, returns all symbols"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.tickerPrice({ + ...(params.symbol && { symbol: params.symbol }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Price Ticker: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get price ticker: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/market-api/time.ts b/src/tools/binance-futures-usdm/market-api/time.ts index f17d8748..76b37ab6 100644 --- a/src/tools/binance-futures-usdm/market-api/time.ts +++ b/src/tools/binance-futures-usdm/market-api/time.ts @@ -5,31 +5,31 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/time.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesTime(server: McpServer) { - server.tool( - "BinanceFuturesTime", - "Get current USD-M Futures server time.", - {}, - async () => { - try { - const response = await futuresClient.restAPI.time(); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Futures server time: ${JSON.stringify(data)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get server time: ${errorMessage}` }], - isError: true - }; - } - } - ); + server.tool("BinanceFuturesTime", "Get current USD-M Futures server time.", {}, async () => { + try { + const response = await futuresClient.restAPI.time() + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Futures server time: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get server time: ${errorMessage}` }], + isError: true, + } + } + }) } diff --git a/src/tools/binance-futures-usdm/market-api/topLongShortAccountRatio.ts b/src/tools/binance-futures-usdm/market-api/topLongShortAccountRatio.ts index a13ff67c..85c5b53c 100644 --- a/src/tools/binance-futures-usdm/market-api/topLongShortAccountRatio.ts +++ b/src/tools/binance-futures-usdm/market-api/topLongShortAccountRatio.ts @@ -5,44 +5,59 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/topLongShortAccountRatio.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesTopLongShortAccountRatio(server: McpServer) { - server.tool( - "BinanceFuturesTopLongShortAccountRatio", - "Get top trader long/short account ratio for USD-M Futures.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - period: z.enum(["5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d"]).describe("Data period"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z.number().int().max(500).optional().describe("Number of records. Default 30, max 500") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.topLongShortAccountRatio({ - symbol: params.symbol, - period: params.period, - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Top traders long/short account ratio for ${params.symbol} (${params.period}): ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get top long/short account ratio: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesTopLongShortAccountRatio", + "Get top trader long/short account ratio for USD-M Futures.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + period: z + .enum(["5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d"]) + .describe("Data period"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(500) + .optional() + .describe("Number of records. Default 30, max 500"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.topLongShortAccountRatio({ + symbol: params.symbol, + period: params.period, + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Top traders long/short account ratio for ${params.symbol} (${params.period}): ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to get top long/short account ratio: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/market-api/topLongShortPositionRatio.ts b/src/tools/binance-futures-usdm/market-api/topLongShortPositionRatio.ts index aa919141..1d3a2839 100644 --- a/src/tools/binance-futures-usdm/market-api/topLongShortPositionRatio.ts +++ b/src/tools/binance-futures-usdm/market-api/topLongShortPositionRatio.ts @@ -5,44 +5,59 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/topLongShortPositionRatio.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesTopLongShortPositionRatio(server: McpServer) { - server.tool( - "BinanceFuturesTopLongShortPositionRatio", - "Get top trader long/short position ratio for USD-M Futures.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - period: z.enum(["5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d"]).describe("Data period"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z.number().int().max(500).optional().describe("Number of records. Default 30, max 500") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.topLongShortPositionRatio({ - symbol: params.symbol, - period: params.period, - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Top traders long/short position ratio for ${params.symbol} (${params.period}): ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get top long/short position ratio: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesTopLongShortPositionRatio", + "Get top trader long/short position ratio for USD-M Futures.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + period: z + .enum(["5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d"]) + .describe("Data period"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(500) + .optional() + .describe("Number of records. Default 30, max 500"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.topLongShortPositionRatio({ + symbol: params.symbol, + period: params.period, + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Top traders long/short position ratio for ${params.symbol} (${params.period}): ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to get top long/short position ratio: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/market-api/trades.ts b/src/tools/binance-futures-usdm/market-api/trades.ts index 1e88994a..c83993e7 100644 --- a/src/tools/binance-futures-usdm/market-api/trades.ts +++ b/src/tools/binance-futures-usdm/market-api/trades.ts @@ -5,38 +5,48 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/trades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesTrades(server: McpServer) { - server.tool( - "BinanceFuturesTrades", - "Get recent trades for a USD-M Futures symbol.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - limit: z.number().int().optional().describe("Number of trades to return. Default 500, max 1000") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.trades({ - symbol: params.symbol, - ...(params.limit && { limit: params.limit }) - }); - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Recent Futures Trades for ${params.symbol}: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get trades: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesTrades", + "Get recent trades for a USD-M Futures symbol.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + limit: z + .number() + .int() + .optional() + .describe("Number of trades to return. Default 500, max 1000"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.trades({ + symbol: params.symbol, + ...(params.limit && { limit: params.limit }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Recent Futures Trades for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get trades: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/multiAssetsMode.ts b/src/tools/binance-futures-usdm/multiAssetsMode.ts index 1f8251c0..6efd42e8 100644 --- a/src/tools/binance-futures-usdm/multiAssetsMode.ts +++ b/src/tools/binance-futures-usdm/multiAssetsMode.ts @@ -1,37 +1,46 @@ // src/tools/binance-futures-usdm/multiAssetsMode.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMMultiAssetsMode(server: McpServer) { - server.tool( - "BinanceFuturesUSDMMultiAssetsMode", - "Change multi-assets mode for USD-M Futures.", - { - multiAssetsMargin: z.boolean().describe("true: Enable multi-assets mode, false: Disable multi-assets mode") - }, - async ({ multiAssetsMargin }) => { - try { - const data = await futuresClient.multiAssetsMargin({ multiAssetsMargin: multiAssetsMargin ? "true" : "false" }); - + server.tool( + "BinanceFuturesUSDMMultiAssetsMode", + "Change multi-assets mode for USD-M Futures.", + { + multiAssetsMargin: z + .boolean() + .describe("true: Enable multi-assets mode, false: Disable multi-assets mode"), + }, + async ({ multiAssetsMargin }) => { + try { + const data = await futuresClient.multiAssetsMargin({ + multiAssetsMargin: multiAssetsMargin ? "true" : "false", + }) + + return { + content: [ + { + type: "text", + text: `USD-M Futures multi-assets mode ${multiAssetsMargin ? "enabled" : "disabled"}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `USD-M Futures multi-assets mode ${multiAssetsMargin ? 'enabled' : 'disabled'}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to change USD-M Futures multi-assets mode: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to change USD-M Futures multi-assets mode: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/newOrder.ts b/src/tools/binance-futures-usdm/newOrder.ts index 55d84daa..3ea2ab15 100644 --- a/src/tools/binance-futures-usdm/newOrder.ts +++ b/src/tools/binance-futures-usdm/newOrder.ts @@ -1,72 +1,100 @@ // src/tools/binance-futures-usdm/newOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMNewOrder(server: McpServer) { - server.tool( - "BinanceFuturesUSDMNewOrder", - "Create a new order for USD-M Futures.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Order side"), - type: z.enum(["LIMIT", "MARKET", "STOP", "STOP_MARKET", "TAKE_PROFIT", "TAKE_PROFIT_MARKET", "TRAILING_STOP_MARKET"]).describe("Order type"), - positionSide: z.enum(["BOTH", "LONG", "SHORT"]).optional().describe("Position side. Default BOTH for One-way Mode; LONG or SHORT for Hedge Mode"), - timeInForce: z.enum(["GTC", "IOC", "FOK", "GTX"]).optional().describe("Time in force"), - quantity: z.number().optional().describe("Order quantity"), - reduceOnly: z.boolean().optional().describe("Cannot be sent in Hedge Mode; cannot be sent with closePosition=true"), - price: z.number().optional().describe("Order price"), - newClientOrderId: z.string().optional().describe("Client order ID"), - stopPrice: z.number().optional().describe("Stop price for STOP/STOP_MARKET/TAKE_PROFIT/TAKE_PROFIT_MARKET"), - closePosition: z.boolean().optional().describe("Close all position. Used with STOP_MARKET or TAKE_PROFIT_MARKET"), - activationPrice: z.number().optional().describe("Activation price for TRAILING_STOP_MARKET"), - callbackRate: z.number().optional().describe("Callback rate for TRAILING_STOP_MARKET"), - workingType: z.enum(["MARK_PRICE", "CONTRACT_PRICE"]).optional().describe("StopPrice triggered by MARK_PRICE or CONTRACT_PRICE"), - priceProtect: z.boolean().optional().describe("Price protect"), - newOrderRespType: z.enum(["ACK", "RESULT"]).optional().describe("Response type") - }, - async (params) => { - try { - const requestParams: any = { - symbol: params.symbol, - side: params.side, - type: params.type - }; + server.tool( + "BinanceFuturesUSDMNewOrder", + "Create a new order for USD-M Futures.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Order side"), + type: z + .enum([ + "LIMIT", + "MARKET", + "STOP", + "STOP_MARKET", + "TAKE_PROFIT", + "TAKE_PROFIT_MARKET", + "TRAILING_STOP_MARKET", + ]) + .describe("Order type"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe("Position side. Default BOTH for One-way Mode; LONG or SHORT for Hedge Mode"), + timeInForce: z.enum(["GTC", "IOC", "FOK", "GTX"]).optional().describe("Time in force"), + quantity: z.number().optional().describe("Order quantity"), + reduceOnly: z + .boolean() + .optional() + .describe("Cannot be sent in Hedge Mode; cannot be sent with closePosition=true"), + price: z.number().optional().describe("Order price"), + newClientOrderId: z.string().optional().describe("Client order ID"), + stopPrice: z + .number() + .optional() + .describe("Stop price for STOP/STOP_MARKET/TAKE_PROFIT/TAKE_PROFIT_MARKET"), + closePosition: z + .boolean() + .optional() + .describe("Close all position. Used with STOP_MARKET or TAKE_PROFIT_MARKET"), + activationPrice: z.number().optional().describe("Activation price for TRAILING_STOP_MARKET"), + callbackRate: z.number().optional().describe("Callback rate for TRAILING_STOP_MARKET"), + workingType: z + .enum(["MARK_PRICE", "CONTRACT_PRICE"]) + .optional() + .describe("StopPrice triggered by MARK_PRICE or CONTRACT_PRICE"), + priceProtect: z.boolean().optional().describe("Price protect"), + newOrderRespType: z.enum(["ACK", "RESULT"]).optional().describe("Response type"), + }, + async (params) => { + try { + const requestParams: any = { + symbol: params.symbol, + side: params.side, + type: params.type, + } - if (params.positionSide) requestParams.positionSide = params.positionSide; - if (params.timeInForce) requestParams.timeInForce = params.timeInForce; - if (params.quantity !== undefined) requestParams.quantity = params.quantity; - if (params.reduceOnly !== undefined) requestParams.reduceOnly = params.reduceOnly; - if (params.price !== undefined) requestParams.price = params.price; - if (params.newClientOrderId) requestParams.newClientOrderId = params.newClientOrderId; - if (params.stopPrice !== undefined) requestParams.stopPrice = params.stopPrice; - if (params.closePosition !== undefined) requestParams.closePosition = params.closePosition; - if (params.activationPrice !== undefined) requestParams.activationPrice = params.activationPrice; - if (params.callbackRate !== undefined) requestParams.callbackRate = params.callbackRate; - if (params.workingType) requestParams.workingType = params.workingType; - if (params.priceProtect !== undefined) requestParams.priceProtect = params.priceProtect; - if (params.newOrderRespType) requestParams.newOrderRespType = params.newOrderRespType; + if (params.positionSide) requestParams.positionSide = params.positionSide + if (params.timeInForce) requestParams.timeInForce = params.timeInForce + if (params.quantity !== undefined) requestParams.quantity = params.quantity + if (params.reduceOnly !== undefined) requestParams.reduceOnly = params.reduceOnly + if (params.price !== undefined) requestParams.price = params.price + if (params.newClientOrderId) requestParams.newClientOrderId = params.newClientOrderId + if (params.stopPrice !== undefined) requestParams.stopPrice = params.stopPrice + if (params.closePosition !== undefined) requestParams.closePosition = params.closePosition + if (params.activationPrice !== undefined) + requestParams.activationPrice = params.activationPrice + if (params.callbackRate !== undefined) requestParams.callbackRate = params.callbackRate + if (params.workingType) requestParams.workingType = params.workingType + if (params.priceProtect !== undefined) requestParams.priceProtect = params.priceProtect + if (params.newOrderRespType) requestParams.newOrderRespType = params.newOrderRespType - const data = await futuresClient.newOrder(requestParams); - + const data = await futuresClient.newOrder(requestParams) + + return { + content: [ + { + type: "text", + text: `USD-M Futures order created successfully. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `USD-M Futures order created successfully. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to create USD-M Futures order: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to create USD-M Futures order: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/openInterest.ts b/src/tools/binance-futures-usdm/openInterest.ts index 965a4525..52281b3c 100644 --- a/src/tools/binance-futures-usdm/openInterest.ts +++ b/src/tools/binance-futures-usdm/openInterest.ts @@ -1,37 +1,42 @@ // src/tools/binance-futures-usdm/openInterest.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMOpenInterest(server: McpServer) { - server.tool( - "BinanceFuturesUSDMOpenInterest", - "Get present open interest of a specific symbol for USD-M Futures.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)") - }, - async ({ symbol }) => { - try { - const data = await futuresClient.openInterest({ symbol }); - + server.tool( + "BinanceFuturesUSDMOpenInterest", + "Get present open interest of a specific symbol for USD-M Futures.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, + async ({ symbol }) => { + try { + const data = await futuresClient.openInterest({ symbol }) + + return { + content: [ + { + type: "text", + text: `Retrieved USD-M Futures open interest for ${symbol}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved USD-M Futures open interest for ${symbol}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve USD-M Futures open interest: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve USD-M Futures open interest: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/openOrders.ts b/src/tools/binance-futures-usdm/openOrders.ts index 24a7c882..746d70eb 100644 --- a/src/tools/binance-futures-usdm/openOrders.ts +++ b/src/tools/binance-futures-usdm/openOrders.ts @@ -1,40 +1,47 @@ // src/tools/binance-futures-usdm/openOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMOpenOrders(server: McpServer) { - server.tool( - "BinanceFuturesUSDMOpenOrders", - "Get all current open orders for USD-M Futures.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT). If not provided, returns all open orders") - }, - async ({ symbol }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; + server.tool( + "BinanceFuturesUSDMOpenOrders", + "Get all current open orders for USD-M Futures.", + { + symbol: z + .string() + .optional() + .describe( + "Symbol of the trading pair (e.g., BTCUSDT). If not provided, returns all open orders", + ), + }, + async ({ symbol }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol - const data = await futuresClient.openOrders(params); - + const data = await futuresClient.openOrders(params) + + return { + content: [ + { + type: "text", + text: `Retrieved USD-M Futures open orders${symbol ? ` for ${symbol}` : ""}. Count: ${data.length || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved USD-M Futures open orders${symbol ? ` for ${symbol}` : ''}. Count: ${data.length || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve USD-M Futures open orders: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve USD-M Futures open orders: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/ping.ts b/src/tools/binance-futures-usdm/ping.ts index e6d219a5..c41b23a0 100644 --- a/src/tools/binance-futures-usdm/ping.ts +++ b/src/tools/binance-futures-usdm/ping.ts @@ -1,33 +1,33 @@ // src/tools/binance-futures-usdm/ping.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMPing(server: McpServer) { - server.tool( - "BinanceFuturesUSDMPing", - "Test connectivity to the USD-M Futures REST API.", - {}, - async () => { - try { - const data = await futuresClient.ping(); - - return { - content: [ - { - type: "text", - text: `USD-M Futures API connectivity test successful. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to ping USD-M Futures API: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceFuturesUSDMPing", + "Test connectivity to the USD-M Futures REST API.", + {}, + async () => { + try { + const data = await futuresClient.ping() + + return { + content: [ + { + type: "text", + text: `USD-M Futures API connectivity test successful. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to ping USD-M Futures API: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/positionMargin.ts b/src/tools/binance-futures-usdm/positionMargin.ts index 264aae9a..dd880fab 100644 --- a/src/tools/binance-futures-usdm/positionMargin.ts +++ b/src/tools/binance-futures-usdm/positionMargin.ts @@ -1,43 +1,51 @@ // src/tools/binance-futures-usdm/positionMargin.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMPositionMargin(server: McpServer) { - server.tool( - "BinanceFuturesUSDMPositionMargin", - "Modify isolated position margin for USD-M Futures.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - positionSide: z.enum(["BOTH", "LONG", "SHORT"]).optional().describe("Position side. Default BOTH for One-way Mode"), - amount: z.number().describe("Amount to add or remove"), - type: z.number().describe("1: Add margin, 2: Remove margin") - }, - async ({ symbol, positionSide, amount, type }) => { - try { - const params: any = { symbol, amount, type }; - if (positionSide) params.positionSide = positionSide; + server.tool( + "BinanceFuturesUSDMPositionMargin", + "Modify isolated position margin for USD-M Futures.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe("Position side. Default BOTH for One-way Mode"), + amount: z.number().describe("Amount to add or remove"), + type: z.number().describe("1: Add margin, 2: Remove margin"), + }, + async ({ symbol, positionSide, amount, type }) => { + try { + const params: any = { symbol, amount, type } + if (positionSide) params.positionSide = positionSide - const data = await futuresClient.positionMargin(params); - + const data = await futuresClient.positionMargin(params) + + return { + content: [ + { + type: "text", + text: `USD-M Futures position margin modified for ${symbol}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `USD-M Futures position margin modified for ${symbol}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to modify USD-M Futures position margin: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to modify USD-M Futures position margin: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/positionMode.ts b/src/tools/binance-futures-usdm/positionMode.ts index 9c11c6ae..2f87e446 100644 --- a/src/tools/binance-futures-usdm/positionMode.ts +++ b/src/tools/binance-futures-usdm/positionMode.ts @@ -1,37 +1,41 @@ // src/tools/binance-futures-usdm/positionMode.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMPositionMode(server: McpServer) { - server.tool( - "BinanceFuturesUSDMPositionMode", - "Change position mode for USD-M Futures (One-way or Hedge Mode).", - { - dualSidePosition: z.boolean().describe("true: Hedge Mode, false: One-way Mode") - }, - async ({ dualSidePosition }) => { - try { - const data = await futuresClient.changePositionMode({ dualSidePosition: dualSidePosition ? "true" : "false" }); - + server.tool( + "BinanceFuturesUSDMPositionMode", + "Change position mode for USD-M Futures (One-way or Hedge Mode).", + { + dualSidePosition: z.boolean().describe("true: Hedge Mode, false: One-way Mode"), + }, + async ({ dualSidePosition }) => { + try { + const data = await futuresClient.changePositionMode({ + dualSidePosition: dualSidePosition ? "true" : "false", + }) + + return { + content: [ + { + type: "text", + text: `USD-M Futures position mode changed to ${dualSidePosition ? "Hedge Mode" : "One-way Mode"}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `USD-M Futures position mode changed to ${dualSidePosition ? 'Hedge Mode' : 'One-way Mode'}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to change USD-M Futures position mode: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to change USD-M Futures position mode: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/positionRisk.ts b/src/tools/binance-futures-usdm/positionRisk.ts index 2bede2e2..ee6883a3 100644 --- a/src/tools/binance-futures-usdm/positionRisk.ts +++ b/src/tools/binance-futures-usdm/positionRisk.ts @@ -1,40 +1,50 @@ // src/tools/binance-futures-usdm/positionRisk.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMPositionRisk(server: McpServer) { - server.tool( - "BinanceFuturesUSDMPositionRisk", - "Get current position information for USD-M Futures.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT). If not provided, returns all positions") - }, - async ({ symbol }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; + server.tool( + "BinanceFuturesUSDMPositionRisk", + "Get current position information for USD-M Futures.", + { + symbol: z + .string() + .optional() + .describe( + "Symbol of the trading pair (e.g., BTCUSDT). If not provided, returns all positions", + ), + }, + async ({ symbol }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol - const data = await futuresClient.positionRisk(params); - + const data = await futuresClient.positionRisk(params) + + return { + content: [ + { + type: "text", + text: `Retrieved USD-M Futures position risk${symbol ? ` for ${symbol}` : " for all positions"}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved USD-M Futures position risk${symbol ? ` for ${symbol}` : ' for all positions'}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve USD-M Futures position risk: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve USD-M Futures position risk: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/premiumIndex.ts b/src/tools/binance-futures-usdm/premiumIndex.ts index 4cf1631f..004051f4 100644 --- a/src/tools/binance-futures-usdm/premiumIndex.ts +++ b/src/tools/binance-futures-usdm/premiumIndex.ts @@ -1,40 +1,50 @@ // src/tools/binance-futures-usdm/premiumIndex.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMPremiumIndex(server: McpServer) { - server.tool( - "BinanceFuturesUSDMPremiumIndex", - "Get mark price and funding rate for USD-M Futures.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT). If not provided, returns all symbols") - }, - async ({ symbol }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; + server.tool( + "BinanceFuturesUSDMPremiumIndex", + "Get mark price and funding rate for USD-M Futures.", + { + symbol: z + .string() + .optional() + .describe( + "Symbol of the trading pair (e.g., BTCUSDT). If not provided, returns all symbols", + ), + }, + async ({ symbol }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol - const data = await futuresClient.premiumIndex(params); - + const data = await futuresClient.premiumIndex(params) + + return { + content: [ + { + type: "text", + text: `Retrieved USD-M Futures premium index${symbol ? ` for ${symbol}` : " for all symbols"}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved USD-M Futures premium index${symbol ? ` for ${symbol}` : ' for all symbols'}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve USD-M Futures premium index: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve USD-M Futures premium index: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/ticker24hr.ts b/src/tools/binance-futures-usdm/ticker24hr.ts index c62f104f..a25a6b2b 100644 --- a/src/tools/binance-futures-usdm/ticker24hr.ts +++ b/src/tools/binance-futures-usdm/ticker24hr.ts @@ -1,40 +1,47 @@ // src/tools/binance-futures-usdm/ticker24hr.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMTicker24hr(server: McpServer) { - server.tool( - "BinanceFuturesUSDMTicker24hr", - "Get 24-hour rolling window price change statistics for USD-M Futures.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT). If not provided, returns all symbols") - }, - async ({ symbol }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; + server.tool( + "BinanceFuturesUSDMTicker24hr", + "Get 24-hour rolling window price change statistics for USD-M Futures.", + { + symbol: z + .string() + .optional() + .describe( + "Symbol of the trading pair (e.g., BTCUSDT). If not provided, returns all symbols", + ), + }, + async ({ symbol }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol - const data = await futuresClient.ticker24hr(params); - + const data = await futuresClient.ticker24hr(params) + + return { + content: [ + { + type: "text", + text: `Retrieved USD-M Futures 24hr ticker${symbol ? ` for ${symbol}` : " for all symbols"}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved USD-M Futures 24hr ticker${symbol ? ` for ${symbol}` : ' for all symbols'}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve USD-M Futures 24hr ticker: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve USD-M Futures 24hr ticker: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/tickerPrice.ts b/src/tools/binance-futures-usdm/tickerPrice.ts index d7b9e040..898c990a 100644 --- a/src/tools/binance-futures-usdm/tickerPrice.ts +++ b/src/tools/binance-futures-usdm/tickerPrice.ts @@ -1,40 +1,50 @@ // src/tools/binance-futures-usdm/tickerPrice.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMTickerPrice(server: McpServer) { - server.tool( - "BinanceFuturesUSDMTickerPrice", - "Get latest price for a symbol or symbols for USD-M Futures.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT). If not provided, returns all symbols") - }, - async ({ symbol }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; + server.tool( + "BinanceFuturesUSDMTickerPrice", + "Get latest price for a symbol or symbols for USD-M Futures.", + { + symbol: z + .string() + .optional() + .describe( + "Symbol of the trading pair (e.g., BTCUSDT). If not provided, returns all symbols", + ), + }, + async ({ symbol }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol - const data = await futuresClient.tickerPrice(params); - + const data = await futuresClient.tickerPrice(params) + + return { + content: [ + { + type: "text", + text: `Retrieved USD-M Futures ticker price${symbol ? ` for ${symbol}` : " for all symbols"}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved USD-M Futures ticker price${symbol ? ` for ${symbol}` : ' for all symbols'}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve USD-M Futures ticker price: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve USD-M Futures ticker price: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/time.ts b/src/tools/binance-futures-usdm/time.ts index 1e5290e5..c6c78781 100644 --- a/src/tools/binance-futures-usdm/time.ts +++ b/src/tools/binance-futures-usdm/time.ts @@ -1,33 +1,35 @@ // src/tools/binance-futures-usdm/time.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMTime(server: McpServer) { - server.tool( - "BinanceFuturesUSDMTime", - "Get the current server time from the USD-M Futures API.", - {}, - async () => { - try { - const data = await futuresClient.time(); - - return { - content: [ - { - type: "text", - text: `USD-M Futures server time: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get USD-M Futures server time: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceFuturesUSDMTime", + "Get the current server time from the USD-M Futures API.", + {}, + async () => { + try { + const data = await futuresClient.time() + + return { + content: [ + { + type: "text", + text: `USD-M Futures server time: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to get USD-M Futures server time: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/trade-api/allOrders.ts b/src/tools/binance-futures-usdm/trade-api/allOrders.ts index b9e91723..fdac8a29 100644 --- a/src/tools/binance-futures-usdm/trade-api/allOrders.ts +++ b/src/tools/binance-futures-usdm/trade-api/allOrders.ts @@ -5,53 +5,53 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/allOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesAllOrders(server: McpServer) { - server.tool( - "BinanceFuturesAllOrders", - "Get all account orders (active, canceled, or filled) for a symbol. Returns orders from the last 7 days by default.", - { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), - orderId: z.number().optional().describe("If set, return orders >= this orderId"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Number of results (default 500, max 1000)") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.allOrders( - params.symbol, - { - orderId: params.orderId, - startTime: params.startTime, - endTime: params.endTime, - limit: params.limit - } - ); + server.tool( + "BinanceFuturesAllOrders", + "Get all account orders (active, canceled, or filled) for a symbol. Returns orders from the last 7 days by default.", + { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), + orderId: z.number().optional().describe("If set, return orders >= this orderId"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Number of results (default 500, max 1000)"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.allOrders(params.symbol, { + orderId: params.orderId, + startTime: params.startTime, + endTime: params.endTime, + limit: params.limit, + }) + + return { + content: [ + { + type: "text" as const, + text: JSON.stringify(response.data, null, 2), + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : "Unknown error occurred" - return { - content: [ - { - type: "text" as const, - text: JSON.stringify(response.data, null, 2) - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : "Unknown error occurred"; - return { - content: [ - { - type: "text" as const, - text: `Error getting all orders: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text" as const, + text: `Error getting all orders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/trade-api/batchOrders.ts b/src/tools/binance-futures-usdm/trade-api/batchOrders.ts index f851d2c0..301c73eb 100644 --- a/src/tools/binance-futures-usdm/trade-api/batchOrders.ts +++ b/src/tools/binance-futures-usdm/trade-api/batchOrders.ts @@ -5,69 +5,90 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/batchOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" const orderSchema = z.object({ - symbol: z.string(), - side: z.enum(["BUY", "SELL"]), - positionSide: z.enum(["BOTH", "LONG", "SHORT"]).optional(), - type: z.enum([ - "LIMIT", "MARKET", "STOP", "STOP_MARKET", - "TAKE_PROFIT", "TAKE_PROFIT_MARKET", "TRAILING_STOP_MARKET" - ]), - quantity: z.string().optional(), - price: z.string().optional(), - stopPrice: z.string().optional(), - timeInForce: z.enum(["GTC", "IOC", "FOK", "GTX"]).optional(), - reduceOnly: z.boolean().optional(), - workingType: z.enum(["MARK_PRICE", "CONTRACT_PRICE"]).optional(), - priceProtect: z.boolean().optional(), - newClientOrderId: z.string().optional() -}); + symbol: z.string(), + side: z.enum(["BUY", "SELL"]), + positionSide: z.enum(["BOTH", "LONG", "SHORT"]).optional(), + type: z.enum([ + "LIMIT", + "MARKET", + "STOP", + "STOP_MARKET", + "TAKE_PROFIT", + "TAKE_PROFIT_MARKET", + "TRAILING_STOP_MARKET", + ]), + quantity: z.string().optional(), + price: z.string().optional(), + stopPrice: z.string().optional(), + timeInForce: z.enum(["GTC", "IOC", "FOK", "GTX"]).optional(), + reduceOnly: z.boolean().optional(), + workingType: z.enum(["MARK_PRICE", "CONTRACT_PRICE"]).optional(), + priceProtect: z.boolean().optional(), + newClientOrderId: z.string().optional(), +}) export function registerBinanceFuturesBatchOrders(server: McpServer) { - server.tool( - "BinanceFuturesBatchOrders", - "Place multiple USD-M Futures orders in a batch (max 5 orders). ⚠️ RISK: Futures trading involves leverage and liquidation risk.", - { - batchOrders: z.array(orderSchema).max(5).describe("Array of orders (max 5). Each order has: symbol, side, type, quantity, price, etc."), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.placeMultipleOrders({ - batchOrders: JSON.stringify(params.batchOrders), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - const results = Array.isArray(data) ? data.map((order: any, index: number) => { - if (order.orderId) { - return `Order ${index + 1}: ✅ ${order.symbol} ${order.side} ${order.type} - ID: ${order.orderId}`; - } else { - return `Order ${index + 1}: ❌ Failed - ${order.msg || 'Unknown error'}`; - } - }).join('\n') : 'Unexpected response format'; - - return { - content: [{ - type: "text", - text: `Batch Order Results:\n${results}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to place batch orders: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceFuturesBatchOrders", + "Place multiple USD-M Futures orders in a batch (max 5 orders). ⚠️ RISK: Futures trading involves leverage and liquidation risk.", + { + batchOrders: z + .array(orderSchema) + .max(5) + .describe( + "Array of orders (max 5). Each order has: symbol, side, type, quantity, price, etc.", + ), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.placeMultipleOrders({ + batchOrders: JSON.stringify(params.batchOrders), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + const results = Array.isArray(data) + ? data + .map((order: any, index: number) => { + if (order.orderId) { + return `Order ${index + 1}: ✅ ${order.symbol} ${order.side} ${order.type} - ID: ${order.orderId}` + } else { + return `Order ${index + 1}: ❌ Failed - ${order.msg || "Unknown error"}` + } + }) + .join("\n") + : "Unexpected response format" + + return { + content: [ + { + type: "text", + text: `Batch Order Results:\n${results}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to place batch orders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/trade-api/cancelAllOpenOrders.ts b/src/tools/binance-futures-usdm/trade-api/cancelAllOpenOrders.ts index ef0297a8..2d5c598e 100644 --- a/src/tools/binance-futures-usdm/trade-api/cancelAllOpenOrders.ts +++ b/src/tools/binance-futures-usdm/trade-api/cancelAllOpenOrders.ts @@ -5,41 +5,44 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/cancelAllOpenOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesCancelAllOpenOrders(server: McpServer) { - server.tool( - "BinanceFuturesCancelAllOpenOrders", - "Cancel all open orders for a symbol. Use with caution as this cancels ALL open orders.", - { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.cancelAllOpenOrders(params.symbol); + server.tool( + "BinanceFuturesCancelAllOpenOrders", + "Cancel all open orders for a symbol. Use with caution as this cancels ALL open orders.", + { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.cancelAllOpenOrders(params.symbol) + + return { + content: [ + { + type: "text" as const, + text: JSON.stringify(response.data, null, 2), + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : "Unknown error occurred" - return { - content: [ - { - type: "text" as const, - text: JSON.stringify(response.data, null, 2) - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : "Unknown error occurred"; - return { - content: [ - { - type: "text" as const, - text: `Error canceling all futures orders: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text" as const, + text: `Error canceling all futures orders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/trade-api/cancelAllOrders.ts b/src/tools/binance-futures-usdm/trade-api/cancelAllOrders.ts index 1426b7e5..95fd1200 100644 --- a/src/tools/binance-futures-usdm/trade-api/cancelAllOrders.ts +++ b/src/tools/binance-futures-usdm/trade-api/cancelAllOrders.ts @@ -5,40 +5,45 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/cancelAllOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesCancelAllOrders(server: McpServer) { - server.tool( - "BinanceFuturesCancelAllOrders", - "Cancel all open USD-M Futures orders for a symbol. ⚠️ This will cancel ALL open orders for the specified symbol.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.cancelAllOpenOrders({ - symbol: params.symbol, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ All open orders cancelled for ${params.symbol}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to cancel all orders: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesCancelAllOrders", + "Cancel all open USD-M Futures orders for a symbol. ⚠️ This will cancel ALL open orders for the specified symbol.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.cancelAllOpenOrders({ + symbol: params.symbol, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ All open orders cancelled for ${params.symbol}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to cancel all orders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/trade-api/cancelBatchOrders.ts b/src/tools/binance-futures-usdm/trade-api/cancelBatchOrders.ts index 1bb5885e..4791c76e 100644 --- a/src/tools/binance-futures-usdm/trade-api/cancelBatchOrders.ts +++ b/src/tools/binance-futures-usdm/trade-api/cancelBatchOrders.ts @@ -5,61 +5,85 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/cancelBatchOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesCancelBatchOrders(server: McpServer) { - server.tool( - "BinanceFuturesCancelBatchOrders", - "Cancel multiple USD-M Futures orders in batch (max 10 orders).", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - orderIdList: z.array(z.number().int()).max(10).optional().describe("List of order IDs to cancel (max 10)"), - origClientOrderIdList: z.array(z.string()).max(10).optional().describe("List of client order IDs to cancel (max 10)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - if (!params.orderIdList && !params.origClientOrderIdList) { - return { - content: [{ type: "text", text: "Either orderIdList or origClientOrderIdList must be provided" }], - isError: true - }; + server.tool( + "BinanceFuturesCancelBatchOrders", + "Cancel multiple USD-M Futures orders in batch (max 10 orders).", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + orderIdList: z + .array(z.number().int()) + .max(10) + .optional() + .describe("List of order IDs to cancel (max 10)"), + origClientOrderIdList: z + .array(z.string()) + .max(10) + .optional() + .describe("List of client order IDs to cancel (max 10)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + if (!params.orderIdList && !params.origClientOrderIdList) { + return { + content: [ + { + type: "text", + text: "Either orderIdList or origClientOrderIdList must be provided", + }, + ], + isError: true, + } + } + + const response = await futuresClient.restAPI.cancelMultipleOrders({ + symbol: params.symbol, + ...(params.orderIdList && { orderIdList: JSON.stringify(params.orderIdList) }), + ...(params.origClientOrderIdList && { + origClientOrderIdList: JSON.stringify(params.origClientOrderIdList), + }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + const results = Array.isArray(data) + ? data + .map((order: any, index: number) => { + if (order.orderId && order.status === "CANCELED") { + return `Order ${index + 1}: ✅ Cancelled - ID: ${order.orderId}` + } else if (order.code) { + return `Order ${index + 1}: ❌ Failed - ${order.msg || "Unknown error"}` + } else { + return `Order ${index + 1}: ${order.status} - ID: ${order.orderId}` } - - const response = await futuresClient.restAPI.cancelMultipleOrders({ - symbol: params.symbol, - ...(params.orderIdList && { orderIdList: JSON.stringify(params.orderIdList) }), - ...(params.origClientOrderIdList && { origClientOrderIdList: JSON.stringify(params.origClientOrderIdList) }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - const results = Array.isArray(data) ? data.map((order: any, index: number) => { - if (order.orderId && order.status === 'CANCELED') { - return `Order ${index + 1}: ✅ Cancelled - ID: ${order.orderId}`; - } else if (order.code) { - return `Order ${index + 1}: ❌ Failed - ${order.msg || 'Unknown error'}`; - } else { - return `Order ${index + 1}: ${order.status} - ID: ${order.orderId}`; - } - }).join('\n') : 'Unexpected response format'; - - return { - content: [{ - type: "text", - text: `Batch Cancel Results:\n${results}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to cancel batch orders: ${errorMessage}` }], - isError: true - }; - } + }) + .join("\n") + : "Unexpected response format" + + return { + content: [ + { + type: "text", + text: `Batch Cancel Results:\n${results}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to cancel batch orders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/trade-api/cancelOrder.ts b/src/tools/binance-futures-usdm/trade-api/cancelOrder.ts index 7191da19..345f39ff 100644 --- a/src/tools/binance-futures-usdm/trade-api/cancelOrder.ts +++ b/src/tools/binance-futures-usdm/trade-api/cancelOrder.ts @@ -5,51 +5,58 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/cancelOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesCancelOrder(server: McpServer) { - server.tool( - "BinanceFuturesCancelOrder", - "Cancel a specific USD-M Futures order by orderId or origClientOrderId.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - orderId: z.number().int().optional().describe("Order ID"), - origClientOrderId: z.string().optional().describe("Original client order ID"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - if (!params.orderId && !params.origClientOrderId) { - return { - content: [{ type: "text", text: "Either orderId or origClientOrderId must be provided" }], - isError: true - }; - } - - const response = await futuresClient.restAPI.cancelOrder({ - symbol: params.symbol, - ...(params.orderId && { orderId: params.orderId }), - ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Order cancelled successfully!\n\nSymbol: ${data.symbol}\nOrder ID: ${data.orderId}\nClient Order ID: ${data.clientOrderId}\nStatus: ${data.status}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to cancel order: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesCancelOrder", + "Cancel a specific USD-M Futures order by orderId or origClientOrderId.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + orderId: z.number().int().optional().describe("Order ID"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + if (!params.orderId && !params.origClientOrderId) { + return { + content: [ + { type: "text", text: "Either orderId or origClientOrderId must be provided" }, + ], + isError: true, + } + } + + const response = await futuresClient.restAPI.cancelOrder({ + symbol: params.symbol, + ...(params.orderId && { orderId: params.orderId }), + ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Order cancelled successfully!\n\nSymbol: ${data.symbol}\nOrder ID: ${data.orderId}\nClient Order ID: ${data.clientOrderId}\nStatus: ${data.status}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to cancel order: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/trade-api/changeLeverage.ts b/src/tools/binance-futures-usdm/trade-api/changeLeverage.ts index 28b0c255..b2a44e20 100644 --- a/src/tools/binance-futures-usdm/trade-api/changeLeverage.ts +++ b/src/tools/binance-futures-usdm/trade-api/changeLeverage.ts @@ -5,42 +5,52 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/changeLeverage.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesChangeLeverage(server: McpServer) { - server.tool( - "BinanceFuturesChangeLeverage", - "Change the initial leverage for a USD-M Futures symbol. Max leverage depends on notional value tier. ⚠️ Higher leverage increases both profit potential and liquidation risk.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - leverage: z.number().int().min(1).max(125).describe("Target leverage (1-125, actual max depends on symbol)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.changeInitialLeverage({ - symbol: params.symbol, - leverage: params.leverage, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Leverage changed successfully!\n\nSymbol: ${data.symbol}\nNew Leverage: ${data.leverage}x\nMax Notional Value: ${data.maxNotionalValue}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to change leverage: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesChangeLeverage", + "Change the initial leverage for a USD-M Futures symbol. Max leverage depends on notional value tier. ⚠️ Higher leverage increases both profit potential and liquidation risk.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + leverage: z + .number() + .int() + .min(1) + .max(125) + .describe("Target leverage (1-125, actual max depends on symbol)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.changeInitialLeverage({ + symbol: params.symbol, + leverage: params.leverage, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Leverage changed successfully!\n\nSymbol: ${data.symbol}\nNew Leverage: ${data.leverage}x\nMax Notional Value: ${data.maxNotionalValue}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to change leverage: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/trade-api/changeMarginType.ts b/src/tools/binance-futures-usdm/trade-api/changeMarginType.ts index 23878792..6dce1e71 100644 --- a/src/tools/binance-futures-usdm/trade-api/changeMarginType.ts +++ b/src/tools/binance-futures-usdm/trade-api/changeMarginType.ts @@ -5,42 +5,51 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/changeMarginType.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesChangeMarginType(server: McpServer) { - server.tool( - "BinanceFuturesChangeMarginType", - "Change margin type between ISOLATED and CROSSED for a USD-M Futures symbol. ISOLATED: Position uses its own margin. CROSSED: All positions share account margin.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - marginType: z.enum(["ISOLATED", "CROSSED"]).describe("ISOLATED: Separate margin per position. CROSSED: Shared margin across positions"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.changeMarginType({ - symbol: params.symbol, - marginType: params.marginType, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Margin type changed successfully!\n\nSymbol: ${params.symbol}\nNew Margin Type: ${params.marginType}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to change margin type: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesChangeMarginType", + "Change margin type between ISOLATED and CROSSED for a USD-M Futures symbol. ISOLATED: Position uses its own margin. CROSSED: All positions share account margin.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + marginType: z + .enum(["ISOLATED", "CROSSED"]) + .describe( + "ISOLATED: Separate margin per position. CROSSED: Shared margin across positions", + ), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.changeMarginType({ + symbol: params.symbol, + marginType: params.marginType, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Margin type changed successfully!\n\nSymbol: ${params.symbol}\nNew Margin Type: ${params.marginType}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to change margin type: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/trade-api/changeMultiAssetsMode.ts b/src/tools/binance-futures-usdm/trade-api/changeMultiAssetsMode.ts index 48d9242c..63682e8b 100644 --- a/src/tools/binance-futures-usdm/trade-api/changeMultiAssetsMode.ts +++ b/src/tools/binance-futures-usdm/trade-api/changeMultiAssetsMode.ts @@ -5,41 +5,48 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/changeMultiAssetsMode.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesChangeMultiAssetsMode(server: McpServer) { - server.tool( - "BinanceFuturesChangeMultiAssetsMode", - "Change Multi-Assets Mode setting. When enabled, margin from multiple assets (USDT, BUSD) can be used to avoid liquidation.", - { - multiAssetsMargin: z.boolean().describe("true = Enable Multi-Assets Mode, false = Disable"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.changeMultiAssetsMode({ - multiAssetsMargin: params.multiAssetsMargin, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - const mode = params.multiAssetsMargin ? "Enabled" : "Disabled"; - - return { - content: [{ - type: "text", - text: `✅ Multi-Assets Mode ${mode}!\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to change multi-assets mode: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesChangeMultiAssetsMode", + "Change Multi-Assets Mode setting. When enabled, margin from multiple assets (USDT, BUSD) can be used to avoid liquidation.", + { + multiAssetsMargin: z.boolean().describe("true = Enable Multi-Assets Mode, false = Disable"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.changeMultiAssetsMode({ + multiAssetsMargin: params.multiAssetsMargin, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + const mode = params.multiAssetsMargin ? "Enabled" : "Disabled" + + return { + content: [ + { + type: "text", + text: `✅ Multi-Assets Mode ${mode}!\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `❌ Failed to change multi-assets mode: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/trade-api/changePositionMode.ts b/src/tools/binance-futures-usdm/trade-api/changePositionMode.ts index 9e848ee6..0b5216d2 100644 --- a/src/tools/binance-futures-usdm/trade-api/changePositionMode.ts +++ b/src/tools/binance-futures-usdm/trade-api/changePositionMode.ts @@ -5,41 +5,48 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/changePositionMode.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesChangePositionMode(server: McpServer) { - server.tool( - "BinanceFuturesChangePositionMode", - "Change position mode between Hedge Mode and One-way Mode. HEDGE: Can hold both LONG and SHORT positions simultaneously. ONE-WAY: Only one direction at a time (positionSide=BOTH).", - { - dualSidePosition: z.boolean().describe("true = Hedge Mode (Long/Short), false = One-way Mode (BOTH)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.changePositionMode({ - dualSidePosition: params.dualSidePosition, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - const mode = params.dualSidePosition ? "Hedge Mode (LONG/SHORT)" : "One-way Mode (BOTH)"; - - return { - content: [{ - type: "text", - text: `✅ Position mode changed successfully!\n\nNew Mode: ${mode}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to change position mode: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesChangePositionMode", + "Change position mode between Hedge Mode and One-way Mode. HEDGE: Can hold both LONG and SHORT positions simultaneously. ONE-WAY: Only one direction at a time (positionSide=BOTH).", + { + dualSidePosition: z + .boolean() + .describe("true = Hedge Mode (Long/Short), false = One-way Mode (BOTH)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.changePositionMode({ + dualSidePosition: params.dualSidePosition, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + const mode = params.dualSidePosition ? "Hedge Mode (LONG/SHORT)" : "One-way Mode (BOTH)" + + return { + content: [ + { + type: "text", + text: `✅ Position mode changed successfully!\n\nNew Mode: ${mode}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to change position mode: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/trade-api/countdownCancelAll.ts b/src/tools/binance-futures-usdm/trade-api/countdownCancelAll.ts index 2b808e49..5c66378e 100644 --- a/src/tools/binance-futures-usdm/trade-api/countdownCancelAll.ts +++ b/src/tools/binance-futures-usdm/trade-api/countdownCancelAll.ts @@ -5,46 +5,55 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/countdownCancelAll.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesCountdownCancelAll(server: McpServer) { - server.tool( - "BinanceFuturesCountdownCancelAll", - "Set auto-cancel all open orders after countdown. Use as dead man's switch for protection. ⚠️ System will cancel orders automatically if no heartbeat received.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - countdownTime: z.number().int().describe("Countdown time in milliseconds. 0 to cancel the countdown."), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.autoCancelAllOpenOrders({ - symbol: params.symbol, - countdownTime: params.countdownTime, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - const message = params.countdownTime === 0 - ? `✅ Countdown cancelled for ${params.symbol}` - : `✅ Countdown set for ${params.symbol}\nOrders will be cancelled in ${params.countdownTime}ms if no heartbeat received`; - - return { - content: [{ - type: "text", - text: `${message}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to set countdown: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesCountdownCancelAll", + "Set auto-cancel all open orders after countdown. Use as dead man's switch for protection. ⚠️ System will cancel orders automatically if no heartbeat received.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + countdownTime: z + .number() + .int() + .describe("Countdown time in milliseconds. 0 to cancel the countdown."), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.autoCancelAllOpenOrders({ + symbol: params.symbol, + countdownTime: params.countdownTime, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + const message = + params.countdownTime === 0 + ? `✅ Countdown cancelled for ${params.symbol}` + : `✅ Countdown set for ${params.symbol}\nOrders will be cancelled in ${params.countdownTime}ms if no heartbeat received` + + return { + content: [ + { + type: "text", + text: `${message}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to set countdown: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/trade-api/getAllOrders.ts b/src/tools/binance-futures-usdm/trade-api/getAllOrders.ts index 8f53d303..c9b9cf73 100644 --- a/src/tools/binance-futures-usdm/trade-api/getAllOrders.ts +++ b/src/tools/binance-futures-usdm/trade-api/getAllOrders.ts @@ -5,50 +5,60 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/getAllOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesGetAllOrders(server: McpServer) { - server.tool( - "BinanceFuturesGetAllOrders", - "Get all USD-M Futures orders (active, canceled, or filled) for a symbol.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - orderId: z.number().int().optional().describe("If set, get orders >= this orderId"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z.number().int().max(1000).optional().describe("Number of orders. Default 500, max 1000"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.allOrders({ - symbol: params.symbol, - ...(params.orderId && { orderId: params.orderId }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - const orderCount = Array.isArray(data) ? data.length : 0; - - return { - content: [{ - type: "text", - text: `All Orders for ${params.symbol}: ${orderCount} orders\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get all orders: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesGetAllOrders", + "Get all USD-M Futures orders (active, canceled, or filled) for a symbol.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + orderId: z.number().int().optional().describe("If set, get orders >= this orderId"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(1000) + .optional() + .describe("Number of orders. Default 500, max 1000"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.allOrders({ + symbol: params.symbol, + ...(params.orderId && { orderId: params.orderId }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + const orderCount = Array.isArray(data) ? data.length : 0 + + return { + content: [ + { + type: "text", + text: `All Orders for ${params.symbol}: ${orderCount} orders\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get all orders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/trade-api/getOpenOrder.ts b/src/tools/binance-futures-usdm/trade-api/getOpenOrder.ts index dc760258..de88b467 100644 --- a/src/tools/binance-futures-usdm/trade-api/getOpenOrder.ts +++ b/src/tools/binance-futures-usdm/trade-api/getOpenOrder.ts @@ -5,51 +5,58 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/getOpenOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesGetOpenOrder(server: McpServer) { - server.tool( - "BinanceFuturesGetOpenOrder", - "Query a specific open USD-M Futures order by orderId or origClientOrderId.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - orderId: z.number().int().optional().describe("Order ID"), - origClientOrderId: z.string().optional().describe("Original client order ID"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - if (!params.orderId && !params.origClientOrderId) { - return { - content: [{ type: "text", text: "Either orderId or origClientOrderId must be provided" }], - isError: true - }; - } - - const response = await futuresClient.restAPI.queryCurrentOpenOrder({ - symbol: params.symbol, - ...(params.orderId && { orderId: params.orderId }), - ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `Open Order Details:\n\nSymbol: ${data.symbol}\nOrder ID: ${data.orderId}\nClient Order ID: ${data.clientOrderId}\nSide: ${data.side}\nType: ${data.type}\nStatus: ${data.status}\nPrice: ${data.price}\nQty: ${data.origQty}\nExecuted Qty: ${data.executedQty}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query open order: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesGetOpenOrder", + "Query a specific open USD-M Futures order by orderId or origClientOrderId.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + orderId: z.number().int().optional().describe("Order ID"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + if (!params.orderId && !params.origClientOrderId) { + return { + content: [ + { type: "text", text: "Either orderId or origClientOrderId must be provided" }, + ], + isError: true, + } + } + + const response = await futuresClient.restAPI.queryCurrentOpenOrder({ + symbol: params.symbol, + ...(params.orderId && { orderId: params.orderId }), + ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Open Order Details:\n\nSymbol: ${data.symbol}\nOrder ID: ${data.orderId}\nClient Order ID: ${data.clientOrderId}\nSide: ${data.side}\nType: ${data.type}\nStatus: ${data.status}\nPrice: ${data.price}\nQty: ${data.origQty}\nExecuted Qty: ${data.executedQty}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to query open order: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/trade-api/getOpenOrders.ts b/src/tools/binance-futures-usdm/trade-api/getOpenOrders.ts index f11a8680..1058133a 100644 --- a/src/tools/binance-futures-usdm/trade-api/getOpenOrders.ts +++ b/src/tools/binance-futures-usdm/trade-api/getOpenOrders.ts @@ -5,47 +5,59 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/getOpenOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesGetOpenOrders(server: McpServer) { - server.tool( - "BinanceFuturesGetOpenOrders", - "Get all open USD-M Futures orders for a symbol or all symbols.", - { - symbol: z.string().optional().describe("Futures symbol (e.g., BTCUSDT). If not provided, returns all open orders"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.currentAllOpenOrders({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - const orderCount = Array.isArray(data) ? data.length : 0; - const orderSummary = Array.isArray(data) && data.length > 0 - ? data.map((order: any) => - `${order.symbol} ${order.side} ${order.type} ${order.origQty}@${order.price} (ID: ${order.orderId})` - ).join('\n') - : 'No open orders'; - - return { - content: [{ - type: "text", - text: `Open Orders${params.symbol ? ` for ${params.symbol}` : ''}: ${orderCount}\n\n${orderSummary}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get open orders: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesGetOpenOrders", + "Get all open USD-M Futures orders for a symbol or all symbols.", + { + symbol: z + .string() + .optional() + .describe("Futures symbol (e.g., BTCUSDT). If not provided, returns all open orders"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.currentAllOpenOrders({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + const orderCount = Array.isArray(data) ? data.length : 0 + const orderSummary = + Array.isArray(data) && data.length > 0 + ? data + .map( + (order: any) => + `${order.symbol} ${order.side} ${order.type} ${order.origQty}@${order.price} (ID: ${order.orderId})`, + ) + .join("\n") + : "No open orders" + + return { + content: [ + { + type: "text", + text: `Open Orders${params.symbol ? ` for ${params.symbol}` : ""}: ${orderCount}\n\n${orderSummary}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get open orders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/trade-api/getOrder.ts b/src/tools/binance-futures-usdm/trade-api/getOrder.ts index 2e992695..012487b1 100644 --- a/src/tools/binance-futures-usdm/trade-api/getOrder.ts +++ b/src/tools/binance-futures-usdm/trade-api/getOrder.ts @@ -5,51 +5,58 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/getOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesGetOrder(server: McpServer) { - server.tool( - "BinanceFuturesGetOrder", - "Query a specific USD-M Futures order by orderId or origClientOrderId.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - orderId: z.number().int().optional().describe("Order ID"), - origClientOrderId: z.string().optional().describe("Original client order ID"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - if (!params.orderId && !params.origClientOrderId) { - return { - content: [{ type: "text", text: "Either orderId or origClientOrderId must be provided" }], - isError: true - }; - } - - const response = await futuresClient.restAPI.queryOrder({ - symbol: params.symbol, - ...(params.orderId && { orderId: params.orderId }), - ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `Order Details:\n\nSymbol: ${data.symbol}\nOrder ID: ${data.orderId}\nClient Order ID: ${data.clientOrderId}\nSide: ${data.side}\nType: ${data.type}\nStatus: ${data.status}\nPrice: ${data.price}\nQty: ${data.origQty}\nExecuted Qty: ${data.executedQty}\nAvg Price: ${data.avgPrice}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query order: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesGetOrder", + "Query a specific USD-M Futures order by orderId or origClientOrderId.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + orderId: z.number().int().optional().describe("Order ID"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + if (!params.orderId && !params.origClientOrderId) { + return { + content: [ + { type: "text", text: "Either orderId or origClientOrderId must be provided" }, + ], + isError: true, + } + } + + const response = await futuresClient.restAPI.queryOrder({ + symbol: params.symbol, + ...(params.orderId && { orderId: params.orderId }), + ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Order Details:\n\nSymbol: ${data.symbol}\nOrder ID: ${data.orderId}\nClient Order ID: ${data.clientOrderId}\nSide: ${data.side}\nType: ${data.type}\nStatus: ${data.status}\nPrice: ${data.price}\nQty: ${data.origQty}\nExecuted Qty: ${data.executedQty}\nAvg Price: ${data.avgPrice}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to query order: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/trade-api/index.ts b/src/tools/binance-futures-usdm/trade-api/index.ts index d32c5ac1..22095479 100644 --- a/src/tools/binance-futures-usdm/trade-api/index.ts +++ b/src/tools/binance-futures-usdm/trade-api/index.ts @@ -5,50 +5,51 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceFuturesNewOrder } from "./newOrder.js"; -import { registerBinanceFuturesBatchOrders } from "./batchOrders.js"; -import { registerBinanceFuturesGetOrder } from "./getOrder.js"; -import { registerBinanceFuturesCancelOrder } from "./cancelOrder.js"; -import { registerBinanceFuturesCancelAllOrders } from "./cancelAllOrders.js"; -import { registerBinanceFuturesCancelBatchOrders } from "./cancelBatchOrders.js"; -import { registerBinanceFuturesCountdownCancelAll } from "./countdownCancelAll.js"; -import { registerBinanceFuturesGetOpenOrder } from "./getOpenOrder.js"; -import { registerBinanceFuturesGetOpenOrders } from "./getOpenOrders.js"; -import { registerBinanceFuturesGetAllOrders } from "./getAllOrders.js"; -import { registerBinanceFuturesModifyOrder } from "./modifyOrder.js"; -import { registerBinanceFuturesChangeLeverage } from "./changeLeverage.js"; -import { registerBinanceFuturesChangeMarginType } from "./changeMarginType.js"; -import { registerBinanceFuturesModifyIsolatedPositionMargin } from "./modifyIsolatedPositionMargin.js"; -import { registerBinanceFuturesPositionMarginHistory } from "./positionMarginHistory.js"; -import { registerBinanceFuturesChangePositionMode } from "./changePositionMode.js"; -import { registerBinanceFuturesChangeMultiAssetsMode } from "./changeMultiAssetsMode.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceFuturesBatchOrders } from "./batchOrders.js" +import { registerBinanceFuturesCancelAllOrders } from "./cancelAllOrders.js" +import { registerBinanceFuturesCancelBatchOrders } from "./cancelBatchOrders.js" +import { registerBinanceFuturesCancelOrder } from "./cancelOrder.js" +import { registerBinanceFuturesChangeLeverage } from "./changeLeverage.js" +import { registerBinanceFuturesChangeMarginType } from "./changeMarginType.js" +import { registerBinanceFuturesChangeMultiAssetsMode } from "./changeMultiAssetsMode.js" +import { registerBinanceFuturesChangePositionMode } from "./changePositionMode.js" +import { registerBinanceFuturesCountdownCancelAll } from "./countdownCancelAll.js" +import { registerBinanceFuturesGetAllOrders } from "./getAllOrders.js" +import { registerBinanceFuturesGetOpenOrder } from "./getOpenOrder.js" +import { registerBinanceFuturesGetOpenOrders } from "./getOpenOrders.js" +import { registerBinanceFuturesGetOrder } from "./getOrder.js" +import { registerBinanceFuturesModifyIsolatedPositionMargin } from "./modifyIsolatedPositionMargin.js" +import { registerBinanceFuturesModifyOrder } from "./modifyOrder.js" +import { registerBinanceFuturesNewOrder } from "./newOrder.js" +import { registerBinanceFuturesPositionMarginHistory } from "./positionMarginHistory.js" export function registerBinanceFuturesTradeApiTools(server: McpServer) { - // Order Placement - registerBinanceFuturesNewOrder(server); - registerBinanceFuturesBatchOrders(server); - registerBinanceFuturesModifyOrder(server); - - // Order Query - registerBinanceFuturesGetOrder(server); - registerBinanceFuturesGetOpenOrder(server); - registerBinanceFuturesGetOpenOrders(server); - registerBinanceFuturesGetAllOrders(server); - - // Order Cancellation - registerBinanceFuturesCancelOrder(server); - registerBinanceFuturesCancelAllOrders(server); - registerBinanceFuturesCancelBatchOrders(server); - registerBinanceFuturesCountdownCancelAll(server); - - // Leverage & Margin - registerBinanceFuturesChangeLeverage(server); - registerBinanceFuturesChangeMarginType(server); - registerBinanceFuturesModifyIsolatedPositionMargin(server); - registerBinanceFuturesPositionMarginHistory(server); - - // Position & Asset Modes - registerBinanceFuturesChangePositionMode(server); - registerBinanceFuturesChangeMultiAssetsMode(server); + // Order Placement + registerBinanceFuturesNewOrder(server) + registerBinanceFuturesBatchOrders(server) + registerBinanceFuturesModifyOrder(server) + + // Order Query + registerBinanceFuturesGetOrder(server) + registerBinanceFuturesGetOpenOrder(server) + registerBinanceFuturesGetOpenOrders(server) + registerBinanceFuturesGetAllOrders(server) + + // Order Cancellation + registerBinanceFuturesCancelOrder(server) + registerBinanceFuturesCancelAllOrders(server) + registerBinanceFuturesCancelBatchOrders(server) + registerBinanceFuturesCountdownCancelAll(server) + + // Leverage & Margin + registerBinanceFuturesChangeLeverage(server) + registerBinanceFuturesChangeMarginType(server) + registerBinanceFuturesModifyIsolatedPositionMargin(server) + registerBinanceFuturesPositionMarginHistory(server) + + // Position & Asset Modes + registerBinanceFuturesChangePositionMode(server) + registerBinanceFuturesChangeMultiAssetsMode(server) } diff --git a/src/tools/binance-futures-usdm/trade-api/modifyIsolatedPositionMargin.ts b/src/tools/binance-futures-usdm/trade-api/modifyIsolatedPositionMargin.ts index 32bef2de..f141525d 100644 --- a/src/tools/binance-futures-usdm/trade-api/modifyIsolatedPositionMargin.ts +++ b/src/tools/binance-futures-usdm/trade-api/modifyIsolatedPositionMargin.ts @@ -5,47 +5,57 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/modifyIsolatedPositionMargin.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesModifyIsolatedPositionMargin(server: McpServer) { - server.tool( - "BinanceFuturesModifyIsolatedPositionMargin", - "Add or reduce margin to/from an isolated margin position. Only works when margin type is ISOLATED.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - amount: z.string().describe("Amount of margin to add or reduce"), - type: z.enum(["1", "2"]).describe("1 = Add margin, 2 = Reduce margin"), - positionSide: z.enum(["BOTH", "LONG", "SHORT"]).optional().describe("Position side for Hedge Mode (default BOTH)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.modifyIsolatedPositionMargin({ - symbol: params.symbol, - amount: params.amount, - type: parseInt(params.type) as 1 | 2, - ...(params.positionSide && { positionSide: params.positionSide }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - const action = params.type === "1" ? "added to" : "reduced from"; - - return { - content: [{ - type: "text", - text: `✅ Margin ${action} position successfully!\n\nSymbol: ${params.symbol}\nAmount: ${params.amount}\nAction: ${params.type === "1" ? "Add" : "Reduce"}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to modify isolated position margin: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesModifyIsolatedPositionMargin", + "Add or reduce margin to/from an isolated margin position. Only works when margin type is ISOLATED.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + amount: z.string().describe("Amount of margin to add or reduce"), + type: z.enum(["1", "2"]).describe("1 = Add margin, 2 = Reduce margin"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe("Position side for Hedge Mode (default BOTH)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.modifyIsolatedPositionMargin({ + symbol: params.symbol, + amount: params.amount, + type: parseInt(params.type) as 1 | 2, + ...(params.positionSide && { positionSide: params.positionSide }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + const action = params.type === "1" ? "added to" : "reduced from" + + return { + content: [ + { + type: "text", + text: `✅ Margin ${action} position successfully!\n\nSymbol: ${params.symbol}\nAmount: ${params.amount}\nAction: ${params.type === "1" ? "Add" : "Reduce"}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `❌ Failed to modify isolated position margin: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/trade-api/modifyOrder.ts b/src/tools/binance-futures-usdm/trade-api/modifyOrder.ts index de7c2641..45df2768 100644 --- a/src/tools/binance-futures-usdm/trade-api/modifyOrder.ts +++ b/src/tools/binance-futures-usdm/trade-api/modifyOrder.ts @@ -5,59 +5,78 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/modifyOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesModifyOrder(server: McpServer) { - server.tool( - "BinanceFuturesModifyOrder", - "Modify an existing USD-M Futures order. Can modify price, quantity, or both.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - orderId: z.number().int().optional().describe("Order ID"), - origClientOrderId: z.string().optional().describe("Original client order ID"), - side: z.enum(["BUY", "SELL"]).describe("Order side"), - quantity: z.string().optional().describe("New quantity"), - price: z.string().optional().describe("New price"), - priceMatch: z.enum(["OPPONENT", "OPPONENT_5", "OPPONENT_10", "OPPONENT_20", "QUEUE", "QUEUE_5", "QUEUE_10", "QUEUE_20"]).optional().describe("Price match mode"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - if (!params.orderId && !params.origClientOrderId) { - return { - content: [{ type: "text", text: "Either orderId or origClientOrderId must be provided" }], - isError: true - }; - } - - const response = await futuresClient.restAPI.modifyOrder({ - symbol: params.symbol, - side: params.side, - ...(params.orderId && { orderId: params.orderId }), - ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), - ...(params.quantity && { quantity: params.quantity }), - ...(params.price && { price: params.price }), - ...(params.priceMatch && { priceMatch: params.priceMatch }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Order modified successfully!\n\nSymbol: ${data.symbol}\nOrder ID: ${data.orderId}\nSide: ${data.side}\nNew Price: ${data.price}\nNew Qty: ${data.origQty}\nStatus: ${data.status}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to modify order: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesModifyOrder", + "Modify an existing USD-M Futures order. Can modify price, quantity, or both.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + orderId: z.number().int().optional().describe("Order ID"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + side: z.enum(["BUY", "SELL"]).describe("Order side"), + quantity: z.string().optional().describe("New quantity"), + price: z.string().optional().describe("New price"), + priceMatch: z + .enum([ + "OPPONENT", + "OPPONENT_5", + "OPPONENT_10", + "OPPONENT_20", + "QUEUE", + "QUEUE_5", + "QUEUE_10", + "QUEUE_20", + ]) + .optional() + .describe("Price match mode"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + if (!params.orderId && !params.origClientOrderId) { + return { + content: [ + { type: "text", text: "Either orderId or origClientOrderId must be provided" }, + ], + isError: true, + } + } + + const response = await futuresClient.restAPI.modifyOrder({ + symbol: params.symbol, + side: params.side, + ...(params.orderId && { orderId: params.orderId }), + ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), + ...(params.quantity && { quantity: params.quantity }), + ...(params.price && { price: params.price }), + ...(params.priceMatch && { priceMatch: params.priceMatch }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Order modified successfully!\n\nSymbol: ${data.symbol}\nOrder ID: ${data.orderId}\nSide: ${data.side}\nNew Price: ${data.price}\nNew Qty: ${data.origQty}\nStatus: ${data.status}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to modify order: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/trade-api/newOrder.ts b/src/tools/binance-futures-usdm/trade-api/newOrder.ts index c12b8cfc..39410830 100644 --- a/src/tools/binance-futures-usdm/trade-api/newOrder.ts +++ b/src/tools/binance-futures-usdm/trade-api/newOrder.ts @@ -5,76 +5,110 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/newOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesNewOrder(server: McpServer) { - server.tool( - "BinanceFuturesNewOrder", - "Place a new USD-M Futures order. Supports LIMIT, MARKET, STOP, TAKE_PROFIT, and TRAILING_STOP_MARKET orders. ⚠️ RISK: Futures trading involves leverage and liquidation risk.", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Order side"), - positionSide: z.enum(["BOTH", "LONG", "SHORT"]).optional().describe("Position side for Hedge Mode. Use BOTH for One-Way Mode"), - type: z.enum([ - "LIMIT", "MARKET", "STOP", "STOP_MARKET", - "TAKE_PROFIT", "TAKE_PROFIT_MARKET", "TRAILING_STOP_MARKET" - ]).describe("Order type"), - quantity: z.string().optional().describe("Order quantity"), - price: z.string().optional().describe("Limit price (required for LIMIT orders)"), - stopPrice: z.string().optional().describe("Stop price (required for STOP orders)"), - timeInForce: z.enum(["GTC", "IOC", "FOK", "GTX"]).optional().describe("Time in force. GTC=Good Till Cancel, IOC=Immediate Or Cancel, FOK=Fill Or Kill, GTX=Good Till Crossing"), - reduceOnly: z.boolean().optional().describe("Reduce position only (cannot be used with closePosition)"), - closePosition: z.boolean().optional().describe("Close entire position (cannot be used with quantity or reduceOnly)"), - activationPrice: z.string().optional().describe("Activation price for TRAILING_STOP_MARKET"), - callbackRate: z.string().optional().describe("Callback rate for TRAILING_STOP_MARKET (0.1% - 5%)"), - workingType: z.enum(["MARK_PRICE", "CONTRACT_PRICE"]).optional().describe("Stop price trigger type"), - priceProtect: z.boolean().optional().describe("Price protection"), - newClientOrderId: z.string().optional().describe("Custom order ID"), - newOrderRespType: z.enum(["ACK", "RESULT"]).optional().describe("Response type"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.newOrder({ - symbol: params.symbol, - side: params.side, - type: params.type, - ...(params.positionSide && { positionSide: params.positionSide }), - ...(params.quantity && { quantity: params.quantity }), - ...(params.price && { price: params.price }), - ...(params.stopPrice && { stopPrice: params.stopPrice }), - ...(params.timeInForce && { timeInForce: params.timeInForce }), - ...(params.reduceOnly !== undefined && { reduceOnly: params.reduceOnly }), - ...(params.closePosition !== undefined && { closePosition: params.closePosition }), - ...(params.activationPrice && { activationPrice: params.activationPrice }), - ...(params.callbackRate && { callbackRate: params.callbackRate }), - ...(params.workingType && { workingType: params.workingType }), - ...(params.priceProtect !== undefined && { priceProtect: params.priceProtect }), - ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), - ...(params.newOrderRespType && { newOrderRespType: params.newOrderRespType }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Futures order placed successfully!\n\nOrder ID: ${data.orderId}\nClient Order ID: ${data.clientOrderId}\nSymbol: ${data.symbol}\nSide: ${data.side}\nPosition Side: ${data.positionSide || 'BOTH'}\nType: ${data.type}\nQuantity: ${data.origQty}\nPrice: ${data.price || 'MARKET'}\nStop Price: ${data.stopPrice || 'N/A'}\nStatus: ${data.status}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ - type: "text", - text: `❌ Failed to place futures order: ${errorMessage}` - }], - isError: true - }; - } + server.tool( + "BinanceFuturesNewOrder", + "Place a new USD-M Futures order. Supports LIMIT, MARKET, STOP, TAKE_PROFIT, and TRAILING_STOP_MARKET orders. ⚠️ RISK: Futures trading involves leverage and liquidation risk.", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Order side"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe("Position side for Hedge Mode. Use BOTH for One-Way Mode"), + type: z + .enum([ + "LIMIT", + "MARKET", + "STOP", + "STOP_MARKET", + "TAKE_PROFIT", + "TAKE_PROFIT_MARKET", + "TRAILING_STOP_MARKET", + ]) + .describe("Order type"), + quantity: z.string().optional().describe("Order quantity"), + price: z.string().optional().describe("Limit price (required for LIMIT orders)"), + stopPrice: z.string().optional().describe("Stop price (required for STOP orders)"), + timeInForce: z + .enum(["GTC", "IOC", "FOK", "GTX"]) + .optional() + .describe( + "Time in force. GTC=Good Till Cancel, IOC=Immediate Or Cancel, FOK=Fill Or Kill, GTX=Good Till Crossing", + ), + reduceOnly: z + .boolean() + .optional() + .describe("Reduce position only (cannot be used with closePosition)"), + closePosition: z + .boolean() + .optional() + .describe("Close entire position (cannot be used with quantity or reduceOnly)"), + activationPrice: z.string().optional().describe("Activation price for TRAILING_STOP_MARKET"), + callbackRate: z + .string() + .optional() + .describe("Callback rate for TRAILING_STOP_MARKET (0.1% - 5%)"), + workingType: z + .enum(["MARK_PRICE", "CONTRACT_PRICE"]) + .optional() + .describe("Stop price trigger type"), + priceProtect: z.boolean().optional().describe("Price protection"), + newClientOrderId: z.string().optional().describe("Custom order ID"), + newOrderRespType: z.enum(["ACK", "RESULT"]).optional().describe("Response type"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.newOrder({ + symbol: params.symbol, + side: params.side, + type: params.type, + ...(params.positionSide && { positionSide: params.positionSide }), + ...(params.quantity && { quantity: params.quantity }), + ...(params.price && { price: params.price }), + ...(params.stopPrice && { stopPrice: params.stopPrice }), + ...(params.timeInForce && { timeInForce: params.timeInForce }), + ...(params.reduceOnly !== undefined && { reduceOnly: params.reduceOnly }), + ...(params.closePosition !== undefined && { closePosition: params.closePosition }), + ...(params.activationPrice && { activationPrice: params.activationPrice }), + ...(params.callbackRate && { callbackRate: params.callbackRate }), + ...(params.workingType && { workingType: params.workingType }), + ...(params.priceProtect !== undefined && { priceProtect: params.priceProtect }), + ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), + ...(params.newOrderRespType && { newOrderRespType: params.newOrderRespType }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Futures order placed successfully!\n\nOrder ID: ${data.orderId}\nClient Order ID: ${data.clientOrderId}\nSymbol: ${data.symbol}\nSide: ${data.side}\nPosition Side: ${data.positionSide || "BOTH"}\nType: ${data.type}\nQuantity: ${data.origQty}\nPrice: ${data.price || "MARKET"}\nStop Price: ${data.stopPrice || "N/A"}\nStatus: ${data.status}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { + type: "text", + text: `❌ Failed to place futures order: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/trade-api/openOrder.ts b/src/tools/binance-futures-usdm/trade-api/openOrder.ts index 39139b79..f4ed0a83 100644 --- a/src/tools/binance-futures-usdm/trade-api/openOrder.ts +++ b/src/tools/binance-futures-usdm/trade-api/openOrder.ts @@ -5,61 +5,61 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/openOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesOpenOrder(server: McpServer) { - server.tool( - "BinanceFuturesOpenOrder", - "Query a single open order. Either orderId or origClientOrderId must be provided.", - { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), - orderId: z.number().optional().describe("Order ID"), - origClientOrderId: z.string().optional().describe("Original client order ID") - }, - async (params) => { - try { - if (!params.orderId && !params.origClientOrderId) { - return { - content: [ - { - type: "text" as const, - text: "Error: Either orderId or origClientOrderId must be provided" - } - ], - isError: true - }; - } + server.tool( + "BinanceFuturesOpenOrder", + "Query a single open order. Either orderId or origClientOrderId must be provided.", + { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), + orderId: z.number().optional().describe("Order ID"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + }, + async (params) => { + try { + if (!params.orderId && !params.origClientOrderId) { + return { + content: [ + { + type: "text" as const, + text: "Error: Either orderId or origClientOrderId must be provided", + }, + ], + isError: true, + } + } - const response = await futuresClient.restAPI.currentOpenOrder( - params.symbol, - { - orderId: params.orderId, - origClientOrderId: params.origClientOrderId - } - ); + const response = await futuresClient.restAPI.currentOpenOrder(params.symbol, { + orderId: params.orderId, + origClientOrderId: params.origClientOrderId, + }) + + return { + content: [ + { + type: "text" as const, + text: JSON.stringify(response.data, null, 2), + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : "Unknown error occurred" - return { - content: [ - { - type: "text" as const, - text: JSON.stringify(response.data, null, 2) - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : "Unknown error occurred"; - return { - content: [ - { - type: "text" as const, - text: `Error getting open order: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text" as const, + text: `Error getting open order: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/trade-api/openOrders.ts b/src/tools/binance-futures-usdm/trade-api/openOrders.ts index fc422b14..3427b869 100644 --- a/src/tools/binance-futures-usdm/trade-api/openOrders.ts +++ b/src/tools/binance-futures-usdm/trade-api/openOrders.ts @@ -5,43 +5,49 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/openOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesOpenOrders(server: McpServer) { - server.tool( - "BinanceFuturesOpenOrders", - "Get all current open orders. If symbol is provided, returns orders for that symbol only. Otherwise returns all open orders (use with caution due to rate limits).", - { - symbol: z.string().optional().describe("Trading pair symbol (e.g., BTCUSDT). If omitted, returns all open orders.") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.currentAllOpenOrders({ - symbol: params.symbol - }); + server.tool( + "BinanceFuturesOpenOrders", + "Get all current open orders. If symbol is provided, returns orders for that symbol only. Otherwise returns all open orders (use with caution due to rate limits).", + { + symbol: z + .string() + .optional() + .describe("Trading pair symbol (e.g., BTCUSDT). If omitted, returns all open orders."), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.currentAllOpenOrders({ + symbol: params.symbol, + }) + + return { + content: [ + { + type: "text" as const, + text: JSON.stringify(response.data, null, 2), + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : "Unknown error occurred" - return { - content: [ - { - type: "text" as const, - text: JSON.stringify(response.data, null, 2) - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : "Unknown error occurred"; - return { - content: [ - { - type: "text" as const, - text: `Error getting open orders: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text" as const, + text: `Error getting open orders: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/trade-api/positionMarginHistory.ts b/src/tools/binance-futures-usdm/trade-api/positionMarginHistory.ts index 095f2b89..b9803249 100644 --- a/src/tools/binance-futures-usdm/trade-api/positionMarginHistory.ts +++ b/src/tools/binance-futures-usdm/trade-api/positionMarginHistory.ts @@ -5,48 +5,55 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/positionMarginHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesPositionMarginHistory(server: McpServer) { - server.tool( - "BinanceFuturesPositionMarginHistory", - "Get the history of isolated position margin changes (additions and reductions).", - { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - type: z.enum(["1", "2"]).optional().describe("1 = Add margin, 2 = Reduce margin (filter)"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z.number().int().optional().describe("Number of results (default 500, max 500)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.getPositionMarginHistory({ - symbol: params.symbol, - ...(params.type && { type: parseInt(params.type) }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `📊 Position Margin History for ${params.symbol}\n\nRecords: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get position margin history: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesPositionMarginHistory", + "Get the history of isolated position margin changes (additions and reductions).", + { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + type: z.enum(["1", "2"]).optional().describe("1 = Add margin, 2 = Reduce margin (filter)"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z.number().int().optional().describe("Number of results (default 500, max 500)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.getPositionMarginHistory({ + symbol: params.symbol, + ...(params.type && { type: parseInt(params.type) }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📊 Position Margin History for ${params.symbol}\n\nRecords: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `❌ Failed to get position margin history: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/trades.ts b/src/tools/binance-futures-usdm/trades.ts index 9251c4d9..e5af8469 100644 --- a/src/tools/binance-futures-usdm/trades.ts +++ b/src/tools/binance-futures-usdm/trades.ts @@ -1,41 +1,46 @@ // src/tools/binance-futures-usdm/trades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMTrades(server: McpServer) { - server.tool( - "BinanceFuturesUSDMTrades", - "Get recent trades for a specific USD-M Futures trading pair.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - limit: z.number().optional().describe("Number of trades to return. Default 500; max 1000") - }, - async ({ symbol, limit }) => { - try { - const params: any = { symbol }; - if (limit !== undefined) params.limit = limit; + server.tool( + "BinanceFuturesUSDMTrades", + "Get recent trades for a specific USD-M Futures trading pair.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + limit: z.number().optional().describe("Number of trades to return. Default 500; max 1000"), + }, + async ({ symbol, limit }) => { + try { + const params: any = { symbol } + if (limit !== undefined) params.limit = limit - const data = await futuresClient.trades(params); - + const data = await futuresClient.trades(params) + + return { + content: [ + { + type: "text", + text: `Retrieved ${data.length || 0} recent trades for USD-M Futures ${symbol}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved ${data.length || 0} recent trades for USD-M Futures ${symbol}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve USD-M Futures recent trades: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve USD-M Futures recent trades: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/userTrades.ts b/src/tools/binance-futures-usdm/userTrades.ts index 03f9d7af..5ad85a7a 100644 --- a/src/tools/binance-futures-usdm/userTrades.ts +++ b/src/tools/binance-futures-usdm/userTrades.ts @@ -1,49 +1,51 @@ // src/tools/binance-futures-usdm/userTrades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../config/binanceClient.js" export function registerBinanceFuturesUSDMUserTrades(server: McpServer) { - server.tool( - "BinanceFuturesUSDMUserTrades", - "Get account trade list for USD-M Futures.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - orderId: z.number().optional().describe("Filter by order ID"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - fromId: z.number().optional().describe("Trade ID to start from"), - limit: z.number().optional().describe("Default 500; max 1000") - }, - async ({ symbol, orderId, startTime, endTime, fromId, limit }) => { - try { - const params: any = { symbol }; - if (orderId !== undefined) params.orderId = orderId; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (fromId !== undefined) params.fromId = fromId; - if (limit !== undefined) params.limit = limit; + server.tool( + "BinanceFuturesUSDMUserTrades", + "Get account trade list for USD-M Futures.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + orderId: z.number().optional().describe("Filter by order ID"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + fromId: z.number().optional().describe("Trade ID to start from"), + limit: z.number().optional().describe("Default 500; max 1000"), + }, + async ({ symbol, orderId, startTime, endTime, fromId, limit }) => { + try { + const params: any = { symbol } + if (orderId !== undefined) params.orderId = orderId + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (fromId !== undefined) params.fromId = fromId + if (limit !== undefined) params.limit = limit - const data = await futuresClient.userTrades(params); - + const data = await futuresClient.userTrades(params) + + return { + content: [ + { + type: "text", + text: `Retrieved ${data.length || 0} USD-M Futures trades for ${symbol}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved ${data.length || 0} USD-M Futures trades for ${symbol}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve USD-M Futures user trades: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve USD-M Futures user trades: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/userdatastream-api/closeListenKey.ts b/src/tools/binance-futures-usdm/userdatastream-api/closeListenKey.ts index b41bf43b..f8e44c50 100644 --- a/src/tools/binance-futures-usdm/userdatastream-api/closeListenKey.ts +++ b/src/tools/binance-futures-usdm/userdatastream-api/closeListenKey.ts @@ -5,40 +5,48 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/userdatastream-api/closeListenKey.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesCloseListenKey(server: McpServer) { - server.tool( - "BinanceFuturesCloseListenKey", - "Close a USD-M Futures user data stream listen key. This invalidates the listen key and closes the associated WebSocket stream.", - { - listenKey: z.string().optional().describe("Listen key to close. If not provided, closes the default listen key."), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.closeListenKey({ - ...(params.listenKey && { listenKey: params.listenKey }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Listen Key Closed!\n\nThe listen key has been invalidated and the stream is closed.\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to close listen key: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesCloseListenKey", + "Close a USD-M Futures user data stream listen key. This invalidates the listen key and closes the associated WebSocket stream.", + { + listenKey: z + .string() + .optional() + .describe("Listen key to close. If not provided, closes the default listen key."), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.closeListenKey({ + ...(params.listenKey && { listenKey: params.listenKey }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Listen Key Closed!\n\nThe listen key has been invalidated and the stream is closed.\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to close listen key: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/userdatastream-api/createListenKey.ts b/src/tools/binance-futures-usdm/userdatastream-api/createListenKey.ts index 050dc0f1..063510ef 100644 --- a/src/tools/binance-futures-usdm/userdatastream-api/createListenKey.ts +++ b/src/tools/binance-futures-usdm/userdatastream-api/createListenKey.ts @@ -5,38 +5,43 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/userdatastream-api/createListenKey.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesCreateListenKey(server: McpServer) { - server.tool( - "BinanceFuturesCreateListenKey", - "Create a new USD-M Futures user data stream listen key. The listen key is valid for 60 minutes and can be used to receive account updates via WebSocket. Must be kept alive with keepAlive endpoint.", - { - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.createListenKey({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Listen Key Created Successfully!\n\nListen Key: ${data.listenKey}\n\n⚠️ Important:\n- Valid for 60 minutes\n- Use keepAlive endpoint to extend validity\n- Use this key to connect to futures websocket stream\n\nWebSocket URL: wss://fstream.binance.com/ws/${data.listenKey}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to create listen key: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesCreateListenKey", + "Create a new USD-M Futures user data stream listen key. The listen key is valid for 60 minutes and can be used to receive account updates via WebSocket. Must be kept alive with keepAlive endpoint.", + { + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.createListenKey({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Listen Key Created Successfully!\n\nListen Key: ${data.listenKey}\n\n⚠️ Important:\n- Valid for 60 minutes\n- Use keepAlive endpoint to extend validity\n- Use this key to connect to futures websocket stream\n\nWebSocket URL: wss://fstream.binance.com/ws/${data.listenKey}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to create listen key: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-futures-usdm/userdatastream-api/index.ts b/src/tools/binance-futures-usdm/userdatastream-api/index.ts index 9ea2340f..e2e06a69 100644 --- a/src/tools/binance-futures-usdm/userdatastream-api/index.ts +++ b/src/tools/binance-futures-usdm/userdatastream-api/index.ts @@ -5,14 +5,15 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/userdatastream-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceFuturesCreateListenKey } from "./createListenKey.js"; -import { registerBinanceFuturesKeepAliveListenKey } from "./keepAliveListenKey.js"; -import { registerBinanceFuturesCloseListenKey } from "./closeListenKey.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceFuturesCloseListenKey } from "./closeListenKey.js" +import { registerBinanceFuturesCreateListenKey } from "./createListenKey.js" +import { registerBinanceFuturesKeepAliveListenKey } from "./keepAliveListenKey.js" export function registerBinanceFuturesUserDataStreamApiTools(server: McpServer) { - // User Data Stream (Listen Key) Management - registerBinanceFuturesCreateListenKey(server); - registerBinanceFuturesKeepAliveListenKey(server); - registerBinanceFuturesCloseListenKey(server); + // User Data Stream (Listen Key) Management + registerBinanceFuturesCreateListenKey(server) + registerBinanceFuturesKeepAliveListenKey(server) + registerBinanceFuturesCloseListenKey(server) } diff --git a/src/tools/binance-futures-usdm/userdatastream-api/keepAliveListenKey.ts b/src/tools/binance-futures-usdm/userdatastream-api/keepAliveListenKey.ts index e40dcc12..02362b47 100644 --- a/src/tools/binance-futures-usdm/userdatastream-api/keepAliveListenKey.ts +++ b/src/tools/binance-futures-usdm/userdatastream-api/keepAliveListenKey.ts @@ -5,40 +5,48 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/userdatastream-api/keepAliveListenKey.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { futuresClient } from "../../../config/binanceClient.js" export function registerBinanceFuturesKeepAliveListenKey(server: McpServer) { - server.tool( - "BinanceFuturesKeepAliveListenKey", - "Keepalive a USD-M Futures user data stream listen key. Extends the validity by 60 minutes. Should be called every 30-50 minutes to maintain the connection.", - { - listenKey: z.string().optional().describe("Listen key to keep alive. If not provided, uses the default listen key."), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds") - }, - async (params) => { - try { - const response = await futuresClient.restAPI.renewListenKey({ - ...(params.listenKey && { listenKey: params.listenKey }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Listen Key Extended!\n\nThe listen key validity has been extended by 60 minutes.\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to keepalive listen key: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceFuturesKeepAliveListenKey", + "Keepalive a USD-M Futures user data stream listen key. Extends the validity by 60 minutes. Should be called every 30-50 minutes to maintain the connection.", + { + listenKey: z + .string() + .optional() + .describe("Listen key to keep alive. If not provided, uses the default listen key."), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, + async (params) => { + try { + const response = await futuresClient.restAPI.renewListenKey({ + ...(params.listenKey && { listenKey: params.listenKey }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Listen Key Extended!\n\nThe listen key validity has been extended by 60 minutes.\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to keepalive listen key: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-gift-card/buyCode.ts b/src/tools/binance-gift-card/buyCode.ts index 4e91fd6c..586deff3 100644 --- a/src/tools/binance-gift-card/buyCode.ts +++ b/src/tools/binance-gift-card/buyCode.ts @@ -1,42 +1,43 @@ // src/tools/binance-gift-card/buyCode.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { giftCardClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { giftCardClient } from "../../config/binanceClient.js" export function registerBinanceGiftCardBuyCode(server: McpServer) { - server.tool( - "BinanceGiftCardBuyCode", - "Buy a Binance Gift Card code using another token as payment. The base token is used to purchase a gift card of the face token.", - { - baseToken: z.string().describe("The token used to pay for the gift card (e.g., USDT)"), - faceToken: z.string().describe("The token the gift card will contain (e.g., BNB)"), - baseTokenAmount: z.number().describe("The amount of base token to spend"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ baseToken, faceToken, baseTokenAmount, recvWindow }) => { - try { - const params: Record = { baseToken, faceToken, baseTokenAmount }; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await giftCardClient.buyCode(params); + server.tool( + "BinanceGiftCardBuyCode", + "Buy a Binance Gift Card code using another token as payment. The base token is used to purchase a gift card of the face token.", + { + baseToken: z.string().describe("The token used to pay for the gift card (e.g., USDT)"), + faceToken: z.string().describe("The token the gift card will contain (e.g., BNB)"), + baseTokenAmount: z.number().describe("The amount of base token to spend"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ baseToken, faceToken, baseTokenAmount, recvWindow }) => { + try { + const params: Record = { baseToken, faceToken, baseTokenAmount } + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await giftCardClient.buyCode(params) + + return { + content: [ + { + type: "text", + text: `Gift card purchased: ${baseTokenAmount} ${baseToken} -> ${faceToken}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Gift card purchased: ${baseTokenAmount} ${baseToken} -> ${faceToken}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to buy gift card: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to buy gift card: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-gift-card/createCode.ts b/src/tools/binance-gift-card/createCode.ts index 1e6471bc..a67137fa 100644 --- a/src/tools/binance-gift-card/createCode.ts +++ b/src/tools/binance-gift-card/createCode.ts @@ -1,41 +1,42 @@ // src/tools/binance-gift-card/createCode.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { giftCardClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { giftCardClient } from "../../config/binanceClient.js" export function registerBinanceGiftCardCreateCode(server: McpServer) { - server.tool( - "BinanceGiftCardCreateCode", - "Create a Binance Gift Card code. This allows you to generate a gift card with a specified token and amount.", - { - token: z.string().describe("The token to include in the gift card (e.g., BNB, USDT)"), - amount: z.number().describe("The amount of the token to include in the gift card"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ token, amount, recvWindow }) => { - try { - const params: Record = { token, amount }; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await giftCardClient.createCode(params); + server.tool( + "BinanceGiftCardCreateCode", + "Create a Binance Gift Card code. This allows you to generate a gift card with a specified token and amount.", + { + token: z.string().describe("The token to include in the gift card (e.g., BNB, USDT)"), + amount: z.number().describe("The amount of the token to include in the gift card"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ token, amount, recvWindow }) => { + try { + const params: Record = { token, amount } + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await giftCardClient.createCode(params) + + return { + content: [ + { + type: "text", + text: `Gift card code created successfully for ${amount} ${token}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Gift card code created successfully for ${amount} ${token}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to create gift card code: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to create gift card code: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-gift-card/createDualTokenCode.ts b/src/tools/binance-gift-card/createDualTokenCode.ts index 965e319f..045cbb53 100644 --- a/src/tools/binance-gift-card/createDualTokenCode.ts +++ b/src/tools/binance-gift-card/createDualTokenCode.ts @@ -1,44 +1,49 @@ // src/tools/binance-gift-card/createDualTokenCode.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { giftCardClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { giftCardClient } from "../../config/binanceClient.js" export function registerBinanceGiftCardCreateDualTokenCode(server: McpServer) { - server.tool( - "BinanceGiftCardCreateDualTokenCode", - "Create a dual-token Binance Gift Card. This creates a gift card where the base token is exchanged to the face token for redemption.", - { - baseToken: z.string().describe("The token used as the base for the gift card (token you pay with)"), - faceToken: z.string().describe("The token the recipient will receive when redeeming"), - baseTokenAmount: z.number().describe("The amount of base token to convert"), - discount: z.number().optional().describe("Discount percentage (if applicable)"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ baseToken, faceToken, baseTokenAmount, discount, recvWindow }) => { - try { - const params: Record = { baseToken, faceToken, baseTokenAmount }; - if (discount !== undefined) params.discount = discount; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await giftCardClient.createDualTokenCode(params); + server.tool( + "BinanceGiftCardCreateDualTokenCode", + "Create a dual-token Binance Gift Card. This creates a gift card where the base token is exchanged to the face token for redemption.", + { + baseToken: z + .string() + .describe("The token used as the base for the gift card (token you pay with)"), + faceToken: z.string().describe("The token the recipient will receive when redeeming"), + baseTokenAmount: z.number().describe("The amount of base token to convert"), + discount: z.number().optional().describe("Discount percentage (if applicable)"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ baseToken, faceToken, baseTokenAmount, discount, recvWindow }) => { + try { + const params: Record = { baseToken, faceToken, baseTokenAmount } + if (discount !== undefined) params.discount = discount + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await giftCardClient.createDualTokenCode(params) + + return { + content: [ + { + type: "text", + text: `Dual-token gift card created: ${baseTokenAmount} ${baseToken} -> ${faceToken}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Dual-token gift card created: ${baseTokenAmount} ${baseToken} -> ${faceToken}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to create dual-token gift card: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to create dual-token gift card: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-gift-card/createDualTokenGiftCard.ts b/src/tools/binance-gift-card/createDualTokenGiftCard.ts index add352b5..529354e1 100644 --- a/src/tools/binance-gift-card/createDualTokenGiftCard.ts +++ b/src/tools/binance-gift-card/createDualTokenGiftCard.ts @@ -5,46 +5,53 @@ * @license Apache-2.0 */ // src/tools/binance-gift-card/createDualTokenGiftCard.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { giftCardClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { giftCardClient } from "../../config/binanceClient.js" export function registerBinanceGiftCardCreateDualToken(server: McpServer) { - server.tool( - "BinanceGiftCardCreateDualToken", - "Create a dual-token Binance Gift Card. Allows creating a gift card using one token that the recipient will receive as another token.", - { - baseToken: z.string().describe("Token used to pay for the gift card (e.g., 'USDT')"), - faceToken: z.string().describe("Token that the recipient will receive (e.g., 'BNB')"), - baseTokenAmount: z.string().describe("Amount of base token to spend"), - discount: z.number().optional().describe("Discount rate (0-100)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await giftCardClient.restAPI.createDualTokenCode({ - baseToken: params.baseToken, - faceToken: params.faceToken, - baseTokenAmount: params.baseTokenAmount, - ...(params.discount !== undefined && { discount: params.discount }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Dual-Token Gift Card Created!\n\nReference No: ${data.referenceNo}\nCode: ${data.code}\nPaid: ${params.baseTokenAmount} ${params.baseToken}\nRecipient Gets: ${data.faceTokenAmount || 'N/A'} ${params.faceToken}\n\n⚠️ Keep the code secure!` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to create dual-token gift card: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceGiftCardCreateDualToken", + "Create a dual-token Binance Gift Card. Allows creating a gift card using one token that the recipient will receive as another token.", + { + baseToken: z.string().describe("Token used to pay for the gift card (e.g., 'USDT')"), + faceToken: z.string().describe("Token that the recipient will receive (e.g., 'BNB')"), + baseTokenAmount: z.string().describe("Amount of base token to spend"), + discount: z.number().optional().describe("Discount rate (0-100)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await giftCardClient.restAPI.createDualTokenCode({ + baseToken: params.baseToken, + faceToken: params.faceToken, + baseTokenAmount: params.baseTokenAmount, + ...(params.discount !== undefined && { discount: params.discount }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Dual-Token Gift Card Created!\n\nReference No: ${data.referenceNo}\nCode: ${data.code}\nPaid: ${params.baseTokenAmount} ${params.baseToken}\nRecipient Gets: ${data.faceTokenAmount || "N/A"} ${params.faceToken}\n\n⚠️ Keep the code secure!`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `❌ Failed to create dual-token gift card: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-gift-card/createGiftCard.ts b/src/tools/binance-gift-card/createGiftCard.ts index 63799d0b..bb2fa89f 100644 --- a/src/tools/binance-gift-card/createGiftCard.ts +++ b/src/tools/binance-gift-card/createGiftCard.ts @@ -5,42 +5,47 @@ * @license Apache-2.0 */ // src/tools/binance-gift-card/createGiftCard.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { giftCardClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { giftCardClient } from "../../config/binanceClient.js" export function registerBinanceGiftCardCreate(server: McpServer) { - server.tool( - "BinanceGiftCardCreate", - "Create a Binance Gift Card. The card will be deducted from your spot wallet balance.", - { - token: z.string().describe("Token type (e.g., 'BNB', 'USDT', 'BTC')"), - amount: z.string().describe("Amount of tokens to include in gift card"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await giftCardClient.restAPI.createCode({ - token: params.token, - amount: params.amount, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Gift Card Created!\n\nReference No: ${data.referenceNo}\nCode: ${data.code}\nToken: ${params.token}\nAmount: ${params.amount}\n\n⚠️ Keep the code secure! Anyone with the code can redeem it.` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to create gift card: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceGiftCardCreate", + "Create a Binance Gift Card. The card will be deducted from your spot wallet balance.", + { + token: z.string().describe("Token type (e.g., 'BNB', 'USDT', 'BTC')"), + amount: z.string().describe("Amount of tokens to include in gift card"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await giftCardClient.restAPI.createCode({ + token: params.token, + amount: params.amount, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Gift Card Created!\n\nReference No: ${data.referenceNo}\nCode: ${data.code}\nToken: ${params.token}\nAmount: ${params.amount}\n\n⚠️ Keep the code secure! Anyone with the code can redeem it.`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to create gift card: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-gift-card/getTokenLimit.ts b/src/tools/binance-gift-card/getTokenLimit.ts index da856247..641044b3 100644 --- a/src/tools/binance-gift-card/getTokenLimit.ts +++ b/src/tools/binance-gift-card/getTokenLimit.ts @@ -1,40 +1,41 @@ // src/tools/binance-gift-card/getTokenLimit.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { giftCardClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { giftCardClient } from "../../config/binanceClient.js" export function registerBinanceGiftCardGetTokenLimit(server: McpServer) { - server.tool( - "BinanceGiftCardGetTokenLimit", - "Fetch the token limits for buying gift cards, including minimum and maximum amounts.", - { - baseToken: z.string().describe("The base token to check limits for (e.g., USDT)"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ baseToken, recvWindow }) => { - try { - const params: Record = { baseToken }; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await giftCardClient.getTokenLimit(params); + server.tool( + "BinanceGiftCardGetTokenLimit", + "Fetch the token limits for buying gift cards, including minimum and maximum amounts.", + { + baseToken: z.string().describe("The base token to check limits for (e.g., USDT)"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ baseToken, recvWindow }) => { + try { + const params: Record = { baseToken } + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await giftCardClient.getTokenLimit(params) + + return { + content: [ + { + type: "text", + text: `Token limit for ${baseToken}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Token limit for ${baseToken}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to fetch token limit: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to fetch token limit: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-gift-card/index.ts b/src/tools/binance-gift-card/index.ts index 2f3dbdf0..3b835aa5 100644 --- a/src/tools/binance-gift-card/index.ts +++ b/src/tools/binance-gift-card/index.ts @@ -1,24 +1,25 @@ // src/tools/binance-gift-card/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGiftCardCreateCode } from "./createCode.js"; -import { registerBinanceGiftCardCreateDualTokenCode } from "./createDualTokenCode.js"; -import { registerBinanceGiftCardRedeemCode } from "./redeemCode.js"; -import { registerBinanceGiftCardVerify } from "./verify.js"; -import { registerBinanceGiftCardRsaPublicKey } from "./rsaPublicKey.js"; -import { registerBinanceGiftCardBuyCode } from "./buyCode.js"; -import { registerBinanceGiftCardGetTokenLimit } from "./getTokenLimit.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceGiftCardBuyCode } from "./buyCode.js" +import { registerBinanceGiftCardCreateCode } from "./createCode.js" +import { registerBinanceGiftCardCreateDualTokenCode } from "./createDualTokenCode.js" +import { registerBinanceGiftCardGetTokenLimit } from "./getTokenLimit.js" +import { registerBinanceGiftCardRedeemCode } from "./redeemCode.js" +import { registerBinanceGiftCardRsaPublicKey } from "./rsaPublicKey.js" +import { registerBinanceGiftCardVerify } from "./verify.js" export function registerBinanceGiftCardTools(server: McpServer) { - // Create Gift Cards - registerBinanceGiftCardCreateCode(server); - registerBinanceGiftCardCreateDualTokenCode(server); - registerBinanceGiftCardBuyCode(server); - - // Redeem & Verify - registerBinanceGiftCardRedeemCode(server); - registerBinanceGiftCardVerify(server); - - // Utilities - registerBinanceGiftCardRsaPublicKey(server); - registerBinanceGiftCardGetTokenLimit(server); + // Create Gift Cards + registerBinanceGiftCardCreateCode(server) + registerBinanceGiftCardCreateDualTokenCode(server) + registerBinanceGiftCardBuyCode(server) + + // Redeem & Verify + registerBinanceGiftCardRedeemCode(server) + registerBinanceGiftCardVerify(server) + + // Utilities + registerBinanceGiftCardRsaPublicKey(server) + registerBinanceGiftCardGetTokenLimit(server) } diff --git a/src/tools/binance-gift-card/redeemCode.ts b/src/tools/binance-gift-card/redeemCode.ts index 9cb054c9..aa7f012c 100644 --- a/src/tools/binance-gift-card/redeemCode.ts +++ b/src/tools/binance-gift-card/redeemCode.ts @@ -1,42 +1,43 @@ // src/tools/binance-gift-card/redeemCode.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { giftCardClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { giftCardClient } from "../../config/binanceClient.js" export function registerBinanceGiftCardRedeemCode(server: McpServer) { - server.tool( - "BinanceGiftCardRedeemCode", - "Redeem a Binance Gift Card code. The tokens will be credited to your account.", - { - code: z.string().describe("The gift card code to redeem"), - externalUid: z.string().optional().describe("External unique identifier for the redemption"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ code, externalUid, recvWindow }) => { - try { - const params: Record = { code }; - if (externalUid !== undefined) params.externalUid = externalUid; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await giftCardClient.redeemCode(params); + server.tool( + "BinanceGiftCardRedeemCode", + "Redeem a Binance Gift Card code. The tokens will be credited to your account.", + { + code: z.string().describe("The gift card code to redeem"), + externalUid: z.string().optional().describe("External unique identifier for the redemption"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ code, externalUid, recvWindow }) => { + try { + const params: Record = { code } + if (externalUid !== undefined) params.externalUid = externalUid + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await giftCardClient.redeemCode(params) + + return { + content: [ + { + type: "text", + text: `Gift card redeemed successfully. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Gift card redeemed successfully. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to redeem gift card: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to redeem gift card: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-gift-card/redeemDualTokenGiftCard.ts b/src/tools/binance-gift-card/redeemDualTokenGiftCard.ts index 72cf9ecb..6450bb81 100644 --- a/src/tools/binance-gift-card/redeemDualTokenGiftCard.ts +++ b/src/tools/binance-gift-card/redeemDualTokenGiftCard.ts @@ -5,42 +5,49 @@ * @license Apache-2.0 */ // src/tools/binance-gift-card/redeemDualTokenGiftCard.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { giftCardClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { giftCardClient } from "../../config/binanceClient.js" export function registerBinanceGiftCardRedeemDualToken(server: McpServer) { - server.tool( - "BinanceGiftCardRedeemDualToken", - "Redeem a dual-token Binance Gift Card.", - { - code: z.string().describe("Gift card redemption code"), - externalUid: z.string().optional().describe("External user ID for partner integration"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await giftCardClient.restAPI.redeemDualTokenCode({ - code: params.code, - ...(params.externalUid && { externalUid: params.externalUid }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Dual-Token Gift Card Redeemed!\n\nReference No: ${data.referenceNo}\nToken Received: ${data.token}\nAmount: ${data.amount}\n\nTokens have been credited to your spot wallet.` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to redeem dual-token gift card: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceGiftCardRedeemDualToken", + "Redeem a dual-token Binance Gift Card.", + { + code: z.string().describe("Gift card redemption code"), + externalUid: z.string().optional().describe("External user ID for partner integration"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await giftCardClient.restAPI.redeemDualTokenCode({ + code: params.code, + ...(params.externalUid && { externalUid: params.externalUid }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Dual-Token Gift Card Redeemed!\n\nReference No: ${data.referenceNo}\nToken Received: ${data.token}\nAmount: ${data.amount}\n\nTokens have been credited to your spot wallet.`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `❌ Failed to redeem dual-token gift card: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-gift-card/redeemGiftCard.ts b/src/tools/binance-gift-card/redeemGiftCard.ts index d70937ef..82b48867 100644 --- a/src/tools/binance-gift-card/redeemGiftCard.ts +++ b/src/tools/binance-gift-card/redeemGiftCard.ts @@ -5,42 +5,47 @@ * @license Apache-2.0 */ // src/tools/binance-gift-card/redeemGiftCard.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { giftCardClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { giftCardClient } from "../../config/binanceClient.js" export function registerBinanceGiftCardRedeem(server: McpServer) { - server.tool( - "BinanceGiftCardRedeem", - "Redeem a Binance Gift Card. The tokens will be credited to your spot wallet.", - { - code: z.string().describe("Gift card redemption code"), - externalUid: z.string().optional().describe("External user ID for partner integration"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await giftCardClient.restAPI.redeemCode({ - code: params.code, - ...(params.externalUid && { externalUid: params.externalUid }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `✅ Gift Card Redeemed!\n\nReference No: ${data.referenceNo}\nToken: ${data.token}\nAmount: ${data.amount}\n\nTokens have been credited to your spot wallet.` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to redeem gift card: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceGiftCardRedeem", + "Redeem a Binance Gift Card. The tokens will be credited to your spot wallet.", + { + code: z.string().describe("Gift card redemption code"), + externalUid: z.string().optional().describe("External user ID for partner integration"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await giftCardClient.restAPI.redeemCode({ + code: params.code, + ...(params.externalUid && { externalUid: params.externalUid }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Gift Card Redeemed!\n\nReference No: ${data.referenceNo}\nToken: ${data.token}\nAmount: ${data.amount}\n\nTokens have been credited to your spot wallet.`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to redeem gift card: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-gift-card/rsaPublicKey.ts b/src/tools/binance-gift-card/rsaPublicKey.ts index 13133b39..9e901198 100644 --- a/src/tools/binance-gift-card/rsaPublicKey.ts +++ b/src/tools/binance-gift-card/rsaPublicKey.ts @@ -1,39 +1,40 @@ // src/tools/binance-gift-card/rsaPublicKey.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { giftCardClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { giftCardClient } from "../../config/binanceClient.js" export function registerBinanceGiftCardRsaPublicKey(server: McpServer) { - server.tool( - "BinanceGiftCardRsaPublicKey", - "Fetch the RSA public key for encrypting gift card codes.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: Record = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await giftCardClient.rsaPublicKey(params); + server.tool( + "BinanceGiftCardRsaPublicKey", + "Fetch the RSA public key for encrypting gift card codes.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: Record = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await giftCardClient.rsaPublicKey(params) + + return { + content: [ + { + type: "text", + text: `Retrieved RSA public key. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved RSA public key. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to fetch RSA public key: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to fetch RSA public key: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-gift-card/tokenLimit.ts b/src/tools/binance-gift-card/tokenLimit.ts index 9e94f07b..fa6be31a 100644 --- a/src/tools/binance-gift-card/tokenLimit.ts +++ b/src/tools/binance-gift-card/tokenLimit.ts @@ -5,40 +5,45 @@ * @license Apache-2.0 */ // src/tools/binance-gift-card/tokenLimit.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { giftCardClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { giftCardClient } from "../../config/binanceClient.js" export function registerBinanceGiftCardTokenLimit(server: McpServer) { - server.tool( - "BinanceGiftCardTokenLimit", - "Get token limit information for Binance Gift Card creation. Shows minimum and maximum amounts.", - { - baseToken: z.string().describe("Base token for buying gift cards (e.g., 'USDT')"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await giftCardClient.restAPI.tokenLimit({ - baseToken: params.baseToken, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - return { - content: [{ - type: "text", - text: `📊 Gift Card Token Limits for ${params.baseToken}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get token limits: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceGiftCardTokenLimit", + "Get token limit information for Binance Gift Card creation. Shows minimum and maximum amounts.", + { + baseToken: z.string().describe("Base token for buying gift cards (e.g., 'USDT')"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await giftCardClient.restAPI.tokenLimit({ + baseToken: params.baseToken, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `📊 Gift Card Token Limits for ${params.baseToken}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to get token limits: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-gift-card/verify.ts b/src/tools/binance-gift-card/verify.ts index 0282cf5e..11b041c4 100644 --- a/src/tools/binance-gift-card/verify.ts +++ b/src/tools/binance-gift-card/verify.ts @@ -1,40 +1,41 @@ // src/tools/binance-gift-card/verify.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { giftCardClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { giftCardClient } from "../../config/binanceClient.js" export function registerBinanceGiftCardVerify(server: McpServer) { - server.tool( - "BinanceGiftCardVerify", - "Verify a Binance Gift Card code to check its validity and status without redeeming it.", - { - referenceNo: z.string().describe("The reference number of the gift card to verify"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ referenceNo, recvWindow }) => { - try { - const params: Record = { referenceNo }; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await giftCardClient.verify(params); + server.tool( + "BinanceGiftCardVerify", + "Verify a Binance Gift Card code to check its validity and status without redeeming it.", + { + referenceNo: z.string().describe("The reference number of the gift card to verify"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ referenceNo, recvWindow }) => { + try { + const params: Record = { referenceNo } + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await giftCardClient.verify(params) + + return { + content: [ + { + type: "text", + text: `Gift card verification result. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Gift card verification result. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to verify gift card: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to verify gift card: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-gift-card/verifyGiftCard.ts b/src/tools/binance-gift-card/verifyGiftCard.ts index fc580174..aab3770d 100644 --- a/src/tools/binance-gift-card/verifyGiftCard.ts +++ b/src/tools/binance-gift-card/verifyGiftCard.ts @@ -5,44 +5,49 @@ * @license Apache-2.0 */ // src/tools/binance-gift-card/verifyGiftCard.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { giftCardClient } from "../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { giftCardClient } from "../../config/binanceClient.js" export function registerBinanceGiftCardVerify(server: McpServer) { - server.tool( - "BinanceGiftCardVerify", - "Verify a Binance Gift Card code. Check if the code is valid and see its details before redeeming.", - { - referenceNo: z.string().describe("Gift card reference number"), - recvWindow: z.number().int().optional().describe("Request validity window in ms") - }, - async (params) => { - try { - const response = await giftCardClient.restAPI.verify({ - referenceNo: params.referenceNo, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const data = await response.data(); - - let statusText = "Unknown"; - if (data.valid === true) statusText = "✅ Valid"; - else if (data.valid === false) statusText = "❌ Invalid/Used"; - - return { - content: [{ - type: "text", - text: `🎁 Gift Card Verification\n\nReference No: ${params.referenceNo}\nStatus: ${statusText}\nToken: ${data.token || 'N/A'}\nAmount: ${data.amount || 'N/A'}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to verify gift card: ${errorMessage}` }], - isError: true - }; - } + server.tool( + "BinanceGiftCardVerify", + "Verify a Binance Gift Card code. Check if the code is valid and see its details before redeeming.", + { + referenceNo: z.string().describe("Gift card reference number"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, + async (params) => { + try { + const response = await giftCardClient.restAPI.verify({ + referenceNo: params.referenceNo, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + let statusText = "Unknown" + if (data.valid === true) statusText = "✅ Valid" + else if (data.valid === false) statusText = "❌ Invalid/Used" + + return { + content: [ + { + type: "text", + text: `🎁 Gift Card Verification\n\nReference No: ${params.referenceNo}\nStatus: ${statusText}\nToken: ${data.token || "N/A"}\nAmount: ${data.amount || "N/A"}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `❌ Failed to verify gift card: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginAccount.ts b/src/tools/binance-margin/cross-margin-api/crossMarginAccount.ts index 366bc51e..df82acca 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginAccount.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginAccount.ts @@ -1,34 +1,39 @@ // src/tools/binance-margin/cross-margin-api/crossMarginAccount.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceCrossMarginAccount(server: McpServer) { - server.tool( - "BinanceCrossMarginAccount", - "Query Cross Margin account details including balances, margin level, and collateral info.", - { - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.getAccount({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCrossMarginAccount", + "Query Cross Margin account details including balances, margin level, and collateral info.", + { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.getAccount({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Cross Margin Account Details: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Cross Margin Account Details: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query account: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to query account: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginAllAssets.ts b/src/tools/binance-margin/cross-margin-api/crossMarginAllAssets.ts index 91faa575..a288d23b 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginAllAssets.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginAllAssets.ts @@ -5,47 +5,57 @@ * @license Apache-2.0 */ // src/tools/binance-margin/cross-margin-api/crossMarginAllAssets.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceCrossMarginAllAssets(server: McpServer) { - server.tool( - "BinanceCrossMarginAllAssets", - "Get all assets available for cross margin trading, including borrowable status, daily interest rates, and limits.", - { - asset: z.string().optional().describe("Specific asset to query (e.g., BTC, USDT). If not provided, returns all assets."), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await marginClient.restAPI.getAllCrossMarginPairs({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCrossMarginAllAssets", + "Get all assets available for cross margin trading, including borrowable status, daily interest rates, and limits.", + { + asset: z + .string() + .optional() + .describe( + "Specific asset to query (e.g., BTC, USDT). If not provided, returns all assets.", + ), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await marginClient.restAPI.getAllCrossMarginPairs({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() - const data = await response.data(); - - // If specific asset requested, filter results - let result = data; - if (params.asset && Array.isArray(data)) { - result = data.filter((item: any) => - item.base === params.asset || item.quote === params.asset - ); - } + // If specific asset requested, filter results + let result = data + if (params.asset && Array.isArray(data)) { + result = data.filter( + (item: any) => item.base === params.asset || item.quote === params.asset, + ) + } + + return { + content: [ + { + type: "text", + text: `Cross Margin Assets: ${JSON.stringify(result, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Cross Margin Assets: ${JSON.stringify(result, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query cross margin assets: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to query cross margin assets: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginAllOrders.ts b/src/tools/binance-margin/cross-margin-api/crossMarginAllOrders.ts index 31fe94d4..a0e29503 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginAllOrders.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginAllOrders.ts @@ -1,46 +1,51 @@ // src/tools/binance-margin/cross-margin-api/crossMarginAllOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceCrossMarginAllOrders(server: McpServer) { - server.tool( - "BinanceCrossMarginAllOrders", - "Query all margin orders for a symbol. Returns both open and filled/cancelled orders.", - { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), - isIsolated: z.enum(["TRUE", "FALSE"]).optional().describe("For isolated margin or not"), - orderId: z.number().int().optional().describe("Order ID to start from"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z.number().int().optional().describe("Number of results (default 500, max 500)"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.getAllOrders({ - symbol: params.symbol, - ...(params.isIsolated && { isIsolated: params.isIsolated }), - ...(params.orderId && { orderId: params.orderId }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCrossMarginAllOrders", + "Query all margin orders for a symbol. Returns both open and filled/cancelled orders.", + { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), + isIsolated: z.enum(["TRUE", "FALSE"]).optional().describe("For isolated margin or not"), + orderId: z.number().int().optional().describe("Order ID to start from"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z.number().int().optional().describe("Number of results (default 500, max 500)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.getAllOrders({ + symbol: params.symbol, + ...(params.isIsolated && { isIsolated: params.isIsolated }), + ...(params.orderId && { orderId: params.orderId }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `All Margin Orders for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `All Margin Orders for ${params.symbol}: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query all orders: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to query all orders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginAvailableInventory.ts b/src/tools/binance-margin/cross-margin-api/crossMarginAvailableInventory.ts index e4daf4b4..0a600504 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginAvailableInventory.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginAvailableInventory.ts @@ -1,36 +1,43 @@ // src/tools/binance-margin/cross-margin-api/crossMarginAvailableInventory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceCrossMarginAvailableInventory(server: McpServer) { - server.tool( - "BinanceCrossMarginAvailableInventory", - "Query margin available inventory for borrowing.", - { - type: z.enum(["MARGIN", "ISOLATED"]).describe("Type of margin (MARGIN for cross, ISOLATED for isolated)"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.getAvailableInventory({ - type: params.type, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCrossMarginAvailableInventory", + "Query margin available inventory for borrowing.", + { + type: z + .enum(["MARGIN", "ISOLATED"]) + .describe("Type of margin (MARGIN for cross, ISOLATED for isolated)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.getAvailableInventory({ + type: params.type, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Margin Available Inventory: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Margin Available Inventory: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query available inventory: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to query available inventory: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginBorrow.ts b/src/tools/binance-margin/cross-margin-api/crossMarginBorrow.ts index c991330e..cfb6d67d 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginBorrow.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginBorrow.ts @@ -1,42 +1,50 @@ // src/tools/binance-margin/cross-margin-api/crossMarginBorrow.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceCrossMarginBorrow(server: McpServer) { - server.tool( - "BinanceCrossMarginBorrow", - "Borrow assets in Cross Margin account. Apply for a loan with the specified asset and amount.", - { - asset: z.string().describe("Asset to borrow (e.g., BTC, USDT)"), - amount: z.string().describe("Amount to borrow"), - isIsolated: z.enum(["TRUE", "FALSE"]).optional().describe("For isolated margin or not, default FALSE"), - symbol: z.string().optional().describe("Isolated symbol, required when isIsolated=TRUE"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.borrow({ - asset: params.asset, - amount: params.amount, - ...(params.isIsolated && { isIsolated: params.isIsolated }), - ...(params.symbol && { symbol: params.symbol }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCrossMarginBorrow", + "Borrow assets in Cross Margin account. Apply for a loan with the specified asset and amount.", + { + asset: z.string().describe("Asset to borrow (e.g., BTC, USDT)"), + amount: z.string().describe("Amount to borrow"), + isIsolated: z + .enum(["TRUE", "FALSE"]) + .optional() + .describe("For isolated margin or not, default FALSE"), + symbol: z.string().optional().describe("Isolated symbol, required when isIsolated=TRUE"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.borrow({ + asset: params.asset, + amount: params.amount, + ...(params.isIsolated && { isIsolated: params.isIsolated }), + ...(params.symbol && { symbol: params.symbol }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Successfully borrowed ${params.amount} ${params.asset} in Cross Margin. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Successfully borrowed ${params.amount} ${params.asset} in Cross Margin. Response: ${JSON.stringify(data)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to borrow: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to borrow: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginCancelAllOrders.ts b/src/tools/binance-margin/cross-margin-api/crossMarginCancelAllOrders.ts index 06f1ce00..f2e1ac9d 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginCancelAllOrders.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginCancelAllOrders.ts @@ -1,36 +1,41 @@ // src/tools/binance-margin/cross-margin-api/crossMarginCancelAllOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceCrossMarginCancelAllOrders(server: McpServer) { - server.tool( - "BinanceCrossMarginCancelAllOrders", - "Cancel all open margin orders for a specific trading pair. This will cancel all open orders on the symbol.", - { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.cancelAllOpenOrders({ - symbol: params.symbol, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCrossMarginCancelAllOrders", + "Cancel all open margin orders for a specific trading pair. This will cancel all open orders on the symbol.", + { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.cancelAllOpenOrders({ + symbol: params.symbol, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `All open margin orders cancelled for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `All open margin orders cancelled for ${params.symbol}: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to cancel all orders: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to cancel all orders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginCancelOrder.ts b/src/tools/binance-margin/cross-margin-api/crossMarginCancelOrder.ts index b8f29a00..a52c53cd 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginCancelOrder.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginCancelOrder.ts @@ -1,42 +1,50 @@ // src/tools/binance-margin/cross-margin-api/crossMarginCancelOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceCrossMarginCancelOrder(server: McpServer) { - server.tool( - "BinanceCrossMarginCancelOrder", - "Cancel an active margin order. Either orderId or origClientOrderId must be provided.", - { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), - orderId: z.number().int().optional().describe("Order ID to cancel"), - origClientOrderId: z.string().optional().describe("Original client order ID to cancel"), - newClientOrderId: z.string().optional().describe("New client order ID for the cancel request"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.cancelOrder({ - symbol: params.symbol, - ...(params.orderId && { orderId: params.orderId }), - ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), - ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCrossMarginCancelOrder", + "Cancel an active margin order. Either orderId or origClientOrderId must be provided.", + { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), + orderId: z.number().int().optional().describe("Order ID to cancel"), + origClientOrderId: z.string().optional().describe("Original client order ID to cancel"), + newClientOrderId: z + .string() + .optional() + .describe("New client order ID for the cancel request"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.cancelOrder({ + symbol: params.symbol, + ...(params.orderId && { orderId: params.orderId }), + ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), + ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Margin order cancelled successfully: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Margin order cancelled successfully: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to cancel margin order: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to cancel margin order: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginCapitalFlow.ts b/src/tools/binance-margin/cross-margin-api/crossMarginCapitalFlow.ts index 8bcde944..22ecb1e5 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginCapitalFlow.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginCapitalFlow.ts @@ -1,48 +1,68 @@ // src/tools/binance-margin/cross-margin-api/crossMarginCapitalFlow.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceCrossMarginCapitalFlow(server: McpServer) { - server.tool( - "BinanceCrossMarginCapitalFlow", - "Get cross margin capital flow history including transfers, borrows, repays, and interest.", - { - asset: z.string().optional().describe("Filter by asset symbol"), - symbol: z.string().optional().describe("Filter by trading pair symbol"), - type: z.enum(["TRANSFER_IN", "TRANSFER_OUT", "BORROW", "REPAY", "BUY_INCOME", "SELL_LOSS", "TRADING_COMMISSION", "LIQUIDATION", "INTEREST", "SMALL_LIABILITY_EXCHANGE", "SMALL_ASSETS_EXCHANGE"]).optional().describe("Type of capital flow"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - fromId: z.number().int().optional().describe("Start from ID"), - limit: z.number().int().optional().describe("Number of results (default 500, max 1000)"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.getCapitalFlow({ - ...(params.asset && { asset: params.asset }), - ...(params.symbol && { symbol: params.symbol }), - ...(params.type && { type: params.type }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.fromId && { fromId: params.fromId }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCrossMarginCapitalFlow", + "Get cross margin capital flow history including transfers, borrows, repays, and interest.", + { + asset: z.string().optional().describe("Filter by asset symbol"), + symbol: z.string().optional().describe("Filter by trading pair symbol"), + type: z + .enum([ + "TRANSFER_IN", + "TRANSFER_OUT", + "BORROW", + "REPAY", + "BUY_INCOME", + "SELL_LOSS", + "TRADING_COMMISSION", + "LIQUIDATION", + "INTEREST", + "SMALL_LIABILITY_EXCHANGE", + "SMALL_ASSETS_EXCHANGE", + ]) + .optional() + .describe("Type of capital flow"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + fromId: z.number().int().optional().describe("Start from ID"), + limit: z.number().int().optional().describe("Number of results (default 500, max 1000)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.getCapitalFlow({ + ...(params.asset && { asset: params.asset }), + ...(params.symbol && { symbol: params.symbol }), + ...(params.type && { type: params.type }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.fromId && { fromId: params.fromId }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Cross Margin Capital Flow: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Cross Margin Capital Flow: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get capital flow: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to get capital flow: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginDelist.ts b/src/tools/binance-margin/cross-margin-api/crossMarginDelist.ts index 34f9bf50..84589947 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginDelist.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginDelist.ts @@ -1,34 +1,39 @@ // src/tools/binance-margin/cross-margin-api/crossMarginDelist.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceCrossMarginDelist(server: McpServer) { - server.tool( - "BinanceCrossMarginDelist", - "Get delist schedule for cross margin trading pairs. Shows upcoming delistings.", - { - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.getDelistSchedule({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCrossMarginDelist", + "Get delist schedule for cross margin trading pairs. Shows upcoming delistings.", + { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.getDelistSchedule({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Cross Margin Delist Schedule: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Cross Margin Delist Schedule: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get delist schedule: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to get delist schedule: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginDustLog.ts b/src/tools/binance-margin/cross-margin-api/crossMarginDustLog.ts index 6460c28e..47896dd2 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginDustLog.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginDustLog.ts @@ -1,38 +1,43 @@ // src/tools/binance-margin/cross-margin-api/crossMarginDustLog.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceCrossMarginDustLog(server: McpServer) { - server.tool( - "BinanceCrossMarginDustLog", - "Query margin dust conversion log. Shows history of small balance conversions to BNB.", - { - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.getDustLog({ - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCrossMarginDustLog", + "Query margin dust conversion log. Shows history of small balance conversions to BNB.", + { + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.getDustLog({ + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Margin Dust Log: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Margin Dust Log: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query dust log: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to query dust log: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginFee.ts b/src/tools/binance-margin/cross-margin-api/crossMarginFee.ts index 783b9ad2..2a60cd2a 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginFee.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginFee.ts @@ -1,38 +1,47 @@ // src/tools/binance-margin/cross-margin-api/crossMarginFee.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceCrossMarginFee(server: McpServer) { - server.tool( - "BinanceCrossMarginFee", - "Query cross margin fee data including interest rates and collateral ratios for margin pairs.", - { - vipLevel: z.number().int().optional().describe("VIP level (default uses current account VIP level)"), - coin: z.string().optional().describe("Filter by specific coin"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.getCrossMarginFee({ - ...(params.vipLevel !== undefined && { vipLevel: params.vipLevel }), - ...(params.coin && { coin: params.coin }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCrossMarginFee", + "Query cross margin fee data including interest rates and collateral ratios for margin pairs.", + { + vipLevel: z + .number() + .int() + .optional() + .describe("VIP level (default uses current account VIP level)"), + coin: z.string().optional().describe("Filter by specific coin"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.getCrossMarginFee({ + ...(params.vipLevel !== undefined && { vipLevel: params.vipLevel }), + ...(params.coin && { coin: params.coin }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Cross Margin Fee Data: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Cross Margin Fee Data: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query cross margin fee: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to query cross margin fee: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginForceLiquidationRec.ts b/src/tools/binance-margin/cross-margin-api/crossMarginForceLiquidationRec.ts index 66a178b4..5f3ffc60 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginForceLiquidationRec.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginForceLiquidationRec.ts @@ -1,44 +1,49 @@ // src/tools/binance-margin/cross-margin-api/crossMarginForceLiquidationRec.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceCrossMarginForceLiquidationRec(server: McpServer) { - server.tool( - "BinanceCrossMarginForceLiquidationRec", - "Get force liquidation record for margin account. Shows historical liquidation events.", - { - isolatedSymbol: z.string().optional().describe("Isolated symbol for isolated margin"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - current: z.number().int().optional().describe("Current page (default 1)"), - size: z.number().int().optional().describe("Page size (default 10, max 100)"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.getForceLiquidationRecord({ - ...(params.isolatedSymbol && { isolatedSymbol: params.isolatedSymbol }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.current && { current: params.current }), - ...(params.size && { size: params.size }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCrossMarginForceLiquidationRec", + "Get force liquidation record for margin account. Shows historical liquidation events.", + { + isolatedSymbol: z.string().optional().describe("Isolated symbol for isolated margin"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + current: z.number().int().optional().describe("Current page (default 1)"), + size: z.number().int().optional().describe("Page size (default 10, max 100)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.getForceLiquidationRecord({ + ...(params.isolatedSymbol && { isolatedSymbol: params.isolatedSymbol }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.current && { current: params.current }), + ...(params.size && { size: params.size }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Force Liquidation Records: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Force Liquidation Records: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get liquidation records: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to get liquidation records: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginInterestHistory.ts b/src/tools/binance-margin/cross-margin-api/crossMarginInterestHistory.ts index ca834337..e7ae5531 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginInterestHistory.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginInterestHistory.ts @@ -1,48 +1,53 @@ // src/tools/binance-margin/cross-margin-api/crossMarginInterestHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceCrossMarginInterestHistory(server: McpServer) { - server.tool( - "BinanceCrossMarginInterestHistory", - "Query interest history for Cross Margin account.", - { - asset: z.string().optional().describe("Asset (e.g., BTC, USDT)"), - isolatedSymbol: z.string().optional().describe("Isolated symbol"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - current: z.number().int().optional().describe("Current page, default 1"), - size: z.number().int().optional().describe("Page size, default 10, max 100"), - archived: z.boolean().optional().describe("Query archived data, default false"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.getInterestHistory({ - ...(params.asset && { asset: params.asset }), - ...(params.isolatedSymbol && { isolatedSymbol: params.isolatedSymbol }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.current && { current: params.current }), - ...(params.size && { size: params.size }), - ...(params.archived !== undefined && { archived: params.archived }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCrossMarginInterestHistory", + "Query interest history for Cross Margin account.", + { + asset: z.string().optional().describe("Asset (e.g., BTC, USDT)"), + isolatedSymbol: z.string().optional().describe("Isolated symbol"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + current: z.number().int().optional().describe("Current page, default 1"), + size: z.number().int().optional().describe("Page size, default 10, max 100"), + archived: z.boolean().optional().describe("Query archived data, default false"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.getInterestHistory({ + ...(params.asset && { asset: params.asset }), + ...(params.isolatedSymbol && { isolatedSymbol: params.isolatedSymbol }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.current && { current: params.current }), + ...(params.size && { size: params.size }), + ...(params.archived !== undefined && { archived: params.archived }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Interest History: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Interest History: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query interest history: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to query interest history: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginInterestRateHistory.ts b/src/tools/binance-margin/cross-margin-api/crossMarginInterestRateHistory.ts index 9bec7ca5..a5337da6 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginInterestRateHistory.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginInterestRateHistory.ts @@ -1,42 +1,53 @@ // src/tools/binance-margin/cross-margin-api/crossMarginInterestRateHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceCrossMarginInterestRateHistory(server: McpServer) { - server.tool( - "BinanceCrossMarginInterestRateHistory", - "Query margin interest rate history for a specific asset.", - { - asset: z.string().describe("Asset symbol (e.g., BTC, USDT)"), - vipLevel: z.number().int().optional().describe("VIP level (default uses current account VIP level)"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.getInterestRateHistory({ - asset: params.asset, - ...(params.vipLevel !== undefined && { vipLevel: params.vipLevel }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCrossMarginInterestRateHistory", + "Query margin interest rate history for a specific asset.", + { + asset: z.string().describe("Asset symbol (e.g., BTC, USDT)"), + vipLevel: z + .number() + .int() + .optional() + .describe("VIP level (default uses current account VIP level)"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.getInterestRateHistory({ + asset: params.asset, + ...(params.vipLevel !== undefined && { vipLevel: params.vipLevel }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Margin Interest Rate History for ${params.asset}: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Margin Interest Rate History for ${params.asset}: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query interest rate history: ${errorMessage}` }], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to query interest rate history: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginLoanRecord.ts b/src/tools/binance-margin/cross-margin-api/crossMarginLoanRecord.ts index 55079602..b331c912 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginLoanRecord.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginLoanRecord.ts @@ -1,50 +1,55 @@ // src/tools/binance-margin/cross-margin-api/crossMarginLoanRecord.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceCrossMarginLoanRecord(server: McpServer) { - server.tool( - "BinanceCrossMarginLoanRecord", - "Query loan record for Cross Margin account.", - { - asset: z.string().describe("Asset (e.g., BTC, USDT)"), - isolatedSymbol: z.string().optional().describe("Isolated symbol"), - txId: z.number().int().optional().describe("Transaction ID"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - current: z.number().int().optional().describe("Current page, default 1"), - size: z.number().int().optional().describe("Page size, default 10, max 100"), - archived: z.boolean().optional().describe("Query archived data, default false"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.getLoanRecord({ - asset: params.asset, - ...(params.isolatedSymbol && { isolatedSymbol: params.isolatedSymbol }), - ...(params.txId && { txId: params.txId }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.current && { current: params.current }), - ...(params.size && { size: params.size }), - ...(params.archived !== undefined && { archived: params.archived }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCrossMarginLoanRecord", + "Query loan record for Cross Margin account.", + { + asset: z.string().describe("Asset (e.g., BTC, USDT)"), + isolatedSymbol: z.string().optional().describe("Isolated symbol"), + txId: z.number().int().optional().describe("Transaction ID"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + current: z.number().int().optional().describe("Current page, default 1"), + size: z.number().int().optional().describe("Page size, default 10, max 100"), + archived: z.boolean().optional().describe("Query archived data, default false"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.getLoanRecord({ + asset: params.asset, + ...(params.isolatedSymbol && { isolatedSymbol: params.isolatedSymbol }), + ...(params.txId && { txId: params.txId }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.current && { current: params.current }), + ...(params.size && { size: params.size }), + ...(params.archived !== undefined && { archived: params.archived }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Loan Records: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Loan Records: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query loan records: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to query loan records: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginMaxBorrowable.ts b/src/tools/binance-margin/cross-margin-api/crossMarginMaxBorrowable.ts index 9c5c3fba..8fd2534e 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginMaxBorrowable.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginMaxBorrowable.ts @@ -1,38 +1,43 @@ // src/tools/binance-margin/cross-margin-api/crossMarginMaxBorrowable.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceCrossMarginMaxBorrowable(server: McpServer) { - server.tool( - "BinanceCrossMarginMaxBorrowable", - "Query maximum borrowable amount for an asset in Cross Margin.", - { - asset: z.string().describe("Asset (e.g., BTC, USDT)"), - isolatedSymbol: z.string().optional().describe("Isolated symbol"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.getMaxBorrowable({ - asset: params.asset, - ...(params.isolatedSymbol && { isolatedSymbol: params.isolatedSymbol }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCrossMarginMaxBorrowable", + "Query maximum borrowable amount for an asset in Cross Margin.", + { + asset: z.string().describe("Asset (e.g., BTC, USDT)"), + isolatedSymbol: z.string().optional().describe("Isolated symbol"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.getMaxBorrowable({ + asset: params.asset, + ...(params.isolatedSymbol && { isolatedSymbol: params.isolatedSymbol }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Max Borrowable for ${params.asset}: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Max Borrowable for ${params.asset}: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query max borrowable: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to query max borrowable: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginMaxTransferable.ts b/src/tools/binance-margin/cross-margin-api/crossMarginMaxTransferable.ts index 240511f6..d2565e0f 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginMaxTransferable.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginMaxTransferable.ts @@ -1,38 +1,43 @@ // src/tools/binance-margin/cross-margin-api/crossMarginMaxTransferable.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceCrossMarginMaxTransferable(server: McpServer) { - server.tool( - "BinanceCrossMarginMaxTransferable", - "Query maximum transferable amount for an asset in Cross Margin.", - { - asset: z.string().describe("Asset (e.g., BTC, USDT)"), - isolatedSymbol: z.string().optional().describe("Isolated symbol"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.getMaxTransferable({ - asset: params.asset, - ...(params.isolatedSymbol && { isolatedSymbol: params.isolatedSymbol }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCrossMarginMaxTransferable", + "Query maximum transferable amount for an asset in Cross Margin.", + { + asset: z.string().describe("Asset (e.g., BTC, USDT)"), + isolatedSymbol: z.string().optional().describe("Isolated symbol"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.getMaxTransferable({ + asset: params.asset, + ...(params.isolatedSymbol && { isolatedSymbol: params.isolatedSymbol }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Max Transferable for ${params.asset}: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Max Transferable for ${params.asset}: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query max transferable: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to query max transferable: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginMyTrades.ts b/src/tools/binance-margin/cross-margin-api/crossMarginMyTrades.ts index b59454fb..4ef22ca7 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginMyTrades.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginMyTrades.ts @@ -1,48 +1,53 @@ // src/tools/binance-margin/cross-margin-api/crossMarginMyTrades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceCrossMarginMyTrades(server: McpServer) { - server.tool( - "BinanceCrossMarginMyTrades", - "Query margin account trade history for a specific symbol.", - { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), - isIsolated: z.enum(["TRUE", "FALSE"]).optional().describe("For isolated margin or not"), - orderId: z.number().int().optional().describe("Filter by order ID"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - fromId: z.number().int().optional().describe("Trade ID to start from"), - limit: z.number().int().optional().describe("Number of results (default 500, max 1000)"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.getMyTrades({ - symbol: params.symbol, - ...(params.isIsolated && { isIsolated: params.isIsolated }), - ...(params.orderId && { orderId: params.orderId }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.fromId && { fromId: params.fromId }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCrossMarginMyTrades", + "Query margin account trade history for a specific symbol.", + { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), + isIsolated: z.enum(["TRUE", "FALSE"]).optional().describe("For isolated margin or not"), + orderId: z.number().int().optional().describe("Filter by order ID"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + fromId: z.number().int().optional().describe("Trade ID to start from"), + limit: z.number().int().optional().describe("Number of results (default 500, max 1000)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.getMyTrades({ + symbol: params.symbol, + ...(params.isIsolated && { isIsolated: params.isIsolated }), + ...(params.orderId && { orderId: params.orderId }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.fromId && { fromId: params.fromId }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Margin Trades for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Margin Trades for ${params.symbol}: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query trades: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to query trades: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginNewOrder.ts b/src/tools/binance-margin/cross-margin-api/crossMarginNewOrder.ts index 5cae320d..c51804e3 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginNewOrder.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginNewOrder.ts @@ -1,62 +1,90 @@ // src/tools/binance-margin/cross-margin-api/crossMarginNewOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceCrossMarginNewOrder(server: McpServer) { - server.tool( - "BinanceCrossMarginNewOrder", - "Post a new margin order in Cross Margin account. Supports various order types including LIMIT, MARKET, STOP_LOSS, etc.", - { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Order side"), - type: z.enum(["LIMIT", "MARKET", "STOP_LOSS", "STOP_LOSS_LIMIT", "TAKE_PROFIT", "TAKE_PROFIT_LIMIT", "LIMIT_MAKER"]).describe("Order type"), - quantity: z.string().optional().describe("Order quantity"), - quoteOrderQty: z.string().optional().describe("Quote order quantity for MARKET orders"), - price: z.string().optional().describe("Order price (required for LIMIT orders)"), - stopPrice: z.string().optional().describe("Stop price for STOP_LOSS and TAKE_PROFIT orders"), - newClientOrderId: z.string().optional().describe("Unique client order ID"), - icebergQty: z.string().optional().describe("Iceberg quantity"), - newOrderRespType: z.enum(["ACK", "RESULT", "FULL"]).optional().describe("Response type"), - sideEffectType: z.enum(["NO_SIDE_EFFECT", "MARGIN_BUY", "AUTO_REPAY", "AUTO_BORROW_REPAY"]).optional().describe("Side effect type for margin orders"), - timeInForce: z.enum(["GTC", "IOC", "FOK"]).optional().describe("Time in force"), - selfTradePreventionMode: z.enum(["EXPIRE_TAKER", "EXPIRE_MAKER", "EXPIRE_BOTH", "NONE"]).optional().describe("Self-trade prevention mode"), - autoRepayAtCancel: z.boolean().optional().describe("Auto repay at cancel, only for AUTO_BORROW_REPAY"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.newOrder({ - symbol: params.symbol, - side: params.side, - type: params.type, - ...(params.quantity && { quantity: params.quantity }), - ...(params.quoteOrderQty && { quoteOrderQty: params.quoteOrderQty }), - ...(params.price && { price: params.price }), - ...(params.stopPrice && { stopPrice: params.stopPrice }), - ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), - ...(params.icebergQty && { icebergQty: params.icebergQty }), - ...(params.newOrderRespType && { newOrderRespType: params.newOrderRespType }), - ...(params.sideEffectType && { sideEffectType: params.sideEffectType }), - ...(params.timeInForce && { timeInForce: params.timeInForce }), - ...(params.selfTradePreventionMode && { selfTradePreventionMode: params.selfTradePreventionMode }), - ...(params.autoRepayAtCancel !== undefined && { autoRepayAtCancel: params.autoRepayAtCancel }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCrossMarginNewOrder", + "Post a new margin order in Cross Margin account. Supports various order types including LIMIT, MARKET, STOP_LOSS, etc.", + { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Order side"), + type: z + .enum([ + "LIMIT", + "MARKET", + "STOP_LOSS", + "STOP_LOSS_LIMIT", + "TAKE_PROFIT", + "TAKE_PROFIT_LIMIT", + "LIMIT_MAKER", + ]) + .describe("Order type"), + quantity: z.string().optional().describe("Order quantity"), + quoteOrderQty: z.string().optional().describe("Quote order quantity for MARKET orders"), + price: z.string().optional().describe("Order price (required for LIMIT orders)"), + stopPrice: z.string().optional().describe("Stop price for STOP_LOSS and TAKE_PROFIT orders"), + newClientOrderId: z.string().optional().describe("Unique client order ID"), + icebergQty: z.string().optional().describe("Iceberg quantity"), + newOrderRespType: z.enum(["ACK", "RESULT", "FULL"]).optional().describe("Response type"), + sideEffectType: z + .enum(["NO_SIDE_EFFECT", "MARGIN_BUY", "AUTO_REPAY", "AUTO_BORROW_REPAY"]) + .optional() + .describe("Side effect type for margin orders"), + timeInForce: z.enum(["GTC", "IOC", "FOK"]).optional().describe("Time in force"), + selfTradePreventionMode: z + .enum(["EXPIRE_TAKER", "EXPIRE_MAKER", "EXPIRE_BOTH", "NONE"]) + .optional() + .describe("Self-trade prevention mode"), + autoRepayAtCancel: z + .boolean() + .optional() + .describe("Auto repay at cancel, only for AUTO_BORROW_REPAY"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.newOrder({ + symbol: params.symbol, + side: params.side, + type: params.type, + ...(params.quantity && { quantity: params.quantity }), + ...(params.quoteOrderQty && { quoteOrderQty: params.quoteOrderQty }), + ...(params.price && { price: params.price }), + ...(params.stopPrice && { stopPrice: params.stopPrice }), + ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), + ...(params.icebergQty && { icebergQty: params.icebergQty }), + ...(params.newOrderRespType && { newOrderRespType: params.newOrderRespType }), + ...(params.sideEffectType && { sideEffectType: params.sideEffectType }), + ...(params.timeInForce && { timeInForce: params.timeInForce }), + ...(params.selfTradePreventionMode && { + selfTradePreventionMode: params.selfTradePreventionMode, + }), + ...(params.autoRepayAtCancel !== undefined && { + autoRepayAtCancel: params.autoRepayAtCancel, + }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Cross Margin order placed successfully: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Cross Margin order placed successfully: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to place margin order: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to place margin order: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginOpenOrders.ts b/src/tools/binance-margin/cross-margin-api/crossMarginOpenOrders.ts index 013947cb..2d1e258c 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginOpenOrders.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginOpenOrders.ts @@ -1,38 +1,43 @@ // src/tools/binance-margin/cross-margin-api/crossMarginOpenOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceCrossMarginOpenOrders(server: McpServer) { - server.tool( - "BinanceCrossMarginOpenOrders", - "Query all open margin orders. If symbol is provided, only orders for that symbol are returned.", - { - symbol: z.string().optional().describe("Trading pair symbol (e.g., BTCUSDT)"), - isIsolated: z.enum(["TRUE", "FALSE"]).optional().describe("For isolated margin or not"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.getOpenOrders({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.isIsolated && { isIsolated: params.isIsolated }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCrossMarginOpenOrders", + "Query all open margin orders. If symbol is provided, only orders for that symbol are returned.", + { + symbol: z.string().optional().describe("Trading pair symbol (e.g., BTCUSDT)"), + isIsolated: z.enum(["TRUE", "FALSE"]).optional().describe("For isolated margin or not"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.getOpenOrders({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.isIsolated && { isIsolated: params.isIsolated }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Open Margin Orders: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Open Margin Orders: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query open orders: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to query open orders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginPairs.ts b/src/tools/binance-margin/cross-margin-api/crossMarginPairs.ts index 0e9133e5..dffea1c1 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginPairs.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginPairs.ts @@ -1,34 +1,39 @@ // src/tools/binance-margin/cross-margin-api/crossMarginPairs.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceCrossMarginPairs(server: McpServer) { - server.tool( - "BinanceCrossMarginPairs", - "Get all cross margin trading pairs. Returns information about all available cross margin pairs including base/quote assets and margin ratio.", - { - symbol: z.string().optional().describe("Filter by specific trading pair symbol") - }, - async (params) => { - try { - const data = await marginClient.getAllPairs({ - ...(params.symbol && { symbol: params.symbol }) - }); + server.tool( + "BinanceCrossMarginPairs", + "Get all cross margin trading pairs. Returns information about all available cross margin pairs including base/quote assets and margin ratio.", + { + symbol: z.string().optional().describe("Filter by specific trading pair symbol"), + }, + async (params) => { + try { + const data = await marginClient.getAllPairs({ + ...(params.symbol && { symbol: params.symbol }), + }) + + return { + content: [ + { + type: "text", + text: `Cross Margin Pairs: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Cross Margin Pairs: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get cross margin pairs: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to get cross margin pairs: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginPriceIndex.ts b/src/tools/binance-margin/cross-margin-api/crossMarginPriceIndex.ts index e2452907..8f7318e4 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginPriceIndex.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginPriceIndex.ts @@ -1,34 +1,39 @@ // src/tools/binance-margin/cross-margin-api/crossMarginPriceIndex.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceCrossMarginPriceIndex(server: McpServer) { - server.tool( - "BinanceCrossMarginPriceIndex", - "Query margin price index for a specific trading pair. Returns the current price index used for margin calculations.", - { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)") - }, - async (params) => { - try { - const data = await marginClient.getPriceIndex({ - symbol: params.symbol - }); + server.tool( + "BinanceCrossMarginPriceIndex", + "Query margin price index for a specific trading pair. Returns the current price index used for margin calculations.", + { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), + }, + async (params) => { + try { + const data = await marginClient.getPriceIndex({ + symbol: params.symbol, + }) + + return { + content: [ + { + type: "text", + text: `Margin Price Index for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Margin Price Index for ${params.symbol}: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query price index: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to query price index: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginRepay.ts b/src/tools/binance-margin/cross-margin-api/crossMarginRepay.ts index 2b0d3c97..f6775e39 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginRepay.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginRepay.ts @@ -1,42 +1,50 @@ // src/tools/binance-margin/cross-margin-api/crossMarginRepay.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceCrossMarginRepay(server: McpServer) { - server.tool( - "BinanceCrossMarginRepay", - "Repay loan for Cross Margin account. Repay the borrowed asset with the specified amount.", - { - asset: z.string().describe("Asset to repay (e.g., BTC, USDT)"), - amount: z.string().describe("Amount to repay"), - isIsolated: z.enum(["TRUE", "FALSE"]).optional().describe("For isolated margin or not, default FALSE"), - symbol: z.string().optional().describe("Isolated symbol, required when isIsolated=TRUE"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.repay({ - asset: params.asset, - amount: params.amount, - ...(params.isIsolated && { isIsolated: params.isIsolated }), - ...(params.symbol && { symbol: params.symbol }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCrossMarginRepay", + "Repay loan for Cross Margin account. Repay the borrowed asset with the specified amount.", + { + asset: z.string().describe("Asset to repay (e.g., BTC, USDT)"), + amount: z.string().describe("Amount to repay"), + isIsolated: z + .enum(["TRUE", "FALSE"]) + .optional() + .describe("For isolated margin or not, default FALSE"), + symbol: z.string().optional().describe("Isolated symbol, required when isIsolated=TRUE"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.repay({ + asset: params.asset, + amount: params.amount, + ...(params.isIsolated && { isIsolated: params.isIsolated }), + ...(params.symbol && { symbol: params.symbol }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Successfully repaid ${params.amount} ${params.asset} in Cross Margin. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Successfully repaid ${params.amount} ${params.asset} in Cross Margin. Response: ${JSON.stringify(data)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to repay: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to repay: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginRepayRecord.ts b/src/tools/binance-margin/cross-margin-api/crossMarginRepayRecord.ts index 75e39f5a..da30984c 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginRepayRecord.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginRepayRecord.ts @@ -1,50 +1,55 @@ // src/tools/binance-margin/cross-margin-api/crossMarginRepayRecord.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceCrossMarginRepayRecord(server: McpServer) { - server.tool( - "BinanceCrossMarginRepayRecord", - "Query repay record for Cross Margin account.", - { - asset: z.string().describe("Asset (e.g., BTC, USDT)"), - isolatedSymbol: z.string().optional().describe("Isolated symbol"), - txId: z.number().int().optional().describe("Transaction ID"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - current: z.number().int().optional().describe("Current page, default 1"), - size: z.number().int().optional().describe("Page size, default 10, max 100"), - archived: z.boolean().optional().describe("Query archived data, default false"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.getRepayRecord({ - asset: params.asset, - ...(params.isolatedSymbol && { isolatedSymbol: params.isolatedSymbol }), - ...(params.txId && { txId: params.txId }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.current && { current: params.current }), - ...(params.size && { size: params.size }), - ...(params.archived !== undefined && { archived: params.archived }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCrossMarginRepayRecord", + "Query repay record for Cross Margin account.", + { + asset: z.string().describe("Asset (e.g., BTC, USDT)"), + isolatedSymbol: z.string().optional().describe("Isolated symbol"), + txId: z.number().int().optional().describe("Transaction ID"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + current: z.number().int().optional().describe("Current page, default 1"), + size: z.number().int().optional().describe("Page size, default 10, max 100"), + archived: z.boolean().optional().describe("Query archived data, default false"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.getRepayRecord({ + asset: params.asset, + ...(params.isolatedSymbol && { isolatedSymbol: params.isolatedSymbol }), + ...(params.txId && { txId: params.txId }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.current && { current: params.current }), + ...(params.size && { size: params.size }), + ...(params.archived !== undefined && { archived: params.archived }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Repay Records: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Repay Records: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query repay records: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to query repay records: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginSmallLiabilityExchange.ts b/src/tools/binance-margin/cross-margin-api/crossMarginSmallLiabilityExchange.ts index 25d8faac..dc53017d 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginSmallLiabilityExchange.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginSmallLiabilityExchange.ts @@ -1,36 +1,43 @@ // src/tools/binance-margin/cross-margin-api/crossMarginSmallLiabilityExchange.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceCrossMarginSmallLiabilityExchange(server: McpServer) { - server.tool( - "BinanceCrossMarginSmallLiabilityExchange", - "Cross margin small liability exchange. Converts small liabilities to a single asset.", - { - assetNames: z.array(z.string()).describe("Array of asset names to exchange (e.g., ['BTC', 'ETH'])"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.smallLiabilityExchange({ - assetNames: params.assetNames.join(","), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCrossMarginSmallLiabilityExchange", + "Cross margin small liability exchange. Converts small liabilities to a single asset.", + { + assetNames: z + .array(z.string()) + .describe("Array of asset names to exchange (e.g., ['BTC', 'ETH'])"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.smallLiabilityExchange({ + assetNames: params.assetNames.join(","), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Small liability exchange completed: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Small liability exchange completed: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to exchange small liability: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to exchange small liability: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginSmallLiabilityExchangeHistory.ts b/src/tools/binance-margin/cross-margin-api/crossMarginSmallLiabilityExchangeHistory.ts index 1f680f73..c773bea5 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginSmallLiabilityExchangeHistory.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginSmallLiabilityExchangeHistory.ts @@ -1,42 +1,47 @@ // src/tools/binance-margin/cross-margin-api/crossMarginSmallLiabilityExchangeHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceCrossMarginSmallLiabilityExchangeHistory(server: McpServer) { - server.tool( - "BinanceCrossMarginSmallLiabilityExchangeHistory", - "Get cross margin small liability exchange history.", - { - current: z.number().int().optional().describe("Current page (default 1)"), - size: z.number().int().optional().describe("Page size (default 10, max 100)"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.getSmallLiabilityExchangeHistory({ - ...(params.current && { current: params.current }), - ...(params.size && { size: params.size }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCrossMarginSmallLiabilityExchangeHistory", + "Get cross margin small liability exchange history.", + { + current: z.number().int().optional().describe("Current page (default 1)"), + size: z.number().int().optional().describe("Page size (default 10, max 100)"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.getSmallLiabilityExchangeHistory({ + ...(params.current && { current: params.current }), + ...(params.size && { size: params.size }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Small Liability Exchange History: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Small Liability Exchange History: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get exchange history: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to get exchange history: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginTransfer.ts b/src/tools/binance-margin/cross-margin-api/crossMarginTransfer.ts index fe41def0..e1686f80 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginTransfer.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginTransfer.ts @@ -1,40 +1,45 @@ // src/tools/binance-margin/cross-margin-api/crossMarginTransfer.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceCrossMarginTransfer(server: McpServer) { - server.tool( - "BinanceCrossMarginTransfer", - "Execute a cross margin account transfer. Transfer between spot and cross margin accounts.", - { - asset: z.string().describe("Asset to transfer (e.g., BTC, USDT)"), - amount: z.string().describe("Amount to transfer"), - type: z.enum(["1", "2"]).describe("1: Spot to Margin, 2: Margin to Spot"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.transfer({ - asset: params.asset, - amount: params.amount, - type: parseInt(params.type), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCrossMarginTransfer", + "Execute a cross margin account transfer. Transfer between spot and cross margin accounts.", + { + asset: z.string().describe("Asset to transfer (e.g., BTC, USDT)"), + amount: z.string().describe("Amount to transfer"), + type: z.enum(["1", "2"]).describe("1: Spot to Margin, 2: Margin to Spot"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.transfer({ + asset: params.asset, + amount: params.amount, + type: parseInt(params.type), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Successfully transferred ${params.amount} ${params.asset}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Successfully transferred ${params.amount} ${params.asset}. Response: ${JSON.stringify(data)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to transfer: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to transfer: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/cross-margin-api/index.ts b/src/tools/binance-margin/cross-margin-api/index.ts index ed39dd80..66bfeb26 100644 --- a/src/tools/binance-margin/cross-margin-api/index.ts +++ b/src/tools/binance-margin/cross-margin-api/index.ts @@ -1,68 +1,69 @@ // src/tools/binance-margin/cross-margin-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceCrossMarginBorrow } from "./crossMarginBorrow.js"; -import { registerBinanceCrossMarginRepay } from "./crossMarginRepay.js"; -import { registerBinanceCrossMarginAccount } from "./crossMarginAccount.js"; -import { registerBinanceCrossMarginTransfer } from "./crossMarginTransfer.js"; -import { registerBinanceCrossMarginInterestHistory } from "./crossMarginInterestHistory.js"; -import { registerBinanceCrossMarginLoanRecord } from "./crossMarginLoanRecord.js"; -import { registerBinanceCrossMarginRepayRecord } from "./crossMarginRepayRecord.js"; -import { registerBinanceCrossMarginMaxBorrowable } from "./crossMarginMaxBorrowable.js"; -import { registerBinanceCrossMarginMaxTransferable } from "./crossMarginMaxTransferable.js"; -import { registerBinanceCrossMarginPairs } from "./crossMarginPairs.js"; -import { registerBinanceCrossMarginPriceIndex } from "./crossMarginPriceIndex.js"; -import { registerBinanceCrossMarginNewOrder } from "./crossMarginNewOrder.js"; -import { registerBinanceCrossMarginCancelOrder } from "./crossMarginCancelOrder.js"; -import { registerBinanceCrossMarginCancelAllOrders } from "./crossMarginCancelAllOrders.js"; -import { registerBinanceCrossMarginOpenOrders } from "./crossMarginOpenOrders.js"; -import { registerBinanceCrossMarginAllOrders } from "./crossMarginAllOrders.js"; -import { registerBinanceCrossMarginMyTrades } from "./crossMarginMyTrades.js"; -import { registerBinanceCrossMarginForceLiquidationRec } from "./crossMarginForceLiquidationRec.js"; -import { registerBinanceCrossMarginInterestRateHistory } from "./crossMarginInterestRateHistory.js"; -import { registerBinanceCrossMarginFee } from "./crossMarginFee.js"; -import { registerBinanceCrossMarginDustLog } from "./crossMarginDustLog.js"; -import { registerBinanceCrossMarginSmallLiabilityExchange } from "./crossMarginSmallLiabilityExchange.js"; -import { registerBinanceCrossMarginSmallLiabilityExchangeHistory } from "./crossMarginSmallLiabilityExchangeHistory.js"; -import { registerBinanceCrossMarginAvailableInventory } from "./crossMarginAvailableInventory.js"; -import { registerBinanceCrossMarginCapitalFlow } from "./crossMarginCapitalFlow.js"; -import { registerBinanceCrossMarginDelist } from "./crossMarginDelist.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceCrossMarginAccount } from "./crossMarginAccount.js" +import { registerBinanceCrossMarginAllOrders } from "./crossMarginAllOrders.js" +import { registerBinanceCrossMarginAvailableInventory } from "./crossMarginAvailableInventory.js" +import { registerBinanceCrossMarginBorrow } from "./crossMarginBorrow.js" +import { registerBinanceCrossMarginCancelAllOrders } from "./crossMarginCancelAllOrders.js" +import { registerBinanceCrossMarginCancelOrder } from "./crossMarginCancelOrder.js" +import { registerBinanceCrossMarginCapitalFlow } from "./crossMarginCapitalFlow.js" +import { registerBinanceCrossMarginDelist } from "./crossMarginDelist.js" +import { registerBinanceCrossMarginDustLog } from "./crossMarginDustLog.js" +import { registerBinanceCrossMarginFee } from "./crossMarginFee.js" +import { registerBinanceCrossMarginForceLiquidationRec } from "./crossMarginForceLiquidationRec.js" +import { registerBinanceCrossMarginInterestHistory } from "./crossMarginInterestHistory.js" +import { registerBinanceCrossMarginInterestRateHistory } from "./crossMarginInterestRateHistory.js" +import { registerBinanceCrossMarginLoanRecord } from "./crossMarginLoanRecord.js" +import { registerBinanceCrossMarginMaxBorrowable } from "./crossMarginMaxBorrowable.js" +import { registerBinanceCrossMarginMaxTransferable } from "./crossMarginMaxTransferable.js" +import { registerBinanceCrossMarginMyTrades } from "./crossMarginMyTrades.js" +import { registerBinanceCrossMarginNewOrder } from "./crossMarginNewOrder.js" +import { registerBinanceCrossMarginOpenOrders } from "./crossMarginOpenOrders.js" +import { registerBinanceCrossMarginPairs } from "./crossMarginPairs.js" +import { registerBinanceCrossMarginPriceIndex } from "./crossMarginPriceIndex.js" +import { registerBinanceCrossMarginRepay } from "./crossMarginRepay.js" +import { registerBinanceCrossMarginRepayRecord } from "./crossMarginRepayRecord.js" +import { registerBinanceCrossMarginSmallLiabilityExchange } from "./crossMarginSmallLiabilityExchange.js" +import { registerBinanceCrossMarginSmallLiabilityExchangeHistory } from "./crossMarginSmallLiabilityExchangeHistory.js" +import { registerBinanceCrossMarginTransfer } from "./crossMarginTransfer.js" export function registerBinanceCrossMarginTools(server: McpServer) { - // Borrow & Repay - registerBinanceCrossMarginBorrow(server); - registerBinanceCrossMarginRepay(server); - - // Account & Transfer - registerBinanceCrossMarginAccount(server); - registerBinanceCrossMarginTransfer(server); - registerBinanceCrossMarginCapitalFlow(server); - - // Records & History - registerBinanceCrossMarginInterestHistory(server); - registerBinanceCrossMarginLoanRecord(server); - registerBinanceCrossMarginRepayRecord(server); - registerBinanceCrossMarginInterestRateHistory(server); - registerBinanceCrossMarginForceLiquidationRec(server); - - // Limits & Info - registerBinanceCrossMarginMaxBorrowable(server); - registerBinanceCrossMarginMaxTransferable(server); - registerBinanceCrossMarginPairs(server); - registerBinanceCrossMarginPriceIndex(server); - registerBinanceCrossMarginFee(server); - registerBinanceCrossMarginAvailableInventory(server); - registerBinanceCrossMarginDelist(server); - - // Trading - registerBinanceCrossMarginNewOrder(server); - registerBinanceCrossMarginCancelOrder(server); - registerBinanceCrossMarginCancelAllOrders(server); - registerBinanceCrossMarginOpenOrders(server); - registerBinanceCrossMarginAllOrders(server); - registerBinanceCrossMarginMyTrades(server); - - // Other - registerBinanceCrossMarginDustLog(server); - registerBinanceCrossMarginSmallLiabilityExchange(server); - registerBinanceCrossMarginSmallLiabilityExchangeHistory(server); + // Borrow & Repay + registerBinanceCrossMarginBorrow(server) + registerBinanceCrossMarginRepay(server) + + // Account & Transfer + registerBinanceCrossMarginAccount(server) + registerBinanceCrossMarginTransfer(server) + registerBinanceCrossMarginCapitalFlow(server) + + // Records & History + registerBinanceCrossMarginInterestHistory(server) + registerBinanceCrossMarginLoanRecord(server) + registerBinanceCrossMarginRepayRecord(server) + registerBinanceCrossMarginInterestRateHistory(server) + registerBinanceCrossMarginForceLiquidationRec(server) + + // Limits & Info + registerBinanceCrossMarginMaxBorrowable(server) + registerBinanceCrossMarginMaxTransferable(server) + registerBinanceCrossMarginPairs(server) + registerBinanceCrossMarginPriceIndex(server) + registerBinanceCrossMarginFee(server) + registerBinanceCrossMarginAvailableInventory(server) + registerBinanceCrossMarginDelist(server) + + // Trading + registerBinanceCrossMarginNewOrder(server) + registerBinanceCrossMarginCancelOrder(server) + registerBinanceCrossMarginCancelAllOrders(server) + registerBinanceCrossMarginOpenOrders(server) + registerBinanceCrossMarginAllOrders(server) + registerBinanceCrossMarginMyTrades(server) + + // Other + registerBinanceCrossMarginDustLog(server) + registerBinanceCrossMarginSmallLiabilityExchange(server) + registerBinanceCrossMarginSmallLiabilityExchangeHistory(server) } diff --git a/src/tools/binance-margin/index.ts b/src/tools/binance-margin/index.ts index d8d1164b..1783b0d2 100644 --- a/src/tools/binance-margin/index.ts +++ b/src/tools/binance-margin/index.ts @@ -1,12 +1,13 @@ // src/tools/binance-margin/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceCrossMarginTools } from "./cross-margin-api/index.js"; -import { registerBinanceIsolatedMarginTools } from "./isolated-margin-api/index.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceCrossMarginTools } from "./cross-margin-api/index.js" +import { registerBinanceIsolatedMarginTools } from "./isolated-margin-api/index.js" export function registerBinanceMarginTools(server: McpServer) { - // Cross Margin API tools - registerBinanceCrossMarginTools(server); - - // Isolated Margin API tools - registerBinanceIsolatedMarginTools(server); + // Cross Margin API tools + registerBinanceCrossMarginTools(server) + + // Isolated Margin API tools + registerBinanceIsolatedMarginTools(server) } diff --git a/src/tools/binance-margin/isolated-margin-api/disableIsolatedMarginAccount.ts b/src/tools/binance-margin/isolated-margin-api/disableIsolatedMarginAccount.ts index aae1b2dd..8db93201 100644 --- a/src/tools/binance-margin/isolated-margin-api/disableIsolatedMarginAccount.ts +++ b/src/tools/binance-margin/isolated-margin-api/disableIsolatedMarginAccount.ts @@ -5,39 +5,45 @@ * @license Apache-2.0 */ // src/tools/binance-margin/isolated-margin-api/disableIsolatedMarginAccount.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceDisableIsolatedMarginAccount(server: McpServer) { - server.tool( - "BinanceDisableIsolatedMarginAccount", - "Disable isolated margin account for a specific symbol. All assets must be transferred out first.", - { - symbol: z.string().describe("Symbol to disable isolated margin for (e.g., BTCUSDT)"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await marginClient.restAPI.disableIsolatedMarginAccount({ - symbol: params.symbol, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceDisableIsolatedMarginAccount", + "Disable isolated margin account for a specific symbol. All assets must be transferred out first.", + { + symbol: z.string().describe("Symbol to disable isolated margin for (e.g., BTCUSDT)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await marginClient.restAPI.disableIsolatedMarginAccount({ + symbol: params.symbol, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Isolated margin account disabled for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Isolated margin account disabled for ${params.symbol}: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to disable isolated margin: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to disable isolated margin: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/isolated-margin-api/enableIsolatedMarginAccount.ts b/src/tools/binance-margin/isolated-margin-api/enableIsolatedMarginAccount.ts index fbe71060..4d13aa7e 100644 --- a/src/tools/binance-margin/isolated-margin-api/enableIsolatedMarginAccount.ts +++ b/src/tools/binance-margin/isolated-margin-api/enableIsolatedMarginAccount.ts @@ -5,39 +5,45 @@ * @license Apache-2.0 */ // src/tools/binance-margin/isolated-margin-api/enableIsolatedMarginAccount.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceEnableIsolatedMarginAccount(server: McpServer) { - server.tool( - "BinanceEnableIsolatedMarginAccount", - "Enable isolated margin account for a specific symbol.", - { - symbol: z.string().describe("Symbol to enable isolated margin for (e.g., BTCUSDT)"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await marginClient.restAPI.enableIsolatedMarginAccount({ - symbol: params.symbol, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceEnableIsolatedMarginAccount", + "Enable isolated margin account for a specific symbol.", + { + symbol: z.string().describe("Symbol to enable isolated margin for (e.g., BTCUSDT)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await marginClient.restAPI.enableIsolatedMarginAccount({ + symbol: params.symbol, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Isolated margin account enabled for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Isolated margin account enabled for ${params.symbol}: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to enable isolated margin: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to enable isolated margin: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/isolated-margin-api/getBnbBurnStatus.ts b/src/tools/binance-margin/isolated-margin-api/getBnbBurnStatus.ts index fff3a620..0cd8eaa3 100644 --- a/src/tools/binance-margin/isolated-margin-api/getBnbBurnStatus.ts +++ b/src/tools/binance-margin/isolated-margin-api/getBnbBurnStatus.ts @@ -1,34 +1,39 @@ // src/tools/binance-margin/isolated-margin-api/getBnbBurnStatus.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceGetBnbBurnStatus(server: McpServer) { - server.tool( - "BinanceGetBnbBurnStatus", - "Get current BNB burn status for spot trading fees and margin interest.", - { - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.getAccount({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetBnbBurnStatus", + "Get current BNB burn status for spot trading fees and margin interest.", + { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.getAccount({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `BNB Burn Status: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `BNB Burn Status: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get BNB burn status: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to get BNB burn status: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/isolated-margin-api/index.ts b/src/tools/binance-margin/isolated-margin-api/index.ts index 815b5507..87da9c92 100644 --- a/src/tools/binance-margin/isolated-margin-api/index.ts +++ b/src/tools/binance-margin/isolated-margin-api/index.ts @@ -1,42 +1,43 @@ // src/tools/binance-margin/isolated-margin-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceIsolatedMarginTransfer } from "./isolatedMarginTransfer.js"; -import { registerBinanceIsolatedMarginAccount } from "./isolatedMarginAccount.js"; -import { registerBinanceIsolatedMarginPair } from "./isolatedMarginPair.js"; -import { registerBinanceIsolatedMarginAllPairs } from "./isolatedMarginAllPairs.js"; -import { registerBinanceIsolatedMarginTierData } from "./isolatedMarginTierData.js"; -import { registerBinanceIsolatedMarginAccountLimit } from "./isolatedMarginAccountLimit.js"; -import { registerBinanceIsolatedMarginFee } from "./isolatedMarginFee.js"; -import { registerBinanceIsolatedMarginNewOrder } from "./isolatedMarginNewOrder.js"; -import { registerBinanceIsolatedMarginCancelOrder } from "./isolatedMarginCancelOrder.js"; -import { registerBinanceIsolatedMarginOpenOrders } from "./isolatedMarginOpenOrders.js"; -import { registerBinanceIsolatedMarginAllOrders } from "./isolatedMarginAllOrders.js"; -import { registerBinanceIsolatedMarginMyTrades } from "./isolatedMarginMyTrades.js"; -import { registerBinanceToggleBnbBurn } from "./toggleBnbBurn.js"; -import { registerBinanceGetBnbBurnStatus } from "./getBnbBurnStatus.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceGetBnbBurnStatus } from "./getBnbBurnStatus.js" +import { registerBinanceIsolatedMarginAccount } from "./isolatedMarginAccount.js" +import { registerBinanceIsolatedMarginAccountLimit } from "./isolatedMarginAccountLimit.js" +import { registerBinanceIsolatedMarginAllOrders } from "./isolatedMarginAllOrders.js" +import { registerBinanceIsolatedMarginAllPairs } from "./isolatedMarginAllPairs.js" +import { registerBinanceIsolatedMarginCancelOrder } from "./isolatedMarginCancelOrder.js" +import { registerBinanceIsolatedMarginFee } from "./isolatedMarginFee.js" +import { registerBinanceIsolatedMarginMyTrades } from "./isolatedMarginMyTrades.js" +import { registerBinanceIsolatedMarginNewOrder } from "./isolatedMarginNewOrder.js" +import { registerBinanceIsolatedMarginOpenOrders } from "./isolatedMarginOpenOrders.js" +import { registerBinanceIsolatedMarginPair } from "./isolatedMarginPair.js" +import { registerBinanceIsolatedMarginTierData } from "./isolatedMarginTierData.js" +import { registerBinanceIsolatedMarginTransfer } from "./isolatedMarginTransfer.js" +import { registerBinanceToggleBnbBurn } from "./toggleBnbBurn.js" export function registerBinanceIsolatedMarginTools(server: McpServer) { - // Transfer - registerBinanceIsolatedMarginTransfer(server); - - // Account Info - registerBinanceIsolatedMarginAccount(server); - registerBinanceIsolatedMarginAccountLimit(server); - - // Pairs & Info - registerBinanceIsolatedMarginPair(server); - registerBinanceIsolatedMarginAllPairs(server); - registerBinanceIsolatedMarginTierData(server); - registerBinanceIsolatedMarginFee(server); - - // Trading - registerBinanceIsolatedMarginNewOrder(server); - registerBinanceIsolatedMarginCancelOrder(server); - registerBinanceIsolatedMarginOpenOrders(server); - registerBinanceIsolatedMarginAllOrders(server); - registerBinanceIsolatedMarginMyTrades(server); - - // BNB Burn - registerBinanceToggleBnbBurn(server); - registerBinanceGetBnbBurnStatus(server); + // Transfer + registerBinanceIsolatedMarginTransfer(server) + + // Account Info + registerBinanceIsolatedMarginAccount(server) + registerBinanceIsolatedMarginAccountLimit(server) + + // Pairs & Info + registerBinanceIsolatedMarginPair(server) + registerBinanceIsolatedMarginAllPairs(server) + registerBinanceIsolatedMarginTierData(server) + registerBinanceIsolatedMarginFee(server) + + // Trading + registerBinanceIsolatedMarginNewOrder(server) + registerBinanceIsolatedMarginCancelOrder(server) + registerBinanceIsolatedMarginOpenOrders(server) + registerBinanceIsolatedMarginAllOrders(server) + registerBinanceIsolatedMarginMyTrades(server) + + // BNB Burn + registerBinanceToggleBnbBurn(server) + registerBinanceGetBnbBurnStatus(server) } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAccount.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAccount.ts index 0ec4ff14..d4532aa2 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAccount.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAccount.ts @@ -1,36 +1,44 @@ // src/tools/binance-margin/isolated-margin-api/isolatedMarginAccount.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceIsolatedMarginAccount(server: McpServer) { - server.tool( - "BinanceIsolatedMarginAccount", - "Query isolated margin account info including balances, margin level, and liquidation price for all symbols or a specific symbol.", - { - symbols: z.string().optional().describe("Comma-separated symbol list (e.g., BTCUSDT,ETHUSDT), max 5 symbols"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.getIsolatedAccount({ - ...(params.symbols && { symbols: params.symbols }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceIsolatedMarginAccount", + "Query isolated margin account info including balances, margin level, and liquidation price for all symbols or a specific symbol.", + { + symbols: z + .string() + .optional() + .describe("Comma-separated symbol list (e.g., BTCUSDT,ETHUSDT), max 5 symbols"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.getIsolatedAccount({ + ...(params.symbols && { symbols: params.symbols }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Isolated Margin Account Info: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Isolated Margin Account Info: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query account: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to query account: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAccountLimit.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAccountLimit.ts index c552b77c..d38705f0 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAccountLimit.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAccountLimit.ts @@ -1,34 +1,39 @@ // src/tools/binance-margin/isolated-margin-api/isolatedMarginAccountLimit.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceIsolatedMarginAccountLimit(server: McpServer) { - server.tool( - "BinanceIsolatedMarginAccountLimit", - "Query the maximum number of isolated margin accounts allowed and currently enabled.", - { - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.getIsolatedAccount({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceIsolatedMarginAccountLimit", + "Query the maximum number of isolated margin accounts allowed and currently enabled.", + { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.getIsolatedAccount({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Isolated Margin Account Limit: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Isolated Margin Account Limit: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query account limit: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to query account limit: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllOrders.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllOrders.ts index 282b533f..84d74aeb 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllOrders.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllOrders.ts @@ -1,45 +1,50 @@ // src/tools/binance-margin/isolated-margin-api/isolatedMarginAllOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceIsolatedMarginAllOrders(server: McpServer) { - server.tool( - "BinanceIsolatedMarginAllOrders", - "Query all orders (open and filled/cancelled) in isolated margin account for a specific symbol.", - { - symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), - orderId: z.number().int().optional().describe("Order ID to start from"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z.number().int().optional().describe("Number of results (default 500, max 500)"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.getAllOrders({ - symbol: params.symbol, - isIsolated: "TRUE", - ...(params.orderId && { orderId: params.orderId }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceIsolatedMarginAllOrders", + "Query all orders (open and filled/cancelled) in isolated margin account for a specific symbol.", + { + symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), + orderId: z.number().int().optional().describe("Order ID to start from"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z.number().int().optional().describe("Number of results (default 500, max 500)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.getAllOrders({ + symbol: params.symbol, + isIsolated: "TRUE", + ...(params.orderId && { orderId: params.orderId }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `All Isolated Margin Orders for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `All Isolated Margin Orders for ${params.symbol}: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query all orders: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to query all orders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllPairs.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllPairs.ts index 39a53a28..48d0097f 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllPairs.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllPairs.ts @@ -1,34 +1,39 @@ // src/tools/binance-margin/isolated-margin-api/isolatedMarginAllPairs.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceIsolatedMarginAllPairs(server: McpServer) { - server.tool( - "BinanceIsolatedMarginAllPairs", - "Get all isolated margin trading pairs with their information.", - { - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.getIsolatedMarginPairs({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceIsolatedMarginAllPairs", + "Get all isolated margin trading pairs with their information.", + { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.getIsolatedMarginPairs({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `All Isolated Margin Pairs: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `All Isolated Margin Pairs: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get isolated pairs: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to get isolated pairs: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllSymbols.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllSymbols.ts index dc47a10f..c1d5ac11 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllSymbols.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllSymbols.ts @@ -5,37 +5,43 @@ * @license Apache-2.0 */ // src/tools/binance-margin/isolated-margin-api/isolatedMarginAllSymbols.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceIsolatedMarginAllSymbols(server: McpServer) { - server.tool( - "BinanceIsolatedMarginAllSymbols", - "Query all isolated margin symbols available for trading.", - { - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await marginClient.restAPI.getAllIsolatedMarginSymbol({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceIsolatedMarginAllSymbols", + "Query all isolated margin symbols available for trading.", + { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await marginClient.restAPI.getAllIsolatedMarginSymbol({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `All Isolated Margin Symbols: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - const data = await response.data(); - return { - content: [{ - type: "text", - text: `All Isolated Margin Symbols: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query all symbols: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to query all symbols: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginBorrow.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginBorrow.ts index cd45cbd8..77f64dc0 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginBorrow.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginBorrow.ts @@ -5,45 +5,51 @@ * @license Apache-2.0 */ // src/tools/binance-margin/isolated-margin-api/isolatedMarginBorrow.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceIsolatedMarginBorrow(server: McpServer) { - server.tool( - "BinanceIsolatedMarginBorrow", - "Borrow assets in isolated margin account for a specific symbol.", - { - asset: z.string().describe("Asset to borrow (e.g., BTC, USDT)"), - symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), - amount: z.string().describe("Amount to borrow"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await marginClient.restAPI.marginBorrowRepay({ - asset: params.asset, - isIsolated: "TRUE", - symbol: params.symbol, - amount: params.amount, - type: "BORROW", - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceIsolatedMarginBorrow", + "Borrow assets in isolated margin account for a specific symbol.", + { + asset: z.string().describe("Asset to borrow (e.g., BTC, USDT)"), + symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), + amount: z.string().describe("Amount to borrow"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await marginClient.restAPI.marginBorrowRepay({ + asset: params.asset, + isIsolated: "TRUE", + symbol: params.symbol, + amount: params.amount, + type: "BORROW", + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Borrowed ${params.amount} ${params.asset} for ${params.symbol}: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Borrowed ${params.amount} ${params.asset} for ${params.symbol}: ${JSON.stringify(data)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to borrow: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to borrow: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginCancelOrder.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginCancelOrder.ts index b6b23e1e..f52cc1ac 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginCancelOrder.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginCancelOrder.ts @@ -1,43 +1,53 @@ // src/tools/binance-margin/isolated-margin-api/isolatedMarginCancelOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceIsolatedMarginCancelOrder(server: McpServer) { - server.tool( - "BinanceIsolatedMarginCancelOrder", - "Cancel an active isolated margin order. Either orderId or origClientOrderId must be provided.", - { - symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), - orderId: z.number().int().optional().describe("Order ID to cancel"), - origClientOrderId: z.string().optional().describe("Original client order ID to cancel"), - newClientOrderId: z.string().optional().describe("New client order ID for the cancel request"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.cancelOrder({ - symbol: params.symbol, - isIsolated: "TRUE", - ...(params.orderId && { orderId: params.orderId }), - ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), - ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceIsolatedMarginCancelOrder", + "Cancel an active isolated margin order. Either orderId or origClientOrderId must be provided.", + { + symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), + orderId: z.number().int().optional().describe("Order ID to cancel"), + origClientOrderId: z.string().optional().describe("Original client order ID to cancel"), + newClientOrderId: z + .string() + .optional() + .describe("New client order ID for the cancel request"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.cancelOrder({ + symbol: params.symbol, + isIsolated: "TRUE", + ...(params.orderId && { orderId: params.orderId }), + ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), + ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Isolated margin order cancelled successfully: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Isolated margin order cancelled successfully: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to cancel isolated margin order: ${errorMessage}` }], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to cancel isolated margin order: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginFee.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginFee.ts index b6133c35..ca47d14d 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginFee.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginFee.ts @@ -1,38 +1,47 @@ // src/tools/binance-margin/isolated-margin-api/isolatedMarginFee.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceIsolatedMarginFee(server: McpServer) { - server.tool( - "BinanceIsolatedMarginFee", - "Query isolated margin fee data including interest rates for borrowing.", - { - symbol: z.string().optional().describe("Isolated margin symbol (e.g., BTCUSDT)"), - vipLevel: z.number().int().optional().describe("VIP level (default uses current account VIP level)"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.getIsolatedMarginFee({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.vipLevel !== undefined && { vipLevel: params.vipLevel }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceIsolatedMarginFee", + "Query isolated margin fee data including interest rates for borrowing.", + { + symbol: z.string().optional().describe("Isolated margin symbol (e.g., BTCUSDT)"), + vipLevel: z + .number() + .int() + .optional() + .describe("VIP level (default uses current account VIP level)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.getIsolatedMarginFee({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.vipLevel !== undefined && { vipLevel: params.vipLevel }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Isolated Margin Fee Data: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Isolated Margin Fee Data: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query fee data: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to query fee data: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginMyTrades.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginMyTrades.ts index 36e82fbc..2beab2fd 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginMyTrades.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginMyTrades.ts @@ -1,47 +1,52 @@ // src/tools/binance-margin/isolated-margin-api/isolatedMarginMyTrades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceIsolatedMarginMyTrades(server: McpServer) { - server.tool( - "BinanceIsolatedMarginMyTrades", - "Query trade history in isolated margin account for a specific symbol.", - { - symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), - orderId: z.number().int().optional().describe("Filter by order ID"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - fromId: z.number().int().optional().describe("Trade ID to start from"), - limit: z.number().int().optional().describe("Number of results (default 500, max 1000)"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.getMyTrades({ - symbol: params.symbol, - isIsolated: "TRUE", - ...(params.orderId && { orderId: params.orderId }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.fromId && { fromId: params.fromId }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceIsolatedMarginMyTrades", + "Query trade history in isolated margin account for a specific symbol.", + { + symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), + orderId: z.number().int().optional().describe("Filter by order ID"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + fromId: z.number().int().optional().describe("Trade ID to start from"), + limit: z.number().int().optional().describe("Number of results (default 500, max 1000)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.getMyTrades({ + symbol: params.symbol, + isIsolated: "TRUE", + ...(params.orderId && { orderId: params.orderId }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.fromId && { fromId: params.fromId }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Isolated Margin Trades for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Isolated Margin Trades for ${params.symbol}: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query trades: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to query trades: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginNewOrder.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginNewOrder.ts index 10382851..4ffc89e9 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginNewOrder.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginNewOrder.ts @@ -1,63 +1,93 @@ // src/tools/binance-margin/isolated-margin-api/isolatedMarginNewOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceIsolatedMarginNewOrder(server: McpServer) { - server.tool( - "BinanceIsolatedMarginNewOrder", - "Post a new order in isolated margin account. Supports various order types including LIMIT, MARKET, STOP_LOSS, etc.", - { - symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Order side"), - type: z.enum(["LIMIT", "MARKET", "STOP_LOSS", "STOP_LOSS_LIMIT", "TAKE_PROFIT", "TAKE_PROFIT_LIMIT", "LIMIT_MAKER"]).describe("Order type"), - quantity: z.string().optional().describe("Order quantity"), - quoteOrderQty: z.string().optional().describe("Quote order quantity for MARKET orders"), - price: z.string().optional().describe("Order price (required for LIMIT orders)"), - stopPrice: z.string().optional().describe("Stop price for STOP_LOSS and TAKE_PROFIT orders"), - newClientOrderId: z.string().optional().describe("Unique client order ID"), - icebergQty: z.string().optional().describe("Iceberg quantity"), - newOrderRespType: z.enum(["ACK", "RESULT", "FULL"]).optional().describe("Response type"), - sideEffectType: z.enum(["NO_SIDE_EFFECT", "MARGIN_BUY", "AUTO_REPAY", "AUTO_BORROW_REPAY"]).optional().describe("Side effect type for margin orders"), - timeInForce: z.enum(["GTC", "IOC", "FOK"]).optional().describe("Time in force"), - selfTradePreventionMode: z.enum(["EXPIRE_TAKER", "EXPIRE_MAKER", "EXPIRE_BOTH", "NONE"]).optional().describe("Self-trade prevention mode"), - autoRepayAtCancel: z.boolean().optional().describe("Auto repay at cancel, only for AUTO_BORROW_REPAY"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.newOrder({ - symbol: params.symbol, - isIsolated: "TRUE", - side: params.side, - type: params.type, - ...(params.quantity && { quantity: params.quantity }), - ...(params.quoteOrderQty && { quoteOrderQty: params.quoteOrderQty }), - ...(params.price && { price: params.price }), - ...(params.stopPrice && { stopPrice: params.stopPrice }), - ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), - ...(params.icebergQty && { icebergQty: params.icebergQty }), - ...(params.newOrderRespType && { newOrderRespType: params.newOrderRespType }), - ...(params.sideEffectType && { sideEffectType: params.sideEffectType }), - ...(params.timeInForce && { timeInForce: params.timeInForce }), - ...(params.selfTradePreventionMode && { selfTradePreventionMode: params.selfTradePreventionMode }), - ...(params.autoRepayAtCancel !== undefined && { autoRepayAtCancel: params.autoRepayAtCancel }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceIsolatedMarginNewOrder", + "Post a new order in isolated margin account. Supports various order types including LIMIT, MARKET, STOP_LOSS, etc.", + { + symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Order side"), + type: z + .enum([ + "LIMIT", + "MARKET", + "STOP_LOSS", + "STOP_LOSS_LIMIT", + "TAKE_PROFIT", + "TAKE_PROFIT_LIMIT", + "LIMIT_MAKER", + ]) + .describe("Order type"), + quantity: z.string().optional().describe("Order quantity"), + quoteOrderQty: z.string().optional().describe("Quote order quantity for MARKET orders"), + price: z.string().optional().describe("Order price (required for LIMIT orders)"), + stopPrice: z.string().optional().describe("Stop price for STOP_LOSS and TAKE_PROFIT orders"), + newClientOrderId: z.string().optional().describe("Unique client order ID"), + icebergQty: z.string().optional().describe("Iceberg quantity"), + newOrderRespType: z.enum(["ACK", "RESULT", "FULL"]).optional().describe("Response type"), + sideEffectType: z + .enum(["NO_SIDE_EFFECT", "MARGIN_BUY", "AUTO_REPAY", "AUTO_BORROW_REPAY"]) + .optional() + .describe("Side effect type for margin orders"), + timeInForce: z.enum(["GTC", "IOC", "FOK"]).optional().describe("Time in force"), + selfTradePreventionMode: z + .enum(["EXPIRE_TAKER", "EXPIRE_MAKER", "EXPIRE_BOTH", "NONE"]) + .optional() + .describe("Self-trade prevention mode"), + autoRepayAtCancel: z + .boolean() + .optional() + .describe("Auto repay at cancel, only for AUTO_BORROW_REPAY"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.newOrder({ + symbol: params.symbol, + isIsolated: "TRUE", + side: params.side, + type: params.type, + ...(params.quantity && { quantity: params.quantity }), + ...(params.quoteOrderQty && { quoteOrderQty: params.quoteOrderQty }), + ...(params.price && { price: params.price }), + ...(params.stopPrice && { stopPrice: params.stopPrice }), + ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), + ...(params.icebergQty && { icebergQty: params.icebergQty }), + ...(params.newOrderRespType && { newOrderRespType: params.newOrderRespType }), + ...(params.sideEffectType && { sideEffectType: params.sideEffectType }), + ...(params.timeInForce && { timeInForce: params.timeInForce }), + ...(params.selfTradePreventionMode && { + selfTradePreventionMode: params.selfTradePreventionMode, + }), + ...(params.autoRepayAtCancel !== undefined && { + autoRepayAtCancel: params.autoRepayAtCancel, + }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Isolated margin order placed successfully: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Isolated margin order placed successfully: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to place isolated margin order: ${errorMessage}` }], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to place isolated margin order: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginOpenOrders.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginOpenOrders.ts index c1909583..3ef79aca 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginOpenOrders.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginOpenOrders.ts @@ -1,37 +1,42 @@ // src/tools/binance-margin/isolated-margin-api/isolatedMarginOpenOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceIsolatedMarginOpenOrders(server: McpServer) { - server.tool( - "BinanceIsolatedMarginOpenOrders", - "Query all open orders in isolated margin account for a specific symbol.", - { - symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.getOpenOrders({ - symbol: params.symbol, - isIsolated: "TRUE", - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceIsolatedMarginOpenOrders", + "Query all open orders in isolated margin account for a specific symbol.", + { + symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.getOpenOrders({ + symbol: params.symbol, + isIsolated: "TRUE", + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Isolated Margin Open Orders for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Isolated Margin Open Orders for ${params.symbol}: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query open orders: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to query open orders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginPair.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginPair.ts index b1c8ea9f..7f5f06c0 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginPair.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginPair.ts @@ -1,36 +1,41 @@ // src/tools/binance-margin/isolated-margin-api/isolatedMarginPair.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceIsolatedMarginPair(server: McpServer) { - server.tool( - "BinanceIsolatedMarginPair", - "Query isolated margin symbol info including margin ratio, base/quote assets, and status.", - { - symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.getIsolatedMarginPairs({ - symbol: params.symbol, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceIsolatedMarginPair", + "Query isolated margin symbol info including margin ratio, base/quote assets, and status.", + { + symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.getIsolatedMarginPairs({ + symbol: params.symbol, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Isolated Margin Pair Info for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Isolated Margin Pair Info for ${params.symbol}: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query pair info: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to query pair info: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginRepay.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginRepay.ts index 10f50803..de753499 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginRepay.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginRepay.ts @@ -5,45 +5,51 @@ * @license Apache-2.0 */ // src/tools/binance-margin/isolated-margin-api/isolatedMarginRepay.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceIsolatedMarginRepay(server: McpServer) { - server.tool( - "BinanceIsolatedMarginRepay", - "Repay borrowed assets in isolated margin account.", - { - asset: z.string().describe("Asset to repay (e.g., BTC, USDT)"), - symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), - amount: z.string().describe("Amount to repay"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await marginClient.restAPI.marginBorrowRepay({ - asset: params.asset, - isIsolated: "TRUE", - symbol: params.symbol, - amount: params.amount, - type: "REPAY", - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceIsolatedMarginRepay", + "Repay borrowed assets in isolated margin account.", + { + asset: z.string().describe("Asset to repay (e.g., BTC, USDT)"), + symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), + amount: z.string().describe("Amount to repay"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await marginClient.restAPI.marginBorrowRepay({ + asset: params.asset, + isIsolated: "TRUE", + symbol: params.symbol, + amount: params.amount, + type: "REPAY", + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Repaid ${params.amount} ${params.asset} for ${params.symbol}: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Repaid ${params.amount} ${params.asset} for ${params.symbol}: ${JSON.stringify(data)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to repay: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to repay: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginSymbol.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginSymbol.ts index 2cb86403..11a424fb 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginSymbol.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginSymbol.ts @@ -5,39 +5,45 @@ * @license Apache-2.0 */ // src/tools/binance-margin/isolated-margin-api/isolatedMarginSymbol.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceIsolatedMarginSymbol(server: McpServer) { - server.tool( - "BinanceIsolatedMarginSymbol", - "Query isolated margin symbol information for a specific trading pair.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await marginClient.restAPI.queryIsolatedMarginSymbol({ - symbol: params.symbol, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceIsolatedMarginSymbol", + "Query isolated margin symbol information for a specific trading pair.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await marginClient.restAPI.queryIsolatedMarginSymbol({ + symbol: params.symbol, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Isolated Margin Symbol Info for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Isolated Margin Symbol Info for ${params.symbol}: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query symbol info: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to query symbol info: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginTierData.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginTierData.ts index 02683f80..1caac253 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginTierData.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginTierData.ts @@ -1,38 +1,43 @@ // src/tools/binance-margin/isolated-margin-api/isolatedMarginTierData.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceIsolatedMarginTierData(server: McpServer) { - server.tool( - "BinanceIsolatedMarginTierData", - "Query isolated margin tier data showing leverage tiers and maintenance margin ratios for a symbol.", - { - symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), - tier: z.number().int().optional().describe("Specific tier to query"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.getIsolatedMarginTier({ - symbol: params.symbol, - ...(params.tier !== undefined && { tier: params.tier }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceIsolatedMarginTierData", + "Query isolated margin tier data showing leverage tiers and maintenance margin ratios for a symbol.", + { + symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), + tier: z.number().int().optional().describe("Specific tier to query"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.getIsolatedMarginTier({ + symbol: params.symbol, + ...(params.tier !== undefined && { tier: params.tier }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Isolated Margin Tier Data for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Isolated Margin Tier Data for ${params.symbol}: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query tier data: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to query tier data: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginTransfer.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginTransfer.ts index 4c49fca1..dc37ab32 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginTransfer.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginTransfer.ts @@ -1,44 +1,49 @@ // src/tools/binance-margin/isolated-margin-api/isolatedMarginTransfer.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceIsolatedMarginTransfer(server: McpServer) { - server.tool( - "BinanceIsolatedMarginTransfer", - "Transfer assets between spot wallet and isolated margin account for a specific symbol.", - { - asset: z.string().describe("Asset to transfer (e.g., BTC, USDT)"), - symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), - amount: z.string().describe("Amount to transfer"), - transFrom: z.enum(["SPOT", "ISOLATED_MARGIN"]).describe("Transfer from account type"), - transTo: z.enum(["SPOT", "ISOLATED_MARGIN"]).describe("Transfer to account type"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.transfer({ - asset: params.asset, - symbol: params.symbol, - amount: params.amount, - transFrom: params.transFrom, - transTo: params.transTo, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceIsolatedMarginTransfer", + "Transfer assets between spot wallet and isolated margin account for a specific symbol.", + { + asset: z.string().describe("Asset to transfer (e.g., BTC, USDT)"), + symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), + amount: z.string().describe("Amount to transfer"), + transFrom: z.enum(["SPOT", "ISOLATED_MARGIN"]).describe("Transfer from account type"), + transTo: z.enum(["SPOT", "ISOLATED_MARGIN"]).describe("Transfer to account type"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.transfer({ + asset: params.asset, + symbol: params.symbol, + amount: params.amount, + transFrom: params.transFrom, + transTo: params.transTo, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `Isolated margin transfer successful: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Isolated margin transfer successful: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to transfer: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to transfer: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginTransferHistory.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginTransferHistory.ts index 646391c0..9551402d 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginTransferHistory.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginTransferHistory.ts @@ -5,55 +5,61 @@ * @license Apache-2.0 */ // src/tools/binance-margin/isolated-margin-api/isolatedMarginTransferHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceIsolatedMarginTransferHistory(server: McpServer) { - server.tool( - "BinanceIsolatedMarginTransferHistory", - "Query isolated margin transfer history.", - { - symbol: z.string().optional().describe("Isolated margin symbol"), - asset: z.string().optional().describe("Asset"), - transFrom: z.enum(["SPOT", "ISOLATED_MARGIN"]).optional().describe("Transfer from"), - transTo: z.enum(["SPOT", "ISOLATED_MARGIN"]).optional().describe("Transfer to"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - current: z.number().int().optional().describe("Current page, default 1"), - size: z.number().int().optional().describe("Page size, default 10, max 100"), - archived: z.boolean().optional().describe("Query archived data"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await marginClient.restAPI.getIsolatedMarginTransferHistory({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.asset && { asset: params.asset }), - ...(params.transFrom && { transFrom: params.transFrom }), - ...(params.transTo && { transTo: params.transTo }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.current && { current: params.current }), - ...(params.size && { size: params.size }), - ...(params.archived !== undefined && { archived: params.archived }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceIsolatedMarginTransferHistory", + "Query isolated margin transfer history.", + { + symbol: z.string().optional().describe("Isolated margin symbol"), + asset: z.string().optional().describe("Asset"), + transFrom: z.enum(["SPOT", "ISOLATED_MARGIN"]).optional().describe("Transfer from"), + transTo: z.enum(["SPOT", "ISOLATED_MARGIN"]).optional().describe("Transfer to"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + current: z.number().int().optional().describe("Current page, default 1"), + size: z.number().int().optional().describe("Page size, default 10, max 100"), + archived: z.boolean().optional().describe("Query archived data"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await marginClient.restAPI.getIsolatedMarginTransferHistory({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.asset && { asset: params.asset }), + ...(params.transFrom && { transFrom: params.transFrom }), + ...(params.transTo && { transTo: params.transTo }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.current && { current: params.current }), + ...(params.size && { size: params.size }), + ...(params.archived !== undefined && { archived: params.archived }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Isolated Margin Transfer History: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Isolated Margin Transfer History: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query transfer history: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to query transfer history: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/isolated-margin-api/toggleBnbBurn.ts b/src/tools/binance-margin/isolated-margin-api/toggleBnbBurn.ts index 8bff5210..f6e43ee9 100644 --- a/src/tools/binance-margin/isolated-margin-api/toggleBnbBurn.ts +++ b/src/tools/binance-margin/isolated-margin-api/toggleBnbBurn.ts @@ -1,38 +1,49 @@ // src/tools/binance-margin/isolated-margin-api/toggleBnbBurn.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceToggleBnbBurn(server: McpServer) { - server.tool( - "BinanceToggleBnbBurn", - "Toggle BNB burn on spot trade and margin interest. When enabled, uses BNB to pay for trading fees and margin interest at a discount.", - { - spotBNBBurn: z.enum(["true", "false"]).optional().describe("Enable/disable BNB burn for spot trading fees"), - interestBNBBurn: z.enum(["true", "false"]).optional().describe("Enable/disable BNB burn for margin interest"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const data = await marginClient.getAccount({ - ...(params.spotBNBBurn && { spotBNBBurn: params.spotBNBBurn }), - ...(params.interestBNBBurn && { interestBNBBurn: params.interestBNBBurn }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceToggleBnbBurn", + "Toggle BNB burn on spot trade and margin interest. When enabled, uses BNB to pay for trading fees and margin interest at a discount.", + { + spotBNBBurn: z + .enum(["true", "false"]) + .optional() + .describe("Enable/disable BNB burn for spot trading fees"), + interestBNBBurn: z + .enum(["true", "false"]) + .optional() + .describe("Enable/disable BNB burn for margin interest"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const data = await marginClient.getAccount({ + ...(params.spotBNBBurn && { spotBNBBurn: params.spotBNBBurn }), + ...(params.interestBNBBurn && { interestBNBBurn: params.interestBNBBurn }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + return { + content: [ + { + type: "text", + text: `BNB Burn settings updated: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `BNB Burn settings updated: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to toggle BNB burn: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to toggle BNB burn: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/margin-order-api/index.ts b/src/tools/binance-margin/margin-order-api/index.ts index c2a603e9..8e32682e 100644 --- a/src/tools/binance-margin/margin-order-api/index.ts +++ b/src/tools/binance-margin/margin-order-api/index.ts @@ -5,18 +5,19 @@ * @license Apache-2.0 */ // src/tools/binance-margin/margin-order-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceMarginNewOco } from "./marginNewOco.js"; -import { registerBinanceMarginCancelOco } from "./marginCancelOco.js"; -import { registerBinanceMarginGetOco } from "./marginGetOco.js"; -import { registerBinanceMarginGetAllOco } from "./marginGetAllOco.js"; -import { registerBinanceMarginGetOpenOco } from "./marginGetOpenOco.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceMarginCancelOco } from "./marginCancelOco.js" +import { registerBinanceMarginGetAllOco } from "./marginGetAllOco.js" +import { registerBinanceMarginGetOco } from "./marginGetOco.js" +import { registerBinanceMarginGetOpenOco } from "./marginGetOpenOco.js" +import { registerBinanceMarginNewOco } from "./marginNewOco.js" export function registerBinanceMarginOrderTools(server: McpServer) { - // OCO Orders - registerBinanceMarginNewOco(server); - registerBinanceMarginCancelOco(server); - registerBinanceMarginGetOco(server); - registerBinanceMarginGetAllOco(server); - registerBinanceMarginGetOpenOco(server); + // OCO Orders + registerBinanceMarginNewOco(server) + registerBinanceMarginCancelOco(server) + registerBinanceMarginGetOco(server) + registerBinanceMarginGetAllOco(server) + registerBinanceMarginGetOpenOco(server) } diff --git a/src/tools/binance-margin/margin-order-api/marginCancelOco.ts b/src/tools/binance-margin/margin-order-api/marginCancelOco.ts index fcc5235e..77ca4f5f 100644 --- a/src/tools/binance-margin/margin-order-api/marginCancelOco.ts +++ b/src/tools/binance-margin/margin-order-api/marginCancelOco.ts @@ -5,55 +5,69 @@ * @license Apache-2.0 */ // src/tools/binance-margin/margin-order-api/marginCancelOco.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceMarginCancelOco(server: McpServer) { - server.tool( - "BinanceMarginCancelOco", - "Cancel an entire OCO (One-Cancels-the-Other) order in Margin account. Both legs will be cancelled.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - orderListId: z.number().int().optional().describe("Order list ID"), - listClientOrderId: z.string().optional().describe("Client order list ID"), - newClientOrderId: z.string().optional().describe("New client order ID for this cancel request"), - isIsolated: z.enum(["TRUE", "FALSE"]).optional().describe("For isolated margin, default FALSE"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - // Either orderListId or listClientOrderId must be provided - if (params.orderListId === undefined && !params.listClientOrderId) { - return { - content: [{ type: "text", text: "Either orderListId or listClientOrderId must be provided" }], - isError: true - }; - } + server.tool( + "BinanceMarginCancelOco", + "Cancel an entire OCO (One-Cancels-the-Other) order in Margin account. Both legs will be cancelled.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + orderListId: z.number().int().optional().describe("Order list ID"), + listClientOrderId: z.string().optional().describe("Client order list ID"), + newClientOrderId: z + .string() + .optional() + .describe("New client order ID for this cancel request"), + isIsolated: z + .enum(["TRUE", "FALSE"]) + .optional() + .describe("For isolated margin, default FALSE"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + // Either orderListId or listClientOrderId must be provided + if (params.orderListId === undefined && !params.listClientOrderId) { + return { + content: [ + { type: "text", text: "Either orderListId or listClientOrderId must be provided" }, + ], + isError: true, + } + } - const response = await marginClient.restAPI.marginAccountCancelOco({ - symbol: params.symbol, - ...(params.orderListId !== undefined && { orderListId: params.orderListId }), - ...(params.listClientOrderId && { listClientOrderId: params.listClientOrderId }), - ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), - ...(params.isIsolated && { isIsolated: params.isIsolated }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + const response = await marginClient.restAPI.marginAccountCancelOco({ + symbol: params.symbol, + ...(params.orderListId !== undefined && { orderListId: params.orderListId }), + ...(params.listClientOrderId && { listClientOrderId: params.listClientOrderId }), + ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), + ...(params.isIsolated && { isIsolated: params.isIsolated }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Margin OCO order cancelled successfully: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Margin OCO order cancelled successfully: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to cancel margin OCO order: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to cancel margin OCO order: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/margin-order-api/marginGetAllOco.ts b/src/tools/binance-margin/margin-order-api/marginGetAllOco.ts index 45da02ac..2dcbde78 100644 --- a/src/tools/binance-margin/margin-order-api/marginGetAllOco.ts +++ b/src/tools/binance-margin/margin-order-api/marginGetAllOco.ts @@ -5,49 +5,63 @@ * @license Apache-2.0 */ // src/tools/binance-margin/margin-order-api/marginGetAllOco.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceMarginGetAllOco(server: McpServer) { - server.tool( - "BinanceMarginGetAllOco", - "Query all OCO (One-Cancels-the-Other) orders in Margin account, both open and closed.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (mandatory for isolated margin)"), - fromId: z.number().int().optional().describe("Order list ID to start from"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - limit: z.number().int().optional().describe("Number of results, default 500, max 1000"), - isIsolated: z.enum(["TRUE", "FALSE"]).optional().describe("For isolated margin, default FALSE"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await marginClient.restAPI.queryMarginAccountsAllOco({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.fromId !== undefined && { fromId: params.fromId }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.isIsolated && { isIsolated: params.isIsolated }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceMarginGetAllOco", + "Query all OCO (One-Cancels-the-Other) orders in Margin account, both open and closed.", + { + symbol: z + .string() + .optional() + .describe("Symbol of the trading pair (mandatory for isolated margin)"), + fromId: z.number().int().optional().describe("Order list ID to start from"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + limit: z.number().int().optional().describe("Number of results, default 500, max 1000"), + isIsolated: z + .enum(["TRUE", "FALSE"]) + .optional() + .describe("For isolated margin, default FALSE"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await marginClient.restAPI.queryMarginAccountsAllOco({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.fromId !== undefined && { fromId: params.fromId }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.isIsolated && { isIsolated: params.isIsolated }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `All Margin OCO orders: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - const data = await response.data(); - return { - content: [{ - type: "text", - text: `All Margin OCO orders: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query all margin OCO orders: ${errorMessage}` }], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to query all margin OCO orders: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/margin-order-api/marginGetOco.ts b/src/tools/binance-margin/margin-order-api/marginGetOco.ts index 9f16c005..03c85fe6 100644 --- a/src/tools/binance-margin/margin-order-api/marginGetOco.ts +++ b/src/tools/binance-margin/margin-order-api/marginGetOco.ts @@ -5,53 +5,67 @@ * @license Apache-2.0 */ // src/tools/binance-margin/margin-order-api/marginGetOco.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceMarginGetOco(server: McpServer) { - server.tool( - "BinanceMarginGetOco", - "Query a specific OCO (One-Cancels-the-Other) order in Margin account by orderListId or listClientOrderId.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (mandatory for isolated margin)"), - orderListId: z.number().int().optional().describe("Order list ID"), - origClientOrderId: z.string().optional().describe("Original client order list ID"), - isIsolated: z.enum(["TRUE", "FALSE"]).optional().describe("For isolated margin, default FALSE"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - // Either orderListId or origClientOrderId must be provided - if (params.orderListId === undefined && !params.origClientOrderId) { - return { - content: [{ type: "text", text: "Either orderListId or origClientOrderId must be provided" }], - isError: true - }; - } + server.tool( + "BinanceMarginGetOco", + "Query a specific OCO (One-Cancels-the-Other) order in Margin account by orderListId or listClientOrderId.", + { + symbol: z + .string() + .optional() + .describe("Symbol of the trading pair (mandatory for isolated margin)"), + orderListId: z.number().int().optional().describe("Order list ID"), + origClientOrderId: z.string().optional().describe("Original client order list ID"), + isIsolated: z + .enum(["TRUE", "FALSE"]) + .optional() + .describe("For isolated margin, default FALSE"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + // Either orderListId or origClientOrderId must be provided + if (params.orderListId === undefined && !params.origClientOrderId) { + return { + content: [ + { type: "text", text: "Either orderListId or origClientOrderId must be provided" }, + ], + isError: true, + } + } - const response = await marginClient.restAPI.queryMarginAccountsOco({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.orderListId !== undefined && { orderListId: params.orderListId }), - ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), - ...(params.isIsolated && { isIsolated: params.isIsolated }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + const response = await marginClient.restAPI.queryMarginAccountsOco({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.orderListId !== undefined && { orderListId: params.orderListId }), + ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), + ...(params.isIsolated && { isIsolated: params.isIsolated }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Margin OCO order details: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Margin OCO order details: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query margin OCO order: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to query margin OCO order: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/margin-order-api/marginGetOpenOco.ts b/src/tools/binance-margin/margin-order-api/marginGetOpenOco.ts index e72fd055..b511759d 100644 --- a/src/tools/binance-margin/margin-order-api/marginGetOpenOco.ts +++ b/src/tools/binance-margin/margin-order-api/marginGetOpenOco.ts @@ -5,41 +5,55 @@ * @license Apache-2.0 */ // src/tools/binance-margin/margin-order-api/marginGetOpenOco.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceMarginGetOpenOco(server: McpServer) { - server.tool( - "BinanceMarginGetOpenOco", - "Query all open OCO (One-Cancels-the-Other) orders in Margin account.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (mandatory for isolated margin)"), - isIsolated: z.enum(["TRUE", "FALSE"]).optional().describe("For isolated margin, default FALSE"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await marginClient.restAPI.queryMarginAccountsOpenOco({ - ...(params.symbol && { symbol: params.symbol }), - ...(params.isIsolated && { isIsolated: params.isIsolated }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceMarginGetOpenOco", + "Query all open OCO (One-Cancels-the-Other) orders in Margin account.", + { + symbol: z + .string() + .optional() + .describe("Symbol of the trading pair (mandatory for isolated margin)"), + isIsolated: z + .enum(["TRUE", "FALSE"]) + .optional() + .describe("For isolated margin, default FALSE"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await marginClient.restAPI.queryMarginAccountsOpenOco({ + ...(params.symbol && { symbol: params.symbol }), + ...(params.isIsolated && { isIsolated: params.isIsolated }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Open Margin OCO orders: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Open Margin OCO orders: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to query open margin OCO orders: ${errorMessage}` }], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to query open margin OCO orders: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-margin/margin-order-api/marginNewOco.ts b/src/tools/binance-margin/margin-order-api/marginNewOco.ts index 16ce3bba..e40290c0 100644 --- a/src/tools/binance-margin/margin-order-api/marginNewOco.ts +++ b/src/tools/binance-margin/margin-order-api/marginNewOco.ts @@ -5,73 +5,96 @@ * @license Apache-2.0 */ // src/tools/binance-margin/margin-order-api/marginNewOco.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { marginClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { marginClient } from "../../../config/binanceClient.js" export function registerBinanceMarginNewOco(server: McpServer) { - server.tool( - "BinanceMarginNewOco", - "Place a new OCO (One-Cancels-the-Other) order in Margin account. Creates both a stop-loss and take-profit order simultaneously. ⚠️ WARNING: OCO orders involve leverage and carry liquidation risk.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Order side"), - quantity: z.number().describe("Order quantity"), - price: z.number().describe("Limit order price"), - stopPrice: z.number().describe("Stop loss trigger price"), - stopLimitPrice: z.number().optional().describe("Stop limit order price (if stop limit order)"), - stopLimitTimeInForce: z.enum(["GTC", "FOK", "IOC"]).optional().describe("Time in force for stop limit leg"), - listClientOrderId: z.string().optional().describe("Unique ID for the order list"), - limitClientOrderId: z.string().optional().describe("Unique ID for the limit order"), - stopClientOrderId: z.string().optional().describe("Unique ID for the stop order"), - limitIcebergQty: z.number().optional().describe("Iceberg quantity for limit leg"), - stopIcebergQty: z.number().optional().describe("Iceberg quantity for stop leg"), - newOrderRespType: z.enum(["ACK", "RESULT", "FULL"]).optional().describe("Response type"), - sideEffectType: z.enum(["NO_SIDE_EFFECT", "MARGIN_BUY", "AUTO_REPAY", "AUTO_BORROW_REPAY"]).optional() - .describe("Side effect type for margin orders"), - isIsolated: z.enum(["TRUE", "FALSE"]).optional().describe("For isolated margin, default FALSE"), - selfTradePreventionMode: z.enum(["EXPIRE_TAKER", "EXPIRE_MAKER", "EXPIRE_BOTH", "NONE"]).optional() - .describe("Self-trade prevention mode"), - autoRepayAtCancel: z.boolean().optional().describe("Auto repay when order is canceled"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await marginClient.restAPI.marginAccountNewOco({ - symbol: params.symbol, - side: params.side, - quantity: params.quantity, - price: params.price, - stopPrice: params.stopPrice, - ...(params.stopLimitPrice !== undefined && { stopLimitPrice: params.stopLimitPrice }), - ...(params.stopLimitTimeInForce && { stopLimitTimeInForce: params.stopLimitTimeInForce }), - ...(params.listClientOrderId && { listClientOrderId: params.listClientOrderId }), - ...(params.limitClientOrderId && { limitClientOrderId: params.limitClientOrderId }), - ...(params.stopClientOrderId && { stopClientOrderId: params.stopClientOrderId }), - ...(params.limitIcebergQty !== undefined && { limitIcebergQty: params.limitIcebergQty }), - ...(params.stopIcebergQty !== undefined && { stopIcebergQty: params.stopIcebergQty }), - ...(params.newOrderRespType && { newOrderRespType: params.newOrderRespType }), - ...(params.sideEffectType && { sideEffectType: params.sideEffectType }), - ...(params.isIsolated && { isIsolated: params.isIsolated }), - ...(params.selfTradePreventionMode && { selfTradePreventionMode: params.selfTradePreventionMode }), - ...(params.autoRepayAtCancel !== undefined && { autoRepayAtCancel: params.autoRepayAtCancel }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceMarginNewOco", + "Place a new OCO (One-Cancels-the-Other) order in Margin account. Creates both a stop-loss and take-profit order simultaneously. ⚠️ WARNING: OCO orders involve leverage and carry liquidation risk.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Order side"), + quantity: z.number().describe("Order quantity"), + price: z.number().describe("Limit order price"), + stopPrice: z.number().describe("Stop loss trigger price"), + stopLimitPrice: z + .number() + .optional() + .describe("Stop limit order price (if stop limit order)"), + stopLimitTimeInForce: z + .enum(["GTC", "FOK", "IOC"]) + .optional() + .describe("Time in force for stop limit leg"), + listClientOrderId: z.string().optional().describe("Unique ID for the order list"), + limitClientOrderId: z.string().optional().describe("Unique ID for the limit order"), + stopClientOrderId: z.string().optional().describe("Unique ID for the stop order"), + limitIcebergQty: z.number().optional().describe("Iceberg quantity for limit leg"), + stopIcebergQty: z.number().optional().describe("Iceberg quantity for stop leg"), + newOrderRespType: z.enum(["ACK", "RESULT", "FULL"]).optional().describe("Response type"), + sideEffectType: z + .enum(["NO_SIDE_EFFECT", "MARGIN_BUY", "AUTO_REPAY", "AUTO_BORROW_REPAY"]) + .optional() + .describe("Side effect type for margin orders"), + isIsolated: z + .enum(["TRUE", "FALSE"]) + .optional() + .describe("For isolated margin, default FALSE"), + selfTradePreventionMode: z + .enum(["EXPIRE_TAKER", "EXPIRE_MAKER", "EXPIRE_BOTH", "NONE"]) + .optional() + .describe("Self-trade prevention mode"), + autoRepayAtCancel: z.boolean().optional().describe("Auto repay when order is canceled"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await marginClient.restAPI.marginAccountNewOco({ + symbol: params.symbol, + side: params.side, + quantity: params.quantity, + price: params.price, + stopPrice: params.stopPrice, + ...(params.stopLimitPrice !== undefined && { stopLimitPrice: params.stopLimitPrice }), + ...(params.stopLimitTimeInForce && { stopLimitTimeInForce: params.stopLimitTimeInForce }), + ...(params.listClientOrderId && { listClientOrderId: params.listClientOrderId }), + ...(params.limitClientOrderId && { limitClientOrderId: params.limitClientOrderId }), + ...(params.stopClientOrderId && { stopClientOrderId: params.stopClientOrderId }), + ...(params.limitIcebergQty !== undefined && { limitIcebergQty: params.limitIcebergQty }), + ...(params.stopIcebergQty !== undefined && { stopIcebergQty: params.stopIcebergQty }), + ...(params.newOrderRespType && { newOrderRespType: params.newOrderRespType }), + ...(params.sideEffectType && { sideEffectType: params.sideEffectType }), + ...(params.isIsolated && { isIsolated: params.isIsolated }), + ...(params.selfTradePreventionMode && { + selfTradePreventionMode: params.selfTradePreventionMode, + }), + ...(params.autoRepayAtCancel !== undefined && { + autoRepayAtCancel: params.autoRepayAtCancel, + }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Margin OCO order placed successfully: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - const data = await response.data(); - return { - content: [{ - type: "text", - text: `Margin OCO order placed successfully: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to place margin OCO order: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to place margin OCO order: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-mining/index.ts b/src/tools/binance-mining/index.ts index 114d9107..e990dca3 100644 --- a/src/tools/binance-mining/index.ts +++ b/src/tools/binance-mining/index.ts @@ -1,31 +1,32 @@ // src/tools/binance-mining/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceAcquiringAlgorithm } from "./mining-api/acquiringAlgorithm.js"; -import { registerBinanceAcquiringCoinName } from "./mining-api/acquiringCoinname.js"; -import { registerBinanceHashRateResaleList } from "./mining-api/hashrateResaleList.js"; -import { registerBinanceRequestForMinerList } from "./mining-api/requestForMinerList.js"; -import { registerBinanceRequestForDetailMinerList } from "./mining-api/requestForDetailMinerList.js"; -import { registerBinanceExtraBonusList } from "./mining-api/extraBonusList.js"; -import { registerBinanceEarningsList } from "./mining-api/earningsList.js"; -import { registerBinanceCancelHashRateResaleConfiguration } from "./mining-api/cancelHashrateResaleConfiguration.js"; -import { registerBinanceHashRateResaleDetail } from "./mining-api/hashrateResaleDetail.js"; -import { registerBinanceMiningAccountEarning } from "./mining-api/miningAccountEarning.js"; -import { registerBinanceStatisticList } from "./mining-api/statisticList.js"; -import { registerBinanceHashRateResaleRequest } from "./mining-api/hashrateResaleRequest.js"; -import { registerBinanceAccountList } from "./mining-api/accountList.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceAccountList } from "./mining-api/accountList.js" +import { registerBinanceAcquiringAlgorithm } from "./mining-api/acquiringAlgorithm.js" +import { registerBinanceAcquiringCoinName } from "./mining-api/acquiringCoinname.js" +import { registerBinanceCancelHashRateResaleConfiguration } from "./mining-api/cancelHashrateResaleConfiguration.js" +import { registerBinanceEarningsList } from "./mining-api/earningsList.js" +import { registerBinanceExtraBonusList } from "./mining-api/extraBonusList.js" +import { registerBinanceHashRateResaleDetail } from "./mining-api/hashrateResaleDetail.js" +import { registerBinanceHashRateResaleList } from "./mining-api/hashrateResaleList.js" +import { registerBinanceHashRateResaleRequest } from "./mining-api/hashrateResaleRequest.js" +import { registerBinanceMiningAccountEarning } from "./mining-api/miningAccountEarning.js" +import { registerBinanceRequestForDetailMinerList } from "./mining-api/requestForDetailMinerList.js" +import { registerBinanceRequestForMinerList } from "./mining-api/requestForMinerList.js" +import { registerBinanceStatisticList } from "./mining-api/statisticList.js" export function registerBinanceMiningTools(server: McpServer) { - registerBinanceAcquiringAlgorithm(server); - registerBinanceAcquiringCoinName(server); - registerBinanceHashRateResaleList(server); - registerBinanceRequestForMinerList(server); - registerBinanceRequestForDetailMinerList(server); - registerBinanceExtraBonusList(server); - registerBinanceEarningsList(server); - registerBinanceCancelHashRateResaleConfiguration(server); - registerBinanceHashRateResaleDetail(server); - registerBinanceMiningAccountEarning(server); - registerBinanceStatisticList(server); - registerBinanceHashRateResaleRequest(server); - registerBinanceAccountList(server); + registerBinanceAcquiringAlgorithm(server) + registerBinanceAcquiringCoinName(server) + registerBinanceHashRateResaleList(server) + registerBinanceRequestForMinerList(server) + registerBinanceRequestForDetailMinerList(server) + registerBinanceExtraBonusList(server) + registerBinanceEarningsList(server) + registerBinanceCancelHashRateResaleConfiguration(server) + registerBinanceHashRateResaleDetail(server) + registerBinanceMiningAccountEarning(server) + registerBinanceStatisticList(server) + registerBinanceHashRateResaleRequest(server) + registerBinanceAccountList(server) } diff --git a/src/tools/binance-mining/mining-api/accountList.ts b/src/tools/binance-mining/mining-api/accountList.ts index 068013a9..cb48f137 100644 --- a/src/tools/binance-mining/mining-api/accountList.ts +++ b/src/tools/binance-mining/mining-api/accountList.ts @@ -1,49 +1,52 @@ // src/tools/binance-mining/mining-api/accountList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { miningClient } from "../../../config/binanceClient.js" export function registerBinanceAccountList(server: McpServer) { - server.tool( - "BinanceAccountList", - "Retrieve hashrate statistics for a mining account. It returns both hourly (H_hashrate) and daily (D_hashrate) data, including timestamps, hashrate values, and rejection rates.", - { - algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), - userName: z.string().min(1).describe("Mining account"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await miningClient.restAPI.accountList({ - algo: params.algo, - userName: params.userName, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceAccountList", + "Retrieve hashrate statistics for a mining account. It returns both hourly (H_hashrate) and daily (D_hashrate) data, including timestamps, hashrate values, and rejection rates.", + { + algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), + userName: z.string().min(1).describe("Mining account"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await miningClient.restAPI.accountList({ + algo: params.algo, + userName: params.userName, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved hashrate statistics for a mining account.. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved hashrate statistics for a mining account.. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve hashrate statistics for a mining account.. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve hashrate statistics for a mining account.. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-mining/mining-api/acquiringAlgorithm.ts b/src/tools/binance-mining/mining-api/acquiringAlgorithm.ts index 0aef5307..4551274c 100644 --- a/src/tools/binance-mining/mining-api/acquiringAlgorithm.ts +++ b/src/tools/binance-mining/mining-api/acquiringAlgorithm.ts @@ -1,40 +1,42 @@ // src/tools/binance-mining/mining-api/acquiringAlgorithm.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { miningClient } from "../../../config/binanceClient.js" export function registerBinanceAcquiringAlgorithm(server: McpServer) { - server.tool( - "BinanceAcquiringAlgorithm", - "Retrieve a list of available mining algorithms, including their name, ID, sequence, and unit.", - {}, - async () => { - try { - const response = await miningClient.restAPI.acquiringAlgorithm(); + server.tool( + "BinanceAcquiringAlgorithm", + "Retrieve a list of available mining algorithms, including their name, ID, sequence, and unit.", + {}, + async () => { + try { + const response = await miningClient.restAPI.acquiringAlgorithm() + + const data = await response.data() - const data = await response.data(); + return { + content: [ + { + type: "text", + text: `Successfully retrieve a list of available mining algorithms. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieve a list of available mining algorithms. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve a list of available mining algorithms: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve a list of available mining algorithms: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-mining/mining-api/acquiringCoinname.ts b/src/tools/binance-mining/mining-api/acquiringCoinname.ts index ef422b24..aef4b04c 100644 --- a/src/tools/binance-mining/mining-api/acquiringCoinname.ts +++ b/src/tools/binance-mining/mining-api/acquiringCoinname.ts @@ -1,38 +1,40 @@ // src/tools/binance-mining/mining-api/acquiringCoinname.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { miningClient } from "../../../config/binanceClient.js" export function registerBinanceAcquiringCoinName(server: McpServer) { - server.tool( - "BinanceAcquiringCoinName", - "Fetch supported mining coins with details like coin name, ID, algorithm name, and associated algorithm ID.", - {}, - async () => { - try { - const response = await miningClient.restAPI.acquiringCoinname(); + server.tool( + "BinanceAcquiringCoinName", + "Fetch supported mining coins with details like coin name, ID, algorithm name, and associated algorithm ID.", + {}, + async () => { + try { + const response = await miningClient.restAPI.acquiringCoinname() + + const data = await response.data() - const data = await response.data(); + return { + content: [ + { + type: "text", + text: `Successfully fetched supported mining coins. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully fetched supported mining coins. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to fetched supported mining coins: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to fetched supported mining coins: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-mining/mining-api/cancelHashrateResaleConfiguration.ts b/src/tools/binance-mining/mining-api/cancelHashrateResaleConfiguration.ts index 1caed1c1..5dd7d120 100644 --- a/src/tools/binance-mining/mining-api/cancelHashrateResaleConfiguration.ts +++ b/src/tools/binance-mining/mining-api/cancelHashrateResaleConfiguration.ts @@ -1,49 +1,52 @@ // src/tools/binance-mining/mining-api/cancelHashrateResaleConfiguration.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { miningClient } from "../../../config/binanceClient.js" export function registerBinanceCancelHashRateResaleConfiguration(server: McpServer) { - server.tool( - "BinanceCancelHashRateResaleConfiguration", - "Cancel an existing hashrate resale configuration using the mining ID and account details.", - { - configId: z.number().int().describe("Mining ID").min(1), - userName: z.string().min(1).describe("Mining Account"), - recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000") - }, - async (params) => { - try { - const response = await miningClient.restAPI.cancelHashrateResaleConfiguration({ - configId: params.configId, - userName: params.userName, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCancelHashRateResaleConfiguration", + "Cancel an existing hashrate resale configuration using the mining ID and account details.", + { + configId: z.number().int().describe("Mining ID").min(1), + userName: z.string().min(1).describe("Mining Account"), + recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + }, + async (params) => { + try { + const response = await miningClient.restAPI.cancelHashrateResaleConfiguration({ + configId: params.configId, + userName: params.userName, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully canceled an existing hashrate resale configuration. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully canceled an existing hashrate resale configuration. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to canceled an existing hashrate resale configuration. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to canceled an existing hashrate resale configuration. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-mining/mining-api/earningsList.ts b/src/tools/binance-mining/mining-api/earningsList.ts index 06a4740b..3afee161 100644 --- a/src/tools/binance-mining/mining-api/earningsList.ts +++ b/src/tools/binance-mining/mining-api/earningsList.ts @@ -1,64 +1,76 @@ // src/tools/binance-mining/mining-api/earningsList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { miningClient } from "../../../config/binanceClient.js" export function registerBinanceEarningsList(server: McpServer) { - server.tool( - "BinanceEarningsList", - "Retrieves list of earnings related to mining activities, including transferred hashrate, daily hashrate, profit amount, and the status of the payment (unpaid, paying, or paid).", - { - algo: z.string().min(1).describe("Transfer algorithm (e.g., sha256)"), - userName: z.string().min(1).describe("Mining account username"), - coin: z.string().optional().describe("Coin name (optional)"), - startDate: z.number().optional().describe("Search start date (milliseconds timestamp, optional)"), - endDate: z.number().optional().describe("Search end date (milliseconds timestamp, optional)"), - pageIndex: z - .number() - .int() - .min(1) - .optional() - .describe("Page number, default is the first page starting from 1"), - pageSize: z.number().int().min(10).max(200).optional().describe("Number of pages, minimum 10, maximum 200"), - recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000") - }, - async (params) => { - try { - const response = await miningClient.restAPI.earningsList({ - algo: params.algo, - userName: params.userName, - ...(params.coin && { coin: params.coin }), - ...(params.startDate && { startDate: params.startDate }), - ...(params.endDate && { endDate: params.endDate }), - ...(params.pageIndex && { pageIndex: params.pageIndex }), - ...(params.pageSize && { pageSize: params.pageSize }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceEarningsList", + "Retrieves list of earnings related to mining activities, including transferred hashrate, daily hashrate, profit amount, and the status of the payment (unpaid, paying, or paid).", + { + algo: z.string().min(1).describe("Transfer algorithm (e.g., sha256)"), + userName: z.string().min(1).describe("Mining account username"), + coin: z.string().optional().describe("Coin name (optional)"), + startDate: z + .number() + .optional() + .describe("Search start date (milliseconds timestamp, optional)"), + endDate: z.number().optional().describe("Search end date (milliseconds timestamp, optional)"), + pageIndex: z + .number() + .int() + .min(1) + .optional() + .describe("Page number, default is the first page starting from 1"), + pageSize: z + .number() + .int() + .min(10) + .max(200) + .optional() + .describe("Number of pages, minimum 10, maximum 200"), + recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + }, + async (params) => { + try { + const response = await miningClient.restAPI.earningsList({ + algo: params.algo, + userName: params.userName, + ...(params.coin && { coin: params.coin }), + ...(params.startDate && { startDate: params.startDate }), + ...(params.endDate && { endDate: params.endDate }), + ...(params.pageIndex && { pageIndex: params.pageIndex }), + ...(params.pageSize && { pageSize: params.pageSize }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved list of earnings related to mining activities. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved list of earnings related to mining activities. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve list of earnings related to mining activities. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve list of earnings related to mining activities. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-mining/mining-api/extraBonusList.ts b/src/tools/binance-mining/mining-api/extraBonusList.ts index 0a46c53b..a49e7c0d 100644 --- a/src/tools/binance-mining/mining-api/extraBonusList.ts +++ b/src/tools/binance-mining/mining-api/extraBonusList.ts @@ -1,58 +1,70 @@ // src/tools/binance-mining/mining-api/extraBonusList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { miningClient } from "../../../config/binanceClient.js" export function registerBinanceExtraBonusList(server: McpServer) { - server.tool( - "BinanceExtraBonusList", - "Retrieves extra bonuses related to mining activities, including merged mining, activity bonuses, rebates, smart pool bonuses, income transfers, and pool savings.", - { - algo: z.string().min(1).describe("Transfer algorithm (e.g., sha256)"), - userName: z.string().min(1).describe("Mining account username"), - coin: z.string().optional().describe("Coin name (optional)"), - startDate: z.number().optional().describe("Search start date (milliseconds timestamp, optional)"), - endDate: z.number().optional().describe("Search end date (milliseconds timestamp, optional)"), - pageIndex: z.number().int().min(1).optional().describe("Page number, default is 1"), - pageSize: z.number().int().min(10).max(200).optional().describe("Number of pages, minimum 10, maximum 200"), - recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000") - }, - async (params) => { - try { - const response = await miningClient.restAPI.extraBonusList({ - algo: params.algo, - userName: params.userName, - ...(params.coin && { coin: params.coin }), - ...(params.startDate && { startDate: params.startDate }), - ...(params.endDate && { endDate: params.endDate }), - ...(params.pageIndex && { pageIndex: params.pageIndex }), - ...(params.pageSize && { pageSize: params.pageSize }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); + server.tool( + "BinanceExtraBonusList", + "Retrieves extra bonuses related to mining activities, including merged mining, activity bonuses, rebates, smart pool bonuses, income transfers, and pool savings.", + { + algo: z.string().min(1).describe("Transfer algorithm (e.g., sha256)"), + userName: z.string().min(1).describe("Mining account username"), + coin: z.string().optional().describe("Coin name (optional)"), + startDate: z + .number() + .optional() + .describe("Search start date (milliseconds timestamp, optional)"), + endDate: z.number().optional().describe("Search end date (milliseconds timestamp, optional)"), + pageIndex: z.number().int().min(1).optional().describe("Page number, default is 1"), + pageSize: z + .number() + .int() + .min(10) + .max(200) + .optional() + .describe("Number of pages, minimum 10, maximum 200"), + recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + }, + async (params) => { + try { + const response = await miningClient.restAPI.extraBonusList({ + algo: params.algo, + userName: params.userName, + ...(params.coin && { coin: params.coin }), + ...(params.startDate && { startDate: params.startDate }), + ...(params.endDate && { endDate: params.endDate }), + ...(params.pageIndex && { pageIndex: params.pageIndex }), + ...(params.pageSize && { pageSize: params.pageSize }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved extra bonuses related to mining activities. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved extra bonuses related to mining activities. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve extra bonuses related to mining activities. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve extra bonuses related to mining activities. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-mining/mining-api/hashrateResaleDetail.ts b/src/tools/binance-mining/mining-api/hashrateResaleDetail.ts index fb286b2e..770d81c9 100644 --- a/src/tools/binance-mining/mining-api/hashrateResaleDetail.ts +++ b/src/tools/binance-mining/mining-api/hashrateResaleDetail.ts @@ -1,58 +1,67 @@ // src/tools/binance-mining/mining-api/hashrateResaleDetail.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { miningClient } from "../../../config/binanceClient.js" export function registerBinanceHashRateResaleDetail(server: McpServer) { - server.tool( - "BinanceHashRateResaleDetail", - "Retrieves details of hashrate resale transactions, including the transferring and receiving subaccounts, algorithm, hash rate, transfer date, and associated income.", - { - configId: z.number().int().min(1).describe("Mining ID"), - userName: z.string().min(1).describe("Mining Account"), - pageIndex: z - .number() - .int() - .min(1) - .optional() - .describe("Page number, default is the first page starting from 1"), - pageSize: z.number().int().min(10).max(200).optional().describe("Number of pages, minimum 10, maximum 200"), - recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000") - }, - async (params) => { - try { - const response = await miningClient.restAPI.hashrateResaleDetail({ - configId: params.configId, - userName: params.userName, - ...(params.pageIndex && { pageIndex: params.pageIndex }), - ...(params.pageSize && { pageSize: params.pageSize }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceHashRateResaleDetail", + "Retrieves details of hashrate resale transactions, including the transferring and receiving subaccounts, algorithm, hash rate, transfer date, and associated income.", + { + configId: z.number().int().min(1).describe("Mining ID"), + userName: z.string().min(1).describe("Mining Account"), + pageIndex: z + .number() + .int() + .min(1) + .optional() + .describe("Page number, default is the first page starting from 1"), + pageSize: z + .number() + .int() + .min(10) + .max(200) + .optional() + .describe("Number of pages, minimum 10, maximum 200"), + recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + }, + async (params) => { + try { + const response = await miningClient.restAPI.hashrateResaleDetail({ + configId: params.configId, + userName: params.userName, + ...(params.pageIndex && { pageIndex: params.pageIndex }), + ...(params.pageSize && { pageSize: params.pageSize }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved details of hashrate resale transactions. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved details of hashrate resale transactions. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve details of hashrate resale transactions. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve details of hashrate resale transactions. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-mining/mining-api/hashrateResaleList.ts b/src/tools/binance-mining/mining-api/hashrateResaleList.ts index 83ee293f..b5b6ab27 100644 --- a/src/tools/binance-mining/mining-api/hashrateResaleList.ts +++ b/src/tools/binance-mining/mining-api/hashrateResaleList.ts @@ -1,60 +1,63 @@ // src/tools/binance-mining/mining-api/hashrateResaleList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { miningClient } from "../../../config/binanceClient.js" export function registerBinanceHashRateResaleList(server: McpServer) { - server.tool( - "BinanceHashRateResaleList", - "Returns the list of hashRate resale configurations including transfer details such as algorithm, hashrate amount, sender and receiver pool usernames, start and end dates, and status of the transfer.", - { - pageIndex: z - .number() - .int() - .min(1) - .optional() - .describe("Page number, default is the first page starting from 1"), - pageSize: z - .number() - .int() - .min(10) - .max(200) - .optional() - .describe("Number of records per page, min 10, max 200"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await miningClient.restAPI.hashrateResaleList({ - ...(params.pageIndex && { pageIndex: params.pageIndex }), - ...(params.pageSize && { pageSize: params.pageSize }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceHashRateResaleList", + "Returns the list of hashRate resale configurations including transfer details such as algorithm, hashrate amount, sender and receiver pool usernames, start and end dates, and status of the transfer.", + { + pageIndex: z + .number() + .int() + .min(1) + .optional() + .describe("Page number, default is the first page starting from 1"), + pageSize: z + .number() + .int() + .min(10) + .max(200) + .optional() + .describe("Number of records per page, min 10, max 200"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await miningClient.restAPI.hashrateResaleList({ + ...(params.pageIndex && { pageIndex: params.pageIndex }), + ...(params.pageSize && { pageSize: params.pageSize }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully return the list of hashRate resale configurations. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully return the list of hashRate resale configurations. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to return the list of hashRate resale configurations. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to return the list of hashRate resale configurations. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-mining/mining-api/hashrateResaleRequest.ts b/src/tools/binance-mining/mining-api/hashrateResaleRequest.ts index 408caca8..73c3b099 100644 --- a/src/tools/binance-mining/mining-api/hashrateResaleRequest.ts +++ b/src/tools/binance-mining/mining-api/hashrateResaleRequest.ts @@ -1,60 +1,67 @@ // src/tools/binance-mining/mining-api/hashrateResaleRequest.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { miningClient } from "../../../config/binanceClient.js" export function registerBinanceHashRateResaleRequest(server: McpServer) { - server.tool( - "BinanceHashRateResaleRequest", - "Retrieve a request for setting up a hashrate resale, specifying the mining account, algorithm, start and end times, target mining account for resale, and the amount of hashrate to transfer", - { - userName: z.string().min(1).describe("Mining Account"), - algo: z.string().min(1).describe("Transfer algorithm (e.g., sha256)"), - endDate: z.number().int().describe("Resale End Time (Millisecond timestamp)"), - startDate: z.number().int().describe("Resale Start Time (Millisecond timestamp)"), - toPoolUser: z.string().min(1).describe("Mining Account of the recipient pool user"), - hashRate: z - .number() - .int() - .describe("Resale hashrate h/s must be transferred (BTC > 500000000000, ETH > 500000)"), - recvWindow: z.number().int().optional().describe("Optional: Time window for request validity") - }, - async (params) => { - try { - const response = await miningClient.restAPI.hashrateResaleRequest({ - userName: params.userName, - algo: params.algo, - endDate: params.endDate, - startDate: params.startDate, - toPoolUser: params.toPoolUser, - hashRate: params.hashRate, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceHashRateResaleRequest", + "Retrieve a request for setting up a hashrate resale, specifying the mining account, algorithm, start and end times, target mining account for resale, and the amount of hashrate to transfer", + { + userName: z.string().min(1).describe("Mining Account"), + algo: z.string().min(1).describe("Transfer algorithm (e.g., sha256)"), + endDate: z.number().int().describe("Resale End Time (Millisecond timestamp)"), + startDate: z.number().int().describe("Resale Start Time (Millisecond timestamp)"), + toPoolUser: z.string().min(1).describe("Mining Account of the recipient pool user"), + hashRate: z + .number() + .int() + .describe("Resale hashrate h/s must be transferred (BTC > 500000000000, ETH > 500000)"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional: Time window for request validity"), + }, + async (params) => { + try { + const response = await miningClient.restAPI.hashrateResaleRequest({ + userName: params.userName, + algo: params.algo, + endDate: params.endDate, + startDate: params.startDate, + toPoolUser: params.toPoolUser, + hashRate: params.hashRate, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved request for setting up a hashrate resale. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved request for setting up a hashrate resale. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve request for setting up a hashrate resale. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve request for setting up a hashrate resale. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-mining/mining-api/miningAccountEarning.ts b/src/tools/binance-mining/mining-api/miningAccountEarning.ts index 09399b8b..17f4e9ac 100644 --- a/src/tools/binance-mining/mining-api/miningAccountEarning.ts +++ b/src/tools/binance-mining/mining-api/miningAccountEarning.ts @@ -1,61 +1,64 @@ // src/tools/binance-mining/mining-api/miningAccountEarning.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { miningClient } from "../../../config/binanceClient.js" export function registerBinanceMiningAccountEarning(server: McpServer) { - server.tool( - "BinanceMiningAccountEarning", - "Retrieves the earnings associated with a mining account, including the type of earnings (e.g., rebate, referral, refund), sub-account ID, the mining account name, and the amount earned. It also supports pagination for large data sets.", - { - algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), - startDate: z.number().int().optional().describe("Millisecond timestamp for the start date"), - endDate: z.number().int().optional().describe("Millisecond timestamp for the end date"), - pageIndex: z.number().int().min(1).optional().describe("Page number, default is 1"), - pageSize: z - .number() - .int() - .min(10) - .max(200) - .optional() - .describe("Number of records per page, min 10, max 200"), - recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000") - }, - async (params) => { - try { - const response = await miningClient.restAPI.miningAccountEarning({ - algo: params.algo, - ...(params.startDate && { startDate: params.startDate }), - ...(params.endDate && { endDate: params.endDate }), - ...(params.pageIndex && { pageIndex: params.pageIndex }), - ...(params.pageSize && { pageSize: params.pageSize }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceMiningAccountEarning", + "Retrieves the earnings associated with a mining account, including the type of earnings (e.g., rebate, referral, refund), sub-account ID, the mining account name, and the amount earned. It also supports pagination for large data sets.", + { + algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), + startDate: z.number().int().optional().describe("Millisecond timestamp for the start date"), + endDate: z.number().int().optional().describe("Millisecond timestamp for the end date"), + pageIndex: z.number().int().min(1).optional().describe("Page number, default is 1"), + pageSize: z + .number() + .int() + .min(10) + .max(200) + .optional() + .describe("Number of records per page, min 10, max 200"), + recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + }, + async (params) => { + try { + const response = await miningClient.restAPI.miningAccountEarning({ + algo: params.algo, + ...(params.startDate && { startDate: params.startDate }), + ...(params.endDate && { endDate: params.endDate }), + ...(params.pageIndex && { pageIndex: params.pageIndex }), + ...(params.pageSize && { pageSize: params.pageSize }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved the earnings associated with a mining account. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved the earnings associated with a mining account. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve the earnings associated with a mining account. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve the earnings associated with a mining account. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-mining/mining-api/requestForDetailMinerList.ts b/src/tools/binance-mining/mining-api/requestForDetailMinerList.ts index df5fb763..a45268a5 100644 --- a/src/tools/binance-mining/mining-api/requestForDetailMinerList.ts +++ b/src/tools/binance-mining/mining-api/requestForDetailMinerList.ts @@ -1,51 +1,54 @@ // src/tools/binance-mining/mining-api/requestForDetailMinerList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { miningClient } from "../../../config/binanceClient.js" export function registerBinanceRequestForDetailMinerList(server: McpServer) { - server.tool( - "BinanceRequestForDetailMinerList", - "Retrieves detailed hashrate data for a specific miner, including both hourly (H_hashrate) and daily (D_hashrate) metrics such as time, hashrate, and rejection rate.", - { - algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), - userName: z.string().min(1).describe("Mining account username"), - workerName: z.string().min(1).describe("Miner’s name (required), e.g., bhdc1.16A10404B"), - recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000") - }, - async (params) => { - try { - const response = await miningClient.restAPI.requestForDetailMinerList({ - algo: params.algo, - userName: params.userName, - workerName: params.workerName, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceRequestForDetailMinerList", + "Retrieves detailed hashrate data for a specific miner, including both hourly (H_hashrate) and daily (D_hashrate) metrics such as time, hashrate, and rejection rate.", + { + algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), + userName: z.string().min(1).describe("Mining account username"), + workerName: z.string().min(1).describe("Miner’s name (required), e.g., bhdc1.16A10404B"), + recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + }, + async (params) => { + try { + const response = await miningClient.restAPI.requestForDetailMinerList({ + algo: params.algo, + userName: params.userName, + workerName: params.workerName, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved detailed hashrate data for a specific miner. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved detailed hashrate data for a specific miner. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve detailed hashrate data for a specific miner. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve detailed hashrate data for a specific miner. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-mining/mining-api/requestForMinerList.ts b/src/tools/binance-mining/mining-api/requestForMinerList.ts index 009f3811..f83cb473 100644 --- a/src/tools/binance-mining/mining-api/requestForMinerList.ts +++ b/src/tools/binance-mining/mining-api/requestForMinerList.ts @@ -1,82 +1,85 @@ // src/tools/binance-mining/mining-api/requestForMinerList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { miningClient } from "../../../config/binanceClient.js" export function registerBinanceRequestForMinerList(server: McpServer) { - server.tool( - "BinanceRequestForMinerList", - "Retrieves a list of miners (workers) associated with a mining account, including details such as miner name, status, real-time hashrate, 24H hashrate, rejection rate, and last submission time.", - { - algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), - userName: z.string().min(1).describe("Mining account username"), - pageIndex: z - .number() - .int() - .min(1) - .optional() - .describe("Page number, default is first page, starting from 1"), - sort: z - .number() - .int() - .min(0) - .max(1) - .optional() - .describe("Sort sequence: 0 = ascending (default), 1 = descending"), - sortColumn: z - .number() - .int() - .min(1) - .max(5) - .optional() - .describe( - `Sort by (default = 1): 1: miner name, 2: real-time computing power, 3: daily average computing power, 4: real-time rejection rate, 5: last submission time` - ), - workerStatus: z - .number() - .int() - .min(0) - .max(3) - .optional() - .describe("Miner status (default = 0): 0 = all, 1 = valid, 2 = invalid, 3 = failure"), - recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000") - }, - async (params) => { - try { - const response = await miningClient.restAPI.requestForMinerList({ - algo: params.algo, - userName: params.userName, - ...(params.pageIndex && { pageIndex: params.pageIndex }), - ...(params.sort && { sort: params.sort }), - ...(params.sortColumn && { sortColumn: params.sortColumn }), - ...(params.workerStatus && { workerStatus: params.workerStatus }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceRequestForMinerList", + "Retrieves a list of miners (workers) associated with a mining account, including details such as miner name, status, real-time hashrate, 24H hashrate, rejection rate, and last submission time.", + { + algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), + userName: z.string().min(1).describe("Mining account username"), + pageIndex: z + .number() + .int() + .min(1) + .optional() + .describe("Page number, default is first page, starting from 1"), + sort: z + .number() + .int() + .min(0) + .max(1) + .optional() + .describe("Sort sequence: 0 = ascending (default), 1 = descending"), + sortColumn: z + .number() + .int() + .min(1) + .max(5) + .optional() + .describe( + `Sort by (default = 1): 1: miner name, 2: real-time computing power, 3: daily average computing power, 4: real-time rejection rate, 5: last submission time`, + ), + workerStatus: z + .number() + .int() + .min(0) + .max(3) + .optional() + .describe("Miner status (default = 0): 0 = all, 1 = valid, 2 = invalid, 3 = failure"), + recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + }, + async (params) => { + try { + const response = await miningClient.restAPI.requestForMinerList({ + algo: params.algo, + userName: params.userName, + ...(params.pageIndex && { pageIndex: params.pageIndex }), + ...(params.sort && { sort: params.sort }), + ...(params.sortColumn && { sortColumn: params.sortColumn }), + ...(params.workerStatus && { workerStatus: params.workerStatus }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved a list of miners (workers) associated with a mining account. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved a list of miners (workers) associated with a mining account. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve a list of miners (workers) associated with a mining account. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve a list of miners (workers) associated with a mining account. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-mining/mining-api/statisticList.ts b/src/tools/binance-mining/mining-api/statisticList.ts index 3be2a279..0b7e4631 100644 --- a/src/tools/binance-mining/mining-api/statisticList.ts +++ b/src/tools/binance-mining/mining-api/statisticList.ts @@ -1,48 +1,55 @@ // src/tools/binance-mining/mining-api/statisticList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { miningClient } from "../../../config/binanceClient.js" export function registerBinanceStatisticList(server: McpServer) { - server.tool( - "BinanceStatisticList", - "Retrieve mining statistics for a specific account, including hash rates for the past 15 minutes and 24 hours, the number of valid and invalid mining units, and the estimated profit for today and yesterday in various cryptocurrencies.", - { - algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), - userName: z.string().min(1).describe("Mining account username"), - recvWindow: z.number().int().optional().describe("Optional: Time window for request validity") - }, - async (params) => { - try { - const response = await miningClient.restAPI.statisticList({ - algo: params.algo, - userName: params.userName, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); + server.tool( + "BinanceStatisticList", + "Retrieve mining statistics for a specific account, including hash rates for the past 15 minutes and 24 hours, the number of valid and invalid mining units, and the estimated profit for today and yesterday in various cryptocurrencies.", + { + algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), + userName: z.string().min(1).describe("Mining account username"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional: Time window for request validity"), + }, + async (params) => { + try { + const response = await miningClient.restAPI.statisticList({ + algo: params.algo, + userName: params.userName, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved mining statistics for a specific account. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved mining statistics for a specific account. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve mining statistics for a specific account. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve mining statistics for a specific account. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-nft/index.ts b/src/tools/binance-nft/index.ts index 36234150..da7e111f 100644 --- a/src/tools/binance-nft/index.ts +++ b/src/tools/binance-nft/index.ts @@ -1,13 +1,14 @@ // src/tools/binance-fiat/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetNFTDepositHistory } from "./nft-api/getNFTDepositHistory.js"; -import { registerBinanceGetNFTWithdrawHistory } from "./nft-api/getNFTWithdrawHistory.js"; -import { registerBinanceGetNFTTransactionHistory } from "./nft-api/getNFTTransactionHistory.js"; -import { registerBinanceGetNFTAsset } from "./nft-api/getNFTAsset.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceGetNFTAsset } from "./nft-api/getNFTAsset.js" +import { registerBinanceGetNFTDepositHistory } from "./nft-api/getNFTDepositHistory.js" +import { registerBinanceGetNFTTransactionHistory } from "./nft-api/getNFTTransactionHistory.js" +import { registerBinanceGetNFTWithdrawHistory } from "./nft-api/getNFTWithdrawHistory.js" export function registerBinanceNFTTools(server: McpServer) { - registerBinanceGetNFTDepositHistory(server); - registerBinanceGetNFTWithdrawHistory(server); - registerBinanceGetNFTTransactionHistory(server); - registerBinanceGetNFTAsset(server); + registerBinanceGetNFTDepositHistory(server) + registerBinanceGetNFTWithdrawHistory(server) + registerBinanceGetNFTTransactionHistory(server) + registerBinanceGetNFTAsset(server) } diff --git a/src/tools/binance-nft/nft-api/getNFTAsset.ts b/src/tools/binance-nft/nft-api/getNFTAsset.ts index e5d658b0..dc5cc49c 100644 --- a/src/tools/binance-nft/nft-api/getNFTAsset.ts +++ b/src/tools/binance-nft/nft-api/getNFTAsset.ts @@ -1,54 +1,57 @@ // src/tools/binance-nft/nft-api/getNFTAsset.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { nftClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { nftClient } from "../../../config/binanceClient.js" export function registerBinanceGetNFTAsset(server: McpServer) { - server.tool( - "BinanceGetNFTAsset", - "Retrieve NFT assets associated with a user's account. It returns details about the network, contract address, and token IDs for each NFT asset.", - { - limit: z - .number() - .int() - .max(50, "Limit cannot be greater than 50") - .default(50) - .describe("Number of records to return, default 50, max 50"), - page: z.number().int().default(1).describe("Page number, default is 1"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await nftClient.restAPI.getNFTAsset({ - ...(params.limit && { limit: params.limit }), - ...(params.page && { page: params.page }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetNFTAsset", + "Retrieve NFT assets associated with a user's account. It returns details about the network, contract address, and token IDs for each NFT asset.", + { + limit: z + .number() + .int() + .max(50, "Limit cannot be greater than 50") + .default(50) + .describe("Number of records to return, default 50, max 50"), + page: z.number().int().default(1).describe("Page number, default is 1"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await nftClient.restAPI.getNFTAsset({ + ...(params.limit && { limit: params.limit }), + ...(params.page && { page: params.page }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved NFT assets associated with a user's account. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved NFT assets associated with a user's account. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve NFT assets : ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve NFT assets : ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-nft/nft-api/getNFTDepositHistory.ts b/src/tools/binance-nft/nft-api/getNFTDepositHistory.ts index 631e647c..a01bc6a2 100644 --- a/src/tools/binance-nft/nft-api/getNFTDepositHistory.ts +++ b/src/tools/binance-nft/nft-api/getNFTDepositHistory.ts @@ -1,58 +1,61 @@ // src/tools/binance-nft/nft-api/getNFTDepositHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { nftClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { nftClient } from "../../../config/binanceClient.js" export function registerBinanceGetNFTDepositHistory(server: McpServer) { - server.tool( - "BinanceGetNFTDepositHistory", - "Retrieves NFT deposit history, including network, contract address, token ID, transaction ID (if available), and timestamps.", - { - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .max(50, "Limit cannot be greater than 50") - .optional() - .describe("Number of records to return, default 50, max 50"), - page: z.number().int().optional().describe("Page number, default is 1"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await nftClient.restAPI.getNFTDepositHistory({ - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.page && { page: params.page }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetNFTDepositHistory", + "Retrieves NFT deposit history, including network, contract address, token ID, transaction ID (if available), and timestamps.", + { + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(50, "Limit cannot be greater than 50") + .optional() + .describe("Number of records to return, default 50, max 50"), + page: z.number().int().optional().describe("Page number, default is 1"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await nftClient.restAPI.getNFTDepositHistory({ + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.page && { page: params.page }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved NFT deposit history, including network, contract address, token ID. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved NFT deposit history, including network, contract address, token ID. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieves NFT deposit history: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieves NFT deposit history: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-nft/nft-api/getNFTTransactionHistory.ts b/src/tools/binance-nft/nft-api/getNFTTransactionHistory.ts index 86b27c9f..8c755bc9 100644 --- a/src/tools/binance-nft/nft-api/getNFTTransactionHistory.ts +++ b/src/tools/binance-nft/nft-api/getNFTTransactionHistory.ts @@ -1,62 +1,65 @@ // src/tools/binance-nft/nft-api/getNFTTransactionHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { nftClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { nftClient } from "../../../config/binanceClient.js" export function registerBinanceGetNFTTransactionHistory(server: McpServer) { - server.tool( - "BinanceGetNFTTransactionHistory", - "Retrieves NFT transaction history, including purchase orders, sale orders, royalty income, primary market orders, and mint fees. It returns details about the NFT network, token IDs, contract addresses, transaction times, trade amounts, and the currencies used in the transactions.", - { - orderType: z - .number() - .describe( - "Order type: 0 for purchase order, 1 for sell order, 2 for royalty income, 3 for primary market order, 4 for mint fee" - ), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .max(50, "Limit cannot be greater than 50") - .default(50) - .describe("Number of records to return, default 50, max 50"), - page: z.number().int().default(1).describe("Page number, default is 1"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await nftClient.restAPI.getNFTTransactionHistory({ - orderType: params.orderType, - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.page && { page: params.page }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetNFTTransactionHistory", + "Retrieves NFT transaction history, including purchase orders, sale orders, royalty income, primary market orders, and mint fees. It returns details about the NFT network, token IDs, contract addresses, transaction times, trade amounts, and the currencies used in the transactions.", + { + orderType: z + .number() + .describe( + "Order type: 0 for purchase order, 1 for sell order, 2 for royalty income, 3 for primary market order, 4 for mint fee", + ), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(50, "Limit cannot be greater than 50") + .default(50) + .describe("Number of records to return, default 50, max 50"), + page: z.number().int().default(1).describe("Page number, default is 1"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await nftClient.restAPI.getNFTTransactionHistory({ + orderType: params.orderType, + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.page && { page: params.page }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved NFT transaction history. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved NFT transaction history. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve NFT transaction history: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve NFT transaction history: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-nft/nft-api/getNFTWithdrawHistory.ts b/src/tools/binance-nft/nft-api/getNFTWithdrawHistory.ts index f2ab7722..6cf2bdb7 100644 --- a/src/tools/binance-nft/nft-api/getNFTWithdrawHistory.ts +++ b/src/tools/binance-nft/nft-api/getNFTWithdrawHistory.ts @@ -1,58 +1,61 @@ // src/tools/binance-nft/nft-api/getNFTWithdrawHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { nftClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { nftClient } from "../../../config/binanceClient.js" export function registerBinanceGetNFTWithdrawHistory(server: McpServer) { - server.tool( - "BinanceGetNFTWithdrawHistory", - "Retrieves NFT withdraw history, including network, transaction ID, contract address, token ID, withdrawal fee, fee asset, and timestamps.", - { - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .max(50, "Limit cannot be greater than 50") - .default(50) - .describe("Number of records to return, default 50, max 50"), - page: z.number().int().default(1).describe("Page number, default is 1"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await nftClient.restAPI.getNFTWithdrawHistory({ - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.page && { page: params.page }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetNFTWithdrawHistory", + "Retrieves NFT withdraw history, including network, transaction ID, contract address, token ID, withdrawal fee, fee asset, and timestamps.", + { + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(50, "Limit cannot be greater than 50") + .default(50) + .describe("Number of records to return, default 50, max 50"), + page: z.number().int().default(1).describe("Page number, default is 1"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await nftClient.restAPI.getNFTWithdrawHistory({ + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.page && { page: params.page }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved NFT withdraw history, including network, transaction ID, contract address. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved NFT withdraw history, including network, transaction ID, contract address. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve NFT withdraw history: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve NFT withdraw history: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-options/account.ts b/src/tools/binance-options/account.ts index a7ee5682..f068d751 100644 --- a/src/tools/binance-options/account.ts +++ b/src/tools/binance-options/account.ts @@ -1,33 +1,28 @@ // src/tools/binance-options/account.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { optionsClient } from "../../config/binanceClient.js" export function registerBinanceOptionsAccount(server: McpServer) { - server.tool( - "BinanceOptionsAccount", - "Get current options account information.", - {}, - async () => { - try { - const data = await optionsClient.account(); - - return { - content: [ - { - type: "text", - text: `Options account information retrieved. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get account info: ${errorMessage}` } - ], - isError: true - }; - } - } - ); + server.tool("BinanceOptionsAccount", "Get current options account information.", {}, async () => { + try { + const data = await optionsClient.account() + + return { + content: [ + { + type: "text", + text: `Options account information retrieved. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get account info: ${errorMessage}` }], + isError: true, + } + } + }) } diff --git a/src/tools/binance-options/batchOrders.ts b/src/tools/binance-options/batchOrders.ts index 5de8a6f0..409f67f1 100644 --- a/src/tools/binance-options/batchOrders.ts +++ b/src/tools/binance-options/batchOrders.ts @@ -1,38 +1,43 @@ // src/tools/binance-options/batchOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../config/binanceClient.js" export function registerBinanceOptionsBatchOrders(server: McpServer) { - server.tool( - "BinanceOptionsBatchOrders", - "Place multiple options orders in batch.", - { - orders: z.string().describe("JSON array of orders, each containing symbol, side, type, quantity, and optionally price, timeInForce, reduceOnly, postOnly, clientOrderId") - }, - async ({ orders }) => { - try { - const params: any = { orders }; - - const data = await optionsClient.batchOrders(params); - - return { - content: [ - { - type: "text", - text: `Batch orders placed successfully. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to place batch orders: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceOptionsBatchOrders", + "Place multiple options orders in batch.", + { + orders: z + .string() + .describe( + "JSON array of orders, each containing symbol, side, type, quantity, and optionally price, timeInForce, reduceOnly, postOnly, clientOrderId", + ), + }, + async ({ orders }) => { + try { + const params: any = { orders } + + const data = await optionsClient.batchOrders(params) + + return { + content: [ + { + type: "text", + text: `Batch orders placed successfully. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to place batch orders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-options/bill.ts b/src/tools/binance-options/bill.ts index 4c553658..b18a8ddb 100644 --- a/src/tools/binance-options/bill.ts +++ b/src/tools/binance-options/bill.ts @@ -1,47 +1,48 @@ // src/tools/binance-options/bill.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../config/binanceClient.js" export function registerBinanceOptionsBill(server: McpServer) { - server.tool( - "BinanceOptionsBill", - "Get options account funding flow (bill history).", - { - currency: z.string().optional().describe("Currency (e.g., USDT)"), - recordId: z.number().optional().describe("Record ID to fetch from"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Number of records to return. Default 100; max 1000.") - }, - async ({ currency, recordId, startTime, endTime, limit }) => { - try { - const params: any = {}; - if (currency) params.currency = currency; - if (recordId !== undefined) params.recordId = recordId; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; - - const data = await optionsClient.bill(params); - - return { - content: [ - { - type: "text", - text: `Bill history retrieved. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get bill history: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceOptionsBill", + "Get options account funding flow (bill history).", + { + currency: z.string().optional().describe("Currency (e.g., USDT)"), + recordId: z.number().optional().describe("Record ID to fetch from"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Number of records to return. Default 100; max 1000."), + }, + async ({ currency, recordId, startTime, endTime, limit }) => { + try { + const params: any = {} + if (currency) params.currency = currency + if (recordId !== undefined) params.recordId = recordId + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit + + const data = await optionsClient.bill(params) + + return { + content: [ + { + type: "text", + text: `Bill history retrieved. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get bill history: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-options/cancelAllOrders.ts b/src/tools/binance-options/cancelAllOrders.ts index b4262300..bd78d7d1 100644 --- a/src/tools/binance-options/cancelAllOrders.ts +++ b/src/tools/binance-options/cancelAllOrders.ts @@ -1,38 +1,39 @@ // src/tools/binance-options/cancelAllOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../config/binanceClient.js" export function registerBinanceOptionsCancelAllOrders(server: McpServer) { - server.tool( - "BinanceOptionsCancelAllOrders", - "Cancel all open options orders for a symbol.", - { - symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)") - }, - async ({ symbol }) => { - try { - const params: any = { symbol }; - - const data = await optionsClient.cancelAllOrders(params); - - return { - content: [ - { - type: "text", - text: `All orders cancelled successfully. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to cancel all orders: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceOptionsCancelAllOrders", + "Cancel all open options orders for a symbol.", + { + symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + }, + async ({ symbol }) => { + try { + const params: any = { symbol } + + const data = await optionsClient.cancelAllOrders(params) + + return { + content: [ + { + type: "text", + text: `All orders cancelled successfully. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to cancel all orders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-options/cancelBatchOrders.ts b/src/tools/binance-options/cancelBatchOrders.ts index c785affb..2f3a2774 100644 --- a/src/tools/binance-options/cancelBatchOrders.ts +++ b/src/tools/binance-options/cancelBatchOrders.ts @@ -1,42 +1,46 @@ // src/tools/binance-options/cancelBatchOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../config/binanceClient.js" export function registerBinanceOptionsCancelBatchOrders(server: McpServer) { - server.tool( - "BinanceOptionsCancelBatchOrders", - "Cancel multiple options orders in batch.", - { - symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), - orderIds: z.string().optional().describe("Comma-separated list of order IDs to cancel"), - clientOrderIds: z.string().optional().describe("Comma-separated list of client order IDs to cancel") - }, - async ({ symbol, orderIds, clientOrderIds }) => { - try { - const params: any = { symbol }; - if (orderIds) params.orderIds = orderIds; - if (clientOrderIds) params.clientOrderIds = clientOrderIds; - - const data = await optionsClient.cancelBatchOrders(params); - - return { - content: [ - { - type: "text", - text: `Batch orders cancelled successfully. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to cancel batch orders: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceOptionsCancelBatchOrders", + "Cancel multiple options orders in batch.", + { + symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + orderIds: z.string().optional().describe("Comma-separated list of order IDs to cancel"), + clientOrderIds: z + .string() + .optional() + .describe("Comma-separated list of client order IDs to cancel"), + }, + async ({ symbol, orderIds, clientOrderIds }) => { + try { + const params: any = { symbol } + if (orderIds) params.orderIds = orderIds + if (clientOrderIds) params.clientOrderIds = clientOrderIds + + const data = await optionsClient.cancelBatchOrders(params) + + return { + content: [ + { + type: "text", + text: `Batch orders cancelled successfully. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to cancel batch orders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-options/cancelOrder.ts b/src/tools/binance-options/cancelOrder.ts index e65bb219..dd514344 100644 --- a/src/tools/binance-options/cancelOrder.ts +++ b/src/tools/binance-options/cancelOrder.ts @@ -1,42 +1,43 @@ // src/tools/binance-options/cancelOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../config/binanceClient.js" export function registerBinanceOptionsCancelOrder(server: McpServer) { - server.tool( - "BinanceOptionsCancelOrder", - "Cancel an existing options order.", - { - symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), - orderId: z.number().optional().describe("Order ID"), - clientOrderId: z.string().optional().describe("Client order ID") - }, - async ({ symbol, orderId, clientOrderId }) => { - try { - const params: any = { symbol }; - if (orderId !== undefined) params.orderId = orderId; - if (clientOrderId) params.clientOrderId = clientOrderId; - - const data = await optionsClient.cancelOrder(params); - - return { - content: [ - { - type: "text", - text: `Order cancelled successfully. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to cancel order: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceOptionsCancelOrder", + "Cancel an existing options order.", + { + symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + orderId: z.number().optional().describe("Order ID"), + clientOrderId: z.string().optional().describe("Client order ID"), + }, + async ({ symbol, orderId, clientOrderId }) => { + try { + const params: any = { symbol } + if (orderId !== undefined) params.orderId = orderId + if (clientOrderId) params.clientOrderId = clientOrderId + + const data = await optionsClient.cancelOrder(params) + + return { + content: [ + { + type: "text", + text: `Order cancelled successfully. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to cancel order: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-options/depth.ts b/src/tools/binance-options/depth.ts index 495d523c..9e11f628 100644 --- a/src/tools/binance-options/depth.ts +++ b/src/tools/binance-options/depth.ts @@ -1,40 +1,41 @@ // src/tools/binance-options/depth.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../config/binanceClient.js" export function registerBinanceOptionsDepth(server: McpServer) { - server.tool( - "BinanceOptionsDepth", - "Get order book depth for an option symbol.", - { - symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), - limit: z.number().optional().describe("Depth limit. Default 100; max 1000.") - }, - async ({ symbol, limit }) => { - try { - const params: any = { symbol }; - if (limit !== undefined) params.limit = limit; - - const data = await optionsClient.depth(params); - - return { - content: [ - { - type: "text", - text: `Order book depth for ${symbol}. Bids: ${data.bids?.length || 0}, Asks: ${data.asks?.length || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get order book depth: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceOptionsDepth", + "Get order book depth for an option symbol.", + { + symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + limit: z.number().optional().describe("Depth limit. Default 100; max 1000."), + }, + async ({ symbol, limit }) => { + try { + const params: any = { symbol } + if (limit !== undefined) params.limit = limit + + const data = await optionsClient.depth(params) + + return { + content: [ + { + type: "text", + text: `Order book depth for ${symbol}. Bids: ${data.bids?.length || 0}, Asks: ${data.asks?.length || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get order book depth: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-options/exchangeInfo.ts b/src/tools/binance-options/exchangeInfo.ts index 5960e653..51e3b8e2 100644 --- a/src/tools/binance-options/exchangeInfo.ts +++ b/src/tools/binance-options/exchangeInfo.ts @@ -1,39 +1,40 @@ // src/tools/binance-options/exchangeInfo.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../config/binanceClient.js" export function registerBinanceOptionsExchangeInfo(server: McpServer) { - server.tool( - "BinanceOptionsExchangeInfo", - "Get current exchange trading rules and symbol information for options.", - { - symbol: z.string().optional().describe("Option trading symbol (e.g., BTC-240126-42000-C)") - }, - async ({ symbol }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - - const data = await optionsClient.exchangeInfo(params); - - return { - content: [ - { - type: "text", - text: `Exchange info retrieved successfully. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get exchange info: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceOptionsExchangeInfo", + "Get current exchange trading rules and symbol information for options.", + { + symbol: z.string().optional().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + }, + async ({ symbol }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + + const data = await optionsClient.exchangeInfo(params) + + return { + content: [ + { + type: "text", + text: `Exchange info retrieved successfully. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get exchange info: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-options/exerciseHistory.ts b/src/tools/binance-options/exerciseHistory.ts index 27b3a8d1..93d9634b 100644 --- a/src/tools/binance-options/exerciseHistory.ts +++ b/src/tools/binance-options/exerciseHistory.ts @@ -1,45 +1,46 @@ // src/tools/binance-options/exerciseHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../config/binanceClient.js" export function registerBinanceOptionsExerciseHistory(server: McpServer) { - server.tool( - "BinanceOptionsExerciseHistory", - "Get historical exercise records for options.", - { - underlying: z.string().optional().describe("Underlying asset (e.g., BTCUSDT)"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Number of records to return. Default 100; max 100.") - }, - async ({ underlying, startTime, endTime, limit }) => { - try { - const params: any = {}; - if (underlying) params.underlying = underlying; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; - - const data = await optionsClient.exerciseHistory(params); - - return { - content: [ - { - type: "text", - text: `Exercise history retrieved. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get exercise history: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceOptionsExerciseHistory", + "Get historical exercise records for options.", + { + underlying: z.string().optional().describe("Underlying asset (e.g., BTCUSDT)"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Number of records to return. Default 100; max 100."), + }, + async ({ underlying, startTime, endTime, limit }) => { + try { + const params: any = {} + if (underlying) params.underlying = underlying + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit + + const data = await optionsClient.exerciseHistory(params) + + return { + content: [ + { + type: "text", + text: `Exercise history retrieved. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get exercise history: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-options/exerciseRecord.ts b/src/tools/binance-options/exerciseRecord.ts index f8123cc8..f52184c4 100644 --- a/src/tools/binance-options/exerciseRecord.ts +++ b/src/tools/binance-options/exerciseRecord.ts @@ -1,45 +1,46 @@ // src/tools/binance-options/exerciseRecord.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../config/binanceClient.js" export function registerBinanceOptionsExerciseRecord(server: McpServer) { - server.tool( - "BinanceOptionsExerciseRecord", - "Get user's options exercise records.", - { - symbol: z.string().optional().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Number of records to return. Default 100; max 1000.") - }, - async ({ symbol, startTime, endTime, limit }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; - - const data = await optionsClient.exerciseRecord(params); - - return { - content: [ - { - type: "text", - text: `Exercise records retrieved. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get exercise records: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceOptionsExerciseRecord", + "Get user's options exercise records.", + { + symbol: z.string().optional().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Number of records to return. Default 100; max 1000."), + }, + async ({ symbol, startTime, endTime, limit }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit + + const data = await optionsClient.exerciseRecord(params) + + return { + content: [ + { + type: "text", + text: `Exercise records retrieved. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get exercise records: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-options/getOrder.ts b/src/tools/binance-options/getOrder.ts index 2cf4302d..e0a7ac8e 100644 --- a/src/tools/binance-options/getOrder.ts +++ b/src/tools/binance-options/getOrder.ts @@ -1,42 +1,43 @@ // src/tools/binance-options/getOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../config/binanceClient.js" export function registerBinanceOptionsGetOrder(server: McpServer) { - server.tool( - "BinanceOptionsGetOrder", - "Query an options order by order ID or client order ID.", - { - symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), - orderId: z.number().optional().describe("Order ID"), - clientOrderId: z.string().optional().describe("Client order ID") - }, - async ({ symbol, orderId, clientOrderId }) => { - try { - const params: any = { symbol }; - if (orderId !== undefined) params.orderId = orderId; - if (clientOrderId) params.clientOrderId = clientOrderId; - - const data = await optionsClient.getOrder(params); - - return { - content: [ - { - type: "text", - text: `Order details retrieved. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get order: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceOptionsGetOrder", + "Query an options order by order ID or client order ID.", + { + symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + orderId: z.number().optional().describe("Order ID"), + clientOrderId: z.string().optional().describe("Client order ID"), + }, + async ({ symbol, orderId, clientOrderId }) => { + try { + const params: any = { symbol } + if (orderId !== undefined) params.orderId = orderId + if (clientOrderId) params.clientOrderId = clientOrderId + + const data = await optionsClient.getOrder(params) + + return { + content: [ + { + type: "text", + text: `Order details retrieved. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get order: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-options/historicalTrades.ts b/src/tools/binance-options/historicalTrades.ts index 0ffc5ce3..b1d36c30 100644 --- a/src/tools/binance-options/historicalTrades.ts +++ b/src/tools/binance-options/historicalTrades.ts @@ -1,42 +1,43 @@ // src/tools/binance-options/historicalTrades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../config/binanceClient.js" export function registerBinanceOptionsHistoricalTrades(server: McpServer) { - server.tool( - "BinanceOptionsHistoricalTrades", - "Get historical trades for an option symbol.", - { - symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), - fromId: z.number().optional().describe("Trade ID to fetch from"), - limit: z.number().optional().describe("Number of trades to return. Default 100; max 500.") - }, - async ({ symbol, fromId, limit }) => { - try { - const params: any = { symbol }; - if (fromId !== undefined) params.fromId = fromId; - if (limit !== undefined) params.limit = limit; - - const data = await optionsClient.historicalTrades(params); - - return { - content: [ - { - type: "text", - text: `Historical trades for ${symbol}. Count: ${Array.isArray(data) ? data.length : 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get historical trades: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceOptionsHistoricalTrades", + "Get historical trades for an option symbol.", + { + symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + fromId: z.number().optional().describe("Trade ID to fetch from"), + limit: z.number().optional().describe("Number of trades to return. Default 100; max 500."), + }, + async ({ symbol, fromId, limit }) => { + try { + const params: any = { symbol } + if (fromId !== undefined) params.fromId = fromId + if (limit !== undefined) params.limit = limit + + const data = await optionsClient.historicalTrades(params) + + return { + content: [ + { + type: "text", + text: `Historical trades for ${symbol}. Count: ${Array.isArray(data) ? data.length : 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get historical trades: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-options/historyOrders.ts b/src/tools/binance-options/historyOrders.ts index d4b5d2e7..c07196a4 100644 --- a/src/tools/binance-options/historyOrders.ts +++ b/src/tools/binance-options/historyOrders.ts @@ -1,46 +1,47 @@ // src/tools/binance-options/historyOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../config/binanceClient.js" export function registerBinanceOptionsHistoryOrders(server: McpServer) { - server.tool( - "BinanceOptionsHistoryOrders", - "Get historical options orders.", - { - symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), - orderId: z.number().optional().describe("Order ID to fetch from"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Number of orders to return. Default 100; max 1000.") - }, - async ({ symbol, orderId, startTime, endTime, limit }) => { - try { - const params: any = { symbol }; - if (orderId !== undefined) params.orderId = orderId; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; - - const data = await optionsClient.historyOrders(params); - - return { - content: [ - { - type: "text", - text: `Historical orders retrieved. Count: ${Array.isArray(data) ? data.length : 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get history orders: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceOptionsHistoryOrders", + "Get historical options orders.", + { + symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + orderId: z.number().optional().describe("Order ID to fetch from"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Number of orders to return. Default 100; max 1000."), + }, + async ({ symbol, orderId, startTime, endTime, limit }) => { + try { + const params: any = { symbol } + if (orderId !== undefined) params.orderId = orderId + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit + + const data = await optionsClient.historyOrders(params) + + return { + content: [ + { + type: "text", + text: `Historical orders retrieved. Count: ${Array.isArray(data) ? data.length : 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get history orders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-options/index.ts b/src/tools/binance-options/index.ts index 1b2ec9ef..d79773ff 100644 --- a/src/tools/binance-options/index.ts +++ b/src/tools/binance-options/index.ts @@ -1,74 +1,72 @@ // src/tools/binance-options/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; - -// Market Data -import { registerBinanceOptionsPing } from "./ping.js"; -import { registerBinanceOptionsTime } from "./time.js"; -import { registerBinanceOptionsExchangeInfo } from "./exchangeInfo.js"; -import { registerBinanceOptionsDepth } from "./depth.js"; -import { registerBinanceOptionsTrades } from "./trades.js"; -import { registerBinanceOptionsHistoricalTrades } from "./historicalTrades.js"; -import { registerBinanceOptionsKlines } from "./klines.js"; -import { registerBinanceOptionsMark } from "./mark.js"; -import { registerBinanceOptionsTicker } from "./ticker.js"; -import { registerBinanceOptionsIndexPrice } from "./indexPrice.js"; -import { registerBinanceOptionsExerciseHistory } from "./exerciseHistory.js"; -import { registerBinanceOptionsOpenInterest } from "./openInterest.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" // Account & Trading -import { registerBinanceOptionsAccount } from "./account.js"; -import { registerBinanceOptionsNewOrder } from "./newOrder.js"; -import { registerBinanceOptionsBatchOrders } from "./batchOrders.js"; -import { registerBinanceOptionsCancelOrder } from "./cancelOrder.js"; -import { registerBinanceOptionsCancelAllOrders } from "./cancelAllOrders.js"; -import { registerBinanceOptionsCancelBatchOrders } from "./cancelBatchOrders.js"; -import { registerBinanceOptionsGetOrder } from "./getOrder.js"; -import { registerBinanceOptionsOpenOrders } from "./openOrders.js"; -import { registerBinanceOptionsHistoryOrders } from "./historyOrders.js"; -import { registerBinanceOptionsPosition } from "./position.js"; -import { registerBinanceOptionsUserTrades } from "./userTrades.js"; -import { registerBinanceOptionsExerciseRecord } from "./exerciseRecord.js"; -import { registerBinanceOptionsBill } from "./bill.js"; - +import { registerBinanceOptionsAccount } from "./account.js" +import { registerBinanceOptionsBatchOrders } from "./batchOrders.js" +import { registerBinanceOptionsBill } from "./bill.js" +import { registerBinanceOptionsCancelAllOrders } from "./cancelAllOrders.js" +import { registerBinanceOptionsCancelBatchOrders } from "./cancelBatchOrders.js" +import { registerBinanceOptionsCancelOrder } from "./cancelOrder.js" +import { registerBinanceOptionsDepth } from "./depth.js" +import { registerBinanceOptionsExchangeInfo } from "./exchangeInfo.js" +import { registerBinanceOptionsExerciseHistory } from "./exerciseHistory.js" +import { registerBinanceOptionsExerciseRecord } from "./exerciseRecord.js" +import { registerBinanceOptionsGetOrder } from "./getOrder.js" +import { registerBinanceOptionsHistoricalTrades } from "./historicalTrades.js" +import { registerBinanceOptionsHistoryOrders } from "./historyOrders.js" +import { registerBinanceOptionsIndexPrice } from "./indexPrice.js" +import { registerBinanceOptionsKlines } from "./klines.js" // User Data Stream -import { - registerBinanceOptionsCreateListenKey, - registerBinanceOptionsKeepAliveListenKey, - registerBinanceOptionsDeleteListenKey -} from "./listenKey.js"; +import { + registerBinanceOptionsCreateListenKey, + registerBinanceOptionsDeleteListenKey, + registerBinanceOptionsKeepAliveListenKey, +} from "./listenKey.js" +import { registerBinanceOptionsMark } from "./mark.js" +import { registerBinanceOptionsNewOrder } from "./newOrder.js" +import { registerBinanceOptionsOpenInterest } from "./openInterest.js" +import { registerBinanceOptionsOpenOrders } from "./openOrders.js" +// Market Data +import { registerBinanceOptionsPing } from "./ping.js" +import { registerBinanceOptionsPosition } from "./position.js" +import { registerBinanceOptionsTicker } from "./ticker.js" +import { registerBinanceOptionsTime } from "./time.js" +import { registerBinanceOptionsTrades } from "./trades.js" +import { registerBinanceOptionsUserTrades } from "./userTrades.js" export function registerBinanceOptionsTools(server: McpServer) { - // Market Data - registerBinanceOptionsPing(server); - registerBinanceOptionsTime(server); - registerBinanceOptionsExchangeInfo(server); - registerBinanceOptionsDepth(server); - registerBinanceOptionsTrades(server); - registerBinanceOptionsHistoricalTrades(server); - registerBinanceOptionsKlines(server); - registerBinanceOptionsMark(server); - registerBinanceOptionsTicker(server); - registerBinanceOptionsIndexPrice(server); - registerBinanceOptionsExerciseHistory(server); - registerBinanceOptionsOpenInterest(server); - - // Account & Trading - registerBinanceOptionsAccount(server); - registerBinanceOptionsNewOrder(server); - registerBinanceOptionsBatchOrders(server); - registerBinanceOptionsCancelOrder(server); - registerBinanceOptionsCancelAllOrders(server); - registerBinanceOptionsCancelBatchOrders(server); - registerBinanceOptionsGetOrder(server); - registerBinanceOptionsOpenOrders(server); - registerBinanceOptionsHistoryOrders(server); - registerBinanceOptionsPosition(server); - registerBinanceOptionsUserTrades(server); - registerBinanceOptionsExerciseRecord(server); - registerBinanceOptionsBill(server); - - // User Data Stream - registerBinanceOptionsCreateListenKey(server); - registerBinanceOptionsKeepAliveListenKey(server); - registerBinanceOptionsDeleteListenKey(server); + // Market Data + registerBinanceOptionsPing(server) + registerBinanceOptionsTime(server) + registerBinanceOptionsExchangeInfo(server) + registerBinanceOptionsDepth(server) + registerBinanceOptionsTrades(server) + registerBinanceOptionsHistoricalTrades(server) + registerBinanceOptionsKlines(server) + registerBinanceOptionsMark(server) + registerBinanceOptionsTicker(server) + registerBinanceOptionsIndexPrice(server) + registerBinanceOptionsExerciseHistory(server) + registerBinanceOptionsOpenInterest(server) + + // Account & Trading + registerBinanceOptionsAccount(server) + registerBinanceOptionsNewOrder(server) + registerBinanceOptionsBatchOrders(server) + registerBinanceOptionsCancelOrder(server) + registerBinanceOptionsCancelAllOrders(server) + registerBinanceOptionsCancelBatchOrders(server) + registerBinanceOptionsGetOrder(server) + registerBinanceOptionsOpenOrders(server) + registerBinanceOptionsHistoryOrders(server) + registerBinanceOptionsPosition(server) + registerBinanceOptionsUserTrades(server) + registerBinanceOptionsExerciseRecord(server) + registerBinanceOptionsBill(server) + + // User Data Stream + registerBinanceOptionsCreateListenKey(server) + registerBinanceOptionsKeepAliveListenKey(server) + registerBinanceOptionsDeleteListenKey(server) } diff --git a/src/tools/binance-options/indexPrice.ts b/src/tools/binance-options/indexPrice.ts index c5f6e3e7..97bc2ed2 100644 --- a/src/tools/binance-options/indexPrice.ts +++ b/src/tools/binance-options/indexPrice.ts @@ -1,38 +1,39 @@ // src/tools/binance-options/indexPrice.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../config/binanceClient.js" export function registerBinanceOptionsIndexPrice(server: McpServer) { - server.tool( - "BinanceOptionsIndexPrice", - "Get the underlying index price for options.", - { - underlying: z.string().describe("Underlying asset (e.g., BTCUSDT)") - }, - async ({ underlying }) => { - try { - const params: any = { underlying }; - - const data = await optionsClient.index(params); - - return { - content: [ - { - type: "text", - text: `Index price for ${underlying} retrieved. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get index price: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceOptionsIndexPrice", + "Get the underlying index price for options.", + { + underlying: z.string().describe("Underlying asset (e.g., BTCUSDT)"), + }, + async ({ underlying }) => { + try { + const params: any = { underlying } + + const data = await optionsClient.index(params) + + return { + content: [ + { + type: "text", + text: `Index price for ${underlying} retrieved. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get index price: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-options/klines.ts b/src/tools/binance-options/klines.ts index bb5066a5..b36fc207 100644 --- a/src/tools/binance-options/klines.ts +++ b/src/tools/binance-options/klines.ts @@ -1,45 +1,48 @@ // src/tools/binance-options/klines.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../config/binanceClient.js" export function registerBinanceOptionsKlines(server: McpServer) { - server.tool( - "BinanceOptionsKlines", - "Get kline/candlestick data for an option symbol.", - { - symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), - interval: z.enum(["1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d", "3d", "1w"]).describe("Kline interval"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Number of klines to return. Default 500; max 1500.") - }, - async ({ symbol, interval, startTime, endTime, limit }) => { - try { - const params: any = { symbol, interval }; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; - - const data = await optionsClient.klines(params); - - return { - content: [ - { - type: "text", - text: `Klines for ${symbol}. Count: ${Array.isArray(data) ? data.length : 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get klines: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceOptionsKlines", + "Get kline/candlestick data for an option symbol.", + { + symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + interval: z + .enum(["1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d", "3d", "1w"]) + .describe("Kline interval"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Number of klines to return. Default 500; max 1500."), + }, + async ({ symbol, interval, startTime, endTime, limit }) => { + try { + const params: any = { symbol, interval } + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit + + const data = await optionsClient.klines(params) + + return { + content: [ + { + type: "text", + text: `Klines for ${symbol}. Count: ${Array.isArray(data) ? data.length : 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get klines: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-options/listenKey.ts b/src/tools/binance-options/listenKey.ts index 2fa0e73f..f4a78cfc 100644 --- a/src/tools/binance-options/listenKey.ts +++ b/src/tools/binance-options/listenKey.ts @@ -1,98 +1,97 @@ // src/tools/binance-options/listenKey.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../config/binanceClient.js" export function registerBinanceOptionsCreateListenKey(server: McpServer) { - server.tool( - "BinanceOptionsCreateListenKey", - "Create a new listen key for options user data stream.", - {}, - async () => { - try { - const data = await optionsClient.createListenKey(); - - return { - content: [ - { - type: "text", - text: `Listen key created successfully. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to create listen key: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceOptionsCreateListenKey", + "Create a new listen key for options user data stream.", + {}, + async () => { + try { + const data = await optionsClient.createListenKey() + + return { + content: [ + { + type: "text", + text: `Listen key created successfully. Response: ${JSON.stringify(data)}`, + }, + ], } - ); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to create listen key: ${errorMessage}` }], + isError: true, + } + } + }, + ) } export function registerBinanceOptionsKeepAliveListenKey(server: McpServer) { - server.tool( - "BinanceOptionsKeepAliveListenKey", - "Keep alive an existing listen key for options user data stream.", - { - listenKey: z.string().describe("The listen key to keep alive") - }, - async ({ listenKey }) => { - try { - const data = await optionsClient.keepAliveListenKey(); - - return { - content: [ - { - type: "text", - text: `Listen key renewed successfully. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to renew listen key: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceOptionsKeepAliveListenKey", + "Keep alive an existing listen key for options user data stream.", + { + listenKey: z.string().describe("The listen key to keep alive"), + }, + async ({ listenKey: _listenKey }) => { + try { + const data = await optionsClient.keepAliveListenKey() + + return { + content: [ + { + type: "text", + text: `Listen key renewed successfully. Response: ${JSON.stringify(data)}`, + }, + ], } - ); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to renew listen key: ${errorMessage}` }], + isError: true, + } + } + }, + ) } export function registerBinanceOptionsDeleteListenKey(server: McpServer) { - server.tool( - "BinanceOptionsDeleteListenKey", - "Delete an existing listen key for options user data stream.", - { - listenKey: z.string().describe("The listen key to delete") - }, - async ({ listenKey }) => { - try { - const data = await optionsClient.closeListenKey(); - - return { - content: [ - { - type: "text", - text: `Listen key deleted successfully. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to delete listen key: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceOptionsDeleteListenKey", + "Delete an existing listen key for options user data stream.", + { + listenKey: z.string().describe("The listen key to delete"), + }, + async ({ listenKey: _listenKey }) => { + try { + const data = await optionsClient.closeListenKey() + + return { + content: [ + { + type: "text", + text: `Listen key deleted successfully. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to delete listen key: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-options/mark.ts b/src/tools/binance-options/mark.ts index 246e5cde..6144971a 100644 --- a/src/tools/binance-options/mark.ts +++ b/src/tools/binance-options/mark.ts @@ -1,39 +1,40 @@ // src/tools/binance-options/mark.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../config/binanceClient.js" export function registerBinanceOptionsMark(server: McpServer) { - server.tool( - "BinanceOptionsMark", - "Get option mark price for a symbol or all symbols.", - { - symbol: z.string().optional().describe("Option trading symbol (e.g., BTC-240126-42000-C)") - }, - async ({ symbol }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - - const data = await optionsClient.mark(params); - - return { - content: [ - { - type: "text", - text: `Option mark price retrieved. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get mark price: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceOptionsMark", + "Get option mark price for a symbol or all symbols.", + { + symbol: z.string().optional().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + }, + async ({ symbol }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + + const data = await optionsClient.mark(params) + + return { + content: [ + { + type: "text", + text: `Option mark price retrieved. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get mark price: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-options/newOrder.ts b/src/tools/binance-options/newOrder.ts index 1d15e5b7..1aeba590 100644 --- a/src/tools/binance-options/newOrder.ts +++ b/src/tools/binance-options/newOrder.ts @@ -1,53 +1,65 @@ // src/tools/binance-options/newOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../config/binanceClient.js" export function registerBinanceOptionsNewOrder(server: McpServer) { - server.tool( - "BinanceOptionsNewOrder", - "Create a new options order.", - { - symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), - side: z.enum(["BUY", "SELL"]).describe("Order side: BUY or SELL"), - type: z.enum(["LIMIT", "MARKET"]).describe("Order type"), - quantity: z.number().describe("Order quantity"), - price: z.number().optional().describe("Order price (required for LIMIT orders)"), - timeInForce: z.enum(["GTC", "IOC", "FOK"]).optional().describe("Time in force"), - reduceOnly: z.boolean().optional().describe("Reduce only flag"), - postOnly: z.boolean().optional().describe("Post only flag"), - newOrderRespType: z.enum(["ACK", "RESULT"]).optional().describe("Response type"), - clientOrderId: z.string().optional().describe("Client order ID") - }, - async ({ symbol, side, type, quantity, price, timeInForce, reduceOnly, postOnly, newOrderRespType, clientOrderId }) => { - try { - const params: any = { symbol, side, type, quantity }; - if (price !== undefined) params.price = price; - if (timeInForce) params.timeInForce = timeInForce; - if (reduceOnly !== undefined) params.reduceOnly = reduceOnly; - if (postOnly !== undefined) params.postOnly = postOnly; - if (newOrderRespType) params.newOrderRespType = newOrderRespType; - if (clientOrderId) params.clientOrderId = clientOrderId; - - const data = await optionsClient.newOrder(params); - - return { - content: [ - { - type: "text", - text: `Options order created successfully. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to create order: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceOptionsNewOrder", + "Create a new options order.", + { + symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + side: z.enum(["BUY", "SELL"]).describe("Order side: BUY or SELL"), + type: z.enum(["LIMIT", "MARKET"]).describe("Order type"), + quantity: z.number().describe("Order quantity"), + price: z.number().optional().describe("Order price (required for LIMIT orders)"), + timeInForce: z.enum(["GTC", "IOC", "FOK"]).optional().describe("Time in force"), + reduceOnly: z.boolean().optional().describe("Reduce only flag"), + postOnly: z.boolean().optional().describe("Post only flag"), + newOrderRespType: z.enum(["ACK", "RESULT"]).optional().describe("Response type"), + clientOrderId: z.string().optional().describe("Client order ID"), + }, + async ({ + symbol, + side, + type, + quantity, + price, + timeInForce, + reduceOnly, + postOnly, + newOrderRespType, + clientOrderId, + }) => { + try { + const params: any = { symbol, side, type, quantity } + if (price !== undefined) params.price = price + if (timeInForce) params.timeInForce = timeInForce + if (reduceOnly !== undefined) params.reduceOnly = reduceOnly + if (postOnly !== undefined) params.postOnly = postOnly + if (newOrderRespType) params.newOrderRespType = newOrderRespType + if (clientOrderId) params.clientOrderId = clientOrderId + + const data = await optionsClient.newOrder(params) + + return { + content: [ + { + type: "text", + text: `Options order created successfully. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to create order: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-options/openInterest.ts b/src/tools/binance-options/openInterest.ts index 15fcb372..7906638c 100644 --- a/src/tools/binance-options/openInterest.ts +++ b/src/tools/binance-options/openInterest.ts @@ -1,39 +1,40 @@ // src/tools/binance-options/openInterest.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../config/binanceClient.js" export function registerBinanceOptionsOpenInterest(server: McpServer) { - server.tool( - "BinanceOptionsOpenInterest", - "Get open interest for an option symbol.", - { - underlyingAsset: z.string().describe("Underlying asset (e.g., BTC)"), - expiration: z.string().describe("Expiration date (e.g., 240126)") - }, - async ({ underlyingAsset, expiration }) => { - try { - const params: any = { underlyingAsset, expiration }; - - const data = await optionsClient.openInterest(params); - - return { - content: [ - { - type: "text", - text: `Open interest retrieved. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get open interest: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceOptionsOpenInterest", + "Get open interest for an option symbol.", + { + underlyingAsset: z.string().describe("Underlying asset (e.g., BTC)"), + expiration: z.string().describe("Expiration date (e.g., 240126)"), + }, + async ({ underlyingAsset, expiration }) => { + try { + const params: any = { underlyingAsset, expiration } + + const data = await optionsClient.openInterest(params) + + return { + content: [ + { + type: "text", + text: `Open interest retrieved. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get open interest: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-options/openOrders.ts b/src/tools/binance-options/openOrders.ts index dbe87f55..0c9cb8b7 100644 --- a/src/tools/binance-options/openOrders.ts +++ b/src/tools/binance-options/openOrders.ts @@ -1,39 +1,40 @@ // src/tools/binance-options/openOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../config/binanceClient.js" export function registerBinanceOptionsOpenOrders(server: McpServer) { - server.tool( - "BinanceOptionsOpenOrders", - "Get all open options orders.", - { - symbol: z.string().optional().describe("Option trading symbol (e.g., BTC-240126-42000-C)") - }, - async ({ symbol }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - - const data = await optionsClient.openOrders(params); - - return { - content: [ - { - type: "text", - text: `Open orders retrieved. Count: ${Array.isArray(data) ? data.length : 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get open orders: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceOptionsOpenOrders", + "Get all open options orders.", + { + symbol: z.string().optional().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + }, + async ({ symbol }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + + const data = await optionsClient.openOrders(params) + + return { + content: [ + { + type: "text", + text: `Open orders retrieved. Count: ${Array.isArray(data) ? data.length : 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get open orders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-options/ping.ts b/src/tools/binance-options/ping.ts index 6528deca..d193ddc0 100644 --- a/src/tools/binance-options/ping.ts +++ b/src/tools/binance-options/ping.ts @@ -1,33 +1,35 @@ // src/tools/binance-options/ping.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { optionsClient } from "../../config/binanceClient.js" export function registerBinanceOptionsPing(server: McpServer) { - server.tool( - "BinanceOptionsPing", - "Test connectivity to the Binance Options API.", - {}, - async () => { - try { - const data = await optionsClient.ping(); - - return { - content: [ - { - type: "text", - text: `Options API connectivity test successful. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Options API connectivity test failed: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceOptionsPing", + "Test connectivity to the Binance Options API.", + {}, + async () => { + try { + const data = await optionsClient.ping() + + return { + content: [ + { + type: "text", + text: `Options API connectivity test successful. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Options API connectivity test failed: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-options/position.ts b/src/tools/binance-options/position.ts index 6b24b3bb..20b89dd8 100644 --- a/src/tools/binance-options/position.ts +++ b/src/tools/binance-options/position.ts @@ -1,39 +1,40 @@ // src/tools/binance-options/position.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../config/binanceClient.js" export function registerBinanceOptionsPosition(server: McpServer) { - server.tool( - "BinanceOptionsPosition", - "Get current options position information.", - { - symbol: z.string().optional().describe("Option trading symbol (e.g., BTC-240126-42000-C)") - }, - async ({ symbol }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - - const data = await optionsClient.position(params); - - return { - content: [ - { - type: "text", - text: `Position information retrieved. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get position: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceOptionsPosition", + "Get current options position information.", + { + symbol: z.string().optional().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + }, + async ({ symbol }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + + const data = await optionsClient.position(params) + + return { + content: [ + { + type: "text", + text: `Position information retrieved. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get position: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-options/ticker.ts b/src/tools/binance-options/ticker.ts index 0c3aa846..878bb0c2 100644 --- a/src/tools/binance-options/ticker.ts +++ b/src/tools/binance-options/ticker.ts @@ -1,39 +1,40 @@ // src/tools/binance-options/ticker.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../config/binanceClient.js" export function registerBinanceOptionsTicker(server: McpServer) { - server.tool( - "BinanceOptionsTicker", - "Get 24hr ticker price change statistics for an option symbol.", - { - symbol: z.string().optional().describe("Option trading symbol (e.g., BTC-240126-42000-C)") - }, - async ({ symbol }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - - const data = await optionsClient.ticker(params); - - return { - content: [ - { - type: "text", - text: `24hr ticker statistics retrieved. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get ticker: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceOptionsTicker", + "Get 24hr ticker price change statistics for an option symbol.", + { + symbol: z.string().optional().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + }, + async ({ symbol }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + + const data = await optionsClient.ticker(params) + + return { + content: [ + { + type: "text", + text: `24hr ticker statistics retrieved. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get ticker: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-options/time.ts b/src/tools/binance-options/time.ts index 10ac4c4d..d7b6c876 100644 --- a/src/tools/binance-options/time.ts +++ b/src/tools/binance-options/time.ts @@ -1,33 +1,33 @@ // src/tools/binance-options/time.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { optionsClient } from "../../config/binanceClient.js" export function registerBinanceOptionsTime(server: McpServer) { - server.tool( - "BinanceOptionsTime", - "Get the current server time from Binance Options API.", - {}, - async () => { - try { - const data = await optionsClient.time(); - - return { - content: [ - { - type: "text", - text: `Server time retrieved successfully. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get server time: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceOptionsTime", + "Get the current server time from Binance Options API.", + {}, + async () => { + try { + const data = await optionsClient.time() + + return { + content: [ + { + type: "text", + text: `Server time retrieved successfully. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get server time: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-options/trades.ts b/src/tools/binance-options/trades.ts index e691b67f..807d1f6f 100644 --- a/src/tools/binance-options/trades.ts +++ b/src/tools/binance-options/trades.ts @@ -1,39 +1,41 @@ // src/tools/binance-options/trades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../config/binanceClient.js" export function registerBinanceOptionsTrades(server: McpServer) { - server.tool( - "BinanceOptionsTrades", - "Get recent trades for an option symbol.", - { - symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), - limit: z.number().optional().describe("Number of trades to return. Default 100; max 500.") - }, - async ({ symbol, limit }) => { - try { - const params: any = { symbol }; - if (limit !== undefined) params.limit = limit; - - const data = await optionsClient.trades(params); - return { - content: [ - { - type: "text", - text: `Recent trades for ${symbol}. Count: ${Array.isArray(data) ? data.length : 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get recent trades: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceOptionsTrades", + "Get recent trades for an option symbol.", + { + symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + limit: z.number().optional().describe("Number of trades to return. Default 100; max 500."), + }, + async ({ symbol, limit }) => { + try { + const params: any = { symbol } + if (limit !== undefined) params.limit = limit + + const data = await optionsClient.trades(params) + + return { + content: [ + { + type: "text", + text: `Recent trades for ${symbol}. Count: ${Array.isArray(data) ? data.length : 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get recent trades: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-options/userTrades.ts b/src/tools/binance-options/userTrades.ts index e36dffc1..fee19f4b 100644 --- a/src/tools/binance-options/userTrades.ts +++ b/src/tools/binance-options/userTrades.ts @@ -1,47 +1,48 @@ // src/tools/binance-options/userTrades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { optionsClient } from "../../config/binanceClient.js" export function registerBinanceOptionsUserTrades(server: McpServer) { - server.tool( - "BinanceOptionsUserTrades", - "Get options account trade list.", - { - symbol: z.string().optional().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), - fromId: z.number().optional().describe("Trade ID to fetch from"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Number of trades to return. Default 100; max 1000.") - }, - async ({ symbol, fromId, startTime, endTime, limit }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - if (fromId !== undefined) params.fromId = fromId; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; - - const data = await optionsClient.userTrades(params); - - return { - content: [ - { - type: "text", - text: `User trades retrieved. Count: ${Array.isArray(data) ? data.length : 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get user trades: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceOptionsUserTrades", + "Get options account trade list.", + { + symbol: z.string().optional().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + fromId: z.number().optional().describe("Trade ID to fetch from"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Number of trades to return. Default 100; max 1000."), + }, + async ({ symbol, fromId, startTime, endTime, limit }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + if (fromId !== undefined) params.fromId = fromId + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit + + const data = await optionsClient.userTrades(params) + + return { + content: [ + { + type: "text", + text: `User trades retrieved. Count: ${Array.isArray(data) ? data.length : 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get user trades: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-pay/index.ts b/src/tools/binance-pay/index.ts index 9a3bc0a2..77fe5ce6 100644 --- a/src/tools/binance-pay/index.ts +++ b/src/tools/binance-pay/index.ts @@ -1,7 +1,8 @@ // src/tools/binance-pay/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetPayTradeHistory } from "./pay-api/getPayTradeHistory.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceGetPayTradeHistory } from "./pay-api/getPayTradeHistory.js" export function registerBinancePayTools(server: McpServer) { - registerBinanceGetPayTradeHistory(server); + registerBinanceGetPayTradeHistory(server) } diff --git a/src/tools/binance-pay/pay-api/getPayTradeHistory.ts b/src/tools/binance-pay/pay-api/getPayTradeHistory.ts index d37b514c..e55a6c73 100644 --- a/src/tools/binance-pay/pay-api/getPayTradeHistory.ts +++ b/src/tools/binance-pay/pay-api/getPayTradeHistory.ts @@ -1,54 +1,57 @@ // src/tools/binance-pay/pay-api/getPayTradeHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { payClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { payClient } from "../../../config/binanceClient.js" export function registerBinanceGetPayTradeHistory(server: McpServer) { - server.tool( - "BinanceGetPayTradeHistory", - "Retrieve Binance Pay trade history using GET to fetch transaction records such as C2C transfers, merchant payments, crypto box activity, refunds, payouts, and remittance details.", - { - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .max(100, "Limit cannot be greater than 100") - .default(100) - .describe("Number of records to return, default 100, max 100"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await payClient.restAPI.getPayTradeHistory({ - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetPayTradeHistory", + "Retrieve Binance Pay trade history using GET to fetch transaction records such as C2C transfers, merchant payments, crypto box activity, refunds, payouts, and remittance details.", + { + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(100, "Limit cannot be greater than 100") + .default(100) + .describe("Number of records to return, default 100, max 100"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await payClient.restAPI.getPayTradeHistory({ + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved Binance Pay trade history. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved Binance Pay trade history. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve Binance Pay trade history: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve Binance Pay trade history: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-portfolio-margin/bnbTransfer.ts b/src/tools/binance-portfolio-margin/bnbTransfer.ts index f815d75d..74f5aece 100644 --- a/src/tools/binance-portfolio-margin/bnbTransfer.ts +++ b/src/tools/binance-portfolio-margin/bnbTransfer.ts @@ -1,41 +1,44 @@ // src/tools/binance-portfolio-margin/bnbTransfer.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { portfolioMarginClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../config/binanceClient.js" export function registerBinancePortfolioMarginBnbTransfer(server: McpServer) { - server.tool( - "BinancePortfolioMarginBnbTransfer", - "Transfer BNB in/out of portfolio margin account.", - { - amount: z.number().describe("Amount of BNB to transfer"), - transferSide: z.enum(["TO_UM", "FROM_UM"]).describe("Transfer direction: TO_UM (to UM account) or FROM_UM (from UM account)"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ amount, transferSide, recvWindow }) => { - try { - const params: Record = { amount, transferSide }; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await portfolioMarginClient.bnbTransfer(params); + server.tool( + "BinancePortfolioMarginBnbTransfer", + "Transfer BNB in/out of portfolio margin account.", + { + amount: z.number().describe("Amount of BNB to transfer"), + transferSide: z + .enum(["TO_UM", "FROM_UM"]) + .describe("Transfer direction: TO_UM (to UM account) or FROM_UM (from UM account)"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ amount, transferSide, recvWindow }) => { + try { + const params: Record = { amount, transferSide } + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await portfolioMarginClient.bnbTransfer(params) + + return { + content: [ + { + type: "text", + text: `BNB transfer completed. Amount: ${amount}, Direction: ${transferSide}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `BNB transfer completed. Amount: ${amount}, Direction: ${transferSide}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to transfer BNB: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to transfer BNB: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-portfolio-margin/changeAutoRepayFutures.ts b/src/tools/binance-portfolio-margin/changeAutoRepayFutures.ts index 7b3c3715..3ddb450f 100644 --- a/src/tools/binance-portfolio-margin/changeAutoRepayFutures.ts +++ b/src/tools/binance-portfolio-margin/changeAutoRepayFutures.ts @@ -1,40 +1,43 @@ // src/tools/binance-portfolio-margin/changeAutoRepayFutures.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { portfolioMarginClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../config/binanceClient.js" export function registerBinancePortfolioMarginChangeAutoRepayFutures(server: McpServer) { - server.tool( - "BinancePortfolioMarginChangeAutoRepayFutures", - "Change the auto-repay-futures status for portfolio margin account.", - { - autoRepay: z.boolean().describe("Enable or disable auto-repay for futures"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ autoRepay, recvWindow }) => { - try { - const params: Record = { autoRepay }; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await portfolioMarginClient.changeAutoRepayFutures(params); + server.tool( + "BinancePortfolioMarginChangeAutoRepayFutures", + "Change the auto-repay-futures status for portfolio margin account.", + { + autoRepay: z.boolean().describe("Enable or disable auto-repay for futures"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ autoRepay, recvWindow }) => { + try { + const params: Record = { autoRepay } + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await portfolioMarginClient.changeAutoRepayFutures(params) + + return { + content: [ + { + type: "text", + text: `Auto-repay-futures status changed to ${autoRepay}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Auto-repay-futures status changed to ${autoRepay}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to change auto-repay-futures status: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to change auto-repay-futures status: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-portfolio-margin/fundAutoCollection.ts b/src/tools/binance-portfolio-margin/fundAutoCollection.ts index c7b8155d..72d6ce34 100644 --- a/src/tools/binance-portfolio-margin/fundAutoCollection.ts +++ b/src/tools/binance-portfolio-margin/fundAutoCollection.ts @@ -1,39 +1,42 @@ // src/tools/binance-portfolio-margin/fundAutoCollection.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { portfolioMarginClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../config/binanceClient.js" export function registerBinancePortfolioMarginFundAutoCollection(server: McpServer) { - server.tool( - "BinancePortfolioMarginFundAutoCollection", - "Enable or configure fund auto-collection for portfolio margin account.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: Record = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await portfolioMarginClient.fundAutoCollection(params); + server.tool( + "BinancePortfolioMarginFundAutoCollection", + "Enable or configure fund auto-collection for portfolio margin account.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: Record = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await portfolioMarginClient.fundAutoCollection(params) + + return { + content: [ + { + type: "text", + text: `Fund auto-collection configured. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Fund auto-collection configured. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to configure fund auto-collection: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to configure fund auto-collection: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-portfolio-margin/fundCollection.ts b/src/tools/binance-portfolio-margin/fundCollection.ts index b88fb70e..f7a415ad 100644 --- a/src/tools/binance-portfolio-margin/fundCollection.ts +++ b/src/tools/binance-portfolio-margin/fundCollection.ts @@ -1,40 +1,41 @@ // src/tools/binance-portfolio-margin/fundCollection.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { portfolioMarginClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../config/binanceClient.js" export function registerBinancePortfolioMarginFundCollection(server: McpServer) { - server.tool( - "BinancePortfolioMarginFundCollection", - "Trigger fund collection by asset for portfolio margin account.", - { - asset: z.string().describe("Asset symbol to collect (e.g., BTC, USDT)"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ asset, recvWindow }) => { - try { - const params: Record = { asset }; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await portfolioMarginClient.fundCollection(params); + server.tool( + "BinancePortfolioMarginFundCollection", + "Trigger fund collection by asset for portfolio margin account.", + { + asset: z.string().describe("Asset symbol to collect (e.g., BTC, USDT)"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ asset, recvWindow }) => { + try { + const params: Record = { asset } + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await portfolioMarginClient.fundCollection(params) + + return { + content: [ + { + type: "text", + text: `Fund collection triggered for ${asset}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Fund collection triggered for ${asset}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to trigger fund collection: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to trigger fund collection: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-portfolio-margin/getAccountBalance.ts b/src/tools/binance-portfolio-margin/getAccountBalance.ts index df9e7fcd..d170aacf 100644 --- a/src/tools/binance-portfolio-margin/getAccountBalance.ts +++ b/src/tools/binance-portfolio-margin/getAccountBalance.ts @@ -1,41 +1,45 @@ // src/tools/binance-portfolio-margin/getAccountBalance.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { portfolioMarginClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../config/binanceClient.js" export function registerBinancePortfolioMarginGetAccountBalance(server: McpServer) { - server.tool( - "BinancePortfolioMarginGetAccountBalance", - "Query portfolio margin account balance.", - { - asset: z.string().optional().describe("Asset symbol (e.g., BTC, USDT). If not provided, returns all assets"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ asset, recvWindow }) => { - try { - const params: Record = {}; - if (asset !== undefined) params.asset = asset; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await portfolioMarginClient.getBalance(params); + server.tool( + "BinancePortfolioMarginGetAccountBalance", + "Query portfolio margin account balance.", + { + asset: z + .string() + .optional() + .describe("Asset symbol (e.g., BTC, USDT). If not provided, returns all assets"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ asset, recvWindow }) => { + try { + const params: Record = {} + if (asset !== undefined) params.asset = asset + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await portfolioMarginClient.getBalance(params) + + return { + content: [ + { + type: "text", + text: `Retrieved account balance. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved account balance. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve account balance: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve account balance: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-portfolio-margin/getAutoRepayFuturesStatus.ts b/src/tools/binance-portfolio-margin/getAutoRepayFuturesStatus.ts index f21b82ea..0212151a 100644 --- a/src/tools/binance-portfolio-margin/getAutoRepayFuturesStatus.ts +++ b/src/tools/binance-portfolio-margin/getAutoRepayFuturesStatus.ts @@ -1,39 +1,42 @@ // src/tools/binance-portfolio-margin/getAutoRepayFuturesStatus.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { portfolioMarginClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../config/binanceClient.js" export function registerBinancePortfolioMarginGetAutoRepayFuturesStatus(server: McpServer) { - server.tool( - "BinancePortfolioMarginGetAutoRepayFuturesStatus", - "Get the current auto-repay-futures status for portfolio margin account.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: Record = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await portfolioMarginClient.getAutoRepayFuturesStatus(params); + server.tool( + "BinancePortfolioMarginGetAutoRepayFuturesStatus", + "Get the current auto-repay-futures status for portfolio margin account.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: Record = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await portfolioMarginClient.getAutoRepayFuturesStatus(params) + + return { + content: [ + { + type: "text", + text: `Retrieved auto-repay-futures status. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved auto-repay-futures status. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve auto-repay-futures status: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve auto-repay-futures status: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-portfolio-margin/getCollateralRate.ts b/src/tools/binance-portfolio-margin/getCollateralRate.ts index 6808aa27..585968e2 100644 --- a/src/tools/binance-portfolio-margin/getCollateralRate.ts +++ b/src/tools/binance-portfolio-margin/getCollateralRate.ts @@ -1,39 +1,40 @@ // src/tools/binance-portfolio-margin/getCollateralRate.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { portfolioMarginClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../config/binanceClient.js" export function registerBinancePortfolioMarginGetCollateralRate(server: McpServer) { - server.tool( - "BinancePortfolioMarginGetCollateralRate", - "Query portfolio margin collateral rate for assets.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: Record = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await portfolioMarginClient.getCollateralRate(params); + server.tool( + "BinancePortfolioMarginGetCollateralRate", + "Query portfolio margin collateral rate for assets.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: Record = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await portfolioMarginClient.getCollateralRate(params) + + return { + content: [ + { + type: "text", + text: `Retrieved portfolio margin collateral rate. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved portfolio margin collateral rate. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve collateral rate: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve collateral rate: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-portfolio-margin/getPortfolioMarginAccount.ts b/src/tools/binance-portfolio-margin/getPortfolioMarginAccount.ts index 084c0c19..83277993 100644 --- a/src/tools/binance-portfolio-margin/getPortfolioMarginAccount.ts +++ b/src/tools/binance-portfolio-margin/getPortfolioMarginAccount.ts @@ -1,39 +1,42 @@ // src/tools/binance-portfolio-margin/getPortfolioMarginAccount.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { portfolioMarginClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../config/binanceClient.js" export function registerBinancePortfolioMarginGetAccount(server: McpServer) { - server.tool( - "BinancePortfolioMarginGetAccount", - "Get portfolio margin account information including account status, balances, and positions.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: Record = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await portfolioMarginClient.getAccount(params); + server.tool( + "BinancePortfolioMarginGetAccount", + "Get portfolio margin account information including account status, balances, and positions.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: Record = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await portfolioMarginClient.getAccount(params) + + return { + content: [ + { + type: "text", + text: `Retrieved portfolio margin account info. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved portfolio margin account info. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve portfolio margin account: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve portfolio margin account: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-portfolio-margin/getPortfolioMarginAssetIndexPrice.ts b/src/tools/binance-portfolio-margin/getPortfolioMarginAssetIndexPrice.ts index c560becb..ed051564 100644 --- a/src/tools/binance-portfolio-margin/getPortfolioMarginAssetIndexPrice.ts +++ b/src/tools/binance-portfolio-margin/getPortfolioMarginAssetIndexPrice.ts @@ -1,41 +1,47 @@ // src/tools/binance-portfolio-margin/getPortfolioMarginAssetIndexPrice.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { portfolioMarginClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../config/binanceClient.js" export function registerBinancePortfolioMarginGetAssetIndexPrice(server: McpServer) { - server.tool( - "BinancePortfolioMarginGetAssetIndexPrice", - "Query portfolio margin asset index price.", - { - asset: z.string().optional().describe("Asset symbol (e.g., BTC, ETH). If not provided, returns all assets"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ asset, recvWindow }) => { - try { - const params: Record = {}; - if (asset !== undefined) params.asset = asset; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await portfolioMarginClient.getAssetIndexPrice(params); + server.tool( + "BinancePortfolioMarginGetAssetIndexPrice", + "Query portfolio margin asset index price.", + { + asset: z + .string() + .optional() + .describe("Asset symbol (e.g., BTC, ETH). If not provided, returns all assets"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ asset, recvWindow }) => { + try { + const params: Record = {} + if (asset !== undefined) params.asset = asset + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await portfolioMarginClient.getAssetIndexPrice(params) + + return { + content: [ + { + type: "text", + text: `Retrieved asset index price. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved asset index price. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve asset index price: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve asset index price: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-portfolio-margin/getPortfolioMarginAssetLeverage.ts b/src/tools/binance-portfolio-margin/getPortfolioMarginAssetLeverage.ts index 5a8e485c..e08c1bb9 100644 --- a/src/tools/binance-portfolio-margin/getPortfolioMarginAssetLeverage.ts +++ b/src/tools/binance-portfolio-margin/getPortfolioMarginAssetLeverage.ts @@ -1,39 +1,40 @@ // src/tools/binance-portfolio-margin/getPortfolioMarginAssetLeverage.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { portfolioMarginClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../config/binanceClient.js" export function registerBinancePortfolioMarginGetAssetLeverage(server: McpServer) { - server.tool( - "BinancePortfolioMarginGetAssetLeverage", - "Query portfolio margin asset leverage information.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: Record = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await portfolioMarginClient.getAssetLeverage(params); + server.tool( + "BinancePortfolioMarginGetAssetLeverage", + "Query portfolio margin asset leverage information.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: Record = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await portfolioMarginClient.getAssetLeverage(params) + + return { + content: [ + { + type: "text", + text: `Retrieved asset leverage information. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved asset leverage information. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve asset leverage: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve asset leverage: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-portfolio-margin/getPortfolioMarginBankruptcyLoanAmount.ts b/src/tools/binance-portfolio-margin/getPortfolioMarginBankruptcyLoanAmount.ts index 7f907918..aa067e1f 100644 --- a/src/tools/binance-portfolio-margin/getPortfolioMarginBankruptcyLoanAmount.ts +++ b/src/tools/binance-portfolio-margin/getPortfolioMarginBankruptcyLoanAmount.ts @@ -1,39 +1,42 @@ // src/tools/binance-portfolio-margin/getPortfolioMarginBankruptcyLoanAmount.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { portfolioMarginClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../config/binanceClient.js" export function registerBinancePortfolioMarginGetBankruptcyLoanAmount(server: McpServer) { - server.tool( - "BinancePortfolioMarginGetBankruptcyLoanAmount", - "Query portfolio margin bankruptcy loan amount.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: Record = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await portfolioMarginClient.getBankruptcyLoanAmount(params); + server.tool( + "BinancePortfolioMarginGetBankruptcyLoanAmount", + "Query portfolio margin bankruptcy loan amount.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: Record = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await portfolioMarginClient.getBankruptcyLoanAmount(params) + + return { + content: [ + { + type: "text", + text: `Retrieved bankruptcy loan amount. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved bankruptcy loan amount. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve bankruptcy loan amount: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve bankruptcy loan amount: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-portfolio-margin/getPortfolioMarginInterestHistory.ts b/src/tools/binance-portfolio-margin/getPortfolioMarginInterestHistory.ts index 8d9bb36f..3c9cdcc9 100644 --- a/src/tools/binance-portfolio-margin/getPortfolioMarginInterestHistory.ts +++ b/src/tools/binance-portfolio-margin/getPortfolioMarginInterestHistory.ts @@ -1,47 +1,48 @@ // src/tools/binance-portfolio-margin/getPortfolioMarginInterestHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { portfolioMarginClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../config/binanceClient.js" export function registerBinancePortfolioMarginGetInterestHistory(server: McpServer) { - server.tool( - "BinancePortfolioMarginGetInterestHistory", - "Query portfolio margin interest history.", - { - asset: z.string().optional().describe("Asset symbol (e.g., BTC, USDT)"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - size: z.number().optional().describe("Number of results to return, default 10, max 100"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ asset, startTime, endTime, size, recvWindow }) => { - try { - const params: Record = {}; - if (asset !== undefined) params.asset = asset; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (size !== undefined) params.size = size; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await portfolioMarginClient.getInterestHistory(params); + server.tool( + "BinancePortfolioMarginGetInterestHistory", + "Query portfolio margin interest history.", + { + asset: z.string().optional().describe("Asset symbol (e.g., BTC, USDT)"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + size: z.number().optional().describe("Number of results to return, default 10, max 100"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ asset, startTime, endTime, size, recvWindow }) => { + try { + const params: Record = {} + if (asset !== undefined) params.asset = asset + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (size !== undefined) params.size = size + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await portfolioMarginClient.getInterestHistory(params) + + return { + content: [ + { + type: "text", + text: `Retrieved interest history. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved interest history. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve interest history: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve interest history: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-portfolio-margin/index.ts b/src/tools/binance-portfolio-margin/index.ts index 48b65b97..ec08ff82 100644 --- a/src/tools/binance-portfolio-margin/index.ts +++ b/src/tools/binance-portfolio-margin/index.ts @@ -1,40 +1,41 @@ // src/tools/binance-portfolio-margin/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinancePortfolioMarginGetAccount } from "./getPortfolioMarginAccount.js"; -import { registerBinancePortfolioMarginGetCollateralRate } from "./getCollateralRate.js"; -import { registerBinancePortfolioMarginGetBankruptcyLoanAmount } from "./getPortfolioMarginBankruptcyLoanAmount.js"; -import { registerBinancePortfolioMarginRepayBankruptcyLoan } from "./repayPortfolioMarginBankruptcyLoan.js"; -import { registerBinancePortfolioMarginGetInterestHistory } from "./getPortfolioMarginInterestHistory.js"; -import { registerBinancePortfolioMarginGetAssetIndexPrice } from "./getPortfolioMarginAssetIndexPrice.js"; -import { registerBinancePortfolioMarginFundAutoCollection } from "./fundAutoCollection.js"; -import { registerBinancePortfolioMarginFundCollection } from "./fundCollection.js"; -import { registerBinancePortfolioMarginBnbTransfer } from "./bnbTransfer.js"; -import { registerBinancePortfolioMarginChangeAutoRepayFutures } from "./changeAutoRepayFutures.js"; -import { registerBinancePortfolioMarginGetAutoRepayFuturesStatus } from "./getAutoRepayFuturesStatus.js"; -import { registerBinancePortfolioMarginRepayFuturesNegativeBalance } from "./repayFuturesNegativeBalance.js"; -import { registerBinancePortfolioMarginGetAssetLeverage } from "./getPortfolioMarginAssetLeverage.js"; -import { registerBinancePortfolioMarginGetAccountBalance } from "./getAccountBalance.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinancePortfolioMarginBnbTransfer } from "./bnbTransfer.js" +import { registerBinancePortfolioMarginChangeAutoRepayFutures } from "./changeAutoRepayFutures.js" +import { registerBinancePortfolioMarginFundAutoCollection } from "./fundAutoCollection.js" +import { registerBinancePortfolioMarginFundCollection } from "./fundCollection.js" +import { registerBinancePortfolioMarginGetAccountBalance } from "./getAccountBalance.js" +import { registerBinancePortfolioMarginGetAutoRepayFuturesStatus } from "./getAutoRepayFuturesStatus.js" +import { registerBinancePortfolioMarginGetCollateralRate } from "./getCollateralRate.js" +import { registerBinancePortfolioMarginGetAccount } from "./getPortfolioMarginAccount.js" +import { registerBinancePortfolioMarginGetAssetIndexPrice } from "./getPortfolioMarginAssetIndexPrice.js" +import { registerBinancePortfolioMarginGetAssetLeverage } from "./getPortfolioMarginAssetLeverage.js" +import { registerBinancePortfolioMarginGetBankruptcyLoanAmount } from "./getPortfolioMarginBankruptcyLoanAmount.js" +import { registerBinancePortfolioMarginGetInterestHistory } from "./getPortfolioMarginInterestHistory.js" +import { registerBinancePortfolioMarginRepayFuturesNegativeBalance } from "./repayFuturesNegativeBalance.js" +import { registerBinancePortfolioMarginRepayBankruptcyLoan } from "./repayPortfolioMarginBankruptcyLoan.js" export function registerBinancePortfolioMarginTools(server: McpServer) { - // Account Information - registerBinancePortfolioMarginGetAccount(server); - registerBinancePortfolioMarginGetAccountBalance(server); - registerBinancePortfolioMarginGetCollateralRate(server); - registerBinancePortfolioMarginGetAssetLeverage(server); - registerBinancePortfolioMarginGetAssetIndexPrice(server); - - // Interest & Loan Management - registerBinancePortfolioMarginGetInterestHistory(server); - registerBinancePortfolioMarginGetBankruptcyLoanAmount(server); - registerBinancePortfolioMarginRepayBankruptcyLoan(server); - - // Fund Management - registerBinancePortfolioMarginFundAutoCollection(server); - registerBinancePortfolioMarginFundCollection(server); - registerBinancePortfolioMarginBnbTransfer(server); - - // Futures Auto-Repay - registerBinancePortfolioMarginChangeAutoRepayFutures(server); - registerBinancePortfolioMarginGetAutoRepayFuturesStatus(server); - registerBinancePortfolioMarginRepayFuturesNegativeBalance(server); + // Account Information + registerBinancePortfolioMarginGetAccount(server) + registerBinancePortfolioMarginGetAccountBalance(server) + registerBinancePortfolioMarginGetCollateralRate(server) + registerBinancePortfolioMarginGetAssetLeverage(server) + registerBinancePortfolioMarginGetAssetIndexPrice(server) + + // Interest & Loan Management + registerBinancePortfolioMarginGetInterestHistory(server) + registerBinancePortfolioMarginGetBankruptcyLoanAmount(server) + registerBinancePortfolioMarginRepayBankruptcyLoan(server) + + // Fund Management + registerBinancePortfolioMarginFundAutoCollection(server) + registerBinancePortfolioMarginFundCollection(server) + registerBinancePortfolioMarginBnbTransfer(server) + + // Futures Auto-Repay + registerBinancePortfolioMarginChangeAutoRepayFutures(server) + registerBinancePortfolioMarginGetAutoRepayFuturesStatus(server) + registerBinancePortfolioMarginRepayFuturesNegativeBalance(server) } diff --git a/src/tools/binance-portfolio-margin/repayFuturesNegativeBalance.ts b/src/tools/binance-portfolio-margin/repayFuturesNegativeBalance.ts index ea8c69e1..0a0622d9 100644 --- a/src/tools/binance-portfolio-margin/repayFuturesNegativeBalance.ts +++ b/src/tools/binance-portfolio-margin/repayFuturesNegativeBalance.ts @@ -1,39 +1,42 @@ // src/tools/binance-portfolio-margin/repayFuturesNegativeBalance.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { portfolioMarginClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../config/binanceClient.js" export function registerBinancePortfolioMarginRepayFuturesNegativeBalance(server: McpServer) { - server.tool( - "BinancePortfolioMarginRepayFuturesNegativeBalance", - "Repay futures negative balance for portfolio margin account.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: Record = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await portfolioMarginClient.repayFuturesNegativeBalance(params); + server.tool( + "BinancePortfolioMarginRepayFuturesNegativeBalance", + "Repay futures negative balance for portfolio margin account.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: Record = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await portfolioMarginClient.repayFuturesNegativeBalance(params) + + return { + content: [ + { + type: "text", + text: `Futures negative balance repaid. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Futures negative balance repaid. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to repay futures negative balance: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to repay futures negative balance: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-portfolio-margin/repayPortfolioMarginBankruptcyLoan.ts b/src/tools/binance-portfolio-margin/repayPortfolioMarginBankruptcyLoan.ts index 0dedd7ed..05982dc7 100644 --- a/src/tools/binance-portfolio-margin/repayPortfolioMarginBankruptcyLoan.ts +++ b/src/tools/binance-portfolio-margin/repayPortfolioMarginBankruptcyLoan.ts @@ -1,39 +1,40 @@ // src/tools/binance-portfolio-margin/repayPortfolioMarginBankruptcyLoan.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { portfolioMarginClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { portfolioMarginClient } from "../../config/binanceClient.js" export function registerBinancePortfolioMarginRepayBankruptcyLoan(server: McpServer) { - server.tool( - "BinancePortfolioMarginRepayBankruptcyLoan", - "Repay portfolio margin bankruptcy loan.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: Record = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await portfolioMarginClient.repayBankruptcyLoan(params); + server.tool( + "BinancePortfolioMarginRepayBankruptcyLoan", + "Repay portfolio margin bankruptcy loan.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: Record = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await portfolioMarginClient.repayBankruptcyLoan(params) + + return { + content: [ + { + type: "text", + text: `Successfully repaid bankruptcy loan. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully repaid bankruptcy loan. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to repay bankruptcy loan: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to repay bankruptcy loan: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-rebate/index.ts b/src/tools/binance-rebate/index.ts index 300e0450..7ffeab67 100644 --- a/src/tools/binance-rebate/index.ts +++ b/src/tools/binance-rebate/index.ts @@ -1,7 +1,8 @@ // src/tools/binance-rebate/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetSpotRebateHistoryRecords } from "./rebate-api/getSpotRebateHistoryRecords.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceGetSpotRebateHistoryRecords } from "./rebate-api/getSpotRebateHistoryRecords.js" export function registerBinanceRebateTools(server: McpServer) { - registerBinanceGetSpotRebateHistoryRecords(server); + registerBinanceGetSpotRebateHistoryRecords(server) } diff --git a/src/tools/binance-rebate/rebate-api/getSpotRebateHistoryRecords.ts b/src/tools/binance-rebate/rebate-api/getSpotRebateHistoryRecords.ts index c3b46ee8..9a5e6b22 100644 --- a/src/tools/binance-rebate/rebate-api/getSpotRebateHistoryRecords.ts +++ b/src/tools/binance-rebate/rebate-api/getSpotRebateHistoryRecords.ts @@ -1,51 +1,54 @@ // src/tools/binance-pay/rebate-api/getSpotRebateHistoryRecords.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { rebateClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { rebateClient } from "../../../config/binanceClient.js" export function registerBinanceGetSpotRebateHistoryRecords(server: McpServer) { - server.tool( - "BinanceGetSpotRebateHistoryRecords", - "Retrieve the history of spot rebate records, including commission rebates and referral kickbacks, for the past 7 days or a custom date range (within 30 days).", - { - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - page: z.number().int().default(1).describe("Page number, default is 1"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await rebateClient.restAPI.getSpotRebateHistoryRecords({ - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.page && { page: params.page }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetSpotRebateHistoryRecords", + "Retrieve the history of spot rebate records, including commission rebates and referral kickbacks, for the past 7 days or a custom date range (within 30 days).", + { + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + page: z.number().int().default(1).describe("Page number, default is 1"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await rebateClient.restAPI.getSpotRebateHistoryRecords({ + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.page && { page: params.page }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved the history of spot rebate records, including commission rebates and referral kickbacks. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved the history of spot rebate records, including commission rebates and referral kickbacks. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve the history of spot rebate records: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve the history of spot rebate records: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-simple-earn/account-api/getFlexibleProductPosition.ts b/src/tools/binance-simple-earn/account-api/getFlexibleProductPosition.ts index df77fa91..5f2208fc 100644 --- a/src/tools/binance-simple-earn/account-api/getFlexibleProductPosition.ts +++ b/src/tools/binance-simple-earn/account-api/getFlexibleProductPosition.ts @@ -1,59 +1,69 @@ // src/tools/binance-simple-earn/account-api/getFlexibleProductPosition.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { simpleEarnClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { simpleEarnClient } from "../../../config/binanceClient.js" export function registerBinanceGetFlexibleProductPosition(server: McpServer) { - server.tool( - "BinanceGetFlexibleProductPosition", - "Fetch your current holdings in Simple Earn Flexible Products, including total amount, reward rates, and redeem status.", - { - asset: z.string().optional().describe("Asset symbol (optional)"), - productId: z.string().optional().describe("Product ID (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying the page. Starts from 1. Default: 1"), - size: z.number().int().min(1).max(100).default(10).optional().describe("Page size. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await simpleEarnClient.restAPI.getFlexibleProductPosition({ - ...(params.asset && { asset: params.asset }), - ...(params.productId && { productId: params.productId }), - ...(params.current && { current: params.current }), - ...(params.size && { size: params.size }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetFlexibleProductPosition", + "Fetch your current holdings in Simple Earn Flexible Products, including total amount, reward rates, and redeem status.", + { + asset: z.string().optional().describe("Asset symbol (optional)"), + productId: z.string().optional().describe("Product ID (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying the page. Starts from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Page size. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await simpleEarnClient.restAPI.getFlexibleProductPosition({ + ...(params.asset && { asset: params.asset }), + ...(params.productId && { productId: params.productId }), + ...(params.current && { current: params.current }), + ...(params.size && { size: params.size }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully fetched your current holdings in Simple Earn Flexible Products. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully fetched your current holdings in Simple Earn Flexible Products. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to fetch your current holdings in Simple Earn Flexible Products: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to fetch your current holdings in Simple Earn Flexible Products: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-simple-earn/account-api/index.ts b/src/tools/binance-simple-earn/account-api/index.ts index 530448c0..c3800c9b 100644 --- a/src/tools/binance-simple-earn/account-api/index.ts +++ b/src/tools/binance-simple-earn/account-api/index.ts @@ -1,12 +1,13 @@ // src/tools/binance-simple-earn/account-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceSimpleEarnFlexibleProductList } from "./simpleEarnFlexibleProductList.js"; -import { registerBinanceGetFlexibleProductPosition } from "./getFlexibleProductPosition.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceGetFlexibleProductPosition } from "./getFlexibleProductPosition.js" +import { registerBinanceSimpleEarnFlexibleProductList } from "./simpleEarnFlexibleProductList.js" export function registerBinanceSimpleEarnAccountApiTools(server: McpServer) { - // Registers a tool to get the list of flexible earning products - registerBinanceSimpleEarnFlexibleProductList(server); + // Registers a tool to get the list of flexible earning products + registerBinanceSimpleEarnFlexibleProductList(server) - // Registers a tool to get the user's position in flexible earning products - registerBinanceGetFlexibleProductPosition(server); + // Registers a tool to get the user's position in flexible earning products + registerBinanceGetFlexibleProductPosition(server) } diff --git a/src/tools/binance-simple-earn/account-api/simpleEarnFlexibleProductList.ts b/src/tools/binance-simple-earn/account-api/simpleEarnFlexibleProductList.ts index 70fd0e68..a76d9793 100644 --- a/src/tools/binance-simple-earn/account-api/simpleEarnFlexibleProductList.ts +++ b/src/tools/binance-simple-earn/account-api/simpleEarnFlexibleProductList.ts @@ -1,57 +1,67 @@ // src/tools/binance-simple-earn/account-api/simpleEarnFlexibleProductList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { simpleEarnClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { simpleEarnClient } from "../../../config/binanceClient.js" export function registerBinanceSimpleEarnFlexibleProductList(server: McpServer) { - server.tool( - "BinanceSimpleEarnFlexibleProductList", - "Retrieve a list of available Simple Earn Flexible Products, including details like APR, purchase status, and subscription limits.", - { - asset: z.string().optional().describe("Asset symbol (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Starts from 1. Default: 1"), - size: z.number().int().min(1).max(100).default(10).optional().describe("Page size. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await simpleEarnClient.restAPI.getSimpleEarnFlexibleProductList({ - ...(params.asset && { asset: params.asset }), - ...(params.current && { current: params.current }), - ...(params.size && { size: params.size }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSimpleEarnFlexibleProductList", + "Retrieve a list of available Simple Earn Flexible Products, including details like APR, purchase status, and subscription limits.", + { + asset: z.string().optional().describe("Asset symbol (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Starts from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Page size. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await simpleEarnClient.restAPI.getSimpleEarnFlexibleProductList({ + ...(params.asset && { asset: params.asset }), + ...(params.current && { current: params.current }), + ...(params.size && { size: params.size }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieve a list of available Simple Earn Flexible Products. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieve a list of available Simple Earn Flexible Products. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve a list of available Simple Earn Flexible Products: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve a list of available Simple Earn Flexible Products: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-simple-earn/earn-api/index.ts b/src/tools/binance-simple-earn/earn-api/index.ts index 7d2a23e0..219084b7 100644 --- a/src/tools/binance-simple-earn/earn-api/index.ts +++ b/src/tools/binance-simple-earn/earn-api/index.ts @@ -1,12 +1,13 @@ // src/tools/binance-simple-earn/earn-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceSubscribeFlexibleProduct } from "./subscribeFlexibleProduct.js"; -import { registerBinanceRedeemFlexibleProduct } from "./redeemFlexibleProduct.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceRedeemFlexibleProduct } from "./redeemFlexibleProduct.js" +import { registerBinanceSubscribeFlexibleProduct } from "./subscribeFlexibleProduct.js" export function registerBinanceSimpleEarnApiTools(server: McpServer) { - // Register the route for subscribing to a flexible earn product - registerBinanceSubscribeFlexibleProduct(server); + // Register the route for subscribing to a flexible earn product + registerBinanceSubscribeFlexibleProduct(server) - // Register the route for redeeming from a flexible earn product - registerBinanceRedeemFlexibleProduct(server); + // Register the route for redeeming from a flexible earn product + registerBinanceRedeemFlexibleProduct(server) } diff --git a/src/tools/binance-simple-earn/earn-api/redeemFlexibleProduct.ts b/src/tools/binance-simple-earn/earn-api/redeemFlexibleProduct.ts index 13f0fd16..bdb4d1cc 100644 --- a/src/tools/binance-simple-earn/earn-api/redeemFlexibleProduct.ts +++ b/src/tools/binance-simple-earn/earn-api/redeemFlexibleProduct.ts @@ -1,71 +1,78 @@ // src/tools/binance-simple-earn/earn-api/redeemFlexibleProduct.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { simpleEarnClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { simpleEarnClient } from "../../../config/binanceClient.js" export function registerBinanceRedeemFlexibleProduct(server: McpServer) { - server.tool( - "BinanceRedeemFlexibleProduct", - "Allows users to redeem their funds from a Flexible Earn investment product using a programmatic HTTP POST request.", - { - productId: z.string().describe("Product ID"), - redeemAll: z.boolean().optional().describe("true or false, default to false"), - amount: z.number().positive().optional().describe("If redeemAll is false, amount is mandatory"), - destAccount: z - .enum(["SPOT", "FUND"]) - .optional() - .describe("Destination account: SPOT or FUND; default is SPOT"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const { productId, redeemAll = false, amount, destAccount, recvWindow } = params; + server.tool( + "BinanceRedeemFlexibleProduct", + "Allows users to redeem their funds from a Flexible Earn investment product using a programmatic HTTP POST request.", + { + productId: z.string().describe("Product ID"), + redeemAll: z.boolean().optional().describe("true or false, default to false"), + amount: z + .number() + .positive() + .optional() + .describe("If redeemAll is false, amount is mandatory"), + destAccount: z + .enum(["SPOT", "FUND"]) + .optional() + .describe("Destination account: SPOT or FUND; default is SPOT"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const { productId, redeemAll = false, amount, destAccount, recvWindow } = params - // Defensive check - if (!redeemAll && (amount === undefined || amount <= 0)) { - return { - content: [ - { - type: "text", - text: "You must provide a valid amount when redeemAll is false." - } - ], - isError: true - }; - } + // Defensive check + if (!redeemAll && (amount === undefined || amount <= 0)) { + return { + content: [ + { + type: "text", + text: "You must provide a valid amount when redeemAll is false.", + }, + ], + isError: true, + } + } - const response = await simpleEarnClient.restAPI.redeemFlexibleProduct({ - productId, - ...(redeemAll !== undefined && { redeemAll }), - ...(amount !== undefined && { amount }), - ...(destAccount && { destAccount }), - ...(recvWindow && { recvWindow }) - }); + const response = await simpleEarnClient.restAPI.redeemFlexibleProduct({ + productId, + ...(redeemAll !== undefined && { redeemAll }), + ...(amount !== undefined && { amount }), + ...(destAccount && { destAccount }), + ...(recvWindow && { recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully redeem funds from a flexible earn investment. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully redeem funds from a flexible earn investment. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to allows users to redeem their funds from a Flexible Earn investment: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to allows users to redeem their funds from a Flexible Earn investment: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-simple-earn/earn-api/subscribeFlexibleProduct.ts b/src/tools/binance-simple-earn/earn-api/subscribeFlexibleProduct.ts index 5ec0a898..3532c8eb 100644 --- a/src/tools/binance-simple-earn/earn-api/subscribeFlexibleProduct.ts +++ b/src/tools/binance-simple-earn/earn-api/subscribeFlexibleProduct.ts @@ -1,56 +1,59 @@ // src/tools/binance-simple-earn/earn-api/subscribeFlexibleProduct.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { simpleEarnClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { simpleEarnClient } from "../../../config/binanceClient.js" export function registerBinanceSubscribeFlexibleProduct(server: McpServer) { - server.tool( - "BinanceSubscribeFlexibleProduct", - "Subscribe to a Simple Earn Flexible Product by specifying the product ID and amount. Optional parameters include auto-subscribe and source account. ", - { - productId: z.string().describe("Product ID"), - amount: z.number().positive().describe("Amount to purchase"), - autoSubscribe: z.boolean().optional().describe("true or false, default is true"), - sourceAccount: z - .enum(["SPOT", "FUND", "ALL"]) - .optional() - .describe("Source account: SPOT, FUND, or ALL; default is SPOT"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await simpleEarnClient.restAPI.subscribeFlexibleProduct({ - productId: params.productId, - amount: params.amount, - ...(params.autoSubscribe !== undefined && { autoSubscribe: params.autoSubscribe }), - ...(params.sourceAccount && { sourceAccount: params.sourceAccount }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSubscribeFlexibleProduct", + "Subscribe to a Simple Earn Flexible Product by specifying the product ID and amount. Optional parameters include auto-subscribe and source account. ", + { + productId: z.string().describe("Product ID"), + amount: z.number().positive().describe("Amount to purchase"), + autoSubscribe: z.boolean().optional().describe("true or false, default is true"), + sourceAccount: z + .enum(["SPOT", "FUND", "ALL"]) + .optional() + .describe("Source account: SPOT, FUND, or ALL; default is SPOT"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await simpleEarnClient.restAPI.subscribeFlexibleProduct({ + productId: params.productId, + amount: params.amount, + ...(params.autoSubscribe !== undefined && { autoSubscribe: params.autoSubscribe }), + ...(params.sourceAccount && { sourceAccount: params.sourceAccount }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully Subscribed to Simple Earn Flexible Product id ${ + params.productId + } and amount${params.amount}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully Subscribed to Simple Earn Flexible Product id ${ - params.productId - } and amount${params.amount}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to subscribe to a Simple Earn Flexible Product: ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to subscribe to a Simple Earn Flexible Product: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-simple-earn/index.ts b/src/tools/binance-simple-earn/index.ts index af82b8ee..7f5ae8eb 100644 --- a/src/tools/binance-simple-earn/index.ts +++ b/src/tools/binance-simple-earn/index.ts @@ -1,12 +1,13 @@ // src/tools/binance-simple-earn/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceSimpleEarnApiTools } from "./earn-api/index.js"; -import { registerBinanceSimpleEarnAccountApiTools } from "./account-api/index.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceSimpleEarnAccountApiTools } from "./account-api/index.js" +import { registerBinanceSimpleEarnApiTools } from "./earn-api/index.js" export function registerBinanceSimpleEarnTools(server: McpServer) { - // Registers core API tools like subscribing to flexible products - registerBinanceSimpleEarnApiTools(server); + // Registers core API tools like subscribing to flexible products + registerBinanceSimpleEarnApiTools(server) - // Registers account-related tools like viewing product lists and positions - registerBinanceSimpleEarnAccountApiTools(server); + // Registers account-related tools like viewing product lists and positions + registerBinanceSimpleEarnAccountApiTools(server) } diff --git a/src/tools/binance-spot/account-api/accountCommission.ts b/src/tools/binance-spot/account-api/accountCommission.ts index 399bebdd..f4a179c2 100644 --- a/src/tools/binance-spot/account-api/accountCommission.ts +++ b/src/tools/binance-spot/account-api/accountCommission.ts @@ -1,43 +1,45 @@ // src/tools/binance-spot/account-api/accountCommission.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceAccountCommission(server: McpServer) { - server.tool( - "BinanceAccountCommission", - "Get account commission rates for a specific symbol.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ symbol, recvWindow }) => { - try { - const params: any = { symbol }; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await spotClient.restAPI.accountCommission(params); + server.tool( + "BinanceAccountCommission", + "Get account commission rates for a specific symbol.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ symbol, recvWindow }) => { + try { + const params: any = { symbol } + if (recvWindow !== undefined) params.recvWindow = recvWindow + const response = await spotClient.restAPI.accountCommission(params) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved account commission rates for ${symbol}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved account commission rates for ${symbol}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve account commission rates: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve account commission rates: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-spot/account-api/getAccount.ts b/src/tools/binance-spot/account-api/getAccount.ts index c1339fa9..556a3e19 100644 --- a/src/tools/binance-spot/account-api/getAccount.ts +++ b/src/tools/binance-spot/account-api/getAccount.ts @@ -1,42 +1,44 @@ // src/tools/binance-spot/account-api/getAccount.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceGetAccount(server: McpServer) { - server.tool( - "BinanceGetAccount", - "Get current account information.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: any = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await spotClient.restAPI.getAccount(params); + server.tool( + "BinanceGetAccount", + "Get current account information.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: any = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + const response = await spotClient.restAPI.getAccount(params) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved account information. Account contains ${data.balances?.length || 0} balances. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved account information. Account contains ${data.balances?.length || 0} balances. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve account information: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve account information: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-spot/account-api/index.ts b/src/tools/binance-spot/account-api/index.ts index 6b1c4c10..2be3a54f 100644 --- a/src/tools/binance-spot/account-api/index.ts +++ b/src/tools/binance-spot/account-api/index.ts @@ -1,17 +1,18 @@ // src/tools/binance-spot/account-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceMyPreventedMatches } from "./myPreventedMatches.js"; -import { registerBinanceGetAccount } from "./getAccount.js"; -import { registerBinanceMyAllocations } from "./myAllocations.js"; -import { registerBinanceRateLimitOrder } from "./rateLimitOrder.js"; -import { registerBinanceAccountCommission } from "./accountCommission.js"; -import { registerBinanceMyTrades } from "./myTrades.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceAccountCommission } from "./accountCommission.js" +import { registerBinanceGetAccount } from "./getAccount.js" +import { registerBinanceMyAllocations } from "./myAllocations.js" +import { registerBinanceMyPreventedMatches } from "./myPreventedMatches.js" +import { registerBinanceMyTrades } from "./myTrades.js" +import { registerBinanceRateLimitOrder } from "./rateLimitOrder.js" export function registerBinanceAccountApiTools(server: McpServer) { - registerBinanceMyPreventedMatches(server); - registerBinanceGetAccount(server); - registerBinanceMyAllocations(server); - registerBinanceRateLimitOrder(server); - registerBinanceAccountCommission(server); - registerBinanceMyTrades(server); + registerBinanceMyPreventedMatches(server) + registerBinanceGetAccount(server) + registerBinanceMyAllocations(server) + registerBinanceRateLimitOrder(server) + registerBinanceAccountCommission(server) + registerBinanceMyTrades(server) } diff --git a/src/tools/binance-spot/account-api/myAllocations.ts b/src/tools/binance-spot/account-api/myAllocations.ts index 9d2bde83..81a00914 100644 --- a/src/tools/binance-spot/account-api/myAllocations.ts +++ b/src/tools/binance-spot/account-api/myAllocations.ts @@ -1,52 +1,52 @@ // src/tools/binance-spot/account-api/myAllocations.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceMyAllocations(server: McpServer) { - server.tool( - "BinanceMyAllocations", - "Get SOR allocations for Self-Trade Prevention.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - allocationId: z.number().optional().describe("Allocation ID"), - orderId: z.number().optional().describe("Order ID"), - fromAllocationId: z.number().optional().describe("Allocation ID to fetch from"), - limit: z.number().optional().describe("Default 500; max 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ symbol, allocationId, orderId, fromAllocationId, limit, recvWindow }) => { - try { - const params: any = { symbol }; - - if (allocationId !== undefined) params.allocationId = allocationId; - if (orderId !== undefined) params.orderId = orderId; - if (fromAllocationId !== undefined) params.fromAllocationId = fromAllocationId; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await spotClient.restAPI.myAllocations(params); - - - const data = await response.data(); - - return { - content: [ - { - type: "text", - text: `Retrieved SOR allocations for ${symbol}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve SOR allocations: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceMyAllocations", + "Get SOR allocations for Self-Trade Prevention.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + allocationId: z.number().optional().describe("Allocation ID"), + orderId: z.number().optional().describe("Order ID"), + fromAllocationId: z.number().optional().describe("Allocation ID to fetch from"), + limit: z.number().optional().describe("Default 500; max 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ symbol, allocationId, orderId, fromAllocationId, limit, recvWindow }) => { + try { + const params: any = { symbol } + + if (allocationId !== undefined) params.allocationId = allocationId + if (orderId !== undefined) params.orderId = orderId + if (fromAllocationId !== undefined) params.fromAllocationId = fromAllocationId + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await spotClient.restAPI.myAllocations(params) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved SOR allocations for ${symbol}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to retrieve SOR allocations: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-spot/account-api/myPreventedMatches.ts b/src/tools/binance-spot/account-api/myPreventedMatches.ts index c1ed4732..61403e30 100644 --- a/src/tools/binance-spot/account-api/myPreventedMatches.ts +++ b/src/tools/binance-spot/account-api/myPreventedMatches.ts @@ -1,51 +1,54 @@ // src/tools/binance-spot/account-api/myPreventedMatches.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceMyPreventedMatches(server: McpServer) { - server.tool( - "BinanceMyPreventedMatches", - "Get prevented matches for Self-Trade Prevention.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - preventedMatchId: z.number().optional().describe("Prevented match ID"), - orderId: z.number().optional().describe("Order ID"), - fromPreventedMatchId: z.number().optional().describe("Prevented match ID to fetch from"), - limit: z.number().optional().describe("Default 500; max 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ symbol, preventedMatchId, orderId, fromPreventedMatchId, limit, recvWindow }) => { - try { - const params: any = { symbol }; - - if (preventedMatchId !== undefined) params.preventedMatchId = preventedMatchId; - if (orderId !== undefined) params.orderId = orderId; - if (fromPreventedMatchId !== undefined) params.fromPreventedMatchId = fromPreventedMatchId; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await spotClient.restAPI.myPreventedMatches(params); - - const data = await response.data(); - - return { - content: [ - { - type: "text", - text: `Retrieved prevented matches for ${symbol}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve prevented matches: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceMyPreventedMatches", + "Get prevented matches for Self-Trade Prevention.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + preventedMatchId: z.number().optional().describe("Prevented match ID"), + orderId: z.number().optional().describe("Order ID"), + fromPreventedMatchId: z.number().optional().describe("Prevented match ID to fetch from"), + limit: z.number().optional().describe("Default 500; max 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ symbol, preventedMatchId, orderId, fromPreventedMatchId, limit, recvWindow }) => { + try { + const params: any = { symbol } + + if (preventedMatchId !== undefined) params.preventedMatchId = preventedMatchId + if (orderId !== undefined) params.orderId = orderId + if (fromPreventedMatchId !== undefined) params.fromPreventedMatchId = fromPreventedMatchId + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await spotClient.restAPI.myPreventedMatches(params) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved prevented matches for ${symbol}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to retrieve prevented matches: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-spot/account-api/myTrades.ts b/src/tools/binance-spot/account-api/myTrades.ts index 450ffd23..bfe95f19 100644 --- a/src/tools/binance-spot/account-api/myTrades.ts +++ b/src/tools/binance-spot/account-api/myTrades.ts @@ -1,54 +1,54 @@ // src/tools/binance-spot/account-api/myTrades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceMyTrades(server: McpServer) { - server.tool( - "BinanceMyTrades", - "Get trades for a specific account and symbol.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - orderId: z.number().optional().describe("Order ID"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - fromId: z.number().optional().describe("Trade ID to fetch from"), - limit: z.number().optional().describe("Default 500; max 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ symbol, orderId, startTime, endTime, fromId, limit, recvWindow }) => { - try { - const params: any = { symbol }; - - if (orderId !== undefined) params.orderId = orderId; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (fromId !== undefined) params.fromId = fromId; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await spotClient.restAPI.myTrades(params); - - - const data = await response.data(); - - return { - content: [ - { - type: "text", - text: `Retrieved trades for ${symbol}. Total trades: ${data.length}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve account trades: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceMyTrades", + "Get trades for a specific account and symbol.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + orderId: z.number().optional().describe("Order ID"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + fromId: z.number().optional().describe("Trade ID to fetch from"), + limit: z.number().optional().describe("Default 500; max 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ symbol, orderId, startTime, endTime, fromId, limit, recvWindow }) => { + try { + const params: any = { symbol } + + if (orderId !== undefined) params.orderId = orderId + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (fromId !== undefined) params.fromId = fromId + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await spotClient.restAPI.myTrades(params) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved trades for ${symbol}. Total trades: ${data.length}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to retrieve account trades: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-spot/account-api/rateLimitOrder.ts b/src/tools/binance-spot/account-api/rateLimitOrder.ts index a7886d3e..bd415e83 100644 --- a/src/tools/binance-spot/account-api/rateLimitOrder.ts +++ b/src/tools/binance-spot/account-api/rateLimitOrder.ts @@ -1,42 +1,44 @@ // src/tools/binance-spot/account-api/rateLimitOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceRateLimitOrder(server: McpServer) { - server.tool( - "BinanceRateLimitOrder", - "Get current order count usage for each rate limit.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: any = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await spotClient.restAPI.rateLimitOrder(params); + server.tool( + "BinanceRateLimitOrder", + "Get current order count usage for each rate limit.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: any = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + const response = await spotClient.restAPI.rateLimitOrder(params) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved current order count usage. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved current order count usage. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve order count usage: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve order count usage: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-spot/general-api/exchangeInfo.ts b/src/tools/binance-spot/general-api/exchangeInfo.ts index 0c869f15..9967eebe 100644 --- a/src/tools/binance-spot/general-api/exchangeInfo.ts +++ b/src/tools/binance-spot/general-api/exchangeInfo.ts @@ -1,49 +1,52 @@ // src/tools/binance-spot/general-api/exchangeInfo.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceExchangeInfo(server: McpServer) { - server.tool( - "BinanceExchangeInfo", - "Get exchange information including rate limits, symbol configs, etc.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - symbols: z.array(z.string()).optional().describe("Array of symbols to get info for"), - permissions: z.array(z.string()).optional().describe("Array of permissions to filter by") - }, - async ({ symbol, symbols, permissions }) => { - try { - const params: any = {}; - - if (symbol) params.symbol = symbol; - if (symbols) params.symbols = symbols; - if (permissions) params.permissions = permissions; - - const response = await spotClient.restAPI.exchangeInfo(params); - - const data = await response.data(); - - const symbolCount = data.symbols?.length || 0; - const exchangeFiltersCount = data.exchangeFilters?.length || 0; - - return { - content: [ - { - type: "text", - text: `Retrieved exchange information. Total symbols: ${symbolCount}, Exchange filters: ${exchangeFiltersCount}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve exchange information: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceExchangeInfo", + "Get exchange information including rate limits, symbol configs, etc.", + { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + symbols: z.array(z.string()).optional().describe("Array of symbols to get info for"), + permissions: z.array(z.string()).optional().describe("Array of permissions to filter by"), + }, + async ({ symbol, symbols, permissions }) => { + try { + const params: any = {} + + if (symbol) params.symbol = symbol + if (symbols) params.symbols = symbols + if (permissions) params.permissions = permissions + + const response = await spotClient.restAPI.exchangeInfo(params) + + const data = await response.data() + + const symbolCount = data.symbols?.length || 0 + const exchangeFiltersCount = data.exchangeFilters?.length || 0 + + return { + content: [ + { + type: "text", + text: `Retrieved exchange information. Total symbols: ${symbolCount}, Exchange filters: ${exchangeFiltersCount}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to retrieve exchange information: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-spot/general-api/index.ts b/src/tools/binance-spot/general-api/index.ts index 5ba8ee07..471676d4 100644 --- a/src/tools/binance-spot/general-api/index.ts +++ b/src/tools/binance-spot/general-api/index.ts @@ -1,12 +1,12 @@ // src/tools/binance-spot/general-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinancePing } from "./ping.js"; -import { registerBinanceTime } from "./time.js"; -import { registerBinanceExchangeInfo } from "./exchangeInfo.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceExchangeInfo } from "./exchangeInfo.js" +import { registerBinancePing } from "./ping.js" +import { registerBinanceTime } from "./time.js" export function registerBinanceGeneralApiTools(server: McpServer) { - registerBinancePing(server); - registerBinanceTime(server); - registerBinanceExchangeInfo(server); - + registerBinancePing(server) + registerBinanceTime(server) + registerBinanceExchangeInfo(server) } diff --git a/src/tools/binance-spot/general-api/ping.ts b/src/tools/binance-spot/general-api/ping.ts index ee57842a..1e0aa465 100644 --- a/src/tools/binance-spot/general-api/ping.ts +++ b/src/tools/binance-spot/general-api/ping.ts @@ -1,37 +1,30 @@ // src/tools/binance-spot/general-api/ping.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinancePing(server: McpServer) { - server.tool( - "BinancePing", - "Test connectivity to the Binance API.", - {}, - async () => { - try { - const response = await spotClient.restAPI.ping(); + server.tool("BinancePing", "Test connectivity to the Binance API.", {}, async () => { + try { + const response = await spotClient.restAPI.ping() + const data = await response.data() - const data = await response.data(); + return { + content: [ + { + type: "text", + text: `Successfully pinged Binance API. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully pinged Binance API. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to ping Binance API: ${errorMessage}` } - ], - isError: true - }; - } - } - ); + return { + content: [{ type: "text", text: `Failed to ping Binance API: ${errorMessage}` }], + isError: true, + } + } + }) } diff --git a/src/tools/binance-spot/general-api/time.ts b/src/tools/binance-spot/general-api/time.ts index cd6b4d18..3c0aa903 100644 --- a/src/tools/binance-spot/general-api/time.ts +++ b/src/tools/binance-spot/general-api/time.ts @@ -1,34 +1,35 @@ // src/tools/binance-spot/general-api/time.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceTime(server: McpServer) { - server.tool("BinanceTime", "Get the current server time from Binance API.", {}, async () => { - try { - const response = await spotClient.restAPI.time(); + server.tool("BinanceTime", "Get the current server time from Binance API.", {}, async () => { + try { + const response = await spotClient.restAPI.time() + + const data = await response.data() + + // @ts-expect-error - serverTime not in generated type definition + const serverTime = new Date(data.serverTime).toISOString() - const data = await response.data(); - - //@ts-ignore - const serverTime = new Date(data.serverTime).toISOString(); + return { + content: [ + { + type: "text", + text: `Current Binance server time: ${serverTime} (${ + data.serverTime + }). Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Current Binance server time: ${serverTime} (${ - data.serverTime - }). Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to retrieve server time: ${errorMessage}` }], - isError: true - }; - } - }); + return { + content: [{ type: "text", text: `Failed to retrieve server time: ${errorMessage}` }], + isError: true, + } + } + }) } diff --git a/src/tools/binance-spot/index.ts b/src/tools/binance-spot/index.ts index d39d3129..1c742dba 100644 --- a/src/tools/binance-spot/index.ts +++ b/src/tools/binance-spot/index.ts @@ -1,25 +1,25 @@ // src/tools/binance-spot/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceMarketApiTools } from "./market-api/index.js"; -import { registerBinanceTradeApiTools } from "./trade-api/index.js"; -import { registerBinanceAccountApiTools } from "./account-api/index.js"; -import { registerBinanceUserDataStreamApiTools } from "./userdatastream-api/index.js"; -import { registerBinanceGeneralApiTools } from "./general-api/index.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceAccountApiTools } from "./account-api/index.js" +import { registerBinanceGeneralApiTools } from "./general-api/index.js" +import { registerBinanceMarketApiTools } from "./market-api/index.js" +import { registerBinanceTradeApiTools } from "./trade-api/index.js" +import { registerBinanceUserDataStreamApiTools } from "./userdatastream-api/index.js" export function registerBinanceSpotTools(server: McpServer) { - // Trade API tools - registerBinanceTradeApiTools(server); - - // Market API tools - registerBinanceMarketApiTools(server); - - // Account API tools - registerBinanceAccountApiTools(server); - - // User Data Stream API tools - registerBinanceUserDataStreamApiTools(server); - - // General API tools - registerBinanceGeneralApiTools(server); - + // Trade API tools + registerBinanceTradeApiTools(server) + + // Market API tools + registerBinanceMarketApiTools(server) + + // Account API tools + registerBinanceAccountApiTools(server) + + // User Data Stream API tools + registerBinanceUserDataStreamApiTools(server) + + // General API tools + registerBinanceGeneralApiTools(server) } diff --git a/src/tools/binance-spot/market-api/aggTrades.ts b/src/tools/binance-spot/market-api/aggTrades.ts index 8c14bed9..3a1a49ef 100644 --- a/src/tools/binance-spot/market-api/aggTrades.ts +++ b/src/tools/binance-spot/market-api/aggTrades.ts @@ -1,50 +1,50 @@ // src/tools/binance-spot/market-api/aggTrades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceAggTrades(server: McpServer) { - server.tool( - "BinanceAggTrades", - "Get compressed, aggregate trades for a specific trading pair.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - fromId: z.number().optional().describe("ID to get aggregate trades from"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1000") - }, - async ({ symbol, fromId, startTime, endTime, limit }) => { - try { - const params: any = { symbol }; - - if (fromId !== undefined) params.fromId = fromId; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; - - const response = await spotClient.restAPI.aggTrades(params); - - - const data = await response.data(); - - return { - content: [ - { - type: "text", - text: `Retrieved aggregate trades for ${symbol}. Total trades: ${data.length}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve aggregate trades: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceAggTrades", + "Get compressed, aggregate trades for a specific trading pair.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + fromId: z.number().optional().describe("ID to get aggregate trades from"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1000"), + }, + async ({ symbol, fromId, startTime, endTime, limit }) => { + try { + const params: any = { symbol } + + if (fromId !== undefined) params.fromId = fromId + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit + + const response = await spotClient.restAPI.aggTrades(params) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved aggregate trades for ${symbol}. Total trades: ${data.length}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to retrieve aggregate trades: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-spot/market-api/avgPrice.ts b/src/tools/binance-spot/market-api/avgPrice.ts index 16107b77..80ed5102 100644 --- a/src/tools/binance-spot/market-api/avgPrice.ts +++ b/src/tools/binance-spot/market-api/avgPrice.ts @@ -1,41 +1,41 @@ // src/tools/binance-spot/market-api/avgPrice.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceAvgPrice(server: McpServer) { - server.tool( - "BinanceAvgPrice", - "Get current average price for a trading pair.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)") - }, - async ({ symbol }) => { - try { - const response = await spotClient.restAPI.avgPrice({ - symbol: symbol - }); + server.tool( + "BinanceAvgPrice", + "Get current average price for a trading pair.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, + async ({ symbol }) => { + try { + const response = await spotClient.restAPI.avgPrice({ + symbol: symbol, + }) + const data = await response.data() - const data = await response.data(); + return { + content: [ + { + type: "text", + text: `Retrieved current average price for ${symbol}. Average price: ${data.price}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved current average price for ${symbol}. Average price: ${data.price}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve average price: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve average price: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-spot/market-api/depth.ts b/src/tools/binance-spot/market-api/depth.ts index b83f84d5..6df7e4b5 100644 --- a/src/tools/binance-spot/market-api/depth.ts +++ b/src/tools/binance-spot/market-api/depth.ts @@ -1,43 +1,43 @@ // src/tools/binance-spot/market-api/depth.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceDepth(server: McpServer) { - server.tool( - "BinanceDepth", - "Get order book depth data for a specific trading pair.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - limit: z.number().optional().describe("Depth of the order book. Default 100; max 5000.") - }, - async ({ symbol, limit }) => { - try { - const params: any = { symbol }; - if (limit !== undefined) params.limit = limit; - - const response = await spotClient.restAPI.depth(params); + server.tool( + "BinanceDepth", + "Get order book depth data for a specific trading pair.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + limit: z.number().optional().describe("Depth of the order book. Default 100; max 5000."), + }, + async ({ symbol, limit }) => { + try { + const params: any = { symbol } + if (limit !== undefined) params.limit = limit + const response = await spotClient.restAPI.depth(params) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved order book depth for ${symbol}. Bids: ${data.bids?.length || 0}, Asks: ${data.asks?.length || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved order book depth for ${symbol}. Bids: ${data.bids?.length || 0}, Asks: ${data.asks?.length || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve order book depth: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve order book depth: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-spot/market-api/getTrades.ts b/src/tools/binance-spot/market-api/getTrades.ts index 7c885045..6f65b5e4 100644 --- a/src/tools/binance-spot/market-api/getTrades.ts +++ b/src/tools/binance-spot/market-api/getTrades.ts @@ -1,43 +1,44 @@ // src/tools/binance-spot/market-api/getTrades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceGetTrades(server: McpServer) { - server.tool( - "BinanceGetTrades", - "Get recent trades for a specific trading pair.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - limit: z.number().optional().describe("Default 500; max 1000") - }, - async ({ symbol, limit }) => { - try { - const params: any = { symbol }; - - if (limit !== undefined) params.limit = limit; - - const response = await spotClient.restAPI.getTrades(params); - - const data = await response.data(); - - return { - content: [ - { - type: "text", - text: `Retrieved recent trades for ${symbol}. Total trades: ${data.length}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve recent trades: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceGetTrades", + "Get recent trades for a specific trading pair.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + limit: z.number().optional().describe("Default 500; max 1000"), + }, + async ({ symbol, limit }) => { + try { + const params: any = { symbol } + + if (limit !== undefined) params.limit = limit + + const response = await spotClient.restAPI.getTrades(params) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved recent trades for ${symbol}. Total trades: ${data.length}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to retrieve recent trades: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-spot/market-api/historicalTrades.ts b/src/tools/binance-spot/market-api/historicalTrades.ts index cefd0378..ca14bb87 100644 --- a/src/tools/binance-spot/market-api/historicalTrades.ts +++ b/src/tools/binance-spot/market-api/historicalTrades.ts @@ -1,45 +1,48 @@ // src/tools/binance-spot/market-api/historicalTrades.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceHistoricalTrades(server: McpServer) { - server.tool( - "BinanceHistoricalTrades", - "Get older historical trades for a specific trading pair.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - limit: z.number().optional().describe("Default 500; max 1000"), - fromId: z.number().optional().describe("Trade ID to fetch from") - }, - async ({ symbol, limit, fromId }) => { - try { - const params: any = { symbol }; - - if (limit !== undefined) params.limit = limit; - if (fromId !== undefined) params.fromId = fromId; - - const response = await spotClient.restAPI.historicalTrades(params); - - const data = await response.data(); - - return { - content: [ - { - type: "text", - text: `Retrieved historical trades for ${symbol}. Total trades: ${data.length}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve historical trades: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceHistoricalTrades", + "Get older historical trades for a specific trading pair.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + limit: z.number().optional().describe("Default 500; max 1000"), + fromId: z.number().optional().describe("Trade ID to fetch from"), + }, + async ({ symbol, limit, fromId }) => { + try { + const params: any = { symbol } + + if (limit !== undefined) params.limit = limit + if (fromId !== undefined) params.fromId = fromId + + const response = await spotClient.restAPI.historicalTrades(params) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved historical trades for ${symbol}. Total trades: ${data.length}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to retrieve historical trades: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-spot/market-api/index.ts b/src/tools/binance-spot/market-api/index.ts index b0730073..4ccede7d 100644 --- a/src/tools/binance-spot/market-api/index.ts +++ b/src/tools/binance-spot/market-api/index.ts @@ -1,30 +1,30 @@ // src/tools/binance-spot/market-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceKlines } from "./klines.js"; -import { registerBinanceTicker24hr } from "./ticker24hr.js"; -import { registerBinanceDepth } from "./depth.js"; -import { registerBinanceAggTrades } from "./aggTrades.js"; -import { registerBinanceTickerTradingDay } from "./tickerTradingDay.js"; -import { registerBinanceUiKlines } from "./uiKlines.js"; -import { registerBinanceTickerBookTicker } from "./tickerBookTicker.js"; -import { registerBinanceAvgPrice } from "./avgPrice.js"; -import { registerBinanceTickerPrice } from "./tickerPrice.js"; -import { registerBinanceTicker } from "./ticker.js"; -import { registerBinanceHistoricalTrades } from "./historicalTrades.js"; -import { registerBinanceGetTrades } from "./getTrades.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceAggTrades } from "./aggTrades.js" +import { registerBinanceAvgPrice } from "./avgPrice.js" +import { registerBinanceDepth } from "./depth.js" +import { registerBinanceGetTrades } from "./getTrades.js" +import { registerBinanceHistoricalTrades } from "./historicalTrades.js" +import { registerBinanceKlines } from "./klines.js" +import { registerBinanceTicker24hr } from "./ticker24hr.js" +import { registerBinanceTicker } from "./ticker.js" +import { registerBinanceTickerBookTicker } from "./tickerBookTicker.js" +import { registerBinanceTickerPrice } from "./tickerPrice.js" +import { registerBinanceTickerTradingDay } from "./tickerTradingDay.js" +import { registerBinanceUiKlines } from "./uiKlines.js" export function registerBinanceMarketApiTools(server: McpServer) { - registerBinanceKlines(server); - registerBinanceTicker24hr(server); - registerBinanceDepth(server); - registerBinanceAggTrades(server); - registerBinanceTickerTradingDay(server); - registerBinanceUiKlines(server); - registerBinanceTickerBookTicker(server); - registerBinanceAvgPrice(server); - registerBinanceTickerPrice(server); - registerBinanceTicker(server); - registerBinanceHistoricalTrades(server); - registerBinanceGetTrades(server); - -} \ No newline at end of file + registerBinanceKlines(server) + registerBinanceTicker24hr(server) + registerBinanceDepth(server) + registerBinanceAggTrades(server) + registerBinanceTickerTradingDay(server) + registerBinanceUiKlines(server) + registerBinanceTickerBookTicker(server) + registerBinanceAvgPrice(server) + registerBinanceTickerPrice(server) + registerBinanceTicker(server) + registerBinanceHistoricalTrades(server) + registerBinanceGetTrades(server) +} diff --git a/src/tools/binance-spot/market-api/klines.ts b/src/tools/binance-spot/market-api/klines.ts index 53e3fcf5..1eb9eb49 100644 --- a/src/tools/binance-spot/market-api/klines.ts +++ b/src/tools/binance-spot/market-api/klines.ts @@ -1,53 +1,70 @@ // src/tools/binance-spot/market-api/klines.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceKlines(server: McpServer) { - server.tool( - "BinanceKlines", - "Get candlestick data (klines) for a specific trading pair and interval.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - interval: z.enum([ - "1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "8h", "12h", "1d", "3d", "1w", "1M" - ]).describe("Kline interval"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1000") - }, - async ({ symbol, interval, startTime, endTime, limit }) => { - try { - const params: any = { - symbol, - interval - }; - - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; - - const response = await spotClient.restAPI.klines(params); - - const data = await response.data(); - - return { - content: [ - { - type: "text", - text: `Retrieved klines for ${symbol} with ${interval} interval. Total candles: ${data.length}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve klines: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceKlines", + "Get candlestick data (klines) for a specific trading pair and interval.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1000"), + }, + async ({ symbol, interval, startTime, endTime, limit }) => { + try { + const params: any = { + symbol, + interval, + } + + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit + + const response = await spotClient.restAPI.klines(params) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved klines for ${symbol} with ${interval} interval. Total candles: ${data.length}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to retrieve klines: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-spot/market-api/ticker.ts b/src/tools/binance-spot/market-api/ticker.ts index 12e44187..05d15f05 100644 --- a/src/tools/binance-spot/market-api/ticker.ts +++ b/src/tools/binance-spot/market-api/ticker.ts @@ -1,49 +1,54 @@ // src/tools/binance-spot/market-api/ticker.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceTicker(server: McpServer) { - server.tool( - "BinanceTicker", - "Get 24-hour rolling window price change statistics for a symbol or all symbols.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - windowSize: z.string().optional().describe("Defaults to 1d. Valid values: 1d, 2d, 3d, 4d, 5d, 6d, 7d") - }, - async ({ symbol, windowSize }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - if (windowSize) params.windowSize = windowSize; - - const response = await spotClient.restAPI.ticker(params); - - - const data = await response.data(); - - const isArray = Array.isArray(data); - const responseText = isArray - ? `Retrieved ticker statistics for all symbols${windowSize ? ` with window size ${windowSize}` : ''}. Total items: ${data.length}.` - : `Retrieved ticker statistics for ${symbol}${windowSize ? ` with window size ${windowSize}` : ''}.`; - - return { - content: [ - { - type: "text", - text: `${responseText} Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve ticker statistics: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceTicker", + "Get 24-hour rolling window price change statistics for a symbol or all symbols.", + { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + windowSize: z + .string() + .optional() + .describe("Defaults to 1d. Valid values: 1d, 2d, 3d, 4d, 5d, 6d, 7d"), + }, + async ({ symbol, windowSize }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + if (windowSize) params.windowSize = windowSize + + const response = await spotClient.restAPI.ticker(params) + + const data = await response.data() + + const isArray = Array.isArray(data) + const responseText = isArray + ? `Retrieved ticker statistics for all symbols${windowSize ? ` with window size ${windowSize}` : ""}. Total items: ${data.length}.` + : `Retrieved ticker statistics for ${symbol}${windowSize ? ` with window size ${windowSize}` : ""}.` + + return { + content: [ + { + type: "text", + text: `${responseText} Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to retrieve ticker statistics: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-spot/market-api/ticker24hr.ts b/src/tools/binance-spot/market-api/ticker24hr.ts index 12ddce0d..58f1d5ed 100644 --- a/src/tools/binance-spot/market-api/ticker24hr.ts +++ b/src/tools/binance-spot/market-api/ticker24hr.ts @@ -1,47 +1,47 @@ // src/tools/binance-spot/market-api/ticker24hr.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceTicker24hr(server: McpServer) { - server.tool( - "BinanceTicker24hr", - "Get 24-hour price change statistics for a symbol or all symbols.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)") - }, - async ({ symbol }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - - const response = await spotClient.restAPI.ticker24hr(params); - - - const data = await response.data(); - - const isArray = Array.isArray(data); - const responseText = isArray - ? `Retrieved 24hr statistics for all symbols. Total items: ${data.length}.` - : `Retrieved 24hr statistics for ${symbol}.`; - - return { - content: [ - { - type: "text", - text: `${responseText} Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve 24hr ticker: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceTicker24hr", + "Get 24-hour price change statistics for a symbol or all symbols.", + { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, + async ({ symbol }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + + const response = await spotClient.restAPI.ticker24hr(params) + + const data = await response.data() + + const isArray = Array.isArray(data) + const responseText = isArray + ? `Retrieved 24hr statistics for all symbols. Total items: ${data.length}.` + : `Retrieved 24hr statistics for ${symbol}.` + + return { + content: [ + { + type: "text", + text: `${responseText} Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to retrieve 24hr ticker: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-spot/market-api/tickerBookTicker.ts b/src/tools/binance-spot/market-api/tickerBookTicker.ts index 44a28791..9fede0b8 100644 --- a/src/tools/binance-spot/market-api/tickerBookTicker.ts +++ b/src/tools/binance-spot/market-api/tickerBookTicker.ts @@ -1,47 +1,47 @@ // src/tools/binance-spot/market-api/tickerBookTicker.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceTickerBookTicker(server: McpServer) { - server.tool( - "BinanceTickerBookTicker", - "Get best price/quantity on the order book for a symbol or all symbols.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)") - }, - async ({ symbol }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - - const response = await spotClient.restAPI.tickerBookTicker(params); - - - const data = await response.data(); - - const isArray = Array.isArray(data); - const responseText = isArray - ? `Retrieved best price/quantity on the order book for all symbols. Total items: ${data.length}.` - : `Retrieved best price/quantity on the order book for ${symbol}.`; - - return { - content: [ - { - type: "text", - text: `${responseText} Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve book ticker: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceTickerBookTicker", + "Get best price/quantity on the order book for a symbol or all symbols.", + { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, + async ({ symbol }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + + const response = await spotClient.restAPI.tickerBookTicker(params) + + const data = await response.data() + + const isArray = Array.isArray(data) + const responseText = isArray + ? `Retrieved best price/quantity on the order book for all symbols. Total items: ${data.length}.` + : `Retrieved best price/quantity on the order book for ${symbol}.` + + return { + content: [ + { + type: "text", + text: `${responseText} Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to retrieve book ticker: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-spot/market-api/tickerPrice.ts b/src/tools/binance-spot/market-api/tickerPrice.ts index 98313726..d57a9323 100644 --- a/src/tools/binance-spot/market-api/tickerPrice.ts +++ b/src/tools/binance-spot/market-api/tickerPrice.ts @@ -1,47 +1,47 @@ // src/tools/binance-spot/market-api/tickerPrice.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceTickerPrice(server: McpServer) { - server.tool( - "BinanceTickerPrice", - "Get latest price for a symbol or all symbols.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)") - }, - async ({ symbol }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - - const response = await spotClient.restAPI.tickerPrice(params); - - - const data = await response.data(); - - const isArray = Array.isArray(data); - const responseText = isArray - ? `Retrieved latest prices for all symbols. Total items: ${data.length}.` - : `Retrieved latest price for ${symbol}: ${data.price}.`; - - return { - content: [ - { - type: "text", - text: `${responseText} Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve ticker price: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceTickerPrice", + "Get latest price for a symbol or all symbols.", + { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, + async ({ symbol }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + + const response = await spotClient.restAPI.tickerPrice(params) + + const data = await response.data() + + const isArray = Array.isArray(data) + const responseText = isArray + ? `Retrieved latest prices for all symbols. Total items: ${data.length}.` + : `Retrieved latest price for ${symbol}: ${data.price}.` + + return { + content: [ + { + type: "text", + text: `${responseText} Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to retrieve ticker price: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-spot/market-api/tickerTradingDay.ts b/src/tools/binance-spot/market-api/tickerTradingDay.ts index 7d96249e..9e21de6f 100644 --- a/src/tools/binance-spot/market-api/tickerTradingDay.ts +++ b/src/tools/binance-spot/market-api/tickerTradingDay.ts @@ -1,47 +1,49 @@ // src/tools/binance-spot/market-api/tickerTradingDay.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceTickerTradingDay(server: McpServer) { - server.tool( - "BinanceTickerTradingDay", - "Get statistics for the current trading day for a symbol or all symbols.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)") - }, - async ({ symbol }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - - const response = await spotClient.restAPI.tickerTradingDay(params); - - - const data = await response.data(); - - const isArray = Array.isArray(data); - const responseText = isArray - ? `Retrieved trading day statistics for all symbols. Total items: ${data.length}.` - : `Retrieved trading day statistics for ${symbol}.`; - - return { - content: [ - { - type: "text", - text: `${responseText} Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve trading day statistics: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceTickerTradingDay", + "Get statistics for the current trading day for a symbol or all symbols.", + { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, + async ({ symbol }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + + const response = await spotClient.restAPI.tickerTradingDay(params) + + const data = await response.data() + + const isArray = Array.isArray(data) + const responseText = isArray + ? `Retrieved trading day statistics for all symbols. Total items: ${data.length}.` + : `Retrieved trading day statistics for ${symbol}.` + + return { + content: [ + { + type: "text", + text: `${responseText} Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to retrieve trading day statistics: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-spot/market-api/uiKlines.ts b/src/tools/binance-spot/market-api/uiKlines.ts index 96100d2b..886a3d75 100644 --- a/src/tools/binance-spot/market-api/uiKlines.ts +++ b/src/tools/binance-spot/market-api/uiKlines.ts @@ -1,53 +1,70 @@ // src/tools/binance-spot/market-api/uiKlines.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceUiKlines(server: McpServer) { - server.tool( - "BinanceUiKlines", - "Get UI-optimized candlestick data for a specific trading pair and interval.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - interval: z.enum([ - "1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "8h", "12h", "1d", "3d", "1w", "1M" - ]).describe("Kline interval"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1000") - }, - async ({ symbol, interval, startTime, endTime, limit }) => { - try { - const params: any = { - symbol, - interval - }; - - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; - - const response = await spotClient.restAPI.uiKlines(params); - - const data = await response.data(); - - return { - content: [ - { - type: "text", - text: `Retrieved UI klines for ${symbol} with ${interval} interval. Total candles: ${data.length}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve UI klines: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceUiKlines", + "Get UI-optimized candlestick data for a specific trading pair and interval.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1000"), + }, + async ({ symbol, interval, startTime, endTime, limit }) => { + try { + const params: any = { + symbol, + interval, + } + + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit + + const response = await spotClient.restAPI.uiKlines(params) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved UI klines for ${symbol} with ${interval} interval. Total candles: ${data.length}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to retrieve UI klines: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-spot/trade-api/allOrders.ts b/src/tools/binance-spot/trade-api/allOrders.ts index d94ac840..1a4b3f19 100644 --- a/src/tools/binance-spot/trade-api/allOrders.ts +++ b/src/tools/binance-spot/trade-api/allOrders.ts @@ -1,49 +1,53 @@ // src/tools/binance-spot/trade-api/allOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceAllOrders(server: McpServer) { - server.tool( - "BinanceAllOrders", - "Get all account orders for a specific symbol; active, canceled, or filled.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - orderId: z.number().optional().describe("Order ID to start from"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Maximum number of orders to return (default 500, max 1000)") - }, - async ({ symbol, orderId, startTime, endTime, limit }) => { - try { - const params: any = { symbol }; - - if (orderId !== undefined) params.orderId = orderId; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; - - const response = await spotClient.restAPI.allOrders(params); - - const data = await response.data(); - - return { - content: [ - { - type: "text", - text: `Retrieved all orders for ${symbol}. Total orders: ${data.length}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve all orders: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceAllOrders", + "Get all account orders for a specific symbol; active, canceled, or filled.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + orderId: z.number().optional().describe("Order ID to start from"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z + .number() + .optional() + .describe("Maximum number of orders to return (default 500, max 1000)"), + }, + async ({ symbol, orderId, startTime, endTime, limit }) => { + try { + const params: any = { symbol } + + if (orderId !== undefined) params.orderId = orderId + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit + + const response = await spotClient.restAPI.allOrders(params) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved all orders for ${symbol}. Total orders: ${data.length}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to retrieve all orders: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-spot/trade-api/deleteOpenOrders.ts b/src/tools/binance-spot/trade-api/deleteOpenOrders.ts index 1cdaca3f..95920e81 100644 --- a/src/tools/binance-spot/trade-api/deleteOpenOrders.ts +++ b/src/tools/binance-spot/trade-api/deleteOpenOrders.ts @@ -1,40 +1,41 @@ // src/tools/binance-spot/trade-api/deleteOpenOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceDeleteOpenOrders(server: McpServer) { - server.tool( - "BinanceDeleteOpenOrders", - "Cancel all open orders on Binance for a specific symbol.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)") - }, - async ({ symbol }) => { - try { - const response = await spotClient.restAPI.deleteOpenOrders({ - symbol: symbol - }); + server.tool( + "BinanceDeleteOpenOrders", + "Cancel all open orders on Binance for a specific symbol.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, + async ({ symbol }) => { + try { + const response = await spotClient.restAPI.deleteOpenOrders({ + symbol: symbol, + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully canceled all open orders for ${symbol}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully canceled all open orders for ${symbol}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to cancel open orders: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to cancel open orders: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-spot/trade-api/deleteOrder.ts b/src/tools/binance-spot/trade-api/deleteOrder.ts index 027bdde0..cbf5490d 100644 --- a/src/tools/binance-spot/trade-api/deleteOrder.ts +++ b/src/tools/binance-spot/trade-api/deleteOrder.ts @@ -1,45 +1,46 @@ // src/tools/binance-spot/trade-api/deleteOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceDeleteOrder(server: McpServer) { - server.tool( - "BinanceDeleteOrder", - "Cancel an active order on Binance for a specific trading pair.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - orderId: z.string().optional().describe("The order ID to cancel"), - origClientOrderId: z.string().optional().describe("Original client order ID") - }, - async ({ symbol, orderId, origClientOrderId }) => { - try { - const params: any = { symbol }; - - if (orderId) params.orderId = orderId; - if (origClientOrderId) params.origClientOrderId = origClientOrderId; - - const response = await spotClient.restAPI.deleteOrder(params); - - const data = await response.data(); - - return { - content: [ - { - type: "text", - text: `Order successfully canceled. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to cancel order: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceDeleteOrder", + "Cancel an active order on Binance for a specific trading pair.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + orderId: z.string().optional().describe("The order ID to cancel"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + }, + async ({ symbol, orderId, origClientOrderId }) => { + try { + const params: any = { symbol } + + if (orderId) params.orderId = orderId + if (origClientOrderId) params.origClientOrderId = origClientOrderId + + const response = await spotClient.restAPI.deleteOrder(params) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Order successfully canceled. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to cancel order: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-spot/trade-api/getOpenOrders.ts b/src/tools/binance-spot/trade-api/getOpenOrders.ts index 0f129727..70e079a7 100644 --- a/src/tools/binance-spot/trade-api/getOpenOrders.ts +++ b/src/tools/binance-spot/trade-api/getOpenOrders.ts @@ -1,41 +1,42 @@ // src/tools/binance-spot/trade-api/getOpenOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceGetOpenOrders(server: McpServer) { - server.tool( - "BinanceGetOpenOrders", - "Get all open orders on Binance for a specific symbol or all symbols.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)") - }, - async ({ symbol }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - - const response = await spotClient.restAPI.getOpenOrders(params); + server.tool( + "BinanceGetOpenOrders", + "Get all open orders on Binance for a specific symbol or all symbols.", + { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, + async ({ symbol }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + + const response = await spotClient.restAPI.getOpenOrders(params) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved open orders${symbol ? ` for ${symbol}` : ""}. Total open orders: ${data.length}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved open orders${symbol ? ` for ${symbol}` : ''}. Total open orders: ${data.length}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve open orders: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve open orders: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-spot/trade-api/getOrder.ts b/src/tools/binance-spot/trade-api/getOrder.ts index e7647207..1c83ac75 100644 --- a/src/tools/binance-spot/trade-api/getOrder.ts +++ b/src/tools/binance-spot/trade-api/getOrder.ts @@ -1,45 +1,48 @@ // src/tools/binance-spot/trade-api/getOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceGetOrder(server: McpServer) { - server.tool( - "BinanceGetOrder", - "Check an order's status on Binance for a specific trading pair.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - orderId: z.string().optional().describe("The order ID to query"), - origClientOrderId: z.string().optional().describe("Original client order ID") - }, - async ({ symbol, orderId, origClientOrderId }) => { - try { - const params: any = { symbol }; - - if (orderId) params.orderId = orderId; - if (origClientOrderId) params.origClientOrderId = origClientOrderId; - - const response = await spotClient.restAPI.getOrder(params); - - const data = await response.data(); - - return { - content: [ - { - type: "text", - text: `Order information retrieved successfully. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve order information: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceGetOrder", + "Check an order's status on Binance for a specific trading pair.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + orderId: z.string().optional().describe("The order ID to query"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + }, + async ({ symbol, orderId, origClientOrderId }) => { + try { + const params: any = { symbol } + + if (orderId) params.orderId = orderId + if (origClientOrderId) params.origClientOrderId = origClientOrderId + + const response = await spotClient.restAPI.getOrder(params) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Order information retrieved successfully. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to retrieve order information: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-spot/trade-api/index.ts b/src/tools/binance-spot/trade-api/index.ts index 1478bdd3..d7dc679c 100644 --- a/src/tools/binance-spot/trade-api/index.ts +++ b/src/tools/binance-spot/trade-api/index.ts @@ -1,22 +1,22 @@ // src/tools/binance-spot/trade-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceDeleteOrder } from "./deleteOrder.js"; -import { registerBinanceAllOrders } from "./allOrders.js"; -import { registerBinanceOpenOrderList } from "./openOrderList.js"; -import { registerBinanceNewOrder } from "./newOrder.js"; -import { registerBinanceGetOrder } from "./getOrder.js"; -import { registerBinanceGetOpenOrders } from "./getOpenOrders.js"; -import { registerBinanceDeleteOpenOrders } from "./deleteOpenOrders.js"; -import { registerBinanceOrderOco } from "./orderOco.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceAllOrders } from "./allOrders.js" +import { registerBinanceDeleteOpenOrders } from "./deleteOpenOrders.js" +import { registerBinanceDeleteOrder } from "./deleteOrder.js" +import { registerBinanceGetOpenOrders } from "./getOpenOrders.js" +import { registerBinanceGetOrder } from "./getOrder.js" +import { registerBinanceNewOrder } from "./newOrder.js" +import { registerBinanceOpenOrderList } from "./openOrderList.js" +import { registerBinanceOrderOco } from "./orderOco.js" export function registerBinanceTradeApiTools(server: McpServer) { - registerBinanceDeleteOrder(server); - registerBinanceAllOrders(server); - registerBinanceOpenOrderList(server); - registerBinanceNewOrder(server); - registerBinanceGetOrder(server); - registerBinanceGetOpenOrders(server); - registerBinanceDeleteOpenOrders(server); - registerBinanceOrderOco(server); - -} \ No newline at end of file + registerBinanceDeleteOrder(server) + registerBinanceAllOrders(server) + registerBinanceOpenOrderList(server) + registerBinanceNewOrder(server) + registerBinanceGetOrder(server) + registerBinanceGetOpenOrders(server) + registerBinanceDeleteOpenOrders(server) + registerBinanceOrderOco(server) +} diff --git a/src/tools/binance-spot/trade-api/newOrder.ts b/src/tools/binance-spot/trade-api/newOrder.ts index 1b01cfe5..9080a015 100644 --- a/src/tools/binance-spot/trade-api/newOrder.ts +++ b/src/tools/binance-spot/trade-api/newOrder.ts @@ -1,63 +1,86 @@ // src/tools/binance-spot/trade-api/newOrder.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceNewOrder(server: McpServer) { - server.tool( - "BinanceNewOrder", - "Create a new order on Binance for a specific trading pair.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Order side: BUY or SELL"), - type: z.enum(["LIMIT", "MARKET", "STOP_LOSS", "STOP_LOSS_LIMIT", "TAKE_PROFIT", "TAKE_PROFIT_LIMIT", "LIMIT_MAKER"]).describe("Order type"), - timeInForce: z.enum(["GTC", "IOC", "FOK"]).optional().describe("Time in force"), - quantity: z.number().describe("Order quantity"), - quoteOrderQty: z.number().optional().describe("Quote order quantity"), - price: z.number().optional().describe("Order price"), - newClientOrderId: z.string().optional().describe("Client order ID"), - stopPrice: z.number().optional().describe("Stop price"), - icebergQty: z.number().optional().describe("Iceberg quantity"), - newOrderRespType: z.enum(["ACK", "RESULT", "FULL"]).optional().describe("Response type") - }, - async ({ symbol, side, type, timeInForce, quantity, quoteOrderQty, price, newClientOrderId, stopPrice, icebergQty, newOrderRespType }) => { - try { - const params: any = { - symbol, - side, - type, - quantity - }; - - if (timeInForce) params.timeInForce = timeInForce; - if (quoteOrderQty !== undefined) params.quoteOrderQty = quoteOrderQty; - if (price !== undefined) params.price = price; - if (newClientOrderId) params.newClientOrderId = newClientOrderId; - if (stopPrice !== undefined) params.stopPrice = stopPrice; - if (icebergQty !== undefined) params.icebergQty = icebergQty; - if (newOrderRespType) params.newOrderRespType = newOrderRespType; - - const response = await spotClient.restAPI.newOrder(params); - - const data = await response.data(); - - return { - content: [ - { - type: "text", - text: `New order successfully created. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to create new order: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceNewOrder", + "Create a new order on Binance for a specific trading pair.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Order side: BUY or SELL"), + type: z + .enum([ + "LIMIT", + "MARKET", + "STOP_LOSS", + "STOP_LOSS_LIMIT", + "TAKE_PROFIT", + "TAKE_PROFIT_LIMIT", + "LIMIT_MAKER", + ]) + .describe("Order type"), + timeInForce: z.enum(["GTC", "IOC", "FOK"]).optional().describe("Time in force"), + quantity: z.number().describe("Order quantity"), + quoteOrderQty: z.number().optional().describe("Quote order quantity"), + price: z.number().optional().describe("Order price"), + newClientOrderId: z.string().optional().describe("Client order ID"), + stopPrice: z.number().optional().describe("Stop price"), + icebergQty: z.number().optional().describe("Iceberg quantity"), + newOrderRespType: z.enum(["ACK", "RESULT", "FULL"]).optional().describe("Response type"), + }, + async ({ + symbol, + side, + type, + timeInForce, + quantity, + quoteOrderQty, + price, + newClientOrderId, + stopPrice, + icebergQty, + newOrderRespType, + }) => { + try { + const params: any = { + symbol, + side, + type, + quantity, + } + + if (timeInForce) params.timeInForce = timeInForce + if (quoteOrderQty !== undefined) params.quoteOrderQty = quoteOrderQty + if (price !== undefined) params.price = price + if (newClientOrderId) params.newClientOrderId = newClientOrderId + if (stopPrice !== undefined) params.stopPrice = stopPrice + if (icebergQty !== undefined) params.icebergQty = icebergQty + if (newOrderRespType) params.newOrderRespType = newOrderRespType + + const response = await spotClient.restAPI.newOrder(params) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `New order successfully created. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to create new order: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-spot/trade-api/openOrderList.ts b/src/tools/binance-spot/trade-api/openOrderList.ts index 7c6134f5..1ba07a57 100644 --- a/src/tools/binance-spot/trade-api/openOrderList.ts +++ b/src/tools/binance-spot/trade-api/openOrderList.ts @@ -1,41 +1,42 @@ // src/tools/binance-spot/trade-api/openOrderList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceOpenOrderList(server: McpServer) { - server.tool( - "BinanceOpenOrderList", - "Query open OCO orders for a specific account or symbol.", - { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)") - }, - async ({ symbol }) => { - try { - const params: any = {}; - if (symbol) params.symbol = symbol; - - const response = await spotClient.restAPI.openOrderList(params); + server.tool( + "BinanceOpenOrderList", + "Query open OCO orders for a specific account or symbol.", + { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, + async ({ symbol }) => { + try { + const params: any = {} + if (symbol) params.symbol = symbol + + const response = await spotClient.restAPI.openOrderList(params) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved open OCO orders${symbol ? ` for ${symbol}` : ""}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved open OCO orders${symbol ? ` for ${symbol}` : ''}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve open OCO orders: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve open OCO orders: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-spot/trade-api/orderOco.ts b/src/tools/binance-spot/trade-api/orderOco.ts index b758bf40..bfca8250 100644 --- a/src/tools/binance-spot/trade-api/orderOco.ts +++ b/src/tools/binance-spot/trade-api/orderOco.ts @@ -1,63 +1,79 @@ // src/tools/binance-spot/trade-api/orderOco.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceOrderOco(server: McpServer) { - server.tool( - "BinanceOrderOco", - "Send a new OCO (One-Cancels-the-Other) order on Binance.", - { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Order side: BUY or SELL"), - quantity: z.number().describe("Order quantity"), - price: z.number().describe("Order price"), - stopPrice: z.number().describe("Stop price"), - stopLimitPrice: z.number().optional().describe("Stop limit price"), - stopLimitTimeInForce: z.enum(["GTC", "IOC", "FOK"]).optional().describe("Stop limit time in force"), - newClientOrderId: z.string().optional().describe("Client order ID for the limit order"), - stopClientOrderId: z.string().optional().describe("Client order ID for the stop order"), - limitIcebergQty: z.number().optional().describe("Limit iceberg quantity"), - stopIcebergQty: z.number().optional().describe("Stop iceberg quantity") - }, - async ({ symbol, side, quantity, price, stopPrice, stopLimitPrice, stopLimitTimeInForce, newClientOrderId, stopClientOrderId, limitIcebergQty, stopIcebergQty }) => { - try { - const params: any = { - symbol, - side, - quantity, - price, - stopPrice - }; - - if (stopLimitPrice !== undefined) params.stopLimitPrice = stopLimitPrice; - if (stopLimitTimeInForce) params.stopLimitTimeInForce = stopLimitTimeInForce; - if (newClientOrderId) params.newClientOrderId = newClientOrderId; - if (stopClientOrderId) params.stopClientOrderId = stopClientOrderId; - if (limitIcebergQty !== undefined) params.limitIcebergQty = limitIcebergQty; - if (stopIcebergQty !== undefined) params.stopIcebergQty = stopIcebergQty; - - const response = await spotClient.restAPI.orderOco(params); - - const data = await response.data(); - - return { - content: [ - { - type: "text", - text: `OCO order successfully created. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to create OCO order: ${errorMessage}` } - ], - isError: true - }; - } + server.tool( + "BinanceOrderOco", + "Send a new OCO (One-Cancels-the-Other) order on Binance.", + { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Order side: BUY or SELL"), + quantity: z.number().describe("Order quantity"), + price: z.number().describe("Order price"), + stopPrice: z.number().describe("Stop price"), + stopLimitPrice: z.number().optional().describe("Stop limit price"), + stopLimitTimeInForce: z + .enum(["GTC", "IOC", "FOK"]) + .optional() + .describe("Stop limit time in force"), + newClientOrderId: z.string().optional().describe("Client order ID for the limit order"), + stopClientOrderId: z.string().optional().describe("Client order ID for the stop order"), + limitIcebergQty: z.number().optional().describe("Limit iceberg quantity"), + stopIcebergQty: z.number().optional().describe("Stop iceberg quantity"), + }, + async ({ + symbol, + side, + quantity, + price, + stopPrice, + stopLimitPrice, + stopLimitTimeInForce, + newClientOrderId, + stopClientOrderId, + limitIcebergQty, + stopIcebergQty, + }) => { + try { + const params: any = { + symbol, + side, + quantity, + price, + stopPrice, + } + + if (stopLimitPrice !== undefined) params.stopLimitPrice = stopLimitPrice + if (stopLimitTimeInForce) params.stopLimitTimeInForce = stopLimitTimeInForce + if (newClientOrderId) params.newClientOrderId = newClientOrderId + if (stopClientOrderId) params.stopClientOrderId = stopClientOrderId + if (limitIcebergQty !== undefined) params.limitIcebergQty = limitIcebergQty + if (stopIcebergQty !== undefined) params.stopIcebergQty = stopIcebergQty + + const response = await spotClient.restAPI.orderOco(params) + + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `OCO order successfully created. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to create OCO order: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-spot/userdatastream-api/deleteUserDataStream.ts b/src/tools/binance-spot/userdatastream-api/deleteUserDataStream.ts index 7f6001f4..45f9c877 100644 --- a/src/tools/binance-spot/userdatastream-api/deleteUserDataStream.ts +++ b/src/tools/binance-spot/userdatastream-api/deleteUserDataStream.ts @@ -1,40 +1,41 @@ // src/tools/binance-spot/userdatastream-api/deleteUserDataStream.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceDeleteUserDataStream(server: McpServer) { - server.tool( - "BinanceDeleteUserDataStream", - "Close a user data stream by invalidating the listen key.", - { - listenKey: z.string().describe("Listen key to close") - }, - async ({ listenKey }) => { - try { - const response = await spotClient.restAPI.deleteUserDataStream({ - listenKey: listenKey - }); + server.tool( + "BinanceDeleteUserDataStream", + "Close a user data stream by invalidating the listen key.", + { + listenKey: z.string().describe("Listen key to close"), + }, + async ({ listenKey }) => { + try { + const response = await spotClient.restAPI.deleteUserDataStream({ + listenKey: listenKey, + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully closed user data stream with listen key: ${listenKey}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully closed user data stream with listen key: ${listenKey}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to close user data stream: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to close user data stream: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-spot/userdatastream-api/index.ts b/src/tools/binance-spot/userdatastream-api/index.ts index f6e3f61c..a321fb5d 100644 --- a/src/tools/binance-spot/userdatastream-api/index.ts +++ b/src/tools/binance-spot/userdatastream-api/index.ts @@ -1,12 +1,12 @@ // src/tools/binance-spot/userdatastream-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceNewUserDataStream } from "./newUserDataStream.js"; -import { registerBinanceDeleteUserDataStream } from "./deleteUserDataStream.js"; -import { registerBinancePutUserDataStream } from "./putUserDataStream.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceDeleteUserDataStream } from "./deleteUserDataStream.js" +import { registerBinanceNewUserDataStream } from "./newUserDataStream.js" +import { registerBinancePutUserDataStream } from "./putUserDataStream.js" export function registerBinanceUserDataStreamApiTools(server: McpServer) { - registerBinanceNewUserDataStream(server); - registerBinanceDeleteUserDataStream(server); - registerBinancePutUserDataStream(server); - + registerBinanceNewUserDataStream(server) + registerBinanceDeleteUserDataStream(server) + registerBinancePutUserDataStream(server) } diff --git a/src/tools/binance-spot/userdatastream-api/newUserDataStream.ts b/src/tools/binance-spot/userdatastream-api/newUserDataStream.ts index 767167dd..e01448e8 100644 --- a/src/tools/binance-spot/userdatastream-api/newUserDataStream.ts +++ b/src/tools/binance-spot/userdatastream-api/newUserDataStream.ts @@ -1,36 +1,35 @@ // src/tools/binance-spot/userdatastream-api/newUserDataStream.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceNewUserDataStream(server: McpServer) { - server.tool( - "BinanceNewUserDataStream", - "Create a new user data stream to receive account updates via WebSocket.", - {}, - async () => { - try { - const response = await spotClient.restAPI.newUserDataStream(); + server.tool( + "BinanceNewUserDataStream", + "Create a new user data stream to receive account updates via WebSocket.", + {}, + async () => { + try { + const response = await spotClient.restAPI.newUserDataStream() + + const data = await response.data() - const data = await response.data(); + return { + content: [ + { + type: "text", + text: `Created new listen key for user data stream. Listen key: ${data.listenKey}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Created new listen key for user data stream. Listen key: ${data.listenKey}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to create user data stream: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to create user data stream: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-spot/userdatastream-api/putUserDataStream.ts b/src/tools/binance-spot/userdatastream-api/putUserDataStream.ts index 4e05e565..4f054acd 100644 --- a/src/tools/binance-spot/userdatastream-api/putUserDataStream.ts +++ b/src/tools/binance-spot/userdatastream-api/putUserDataStream.ts @@ -1,40 +1,43 @@ // src/tools/binance-spot/userdatastream-api/putUserDataStream.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinancePutUserDataStream(server: McpServer) { - server.tool( - "BinancePutUserDataStream", - "Extend the validity of a user data stream listen key.", - { - listenKey: z.string().describe("Listen key to keep alive") - }, - async ({ listenKey }) => { - try { - const response = await spotClient.restAPI.putUserDataStream({ - listenKey: listenKey - }); + server.tool( + "BinancePutUserDataStream", + "Extend the validity of a user data stream listen key.", + { + listenKey: z.string().describe("Listen key to keep alive"), + }, + async ({ listenKey }) => { + try { + const response = await spotClient.restAPI.putUserDataStream({ + listenKey: listenKey, + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully extended validity of listen key: ${listenKey}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully extended validity of listen key: ${listenKey}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to extend listen key validity: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to extend listen key validity: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-staking/ETH-staking-api/ethStakingAccount.ts b/src/tools/binance-staking/ETH-staking-api/ethStakingAccount.ts index aeff9941..f2c6820f 100644 --- a/src/tools/binance-staking/ETH-staking-api/ethStakingAccount.ts +++ b/src/tools/binance-staking/ETH-staking-api/ethStakingAccount.ts @@ -1,45 +1,48 @@ // src/tools/binance-staking/ETH-staking-api/ethStakingAccount.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceEthStakingAccount(server: McpServer) { - server.tool( - "BinanceEthStakingAccount", - "ETH Staking Account API allows users to retrieve their current ETH staking holdings and 30-day profit details, including amounts from WBETH and BETH", - { - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.ethStakingAccount({ - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceEthStakingAccount", + "ETH Staking Account API allows users to retrieve their current ETH staking holdings and 30-day profit details, including amounts from WBETH and BETH", + { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.ethStakingAccount({ + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved current ETH staking holdings . Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved current ETH staking holdings . Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve ETH staking holdings . ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve ETH staking holdings . ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-staking/ETH-staking-api/getCurrentEthStakingQuota.ts b/src/tools/binance-staking/ETH-staking-api/getCurrentEthStakingQuota.ts index ed542bda..f64b1532 100644 --- a/src/tools/binance-staking/ETH-staking-api/getCurrentEthStakingQuota.ts +++ b/src/tools/binance-staking/ETH-staking-api/getCurrentEthStakingQuota.ts @@ -1,45 +1,48 @@ // src/tools/binance-staking/ETH-staking-api/getCurrentEthStakingQuota.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceGetCurrentEthStakingQuota(server: McpServer) { - server.tool( - "BinanceGetCurrentEthStakingQuota", - "Get Current ETH Staking Quota API allows users to retrieve their available ETH staking and redemption quotas, reflecting personal and daily limits.", - { - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.getCurrentEthStakingQuota({ - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetCurrentEthStakingQuota", + "Get Current ETH Staking Quota API allows users to retrieve their available ETH staking and redemption quotas, reflecting personal and daily limits.", + { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.getCurrentEthStakingQuota({ + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved current ETH Staking Quota API allows users. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved current ETH Staking Quota API allows users. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve current ETH Staking Quota API allows users. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve current ETH Staking Quota API allows users. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-staking/ETH-staking-api/getEthRedemptionHistory.ts b/src/tools/binance-staking/ETH-staking-api/getEthRedemptionHistory.ts index 4f86c09c..4e47b3ee 100644 --- a/src/tools/binance-staking/ETH-staking-api/getEthRedemptionHistory.ts +++ b/src/tools/binance-staking/ETH-staking-api/getEthRedemptionHistory.ts @@ -1,66 +1,77 @@ // src/tools/binance-staking/ETH-staking-api/getEthRedemptionHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceGetEthRedemptionHistory(server: McpServer) { - server.tool( - "BinanceGetEthRedemptionHistory", - "Get ETH Redemption History API allows users to retrieve their historical ETH staking redemption records, including details like asset type, amount, status, and time of redemption.", - { - startTime: z.number().int().optional().describe("Start time in milliseconds (e.g., 1641522717552)"), - endTime: z.number().int().optional().describe("End time in milliseconds (e.g., 1641522526562)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page, start from 1. Default is 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page, Default is 10, Max is 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.getCurrentEthStakingQuota({ - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - ...(params.startTime !== undefined && { startTime: params.startTime }), - ...(params.endTime !== undefined && { endTime: params.endTime }), - ...(params.current !== undefined && { current: params.current }), - ...(params.size !== undefined && { size: params.size }) - }); + server.tool( + "BinanceGetEthRedemptionHistory", + "Get ETH Redemption History API allows users to retrieve their historical ETH staking redemption records, including details like asset type, amount, status, and time of redemption.", + { + startTime: z + .number() + .int() + .optional() + .describe("Start time in milliseconds (e.g., 1641522717552)"), + endTime: z + .number() + .int() + .optional() + .describe("End time in milliseconds (e.g., 1641522526562)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page, start from 1. Default is 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page, Default is 10, Max is 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.getCurrentEthStakingQuota({ + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + ...(params.startTime !== undefined && { startTime: params.startTime }), + ...(params.endTime !== undefined && { endTime: params.endTime }), + ...(params.current !== undefined && { current: params.current }), + ...(params.size !== undefined && { size: params.size }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved history API allows users to retrieve their historical ETH staking redemption records. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved history API allows users to retrieve their historical ETH staking redemption records. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve history API allows users to retrieve their historical ETH staking redemption records. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve history API allows users to retrieve their historical ETH staking redemption records. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-staking/ETH-staking-api/getEthStakingHistory.ts b/src/tools/binance-staking/ETH-staking-api/getEthStakingHistory.ts index e93d94d9..80d93ebb 100644 --- a/src/tools/binance-staking/ETH-staking-api/getEthStakingHistory.ts +++ b/src/tools/binance-staking/ETH-staking-api/getEthStakingHistory.ts @@ -1,66 +1,77 @@ // src/tools/binance-staking/ETH-staking-api/getEthStakingHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceGetEthStakingHistory(server: McpServer) { - server.tool( - "registerBinanceGetEthStakingHistory", - "Get ETH Staking History API allows users to retrieve their historical ETH staking records, including details like asset type, amount, status, and time of staking", - { - startTime: z.number().int().optional().describe("Start time in milliseconds (e.g., 1641522717552)"), - endTime: z.number().int().optional().describe("End time in milliseconds (e.g., 1641522526562)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default is 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default is 10, Max is 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.getEthStakingHistory({ - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - ...(params.startTime !== undefined && { startTime: params.startTime }), - ...(params.endTime !== undefined && { endTime: params.endTime }), - ...(params.current !== undefined && { current: params.current }), - ...(params.size !== undefined && { size: params.size }) - }); + server.tool( + "registerBinanceGetEthStakingHistory", + "Get ETH Staking History API allows users to retrieve their historical ETH staking records, including details like asset type, amount, status, and time of staking", + { + startTime: z + .number() + .int() + .optional() + .describe("Start time in milliseconds (e.g., 1641522717552)"), + endTime: z + .number() + .int() + .optional() + .describe("End time in milliseconds (e.g., 1641522526562)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default is 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default is 10, Max is 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.getEthStakingHistory({ + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + ...(params.startTime !== undefined && { startTime: params.startTime }), + ...(params.endTime !== undefined && { endTime: params.endTime }), + ...(params.current !== undefined && { current: params.current }), + ...(params.size !== undefined && { size: params.size }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved ETH Staking History API allows users to retrieve their historical ETH staking records. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved ETH Staking History API allows users to retrieve their historical ETH staking records. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve ETH Staking History API allows users to retrieve their historical ETH staking records. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve ETH Staking History API allows users to retrieve their historical ETH staking records. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-staking/ETH-staking-api/getWbethRateHistory.ts b/src/tools/binance-staking/ETH-staking-api/getWbethRateHistory.ts index d54febd0..a9c69bef 100644 --- a/src/tools/binance-staking/ETH-staking-api/getWbethRateHistory.ts +++ b/src/tools/binance-staking/ETH-staking-api/getWbethRateHistory.ts @@ -1,67 +1,74 @@ // src/tools/binance-staking/ETH-staking-api/getWbethRateHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceGetWbethRateHistory(server: McpServer) { - server.tool( - "BinanceGetWbethRateHistory", - "Get WBETH Rate History API allows users to retrieve historical WBETH exchange rates and BETH annual percentage rates (APR) within a specified time range.", - { - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Starts from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), + server.tool( + "BinanceGetWbethRateHistory", + "Get WBETH Rate History API allows users to retrieve historical WBETH exchange rates and BETH annual percentage rates (APR) within a specified time range.", + { + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Starts from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity (in milliseconds)") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.getWbethRateHistory({ - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - ...(params.startTime !== undefined && { startTime: params.startTime }), - ...(params.endTime !== undefined && { endTime: params.endTime }), - ...(params.current !== undefined && { current: params.current }), - ...(params.size !== undefined && { size: params.size }) - }); + recvWindow: z + .number() + .int() + .optional() + .describe("Time window for request validity (in milliseconds)"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.getWbethRateHistory({ + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + ...(params.startTime !== undefined && { startTime: params.startTime }), + ...(params.endTime !== undefined && { endTime: params.endTime }), + ...(params.current !== undefined && { current: params.current }), + ...(params.size !== undefined && { size: params.size }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved historical WBETH exchange rates and BETH annual percentage rates. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved historical WBETH exchange rates and BETH annual percentage rates. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve historical WBETH exchange rates and BETH annual percentage rates. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve historical WBETH exchange rates and BETH annual percentage rates. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-staking/ETH-staking-api/getWbethRewardsHistory.ts b/src/tools/binance-staking/ETH-staking-api/getWbethRewardsHistory.ts index e0c06400..79a83b5a 100644 --- a/src/tools/binance-staking/ETH-staking-api/getWbethRewardsHistory.ts +++ b/src/tools/binance-staking/ETH-staking-api/getWbethRewardsHistory.ts @@ -1,66 +1,77 @@ // src/tools/binance-staking/ETH-staking-api/getWbethRewardsHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceGetWbethRewardsHistory(server: McpServer) { - server.tool( - "BinanceGetWbethRewardsHistory", - "Get WBETH Rewards History API allows users to retrieve historical reward data earned from WBETH holdings, including estimated rewards in ETH, holding amounts, and APR details.", - { - startTime: z.number().int().optional().describe("Start time in milliseconds (e.g., 1641522717552)"), - endTime: z.number().int().optional().describe("End time in milliseconds (e.g., 1641522720000)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.getWbethRewardsHistory({ - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - ...(params.startTime !== undefined && { startTime: params.startTime }), - ...(params.endTime !== undefined && { endTime: params.endTime }), - ...(params.current !== undefined && { current: params.current }), - ...(params.size !== undefined && { size: params.size }) - }); + server.tool( + "BinanceGetWbethRewardsHistory", + "Get WBETH Rewards History API allows users to retrieve historical reward data earned from WBETH holdings, including estimated rewards in ETH, holding amounts, and APR details.", + { + startTime: z + .number() + .int() + .optional() + .describe("Start time in milliseconds (e.g., 1641522717552)"), + endTime: z + .number() + .int() + .optional() + .describe("End time in milliseconds (e.g., 1641522720000)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.getWbethRewardsHistory({ + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + ...(params.startTime !== undefined && { startTime: params.startTime }), + ...(params.endTime !== undefined && { endTime: params.endTime }), + ...(params.current !== undefined && { current: params.current }), + ...(params.size !== undefined && { size: params.size }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved historical reward data earned from WBETH holdings. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved historical reward data earned from WBETH holdings. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve historical reward data earned from WBETH holdings. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve historical reward data earned from WBETH holdings. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-staking/ETH-staking-api/getWbethUnwrapHistory.ts b/src/tools/binance-staking/ETH-staking-api/getWbethUnwrapHistory.ts index 9167ac06..7bdf1f01 100644 --- a/src/tools/binance-staking/ETH-staking-api/getWbethUnwrapHistory.ts +++ b/src/tools/binance-staking/ETH-staking-api/getWbethUnwrapHistory.ts @@ -1,66 +1,73 @@ // src/tools/binance-staking/ETH-staking-api/getWbethUnwrapHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceGetWbethUnwrapHistory(server: McpServer) { - server.tool( - "BinanceGetWbethUnwrapHistory", - "Get WBETH Unwrap History API allows users to retrieve historical records of WBETH unwrap operations, including asset conversion details, exchange rates, and transaction status.", - { - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity (in milliseconds)") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.getWbethUnwrapHistory({ - ...(params.startTime !== undefined && { startTime: params.startTime }), - ...(params.endTime !== undefined && { endTime: params.endTime }), - ...(params.current !== undefined && { current: params.current }), - ...(params.size !== undefined && { size: params.size }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetWbethUnwrapHistory", + "Get WBETH Unwrap History API allows users to retrieve historical records of WBETH unwrap operations, including asset conversion details, exchange rates, and transaction status.", + { + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z + .number() + .int() + .optional() + .describe("Time window for request validity (in milliseconds)"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.getWbethUnwrapHistory({ + ...(params.startTime !== undefined && { startTime: params.startTime }), + ...(params.endTime !== undefined && { endTime: params.endTime }), + ...(params.current !== undefined && { current: params.current }), + ...(params.size !== undefined && { size: params.size }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved historical records of WBETH unwrap operations. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved historical records of WBETH unwrap operations. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve historical records of WBETH unwrap operations. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve historical records of WBETH unwrap operations. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-staking/ETH-staking-api/getWbethWrapHistory.ts b/src/tools/binance-staking/ETH-staking-api/getWbethWrapHistory.ts index e6295b81..0901f741 100644 --- a/src/tools/binance-staking/ETH-staking-api/getWbethWrapHistory.ts +++ b/src/tools/binance-staking/ETH-staking-api/getWbethWrapHistory.ts @@ -1,66 +1,69 @@ // src/tools/binance-staking/ETH-staking-api/getWbethWrapHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceGetWbethWrapHistory(server: McpServer) { - server.tool( - "BinanceGetWbethWrapHistory", - "Get WBETH Wrap History API allows users to retrieve historical records of WBETH wrap operations, including asset conversion details, exchange rates, and transaction status.", - { - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.getWbethWrapHistory({ - ...(params.startTime !== undefined && { startTime: params.startTime }), - ...(params.endTime !== undefined && { endTime: params.endTime }), - ...(params.current !== undefined && { current: params.current }), - ...(params.size !== undefined && { size: params.size }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetWbethWrapHistory", + "Get WBETH Wrap History API allows users to retrieve historical records of WBETH wrap operations, including asset conversion details, exchange rates, and transaction status.", + { + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.getWbethWrapHistory({ + ...(params.startTime !== undefined && { startTime: params.startTime }), + ...(params.endTime !== undefined && { endTime: params.endTime }), + ...(params.current !== undefined && { current: params.current }), + ...(params.size !== undefined && { size: params.size }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved historical records of WBETH wrap operations. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved historical records of WBETH wrap operations. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve historical records of WBETH wrap operations. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve historical records of WBETH wrap operations. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-staking/ETH-staking-api/index.ts b/src/tools/binance-staking/ETH-staking-api/index.ts index f2641ade..ce933182 100644 --- a/src/tools/binance-staking/ETH-staking-api/index.ts +++ b/src/tools/binance-staking/ETH-staking-api/index.ts @@ -1,27 +1,28 @@ // src/tools/binance-staking/ETH-staking-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceEthStakingAccount } from "./ethStakingAccount.js"; -import { registerBinanceGetCurrentEthStakingQuota } from "./getCurrentEthStakingQuota.js"; -import { registerBinanceGetEthRedemptionHistory } from "./getEthRedemptionHistory.js"; -import { registerBinanceGetEthStakingHistory } from "./getEthStakingHistory.js"; -import { registerBinanceGetWbethRateHistory } from "./getWbethRateHistory.js"; -import { registerBinanceGetWbethRewardsHistory } from "./getWbethRewardsHistory.js"; -import { registerBinanceGetWbethUnwrapHistory } from "./getWbethUnwrapHistory.js"; -import { registerBinanceGetWbethWrapHistory } from "./getWbethWrapHistory.js"; -import { registerBinanceRedeemEth } from "./redeemEth.js"; -import { registerBinanceSubscribeEthStaking } from "./subscribeEthStaking.js"; -import { registerBinanceWrapBeth } from "./wrapBeth.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceEthStakingAccount } from "./ethStakingAccount.js" +import { registerBinanceGetCurrentEthStakingQuota } from "./getCurrentEthStakingQuota.js" +import { registerBinanceGetEthRedemptionHistory } from "./getEthRedemptionHistory.js" +import { registerBinanceGetEthStakingHistory } from "./getEthStakingHistory.js" +import { registerBinanceGetWbethRateHistory } from "./getWbethRateHistory.js" +import { registerBinanceGetWbethRewardsHistory } from "./getWbethRewardsHistory.js" +import { registerBinanceGetWbethUnwrapHistory } from "./getWbethUnwrapHistory.js" +import { registerBinanceGetWbethWrapHistory } from "./getWbethWrapHistory.js" +import { registerBinanceRedeemEth } from "./redeemEth.js" +import { registerBinanceSubscribeEthStaking } from "./subscribeEthStaking.js" +import { registerBinanceWrapBeth } from "./wrapBeth.js" export function registerBinanceETHStakingApiTools(server: McpServer) { - registerBinanceEthStakingAccount(server); - registerBinanceGetCurrentEthStakingQuota(server); - registerBinanceGetEthRedemptionHistory(server); - registerBinanceGetEthStakingHistory(server); - registerBinanceGetWbethRateHistory(server); - registerBinanceGetWbethRewardsHistory(server); - registerBinanceGetWbethUnwrapHistory(server); - registerBinanceGetWbethWrapHistory(server); - registerBinanceRedeemEth(server); - registerBinanceSubscribeEthStaking(server); - registerBinanceWrapBeth(server); + registerBinanceEthStakingAccount(server) + registerBinanceGetCurrentEthStakingQuota(server) + registerBinanceGetEthRedemptionHistory(server) + registerBinanceGetEthStakingHistory(server) + registerBinanceGetWbethRateHistory(server) + registerBinanceGetWbethRewardsHistory(server) + registerBinanceGetWbethUnwrapHistory(server) + registerBinanceGetWbethWrapHistory(server) + registerBinanceRedeemEth(server) + registerBinanceSubscribeEthStaking(server) + registerBinanceWrapBeth(server) } diff --git a/src/tools/binance-staking/ETH-staking-api/redeemEth.ts b/src/tools/binance-staking/ETH-staking-api/redeemEth.ts index 20dc7b60..33fc2e31 100644 --- a/src/tools/binance-staking/ETH-staking-api/redeemEth.ts +++ b/src/tools/binance-staking/ETH-staking-api/redeemEth.ts @@ -1,47 +1,54 @@ // src/tools/binance-staking/ETH-staking-api/redeemEth.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceRedeemEth(server: McpServer) { - server.tool( - "BinanceRedeemEth", - "Redeem ETH API allows users to redeem WBETH or BETH for ETH, providing the amount, conversion ratio, and arrival time details.", - { - amount: z.number().min(0).describe("Amount in BETH, limit 8 decimals (mandatory)"), - asset: z.string().optional().default("BETH").describe("Asset type, either WBETH or BETH. Default: BETH"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.redeemEth({ - amount: params.amount, - asset: params.asset, - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceRedeemEth", + "Redeem ETH API allows users to redeem WBETH or BETH for ETH, providing the amount, conversion ratio, and arrival time details.", + { + amount: z.number().min(0).describe("Amount in BETH, limit 8 decimals (mandatory)"), + asset: z + .string() + .optional() + .default("BETH") + .describe("Asset type, either WBETH or BETH. Default: BETH"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.redeemEth({ + amount: params.amount, + asset: params.asset, + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully redeemed WBETH or BETH for ETH. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully redeemed WBETH or BETH for ETH. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to redeem WBETH or BETH for ETH. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to redeem WBETH or BETH for ETH. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-staking/ETH-staking-api/subscribeEthStaking.ts b/src/tools/binance-staking/ETH-staking-api/subscribeEthStaking.ts index b10e1946..f288528d 100644 --- a/src/tools/binance-staking/ETH-staking-api/subscribeEthStaking.ts +++ b/src/tools/binance-staking/ETH-staking-api/subscribeEthStaking.ts @@ -1,45 +1,48 @@ // src/tools/binance-staking/ETH-staking-api/subscribeEthStaking.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceSubscribeEthStaking(server: McpServer) { - server.tool( - "BinanceSubscribeEthStaking", - "Subscribe ETH Staking API allows users to stake ETH and receive WBETH, providing the staked amount and the conversion ratio for ETH to WBETH.", - { - amount: z.number().min(0).describe("Amount in BETH, limit 4 decimals (mandatory)"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.subscribeEthStaking({ - amount: params.amount, - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSubscribeEthStaking", + "Subscribe ETH Staking API allows users to stake ETH and receive WBETH, providing the staked amount and the conversion ratio for ETH to WBETH.", + { + amount: z.number().min(0).describe("Amount in BETH, limit 4 decimals (mandatory)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.subscribeEthStaking({ + amount: params.amount, + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully staked ETH and receive WBETH. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully staked ETH and receive WBETH. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to stake ETH and receive WBETH. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to stake ETH and receive WBETH. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-staking/ETH-staking-api/wrapBeth.ts b/src/tools/binance-staking/ETH-staking-api/wrapBeth.ts index c753711a..01845a0c 100644 --- a/src/tools/binance-staking/ETH-staking-api/wrapBeth.ts +++ b/src/tools/binance-staking/ETH-staking-api/wrapBeth.ts @@ -1,45 +1,48 @@ // src/tools/binance-staking/ETHStaking-api/wrapBeth.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceWrapBeth(server: McpServer) { - server.tool( - "BinanceWrapBeth", - "Wrap BETH API allows users to convert BETH into WBETH, providing the wrapped WBETH amount and the exchange rate from BETH to WBETH.", - { - amount: z.number().min(0).describe("Amount in BETH, limit 4 decimals (mandatory)"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.wrapBeth({ - amount: params.amount, - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceWrapBeth", + "Wrap BETH API allows users to convert BETH into WBETH, providing the wrapped WBETH amount and the exchange rate from BETH to WBETH.", + { + amount: z.number().min(0).describe("Amount in BETH, limit 4 decimals (mandatory)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.wrapBeth({ + amount: params.amount, + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully convert BETH into WBETH. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully convert BETH into WBETH. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to convert BETH into WBETH. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to convert BETH into WBETH. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-staking/SOL-staking-api/claimBoostRewards.ts b/src/tools/binance-staking/SOL-staking-api/claimBoostRewards.ts index fbb1eaaf..2cb0f0d9 100644 --- a/src/tools/binance-staking/SOL-staking-api/claimBoostRewards.ts +++ b/src/tools/binance-staking/SOL-staking-api/claimBoostRewards.ts @@ -1,45 +1,48 @@ // src/tools/binance-staking/SOL-staking-api/claimBoostRewards.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceClaimBoostRewards(server: McpServer) { - server.tool( - "BinanceClaimBoostRewards", - "Claim Boost Rewards API allows users to claim their Boost APR airdrop rewards for staking.", - { - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.claimBoostRewards({ - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceClaimBoostRewards", + "Claim Boost Rewards API allows users to claim their Boost APR airdrop rewards for staking.", + { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.claimBoostRewards({ + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully claim Boost APR airdrop rewards for staking. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully claim Boost APR airdrop rewards for staking. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to claim Boost APR airdrop rewards. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to claim Boost APR airdrop rewards. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-staking/SOL-staking-api/getBnsolRateHistory.ts b/src/tools/binance-staking/SOL-staking-api/getBnsolRateHistory.ts index 8d3c5a97..7ee8fbc6 100644 --- a/src/tools/binance-staking/SOL-staking-api/getBnsolRateHistory.ts +++ b/src/tools/binance-staking/SOL-staking-api/getBnsolRateHistory.ts @@ -1,66 +1,69 @@ // src/tools/binance-staking/SOL-staking-api/getBnsolRateHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceGetBnsolRateHistory(server: McpServer) { - server.tool( - "registerBinanceGetBnsolRateHistory", - " Get BNSOL Rate History API allows users to retrieve the historical data of the BNSOL staking rate, including APR and exchange rates for SOL to BNSOL.", - { - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.getBnsolRateHistory({ - ...(params.startTime !== undefined && { startTime: params.startTime }), - ...(params.endTime !== undefined && { endTime: params.endTime }), - ...(params.current !== undefined && { current: params.current }), - ...(params.size !== undefined && { size: params.size }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "registerBinanceGetBnsolRateHistory", + " Get BNSOL Rate History API allows users to retrieve the historical data of the BNSOL staking rate, including APR and exchange rates for SOL to BNSOL.", + { + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.getBnsolRateHistory({ + ...(params.startTime !== undefined && { startTime: params.startTime }), + ...(params.endTime !== undefined && { endTime: params.endTime }), + ...(params.current !== undefined && { current: params.current }), + ...(params.size !== undefined && { size: params.size }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved the historical data of the BNSOL staking rate. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved the historical data of the BNSOL staking rate. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve the historical data of the BNSOL staking rate. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve the historical data of the BNSOL staking rate. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-staking/SOL-staking-api/getBnsolRewardsHistory.ts b/src/tools/binance-staking/SOL-staking-api/getBnsolRewardsHistory.ts index 360311b2..277f7189 100644 --- a/src/tools/binance-staking/SOL-staking-api/getBnsolRewardsHistory.ts +++ b/src/tools/binance-staking/SOL-staking-api/getBnsolRewardsHistory.ts @@ -1,71 +1,74 @@ // src/tools/binance-staking/SOL-staking-api/getBnsolRewardsHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceGetBnsolRewardsHistory(server: McpServer) { - server.tool( - "BinanceGetBnsolRewardsHistory", - "Get Boost Rewards History API allows users to retrieve their historical boost rewards data for staking, including the amount of rewards, token type (e.g., SOL), and status of the rewards (e.g., CLAIM, DISTRIBUTE).", - { - type: z - .enum(["CLAIM", "DISTRIBUTE"]) - .default("CLAIM") - .describe('Type of action. Must be "CLAIM" or "DISTRIBUTE". Default: "CLAIM"'), - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.getBnsolRewardsHistory({ - ...(params.startTime !== undefined && { startTime: params.startTime }), - ...(params.endTime !== undefined && { endTime: params.endTime }), - ...(params.current !== undefined && { current: params.current }), - ...(params.size !== undefined && { size: params.size }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - ...(params.type && { type: params.type }) - }); + server.tool( + "BinanceGetBnsolRewardsHistory", + "Get Boost Rewards History API allows users to retrieve their historical boost rewards data for staking, including the amount of rewards, token type (e.g., SOL), and status of the rewards (e.g., CLAIM, DISTRIBUTE).", + { + type: z + .enum(["CLAIM", "DISTRIBUTE"]) + .default("CLAIM") + .describe('Type of action. Must be "CLAIM" or "DISTRIBUTE". Default: "CLAIM"'), + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.getBnsolRewardsHistory({ + ...(params.startTime !== undefined && { startTime: params.startTime }), + ...(params.endTime !== undefined && { endTime: params.endTime }), + ...(params.current !== undefined && { current: params.current }), + ...(params.size !== undefined && { size: params.size }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + ...(params.type && { type: params.type }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved historical boost rewards data for staking. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved historical boost rewards data for staking. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve historical boost rewards data for staking. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve historical boost rewards data for staking. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-staking/SOL-staking-api/getBoostRewardsHistory.ts b/src/tools/binance-staking/SOL-staking-api/getBoostRewardsHistory.ts index 790b2f0e..b4659629 100644 --- a/src/tools/binance-staking/SOL-staking-api/getBoostRewardsHistory.ts +++ b/src/tools/binance-staking/SOL-staking-api/getBoostRewardsHistory.ts @@ -1,70 +1,73 @@ // src/tools/binance-staking/SOL-staking-api/getBoostRewardsHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceGetBoostRewardsHistory(server: McpServer) { - server.tool( - "BinanceGetBoostRewardsHistory", - "Get Boost Rewards History API allows users to retrieve their boost rewards history for staking activities. This includes the amount of rewards received, the token type (e.g., SOL), and the status of the rewards (e.g., CLAIM or DISTRIBUTE).", - { - type: z - .enum(["CLAIM", "DISTRIBUTE"]) - .default("CLAIM") - .describe('Type of action. Must be "CLAIM" or "DISTRIBUTE". Default: "CLAIM"'), - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.getBoostRewardsHistory({ - type: params.type, - ...(params.startTime !== undefined && { startTime: params.startTime }), - ...(params.endTime !== undefined && { endTime: params.endTime }), - ...(params.current !== undefined && { current: params.current }), - ...(params.size !== undefined && { size: params.size }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); + server.tool( + "BinanceGetBoostRewardsHistory", + "Get Boost Rewards History API allows users to retrieve their boost rewards history for staking activities. This includes the amount of rewards received, the token type (e.g., SOL), and the status of the rewards (e.g., CLAIM or DISTRIBUTE).", + { + type: z + .enum(["CLAIM", "DISTRIBUTE"]) + .default("CLAIM") + .describe('Type of action. Must be "CLAIM" or "DISTRIBUTE". Default: "CLAIM"'), + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.getBoostRewardsHistory({ + type: params.type, + ...(params.startTime !== undefined && { startTime: params.startTime }), + ...(params.endTime !== undefined && { endTime: params.endTime }), + ...(params.current !== undefined && { current: params.current }), + ...(params.size !== undefined && { size: params.size }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved boost rewards history for staking activities. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved boost rewards history for staking activities. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve boost rewards history for staking activities. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve boost rewards history for staking activities. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-staking/SOL-staking-api/getSolRedemptionHistory.ts b/src/tools/binance-staking/SOL-staking-api/getSolRedemptionHistory.ts index 009a340c..03e91757 100644 --- a/src/tools/binance-staking/SOL-staking-api/getSolRedemptionHistory.ts +++ b/src/tools/binance-staking/SOL-staking-api/getSolRedemptionHistory.ts @@ -1,64 +1,67 @@ // src/tools/binance-staking/SOL-staking-api/getSolRedemptionHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceGetSolRedemptionHistory(server: McpServer) { - server.tool( - "BinanceGetSolRedemptionHistory", - "Get SOL Redemption History API allows users to retrieve their SOL redemption history, detailing the amount of BNSOL redeemed for SOL and the exchange rate.", - { - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.getSolRedemptionHistory({ - ...(params.startTime !== undefined && { startTime: params.startTime }), - ...(params.endTime !== undefined && { endTime: params.endTime }), - ...(params.current !== undefined && { current: params.current }), - ...(params.size !== undefined && { size: params.size }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetSolRedemptionHistory", + "Get SOL Redemption History API allows users to retrieve their SOL redemption history, detailing the amount of BNSOL redeemed for SOL and the exchange rate.", + { + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.getSolRedemptionHistory({ + ...(params.startTime !== undefined && { startTime: params.startTime }), + ...(params.endTime !== undefined && { endTime: params.endTime }), + ...(params.current !== undefined && { current: params.current }), + ...(params.size !== undefined && { size: params.size }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved SOL redemption history. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved SOL redemption history. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve SOL redemption history. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve SOL redemption history. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-staking/SOL-staking-api/getSolStakingHistory.ts b/src/tools/binance-staking/SOL-staking-api/getSolStakingHistory.ts index cb8f4ec9..e20e2c7c 100644 --- a/src/tools/binance-staking/SOL-staking-api/getSolStakingHistory.ts +++ b/src/tools/binance-staking/SOL-staking-api/getSolStakingHistory.ts @@ -1,64 +1,67 @@ // src/tools/binance-staking/SOL-staking-api/getSolStakingHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceGetSolStakingHistory(server: McpServer) { - server.tool( - "BinanceGetSolStakingHistory", - "Get SOL Staking History API allows users to retrieve their SOL staking history, including details about the amount of SOL staked, the equivalent BNSOL amount distributed, the exchange rate, and the status of each staking.", - { - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.getSolStakingHistory({ - ...(params.startTime !== undefined && { startTime: params.startTime }), - ...(params.endTime !== undefined && { endTime: params.endTime }), - ...(params.current !== undefined && { current: params.current }), - ...(params.size !== undefined && { size: params.size }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetSolStakingHistory", + "Get SOL Staking History API allows users to retrieve their SOL staking history, including details about the amount of SOL staked, the equivalent BNSOL amount distributed, the exchange rate, and the status of each staking.", + { + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.getSolStakingHistory({ + ...(params.startTime !== undefined && { startTime: params.startTime }), + ...(params.endTime !== undefined && { endTime: params.endTime }), + ...(params.current !== undefined && { current: params.current }), + ...(params.size !== undefined && { size: params.size }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved SOL staking history. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved SOL staking history. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve SOL staking history. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve SOL staking history. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-staking/SOL-staking-api/getSolStakingQuotaDetails.ts b/src/tools/binance-staking/SOL-staking-api/getSolStakingQuotaDetails.ts index ce5df6e9..84ed7ce3 100644 --- a/src/tools/binance-staking/SOL-staking-api/getSolStakingQuotaDetails.ts +++ b/src/tools/binance-staking/SOL-staking-api/getSolStakingQuotaDetails.ts @@ -1,43 +1,46 @@ // src/tools/binance-staking/SOL-staking-api/getSolStakingQuotaDetails.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceGetSolStakingQuotaDetails(server: McpServer) { - server.tool( - "getSolStakingQuotaDetails", - "Get SOL Staking Quota API allows users to retrieve their current SOL staking quota, including information such as the remaining staking and redemption limits, minimum staking and redeem amounts, commission fees, and the status of staking and redemption availability.", - { - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.getSolStakingQuotaDetails({ - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "getSolStakingQuotaDetails", + "Get SOL Staking Quota API allows users to retrieve their current SOL staking quota, including information such as the remaining staking and redemption limits, minimum staking and redeem amounts, commission fees, and the status of staking and redemption availability.", + { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.getSolStakingQuotaDetails({ + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved current SOL staking quota. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved current SOL staking quota. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve current SOL staking quota. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve current SOL staking quota. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-staking/SOL-staking-api/getUnclaimedRewards.ts b/src/tools/binance-staking/SOL-staking-api/getUnclaimedRewards.ts index 67bee5c5..93687ff9 100644 --- a/src/tools/binance-staking/SOL-staking-api/getUnclaimedRewards.ts +++ b/src/tools/binance-staking/SOL-staking-api/getUnclaimedRewards.ts @@ -1,45 +1,48 @@ // src/tools/binance-staking/SOL-staking-api/getUnclaimedRewards.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceGetUnclaimedRewards(server: McpServer) { - server.tool( - "BinanceGetUnclaimedRewards", - "Get Unclaimed Rewards API allows users to retrieve information about unclaimed rewards from their SOL staking activities.", - { - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.getUnclaimedRewards({ - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetUnclaimedRewards", + "Get Unclaimed Rewards API allows users to retrieve information about unclaimed rewards from their SOL staking activities.", + { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.getUnclaimedRewards({ + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved information about unclaimed rewards. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved information about unclaimed rewards. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve information about unclaimed rewards. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve information about unclaimed rewards. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-staking/SOL-staking-api/index.ts b/src/tools/binance-staking/SOL-staking-api/index.ts index cd12159d..117dd8e1 100644 --- a/src/tools/binance-staking/SOL-staking-api/index.ts +++ b/src/tools/binance-staking/SOL-staking-api/index.ts @@ -1,27 +1,28 @@ // src/tools/binance-staking/SOL-staking-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceClaimBoostRewards } from "./claimBoostRewards.js"; -import { registerBinanceGetBnsolRateHistory } from "./getBnsolRateHistory.js"; -import { registerBinanceGetBnsolRewardsHistory } from "./getBnsolRewardsHistory.js"; -import { registerBinanceGetBoostRewardsHistory } from "./getBoostRewardsHistory.js"; -import { registerBinanceGetSolRedemptionHistory } from "./getSolRedemptionHistory.js"; -import { registerBinanceGetSolStakingHistory } from "./getSolStakingHistory.js"; -import { registerBinanceGetSolStakingQuotaDetails } from "./getSolStakingQuotaDetails.js"; -import { registerBinanceGetUnclaimedRewards } from "./getUnclaimedRewards.js"; -import { registerBinanceRedeemSol } from "./redeemSol.js"; -import { registerBinanceSolStakingAccount } from "./solStakingAccount.js"; -import { registerBinanceSubscribeSolStaking } from "./subscribeSolStaking.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceClaimBoostRewards } from "./claimBoostRewards.js" +import { registerBinanceGetBnsolRateHistory } from "./getBnsolRateHistory.js" +import { registerBinanceGetBnsolRewardsHistory } from "./getBnsolRewardsHistory.js" +import { registerBinanceGetBoostRewardsHistory } from "./getBoostRewardsHistory.js" +import { registerBinanceGetSolRedemptionHistory } from "./getSolRedemptionHistory.js" +import { registerBinanceGetSolStakingHistory } from "./getSolStakingHistory.js" +import { registerBinanceGetSolStakingQuotaDetails } from "./getSolStakingQuotaDetails.js" +import { registerBinanceGetUnclaimedRewards } from "./getUnclaimedRewards.js" +import { registerBinanceRedeemSol } from "./redeemSol.js" +import { registerBinanceSolStakingAccount } from "./solStakingAccount.js" +import { registerBinanceSubscribeSolStaking } from "./subscribeSolStaking.js" export function registerBinanceSOLStakingApiTools(server: McpServer) { - registerBinanceClaimBoostRewards(server); - registerBinanceGetBnsolRateHistory(server); - registerBinanceGetBnsolRewardsHistory(server); - registerBinanceGetBoostRewardsHistory(server); - registerBinanceGetSolRedemptionHistory(server); - registerBinanceGetSolStakingHistory(server); - registerBinanceGetSolStakingQuotaDetails(server); - registerBinanceGetUnclaimedRewards(server); - registerBinanceRedeemSol(server); - registerBinanceSolStakingAccount(server); - registerBinanceSubscribeSolStaking(server); + registerBinanceClaimBoostRewards(server) + registerBinanceGetBnsolRateHistory(server) + registerBinanceGetBnsolRewardsHistory(server) + registerBinanceGetBoostRewardsHistory(server) + registerBinanceGetSolRedemptionHistory(server) + registerBinanceGetSolStakingHistory(server) + registerBinanceGetSolStakingQuotaDetails(server) + registerBinanceGetUnclaimedRewards(server) + registerBinanceRedeemSol(server) + registerBinanceSolStakingAccount(server) + registerBinanceSubscribeSolStaking(server) } diff --git a/src/tools/binance-staking/SOL-staking-api/redeemSol.ts b/src/tools/binance-staking/SOL-staking-api/redeemSol.ts index fa98b3b1..ef2d7608 100644 --- a/src/tools/binance-staking/SOL-staking-api/redeemSol.ts +++ b/src/tools/binance-staking/SOL-staking-api/redeemSol.ts @@ -1,47 +1,54 @@ // src/tools/binance-staking/SOL-staking-api/getUnclaimedRewards.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceRedeemSol(server: McpServer) { - server.tool( - "registerBinanceRedeemSol", - " Redeem SOL API allows users to redeem BNSOL and receive SOL in exchange. It enables the conversion of BNSOL tokens into SOL based on the specified amount", - { - amount: z.number().min(0).max(99999999).describe("Amount in BNSOL, limit to 8 decimals (mandatory)"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.redeemSol({ - amount: params.amount, - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "registerBinanceRedeemSol", + " Redeem SOL API allows users to redeem BNSOL and receive SOL in exchange. It enables the conversion of BNSOL tokens into SOL based on the specified amount", + { + amount: z + .number() + .min(0) + .max(99999999) + .describe("Amount in BNSOL, limit to 8 decimals (mandatory)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.redeemSol({ + amount: params.amount, + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully redeem BNSOL and receive SOL in exchange. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully redeem BNSOL and receive SOL in exchange. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to redeem BNSOL and receive SOL in exchange. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to redeem BNSOL and receive SOL in exchange. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-staking/SOL-staking-api/solStakingAccount.ts b/src/tools/binance-staking/SOL-staking-api/solStakingAccount.ts index 17506fb6..9674b5e3 100644 --- a/src/tools/binance-staking/SOL-staking-api/solStakingAccount.ts +++ b/src/tools/binance-staking/SOL-staking-api/solStakingAccount.ts @@ -1,43 +1,46 @@ // src/tools/binance-staking/SOL-staking-api/solStakingAccount.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceSolStakingAccount(server: McpServer) { - server.tool( - "registerBinanceSolStakingAccount", - "SOL Staking Account API allows users to view their SOL staking account details, including their current BNSOL holdings, equivalent SOL balance, and the profit in SOL over the past 30 days.", - { - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.solStakingAccount({ - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "registerBinanceSolStakingAccount", + "SOL Staking Account API allows users to view their SOL staking account details, including their current BNSOL holdings, equivalent SOL balance, and the profit in SOL over the past 30 days.", + { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.solStakingAccount({ + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieve SOL staking account details: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieve SOL staking account details: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve SOL staking account details. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve SOL staking account details. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-staking/SOL-staking-api/subscribeSolStaking.ts b/src/tools/binance-staking/SOL-staking-api/subscribeSolStaking.ts index 65fded66..81b31bf7 100644 --- a/src/tools/binance-staking/SOL-staking-api/subscribeSolStaking.ts +++ b/src/tools/binance-staking/SOL-staking-api/subscribeSolStaking.ts @@ -1,45 +1,48 @@ // src/tools/binance-staking/SOL-staking-api/subscribeSolStaking.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { stakingClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { stakingClient } from "../../../config/binanceClient.js" export function registerBinanceSubscribeSolStaking(server: McpServer) { - server.tool( - "BinanceSubscribeSolStaking", - "Subscribe SOL Staking API allows users to stake SOL and receive BNSOL in return. This endpoint requires specifying the amount of SOL to stake, and the response includes the equivalent BNSOL amount and exchange rate for SOL to BNSOL.", - { - amount: z.number().min(0).describe("Amount in SOL (mandatory)"), - recvWindow: z.number().int().optional().describe("Time window for request validity") - }, - async (params) => { - try { - const response = await stakingClient.restAPI.subscribeSolStaking({ - amount: params.amount, - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSubscribeSolStaking", + "Subscribe SOL Staking API allows users to stake SOL and receive BNSOL in return. This endpoint requires specifying the amount of SOL to stake, and the response includes the equivalent BNSOL amount and exchange rate for SOL to BNSOL.", + { + amount: z.number().min(0).describe("Amount in SOL (mandatory)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, + async (params) => { + try { + const response = await stakingClient.restAPI.subscribeSolStaking({ + amount: params.amount, + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully stake SOL and receive BNSOL in return: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully stake SOL and receive BNSOL in return: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to stake SOL. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to stake SOL. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-staking/index.ts b/src/tools/binance-staking/index.ts index 7c594983..3ba3de44 100644 --- a/src/tools/binance-staking/index.ts +++ b/src/tools/binance-staking/index.ts @@ -1,9 +1,10 @@ // src/tools/binance-staking/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceETHStakingApiTools } from "./ETH-staking-api/index.js"; -import { registerBinanceSOLStakingApiTools } from "./SOL-staking-api/index.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceETHStakingApiTools } from "./ETH-staking-api/index.js" +import { registerBinanceSOLStakingApiTools } from "./SOL-staking-api/index.js" export function registerBinanceStakingTools(server: McpServer) { - registerBinanceETHStakingApiTools(server); - registerBinanceSOLStakingApiTools(server); + registerBinanceETHStakingApiTools(server) + registerBinanceSOLStakingApiTools(server) } diff --git a/src/tools/binance-sub-account/assets-api/getFuturesAssetsSummary.ts b/src/tools/binance-sub-account/assets-api/getFuturesAssetsSummary.ts index 736671e7..d3609a42 100644 --- a/src/tools/binance-sub-account/assets-api/getFuturesAssetsSummary.ts +++ b/src/tools/binance-sub-account/assets-api/getFuturesAssetsSummary.ts @@ -5,42 +5,48 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/assets-api/getFuturesAssetsSummary.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { spotClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceSubAccountFuturesSummary(server: McpServer) { - server.tool( - "BinanceSubAccountFuturesSummary", - "Get futures account summary for all sub-accounts. Returns total initial margin, maintenance margin, and unrealized PnL.", - { - futuresType: z.enum(["1", "2"]).optional() - .describe("Futures type: 1 for USD-M, 2 for COIN-M"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await spotClient.restAPI.getSubAccountFuturesAccountSummaryV2({ - ...(params.futuresType && { futuresType: params.futuresType }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSubAccountFuturesSummary", + "Get futures account summary for all sub-accounts. Returns total initial margin, maintenance margin, and unrealized PnL.", + { + futuresType: z + .enum(["1", "2"]) + .optional() + .describe("Futures type: 1 for USD-M, 2 for COIN-M"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await spotClient.restAPI.getSubAccountFuturesAccountSummaryV2({ + ...(params.futuresType && { futuresType: params.futuresType }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Sub-Account Futures Summary:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Sub-Account Futures Summary:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get futures summary: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to get futures summary: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/assets-api/getFuturesPositionRisk.ts b/src/tools/binance-sub-account/assets-api/getFuturesPositionRisk.ts index 6ca56b71..498d079a 100644 --- a/src/tools/binance-sub-account/assets-api/getFuturesPositionRisk.ts +++ b/src/tools/binance-sub-account/assets-api/getFuturesPositionRisk.ts @@ -5,45 +5,50 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/assets-api/getFuturesPositionRisk.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { spotClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceSubAccountFuturesPositionRisk(server: McpServer) { - server.tool( - "BinanceSubAccountFuturesPositionRisk", - "Get futures position risk for a sub-account. Shows all open positions with entry price, leverage, unrealized PnL, and liquidation price.", - { - email: z.string().email() - .describe("Sub-account email to query position risk for"), - futuresType: z.enum(["1", "2"]).optional() - .describe("Futures type: 1 for USD-M, 2 for COIN-M"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await spotClient.restAPI.getSubAccountFuturesPositionRiskV2({ - email: params.email, - ...(params.futuresType && { futuresType: params.futuresType }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSubAccountFuturesPositionRisk", + "Get futures position risk for a sub-account. Shows all open positions with entry price, leverage, unrealized PnL, and liquidation price.", + { + email: z.string().email().describe("Sub-account email to query position risk for"), + futuresType: z + .enum(["1", "2"]) + .optional() + .describe("Futures type: 1 for USD-M, 2 for COIN-M"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await spotClient.restAPI.getSubAccountFuturesPositionRiskV2({ + email: params.email, + ...(params.futuresType && { futuresType: params.futuresType }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Sub-Account Futures Position Risk for ${params.email}:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Sub-Account Futures Position Risk for ${params.email}:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get position risk: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to get position risk: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/assets-api/getMarginAssetsSummary.ts b/src/tools/binance-sub-account/assets-api/getMarginAssetsSummary.ts index 0f7aaa9b..8bde0597 100644 --- a/src/tools/binance-sub-account/assets-api/getMarginAssetsSummary.ts +++ b/src/tools/binance-sub-account/assets-api/getMarginAssetsSummary.ts @@ -5,39 +5,43 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/assets-api/getMarginAssetsSummary.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { spotClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceSubAccountMarginSummary(server: McpServer) { - server.tool( - "BinanceSubAccountMarginSummary", - "Get margin account summary for all sub-accounts. Returns margin level, total assets, and liability information.", - { - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await spotClient.restAPI.getSubAccountMarginAccountSummary({ - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSubAccountMarginSummary", + "Get margin account summary for all sub-accounts. Returns margin level, total assets, and liability information.", + { + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await spotClient.restAPI.getSubAccountMarginAccountSummary({ + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Sub-Account Margin Summary:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Sub-Account Margin Summary:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get margin summary: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to get margin summary: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/assets-api/getSpotAssetsSummary.ts b/src/tools/binance-sub-account/assets-api/getSpotAssetsSummary.ts index c15a3a2d..c6857004 100644 --- a/src/tools/binance-sub-account/assets-api/getSpotAssetsSummary.ts +++ b/src/tools/binance-sub-account/assets-api/getSpotAssetsSummary.ts @@ -5,48 +5,55 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/assets-api/getSpotAssetsSummary.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { spotClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceSubAccountSpotSummary(server: McpServer) { - server.tool( - "BinanceSubAccountSpotSummary", - "Get spot account summary for all sub-accounts. Returns aggregated BTC value of all sub-account spot wallets.", - { - email: z.string().email().optional() - .describe("Filter by specific sub-account email"), - page: z.number().int().min(1).optional() - .describe("Page number (starts from 1)"), - size: z.number().int().min(1).max(20).optional() - .describe("Number of results per page (max 20)"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await spotClient.restAPI.querySubAccountSpotAssetsSummary({ - ...(params.email && { email: params.email }), - ...(params.page && { page: params.page }), - ...(params.size && { size: params.size }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSubAccountSpotSummary", + "Get spot account summary for all sub-accounts. Returns aggregated BTC value of all sub-account spot wallets.", + { + email: z.string().email().optional().describe("Filter by specific sub-account email"), + page: z.number().int().min(1).optional().describe("Page number (starts from 1)"), + size: z + .number() + .int() + .min(1) + .max(20) + .optional() + .describe("Number of results per page (max 20)"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await spotClient.restAPI.querySubAccountSpotAssetsSummary({ + ...(params.email && { email: params.email }), + ...(params.page && { page: params.page }), + ...(params.size && { size: params.size }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Sub-Account Spot Assets Summary:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Sub-Account Spot Assets Summary:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get spot summary: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to get spot summary: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/assets-api/getSubAccountAssets.ts b/src/tools/binance-sub-account/assets-api/getSubAccountAssets.ts index b98d5c16..6d974aeb 100644 --- a/src/tools/binance-sub-account/assets-api/getSubAccountAssets.ts +++ b/src/tools/binance-sub-account/assets-api/getSubAccountAssets.ts @@ -5,42 +5,45 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/assets-api/getSubAccountAssets.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { spotClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceSubAccountAssets(server: McpServer) { - server.tool( - "BinanceSubAccountAssets", - "Get detailed asset balances for a specific sub-account. Shows all tokens and their free/locked amounts.", - { - email: z.string().email() - .describe("Sub-account email to query assets for"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await spotClient.restAPI.querySubAccountAssetsV4({ - email: params.email, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSubAccountAssets", + "Get detailed asset balances for a specific sub-account. Shows all tokens and their free/locked amounts.", + { + email: z.string().email().describe("Sub-account email to query assets for"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await spotClient.restAPI.querySubAccountAssetsV4({ + email: params.email, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Sub-Account Assets for ${params.email}:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Sub-Account Assets for ${params.email}:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get sub-account assets: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to get sub-account assets: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/assets-api/index.ts b/src/tools/binance-sub-account/assets-api/index.ts index d1c426f2..e085ec42 100644 --- a/src/tools/binance-sub-account/assets-api/index.ts +++ b/src/tools/binance-sub-account/assets-api/index.ts @@ -5,17 +5,18 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/assets-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceSubAccountAssets } from "./getSubAccountAssets.js"; -import { registerBinanceSubAccountSpotSummary } from "./getSpotAssetsSummary.js"; -import { registerBinanceSubAccountMarginSummary } from "./getMarginAssetsSummary.js"; -import { registerBinanceSubAccountFuturesSummary } from "./getFuturesAssetsSummary.js"; -import { registerBinanceSubAccountFuturesPositionRisk } from "./getFuturesPositionRisk.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceSubAccountFuturesSummary } from "./getFuturesAssetsSummary.js" +import { registerBinanceSubAccountFuturesPositionRisk } from "./getFuturesPositionRisk.js" +import { registerBinanceSubAccountMarginSummary } from "./getMarginAssetsSummary.js" +import { registerBinanceSubAccountSpotSummary } from "./getSpotAssetsSummary.js" +import { registerBinanceSubAccountAssets } from "./getSubAccountAssets.js" export function registerBinanceSubAccountAssetsTools(server: McpServer) { - registerBinanceSubAccountAssets(server); - registerBinanceSubAccountSpotSummary(server); - registerBinanceSubAccountMarginSummary(server); - registerBinanceSubAccountFuturesSummary(server); - registerBinanceSubAccountFuturesPositionRisk(server); + registerBinanceSubAccountAssets(server) + registerBinanceSubAccountSpotSummary(server) + registerBinanceSubAccountMarginSummary(server) + registerBinanceSubAccountFuturesSummary(server) + registerBinanceSubAccountFuturesPositionRisk(server) } diff --git a/src/tools/binance-sub-account/createApiKey.ts b/src/tools/binance-sub-account/createApiKey.ts index 2c49bc1b..531f4ed6 100644 --- a/src/tools/binance-sub-account/createApiKey.ts +++ b/src/tools/binance-sub-account/createApiKey.ts @@ -1,45 +1,48 @@ // src/tools/binance-sub-account/createApiKey.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { subAccountApiClient } from "../../config/binanceClient.js" export function registerBinanceSubAccountCreateApiKey(server: McpServer) { - server.tool( - "BinanceSubAccountCreateApiKey", - "Create API key for a sub-account.", - { - subAccountId: z.string().describe("Sub-account ID"), - canTrade: z.boolean().describe("Enable spot and margin trading"), - marginTrade: z.boolean().optional().describe("Enable margin loan, repay and transfer"), - futuresTrade: z.boolean().optional().describe("Enable futures trading"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ subAccountId, canTrade, marginTrade, futuresTrade, recvWindow }) => { - try { - const params: any = { subAccountId, canTrade }; - if (marginTrade !== undefined) params.marginTrade = marginTrade; - if (futuresTrade !== undefined) params.futuresTrade = futuresTrade; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await subAccountApiClient.createSubAccountApiKey(params); + server.tool( + "BinanceSubAccountCreateApiKey", + "Create API key for a sub-account.", + { + subAccountId: z.string().describe("Sub-account ID"), + canTrade: z.boolean().describe("Enable spot and margin trading"), + marginTrade: z.boolean().optional().describe("Enable margin loan, repay and transfer"), + futuresTrade: z.boolean().optional().describe("Enable futures trading"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ subAccountId, canTrade, marginTrade, futuresTrade, recvWindow }) => { + try { + const params: any = { subAccountId, canTrade } + if (marginTrade !== undefined) params.marginTrade = marginTrade + if (futuresTrade !== undefined) params.futuresTrade = futuresTrade + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await subAccountApiClient.createSubAccountApiKey(params) + + return { + content: [ + { + type: "text", + text: `API key created for sub-account. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `API key created for sub-account. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to create sub-account API key: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to create sub-account API key: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/createVirtualSubAccount.ts b/src/tools/binance-sub-account/createVirtualSubAccount.ts index c5b6746b..1769b68b 100644 --- a/src/tools/binance-sub-account/createVirtualSubAccount.ts +++ b/src/tools/binance-sub-account/createVirtualSubAccount.ts @@ -1,40 +1,43 @@ // src/tools/binance-sub-account/createVirtualSubAccount.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { subAccountApiClient } from "../../config/binanceClient.js" export function registerBinanceSubAccountCreateVirtual(server: McpServer) { - server.tool( - "BinanceSubAccountCreateVirtual", - "Create a virtual sub-account under the master account. Requires master account API key.", - { - subAccountString: z.string().describe("The email address for the virtual sub-account"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ subAccountString, recvWindow }) => { - try { - const params: any = { subAccountString }; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await subAccountApiClient.createVirtualSubAccount(params); + server.tool( + "BinanceSubAccountCreateVirtual", + "Create a virtual sub-account under the master account. Requires master account API key.", + { + subAccountString: z.string().describe("The email address for the virtual sub-account"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ subAccountString, recvWindow }) => { + try { + const params: any = { subAccountString } + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await subAccountApiClient.createVirtualSubAccount(params) + + return { + content: [ + { + type: "text", + text: `Virtual sub-account created: ${subAccountString}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Virtual sub-account created: ${subAccountString}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to create virtual sub-account: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to create virtual sub-account: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/deleteApiKey.ts b/src/tools/binance-sub-account/deleteApiKey.ts index c14ea3fa..ae2f84de 100644 --- a/src/tools/binance-sub-account/deleteApiKey.ts +++ b/src/tools/binance-sub-account/deleteApiKey.ts @@ -1,41 +1,44 @@ // src/tools/binance-sub-account/deleteApiKey.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { subAccountApiClient } from "../../config/binanceClient.js" export function registerBinanceSubAccountDeleteApiKey(server: McpServer) { - server.tool( - "BinanceSubAccountDeleteApiKey", - "Delete API key for a sub-account.", - { - subAccountId: z.string().describe("Sub-account ID"), - subAccountApiKey: z.string().describe("API key to delete"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ subAccountId, subAccountApiKey, recvWindow }) => { - try { - const params: any = { subAccountId, subAccountApiKey }; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await subAccountApiClient.deleteSubAccountApiKey(params); + server.tool( + "BinanceSubAccountDeleteApiKey", + "Delete API key for a sub-account.", + { + subAccountId: z.string().describe("Sub-account ID"), + subAccountApiKey: z.string().describe("API key to delete"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ subAccountId, subAccountApiKey, recvWindow }) => { + try { + const params: any = { subAccountId, subAccountApiKey } + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await subAccountApiClient.deleteSubAccountApiKey(params) + + return { + content: [ + { + type: "text", + text: `API key deleted for sub-account. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `API key deleted for sub-account. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to delete sub-account API key: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to delete sub-account API key: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/deposit-api/getDepositAddress.ts b/src/tools/binance-sub-account/deposit-api/getDepositAddress.ts index 09ed01a7..186cac5a 100644 --- a/src/tools/binance-sub-account/deposit-api/getDepositAddress.ts +++ b/src/tools/binance-sub-account/deposit-api/getDepositAddress.ts @@ -5,48 +5,49 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/deposit-api/getDepositAddress.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { spotClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceSubAccountDepositAddress(server: McpServer) { - server.tool( - "BinanceSubAccountDepositAddress", - "Get deposit address for a sub-account. Returns the address and tag/memo if required for the specified asset and network.", - { - email: z.string().email() - .describe("Sub-account email to get deposit address for"), - coin: z.string() - .describe("Coin/asset to get deposit address for (e.g., 'BTC', 'ETH')"), - network: z.string().optional() - .describe("Network (e.g., 'BTC', 'ETH', 'TRX', 'BSC')"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await spotClient.restAPI.getSubAccountDepositAddress({ - email: params.email, - coin: params.coin, - ...(params.network && { network: params.network }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSubAccountDepositAddress", + "Get deposit address for a sub-account. Returns the address and tag/memo if required for the specified asset and network.", + { + email: z.string().email().describe("Sub-account email to get deposit address for"), + coin: z.string().describe("Coin/asset to get deposit address for (e.g., 'BTC', 'ETH')"), + network: z.string().optional().describe("Network (e.g., 'BTC', 'ETH', 'TRX', 'BSC')"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await spotClient.restAPI.getSubAccountDepositAddress({ + email: params.email, + coin: params.coin, + ...(params.network && { network: params.network }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Deposit Address for ${params.email}:\n\nCoin: ${params.coin}\nNetwork: ${params.network || "Default"}\nAddress: ${data.address}\n${data.tag ? `Tag/Memo: ${data.tag}` : ""}\n\n⚠️ Always verify the address before sending funds!`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Deposit Address for ${params.email}:\n\nCoin: ${params.coin}\nNetwork: ${params.network || 'Default'}\nAddress: ${data.address}\n${data.tag ? `Tag/Memo: ${data.tag}` : ''}\n\n⚠️ Always verify the address before sending funds!` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get deposit address: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to get deposit address: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/deposit-api/getDepositHistory.ts b/src/tools/binance-sub-account/deposit-api/getDepositHistory.ts index ca80d762..19b4921f 100644 --- a/src/tools/binance-sub-account/deposit-api/getDepositHistory.ts +++ b/src/tools/binance-sub-account/deposit-api/getDepositHistory.ts @@ -5,60 +5,60 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/deposit-api/getDepositHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { spotClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceSubAccountDepositHistory(server: McpServer) { - server.tool( - "BinanceSubAccountDepositHistory", - "Get deposit history for a sub-account. Shows all incoming deposits with status, txid, and confirmation details.", - { - email: z.string().email() - .describe("Sub-account email to get deposit history for"), - coin: z.string().optional() - .describe("Filter by specific coin"), - status: z.enum(["0", "1", "6"]).optional() - .describe("Filter by status: 0 = pending, 1 = success, 6 = credited but cannot withdraw"), - startTime: z.number().int().optional() - .describe("Start timestamp in ms"), - endTime: z.number().int().optional() - .describe("End timestamp in ms"), - limit: z.number().int().min(1).max(1000).optional() - .describe("Number of results (max 1000)"), - offset: z.number().int().optional() - .describe("Offset for pagination"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await spotClient.restAPI.getSubAccountDepositHistory({ - email: params.email, - ...(params.coin && { coin: params.coin }), - ...(params.status && { status: params.status }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.offset && { offset: params.offset }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSubAccountDepositHistory", + "Get deposit history for a sub-account. Shows all incoming deposits with status, txid, and confirmation details.", + { + email: z.string().email().describe("Sub-account email to get deposit history for"), + coin: z.string().optional().describe("Filter by specific coin"), + status: z + .enum(["0", "1", "6"]) + .optional() + .describe("Filter by status: 0 = pending, 1 = success, 6 = credited but cannot withdraw"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + limit: z.number().int().min(1).max(1000).optional().describe("Number of results (max 1000)"), + offset: z.number().int().optional().describe("Offset for pagination"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await spotClient.restAPI.getSubAccountDepositHistory({ + email: params.email, + ...(params.coin && { coin: params.coin }), + ...(params.status && { status: params.status }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.offset && { offset: params.offset }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Sub-Account Deposit History for ${params.email}:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Sub-Account Deposit History for ${params.email}:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get deposit history: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to get deposit history: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/deposit-api/index.ts b/src/tools/binance-sub-account/deposit-api/index.ts index 390a06ce..bea59881 100644 --- a/src/tools/binance-sub-account/deposit-api/index.ts +++ b/src/tools/binance-sub-account/deposit-api/index.ts @@ -5,11 +5,12 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/deposit-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceSubAccountDepositAddress } from "./getDepositAddress.js"; -import { registerBinanceSubAccountDepositHistory } from "./getDepositHistory.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceSubAccountDepositAddress } from "./getDepositAddress.js" +import { registerBinanceSubAccountDepositHistory } from "./getDepositHistory.js" export function registerBinanceSubAccountDepositTools(server: McpServer) { - registerBinanceSubAccountDepositAddress(server); - registerBinanceSubAccountDepositHistory(server); + registerBinanceSubAccountDepositAddress(server) + registerBinanceSubAccountDepositHistory(server) } diff --git a/src/tools/binance-sub-account/enableFutures.ts b/src/tools/binance-sub-account/enableFutures.ts index 11aa84da..8242eaed 100644 --- a/src/tools/binance-sub-account/enableFutures.ts +++ b/src/tools/binance-sub-account/enableFutures.ts @@ -1,40 +1,43 @@ // src/tools/binance-sub-account/enableFutures.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { subAccountApiClient } from "../../config/binanceClient.js" export function registerBinanceSubAccountEnableFutures(server: McpServer) { - server.tool( - "BinanceSubAccountEnableFutures", - "Enable futures trading for a sub-account.", - { - email: z.string().describe("Sub-account email"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ email, recvWindow }) => { - try { - const params: any = { email }; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await subAccountApiClient.enableFuturesForSubAccount(params); + server.tool( + "BinanceSubAccountEnableFutures", + "Enable futures trading for a sub-account.", + { + email: z.string().describe("Sub-account email"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ email, recvWindow }) => { + try { + const params: any = { email } + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await subAccountApiClient.enableFuturesForSubAccount(params) + + return { + content: [ + { + type: "text", + text: `Futures enabled for sub-account ${email}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Futures enabled for sub-account ${email}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to enable futures for sub-account: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to enable futures for sub-account: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/enableMargin.ts b/src/tools/binance-sub-account/enableMargin.ts index 859c8411..0fa97800 100644 --- a/src/tools/binance-sub-account/enableMargin.ts +++ b/src/tools/binance-sub-account/enableMargin.ts @@ -1,40 +1,43 @@ // src/tools/binance-sub-account/enableMargin.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { subAccountApiClient } from "../../config/binanceClient.js" export function registerBinanceSubAccountEnableMargin(server: McpServer) { - server.tool( - "BinanceSubAccountEnableMargin", - "Enable margin trading for a sub-account.", - { - email: z.string().describe("Sub-account email"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ email, recvWindow }) => { - try { - const params: any = { email }; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await subAccountApiClient.enableMarginForSubAccount(params); + server.tool( + "BinanceSubAccountEnableMargin", + "Enable margin trading for a sub-account.", + { + email: z.string().describe("Sub-account email"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ email, recvWindow }) => { + try { + const params: any = { email } + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await subAccountApiClient.enableMarginForSubAccount(params) + + return { + content: [ + { + type: "text", + text: `Margin enabled for sub-account ${email}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Margin enabled for sub-account ${email}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to enable margin for sub-account: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to enable margin for sub-account: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/getApiKeyIpRestriction.ts b/src/tools/binance-sub-account/getApiKeyIpRestriction.ts index efe78204..aa378c95 100644 --- a/src/tools/binance-sub-account/getApiKeyIpRestriction.ts +++ b/src/tools/binance-sub-account/getApiKeyIpRestriction.ts @@ -1,41 +1,42 @@ // src/tools/binance-sub-account/getApiKeyIpRestriction.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { subAccountApiClient } from "../../config/binanceClient.js" export function registerBinanceSubAccountGetApiKeyIpRestriction(server: McpServer) { - server.tool( - "BinanceSubAccountGetApiKeyIpRestriction", - "Get IP restriction for a sub-account API key.", - { - subAccountId: z.string().describe("Sub-account ID"), - subAccountApiKey: z.string().describe("Sub-account API key"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ subAccountId, subAccountApiKey, recvWindow }) => { - try { - const params: any = { subAccountId, subAccountApiKey }; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await subAccountApiClient.getSubAccountApiKeyIpRestriction(params); + server.tool( + "BinanceSubAccountGetApiKeyIpRestriction", + "Get IP restriction for a sub-account API key.", + { + subAccountId: z.string().describe("Sub-account ID"), + subAccountApiKey: z.string().describe("Sub-account API key"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ subAccountId, subAccountApiKey, recvWindow }) => { + try { + const params: any = { subAccountId, subAccountApiKey } + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await subAccountApiClient.getSubAccountApiKeyIpRestriction(params) + + return { + content: [ + { + type: "text", + text: `Retrieved IP restriction for sub-account API key. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved IP restriction for sub-account API key. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get IP restriction: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to get IP restriction: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/getSubAccountAssets.ts b/src/tools/binance-sub-account/getSubAccountAssets.ts index 6c36f1f6..5fcef84b 100644 --- a/src/tools/binance-sub-account/getSubAccountAssets.ts +++ b/src/tools/binance-sub-account/getSubAccountAssets.ts @@ -1,40 +1,41 @@ // src/tools/binance-sub-account/getSubAccountAssets.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { subAccountApiClient } from "../../config/binanceClient.js" export function registerBinanceSubAccountGetAssets(server: McpServer) { - server.tool( - "BinanceSubAccountGetAssets", - "Query sub-account assets (balances).", - { - email: z.string().describe("Sub-account email"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ email, recvWindow }) => { - try { - const params: any = { email }; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await subAccountApiClient.getSubAccountAssets(params); + server.tool( + "BinanceSubAccountGetAssets", + "Query sub-account assets (balances).", + { + email: z.string().describe("Sub-account email"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ email, recvWindow }) => { + try { + const params: any = { email } + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await subAccountApiClient.getSubAccountAssets(params) + + return { + content: [ + { + type: "text", + text: `Retrieved assets for sub-account ${email}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved assets for sub-account ${email}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get sub-account assets: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to get sub-account assets: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/getSubAccountDepositAddress.ts b/src/tools/binance-sub-account/getSubAccountDepositAddress.ts index c84b357a..104b89c3 100644 --- a/src/tools/binance-sub-account/getSubAccountDepositAddress.ts +++ b/src/tools/binance-sub-account/getSubAccountDepositAddress.ts @@ -1,43 +1,46 @@ // src/tools/binance-sub-account/getSubAccountDepositAddress.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { subAccountApiClient } from "../../config/binanceClient.js" export function registerBinanceSubAccountGetDepositAddress(server: McpServer) { - server.tool( - "BinanceSubAccountGetDepositAddress", - "Get sub-account deposit address for a specific coin.", - { - email: z.string().describe("Sub-account email"), - coin: z.string().describe("Coin to get deposit address for (e.g., BTC, ETH)"), - network: z.string().optional().describe("Network to use (e.g., BTC, ETH, BSC)"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ email, coin, network, recvWindow }) => { - try { - const params: any = { email, coin }; - if (network !== undefined) params.network = network; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await subAccountApiClient.getSubAccountDepositAddress(params); + server.tool( + "BinanceSubAccountGetDepositAddress", + "Get sub-account deposit address for a specific coin.", + { + email: z.string().describe("Sub-account email"), + coin: z.string().describe("Coin to get deposit address for (e.g., BTC, ETH)"), + network: z.string().optional().describe("Network to use (e.g., BTC, ETH, BSC)"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ email, coin, network, recvWindow }) => { + try { + const params: any = { email, coin } + if (network !== undefined) params.network = network + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await subAccountApiClient.getSubAccountDepositAddress(params) + + return { + content: [ + { + type: "text", + text: `Retrieved deposit address for ${coin} on ${email}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved deposit address for ${coin} on ${email}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get sub-account deposit address: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to get sub-account deposit address: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/getSubAccountDepositHistory.ts b/src/tools/binance-sub-account/getSubAccountDepositHistory.ts index 475366b5..81ff3250 100644 --- a/src/tools/binance-sub-account/getSubAccountDepositHistory.ts +++ b/src/tools/binance-sub-account/getSubAccountDepositHistory.ts @@ -1,52 +1,58 @@ // src/tools/binance-sub-account/getSubAccountDepositHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { subAccountApiClient } from "../../config/binanceClient.js" export function registerBinanceSubAccountGetDepositHistory(server: McpServer) { - server.tool( - "BinanceSubAccountGetDepositHistory", - "Query sub-account deposit history.", - { - email: z.string().describe("Sub-account email"), - coin: z.string().optional().describe("Coin to filter by"), - status: z.number().optional().describe("0: pending, 6: credited but cannot withdraw, 1: success"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500, max 500"), - offset: z.number().optional().describe("Default 0"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ email, coin, status, startTime, endTime, limit, offset, recvWindow }) => { - try { - const params: any = { email }; - if (coin !== undefined) params.coin = coin; - if (status !== undefined) params.status = status; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; - if (offset !== undefined) params.offset = offset; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await subAccountApiClient.getSubAccountDepositHistory(params); + server.tool( + "BinanceSubAccountGetDepositHistory", + "Query sub-account deposit history.", + { + email: z.string().describe("Sub-account email"), + coin: z.string().optional().describe("Coin to filter by"), + status: z + .number() + .optional() + .describe("0: pending, 6: credited but cannot withdraw, 1: success"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500, max 500"), + offset: z.number().optional().describe("Default 0"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ email, coin, status, startTime, endTime, limit, offset, recvWindow }) => { + try { + const params: any = { email } + if (coin !== undefined) params.coin = coin + if (status !== undefined) params.status = status + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit + if (offset !== undefined) params.offset = offset + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await subAccountApiClient.getSubAccountDepositHistory(params) + + return { + content: [ + { + type: "text", + text: `Retrieved deposit history for ${email}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved deposit history for ${email}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get sub-account deposit history: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to get sub-account deposit history: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/getSubAccountFuturesPositionRisk.ts b/src/tools/binance-sub-account/getSubAccountFuturesPositionRisk.ts index 0b4fd5ef..9c04bc93 100644 --- a/src/tools/binance-sub-account/getSubAccountFuturesPositionRisk.ts +++ b/src/tools/binance-sub-account/getSubAccountFuturesPositionRisk.ts @@ -1,42 +1,51 @@ // src/tools/binance-sub-account/getSubAccountFuturesPositionRisk.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { subAccountApiClient } from "../../config/binanceClient.js" export function registerBinanceSubAccountGetFuturesPositionRisk(server: McpServer) { - server.tool( - "BinanceSubAccountGetFuturesPositionRisk", - "Query sub-account futures position risk.", - { - email: z.string().describe("Sub-account email"), - futuresType: z.number().optional().describe("1: USDT Margined Futures, 2: COIN Margined Futures"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ email, futuresType, recvWindow }) => { - try { - const params: any = { email }; - if (futuresType !== undefined) params.futuresType = futuresType; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await subAccountApiClient.getSubAccountFuturesPositionRisk(params); + server.tool( + "BinanceSubAccountGetFuturesPositionRisk", + "Query sub-account futures position risk.", + { + email: z.string().describe("Sub-account email"), + futuresType: z + .number() + .optional() + .describe("1: USDT Margined Futures, 2: COIN Margined Futures"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ email, futuresType, recvWindow }) => { + try { + const params: any = { email } + if (futuresType !== undefined) params.futuresType = futuresType + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await subAccountApiClient.getSubAccountFuturesPositionRisk(params) + + return { + content: [ + { + type: "text", + text: `Retrieved futures position risk for ${email}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved futures position risk for ${email}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get sub-account futures position risk: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to get sub-account futures position risk: ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/getSubAccountFuturesSummary.ts b/src/tools/binance-sub-account/getSubAccountFuturesSummary.ts index ceb11fc1..73299a95 100644 --- a/src/tools/binance-sub-account/getSubAccountFuturesSummary.ts +++ b/src/tools/binance-sub-account/getSubAccountFuturesSummary.ts @@ -1,41 +1,44 @@ // src/tools/binance-sub-account/getSubAccountFuturesSummary.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { subAccountApiClient } from "../../config/binanceClient.js" export function registerBinanceSubAccountGetFuturesSummary(server: McpServer) { - server.tool( - "BinanceSubAccountGetFuturesSummary", - "Query sub-account futures account summary.", - { - email: z.string().optional().describe("Sub-account email (optional)"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ email, recvWindow }) => { - try { - const params: any = {}; - if (email !== undefined) params.email = email; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await subAccountApiClient.getSubAccountFuturesSummary(params); + server.tool( + "BinanceSubAccountGetFuturesSummary", + "Query sub-account futures account summary.", + { + email: z.string().optional().describe("Sub-account email (optional)"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ email, recvWindow }) => { + try { + const params: any = {} + if (email !== undefined) params.email = email + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await subAccountApiClient.getSubAccountFuturesSummary(params) + + return { + content: [ + { + type: "text", + text: `Retrieved sub-account futures summary. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved sub-account futures summary. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get sub-account futures summary: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to get sub-account futures summary: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/getSubAccountList.ts b/src/tools/binance-sub-account/getSubAccountList.ts index a177c3dd..5ac5b8ad 100644 --- a/src/tools/binance-sub-account/getSubAccountList.ts +++ b/src/tools/binance-sub-account/getSubAccountList.ts @@ -1,47 +1,48 @@ // src/tools/binance-sub-account/getSubAccountList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { subAccountApiClient } from "../../config/binanceClient.js" export function registerBinanceSubAccountGetList(server: McpServer) { - server.tool( - "BinanceSubAccountGetList", - "Query the list of sub-accounts under the master account.", - { - email: z.string().optional().describe("Sub-account email to filter"), - isFreeze: z.string().optional().describe("Filter by freeze status: 'true' or 'false'"), - page: z.number().optional().describe("Page number, default 1"), - limit: z.number().optional().describe("Results per page, default 1, max 200"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ email, isFreeze, page, limit, recvWindow }) => { - try { - const params: any = {}; - if (email !== undefined) params.email = email; - if (isFreeze !== undefined) params.isFreeze = isFreeze; - if (page !== undefined) params.page = page; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await subAccountApiClient.getSubAccountList(params); + server.tool( + "BinanceSubAccountGetList", + "Query the list of sub-accounts under the master account.", + { + email: z.string().optional().describe("Sub-account email to filter"), + isFreeze: z.string().optional().describe("Filter by freeze status: 'true' or 'false'"), + page: z.number().optional().describe("Page number, default 1"), + limit: z.number().optional().describe("Results per page, default 1, max 200"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ email, isFreeze, page, limit, recvWindow }) => { + try { + const params: any = {} + if (email !== undefined) params.email = email + if (isFreeze !== undefined) params.isFreeze = isFreeze + if (page !== undefined) params.page = page + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await subAccountApiClient.getSubAccountList(params) + + return { + content: [ + { + type: "text", + text: `Retrieved sub-account list. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved sub-account list. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get sub-account list: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to get sub-account list: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/getSubAccountMarginSummary.ts b/src/tools/binance-sub-account/getSubAccountMarginSummary.ts index 77908a00..9f2f9e9f 100644 --- a/src/tools/binance-sub-account/getSubAccountMarginSummary.ts +++ b/src/tools/binance-sub-account/getSubAccountMarginSummary.ts @@ -1,41 +1,44 @@ // src/tools/binance-sub-account/getSubAccountMarginSummary.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { subAccountApiClient } from "../../config/binanceClient.js" export function registerBinanceSubAccountGetMarginSummary(server: McpServer) { - server.tool( - "BinanceSubAccountGetMarginSummary", - "Query sub-account margin account summary.", - { - email: z.string().optional().describe("Sub-account email (optional)"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ email, recvWindow }) => { - try { - const params: any = {}; - if (email !== undefined) params.email = email; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await subAccountApiClient.getSubAccountMarginSummary(params); + server.tool( + "BinanceSubAccountGetMarginSummary", + "Query sub-account margin account summary.", + { + email: z.string().optional().describe("Sub-account email (optional)"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ email, recvWindow }) => { + try { + const params: any = {} + if (email !== undefined) params.email = email + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await subAccountApiClient.getSubAccountMarginSummary(params) + + return { + content: [ + { + type: "text", + text: `Retrieved sub-account margin summary. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved sub-account margin summary. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get sub-account margin summary: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to get sub-account margin summary: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/getSubAccountSpotSummary.ts b/src/tools/binance-sub-account/getSubAccountSpotSummary.ts index b713f4c7..0df399e7 100644 --- a/src/tools/binance-sub-account/getSubAccountSpotSummary.ts +++ b/src/tools/binance-sub-account/getSubAccountSpotSummary.ts @@ -1,45 +1,51 @@ // src/tools/binance-sub-account/getSubAccountSpotSummary.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { subAccountApiClient } from "../../config/binanceClient.js" export function registerBinanceSubAccountGetSpotSummary(server: McpServer) { - server.tool( - "BinanceSubAccountGetSpotSummary", - "Query sub-account spot assets summary for master account.", - { - email: z.string().optional().describe("Sub-account email (optional, returns all if not provided)"), - page: z.number().optional().describe("Page number, default 1"), - size: z.number().optional().describe("Results per page, default 10, max 20"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ email, page, size, recvWindow }) => { - try { - const params: any = {}; - if (email !== undefined) params.email = email; - if (page !== undefined) params.page = page; - if (size !== undefined) params.size = size; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await subAccountApiClient.getSubAccountSpotSummary(params); + server.tool( + "BinanceSubAccountGetSpotSummary", + "Query sub-account spot assets summary for master account.", + { + email: z + .string() + .optional() + .describe("Sub-account email (optional, returns all if not provided)"), + page: z.number().optional().describe("Page number, default 1"), + size: z.number().optional().describe("Results per page, default 10, max 20"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ email, page, size, recvWindow }) => { + try { + const params: any = {} + if (email !== undefined) params.email = email + if (page !== undefined) params.page = page + if (size !== undefined) params.size = size + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await subAccountApiClient.getSubAccountSpotSummary(params) + + return { + content: [ + { + type: "text", + text: `Retrieved sub-account spot summary. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved sub-account spot summary. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get sub-account spot summary: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to get sub-account spot summary: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/getSubAccountStatus.ts b/src/tools/binance-sub-account/getSubAccountStatus.ts index 3cedc4dd..dd493ce1 100644 --- a/src/tools/binance-sub-account/getSubAccountStatus.ts +++ b/src/tools/binance-sub-account/getSubAccountStatus.ts @@ -1,41 +1,42 @@ // src/tools/binance-sub-account/getSubAccountStatus.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { subAccountApiClient } from "../../config/binanceClient.js" export function registerBinanceSubAccountGetStatus(server: McpServer) { - server.tool( - "BinanceSubAccountGetStatus", - "Get sub-account status including enable/disable status for margin and futures.", - { - email: z.string().optional().describe("Sub-account email (optional)"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ email, recvWindow }) => { - try { - const params: any = {}; - if (email !== undefined) params.email = email; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await subAccountApiClient.getSubAccountStatus(params); + server.tool( + "BinanceSubAccountGetStatus", + "Get sub-account status including enable/disable status for margin and futures.", + { + email: z.string().optional().describe("Sub-account email (optional)"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ email, recvWindow }) => { + try { + const params: any = {} + if (email !== undefined) params.email = email + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await subAccountApiClient.getSubAccountStatus(params) + + return { + content: [ + { + type: "text", + text: `Retrieved sub-account status. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved sub-account status. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get sub-account status: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to get sub-account status: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/getSubAccountTransferHistory.ts b/src/tools/binance-sub-account/getSubAccountTransferHistory.ts index 9ae64481..c4b81bdd 100644 --- a/src/tools/binance-sub-account/getSubAccountTransferHistory.ts +++ b/src/tools/binance-sub-account/getSubAccountTransferHistory.ts @@ -1,49 +1,52 @@ // src/tools/binance-sub-account/getSubAccountTransferHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { subAccountApiClient } from "../../config/binanceClient.js" export function registerBinanceSubAccountGetTransferHistory(server: McpServer) { - server.tool( - "BinanceSubAccountGetTransferHistory", - "Query sub-account transfer history.", - { - asset: z.string().optional().describe("Asset to filter by"), - type: z.number().optional().describe("1: transfer in, 2: transfer out"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500, max 500"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ asset, type, startTime, endTime, limit, recvWindow }) => { - try { - const params: any = {}; - if (asset !== undefined) params.asset = asset; - if (type !== undefined) params.type = type; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await subAccountApiClient.getSubAccountTransferHistory(params); + server.tool( + "BinanceSubAccountGetTransferHistory", + "Query sub-account transfer history.", + { + asset: z.string().optional().describe("Asset to filter by"), + type: z.number().optional().describe("1: transfer in, 2: transfer out"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500, max 500"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ asset, type, startTime, endTime, limit, recvWindow }) => { + try { + const params: any = {} + if (asset !== undefined) params.asset = asset + if (type !== undefined) params.type = type + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await subAccountApiClient.getSubAccountTransferHistory(params) + + return { + content: [ + { + type: "text", + text: `Retrieved sub-account transfer history. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved sub-account transfer history. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get sub-account transfer history: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to get sub-account transfer history: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/getUniversalTransferHistory.ts b/src/tools/binance-sub-account/getUniversalTransferHistory.ts index 2a3f24b7..7cff1cf3 100644 --- a/src/tools/binance-sub-account/getUniversalTransferHistory.ts +++ b/src/tools/binance-sub-account/getUniversalTransferHistory.ts @@ -1,51 +1,54 @@ // src/tools/binance-sub-account/getUniversalTransferHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { subAccountApiClient } from "../../config/binanceClient.js" export function registerBinanceSubAccountGetUniversalTransferHistory(server: McpServer) { - server.tool( - "BinanceSubAccountGetUniversalTransferHistory", - "Query universal transfer history for sub-accounts.", - { - fromEmail: z.string().optional().describe("Sender email"), - toEmail: z.string().optional().describe("Recipient email"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - page: z.number().optional().describe("Page number, default 1"), - limit: z.number().optional().describe("Results per page, default 500, max 500"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ fromEmail, toEmail, startTime, endTime, page, limit, recvWindow }) => { - try { - const params: any = {}; - if (fromEmail !== undefined) params.fromEmail = fromEmail; - if (toEmail !== undefined) params.toEmail = toEmail; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (page !== undefined) params.page = page; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await subAccountApiClient.getSubAccountUniversalTransferHistory(params); + server.tool( + "BinanceSubAccountGetUniversalTransferHistory", + "Query universal transfer history for sub-accounts.", + { + fromEmail: z.string().optional().describe("Sender email"), + toEmail: z.string().optional().describe("Recipient email"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + page: z.number().optional().describe("Page number, default 1"), + limit: z.number().optional().describe("Results per page, default 500, max 500"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ fromEmail, toEmail, startTime, endTime, page, limit, recvWindow }) => { + try { + const params: any = {} + if (fromEmail !== undefined) params.fromEmail = fromEmail + if (toEmail !== undefined) params.toEmail = toEmail + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (page !== undefined) params.page = page + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await subAccountApiClient.getSubAccountUniversalTransferHistory(params) + + return { + content: [ + { + type: "text", + text: `Retrieved universal transfer history. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved universal transfer history. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get universal transfer history: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to get universal transfer history: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/index.ts b/src/tools/binance-sub-account/index.ts index 8d8f5495..658a89bd 100644 --- a/src/tools/binance-sub-account/index.ts +++ b/src/tools/binance-sub-account/index.ts @@ -1,58 +1,59 @@ // src/tools/binance-sub-account/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceSubAccountCreateVirtual } from "./createVirtualSubAccount.js"; -import { registerBinanceSubAccountGetList } from "./getSubAccountList.js"; -import { registerBinanceSubAccountGetAssets } from "./getSubAccountAssets.js"; -import { registerBinanceSubAccountGetSpotSummary } from "./getSubAccountSpotSummary.js"; -import { registerBinanceSubAccountGetStatus } from "./getSubAccountStatus.js"; -import { registerBinanceSubAccountEnableMargin } from "./enableMargin.js"; -import { registerBinanceSubAccountGetMarginSummary } from "./getSubAccountMarginSummary.js"; -import { registerBinanceSubAccountEnableFutures } from "./enableFutures.js"; -import { registerBinanceSubAccountGetFuturesSummary } from "./getSubAccountFuturesSummary.js"; -import { registerBinanceSubAccountGetFuturesPositionRisk } from "./getSubAccountFuturesPositionRisk.js"; -import { registerBinanceSubAccountTransferToSub } from "./transferToSubAccount.js"; -import { registerBinanceSubAccountTransferToMaster } from "./transferToMaster.js"; -import { registerBinanceSubAccountGetTransferHistory } from "./getSubAccountTransferHistory.js"; -import { registerBinanceSubAccountUniversalTransfer } from "./universalTransfer.js"; -import { registerBinanceSubAccountGetUniversalTransferHistory } from "./getUniversalTransferHistory.js"; -import { registerBinanceSubAccountGetDepositAddress } from "./getSubAccountDepositAddress.js"; -import { registerBinanceSubAccountGetDepositHistory } from "./getSubAccountDepositHistory.js"; -import { registerBinanceSubAccountCreateApiKey } from "./createApiKey.js"; -import { registerBinanceSubAccountDeleteApiKey } from "./deleteApiKey.js"; -import { registerBinanceSubAccountUpdateIpRestriction } from "./updateIpRestriction.js"; -import { registerBinanceSubAccountGetApiKeyIpRestriction } from "./getApiKeyIpRestriction.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceSubAccountCreateApiKey } from "./createApiKey.js" +import { registerBinanceSubAccountCreateVirtual } from "./createVirtualSubAccount.js" +import { registerBinanceSubAccountDeleteApiKey } from "./deleteApiKey.js" +import { registerBinanceSubAccountEnableFutures } from "./enableFutures.js" +import { registerBinanceSubAccountEnableMargin } from "./enableMargin.js" +import { registerBinanceSubAccountGetApiKeyIpRestriction } from "./getApiKeyIpRestriction.js" +import { registerBinanceSubAccountGetAssets } from "./getSubAccountAssets.js" +import { registerBinanceSubAccountGetDepositAddress } from "./getSubAccountDepositAddress.js" +import { registerBinanceSubAccountGetDepositHistory } from "./getSubAccountDepositHistory.js" +import { registerBinanceSubAccountGetFuturesPositionRisk } from "./getSubAccountFuturesPositionRisk.js" +import { registerBinanceSubAccountGetFuturesSummary } from "./getSubAccountFuturesSummary.js" +import { registerBinanceSubAccountGetList } from "./getSubAccountList.js" +import { registerBinanceSubAccountGetMarginSummary } from "./getSubAccountMarginSummary.js" +import { registerBinanceSubAccountGetSpotSummary } from "./getSubAccountSpotSummary.js" +import { registerBinanceSubAccountGetStatus } from "./getSubAccountStatus.js" +import { registerBinanceSubAccountGetTransferHistory } from "./getSubAccountTransferHistory.js" +import { registerBinanceSubAccountGetUniversalTransferHistory } from "./getUniversalTransferHistory.js" +import { registerBinanceSubAccountTransferToMaster } from "./transferToMaster.js" +import { registerBinanceSubAccountTransferToSub } from "./transferToSubAccount.js" +import { registerBinanceSubAccountUniversalTransfer } from "./universalTransfer.js" +import { registerBinanceSubAccountUpdateIpRestriction } from "./updateIpRestriction.js" export function registerBinanceSubAccountTools(server: McpServer) { - // Sub-account Management - registerBinanceSubAccountCreateVirtual(server); - registerBinanceSubAccountGetList(server); - registerBinanceSubAccountGetAssets(server); - registerBinanceSubAccountGetSpotSummary(server); - registerBinanceSubAccountGetStatus(server); - - // Margin Management - registerBinanceSubAccountEnableMargin(server); - registerBinanceSubAccountGetMarginSummary(server); - - // Futures Management - registerBinanceSubAccountEnableFutures(server); - registerBinanceSubAccountGetFuturesSummary(server); - registerBinanceSubAccountGetFuturesPositionRisk(server); - - // Transfers - registerBinanceSubAccountTransferToSub(server); - registerBinanceSubAccountTransferToMaster(server); - registerBinanceSubAccountGetTransferHistory(server); - registerBinanceSubAccountUniversalTransfer(server); - registerBinanceSubAccountGetUniversalTransferHistory(server); - - // Deposit - registerBinanceSubAccountGetDepositAddress(server); - registerBinanceSubAccountGetDepositHistory(server); - - // API Key Management - registerBinanceSubAccountCreateApiKey(server); - registerBinanceSubAccountDeleteApiKey(server); - registerBinanceSubAccountUpdateIpRestriction(server); - registerBinanceSubAccountGetApiKeyIpRestriction(server); + // Sub-account Management + registerBinanceSubAccountCreateVirtual(server) + registerBinanceSubAccountGetList(server) + registerBinanceSubAccountGetAssets(server) + registerBinanceSubAccountGetSpotSummary(server) + registerBinanceSubAccountGetStatus(server) + + // Margin Management + registerBinanceSubAccountEnableMargin(server) + registerBinanceSubAccountGetMarginSummary(server) + + // Futures Management + registerBinanceSubAccountEnableFutures(server) + registerBinanceSubAccountGetFuturesSummary(server) + registerBinanceSubAccountGetFuturesPositionRisk(server) + + // Transfers + registerBinanceSubAccountTransferToSub(server) + registerBinanceSubAccountTransferToMaster(server) + registerBinanceSubAccountGetTransferHistory(server) + registerBinanceSubAccountUniversalTransfer(server) + registerBinanceSubAccountGetUniversalTransferHistory(server) + + // Deposit + registerBinanceSubAccountGetDepositAddress(server) + registerBinanceSubAccountGetDepositHistory(server) + + // API Key Management + registerBinanceSubAccountCreateApiKey(server) + registerBinanceSubAccountDeleteApiKey(server) + registerBinanceSubAccountUpdateIpRestriction(server) + registerBinanceSubAccountGetApiKeyIpRestriction(server) } diff --git a/src/tools/binance-sub-account/management-api/createSubAccount.ts b/src/tools/binance-sub-account/management-api/createSubAccount.ts index 991e6fc5..9cd4ac9a 100644 --- a/src/tools/binance-sub-account/management-api/createSubAccount.ts +++ b/src/tools/binance-sub-account/management-api/createSubAccount.ts @@ -5,42 +5,49 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/management-api/createSubAccount.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { spotClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceSubAccountCreate(server: McpServer) { - server.tool( - "BinanceSubAccountCreate", - "Create a new virtual sub-account under your master account. Sub-accounts are useful for separating trading strategies or managing funds for different purposes. ⚠️ Requires master account permissions.", - { - subAccountString: z.string().min(1).max(20) - .describe("Sub-account name/label (1-20 characters, alphanumeric)"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await spotClient.restAPI.createVirtualSubAccount({ - subAccountString: params.subAccountString, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSubAccountCreate", + "Create a new virtual sub-account under your master account. Sub-accounts are useful for separating trading strategies or managing funds for different purposes. ⚠️ Requires master account permissions.", + { + subAccountString: z + .string() + .min(1) + .max(20) + .describe("Sub-account name/label (1-20 characters, alphanumeric)"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await spotClient.restAPI.createVirtualSubAccount({ + subAccountString: params.subAccountString, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Sub-account created successfully!\n\nEmail: ${data.email}\n\n📝 Note: The sub-account email is auto-generated. Use it for API operations and transfers.`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `✅ Sub-account created successfully!\n\nEmail: ${data.email}\n\n📝 Note: The sub-account email is auto-generated. Use it for API operations and transfers.` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to create sub-account: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to create sub-account: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/management-api/enableFutures.ts b/src/tools/binance-sub-account/management-api/enableFutures.ts index e01ef66a..f84d9aaf 100644 --- a/src/tools/binance-sub-account/management-api/enableFutures.ts +++ b/src/tools/binance-sub-account/management-api/enableFutures.ts @@ -5,42 +5,45 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/management-api/enableFutures.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { spotClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceSubAccountEnableFutures(server: McpServer) { - server.tool( - "BinanceSubAccountEnableFutures", - "Enable futures trading for a sub-account. ⚠️ WARNING: Futures trading involves leverage and carries significant risk of total loss. Only enable if you understand the risks.", - { - email: z.string().email() - .describe("Sub-account email to enable futures for"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await spotClient.restAPI.enableFuturesForSubAccount({ - email: params.email, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSubAccountEnableFutures", + "Enable futures trading for a sub-account. ⚠️ WARNING: Futures trading involves leverage and carries significant risk of total loss. Only enable if you understand the risks.", + { + email: z.string().email().describe("Sub-account email to enable futures for"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await spotClient.restAPI.enableFuturesForSubAccount({ + email: params.email, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Futures trading enabled for sub-account: ${params.email}\n\nResponse: ${JSON.stringify(data, null, 2)}\n\n⚠️ Reminder: Futures trading carries significant risk of total loss.`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `✅ Futures trading enabled for sub-account: ${params.email}\n\nResponse: ${JSON.stringify(data, null, 2)}\n\n⚠️ Reminder: Futures trading carries significant risk of total loss.` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to enable futures: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to enable futures: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/management-api/enableMargin.ts b/src/tools/binance-sub-account/management-api/enableMargin.ts index cda0a247..59ae5cee 100644 --- a/src/tools/binance-sub-account/management-api/enableMargin.ts +++ b/src/tools/binance-sub-account/management-api/enableMargin.ts @@ -5,42 +5,45 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/management-api/enableMargin.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { spotClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceSubAccountEnableMargin(server: McpServer) { - server.tool( - "BinanceSubAccountEnableMargin", - "Enable margin trading for a sub-account. ⚠️ WARNING: Margin trading involves leverage and carries significant risk of loss. Only enable if you understand the risks.", - { - email: z.string().email() - .describe("Sub-account email to enable margin for"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await spotClient.restAPI.enableMarginForSubAccount({ - email: params.email, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSubAccountEnableMargin", + "Enable margin trading for a sub-account. ⚠️ WARNING: Margin trading involves leverage and carries significant risk of loss. Only enable if you understand the risks.", + { + email: z.string().email().describe("Sub-account email to enable margin for"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await spotClient.restAPI.enableMarginForSubAccount({ + email: params.email, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Margin trading enabled for sub-account: ${params.email}\n\nResponse: ${JSON.stringify(data, null, 2)}\n\n⚠️ Reminder: Margin trading carries significant risk.`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `✅ Margin trading enabled for sub-account: ${params.email}\n\nResponse: ${JSON.stringify(data, null, 2)}\n\n⚠️ Reminder: Margin trading carries significant risk.` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to enable margin: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to enable margin: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/management-api/getSubAccountApiPermission.ts b/src/tools/binance-sub-account/management-api/getSubAccountApiPermission.ts index a277c542..f9843bba 100644 --- a/src/tools/binance-sub-account/management-api/getSubAccountApiPermission.ts +++ b/src/tools/binance-sub-account/management-api/getSubAccountApiPermission.ts @@ -5,45 +5,47 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/management-api/getSubAccountApiPermission.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { spotClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceSubAccountApiPermission(server: McpServer) { - server.tool( - "BinanceSubAccountApiPermission", - "Get API key permissions for a sub-account. Shows what operations the API key is allowed to perform.", - { - email: z.string().email() - .describe("Sub-account email to query API permissions for"), - subAccountApiKey: z.string() - .describe("Sub-account API key to check permissions for"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await spotClient.restAPI.getSubAccountApiIpRestriction({ - email: params.email, - subAccountApiKey: params.subAccountApiKey, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSubAccountApiPermission", + "Get API key permissions for a sub-account. Shows what operations the API key is allowed to perform.", + { + email: z.string().email().describe("Sub-account email to query API permissions for"), + subAccountApiKey: z.string().describe("Sub-account API key to check permissions for"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await spotClient.restAPI.getSubAccountApiIpRestriction({ + email: params.email, + subAccountApiKey: params.subAccountApiKey, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Sub-Account API Permissions:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Sub-Account API Permissions:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get API permissions: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to get API permissions: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/management-api/getSubAccountList.ts b/src/tools/binance-sub-account/management-api/getSubAccountList.ts index b30713a2..444d3bb9 100644 --- a/src/tools/binance-sub-account/management-api/getSubAccountList.ts +++ b/src/tools/binance-sub-account/management-api/getSubAccountList.ts @@ -5,51 +5,57 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/management-api/getSubAccountList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { spotClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceSubAccountList(server: McpServer) { - server.tool( - "BinanceSubAccountList", - "Get a list of all sub-accounts under your master account. Returns email, status, and creation time for each sub-account.", - { - email: z.string().email().optional() - .describe("Filter by specific sub-account email"), - isFreeze: z.enum(["true", "false"]).optional() - .describe("Filter by freeze status"), - page: z.number().int().min(1).optional() - .describe("Page number (starts from 1)"), - limit: z.number().int().min(1).max(200).optional() - .describe("Number of results per page (max 200)"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await spotClient.restAPI.querySubAccountList({ - ...(params.email && { email: params.email }), - ...(params.isFreeze && { isFreeze: params.isFreeze }), - ...(params.page && { page: params.page }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSubAccountList", + "Get a list of all sub-accounts under your master account. Returns email, status, and creation time for each sub-account.", + { + email: z.string().email().optional().describe("Filter by specific sub-account email"), + isFreeze: z.enum(["true", "false"]).optional().describe("Filter by freeze status"), + page: z.number().int().min(1).optional().describe("Page number (starts from 1)"), + limit: z + .number() + .int() + .min(1) + .max(200) + .optional() + .describe("Number of results per page (max 200)"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await spotClient.restAPI.querySubAccountList({ + ...(params.email && { email: params.email }), + ...(params.isFreeze && { isFreeze: params.isFreeze }), + ...(params.page && { page: params.page }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Sub-Account List:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Sub-Account List:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get sub-account list: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to get sub-account list: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/management-api/getSubAccountStatus.ts b/src/tools/binance-sub-account/management-api/getSubAccountStatus.ts index 90c8483c..455b60ee 100644 --- a/src/tools/binance-sub-account/management-api/getSubAccountStatus.ts +++ b/src/tools/binance-sub-account/management-api/getSubAccountStatus.ts @@ -5,42 +5,45 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/management-api/getSubAccountStatus.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { spotClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceSubAccountStatus(server: McpServer) { - server.tool( - "BinanceSubAccountStatus", - "Get the status of a sub-account including enabled features (margin, futures, etc.) and trading permissions.", - { - email: z.string().email().optional() - .describe("Sub-account email to query"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await spotClient.restAPI.getSubAccountStatus({ - ...(params.email && { email: params.email }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSubAccountStatus", + "Get the status of a sub-account including enabled features (margin, futures, etc.) and trading permissions.", + { + email: z.string().email().optional().describe("Sub-account email to query"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await spotClient.restAPI.getSubAccountStatus({ + ...(params.email && { email: params.email }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Sub-Account Status:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Sub-Account Status:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get sub-account status: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to get sub-account status: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/management-api/index.ts b/src/tools/binance-sub-account/management-api/index.ts index 54f56e3b..71a66075 100644 --- a/src/tools/binance-sub-account/management-api/index.ts +++ b/src/tools/binance-sub-account/management-api/index.ts @@ -5,19 +5,20 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/management-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceSubAccountCreate } from "./createSubAccount.js"; -import { registerBinanceSubAccountList } from "./getSubAccountList.js"; -import { registerBinanceSubAccountStatus } from "./getSubAccountStatus.js"; -import { registerBinanceSubAccountEnableMargin } from "./enableMargin.js"; -import { registerBinanceSubAccountEnableFutures } from "./enableFutures.js"; -import { registerBinanceSubAccountApiPermission } from "./getSubAccountApiPermission.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceSubAccountCreate } from "./createSubAccount.js" +import { registerBinanceSubAccountEnableFutures } from "./enableFutures.js" +import { registerBinanceSubAccountEnableMargin } from "./enableMargin.js" +import { registerBinanceSubAccountApiPermission } from "./getSubAccountApiPermission.js" +import { registerBinanceSubAccountList } from "./getSubAccountList.js" +import { registerBinanceSubAccountStatus } from "./getSubAccountStatus.js" export function registerBinanceSubAccountManagementTools(server: McpServer) { - registerBinanceSubAccountCreate(server); - registerBinanceSubAccountList(server); - registerBinanceSubAccountStatus(server); - registerBinanceSubAccountEnableMargin(server); - registerBinanceSubAccountEnableFutures(server); - registerBinanceSubAccountApiPermission(server); + registerBinanceSubAccountCreate(server) + registerBinanceSubAccountList(server) + registerBinanceSubAccountStatus(server) + registerBinanceSubAccountEnableMargin(server) + registerBinanceSubAccountEnableFutures(server) + registerBinanceSubAccountApiPermission(server) } diff --git a/src/tools/binance-sub-account/transfer-api/futuresTransfer.ts b/src/tools/binance-sub-account/transfer-api/futuresTransfer.ts index 857dd54c..350e094f 100644 --- a/src/tools/binance-sub-account/transfer-api/futuresTransfer.ts +++ b/src/tools/binance-sub-account/transfer-api/futuresTransfer.ts @@ -5,54 +5,53 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/transfer-api/futuresTransfer.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { spotClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceSubAccountFuturesTransfer(server: McpServer) { - server.tool( - "BinanceSubAccountFuturesTransfer", - "Internal transfer between sub-account futures accounts. Move assets between different sub-account futures wallets.", - { - fromEmail: z.string().email() - .describe("Sender sub-account email"), - toEmail: z.string().email() - .describe("Recipient sub-account email"), - futuresType: z.enum(["1", "2"]) - .describe("Futures type: 1 for USD-M, 2 for COIN-M"), - asset: z.string() - .describe("Asset to transfer (e.g., 'USDT', 'BTC')"), - amount: z.number().positive() - .describe("Amount to transfer"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await spotClient.restAPI.subAccountFuturesInternalTransfer({ - fromEmail: params.fromEmail, - toEmail: params.toEmail, - futuresType: params.futuresType, - asset: params.asset, - amount: params.amount, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSubAccountFuturesTransfer", + "Internal transfer between sub-account futures accounts. Move assets between different sub-account futures wallets.", + { + fromEmail: z.string().email().describe("Sender sub-account email"), + toEmail: z.string().email().describe("Recipient sub-account email"), + futuresType: z.enum(["1", "2"]).describe("Futures type: 1 for USD-M, 2 for COIN-M"), + asset: z.string().describe("Asset to transfer (e.g., 'USDT', 'BTC')"), + amount: z.number().positive().describe("Amount to transfer"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await spotClient.restAPI.subAccountFuturesInternalTransfer({ + fromEmail: params.fromEmail, + toEmail: params.toEmail, + futuresType: params.futuresType, + asset: params.asset, + amount: params.amount, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Futures internal transfer successful!\n\nFrom: ${params.fromEmail}\nTo: ${params.toEmail}\nFutures Type: ${params.futuresType === "1" ? "USD-M" : "COIN-M"}\nAsset: ${params.asset}\nAmount: ${params.amount}\n\nTransaction: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `✅ Futures internal transfer successful!\n\nFrom: ${params.fromEmail}\nTo: ${params.toEmail}\nFutures Type: ${params.futuresType === "1" ? "USD-M" : "COIN-M"}\nAsset: ${params.asset}\nAmount: ${params.amount}\n\nTransaction: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to transfer: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to transfer: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/transfer-api/getTransferHistory.ts b/src/tools/binance-sub-account/transfer-api/getTransferHistory.ts index fcaed7a5..578a0e3f 100644 --- a/src/tools/binance-sub-account/transfer-api/getTransferHistory.ts +++ b/src/tools/binance-sub-account/transfer-api/getTransferHistory.ts @@ -5,54 +5,56 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/transfer-api/getTransferHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { spotClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceSubAccountTransferHistory(server: McpServer) { - server.tool( - "BinanceSubAccountTransferHistory", - "Get transfer history for sub-accounts. Shows all internal transfers between master and sub-accounts.", - { - asset: z.string().optional() - .describe("Filter by specific asset"), - type: z.enum(["1", "2"]).optional() - .describe("Transfer type: 1 = transfer in, 2 = transfer out"), - startTime: z.number().int().optional() - .describe("Start timestamp in ms"), - endTime: z.number().int().optional() - .describe("End timestamp in ms"), - limit: z.number().int().min(1).max(500).optional() - .describe("Number of results (max 500)"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await spotClient.restAPI.querySubAccountTransferHistoryV1({ - ...(params.asset && { asset: params.asset }), - ...(params.type && { type: params.type }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSubAccountTransferHistory", + "Get transfer history for sub-accounts. Shows all internal transfers between master and sub-accounts.", + { + asset: z.string().optional().describe("Filter by specific asset"), + type: z + .enum(["1", "2"]) + .optional() + .describe("Transfer type: 1 = transfer in, 2 = transfer out"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + limit: z.number().int().min(1).max(500).optional().describe("Number of results (max 500)"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await spotClient.restAPI.querySubAccountTransferHistoryV1({ + ...(params.asset && { asset: params.asset }), + ...(params.type && { type: params.type }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Sub-Account Transfer History:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `Sub-Account Transfer History:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to get transfer history: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to get transfer history: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/transfer-api/index.ts b/src/tools/binance-sub-account/transfer-api/index.ts index 84af79d4..a023779d 100644 --- a/src/tools/binance-sub-account/transfer-api/index.ts +++ b/src/tools/binance-sub-account/transfer-api/index.ts @@ -5,17 +5,18 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/transfer-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceSubAccountTransferToSub } from "./transferToSubAccount.js"; -import { registerBinanceSubAccountTransferToMaster } from "./transferToMaster.js"; -import { registerBinanceSubAccountUniversalTransfer } from "./universalTransfer.js"; -import { registerBinanceSubAccountTransferHistory } from "./getTransferHistory.js"; -import { registerBinanceSubAccountFuturesTransfer } from "./futuresTransfer.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceSubAccountFuturesTransfer } from "./futuresTransfer.js" +import { registerBinanceSubAccountTransferHistory } from "./getTransferHistory.js" +import { registerBinanceSubAccountTransferToMaster } from "./transferToMaster.js" +import { registerBinanceSubAccountTransferToSub } from "./transferToSubAccount.js" +import { registerBinanceSubAccountUniversalTransfer } from "./universalTransfer.js" export function registerBinanceSubAccountTransferTools(server: McpServer) { - registerBinanceSubAccountTransferToSub(server); - registerBinanceSubAccountTransferToMaster(server); - registerBinanceSubAccountUniversalTransfer(server); - registerBinanceSubAccountTransferHistory(server); - registerBinanceSubAccountFuturesTransfer(server); + registerBinanceSubAccountTransferToSub(server) + registerBinanceSubAccountTransferToMaster(server) + registerBinanceSubAccountUniversalTransfer(server) + registerBinanceSubAccountTransferHistory(server) + registerBinanceSubAccountFuturesTransfer(server) } diff --git a/src/tools/binance-sub-account/transfer-api/transferToMaster.ts b/src/tools/binance-sub-account/transfer-api/transferToMaster.ts index b78bff11..210551d3 100644 --- a/src/tools/binance-sub-account/transfer-api/transferToMaster.ts +++ b/src/tools/binance-sub-account/transfer-api/transferToMaster.ts @@ -5,45 +5,47 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/transfer-api/transferToMaster.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { spotClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceSubAccountTransferToMaster(server: McpServer) { - server.tool( - "BinanceSubAccountTransferToMaster", - "Transfer assets from a sub-account back to the master account.", - { - asset: z.string() - .describe("Asset to transfer (e.g., 'BTC', 'USDT')"), - amount: z.number().positive() - .describe("Amount to transfer"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await spotClient.restAPI.subAccountTransferSubToMaster({ - asset: params.asset, - amount: params.amount, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSubAccountTransferToMaster", + "Transfer assets from a sub-account back to the master account.", + { + asset: z.string().describe("Asset to transfer (e.g., 'BTC', 'USDT')"), + amount: z.number().positive().describe("Amount to transfer"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await spotClient.restAPI.subAccountTransferSubToMaster({ + asset: params.asset, + amount: params.amount, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Transfer to master successful!\n\nAsset: ${params.asset}\nAmount: ${params.amount}\n\nTransaction: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `✅ Transfer to master successful!\n\nAsset: ${params.asset}\nAmount: ${params.amount}\n\nTransaction: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to transfer to master: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to transfer to master: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/transfer-api/transferToSubAccount.ts b/src/tools/binance-sub-account/transfer-api/transferToSubAccount.ts index b108e892..e0c8b87f 100644 --- a/src/tools/binance-sub-account/transfer-api/transferToSubAccount.ts +++ b/src/tools/binance-sub-account/transfer-api/transferToSubAccount.ts @@ -5,48 +5,49 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/transfer-api/transferToSubAccount.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { spotClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceSubAccountTransferToSub(server: McpServer) { - server.tool( - "BinanceSubAccountTransferToSub", - "Transfer assets from one sub-account to another sub-account. Both accounts must belong to the same master account.", - { - toEmail: z.string().email() - .describe("Recipient sub-account email"), - asset: z.string() - .describe("Asset to transfer (e.g., 'BTC', 'USDT')"), - amount: z.number().positive() - .describe("Amount to transfer"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await spotClient.restAPI.subAccountTransferSubToSub({ - toEmail: params.toEmail, - asset: params.asset, - amount: params.amount, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSubAccountTransferToSub", + "Transfer assets from one sub-account to another sub-account. Both accounts must belong to the same master account.", + { + toEmail: z.string().email().describe("Recipient sub-account email"), + asset: z.string().describe("Asset to transfer (e.g., 'BTC', 'USDT')"), + amount: z.number().positive().describe("Amount to transfer"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await spotClient.restAPI.subAccountTransferSubToSub({ + toEmail: params.toEmail, + asset: params.asset, + amount: params.amount, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Transfer successful!\n\nTo: ${params.toEmail}\nAsset: ${params.asset}\nAmount: ${params.amount}\n\nTransaction: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `✅ Transfer successful!\n\nTo: ${params.toEmail}\nAsset: ${params.asset}\nAmount: ${params.amount}\n\nTransaction: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to transfer: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to transfer: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/transfer-api/universalTransfer.ts b/src/tools/binance-sub-account/transfer-api/universalTransfer.ts index 2c9924e3..c2647e57 100644 --- a/src/tools/binance-sub-account/transfer-api/universalTransfer.ts +++ b/src/tools/binance-sub-account/transfer-api/universalTransfer.ts @@ -5,63 +5,71 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/transfer-api/universalTransfer.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { spotClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../../../config/binanceClient.js" export function registerBinanceSubAccountUniversalTransfer(server: McpServer) { - server.tool( - "BinanceSubAccountUniversalTransfer", - "Universal transfer between master account and sub-accounts, supporting various account types (spot, margin, futures, etc.).", - { - fromEmail: z.string().email().optional() - .describe("Sender email (leave empty for master account)"), - toEmail: z.string().email().optional() - .describe("Recipient email (leave empty for master account)"), - fromAccountType: z.enum(["SPOT", "USDT_FUTURE", "COIN_FUTURE", "MARGIN", "ISOLATED_MARGIN"]) - .describe("Source account type"), - toAccountType: z.enum(["SPOT", "USDT_FUTURE", "COIN_FUTURE", "MARGIN", "ISOLATED_MARGIN"]) - .describe("Destination account type"), - clientTranId: z.string().optional() - .describe("Client transfer ID for idempotency"), - symbol: z.string().optional() - .describe("Required for isolated margin transfers"), - asset: z.string() - .describe("Asset to transfer (e.g., 'BTC', 'USDT')"), - amount: z.number().positive() - .describe("Amount to transfer"), - recvWindow: z.number().int().optional() - .describe("Time window for request validity in ms") - }, - async (params) => { - try { - const response = await spotClient.restAPI.universalTransfer({ - fromAccountType: params.fromAccountType, - toAccountType: params.toAccountType, - asset: params.asset, - amount: params.amount, - ...(params.fromEmail && { fromEmail: params.fromEmail }), - ...(params.toEmail && { toEmail: params.toEmail }), - ...(params.clientTranId && { clientTranId: params.clientTranId }), - ...(params.symbol && { symbol: params.symbol }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceSubAccountUniversalTransfer", + "Universal transfer between master account and sub-accounts, supporting various account types (spot, margin, futures, etc.).", + { + fromEmail: z + .string() + .email() + .optional() + .describe("Sender email (leave empty for master account)"), + toEmail: z + .string() + .email() + .optional() + .describe("Recipient email (leave empty for master account)"), + fromAccountType: z + .enum(["SPOT", "USDT_FUTURE", "COIN_FUTURE", "MARGIN", "ISOLATED_MARGIN"]) + .describe("Source account type"), + toAccountType: z + .enum(["SPOT", "USDT_FUTURE", "COIN_FUTURE", "MARGIN", "ISOLATED_MARGIN"]) + .describe("Destination account type"), + clientTranId: z.string().optional().describe("Client transfer ID for idempotency"), + symbol: z.string().optional().describe("Required for isolated margin transfers"), + asset: z.string().describe("Asset to transfer (e.g., 'BTC', 'USDT')"), + amount: z.number().positive().describe("Amount to transfer"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, + async (params) => { + try { + const response = await spotClient.restAPI.universalTransfer({ + fromAccountType: params.fromAccountType, + toAccountType: params.toAccountType, + asset: params.asset, + amount: params.amount, + ...(params.fromEmail && { fromEmail: params.fromEmail }), + ...(params.toEmail && { toEmail: params.toEmail }), + ...(params.clientTranId && { clientTranId: params.clientTranId }), + ...(params.symbol && { symbol: params.symbol }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `✅ Universal transfer successful!\n\nFrom: ${params.fromEmail || "Master"} (${params.fromAccountType})\nTo: ${params.toEmail || "Master"} (${params.toAccountType})\nAsset: ${params.asset}\nAmount: ${params.amount}\n\nTransaction: ${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [{ - type: "text", - text: `✅ Universal transfer successful!\n\nFrom: ${params.fromEmail || 'Master'} (${params.fromAccountType})\nTo: ${params.toEmail || 'Master'} (${params.toAccountType})\nAsset: ${params.asset}\nAmount: ${params.amount}\n\nTransaction: ${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `❌ Failed to transfer: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `❌ Failed to transfer: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/transferToMaster.ts b/src/tools/binance-sub-account/transferToMaster.ts index ea2304c0..dce01406 100644 --- a/src/tools/binance-sub-account/transferToMaster.ts +++ b/src/tools/binance-sub-account/transferToMaster.ts @@ -1,41 +1,44 @@ // src/tools/binance-sub-account/transferToMaster.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { subAccountApiClient } from "../../config/binanceClient.js" export function registerBinanceSubAccountTransferToMaster(server: McpServer) { - server.tool( - "BinanceSubAccountTransferToMaster", - "Transfer assets from sub-account to master account (SPOT). Must be called from sub-account API key.", - { - asset: z.string().describe("Asset to transfer (e.g., BTC, USDT)"), - amount: z.number().describe("Amount to transfer"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ asset, amount, recvWindow }) => { - try { - const params: any = { asset, amount }; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await subAccountApiClient.transferToMaster(params); + server.tool( + "BinanceSubAccountTransferToMaster", + "Transfer assets from sub-account to master account (SPOT). Must be called from sub-account API key.", + { + asset: z.string().describe("Asset to transfer (e.g., BTC, USDT)"), + amount: z.number().describe("Amount to transfer"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ asset, amount, recvWindow }) => { + try { + const params: any = { asset, amount } + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await subAccountApiClient.transferToMaster(params) + + return { + content: [ + { + type: "text", + text: `Transferred ${amount} ${asset} to master account. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Transferred ${amount} ${asset} to master account. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to transfer to master account: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to transfer to master account: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/transferToSubAccount.ts b/src/tools/binance-sub-account/transferToSubAccount.ts index 5109ea81..4e22c825 100644 --- a/src/tools/binance-sub-account/transferToSubAccount.ts +++ b/src/tools/binance-sub-account/transferToSubAccount.ts @@ -1,42 +1,43 @@ // src/tools/binance-sub-account/transferToSubAccount.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { subAccountApiClient } from "../../config/binanceClient.js" export function registerBinanceSubAccountTransferToSub(server: McpServer) { - server.tool( - "BinanceSubAccountTransferToSub", - "Transfer assets from master account to sub-account (SPOT).", - { - toEmail: z.string().describe("Sub-account email to transfer to"), - asset: z.string().describe("Asset to transfer (e.g., BTC, USDT)"), - amount: z.number().describe("Amount to transfer"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ toEmail, asset, amount, recvWindow }) => { - try { - const params: any = { toEmail, asset, amount }; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await subAccountApiClient.transferToSubAccount(params); + server.tool( + "BinanceSubAccountTransferToSub", + "Transfer assets from master account to sub-account (SPOT).", + { + toEmail: z.string().describe("Sub-account email to transfer to"), + asset: z.string().describe("Asset to transfer (e.g., BTC, USDT)"), + amount: z.number().describe("Amount to transfer"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ toEmail, asset, amount, recvWindow }) => { + try { + const params: any = { toEmail, asset, amount } + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await subAccountApiClient.transferToSubAccount(params) + + return { + content: [ + { + type: "text", + text: `Transferred ${amount} ${asset} to ${toEmail}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Transferred ${amount} ${asset} to ${toEmail}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to transfer to sub-account: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to transfer to sub-account: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/universalTransfer.ts b/src/tools/binance-sub-account/universalTransfer.ts index 358fce2b..b167ac89 100644 --- a/src/tools/binance-sub-account/universalTransfer.ts +++ b/src/tools/binance-sub-account/universalTransfer.ts @@ -1,49 +1,70 @@ // src/tools/binance-sub-account/universalTransfer.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { subAccountApiClient } from "../../config/binanceClient.js" export function registerBinanceSubAccountUniversalTransfer(server: McpServer) { - server.tool( - "BinanceSubAccountUniversalTransfer", - "Universal transfer between sub-accounts or between master and sub-accounts.", - { - fromEmail: z.string().optional().describe("Sender email (leave empty for master account)"), - toEmail: z.string().optional().describe("Recipient email (leave empty for master account)"), - fromAccountType: z.string().describe("Sender account type: SPOT, USDT_FUTURE, COIN_FUTURE, MARGIN, ISOLATED_MARGIN"), - toAccountType: z.string().describe("Recipient account type: SPOT, USDT_FUTURE, COIN_FUTURE, MARGIN, ISOLATED_MARGIN"), - asset: z.string().describe("Asset to transfer"), - amount: z.number().describe("Amount to transfer"), - symbol: z.string().optional().describe("Required when fromAccountType or toAccountType is ISOLATED_MARGIN"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ fromEmail, toEmail, fromAccountType, toAccountType, asset, amount, symbol, recvWindow }) => { - try { - const params: any = { fromAccountType, toAccountType, asset, amount }; - if (fromEmail !== undefined) params.fromEmail = fromEmail; - if (toEmail !== undefined) params.toEmail = toEmail; - if (symbol !== undefined) params.symbol = symbol; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await subAccountApiClient.subAccountUniversalTransfer(params); + server.tool( + "BinanceSubAccountUniversalTransfer", + "Universal transfer between sub-accounts or between master and sub-accounts.", + { + fromEmail: z.string().optional().describe("Sender email (leave empty for master account)"), + toEmail: z.string().optional().describe("Recipient email (leave empty for master account)"), + fromAccountType: z + .string() + .describe("Sender account type: SPOT, USDT_FUTURE, COIN_FUTURE, MARGIN, ISOLATED_MARGIN"), + toAccountType: z + .string() + .describe( + "Recipient account type: SPOT, USDT_FUTURE, COIN_FUTURE, MARGIN, ISOLATED_MARGIN", + ), + asset: z.string().describe("Asset to transfer"), + amount: z.number().describe("Amount to transfer"), + symbol: z + .string() + .optional() + .describe("Required when fromAccountType or toAccountType is ISOLATED_MARGIN"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ + fromEmail, + toEmail, + fromAccountType, + toAccountType, + asset, + amount, + symbol, + recvWindow, + }) => { + try { + const params: any = { fromAccountType, toAccountType, asset, amount } + if (fromEmail !== undefined) params.fromEmail = fromEmail + if (toEmail !== undefined) params.toEmail = toEmail + if (symbol !== undefined) params.symbol = symbol + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await subAccountApiClient.subAccountUniversalTransfer(params) + + return { + content: [ + { + type: "text", + text: `Universal transfer completed: ${amount} ${asset}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Universal transfer completed: ${amount} ${asset}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to execute universal transfer: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to execute universal transfer: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-sub-account/updateIpRestriction.ts b/src/tools/binance-sub-account/updateIpRestriction.ts index a3b73be1..c98e520c 100644 --- a/src/tools/binance-sub-account/updateIpRestriction.ts +++ b/src/tools/binance-sub-account/updateIpRestriction.ts @@ -1,44 +1,45 @@ // src/tools/binance-sub-account/updateIpRestriction.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { subAccountApiClient } from "../../config/binanceClient.js" export function registerBinanceSubAccountUpdateIpRestriction(server: McpServer) { - server.tool( - "BinanceSubAccountUpdateIpRestriction", - "Update IP restriction for a sub-account API key.", - { - subAccountId: z.string().describe("Sub-account ID"), - subAccountApiKey: z.string().describe("Sub-account API key"), - status: z.string().describe("IP restriction status: 1 - Restrict by IP, 2 - Unrestrict"), - ipAddress: z.string().optional().describe("IP address (comma-separated for multiple)"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ subAccountId, subAccountApiKey, status, ipAddress, recvWindow }) => { - try { - const params: any = { subAccountId, subAccountApiKey, status }; - if (ipAddress !== undefined) params.ipAddress = ipAddress; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await subAccountApiClient.updateSubAccountApiKeyIpRestriction(params); + server.tool( + "BinanceSubAccountUpdateIpRestriction", + "Update IP restriction for a sub-account API key.", + { + subAccountId: z.string().describe("Sub-account ID"), + subAccountApiKey: z.string().describe("Sub-account API key"), + status: z.string().describe("IP restriction status: 1 - Restrict by IP, 2 - Unrestrict"), + ipAddress: z.string().optional().describe("IP address (comma-separated for multiple)"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ subAccountId, subAccountApiKey, status, ipAddress, recvWindow }) => { + try { + const params: any = { subAccountId, subAccountApiKey, status } + if (ipAddress !== undefined) params.ipAddress = ipAddress + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await subAccountApiClient.updateSubAccountApiKeyIpRestriction(params) + + return { + content: [ + { + type: "text", + text: `IP restriction updated for sub-account API key. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `IP restriction updated for sub-account API key. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to update IP restriction: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to update IP restriction: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-vip-loan/index.ts b/src/tools/binance-vip-loan/index.ts index a94ffa9e..71d157fb 100644 --- a/src/tools/binance-vip-loan/index.ts +++ b/src/tools/binance-vip-loan/index.ts @@ -1,11 +1,12 @@ // src/tools/binance-vip-loan/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceVipLoanMarketApiTools } from "./market-api/index.js"; -import { registerBinanceVipLoanTradeApiTools } from "./trade-api/index.js"; -import { registerBinanceVipLoanUserInformationApiTools } from "./userInformation-api/index.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceVipLoanMarketApiTools } from "./market-api/index.js" +import { registerBinanceVipLoanTradeApiTools } from "./trade-api/index.js" +import { registerBinanceVipLoanUserInformationApiTools } from "./userInformation-api/index.js" export function registerBinanceVipLoanTools(server: McpServer) { - registerBinanceVipLoanMarketApiTools(server); - registerBinanceVipLoanTradeApiTools(server); - registerBinanceVipLoanUserInformationApiTools(server); + registerBinanceVipLoanMarketApiTools(server) + registerBinanceVipLoanTradeApiTools(server) + registerBinanceVipLoanUserInformationApiTools(server) } diff --git a/src/tools/binance-vip-loan/market-api/getBorrowInterestRate.ts b/src/tools/binance-vip-loan/market-api/getBorrowInterestRate.ts index 51888e73..bececb1b 100644 --- a/src/tools/binance-vip-loan/market-api/getBorrowInterestRate.ts +++ b/src/tools/binance-vip-loan/market-api/getBorrowInterestRate.ts @@ -1,47 +1,50 @@ // src/tools/binance-vip-loan/market-api/getBorrowInterestRate.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { vipLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { vipLoanClient } from "../../../config/binanceClient.js" export function registerBinanceGetBorrowInterestRate(server: McpServer) { - server.tool( - "BinanceGetBorrowInterestRate", - "Retrieves the interest rates for borrowing assets. It provides both daily and yearly interest rates for multiple assets (e.g., BUSD, BTC). You can specify the assets by using a comma-separated list.", - { - loanCoin: z.string().min(1).describe("Max 10 assets, multiple split by ','"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await vipLoanClient.restAPI.getBorrowInterestRate({ - loanCoin: params.loanCoin, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetBorrowInterestRate", + "Retrieves the interest rates for borrowing assets. It provides both daily and yearly interest rates for multiple assets (e.g., BUSD, BTC). You can specify the assets by using a comma-separated list.", + { + loanCoin: z.string().min(1).describe("Max 10 assets, multiple split by ','"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await vipLoanClient.restAPI.getBorrowInterestRate({ + loanCoin: params.loanCoin, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved the interest rates for borrowing assets. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved the interest rates for borrowing assets. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve the interest rates for borrowing assets. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve the interest rates for borrowing assets. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-vip-loan/market-api/getCollateralAssetData.ts b/src/tools/binance-vip-loan/market-api/getCollateralAssetData.ts index 5f9c7a34..b3ac53ff 100644 --- a/src/tools/binance-vip-loan/market-api/getCollateralAssetData.ts +++ b/src/tools/binance-vip-loan/market-api/getCollateralAssetData.ts @@ -1,47 +1,50 @@ // src/tools/binance-vip-loan/market-api/getCollateralAssetData.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { vipLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { vipLoanClient } from "../../../config/binanceClient.js" export function registerBinanceGetCollateralAssetData(server: McpServer) { - server.tool( - "BinanceGetCollateralAssetData", - "Retrieves information about collateral assets, including collateral ratios and range values for different tiers of collateral. The ratios are used to determine the collateral requirement for various levels of borrowing.", - { - collateralCoin: z.string().optional().describe("Optional: Coin used as collateral"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await vipLoanClient.restAPI.getCollateralAssetData({ - ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetCollateralAssetData", + "Retrieves information about collateral assets, including collateral ratios and range values for different tiers of collateral. The ratios are used to determine the collateral requirement for various levels of borrowing.", + { + collateralCoin: z.string().optional().describe("Optional: Coin used as collateral"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await vipLoanClient.restAPI.getCollateralAssetData({ + ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved information about collateral assets. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved information about collateral assets. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve information about collateral assets. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve information about collateral assets. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-vip-loan/market-api/getLoanableAssetsData.ts b/src/tools/binance-vip-loan/market-api/getLoanableAssetsData.ts index 5c256508..69acff8d 100644 --- a/src/tools/binance-vip-loan/market-api/getLoanableAssetsData.ts +++ b/src/tools/binance-vip-loan/market-api/getLoanableAssetsData.ts @@ -1,49 +1,56 @@ // src/tools/binance-vip-loan/market-api/getLoanableAssetsData.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { vipLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { vipLoanClient } from "../../../config/binanceClient.js" export function registerBinanceGetLoanableAssetsData(server: McpServer) { - server.tool( - "BinanceGetLoanableAssetsData", - "Retrieves interest rates and borrowing limits for loanable assets. The borrow limit is expressed in USD. You can request information for specific assets or leave it empty to query all available assets.", - { - loanCoin: z.string().optional().describe("Optional: Coin for the loan"), - vipLevel: z.number().int().optional().describe("Optional: User's VIP level (default is user's vip level)"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await vipLoanClient.restAPI.getLoanableAssetsData({ - ...(params.loanCoin && { loanCoin: params.loanCoin }), - ...(params.vipLevel && { vipLevel: params.vipLevel }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetLoanableAssetsData", + "Retrieves interest rates and borrowing limits for loanable assets. The borrow limit is expressed in USD. You can request information for specific assets or leave it empty to query all available assets.", + { + loanCoin: z.string().optional().describe("Optional: Coin for the loan"), + vipLevel: z + .number() + .int() + .optional() + .describe("Optional: User's VIP level (default is user's vip level)"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await vipLoanClient.restAPI.getLoanableAssetsData({ + ...(params.loanCoin && { loanCoin: params.loanCoin }), + ...(params.vipLevel && { vipLevel: params.vipLevel }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved interest rates and borrowing limits for loanable assets. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved interest rates and borrowing limits for loanable assets. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve interest rates and borrowing limits for loanable assets. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve interest rates and borrowing limits for loanable assets. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-vip-loan/market-api/index.ts b/src/tools/binance-vip-loan/market-api/index.ts index 3e0ee81a..ffc74390 100644 --- a/src/tools/binance-vip-loan/market-api/index.ts +++ b/src/tools/binance-vip-loan/market-api/index.ts @@ -1,11 +1,12 @@ // src/tools/binance-vip-loan/market-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetBorrowInterestRate } from "./getBorrowInterestRate.js"; -import { registerBinanceGetLoanableAssetsData } from "./getLoanableAssetsData.js"; -import { registerBinanceGetCollateralAssetData } from "./getCollateralAssetData.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceGetBorrowInterestRate } from "./getBorrowInterestRate.js" +import { registerBinanceGetCollateralAssetData } from "./getCollateralAssetData.js" +import { registerBinanceGetLoanableAssetsData } from "./getLoanableAssetsData.js" export function registerBinanceVipLoanMarketApiTools(server: McpServer) { - registerBinanceGetBorrowInterestRate(server); - registerBinanceGetCollateralAssetData(server); - registerBinanceGetLoanableAssetsData(server); + registerBinanceGetBorrowInterestRate(server) + registerBinanceGetCollateralAssetData(server) + registerBinanceGetLoanableAssetsData(server) } diff --git a/src/tools/binance-vip-loan/trade-api/index.ts b/src/tools/binance-vip-loan/trade-api/index.ts index 7395b3ff..85a97036 100644 --- a/src/tools/binance-vip-loan/trade-api/index.ts +++ b/src/tools/binance-vip-loan/trade-api/index.ts @@ -1,11 +1,12 @@ // src/tools/binance-vip-loan/trade-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceVipLoanRenew } from "./vipLoanRenew.js"; -import { registerBinanceVipLoanRepay } from "./vipLoanRepay.js"; -import { registerBinanceVipLoanBorrow } from "./vipLoanBorrow.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceVipLoanBorrow } from "./vipLoanBorrow.js" +import { registerBinanceVipLoanRenew } from "./vipLoanRenew.js" +import { registerBinanceVipLoanRepay } from "./vipLoanRepay.js" export function registerBinanceVipLoanTradeApiTools(server: McpServer) { - registerBinanceVipLoanRenew(server); - registerBinanceVipLoanRepay(server); - registerBinanceVipLoanBorrow(server); + registerBinanceVipLoanRenew(server) + registerBinanceVipLoanRepay(server) + registerBinanceVipLoanBorrow(server) } diff --git a/src/tools/binance-vip-loan/trade-api/vipLoanBorrow.ts b/src/tools/binance-vip-loan/trade-api/vipLoanBorrow.ts index 2dc82b5f..032e83c4 100644 --- a/src/tools/binance-vip-loan/trade-api/vipLoanBorrow.ts +++ b/src/tools/binance-vip-loan/trade-api/vipLoanBorrow.ts @@ -1,59 +1,69 @@ // src/tools/binance-vip-loan/trade-api/vipLoanBorrow.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { vipLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { vipLoanClient } from "../../../config/binanceClient.js" export function registerBinanceVipLoanBorrow(server: McpServer) { - server.tool( - "BinanceVipLoanBorrow", - "Allow users (master account only) to apply for a loan by pledging collateral. Users specify the coin they want to borrow, the amount, and the collateral details.", - { - loanAccountId: z.number().int().describe("Loan account ID"), - loanCoin: z.string().min(1).describe("Loan coin (e.g., BTC, ETH)"), - loanAmount: z.number().describe("Loan amount as decimal"), - collateralAccountId: z.string().min(1).describe("Collateral account IDs, separated by commas"), - collateralCoin: z.string().min(1).describe("Collateral coins, separated by commas"), - isFlexibleRate: z.boolean().describe("TRUE: flexible rate, FALSE: fixed rate. Default: TRUE"), - loanTerm: z.number().int().optional().describe("Loan term (only required if fixed rate, e.g., 30/60 days)"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await vipLoanClient.restAPI.vipLoanBorrow({ - loanAccountId: params.loanAccountId, - loanCoin: params.loanCoin, - loanAmount: params.loanAmount, - collateralAccountId: params.collateralAccountId, - collateralCoin: params.collateralCoin, - isFlexibleRate: params.isFlexibleRate, - ...(params.loanTerm !== undefined && { loanTerm: params.loanTerm }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceVipLoanBorrow", + "Allow users (master account only) to apply for a loan by pledging collateral. Users specify the coin they want to borrow, the amount, and the collateral details.", + { + loanAccountId: z.number().int().describe("Loan account ID"), + loanCoin: z.string().min(1).describe("Loan coin (e.g., BTC, ETH)"), + loanAmount: z.number().describe("Loan amount as decimal"), + collateralAccountId: z + .string() + .min(1) + .describe("Collateral account IDs, separated by commas"), + collateralCoin: z.string().min(1).describe("Collateral coins, separated by commas"), + isFlexibleRate: z.boolean().describe("TRUE: flexible rate, FALSE: fixed rate. Default: TRUE"), + loanTerm: z + .number() + .int() + .optional() + .describe("Loan term (only required if fixed rate, e.g., 30/60 days)"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await vipLoanClient.restAPI.vipLoanBorrow({ + loanAccountId: params.loanAccountId, + loanCoin: params.loanCoin, + loanAmount: params.loanAmount, + collateralAccountId: params.collateralAccountId, + collateralCoin: params.collateralCoin, + isFlexibleRate: params.isFlexibleRate, + ...(params.loanTerm !== undefined && { loanTerm: params.loanTerm }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully apply for a loan by pledging collateral. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully apply for a loan by pledging collateral. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to apply for a loan by pledging collateral. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to apply for a loan by pledging collateral. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-vip-loan/trade-api/vipLoanRenew.ts b/src/tools/binance-vip-loan/trade-api/vipLoanRenew.ts index 50e7491c..2699fbb4 100644 --- a/src/tools/binance-vip-loan/trade-api/vipLoanRenew.ts +++ b/src/tools/binance-vip-loan/trade-api/vipLoanRenew.ts @@ -1,46 +1,55 @@ // src/tools/binance-vip-loan/trade-api/vipLoanRenew.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { vipLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { vipLoanClient } from "../../../config/binanceClient.js" export function registerBinanceVipLoanRenew(server: McpServer) { - server.tool( - "BinanceVipLoanRenew", - "Allow VIP users to renew an existing VIP loan for a specified term, either 30 or 60 days.", - { - orderId: z.number().int().describe("The order ID for the loan request"), - loanTerm: z.union([z.literal(30), z.literal(60)]).describe("Loan term in days, either 30 or 60"), - recvWindow: z.number().int().optional().describe("Optional: Time window for request validity") - }, - async (params) => { - try { - const response = await vipLoanClient.restAPI.vipLoanRenew({ - orderId: params.orderId, - loanTerm: params.loanTerm, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - const data = await response.data(); + server.tool( + "BinanceVipLoanRenew", + "Allow VIP users to renew an existing VIP loan for a specified term, either 30 or 60 days.", + { + orderId: z.number().int().describe("The order ID for the loan request"), + loanTerm: z + .union([z.literal(30), z.literal(60)]) + .describe("Loan term in days, either 30 or 60"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional: Time window for request validity"), + }, + async (params) => { + try { + const response = await vipLoanClient.restAPI.vipLoanRenew({ + orderId: params.orderId, + loanTerm: params.loanTerm, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully renew an existing VIP loan. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully renew an existing VIP loan. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to renew an existing VIP loan. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to renew an existing VIP loan. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-vip-loan/trade-api/vipLoanRepay.ts b/src/tools/binance-vip-loan/trade-api/vipLoanRepay.ts index e6389ef0..8f8d7041 100644 --- a/src/tools/binance-vip-loan/trade-api/vipLoanRepay.ts +++ b/src/tools/binance-vip-loan/trade-api/vipLoanRepay.ts @@ -1,47 +1,50 @@ // src/tools/binance-vip-loan/trade-api/vipLoanRepay.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { vipLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { vipLoanClient } from "../../../config/binanceClient.js" export function registerBinanceVipLoanRepay(server: McpServer) { - server.tool( - "BinanceVipLoanRepay", - "Allow VIP users to repay a specified amount of their active loan, partially or fully. It updates the remaining principal and interest, and provides the repayment status.", - { - orderId: z.number().int().describe("Order ID of the loan request"), - amount: z.number().describe("Amount to be processed (decimal allowed)"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await vipLoanClient.restAPI.vipLoanRepay({ - orderId: params.orderId, - amount: params.amount, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceVipLoanRepay", + "Allow VIP users to repay a specified amount of their active loan, partially or fully. It updates the remaining principal and interest, and provides the repayment status.", + { + orderId: z.number().int().describe("Order ID of the loan request"), + amount: z.number().describe("Amount to be processed (decimal allowed)"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await vipLoanClient.restAPI.vipLoanRepay({ + orderId: params.orderId, + amount: params.amount, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully repay the active loan. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully repay the active loan. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to repay the active loan. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to repay the active loan. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-vip-loan/userInformation-api/checkVIPLoanCollateralAccount.ts b/src/tools/binance-vip-loan/userInformation-api/checkVIPLoanCollateralAccount.ts index 841d583e..ca85b235 100644 --- a/src/tools/binance-vip-loan/userInformation-api/checkVIPLoanCollateralAccount.ts +++ b/src/tools/binance-vip-loan/userInformation-api/checkVIPLoanCollateralAccount.ts @@ -1,51 +1,54 @@ // src/tools/binance-vip-loan/userInformation-api/checkVIPLoanCollateralAccount.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { vipLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { vipLoanClient } from "../../../config/binanceClient.js" export function registerBinanceCheckVIPLoanCollateralAccount(server: McpServer) { - server.tool( - "BinanceCheckVIPLoanCollateralAccount", - "Allow users to check their collateral accounts and the coins held as collateral. If the logged-in account is a loan account, it will return all associated collateral accounts. If it's a collateral account, it returns details of the current account only.", - { - orderId: z.number().int().optional().describe("Optional order ID"), - collateralAccountId: z.number().int().optional().describe("Optional collateral account ID"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await vipLoanClient.restAPI.checkVIPLoanCollateralAccount({ - ...(params.orderId !== undefined && { orderId: params.orderId }), - ...(params.collateralAccountId !== undefined && { - collateralAccountId: params.collateralAccountId - }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceCheckVIPLoanCollateralAccount", + "Allow users to check their collateral accounts and the coins held as collateral. If the logged-in account is a loan account, it will return all associated collateral accounts. If it's a collateral account, it returns details of the current account only.", + { + orderId: z.number().int().optional().describe("Optional order ID"), + collateralAccountId: z.number().int().optional().describe("Optional collateral account ID"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await vipLoanClient.restAPI.checkVIPLoanCollateralAccount({ + ...(params.orderId !== undefined && { orderId: params.orderId }), + ...(params.collateralAccountId !== undefined && { + collateralAccountId: params.collateralAccountId, + }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved collateral accounts and the coins held as collateral. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved collateral accounts and the coins held as collateral. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve collateral accounts and the coins held as collateral. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve collateral accounts and the coins held as collateral. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-vip-loan/userInformation-api/getVIPLoanOngoingOrders.ts b/src/tools/binance-vip-loan/userInformation-api/getVIPLoanOngoingOrders.ts index 70c69c6f..4effee4e 100644 --- a/src/tools/binance-vip-loan/userInformation-api/getVIPLoanOngoingOrders.ts +++ b/src/tools/binance-vip-loan/userInformation-api/getVIPLoanOngoingOrders.ts @@ -1,59 +1,74 @@ // src/tools/binance-vip-loan/userInformation-api/getVIPLoanOngoingOrders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { vipLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { vipLoanClient } from "../../../config/binanceClient.js" export function registerBinanceGetVIPLoanOngoingOrders(server: McpServer) { - server.tool( - "BinanceGetVIPLoanOngoingOrders", - "Allows VIP users to retrieve a list of their current active loan orders. Users can filter results by loan coin, collateral coin, order ID, or collateral account ID.", - { - orderId: z.number().int().optional().describe("Optional order ID"), - collateralAccountId: z.number().int().optional().describe("Optional collateral account ID"), - loanCoin: z.string().optional().describe("Optional loan coin"), - collateralCoin: z.string().optional().describe("Optional collateral coin"), - current: z.number().int().min(1).max(1000).optional().describe("Current page, start from 1, max 1000"), - limit: z.number().int().min(1).max(100).optional().describe("Results per page, default 10, max 100"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await vipLoanClient.restAPI.getVIPLoanOngoingOrders({ - ...(params.orderId !== undefined && { orderId: params.orderId }), - ...(params.collateralAccountId !== undefined && { - collateralAccountId: params.collateralAccountId - }), - ...(params.loanCoin !== undefined && { loanCoin: params.loanCoin }), - ...(params.collateralCoin !== undefined && { collateralCoin: params.collateralCoin }), - ...(params.current !== undefined && { current: params.current }), - ...(params.limit !== undefined && { limit: params.limit }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceGetVIPLoanOngoingOrders", + "Allows VIP users to retrieve a list of their current active loan orders. Users can filter results by loan coin, collateral coin, order ID, or collateral account ID.", + { + orderId: z.number().int().optional().describe("Optional order ID"), + collateralAccountId: z.number().int().optional().describe("Optional collateral account ID"), + loanCoin: z.string().optional().describe("Optional loan coin"), + collateralCoin: z.string().optional().describe("Optional collateral coin"), + current: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .describe("Current page, start from 1, max 1000"), + limit: z + .number() + .int() + .min(1) + .max(100) + .optional() + .describe("Results per page, default 10, max 100"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await vipLoanClient.restAPI.getVIPLoanOngoingOrders({ + ...(params.orderId !== undefined && { orderId: params.orderId }), + ...(params.collateralAccountId !== undefined && { + collateralAccountId: params.collateralAccountId, + }), + ...(params.loanCoin !== undefined && { loanCoin: params.loanCoin }), + ...(params.collateralCoin !== undefined && { collateralCoin: params.collateralCoin }), + ...(params.current !== undefined && { current: params.current }), + ...(params.limit !== undefined && { limit: params.limit }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved list of their current active loan orders. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved list of their current active loan orders. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve list of their current active loan orders. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve list of their current active loan orders. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-vip-loan/userInformation-api/index.ts b/src/tools/binance-vip-loan/userInformation-api/index.ts index 58bad6e4..82cd64ab 100644 --- a/src/tools/binance-vip-loan/userInformation-api/index.ts +++ b/src/tools/binance-vip-loan/userInformation-api/index.ts @@ -1,11 +1,12 @@ // src/tools/binance-vip-loan/userInformation-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceCheckVIPLoanCollateralAccount } from "./checkVIPLoanCollateralAccount.js"; -import { registerBinanceGetVIPLoanOngoingOrders } from "./getVIPLoanOngoingOrders.js"; -import { registerBinanceQueryApplicationStatus } from "./queryApplicationStatus.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceCheckVIPLoanCollateralAccount } from "./checkVIPLoanCollateralAccount.js" +import { registerBinanceGetVIPLoanOngoingOrders } from "./getVIPLoanOngoingOrders.js" +import { registerBinanceQueryApplicationStatus } from "./queryApplicationStatus.js" export function registerBinanceVipLoanUserInformationApiTools(server: McpServer) { - registerBinanceCheckVIPLoanCollateralAccount(server); - registerBinanceGetVIPLoanOngoingOrders(server); - registerBinanceQueryApplicationStatus(server); + registerBinanceCheckVIPLoanCollateralAccount(server) + registerBinanceGetVIPLoanOngoingOrders(server) + registerBinanceQueryApplicationStatus(server) } diff --git a/src/tools/binance-vip-loan/userInformation-api/queryApplicationStatus.ts b/src/tools/binance-vip-loan/userInformation-api/queryApplicationStatus.ts index 7d5e5a05..aa8a6295 100644 --- a/src/tools/binance-vip-loan/userInformation-api/queryApplicationStatus.ts +++ b/src/tools/binance-vip-loan/userInformation-api/queryApplicationStatus.ts @@ -1,55 +1,58 @@ // src/tools/binance-vip-loan/userInformation-api/queryApplicationStatus.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { vipLoanClient } from "../../../config/binanceClient.js"; -import { z } from "zod"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { vipLoanClient } from "../../../config/binanceClient.js" export function registerBinanceQueryApplicationStatus(server: McpServer) { - server.tool( - "BinanceQueryApplicationStatus", - "Allows VIP users to check the status of their loan applications. It returns a list of loan requests with details such as loan coin, amount, term, collateral details, and current application status", - { - current: z - .number() - .int() - .min(1) - .max(1000) - .optional() - .describe("Currently querying page. Start from 1, default 1, max 1000"), - limit: z.number().int().min(1).max(100).optional().describe("Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity") - }, - async (params) => { - try { - const response = await vipLoanClient.restAPI.queryApplicationStatus({ - ...(params.current !== undefined && { current: params.current }), - ...(params.limit !== undefined && { limit: params.limit }), - ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }) - }); + server.tool( + "BinanceQueryApplicationStatus", + "Allows VIP users to check the status of their loan applications. It returns a list of loan requests with details such as loan coin, amount, term, collateral details, and current application status", + { + current: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .describe("Currently querying page. Start from 1, default 1, max 1000"), + limit: z.number().int().min(1).max(100).optional().describe("Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + }, + async (params) => { + try { + const response = await vipLoanClient.restAPI.queryApplicationStatus({ + ...(params.current !== undefined && { current: params.current }), + ...(params.limit !== undefined && { limit: params.limit }), + ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), + }) - const data = await response.data(); + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Successfully retrieved status of their loan applications. Response: ${JSON.stringify( + data, + )}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Successfully retrieved status of their loan applications. Response: ${JSON.stringify( - data - )}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { - type: "text", - text: `Failed to retrieve status of their loan applications.. ${errorMessage}` - } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve status of their loan applications.. ${errorMessage}`, + }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/binance-wallet/account-api/accountApiTradingStatus.ts b/src/tools/binance-wallet/account-api/accountApiTradingStatus.ts index d5ed7e7b..c24c0226 100644 --- a/src/tools/binance-wallet/account-api/accountApiTradingStatus.ts +++ b/src/tools/binance-wallet/account-api/accountApiTradingStatus.ts @@ -1,40 +1,46 @@ // src/tools/binance-wallet/account-api/accountApiTradingStatus.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletAccountApiTradingStatus(server: McpServer) { - server.tool( - "BinanceWalletAccountApiTradingStatus", - "Get account API trading status.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: any = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.accountApiTradingStatus(params); - const data = await response.data(); + server.tool( + "BinanceWalletAccountApiTradingStatus", + "Get account API trading status.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: any = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.accountApiTradingStatus(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved account API trading status. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved account API trading status. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve account API trading status: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve account API trading status: ${errorMessage}`, + }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/account-api/accountInfo.ts b/src/tools/binance-wallet/account-api/accountInfo.ts index 4b426dc4..39b964df 100644 --- a/src/tools/binance-wallet/account-api/accountInfo.ts +++ b/src/tools/binance-wallet/account-api/accountInfo.ts @@ -1,40 +1,46 @@ // src/tools/binance-wallet/account-api/accountInfo.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletAccountInfo(server: McpServer) { - server.tool( - "BinanceWalletAccountInfo", - "Get Binance Wallet account information.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: any = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.accountInfo(params); - const data = await response.data(); + server.tool( + "BinanceWalletAccountInfo", + "Get Binance Wallet account information.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: any = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.accountInfo(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved wallet account information. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved wallet account information. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve wallet account information: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve wallet account information: ${errorMessage}`, + }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/account-api/accountStatus.ts b/src/tools/binance-wallet/account-api/accountStatus.ts index e5efdcec..4cefe42b 100644 --- a/src/tools/binance-wallet/account-api/accountStatus.ts +++ b/src/tools/binance-wallet/account-api/accountStatus.ts @@ -1,40 +1,43 @@ // src/tools/binance-wallet/account-api/accountStatus.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletAccountStatus(server: McpServer) { - server.tool( - "BinanceWalletAccountStatus", - "Get Binance Wallet account status.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: any = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.accountStatus(params); - const data = await response.data(); + server.tool( + "BinanceWalletAccountStatus", + "Get Binance Wallet account status.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: any = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.accountStatus(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved wallet account status. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved wallet account status. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve wallet account status: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve wallet account status: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/account-api/dailyAccountSnapshot.ts b/src/tools/binance-wallet/account-api/dailyAccountSnapshot.ts index 8bfde6f8..145e3db8 100644 --- a/src/tools/binance-wallet/account-api/dailyAccountSnapshot.ts +++ b/src/tools/binance-wallet/account-api/dailyAccountSnapshot.ts @@ -1,47 +1,50 @@ // src/tools/binance-wallet/account-api/dailyAccountSnapshot.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletDailyAccountSnapshot(server: McpServer) { - server.tool( - "BinanceWalletDailyAccountSnapshot", - "Get daily account snapshot.", - { - type: z.string().describe("The account type (e.g., SPOT, MARGIN, FUTURES)"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 7, max 30"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ type, startTime, endTime, limit, recvWindow }) => { - try { - const params: any = { type }; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.dailyAccountSnapshot(params); - const data = await response.data(); + server.tool( + "BinanceWalletDailyAccountSnapshot", + "Get daily account snapshot.", + { + type: z.string().describe("The account type (e.g., SPOT, MARGIN, FUTURES)"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 7, max 30"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ type, startTime, endTime, limit, recvWindow }) => { + try { + const params: any = { type } + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.dailyAccountSnapshot(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved daily account snapshot for ${type}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved daily account snapshot for ${type}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve daily account snapshot: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve daily account snapshot: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/account-api/disableFastWithdrawSwitch.ts b/src/tools/binance-wallet/account-api/disableFastWithdrawSwitch.ts index 5e0e8106..f348aaa2 100644 --- a/src/tools/binance-wallet/account-api/disableFastWithdrawSwitch.ts +++ b/src/tools/binance-wallet/account-api/disableFastWithdrawSwitch.ts @@ -1,40 +1,43 @@ // src/tools/binance-wallet/account-api/disableFastWithdrawSwitch.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletDisableFastWithdrawSwitch(server: McpServer) { - server.tool( - "BinanceWalletDisableFastWithdrawSwitch", - "Disable fast withdraw switch.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: any = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.disableFastWithdrawSwitch(params); - const data = await response.data(); + server.tool( + "BinanceWalletDisableFastWithdrawSwitch", + "Disable fast withdraw switch.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: any = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.disableFastWithdrawSwitch(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Disabled fast withdraw switch. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Disabled fast withdraw switch. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to disable fast withdraw switch: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to disable fast withdraw switch: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/account-api/enableFastWithdrawSwitch.ts b/src/tools/binance-wallet/account-api/enableFastWithdrawSwitch.ts index d6679332..08b0430f 100644 --- a/src/tools/binance-wallet/account-api/enableFastWithdrawSwitch.ts +++ b/src/tools/binance-wallet/account-api/enableFastWithdrawSwitch.ts @@ -1,40 +1,43 @@ // src/tools/binance-wallet/account-api/enableFastWithdrawSwitch.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletEnableFastWithdrawSwitch(server: McpServer) { - server.tool( - "BinanceWalletEnableFastWithdrawSwitch", - "Enable fast withdraw switch.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: any = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.enableFastWithdrawSwitch(params); - const data = await response.data(); + server.tool( + "BinanceWalletEnableFastWithdrawSwitch", + "Enable fast withdraw switch.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: any = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.enableFastWithdrawSwitch(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Enabled fast withdraw switch. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Enabled fast withdraw switch. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to enable fast withdraw switch: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to enable fast withdraw switch: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/account-api/getApiKeyPermission.ts b/src/tools/binance-wallet/account-api/getApiKeyPermission.ts index 773e8175..782053fb 100644 --- a/src/tools/binance-wallet/account-api/getApiKeyPermission.ts +++ b/src/tools/binance-wallet/account-api/getApiKeyPermission.ts @@ -1,40 +1,43 @@ // src/tools/binance-wallet/account-api/getApiKeyPermission.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletGetApiKeyPermission(server: McpServer) { - server.tool( - "BinanceWalletGetApiKeyPermission", - "Get API key permission.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: any = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.getApiKeyPermission(params); - const data = await response.data(); + server.tool( + "BinanceWalletGetApiKeyPermission", + "Get API key permission.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: any = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.getApiKeyPermission(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved API key permission. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved API key permission. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve API key permission: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve API key permission: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/account-api/index.ts b/src/tools/binance-wallet/account-api/index.ts index 0b8cfdf0..c01341a4 100644 --- a/src/tools/binance-wallet/account-api/index.ts +++ b/src/tools/binance-wallet/account-api/index.ts @@ -1,20 +1,20 @@ // src/tools/binance-wallet/account-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceWalletDailyAccountSnapshot } from "./dailyAccountSnapshot.js"; -import { registerBinanceWalletGetApiKeyPermission } from "./getApiKeyPermission.js"; -import { registerBinanceWalletAccountInfo } from "./accountInfo.js"; -import { registerBinanceWalletAccountStatus } from "./accountStatus.js"; -import { registerBinanceWalletAccountApiTradingStatus } from "./accountApiTradingStatus.js"; -import { registerBinanceWalletEnableFastWithdrawSwitch } from "./enableFastWithdrawSwitch.js"; -import { registerBinanceWalletDisableFastWithdrawSwitch } from "./disableFastWithdrawSwitch.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceWalletAccountApiTradingStatus } from "./accountApiTradingStatus.js" +import { registerBinanceWalletAccountInfo } from "./accountInfo.js" +import { registerBinanceWalletAccountStatus } from "./accountStatus.js" +import { registerBinanceWalletDailyAccountSnapshot } from "./dailyAccountSnapshot.js" +import { registerBinanceWalletDisableFastWithdrawSwitch } from "./disableFastWithdrawSwitch.js" +import { registerBinanceWalletEnableFastWithdrawSwitch } from "./enableFastWithdrawSwitch.js" +import { registerBinanceWalletGetApiKeyPermission } from "./getApiKeyPermission.js" export function registerBinanceWalletAccountApiTools(server: McpServer) { - registerBinanceWalletDailyAccountSnapshot(server); - registerBinanceWalletGetApiKeyPermission(server); - registerBinanceWalletAccountInfo(server); - registerBinanceWalletAccountStatus(server); - registerBinanceWalletAccountApiTradingStatus(server); - registerBinanceWalletEnableFastWithdrawSwitch(server); - registerBinanceWalletDisableFastWithdrawSwitch(server); - -} \ No newline at end of file + registerBinanceWalletDailyAccountSnapshot(server) + registerBinanceWalletGetApiKeyPermission(server) + registerBinanceWalletAccountInfo(server) + registerBinanceWalletAccountStatus(server) + registerBinanceWalletAccountApiTradingStatus(server) + registerBinanceWalletEnableFastWithdrawSwitch(server) + registerBinanceWalletDisableFastWithdrawSwitch(server) +} diff --git a/src/tools/binance-wallet/asset-api/assetDetail.ts b/src/tools/binance-wallet/asset-api/assetDetail.ts index 8eabf38b..33f3dd6b 100644 --- a/src/tools/binance-wallet/asset-api/assetDetail.ts +++ b/src/tools/binance-wallet/asset-api/assetDetail.ts @@ -1,42 +1,43 @@ // src/tools/binance-wallet/asset-api/assetDetail.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletAssetDetail(server: McpServer) { - server.tool( - "BinanceWalletAssetDetail", - "Get asset details.", - { - asset: z.string().optional().describe("Asset symbol"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ asset, recvWindow }) => { - try { - const params: any = {}; - if (asset !== undefined) params.asset = asset; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.assetDetail(params); - const data = await response.data(); + server.tool( + "BinanceWalletAssetDetail", + "Get asset details.", + { + asset: z.string().optional().describe("Asset symbol"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ asset, recvWindow }) => { + try { + const params: any = {} + if (asset !== undefined) params.asset = asset + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.assetDetail(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved asset details. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved asset details. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve asset details: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve asset details: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/asset-api/assetDividendRecord.ts b/src/tools/binance-wallet/asset-api/assetDividendRecord.ts index c24cff7d..038cf6aa 100644 --- a/src/tools/binance-wallet/asset-api/assetDividendRecord.ts +++ b/src/tools/binance-wallet/asset-api/assetDividendRecord.ts @@ -1,48 +1,51 @@ // src/tools/binance-wallet/asset-api/assetDividendRecord.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletAssetDividendRecord(server: McpServer) { - server.tool( - "BinanceWalletAssetDividendRecord", - "Get asset dividend record.", - { - asset: z.string().optional().describe("Asset symbol"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 20, max 500"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ asset, startTime, endTime, limit, recvWindow }) => { - try { - const params: any = {}; - if (asset !== undefined) params.asset = asset; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.assetDividendRecord(params); - const data = await response.data(); + server.tool( + "BinanceWalletAssetDividendRecord", + "Get asset dividend record.", + { + asset: z.string().optional().describe("Asset symbol"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 20, max 500"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ asset, startTime, endTime, limit, recvWindow }) => { + try { + const params: any = {} + if (asset !== undefined) params.asset = asset + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.assetDividendRecord(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved asset dividend record. Total records: ${data.total || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved asset dividend record. Total records: ${data.total || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve asset dividend record: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve asset dividend record: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/asset-api/dustTransfer.ts b/src/tools/binance-wallet/asset-api/dustTransfer.ts index 74d7b520..bc1ebf68 100644 --- a/src/tools/binance-wallet/asset-api/dustTransfer.ts +++ b/src/tools/binance-wallet/asset-api/dustTransfer.ts @@ -1,42 +1,42 @@ - // src/tools/binance-wallet/asset-api/dustTransfer.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletDustTransfer(server: McpServer) { - server.tool( - "BinanceWalletDustTransfer", - "Convert dust assets to BNB.", - { - asset: z.array(z.string()).describe("Array of asset symbols to convert"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ asset, recvWindow }) => { - try { - const params: any = { asset }; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.dustTransfer(params); - const data = await response.data(); + server.tool( + "BinanceWalletDustTransfer", + "Convert dust assets to BNB.", + { + asset: z.array(z.string()).describe("Array of asset symbols to convert"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ asset, recvWindow }) => { + try { + const params: any = { asset } + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.dustTransfer(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Dust transfer completed. Total BNB received: ${data.totalServiceCharge || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Dust transfer completed. Total BNB received: ${data.totalServiceCharge || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to process dust transfer: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to process dust transfer: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/asset-api/dustlog.ts b/src/tools/binance-wallet/asset-api/dustlog.ts index 9ad92947..f86dd243 100644 --- a/src/tools/binance-wallet/asset-api/dustlog.ts +++ b/src/tools/binance-wallet/asset-api/dustlog.ts @@ -1,44 +1,45 @@ // src/tools/binance-wallet/asset-api/dustlog.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletDustlog(server: McpServer) { - server.tool( - "BinanceWalletDustlog", - "Get dust log (history of dust transfers).", - { - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ startTime, endTime, recvWindow }) => { - try { - const params: any = {}; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.dustlog(params); - const data = await response.data(); + server.tool( + "BinanceWalletDustlog", + "Get dust log (history of dust transfers).", + { + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ startTime, endTime, recvWindow }) => { + try { + const params: any = {} + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.dustlog(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved dust log. Total transfers: ${data.total || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved dust log. Total transfers: ${data.total || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve dust log: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve dust log: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/asset-api/fundingWallet.ts b/src/tools/binance-wallet/asset-api/fundingWallet.ts index 0a08c73f..28ecfab4 100644 --- a/src/tools/binance-wallet/asset-api/fundingWallet.ts +++ b/src/tools/binance-wallet/asset-api/fundingWallet.ts @@ -1,44 +1,47 @@ // src/tools/binance-wallet/asset-api/fundingWallet.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletFundingWallet(server: McpServer) { - server.tool( - "BinanceWalletFundingWallet", - "Get funding wallet balance.", - { - asset: z.string().optional().describe("Asset symbol"), - needBtcValuation: z.boolean().optional().describe("Whether to include BTC valuation"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ asset, needBtcValuation, recvWindow }) => { - try { - const params: any = {}; - if (asset !== undefined) params.asset = asset; - if (needBtcValuation !== undefined) params.needBtcValuation = needBtcValuation; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.fundingWallet(params); - const data = await response.data(); + server.tool( + "BinanceWalletFundingWallet", + "Get funding wallet balance.", + { + asset: z.string().optional().describe("Asset symbol"), + needBtcValuation: z.boolean().optional().describe("Whether to include BTC valuation"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ asset, needBtcValuation, recvWindow }) => { + try { + const params: any = {} + if (asset !== undefined) params.asset = asset + if (needBtcValuation !== undefined) params.needBtcValuation = needBtcValuation + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.fundingWallet(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved funding wallet balance. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved funding wallet balance. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve funding wallet balance: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve funding wallet balance: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts b/src/tools/binance-wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts index 8c5a3ef1..aa233936 100644 --- a/src/tools/binance-wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts +++ b/src/tools/binance-wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts @@ -1,40 +1,43 @@ // src/tools/binance-wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletGetAssetsThatCanBeConvertedIntoBnb(server: McpServer) { - server.tool( - "BinanceWalletGetAssetsThatCanBeConvertedIntoBnb", - "Get assets that can be converted to BNB.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: any = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.getAssetsThatCanBeConvertedIntoBnb(params); - const data = await response.data(); + server.tool( + "BinanceWalletGetAssetsThatCanBeConvertedIntoBnb", + "Get assets that can be converted to BNB.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: any = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.getAssetsThatCanBeConvertedIntoBnb(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved assets that can be converted to BNB. Total: ${data.details?.length || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved assets that can be converted to BNB. Total: ${data.details?.length || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve convertible assets: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve convertible assets: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts b/src/tools/binance-wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts index d8317c6b..52652ef4 100644 --- a/src/tools/binance-wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts +++ b/src/tools/binance-wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts @@ -1,49 +1,52 @@ // src/tools/binance-wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletGetCloudMiningPaymentAndRefundHistory(server: McpServer) { - server.tool( - "BinanceWalletGetCloudMiningPaymentAndRefundHistory", - "Get cloud mining payment and refund history.", - { - startTime: z.number().describe("Start time in milliseconds"), - endTime: z.number().describe("End time in milliseconds"), - page: z.number().optional().describe("Page number"), - pageSize: z.number().optional().describe("Page size"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ startTime, endTime, page, pageSize, recvWindow }) => { - try { - const params: any = { - startTime, - endTime - }; - if (page !== undefined) params.page = page; - if (pageSize !== undefined) params.pageSize = pageSize; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.getCloudMiningPaymentAndRefundHistory(params); - const data = await response.data(); + server.tool( + "BinanceWalletGetCloudMiningPaymentAndRefundHistory", + "Get cloud mining payment and refund history.", + { + startTime: z.number().describe("Start time in milliseconds"), + endTime: z.number().describe("End time in milliseconds"), + page: z.number().optional().describe("Page number"), + pageSize: z.number().optional().describe("Page size"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ startTime, endTime, page, pageSize, recvWindow }) => { + try { + const params: any = { + startTime, + endTime, + } + if (page !== undefined) params.page = page + if (pageSize !== undefined) params.pageSize = pageSize + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.getCloudMiningPaymentAndRefundHistory(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved cloud mining payment and refund history. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved cloud mining payment and refund history. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve cloud mining history: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve cloud mining history: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/asset-api/getOpenSymbolList.ts b/src/tools/binance-wallet/asset-api/getOpenSymbolList.ts index dee5dbcf..f79ebab2 100644 --- a/src/tools/binance-wallet/asset-api/getOpenSymbolList.ts +++ b/src/tools/binance-wallet/asset-api/getOpenSymbolList.ts @@ -1,35 +1,29 @@ // src/tools/binance-wallet/asset-api/getOpenSymbolList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletGetOpenSymbolList(server: McpServer) { - server.tool( - "BinanceWalletGetOpenSymbolList", - "Get open symbol list.", - {}, - async () => { - try { - const response = await walletClient.restAPI.getOpenSymbolList(); - const data = await response.data(); + server.tool("BinanceWalletGetOpenSymbolList", "Get open symbol list.", {}, async () => { + try { + const response = await walletClient.restAPI.getOpenSymbolList() + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved open symbol list. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved open symbol list. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve open symbol list: ${errorMessage}` } - ], - isError: true - }; - } - } - ); -} \ No newline at end of file + return { + content: [{ type: "text", text: `Failed to retrieve open symbol list: ${errorMessage}` }], + isError: true, + } + } + }) +} diff --git a/src/tools/binance-wallet/asset-api/index.ts b/src/tools/binance-wallet/asset-api/index.ts index c3d59031..e736e603 100644 --- a/src/tools/binance-wallet/asset-api/index.ts +++ b/src/tools/binance-wallet/asset-api/index.ts @@ -1,35 +1,36 @@ // src/tools/binance-wallet/asset-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceWalletUserAsset } from "./userAsset.js"; -import { registerBinanceWalletFundingWallet } from "./fundingWallet.js"; -import { registerBinanceWalletAssetDetail } from "./assetDetail.js"; -import { registerBinanceWalletTradeFee } from "./tradeFee.js"; -import { registerBinanceWalletUserUniversalTransfer } from "./userUniversalTransfer.js"; -import { registerBinanceWalletQueryUserUniversalTransferHistory } from "./queryUserUniversalTransferHistory.js"; -import { registerBinanceWalletDustTransfer } from "./dustTransfer.js"; -import { registerBinanceWalletDustlog } from "./dustlog.js"; -import { registerBinanceWalletAssetDividendRecord } from "./assetDividendRecord.js"; -import { registerBinanceWalletGetAssetsThatCanBeConvertedIntoBnb } from "./getAssetsThatCanBeConvertedIntoBnb.js"; -import { registerBinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest } from "./toggleBnbBurnOnSpotTradeAndMarginInterest.js"; -import { registerBinanceWalletGetCloudMiningPaymentAndRefundHistory } from "./getCloudMiningPaymentAndRefundHistory.js"; -import { registerBinanceWalletQueryUserDelegationHistory } from "./queryUserDelegationHistory.js"; -import { registerBinanceWalletGetOpenSymbolList } from "./getOpenSymbolList.js"; -import { registerBinanceWalletQueryUserWalletBalance } from "./queryUserWalletBalance.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceWalletAssetDetail } from "./assetDetail.js" +import { registerBinanceWalletAssetDividendRecord } from "./assetDividendRecord.js" +import { registerBinanceWalletDustlog } from "./dustlog.js" +import { registerBinanceWalletDustTransfer } from "./dustTransfer.js" +import { registerBinanceWalletFundingWallet } from "./fundingWallet.js" +import { registerBinanceWalletGetAssetsThatCanBeConvertedIntoBnb } from "./getAssetsThatCanBeConvertedIntoBnb.js" +import { registerBinanceWalletGetCloudMiningPaymentAndRefundHistory } from "./getCloudMiningPaymentAndRefundHistory.js" +import { registerBinanceWalletGetOpenSymbolList } from "./getOpenSymbolList.js" +import { registerBinanceWalletQueryUserDelegationHistory } from "./queryUserDelegationHistory.js" +import { registerBinanceWalletQueryUserUniversalTransferHistory } from "./queryUserUniversalTransferHistory.js" +import { registerBinanceWalletQueryUserWalletBalance } from "./queryUserWalletBalance.js" +import { registerBinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest } from "./toggleBnbBurnOnSpotTradeAndMarginInterest.js" +import { registerBinanceWalletTradeFee } from "./tradeFee.js" +import { registerBinanceWalletUserAsset } from "./userAsset.js" +import { registerBinanceWalletUserUniversalTransfer } from "./userUniversalTransfer.js" export function registerBinanceWalletAssetApiTools(server: McpServer) { - registerBinanceWalletUserAsset(server); - registerBinanceWalletFundingWallet(server); - registerBinanceWalletAssetDetail(server); - registerBinanceWalletTradeFee(server); - registerBinanceWalletUserUniversalTransfer(server); - registerBinanceWalletQueryUserUniversalTransferHistory(server); - registerBinanceWalletDustTransfer(server); - registerBinanceWalletDustlog(server); - registerBinanceWalletAssetDividendRecord(server); - registerBinanceWalletGetAssetsThatCanBeConvertedIntoBnb(server); - registerBinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest(server); - registerBinanceWalletGetCloudMiningPaymentAndRefundHistory(server); - registerBinanceWalletQueryUserDelegationHistory(server); - registerBinanceWalletGetOpenSymbolList(server); - registerBinanceWalletQueryUserWalletBalance(server); -} \ No newline at end of file + registerBinanceWalletUserAsset(server) + registerBinanceWalletFundingWallet(server) + registerBinanceWalletAssetDetail(server) + registerBinanceWalletTradeFee(server) + registerBinanceWalletUserUniversalTransfer(server) + registerBinanceWalletQueryUserUniversalTransferHistory(server) + registerBinanceWalletDustTransfer(server) + registerBinanceWalletDustlog(server) + registerBinanceWalletAssetDividendRecord(server) + registerBinanceWalletGetAssetsThatCanBeConvertedIntoBnb(server) + registerBinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest(server) + registerBinanceWalletGetCloudMiningPaymentAndRefundHistory(server) + registerBinanceWalletQueryUserDelegationHistory(server) + registerBinanceWalletGetOpenSymbolList(server) + registerBinanceWalletQueryUserWalletBalance(server) +} diff --git a/src/tools/binance-wallet/asset-api/queryUserDelegationHistory.ts b/src/tools/binance-wallet/asset-api/queryUserDelegationHistory.ts index 02075a79..733e68ec 100644 --- a/src/tools/binance-wallet/asset-api/queryUserDelegationHistory.ts +++ b/src/tools/binance-wallet/asset-api/queryUserDelegationHistory.ts @@ -1,51 +1,54 @@ // src/tools/binance-wallet/asset-api/queryUserDelegationHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletQueryUserDelegationHistory(server: McpServer) { - server.tool( - "BinanceWalletQueryUserDelegationHistory", - "Query user delegation history.", - { - email: z.string().describe("Email address"), - startTime: z.number().describe("Start time in milliseconds"), - endTime: z.number().describe("End time in milliseconds"), - page: z.number().optional().describe("Page number"), - limit: z.number().optional().describe("Results per page"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ email, startTime, endTime, page, limit, recvWindow }) => { - try { - const params: any = { - email, - startTime, - endTime - }; - if (page !== undefined) params.page = page; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.queryUserDelegationHistory(params); - const data = await response.data(); + server.tool( + "BinanceWalletQueryUserDelegationHistory", + "Query user delegation history.", + { + email: z.string().describe("Email address"), + startTime: z.number().describe("Start time in milliseconds"), + endTime: z.number().describe("End time in milliseconds"), + page: z.number().optional().describe("Page number"), + limit: z.number().optional().describe("Results per page"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ email, startTime, endTime, page, limit, recvWindow }) => { + try { + const params: any = { + email, + startTime, + endTime, + } + if (page !== undefined) params.page = page + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.queryUserDelegationHistory(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved user delegation history. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved user delegation history. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve user delegation history: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve user delegation history: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/asset-api/queryUserUniversalTransferHistory.ts b/src/tools/binance-wallet/asset-api/queryUserUniversalTransferHistory.ts index 59e3fca7..f8c0bb20 100644 --- a/src/tools/binance-wallet/asset-api/queryUserUniversalTransferHistory.ts +++ b/src/tools/binance-wallet/asset-api/queryUserUniversalTransferHistory.ts @@ -1,53 +1,59 @@ // src/tools/binance-wallet/asset-api/queryUserUniversalTransferHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletQueryUserUniversalTransferHistory(server: McpServer) { - server.tool( - "BinanceWalletQueryUserUniversalTransferHistory", - "Query universal transfer history.", - { - type: z.string().describe("Transfer type"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - current: z.number().optional().describe("Current page"), - size: z.number().optional().describe("Page size"), - fromSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), - toSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ type, startTime, endTime, current, size, fromSymbol, toSymbol, recvWindow }) => { - try { - const params: any = { type }; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (current !== undefined) params.current = current; - if (size !== undefined) params.size = size; - if (fromSymbol !== undefined) params.fromSymbol = fromSymbol; - if (toSymbol !== undefined) params.toSymbol = toSymbol; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.queryUserUniversalTransferHistory(params); - const data = await response.data(); + server.tool( + "BinanceWalletQueryUserUniversalTransferHistory", + "Query universal transfer history.", + { + type: z.string().describe("Transfer type"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + current: z.number().optional().describe("Current page"), + size: z.number().optional().describe("Page size"), + fromSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), + toSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ type, startTime, endTime, current, size, fromSymbol, toSymbol, recvWindow }) => { + try { + const params: any = { type } + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (current !== undefined) params.current = current + if (size !== undefined) params.size = size + if (fromSymbol !== undefined) params.fromSymbol = fromSymbol + if (toSymbol !== undefined) params.toSymbol = toSymbol + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.queryUserUniversalTransferHistory(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved universal transfer history. Total: ${data.total || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved universal transfer history. Total: ${data.total || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve universal transfer history: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to retrieve universal transfer history: ${errorMessage}`, + }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/asset-api/queryUserWalletBalance.ts b/src/tools/binance-wallet/asset-api/queryUserWalletBalance.ts index b386a6d5..bc5791bf 100644 --- a/src/tools/binance-wallet/asset-api/queryUserWalletBalance.ts +++ b/src/tools/binance-wallet/asset-api/queryUserWalletBalance.ts @@ -1,40 +1,43 @@ // src/tools/binance-wallet/asset-api/queryUserWalletBalance.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletQueryUserWalletBalance(server: McpServer) { - server.tool( - "BinanceWalletQueryUserWalletBalance", - "Query user wallet balance.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: any = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.queryUserWalletBalance(params); - const data = await response.data(); + server.tool( + "BinanceWalletQueryUserWalletBalance", + "Query user wallet balance.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: any = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.queryUserWalletBalance(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved user wallet balance. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved user wallet balance. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve user wallet balance: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve user wallet balance: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts b/src/tools/binance-wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts index bf05c09b..adfe18ed 100644 --- a/src/tools/binance-wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts +++ b/src/tools/binance-wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts @@ -1,44 +1,46 @@ // src/tools/binance-wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest(server: McpServer) { - server.tool( - "BinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest", - "Toggle BNB burn on spot trade and margin interest.", - { - spotBNBBurn: z.string().optional().describe("'true' or 'false' for spot trade"), - interestBNBBurn: z.string().optional().describe("'true' or 'false' for margin interest"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ spotBNBBurn, interestBNBBurn, recvWindow }) => { - try { - const params: any = {}; - if (spotBNBBurn !== undefined) params.spotBNBBurn = spotBNBBurn; - if (interestBNBBurn !== undefined) params.interestBNBBurn = interestBNBBurn; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.toggleBnbBurnOnSpotTradeAndMarginInterest(params); - const data = await response.data(); + server.tool( + "BinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest", + "Toggle BNB burn on spot trade and margin interest.", + { + spotBNBBurn: z.string().optional().describe("'true' or 'false' for spot trade"), + interestBNBBurn: z.string().optional().describe("'true' or 'false' for margin interest"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ spotBNBBurn, interestBNBBurn, recvWindow }) => { + try { + const params: any = {} + if (spotBNBBurn !== undefined) params.spotBNBBurn = spotBNBBurn + if (interestBNBBurn !== undefined) params.interestBNBBurn = interestBNBBurn + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = + await walletClient.restAPI.toggleBnbBurnOnSpotTradeAndMarginInterest(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `BNB burn settings updated. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `BNB burn settings updated. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to update BNB burn settings: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to update BNB burn settings: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/asset-api/tradeFee.ts b/src/tools/binance-wallet/asset-api/tradeFee.ts index e1a613a0..026f68ec 100644 --- a/src/tools/binance-wallet/asset-api/tradeFee.ts +++ b/src/tools/binance-wallet/asset-api/tradeFee.ts @@ -1,42 +1,45 @@ // src/tools/binance-wallet/asset-api/tradeFee.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletTradeFee(server: McpServer) { - server.tool( - "BinanceWalletTradeFee", - "Get trade fee.", - { - symbol: z.string().optional().describe("Trading pair symbol"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ symbol, recvWindow }) => { - try { - const params: any = {}; - if (symbol !== undefined) params.symbol = symbol; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.tradeFee(params); - const data = await response.data(); + server.tool( + "BinanceWalletTradeFee", + "Get trade fee.", + { + symbol: z.string().optional().describe("Trading pair symbol"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ symbol, recvWindow }) => { + try { + const params: any = {} + if (symbol !== undefined) params.symbol = symbol + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.tradeFee(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved trade fee information. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved trade fee information. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve trade fee information: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve trade fee information: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/asset-api/userAsset.ts b/src/tools/binance-wallet/asset-api/userAsset.ts index f0d373e6..69f73322 100644 --- a/src/tools/binance-wallet/asset-api/userAsset.ts +++ b/src/tools/binance-wallet/asset-api/userAsset.ts @@ -1,42 +1,43 @@ // src/tools/binance-wallet/asset-api/userAsset.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletUserAsset(server: McpServer) { - server.tool( - "BinanceWalletUserAsset", - "Get user assets.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), - needBtcValuation: z.boolean().optional().describe("Whether to include BTC valuation") - }, - async ({ recvWindow, needBtcValuation }) => { - try { - const params: any = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - if (needBtcValuation !== undefined) params.needBtcValuation = needBtcValuation; - - const response = await walletClient.restAPI.userAsset(params); - const data = await response.data(); + server.tool( + "BinanceWalletUserAsset", + "Get user assets.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + needBtcValuation: z.boolean().optional().describe("Whether to include BTC valuation"), + }, + async ({ recvWindow, needBtcValuation }) => { + try { + const params: any = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + if (needBtcValuation !== undefined) params.needBtcValuation = needBtcValuation + + const response = await walletClient.restAPI.userAsset(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved user assets. Number of assets: ${data.length || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved user assets. Number of assets: ${data.length || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve user assets: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve user assets: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/asset-api/userUniversalTransfer.ts b/src/tools/binance-wallet/asset-api/userUniversalTransfer.ts index 3f9cf173..fc9def86 100644 --- a/src/tools/binance-wallet/asset-api/userUniversalTransfer.ts +++ b/src/tools/binance-wallet/asset-api/userUniversalTransfer.ts @@ -1,52 +1,54 @@ - // src/tools/binance-wallet/asset-api/userUniversalTransfer.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletUserUniversalTransfer(server: McpServer) { - server.tool( - "BinanceWalletUserUniversalTransfer", - "Make universal transfer between different accounts.", - { - type: z.string().describe("Transfer type"), - asset: z.string().describe("Asset symbol"), - amount: z.number().describe("Transfer amount"), - fromSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), - toSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ type, asset, amount, fromSymbol, toSymbol, recvWindow }) => { - try { - const params: any = { - type, - asset, - amount - }; - if (fromSymbol !== undefined) params.fromSymbol = fromSymbol; - if (toSymbol !== undefined) params.toSymbol = toSymbol; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.userUniversalTransfer(params); - const data = await response.data(); + server.tool( + "BinanceWalletUserUniversalTransfer", + "Make universal transfer between different accounts.", + { + type: z.string().describe("Transfer type"), + asset: z.string().describe("Asset symbol"), + amount: z.number().describe("Transfer amount"), + fromSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), + toSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ type, asset, amount, fromSymbol, toSymbol, recvWindow }) => { + try { + const params: any = { + type, + asset, + amount, + } + if (fromSymbol !== undefined) params.fromSymbol = fromSymbol + if (toSymbol !== undefined) params.toSymbol = toSymbol + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.userUniversalTransfer(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Universal transfer completed. Transfer ID: ${data.tranId}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Universal transfer completed. Transfer ID: ${data.tranId}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to process universal transfer: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to process universal transfer: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/capital-api/allCoinsInformation.ts b/src/tools/binance-wallet/capital-api/allCoinsInformation.ts index 1dc48aad..af4fcb32 100644 --- a/src/tools/binance-wallet/capital-api/allCoinsInformation.ts +++ b/src/tools/binance-wallet/capital-api/allCoinsInformation.ts @@ -1,40 +1,41 @@ // src/tools/binance-wallet/capital-api/allCoinsInformation.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletAllCoinsInformation(server: McpServer) { - server.tool( - "BinanceWalletAllCoinsInformation", - "Get information for all coins.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ recvWindow }) => { - try { - const params: any = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.allCoinsInformation(params); - const data = await response.data(); + server.tool( + "BinanceWalletAllCoinsInformation", + "Get information for all coins.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: any = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.allCoinsInformation(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved information for all coins. Total coins: ${data.length || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved information for all coins. Total coins: ${data.length || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve coin information: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve coin information: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/capital-api/depositAddress.ts b/src/tools/binance-wallet/capital-api/depositAddress.ts index cbcc2d66..2899d1db 100644 --- a/src/tools/binance-wallet/capital-api/depositAddress.ts +++ b/src/tools/binance-wallet/capital-api/depositAddress.ts @@ -1,43 +1,44 @@ // src/tools/binance-wallet/capital-api/depositAddress.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletDepositAddress(server: McpServer) { - server.tool( - "BinanceWalletDepositAddress", - "Get deposit address for a specific coin.", - { - coin: z.string().describe("Coin symbol"), - network: z.string().optional().describe("Network"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ coin, network, recvWindow }) => { - try { - const params: any = { coin }; - if (network !== undefined) params.network = network; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.depositAddress(params); - const data = await response.data(); + server.tool( + "BinanceWalletDepositAddress", + "Get deposit address for a specific coin.", + { + coin: z.string().describe("Coin symbol"), + network: z.string().optional().describe("Network"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ coin, network, recvWindow }) => { + try { + const params: any = { coin } + if (network !== undefined) params.network = network + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.depositAddress(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved deposit address for ${coin}. Address: ${data.address}${data.tag ? `, Tag: ${data.tag}` : ""}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved deposit address for ${coin}. Address: ${data.address}${data.tag ? `, Tag: ${data.tag}` : ''}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve deposit address: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve deposit address: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/capital-api/depositHistory.ts b/src/tools/binance-wallet/capital-api/depositHistory.ts index 20c3ed33..c46eafe0 100644 --- a/src/tools/binance-wallet/capital-api/depositHistory.ts +++ b/src/tools/binance-wallet/capital-api/depositHistory.ts @@ -1,52 +1,53 @@ // src/tools/binance-wallet/capital-api/depositHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletDepositHistory(server: McpServer) { - server.tool( - "BinanceWalletDepositHistory", - "Get deposit history.", - { - coin: z.string().optional().describe("Coin symbol"), - status: z.number().optional().describe("Deposit status"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - offset: z.number().optional().describe("Pagination offset"), - limit: z.number().optional().describe("Number of records to return"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { - try { - const params: any = {}; - if (coin !== undefined) params.coin = coin; - if (status !== undefined) params.status = status; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (offset !== undefined) params.offset = offset; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; + server.tool( + "BinanceWalletDepositHistory", + "Get deposit history.", + { + coin: z.string().optional().describe("Coin symbol"), + status: z.number().optional().describe("Deposit status"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + offset: z.number().optional().describe("Pagination offset"), + limit: z.number().optional().describe("Number of records to return"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { + try { + const params: any = {} + if (coin !== undefined) params.coin = coin + if (status !== undefined) params.status = status + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (offset !== undefined) params.offset = offset + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow - const response = await walletClient.restAPI.depositHistory(params); - const data = await response.data(); + const response = await walletClient.restAPI.depositHistory(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved deposit history. Total deposits: ${data.length || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved deposit history. Total deposits: ${data.length || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve deposit history: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve deposit history: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/capital-api/fetchDepositAddressListWithNetwork.ts b/src/tools/binance-wallet/capital-api/fetchDepositAddressListWithNetwork.ts index a9b87324..e924cdbe 100644 --- a/src/tools/binance-wallet/capital-api/fetchDepositAddressListWithNetwork.ts +++ b/src/tools/binance-wallet/capital-api/fetchDepositAddressListWithNetwork.ts @@ -1,43 +1,46 @@ // src/tools/binance-wallet/capital-api/fetchDepositAddressListWithNetwork.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletFetchDepositAddressListWithNetwork(server: McpServer) { - server.tool( - "BinanceWalletFetchDepositAddressListWithNetwork", - "Fetch deposit address with network.", - { - coin: z.string().describe("Coin symbol"), - network: z.string().optional().describe("Network"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ coin, network, recvWindow }) => { - try { - const params: any = { coin }; - if (network !== undefined) params.network = network; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.fetchDepositAddressListWithNetwork(params); - const data = await response.data(); + server.tool( + "BinanceWalletFetchDepositAddressListWithNetwork", + "Fetch deposit address with network.", + { + coin: z.string().describe("Coin symbol"), + network: z.string().optional().describe("Network"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ coin, network, recvWindow }) => { + try { + const params: any = { coin } + if (network !== undefined) params.network = network + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.fetchDepositAddressListWithNetwork(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved deposit addresses for ${coin}. Total addresses: ${data.length || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved deposit addresses for ${coin}. Total addresses: ${data.length || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve deposit addresses: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve deposit addresses: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/capital-api/fetchWithdrawAddressList.ts b/src/tools/binance-wallet/capital-api/fetchWithdrawAddressList.ts index 1aa56a22..ae2946c2 100644 --- a/src/tools/binance-wallet/capital-api/fetchWithdrawAddressList.ts +++ b/src/tools/binance-wallet/capital-api/fetchWithdrawAddressList.ts @@ -1,37 +1,36 @@ // src/tools/binance-wallet/capital-api/fetchWithdrawAddressList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletFetchWithdrawAddressList(server: McpServer) { - server.tool( - "BinanceWalletFetchWithdrawAddressList", - "Fetch withdraw address list.", - { - }, - async () => { - try { - - const response = await walletClient.restAPI.fetchWithdrawAddressList(); - const data = await response.data(); + server.tool( + "BinanceWalletFetchWithdrawAddressList", + "Fetch withdraw address list.", + {}, + async () => { + try { + const response = await walletClient.restAPI.fetchWithdrawAddressList() + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved withdraw address list. Total addresses: ${data || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved withdraw address list. Total addresses: ${data || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve withdraw address list: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve withdraw address list: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/capital-api/index.ts b/src/tools/binance-wallet/capital-api/index.ts index be8c1ac1..694efb2d 100644 --- a/src/tools/binance-wallet/capital-api/index.ts +++ b/src/tools/binance-wallet/capital-api/index.ts @@ -1,21 +1,22 @@ // src/tools/binance-wallet/capital-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceWalletAllCoinsInformation } from "./allCoinsInformation.js"; -import { registerBinanceWalletDepositAddress } from "./depositAddress.js"; -import { registerBinanceWalletDepositHistory } from "./depositHistory.js"; -import { registerBinanceWalletWithdrawHistory } from "./withdrawHistory.js"; -import { registerBinanceWalletWithdraw } from "./withdraw.js"; -import { registerBinanceWalletFetchDepositAddressListWithNetwork } from "./fetchDepositAddressListWithNetwork.js"; -import { registerBinanceWalletFetchWithdrawAddressList } from "./fetchWithdrawAddressList.js"; -import { registerBinanceWalletOneClickArrivalDepositApply } from "./oneClickArrivalDepositApply.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceWalletAllCoinsInformation } from "./allCoinsInformation.js" +import { registerBinanceWalletDepositAddress } from "./depositAddress.js" +import { registerBinanceWalletDepositHistory } from "./depositHistory.js" +import { registerBinanceWalletFetchDepositAddressListWithNetwork } from "./fetchDepositAddressListWithNetwork.js" +import { registerBinanceWalletFetchWithdrawAddressList } from "./fetchWithdrawAddressList.js" +import { registerBinanceWalletOneClickArrivalDepositApply } from "./oneClickArrivalDepositApply.js" +import { registerBinanceWalletWithdraw } from "./withdraw.js" +import { registerBinanceWalletWithdrawHistory } from "./withdrawHistory.js" export function registerBinanceWalletCapitalApiTools(server: McpServer) { - registerBinanceWalletAllCoinsInformation(server); - registerBinanceWalletDepositAddress(server); - registerBinanceWalletDepositHistory(server); - registerBinanceWalletWithdrawHistory(server); - registerBinanceWalletWithdraw(server); - registerBinanceWalletFetchDepositAddressListWithNetwork(server); - registerBinanceWalletFetchWithdrawAddressList(server); - registerBinanceWalletOneClickArrivalDepositApply(server); -} \ No newline at end of file + registerBinanceWalletAllCoinsInformation(server) + registerBinanceWalletDepositAddress(server) + registerBinanceWalletDepositHistory(server) + registerBinanceWalletWithdrawHistory(server) + registerBinanceWalletWithdraw(server) + registerBinanceWalletFetchDepositAddressListWithNetwork(server) + registerBinanceWalletFetchWithdrawAddressList(server) + registerBinanceWalletOneClickArrivalDepositApply(server) +} diff --git a/src/tools/binance-wallet/capital-api/oneClickArrivalDepositApply.ts b/src/tools/binance-wallet/capital-api/oneClickArrivalDepositApply.ts index 8ecc17ed..13e562ba 100644 --- a/src/tools/binance-wallet/capital-api/oneClickArrivalDepositApply.ts +++ b/src/tools/binance-wallet/capital-api/oneClickArrivalDepositApply.ts @@ -1,42 +1,48 @@ // src/tools/binance-wallet/capital-api/oneClickArrivalDepositApply.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletOneClickArrivalDepositApply(server: McpServer) { - server.tool( - "BinanceWalletOneClickArrivalDepositApply", - "Apply for one-click arrival deposit.", - { - subAccountId: z.string().optional().describe("Sub-account ID"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ subAccountId, recvWindow }) => { - try { - const params: any = {}; - if (subAccountId !== undefined) params.subAccountId = subAccountId; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.oneClickArrivalDepositApply(params); - const data = await response.data(); + server.tool( + "BinanceWalletOneClickArrivalDepositApply", + "Apply for one-click arrival deposit.", + { + subAccountId: z.string().optional().describe("Sub-account ID"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ subAccountId, recvWindow }) => { + try { + const params: any = {} + if (subAccountId !== undefined) params.subAccountId = subAccountId + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.oneClickArrivalDepositApply(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Applied for one-click arrival deposit. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Applied for one-click arrival deposit. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to apply for one-click arrival deposit: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to apply for one-click arrival deposit: ${errorMessage}`, + }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/capital-api/withdraw.ts b/src/tools/binance-wallet/capital-api/withdraw.ts index 50e4c1a6..3619a467 100644 --- a/src/tools/binance-wallet/capital-api/withdraw.ts +++ b/src/tools/binance-wallet/capital-api/withdraw.ts @@ -1,59 +1,71 @@ // src/tools/binance-wallet/capital-api/withdraw.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletWithdraw(server: McpServer) { - server.tool( - "BinanceWalletWithdraw", - "Submit a withdraw request.", - { - coin: z.string().describe("Coin symbol"), - address: z.string().describe("Withdrawal address"), - amount: z.number().describe("Withdrawal amount"), - withdrawOrderId: z.string().optional().describe("Client order id"), - network: z.string().optional().describe("Network"), - addressTag: z.string().optional().describe("Secondary address identifier (tag/memo)"), - name: z.string().optional().describe("Address name"), - walletType: z.number().optional().describe("Wallet type"), - transactionFeeFlag: z.boolean().optional().describe("Pay fee with BNB"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ coin, address, amount, withdrawOrderId, network, addressTag, name, walletType, transactionFeeFlag, recvWindow }) => { - try { - const params: any = { - coin, - address, - amount - }; - if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId; - if (network !== undefined) params.network = network; - if (addressTag !== undefined) params.addressTag = addressTag; - if (name !== undefined) params.name = name; - if (walletType !== undefined) params.walletType = walletType; - if (transactionFeeFlag !== undefined) params.transactionFeeFlag = transactionFeeFlag; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.withdraw(params); - const data = await response.data(); + server.tool( + "BinanceWalletWithdraw", + "Submit a withdraw request.", + { + coin: z.string().describe("Coin symbol"), + address: z.string().describe("Withdrawal address"), + amount: z.number().describe("Withdrawal amount"), + withdrawOrderId: z.string().optional().describe("Client order id"), + network: z.string().optional().describe("Network"), + addressTag: z.string().optional().describe("Secondary address identifier (tag/memo)"), + name: z.string().optional().describe("Address name"), + walletType: z.number().optional().describe("Wallet type"), + transactionFeeFlag: z.boolean().optional().describe("Pay fee with BNB"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ + coin, + address, + amount, + withdrawOrderId, + network, + addressTag, + name, + walletType, + transactionFeeFlag, + recvWindow, + }) => { + try { + const params: any = { + coin, + address, + amount, + } + if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId + if (network !== undefined) params.network = network + if (addressTag !== undefined) params.addressTag = addressTag + if (name !== undefined) params.name = name + if (walletType !== undefined) params.walletType = walletType + if (transactionFeeFlag !== undefined) params.transactionFeeFlag = transactionFeeFlag + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.withdraw(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Withdraw request submitted. Withdrawal ID: ${data.id}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Withdraw request submitted. Withdrawal ID: ${data.id}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to submit withdraw request: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to submit withdraw request: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/capital-api/withdrawHistory.ts b/src/tools/binance-wallet/capital-api/withdrawHistory.ts index f846925c..63f0e692 100644 --- a/src/tools/binance-wallet/capital-api/withdrawHistory.ts +++ b/src/tools/binance-wallet/capital-api/withdrawHistory.ts @@ -1,54 +1,55 @@ // src/tools/binance-wallet/capital-api/withdrawHistory.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletWithdrawHistory(server: McpServer) { - server.tool( - "BinanceWalletWithdrawHistory", - "Get withdraw history.", - { - coin: z.string().optional().describe("Coin symbol"), - withdrawOrderId: z.string().optional().describe("Withdraw order ID"), - status: z.number().optional().describe("Withdraw status"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - offset: z.number().optional().describe("Pagination offset"), - limit: z.number().optional().describe("Number of records to return"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ coin, withdrawOrderId, status, startTime, endTime, offset, limit, recvWindow }) => { - try { - const params: any = {}; - if (coin !== undefined) params.coin = coin; - if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId; - if (status !== undefined) params.status = status; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (offset !== undefined) params.offset = offset; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.withdrawHistory(params); - const data = await response.data(); + server.tool( + "BinanceWalletWithdrawHistory", + "Get withdraw history.", + { + coin: z.string().optional().describe("Coin symbol"), + withdrawOrderId: z.string().optional().describe("Withdraw order ID"), + status: z.number().optional().describe("Withdraw status"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + offset: z.number().optional().describe("Pagination offset"), + limit: z.number().optional().describe("Number of records to return"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ coin, withdrawOrderId, status, startTime, endTime, offset, limit, recvWindow }) => { + try { + const params: any = {} + if (coin !== undefined) params.coin = coin + if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId + if (status !== undefined) params.status = status + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (offset !== undefined) params.offset = offset + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.withdrawHistory(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved withdraw history. Total withdrawals: ${data.length || 0}. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved withdraw history. Total withdrawals: ${data.length || 0}. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve withdraw history: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve withdraw history: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/index.ts b/src/tools/binance-wallet/index.ts index e3e85d29..7b1665ce 100644 --- a/src/tools/binance-wallet/index.ts +++ b/src/tools/binance-wallet/index.ts @@ -1,24 +1,25 @@ // src/tools/binance-wallet/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceWalletAccountApiTools } from "./account-api/index.js"; -import { registerBinanceWalletOthersApiTools } from "./others-api/index.js"; -import { registerBinanceWalletTravelRuleApiTools } from "./travel-rule-api/index.js"; -import { registerBinanceWalletAssetApiTools } from "./asset-api/index.js"; -import { registerBinanceWalletCapitalApiTools } from "./capital-api/index.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceWalletAccountApiTools } from "./account-api/index.js" +import { registerBinanceWalletAssetApiTools } from "./asset-api/index.js" +import { registerBinanceWalletCapitalApiTools } from "./capital-api/index.js" +import { registerBinanceWalletOthersApiTools } from "./others-api/index.js" +import { registerBinanceWalletTravelRuleApiTools } from "./travel-rule-api/index.js" export function registerBinanceWalletTools(server: McpServer) { - // Account API tools - registerBinanceWalletAccountApiTools(server); - - // Others API tools - registerBinanceWalletOthersApiTools(server); - - // Travel Rule API tools - registerBinanceWalletTravelRuleApiTools(server); - - // Asset API tools - registerBinanceWalletAssetApiTools(server); - - // Capital API tools - registerBinanceWalletCapitalApiTools(server); -} \ No newline at end of file + // Account API tools + registerBinanceWalletAccountApiTools(server) + + // Others API tools + registerBinanceWalletOthersApiTools(server) + + // Travel Rule API tools + registerBinanceWalletTravelRuleApiTools(server) + + // Asset API tools + registerBinanceWalletAssetApiTools(server) + + // Capital API tools + registerBinanceWalletCapitalApiTools(server) +} diff --git a/src/tools/binance-wallet/others-api/getSymbolsDelistScheduleForSpot.ts b/src/tools/binance-wallet/others-api/getSymbolsDelistScheduleForSpot.ts index f1c4f0f6..8ac0a258 100644 --- a/src/tools/binance-wallet/others-api/getSymbolsDelistScheduleForSpot.ts +++ b/src/tools/binance-wallet/others-api/getSymbolsDelistScheduleForSpot.ts @@ -1,34 +1,34 @@ // src/tools/binance-wallet/others-api/getSymbolsDelistScheduleForSpot.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletGetSymbolsDelistScheduleForSpot(server: McpServer) { - server.tool( - "BinanceWalletGetSymbolsDelistScheduleForSpot", - "Get delist schedule for spot symbols.", - {}, - async () => { - try { - const response = await walletClient.restAPI.getSymbolsDelistScheduleForSpot(); - const data = await response.data(); + server.tool( + "BinanceWalletGetSymbolsDelistScheduleForSpot", + "Get delist schedule for spot symbols.", + {}, + async () => { + try { + const response = await walletClient.restAPI.getSymbolsDelistScheduleForSpot() + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved delist schedule for spot symbols. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved delist schedule for spot symbols. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve delist schedule: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve delist schedule: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/others-api/index.ts b/src/tools/binance-wallet/others-api/index.ts index d0ca0559..3b6520d6 100644 --- a/src/tools/binance-wallet/others-api/index.ts +++ b/src/tools/binance-wallet/others-api/index.ts @@ -1,10 +1,10 @@ //src/tools/binance-wallet/others-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceWalletSystemStatus } from "./systemStatus.js"; -import { registerBinanceWalletGetSymbolsDelistScheduleForSpot } from "./getSymbolsDelistScheduleForSpot.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceWalletGetSymbolsDelistScheduleForSpot } from "./getSymbolsDelistScheduleForSpot.js" +import { registerBinanceWalletSystemStatus } from "./systemStatus.js" export function registerBinanceWalletOthersApiTools(server: McpServer) { - registerBinanceWalletSystemStatus(server); - registerBinanceWalletGetSymbolsDelistScheduleForSpot(server); - -} \ No newline at end of file + registerBinanceWalletSystemStatus(server) + registerBinanceWalletGetSymbolsDelistScheduleForSpot(server) +} diff --git a/src/tools/binance-wallet/others-api/systemStatus.ts b/src/tools/binance-wallet/others-api/systemStatus.ts index 57e4133e..f2bcc1b3 100644 --- a/src/tools/binance-wallet/others-api/systemStatus.ts +++ b/src/tools/binance-wallet/others-api/systemStatus.ts @@ -1,34 +1,29 @@ // src/tools/binance-wallet/others-api/systemStatus.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletSystemStatus(server: McpServer) { - server.tool( - "BinanceWalletSystemStatus", - "Get Binance Wallet system status.", - {}, - async () => { - try { - const response = await walletClient.restAPI.systemStatus(); - const data = await response.data(); + server.tool("BinanceWalletSystemStatus", "Get Binance Wallet system status.", {}, async () => { + try { + const response = await walletClient.restAPI.systemStatus() + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved system status. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved system status. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve system status: ${errorMessage}` } - ], - isError: true - }; - } - } - ); -} \ No newline at end of file + return { + content: [{ type: "text", text: `Failed to retrieve system status: ${errorMessage}` }], + isError: true, + } + } + }) +} diff --git a/src/tools/binance-wallet/travel-rule-api/brokerWithdraw.ts b/src/tools/binance-wallet/travel-rule-api/brokerWithdraw.ts index 08be01e6..f28f42ec 100644 --- a/src/tools/binance-wallet/travel-rule-api/brokerWithdraw.ts +++ b/src/tools/binance-wallet/travel-rule-api/brokerWithdraw.ts @@ -1,63 +1,79 @@ // src/tools/binance-wallet/travel-rule-api/brokerWithdraw.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletBrokerWithdraw(server: McpServer) { - server.tool( - "BinanceWalletBrokerWithdraw", - "Initiate broker withdrawal with travel rule compliance.", - { - subAccountId: z.string().describe("Sub-account ID"), - address: z.string().describe("Withdrawal address"), - coin: z.string().describe("Coin symbol"), - amount: z.number().describe("Withdrawal amount"), - withdrawOrderId: z.string().describe("Client order id"), - questionnaire: z.string().describe("Travel rule questionnaire"), - originatorPii: z.string().describe("Originator PII information"), - signature: z.string().describe("Signature"), - network: z.string().optional().describe("Network"), - addressTag: z.string().optional().describe("Secondary address identifier"), - name: z.string().optional().describe("Address name"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ subAccountId, address, coin, amount, withdrawOrderId, questionnaire, originatorPii, signature, network, addressTag, name, recvWindow }) => { - try { - const params: any = { - subAccountId, - address, - coin, - amount, - withdrawOrderId, - questionnaire, - originatorPii, - signature - }; - if (network !== undefined) params.network = network; - if (addressTag !== undefined) params.addressTag = addressTag; - if (name !== undefined) params.name = name; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.brokerWithdraw(params); - const data = await response.data(); + server.tool( + "BinanceWalletBrokerWithdraw", + "Initiate broker withdrawal with travel rule compliance.", + { + subAccountId: z.string().describe("Sub-account ID"), + address: z.string().describe("Withdrawal address"), + coin: z.string().describe("Coin symbol"), + amount: z.number().describe("Withdrawal amount"), + withdrawOrderId: z.string().describe("Client order id"), + questionnaire: z.string().describe("Travel rule questionnaire"), + originatorPii: z.string().describe("Originator PII information"), + signature: z.string().describe("Signature"), + network: z.string().optional().describe("Network"), + addressTag: z.string().optional().describe("Secondary address identifier"), + name: z.string().optional().describe("Address name"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ + subAccountId, + address, + coin, + amount, + withdrawOrderId, + questionnaire, + originatorPii, + signature, + network, + addressTag, + name, + recvWindow, + }) => { + try { + const params: any = { + subAccountId, + address, + coin, + amount, + withdrawOrderId, + questionnaire, + originatorPii, + signature, + } + if (network !== undefined) params.network = network + if (addressTag !== undefined) params.addressTag = addressTag + if (name !== undefined) params.name = name + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.brokerWithdraw(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Broker withdraw request submitted. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Broker withdraw request submitted. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to submit broker withdraw request: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to submit broker withdraw request: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/travel-rule-api/depositHistoryTravelRule.ts b/src/tools/binance-wallet/travel-rule-api/depositHistoryTravelRule.ts index e86c7efa..9e1d7ef7 100644 --- a/src/tools/binance-wallet/travel-rule-api/depositHistoryTravelRule.ts +++ b/src/tools/binance-wallet/travel-rule-api/depositHistoryTravelRule.ts @@ -1,52 +1,53 @@ // src/tools/binance-wallet/travel-rule-api/depositHistoryTravelRule.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletDepositHistoryTravelRule(server: McpServer) { - server.tool( - "BinanceWalletDepositHistoryTravelRule", - "Get deposit history for travel rule.", - { - coin: z.string().optional().describe("Coin symbol"), - status: z.number().optional().describe("Deposit status"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - offset: z.number().optional().describe("Default 0"), - limit: z.number().optional().describe("Default 1000, max 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { - try { - const params: any = {}; - if (coin !== undefined) params.coin = coin; - if (status !== undefined) params.status = status; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (offset !== undefined) params.offset = offset; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.depositHistoryTravelRule(params); - const data = await response.data(); + server.tool( + "BinanceWalletDepositHistoryTravelRule", + "Get deposit history for travel rule.", + { + coin: z.string().optional().describe("Coin symbol"), + status: z.number().optional().describe("Deposit status"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + offset: z.number().optional().describe("Default 0"), + limit: z.number().optional().describe("Default 1000, max 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { + try { + const params: any = {} + if (coin !== undefined) params.coin = coin + if (status !== undefined) params.status = status + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (offset !== undefined) params.offset = offset + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.depositHistoryTravelRule(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved deposit history for travel rule. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved deposit history for travel rule. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve deposit history: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve deposit history: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/travel-rule-api/index.ts b/src/tools/binance-wallet/travel-rule-api/index.ts index 5cafccd8..9e76b47d 100644 --- a/src/tools/binance-wallet/travel-rule-api/index.ts +++ b/src/tools/binance-wallet/travel-rule-api/index.ts @@ -1,22 +1,22 @@ //src/tools/binance-wallet/travel-rule-api/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceWalletBrokerWithdraw } from "./brokerWithdraw.js"; -import { registerBinanceWalletOnboardedVaspList } from "./onboardedVaspList.js"; -import { registerBinanceWalletSubmitDepositQuestionnaire } from "./submitDepositQuestionnaire.js"; -import { registerBinanceWalletWithdrawHistoryV1 } from "./withdrawHistoryV1.js"; -import { registerBinanceWalletDepositHistoryTravelRule } from "./depositHistoryTravelRule.js"; -import { registerBinanceWalletWithdrawHistoryV2 } from "./withdrawHistoryV2.js"; -import { registerBinanceWalletWithdrawTravelRule } from "./withdrawTravelRule.js"; -import { registerBinanceWalletSubmitDepositQuestionnaireTravelRule } from "./submitDepositQuestionnaireTravelRule.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceWalletBrokerWithdraw } from "./brokerWithdraw.js" +import { registerBinanceWalletDepositHistoryTravelRule } from "./depositHistoryTravelRule.js" +import { registerBinanceWalletOnboardedVaspList } from "./onboardedVaspList.js" +import { registerBinanceWalletSubmitDepositQuestionnaire } from "./submitDepositQuestionnaire.js" +import { registerBinanceWalletSubmitDepositQuestionnaireTravelRule } from "./submitDepositQuestionnaireTravelRule.js" +import { registerBinanceWalletWithdrawHistoryV1 } from "./withdrawHistoryV1.js" +import { registerBinanceWalletWithdrawHistoryV2 } from "./withdrawHistoryV2.js" +import { registerBinanceWalletWithdrawTravelRule } from "./withdrawTravelRule.js" export function registerBinanceWalletTravelRuleApiTools(server: McpServer) { - registerBinanceWalletBrokerWithdraw(server); - registerBinanceWalletOnboardedVaspList(server); - registerBinanceWalletSubmitDepositQuestionnaire(server); - registerBinanceWalletWithdrawHistoryV1(server); - registerBinanceWalletDepositHistoryTravelRule(server); - registerBinanceWalletWithdrawHistoryV2(server); - registerBinanceWalletWithdrawTravelRule(server); - registerBinanceWalletSubmitDepositQuestionnaireTravelRule(server); - -} \ No newline at end of file + registerBinanceWalletBrokerWithdraw(server) + registerBinanceWalletOnboardedVaspList(server) + registerBinanceWalletSubmitDepositQuestionnaire(server) + registerBinanceWalletWithdrawHistoryV1(server) + registerBinanceWalletDepositHistoryTravelRule(server) + registerBinanceWalletWithdrawHistoryV2(server) + registerBinanceWalletWithdrawTravelRule(server) + registerBinanceWalletSubmitDepositQuestionnaireTravelRule(server) +} diff --git a/src/tools/binance-wallet/travel-rule-api/onboardedVaspList.ts b/src/tools/binance-wallet/travel-rule-api/onboardedVaspList.ts index d78089c6..c6d74c32 100644 --- a/src/tools/binance-wallet/travel-rule-api/onboardedVaspList.ts +++ b/src/tools/binance-wallet/travel-rule-api/onboardedVaspList.ts @@ -1,35 +1,36 @@ // src/tools/binance-wallet/travel-rule-api/onboardedVaspList.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletOnboardedVaspList(server: McpServer) { - server.tool( - "BinanceWalletOnboardedVaspList", - "Get list of onboarded VASPs (Virtual Asset Service Providers).", - {}, - async () => { - try { - const response = await walletClient.restAPI.onboardedVaspList(); - const data = await response.data(); + server.tool( + "BinanceWalletOnboardedVaspList", + "Get list of onboarded VASPs (Virtual Asset Service Providers).", + {}, + async () => { + try { + const response = await walletClient.restAPI.onboardedVaspList() + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved onboarded VASP list. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved onboarded VASP list. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve onboarded VASP list: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to retrieve onboarded VASP list: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaire.ts b/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaire.ts index 37ef2dc6..76a8e0ba 100644 --- a/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaire.ts +++ b/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaire.ts @@ -1,51 +1,54 @@ // src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaire.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletSubmitDepositQuestionnaire(server: McpServer) { - server.tool( - "BinanceWalletSubmitDepositQuestionnaire", - "Submit deposit questionnaire for broker deposit.", - { - subAccountId: z.string().describe("Sub-account ID"), - depositId: z.string().describe("Deposit ID"), - questionnaire: z.string().describe("Travel rule questionnaire"), - beneficiaryPii: z.string().describe("Beneficiary PII information"), - signature: z.string().describe("Signature"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ subAccountId, depositId, questionnaire, beneficiaryPii, signature, recvWindow }) => { - try { - const params: any = { - subAccountId, - depositId, - questionnaire, - beneficiaryPii, - signature - }; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.submitDepositQuestionnaire(params); - const data = await response.data(); + server.tool( + "BinanceWalletSubmitDepositQuestionnaire", + "Submit deposit questionnaire for broker deposit.", + { + subAccountId: z.string().describe("Sub-account ID"), + depositId: z.string().describe("Deposit ID"), + questionnaire: z.string().describe("Travel rule questionnaire"), + beneficiaryPii: z.string().describe("Beneficiary PII information"), + signature: z.string().describe("Signature"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ subAccountId, depositId, questionnaire, beneficiaryPii, signature, recvWindow }) => { + try { + const params: any = { + subAccountId, + depositId, + questionnaire, + beneficiaryPii, + signature, + } + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.submitDepositQuestionnaire(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Submitted deposit questionnaire for broker deposit. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Submitted deposit questionnaire for broker deposit. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to submit deposit questionnaire: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to submit deposit questionnaire: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts b/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts index 4d2f4f9e..1160d5c9 100644 --- a/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts +++ b/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts @@ -1,45 +1,48 @@ // src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletSubmitDepositQuestionnaireTravelRule(server: McpServer) { - server.tool( - "BinanceWalletSubmitDepositQuestionnaireTravelRule", - "Submit deposit questionnaire for travel rule.", - { - tranId: z.number().describe("Transaction ID"), - questionnaire: z.string().describe("Travel rule questionnaire"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ tranId, questionnaire, recvWindow }) => { - try { - const params: any = { - tranId, - questionnaire - }; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.submitDepositQuestionnaireTravelRule(params); - const data = await response.data(); + server.tool( + "BinanceWalletSubmitDepositQuestionnaireTravelRule", + "Submit deposit questionnaire for travel rule.", + { + tranId: z.number().describe("Transaction ID"), + questionnaire: z.string().describe("Travel rule questionnaire"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ tranId, questionnaire, recvWindow }) => { + try { + const params: any = { + tranId, + questionnaire, + } + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.submitDepositQuestionnaireTravelRule(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Submitted deposit questionnaire for travel rule. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Submitted deposit questionnaire for travel rule. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to submit deposit questionnaire: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { type: "text", text: `Failed to submit deposit questionnaire: ${errorMessage}` }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV1.ts b/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV1.ts index 4cf980f9..a1beb2c2 100644 --- a/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV1.ts +++ b/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV1.ts @@ -1,52 +1,53 @@ // src/tools/binance-wallet/travel-rule-api/withdrawHistoryV1.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletWithdrawHistoryV1(server: McpServer) { - server.tool( - "BinanceWalletWithdrawHistoryV1", - "Get withdraw history (v1).", - { - coin: z.string().optional().describe("Coin symbol"), - status: z.number().optional().describe("Withdraw status"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - offset: z.number().optional().describe("Default 0"), - limit: z.number().optional().describe("Default 1000, max 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { - try { - const params: any = {}; - if (coin !== undefined) params.coin = coin; - if (status !== undefined) params.status = status; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (offset !== undefined) params.offset = offset; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.withdrawHistoryV1(params); - const data = await response.data(); + server.tool( + "BinanceWalletWithdrawHistoryV1", + "Get withdraw history (v1).", + { + coin: z.string().optional().describe("Coin symbol"), + status: z.number().optional().describe("Withdraw status"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + offset: z.number().optional().describe("Default 0"), + limit: z.number().optional().describe("Default 1000, max 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { + try { + const params: any = {} + if (coin !== undefined) params.coin = coin + if (status !== undefined) params.status = status + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (offset !== undefined) params.offset = offset + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.withdrawHistoryV1(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved withdraw history v1. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved withdraw history v1. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve withdraw history: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve withdraw history: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV2.ts b/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV2.ts index 2b20d3a2..fac53e5d 100644 --- a/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV2.ts +++ b/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV2.ts @@ -1,52 +1,53 @@ // src/tools/binance-wallet/travel-rule-api/withdrawHistoryV2.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletWithdrawHistoryV2(server: McpServer) { - server.tool( - "BinanceWalletWithdrawHistoryV2", - "Get withdraw history (v2).", - { - coin: z.string().optional().describe("Coin symbol"), - status: z.number().optional().describe("Withdraw status"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - offset: z.number().optional().describe("Default 0"), - limit: z.number().optional().describe("Default 1000, max 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { - try { - const params: any = {}; - if (coin !== undefined) params.coin = coin; - if (status !== undefined) params.status = status; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (offset !== undefined) params.offset = offset; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.withdrawHistoryV2(params); - const data = await response.data(); + server.tool( + "BinanceWalletWithdrawHistoryV2", + "Get withdraw history (v2).", + { + coin: z.string().optional().describe("Coin symbol"), + status: z.number().optional().describe("Withdraw status"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + offset: z.number().optional().describe("Default 0"), + limit: z.number().optional().describe("Default 1000, max 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { + try { + const params: any = {} + if (coin !== undefined) params.coin = coin + if (status !== undefined) params.status = status + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (offset !== undefined) params.offset = offset + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.withdrawHistoryV2(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Retrieved withdraw history v2. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Retrieved withdraw history v2. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to retrieve withdraw history: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to retrieve withdraw history: ${errorMessage}` }], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binance-wallet/travel-rule-api/withdrawTravelRule.ts b/src/tools/binance-wallet/travel-rule-api/withdrawTravelRule.ts index 5d7bd8bf..b9e385ec 100644 --- a/src/tools/binance-wallet/travel-rule-api/withdrawTravelRule.ts +++ b/src/tools/binance-wallet/travel-rule-api/withdrawTravelRule.ts @@ -1,57 +1,73 @@ // src/tools/binance-wallet/travel-rule-api/withdrawTravelRule.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { walletClient } from "../../../config/binanceClient.js" export function registerBinanceWalletWithdrawTravelRule(server: McpServer) { - server.tool( - "BinanceWalletWithdrawTravelRule", - "Withdraw with travel rule compliance.", - { - coin: z.string().describe("Coin symbol"), - address: z.string().describe("Withdrawal address"), - amount: z.number().describe("Withdrawal amount"), - withdrawOrderId: z.string().optional().describe("Client order id"), - network: z.string().optional().describe("Network"), - addressTag: z.string().optional().describe("Secondary address identifier"), - name: z.string().optional().describe("Address name"), - questionnaire: z.string().describe("Travel rule questionnaire"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async ({ coin, address, amount, withdrawOrderId, network, addressTag, name, questionnaire, recvWindow }) => { - try { - const params: any = { - coin, - address, - amount, - questionnaire - }; - if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId; - if (network !== undefined) params.network = network; - if (addressTag !== undefined) params.addressTag = addressTag; - if (name !== undefined) params.name = name; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const response = await walletClient.restAPI.withdrawTravelRule(params); - const data = await response.data(); + server.tool( + "BinanceWalletWithdrawTravelRule", + "Withdraw with travel rule compliance.", + { + coin: z.string().describe("Coin symbol"), + address: z.string().describe("Withdrawal address"), + amount: z.number().describe("Withdrawal amount"), + withdrawOrderId: z.string().optional().describe("Client order id"), + network: z.string().optional().describe("Network"), + addressTag: z.string().optional().describe("Secondary address identifier"), + name: z.string().optional().describe("Address name"), + questionnaire: z.string().describe("Travel rule questionnaire"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ + coin, + address, + amount, + withdrawOrderId, + network, + addressTag, + name, + questionnaire, + recvWindow, + }) => { + try { + const params: any = { + coin, + address, + amount, + questionnaire, + } + if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId + if (network !== undefined) params.network = network + if (addressTag !== undefined) params.addressTag = addressTag + if (name !== undefined) params.name = name + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const response = await walletClient.restAPI.withdrawTravelRule(params) + const data = await response.data() + + return { + content: [ + { + type: "text", + text: `Withdraw travel rule request submitted. Response: ${JSON.stringify(data)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - return { - content: [ - { - type: "text", - text: `Withdraw travel rule request submitted. Response: ${JSON.stringify(data)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to submit withdraw travel rule request: ${errorMessage}` } - ], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Failed to submit withdraw travel rule request: ${errorMessage}`, + }, + ], + isError: true, } - ); -} \ No newline at end of file + } + }, + ) +} diff --git a/src/tools/binanceAccountInfo.ts b/src/tools/binanceAccountInfo.ts index 6706eee2..66323600 100644 --- a/src/tools/binanceAccountInfo.ts +++ b/src/tools/binanceAccountInfo.ts @@ -1,58 +1,64 @@ -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../config/client.js"; -import { AccountSnapshotType } from "@binance/connector-typescript"; -export function registerBinanceAccountInfo(server: McpServer) { - server.tool( - "binanceAccountInfo", - "check binance account info", - {}, - async ({}) => { - try { - const accountInfo = await spotClient.accountInformation(); - const accountSnapshot = await spotClient.dailyAccountSnapshot(AccountSnapshotType.SPOT, { limit: 7 }); - const userAsset = await spotClient.userAsset({ needBtcValuation: true }) - if (userAsset) { - const balances = userAsset.map(item => ({ - asset: item.asset, free: item.free, locked: item.locked - })) - const totalAssetOfBtc = userAsset.reduce((sum, item) => sum + parseFloat(item.btcValuation || "0"), 0).toFixed(20).replace(/\.?0+$/, ""); - accountSnapshot.snapshotVos.push({ - type: "spot", - updateTime: Date.now(), - data: { - totalAssetOfBtc, - balances, - } - }) - } - const btcPrice = await spotClient.symbolPriceTicker({ symbol: "BTCUSDT" }); - return { - content: [ - { - type: "text", - text: `Get binance account info successfully. data: ${JSON.stringify(accountInfo)}`, - }, - { - type: "text", - text: `Get binance balance history info successfully. data: ${JSON.stringify(accountSnapshot)}`, - }, - { - type: "text", - text: `Get BTC price successfully. data: ${JSON.stringify(btcPrice)}`, - }, - ], - }; - } catch (error) { - const errorMessage = - error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Server failed: ${errorMessage}` }, - ], - isError: true, - }; - } - } - ); -} \ No newline at end of file +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { AccountSnapshotType } from "@binance/connector-typescript" + +import { spotClient } from "../config/client.js" +export function registerBinanceAccountInfo(server: McpServer) { + server.tool("binanceAccountInfo", "check binance account info", {}, async (_params) => { + try { + const accountInfo = await spotClient.accountInformation() + const accountSnapshot = await spotClient.dailyAccountSnapshot(AccountSnapshotType.SPOT, { + limit: 7, + }) + const userAsset = await spotClient.userAsset({ + needBtcValuation: true, + }) + if (userAsset) { + const balances = userAsset.map((item) => ({ + asset: item.asset, + free: item.free, + locked: item.locked, + })) + const totalAssetOfBtc = userAsset + .reduce((sum, item) => sum + parseFloat(item.btcValuation || "0"), 0) + .toFixed(20) + .replace(/\.?0+$/, "") + accountSnapshot.snapshotVos.push({ + type: "spot", + updateTime: Date.now(), + data: { + totalAssetOfBtc, + balances, + }, + }) + } + const btcPrice = await spotClient.symbolPriceTicker({ + symbol: "BTCUSDT", + }) + + return { + content: [ + { + type: "text", + text: `Get binance account info successfully. data: ${JSON.stringify(accountInfo)}`, + }, + { + type: "text", + text: `Get binance balance history info successfully. data: ${JSON.stringify(accountSnapshot)}`, + }, + { + type: "text", + text: `Get BTC price successfully. data: ${JSON.stringify(btcPrice)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Server failed: ${errorMessage}` }], + isError: true, + } + } + }) +} diff --git a/src/tools/binanceOrderBook.ts b/src/tools/binanceOrderBook.ts index 2a47d9ed..c018a0f7 100644 --- a/src/tools/binanceOrderBook.ts +++ b/src/tools/binanceOrderBook.ts @@ -1,37 +1,36 @@ -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { spotClient } from "../config/client.js"; - -export function registerBinanceOrderBook(server: McpServer) { - server.tool( - "binanceOrderBook", - "check binance order book", - { - symbol: z.string().describe("symbol: exemple: BTCUSDT"), - }, - async ({ symbol }) => { - try { - - const orderBook = await spotClient.orderBook(symbol, {limit: 50}); - - return { - content: [ - { - type: "text", - text: `Get binance order book successfully. data: ${JSON.stringify(orderBook)}}`, - }, - ], - }; - } catch (error) { - const errorMessage = - error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Server failed: ${errorMessage}` }, - ], - isError: true, - }; - } - } - ); -} +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { spotClient } from "../config/client.js" + +export function registerBinanceOrderBook(server: McpServer) { + server.tool( + "binanceOrderBook", + "check binance order book", + { + symbol: z.string().describe("symbol: exemple: BTCUSDT"), + }, + async ({ symbol }) => { + try { + const orderBook = await spotClient.orderBook(symbol, { limit: 50 }) + + return { + content: [ + { + type: "text", + text: `Get binance order book successfully. data: ${JSON.stringify(orderBook)}}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Server failed: ${errorMessage}` }], + isError: true, + } + } + }, + ) +} diff --git a/src/tools/binanceSpotPlaceOrder.ts b/src/tools/binanceSpotPlaceOrder.ts index 3e39982c..a80c62a4 100644 --- a/src/tools/binanceSpotPlaceOrder.ts +++ b/src/tools/binanceSpotPlaceOrder.ts @@ -1,49 +1,52 @@ -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { algoClient, spotClient } from "../config/client.js"; -import { OrderType, Side } from "@binance/connector-typescript"; - -export function registerBinanceSpotPlaceOrder(server: McpServer) { - server.tool( - "binanceSpotPlaceOrder", - `Trading for small orders will not generate significant selling pressure on the market`, - { - symbol: z.string().describe("symbol: exemple: BTCUSDT"), - side: z.enum(["BUY", "SELL"]).describe("BUY or SELL"), - quantity: z.number().describe("quantity Quantity of base asset").optional(), - quoteOrderQty: z.number().describe(`MARKET orders using quoteOrderQty specifies the amount the user wants to spend (when buying) or receive (when selling) the quote asset; the correct quantity will be determined based on the market liquidity and quoteOrderQty. - E.g. Using the symbol BTCUSDT: - BUY side, the order will buy as many BTC as quoteOrderQty USDT can. - SELL side, the order will sell as much BTC needed to receive quoteOrderQty USDT.`).optional(), - }, - async ({ symbol, side, quantity, quoteOrderQty }) => { - try { - - - const result = await spotClient.newOrder(symbol, side as Side, OrderType.MARKET, { - quantity, - quoteOrderQty, - }) - - - return { - content: [ - { - type: "text", - text: `Place a new spot TWAP order with Algo service successfully. result: ${JSON.stringify(result)}}`, - }, - ], - }; - } catch (error) { - const errorMessage = - error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Server failed: ${errorMessage}` }, - ], - isError: true, - }; - } - } - ); -} +import type { Side } from "@binance/connector-typescript" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { OrderType } from "@binance/connector-typescript" +import { z } from "zod" + +import { spotClient } from "../config/client.js" + +export function registerBinanceSpotPlaceOrder(server: McpServer) { + server.tool( + "binanceSpotPlaceOrder", + `Trading for small orders will not generate significant selling pressure on the market`, + { + symbol: z.string().describe("symbol: exemple: BTCUSDT"), + side: z.enum(["BUY", "SELL"]).describe("BUY or SELL"), + quantity: z.number().describe("quantity Quantity of base asset").optional(), + quoteOrderQty: z + .number() + .describe( + `MARKET orders using quoteOrderQty specifies the amount the user wants to spend (when buying) or receive (when selling) the quote asset; the correct quantity will be determined based on the market liquidity and quoteOrderQty. + E.g. Using the symbol BTCUSDT: + BUY side, the order will buy as many BTC as quoteOrderQty USDT can. + SELL side, the order will sell as much BTC needed to receive quoteOrderQty USDT.`, + ) + .optional(), + }, + async ({ symbol, side, quantity, quoteOrderQty }) => { + try { + const result = await spotClient.newOrder(symbol, side as Side, OrderType.MARKET, { + quantity, + quoteOrderQty, + }) + + return { + content: [ + { + type: "text", + text: `Place a new spot TWAP order with Algo service successfully. result: ${JSON.stringify(result)}}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Server failed: ${errorMessage}` }], + isError: true, + } + } + }, + ) +} diff --git a/src/tools/binanceTimeWeightedAveragePriceFutureAlgo.ts b/src/tools/binanceTimeWeightedAveragePriceFutureAlgo.ts index 15066269..4424b746 100644 --- a/src/tools/binanceTimeWeightedAveragePriceFutureAlgo.ts +++ b/src/tools/binanceTimeWeightedAveragePriceFutureAlgo.ts @@ -1,48 +1,50 @@ -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { algoClient, spotClient } from "../config/client.js"; - -export function registerBinanceTimeWeightedAveragePriceFutureAlgo(server: McpServer) { - server.tool( - "binanceTimeWeightedAveragePriceFutureAlgo", - `Place a new spot TWAP order with Algo service. Trading for large orders can generate significant selling pressure on the market`, - { - symbol: z.string().describe("symbol: exemple: BTCUSDT"), - side: z.enum(["BUY", "SELL"]).describe("BUY or SELL"), - quantity: z.number().describe("quantity Quantity of base asset; Maximum notional per order is 200k, 2mm or 10mm, depending on symbol. Please reduce your size if you order is above the maximum notional per order."), - duration: z.number().describe("duration Duration for TWAP orders in seconds. [300, 86400]"), - }, - async ({ symbol, side, quantity, duration }) => { - try { - - console.log({ symbol, side, quantity, duration }); - - const result = await algoClient.restAPI.timeWeightedAveragePriceSpotAlgo({ - symbol, - side, - quantity, - duration, - }); - - - return { - content: [ - { - type: "text", - text: `Place a new spot TWAP order with Algo service successfully. result: ${JSON.stringify(result)}}`, - }, - ], - }; - } catch (error) { - const errorMessage = - error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Server failed: ${errorMessage}` }, - ], - isError: true, - }; - } - } - ); -} +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { algoClient } from "../config/client.js" + +export function registerBinanceTimeWeightedAveragePriceFutureAlgo(server: McpServer) { + server.tool( + "binanceTimeWeightedAveragePriceFutureAlgo", + `Place a new spot TWAP order with Algo service. Trading for large orders can generate significant selling pressure on the market`, + { + symbol: z.string().describe("symbol: exemple: BTCUSDT"), + side: z.enum(["BUY", "SELL"]).describe("BUY or SELL"), + quantity: z + .number() + .describe( + "quantity Quantity of base asset; Maximum notional per order is 200k, 2mm or 10mm, depending on symbol. Please reduce your size if you order is above the maximum notional per order.", + ), + duration: z.number().describe("duration Duration for TWAP orders in seconds. [300, 86400]"), + }, + async ({ symbol, side, quantity, duration }) => { + try { + console.log({ symbol, side, quantity, duration }) + + const result = await algoClient.restAPI.timeWeightedAveragePriceSpotAlgo({ + symbol, + side, + quantity, + duration, + }) + + return { + content: [ + { + type: "text", + text: `Place a new spot TWAP order with Algo service successfully. result: ${JSON.stringify(result)}}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Server failed: ${errorMessage}` }], + isError: true, + } + } + }, + ) +} diff --git a/src/tools/credit-line/index.ts b/src/tools/credit-line/index.ts index 77ae74d2..712872d7 100644 --- a/src/tools/credit-line/index.ts +++ b/src/tools/credit-line/index.ts @@ -2,33 +2,35 @@ // Binance.US Credit Line Tools // For institutional clients with credit line agreements -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { makeSignedRequest } from "../../config/binanceUsClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { makeSignedRequest } from "../../config/binanceUsClient.js" /** * Register all Binance.US Credit Line tools - * - * ⚠️ IMPORTANT: These APIs require a Credit Line API key type and an institutional + * + * ⚠️ IMPORTANT: These APIs require a Credit Line API key type and an institutional * credit line agreement with Binance.US. These are NOT available to retail users. - * + * * Credit Line allows institutional clients to: * - Borrow assets against collateral * - Trade with borrowed funds * - Manage margin call and liquidation thresholds - * + * * Key metrics: * - LTV (Loan-to-Value): Current loan amount / collateral value * - Margin Call LTV: Threshold that triggers margin call alerts * - Liquidation LTV: Threshold that triggers automatic liquidation */ export function registerCreditLineTools(server: McpServer) { - // ===================================================================== - // GET /sapi/v2/cl/account - Get Credit Line Account Information - // ===================================================================== - server.tool( - "binance_us_cl_account", - `Get current credit line account information including LTV ratios, balances, and loan details. + // ===================================================================== + // GET /sapi/v2/cl/account - Get Credit Line Account Information + // ===================================================================== + server.tool( + "binance_us_cl_account", + `Get current credit line account information including LTV ratios, balances, and loan details. ⚠️ REQUIRES CREDIT LINE API KEY - Standard API keys will not work. ⚠️ Requires institutional credit line agreement with Binance.US. @@ -45,18 +47,18 @@ Returns comprehensive account information including: - availableAmountToTransferOut: How much can be withdrawn - loanAssets: Details of borrowed assets - balances: Current asset balances (collateral)`, - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async (params) => { - try { - const requestParams: Record = {}; - if (params.recvWindow) requestParams.recvWindow = params.recvWindow; - - const response = await makeSignedRequest("GET", "/sapi/v2/cl/account", requestParams); - - // Format key metrics for easy reading - const summary = `Credit Line Account Summary: + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async (params) => { + try { + const requestParams: Record = {} + if (params.recvWindow) requestParams.recvWindow = params.recvWindow + + const response = await makeSignedRequest("GET", "/sapi/v2/cl/account", requestParams) + + // Format key metrics for easy reading + const summary = `Credit Line Account Summary: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Account ID: ${response.clAccountId} Master Account: ${response.masterAccountId} @@ -82,30 +84,33 @@ Contract Period: End: ${new Date(response.contractEndTime).toISOString()} Required Deposit: ${response.requiredDepositAmount} -Available to Withdraw: ${response.availableAmountToTransferOut}`; - - return { - content: [{ - type: "text", - text: `${summary}\n\nFull Response:\n${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get credit line account: ${errorMessage}` }], - isError: true - }; - } +Available to Withdraw: ${response.availableAmountToTransferOut}` + + return { + content: [ + { + type: "text", + text: `${summary}\n\nFull Response:\n${JSON.stringify(response, null, 2)}`, + }, + ], } - ); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - // ===================================================================== - // GET /sapi/v1/cl/alert/history - Get Alert History (Margin Calls/Liquidations) - // ===================================================================== - server.tool( - "binance_us_cl_alert_history", - `Get margin call and liquidation alert history for your credit line account. + return { + content: [{ type: "text", text: `Failed to get credit line account: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================================== + // GET /sapi/v1/cl/alert/history - Get Alert History (Margin Calls/Liquidations) + // ===================================================================== + server.tool( + "binance_us_cl_alert_history", + `Get margin call and liquidation alert history for your credit line account. ⚠️ REQUIRES CREDIT LINE API KEY - Standard API keys will not work. ⚠️ Requires institutional credit line agreement with Binance.US. @@ -121,59 +126,65 @@ Returns alert records including: Use this to monitor your account's health history and understand when margin calls or liquidation warnings have occurred.`, - { - alertType: z.enum(["MARGIN_CALL", "LIQUIDATION_CALL"]).optional().describe("Filter by alert type"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Number of results. Default: 200"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async (params) => { - try { - const requestParams: Record = {}; - if (params.alertType) requestParams.alertType = params.alertType; - if (params.startTime) requestParams.startTime = params.startTime; - if (params.endTime) requestParams.endTime = params.endTime; - if (params.limit) requestParams.limit = params.limit; - if (params.recvWindow) requestParams.recvWindow = params.recvWindow; - - const response = await makeSignedRequest("GET", "/sapi/v1/cl/alert/history", requestParams); - - // Format alerts for readability - let alertSummary = "Credit Line Alert History:\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n"; - if (Array.isArray(response) && response.length > 0) { - response.forEach((alert: any, index: number) => { - alertSummary += `\n[${index + 1}] ${alert.alertType}\n`; - alertSummary += ` Time: ${new Date(alert.alertTime).toISOString()}\n`; - alertSummary += ` Current LTV: ${(parseFloat(alert.currentLTV) * 100).toFixed(2)}%\n`; - alertSummary += ` Total Balance: $${alert.totalBalance}\n`; - }); - } else { - alertSummary += "No alerts found.\n"; - } - - return { - content: [{ - type: "text", - text: `${alertSummary}\nFull Response:\n${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get alert history: ${errorMessage}` }], - isError: true - }; - } + { + alertType: z + .enum(["MARGIN_CALL", "LIQUIDATION_CALL"]) + .optional() + .describe("Filter by alert type"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Number of results. Default: 200"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async (params) => { + try { + const requestParams: Record = {} + if (params.alertType) requestParams.alertType = params.alertType + if (params.startTime) requestParams.startTime = params.startTime + if (params.endTime) requestParams.endTime = params.endTime + if (params.limit) requestParams.limit = params.limit + if (params.recvWindow) requestParams.recvWindow = params.recvWindow + + const response = await makeSignedRequest("GET", "/sapi/v1/cl/alert/history", requestParams) + + // Format alerts for readability + let alertSummary = "Credit Line Alert History:\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n" + if (Array.isArray(response) && response.length > 0) { + response.forEach((alert: any, index: number) => { + alertSummary += `\n[${index + 1}] ${alert.alertType}\n` + alertSummary += ` Time: ${new Date(alert.alertTime).toISOString()}\n` + alertSummary += ` Current LTV: ${(parseFloat(alert.currentLTV) * 100).toFixed(2)}%\n` + alertSummary += ` Total Balance: $${alert.totalBalance}\n` + }) + } else { + alertSummary += "No alerts found.\n" } - ); - // ===================================================================== - // GET /sapi/v1/cl/transferHistory - Get Transfer History - // ===================================================================== - server.tool( - "binance_us_cl_transfer_history", - `Get transfer history for your credit line account. + return { + content: [ + { + type: "text", + text: `${alertSummary}\nFull Response:\n${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get alert history: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================================== + // GET /sapi/v1/cl/transferHistory - Get Transfer History + // ===================================================================== + server.tool( + "binance_us_cl_transfer_history", + `Get transfer history for your credit line account. ⚠️ REQUIRES CREDIT LINE API KEY - Standard API keys will not work. ⚠️ Requires institutional credit line agreement with Binance.US. @@ -187,62 +198,72 @@ Returns transfer records including: - transferTime: When the transfer occurred Use this to track deposits and withdrawals from your credit line account.`, - { - transferType: z.enum(["TRANSFER_IN", "TRANSFER_OUT"]).optional().describe("Filter by transfer type"), - asset: z.string().optional().describe("Filter by asset, e.g., BTC, USD"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Number of results. Default: 20, Max: 100"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async (params) => { - try { - const requestParams: Record = {}; - if (params.transferType) requestParams.transferType = params.transferType; - if (params.asset) requestParams.asset = params.asset.toUpperCase(); - if (params.startTime) requestParams.startTime = params.startTime; - if (params.endTime) requestParams.endTime = params.endTime; - if (params.limit) requestParams.limit = params.limit; - if (params.recvWindow) requestParams.recvWindow = params.recvWindow; - - const response = await makeSignedRequest("GET", "/sapi/v1/cl/transferHistory", requestParams); - - // Format transfers for readability - let transferSummary = "Credit Line Transfer History:\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n"; - if (Array.isArray(response) && response.length > 0) { - response.forEach((transfer: any, index: number) => { - const direction = transfer.transferType === "TRANSFER_IN" ? "→ IN" : "← OUT"; - transferSummary += `\n[${index + 1}] ${direction} ${transfer.amount} ${transfer.asset}\n`; - transferSummary += ` ID: ${transfer.transferId}\n`; - transferSummary += ` Status: ${transfer.status}\n`; - transferSummary += ` Time: ${new Date(transfer.transferTime).toISOString()}\n`; - }); - } else { - transferSummary += "No transfers found.\n"; - } - - return { - content: [{ - type: "text", - text: `${transferSummary}\nFull Response:\n${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get transfer history: ${errorMessage}` }], - isError: true - }; - } + { + transferType: z + .enum(["TRANSFER_IN", "TRANSFER_OUT"]) + .optional() + .describe("Filter by transfer type"), + asset: z.string().optional().describe("Filter by asset, e.g., BTC, USD"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Number of results. Default: 20, Max: 100"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async (params) => { + try { + const requestParams: Record = {} + if (params.transferType) requestParams.transferType = params.transferType + if (params.asset) requestParams.asset = params.asset.toUpperCase() + if (params.startTime) requestParams.startTime = params.startTime + if (params.endTime) requestParams.endTime = params.endTime + if (params.limit) requestParams.limit = params.limit + if (params.recvWindow) requestParams.recvWindow = params.recvWindow + + const response = await makeSignedRequest( + "GET", + "/sapi/v1/cl/transferHistory", + requestParams, + ) + + // Format transfers for readability + let transferSummary = "Credit Line Transfer History:\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n" + if (Array.isArray(response) && response.length > 0) { + response.forEach((transfer: any, index: number) => { + const direction = transfer.transferType === "TRANSFER_IN" ? "→ IN" : "← OUT" + transferSummary += `\n[${index + 1}] ${direction} ${transfer.amount} ${transfer.asset}\n` + transferSummary += ` ID: ${transfer.transferId}\n` + transferSummary += ` Status: ${transfer.status}\n` + transferSummary += ` Time: ${new Date(transfer.transferTime).toISOString()}\n` + }) + } else { + transferSummary += "No transfers found.\n" + } + + return { + content: [ + { + type: "text", + text: `${transferSummary}\nFull Response:\n${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get transfer history: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) - // ===================================================================== - // POST /sapi/v1/cl/transfer - Execute Transfer - // ===================================================================== - server.tool( - "binance_us_cl_transfer", - `Transfer assets in or out of your credit line account. + // ===================================================================== + // POST /sapi/v1/cl/transfer - Execute Transfer + // ===================================================================== + server.tool( + "binance_us_cl_transfer", + `Transfer assets in or out of your credit line account. ⚠️ REQUIRES CREDIT LINE API KEY - Standard API keys will not work. ⚠️ Requires institutional credit line agreement with Binance.US. @@ -254,38 +275,43 @@ Transfer types: Note: Transferring out may be restricted if it would cause LTV to exceed limits. Check availableAmountToTransferOut in binance_us_cl_account first.`, - { - transferType: z.enum(["TRANSFER_IN", "TRANSFER_OUT"]).describe("Direction: TRANSFER_IN (deposit) or TRANSFER_OUT (withdraw)"), - transferAssetType: z.string().describe("Asset to transfer, e.g., BTC, USD"), - quantity: z.number().positive().describe("Amount to transfer"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000") - }, - async (params) => { - try { - const requestParams: Record = { - transferType: params.transferType, - transferAssetType: params.transferAssetType.toUpperCase(), - quantity: params.quantity - }; - if (params.recvWindow) requestParams.recvWindow = params.recvWindow; - - const response = await makeSignedRequest("POST", "/sapi/v1/cl/transfer", requestParams); - - const direction = params.transferType === "TRANSFER_IN" ? "deposited to" : "withdrawn from"; - - return { - content: [{ - type: "text", - text: `Transfer completed!\n\nTransfer ID: ${response.transferId}\nStatus: ${response.status}\n${params.quantity} ${params.transferAssetType.toUpperCase()} ${direction} credit line account.\n\nFull Response:\n${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to execute transfer: ${errorMessage}` }], - isError: true - }; - } + { + transferType: z + .enum(["TRANSFER_IN", "TRANSFER_OUT"]) + .describe("Direction: TRANSFER_IN (deposit) or TRANSFER_OUT (withdraw)"), + transferAssetType: z.string().describe("Asset to transfer, e.g., BTC, USD"), + quantity: z.number().positive().describe("Amount to transfer"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async (params) => { + try { + const requestParams: Record = { + transferType: params.transferType, + transferAssetType: params.transferAssetType.toUpperCase(), + quantity: params.quantity, + } + if (params.recvWindow) requestParams.recvWindow = params.recvWindow + + const response = await makeSignedRequest("POST", "/sapi/v1/cl/transfer", requestParams) + + const direction = params.transferType === "TRANSFER_IN" ? "deposited to" : "withdrawn from" + + return { + content: [ + { + type: "text", + text: `Transfer completed!\n\nTransfer ID: ${response.transferId}\nStatus: ${response.status}\n${params.quantity} ${params.transferAssetType.toUpperCase()} ${direction} credit line account.\n\nFull Response:\n${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to execute transfer: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/creditline/index.ts b/src/tools/creditline/index.ts index ef917b95..fb846b91 100644 --- a/src/tools/creditline/index.ts +++ b/src/tools/creditline/index.ts @@ -2,28 +2,30 @@ // Binance.US Credit Line Tools // For institutional credit line agreements -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { makeSignedRequest } from "../../config/binanceUsClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { makeSignedRequest } from "../../config/binanceUsClient.js" /** * Register all Binance.US Credit Line tools - * + * * ⚠️ IMPORTANT: These APIs require a Credit Line agreement with Binance.US. * They are only available to institutional users with approved credit facilities. * Standard Binance.US accounts do NOT have access to these endpoints. - * + * * Credit Line allows institutional traders to trade with borrowed funds, * similar to margin trading but with different risk parameters and * institutional-grade features. */ export function registerCreditLineTools(server: McpServer) { - // ===================================================================== - // GET /sapi/v2/cl/account - Get Credit Line Account Information - // ===================================================================== - server.tool( - "binance_us_cl_account", - `Get comprehensive credit line account information. + // ===================================================================== + // GET /sapi/v2/cl/account - Get Credit Line Account Information + // ===================================================================== + server.tool( + "binance_us_cl_account", + `Get comprehensive credit line account information. ⚠️ REQUIRES INSTITUTIONAL CREDIT LINE AGREEMENT This API is only available to institutional users with approved credit facilities. @@ -58,33 +60,39 @@ Loan Information: Balances: - balances: Array of asset balances (free, locked)`, - { - recvWindow: z.number().int().max(60000).optional().describe("Request validity window in ms (max: 60000)") - }, - async (params) => { - try { - const response = await makeSignedRequest("GET", "/sapi/v2/cl/account", { - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - // Calculate risk level based on LTV - let riskLevel = "LOW"; - const currentLTV = parseFloat(response.currentLTV); - const marginCallLTV = parseFloat(response.marginCallLTV); - const liquidationLTV = parseFloat(response.liquidationLTV); - - if (currentLTV >= liquidationLTV) { - riskLevel = "CRITICAL - LIQUIDATION IMMINENT"; - } else if (currentLTV >= marginCallLTV) { - riskLevel = "HIGH - MARGIN CALL"; - } else if (currentLTV >= marginCallLTV * 0.9) { - riskLevel = "MEDIUM"; - } - - return { - content: [{ - type: "text", - text: `Credit Line Account Info retrieved. + { + recvWindow: z + .number() + .int() + .max(60000) + .optional() + .describe("Request validity window in ms (max: 60000)"), + }, + async (params) => { + try { + const response = await makeSignedRequest("GET", "/sapi/v2/cl/account", { + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + // Calculate risk level based on LTV + let riskLevel = "LOW" + const currentLTV = parseFloat(response.currentLTV) + const marginCallLTV = parseFloat(response.marginCallLTV) + const liquidationLTV = parseFloat(response.liquidationLTV) + + if (currentLTV >= liquidationLTV) { + riskLevel = "CRITICAL - LIQUIDATION IMMINENT" + } else if (currentLTV >= marginCallLTV) { + riskLevel = "HIGH - MARGIN CALL" + } else if (currentLTV >= marginCallLTV * 0.9) { + riskLevel = "MEDIUM" + } + + return { + content: [ + { + type: "text", + text: `Credit Line Account Info retrieved. ⚠️ Risk Level: ${riskLevel} 📊 Current LTV: ${(currentLTV * 100).toFixed(2)}% @@ -92,25 +100,27 @@ Balances: 🔴 Liquidation LTV: ${(liquidationLTV * 100).toFixed(2)}% 💰 Interest Rate: ${(parseFloat(response.interestRate) * 100).toFixed(2)}% annual -Full Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get credit line account: ${errorMessage}` }], - isError: true - }; - } +Full Response: ${JSON.stringify(response, null, 2)}`, + }, + ], } - ); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - // ===================================================================== - // GET /sapi/v1/cl/alert/history - Get Alert History (Margin Call & Liquidation) - // ===================================================================== - server.tool( - "binance_us_cl_alert_history", - `Get margin call and liquidation alert history for credit line account. + return { + content: [{ type: "text", text: `Failed to get credit line account: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================================== + // GET /sapi/v1/cl/alert/history - Get Alert History (Margin Call & Liquidation) + // ===================================================================== + server.tool( + "binance_us_cl_alert_history", + `Get margin call and liquidation alert history for credit line account. ⚠️ REQUIRES INSTITUTIONAL CREDIT LINE AGREEMENT @@ -131,55 +141,75 @@ Use this to: - Review past risk events - Understand account risk patterns - Audit margin call history`, - { - startTime: z.number().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().optional().describe("End timestamp in milliseconds"), - limit: z.number().int().min(1).max(1000).optional().default(200).describe("Max records (default: 200)"), - alertType: z.enum(["LIQUIDATION_CALL", "MARGIN_CALL"]).optional().describe("Filter by alert type"), - recvWindow: z.number().int().max(60000).optional().describe("Request validity window (max: 60000)") - }, - async (params) => { - try { - const response = await makeSignedRequest("GET", "/sapi/v1/cl/alert/history", { - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.alertType && { alertType: params.alertType }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const alerts = Array.isArray(response) ? response : []; - const marginCalls = alerts.filter((a: any) => a.alertType === "MARGIN_CALL").length; - const liquidationCalls = alerts.filter((a: any) => a.alertType === "LIQUIDATION_CALL").length; - - return { - content: [{ - type: "text", - text: `Credit Line Alert History retrieved. + { + startTime: z.number().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().optional().describe("End timestamp in milliseconds"), + limit: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .default(200) + .describe("Max records (default: 200)"), + alertType: z + .enum(["LIQUIDATION_CALL", "MARGIN_CALL"]) + .optional() + .describe("Filter by alert type"), + recvWindow: z + .number() + .int() + .max(60000) + .optional() + .describe("Request validity window (max: 60000)"), + }, + async (params) => { + try { + const response = await makeSignedRequest("GET", "/sapi/v1/cl/alert/history", { + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.alertType && { alertType: params.alertType }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const alerts = Array.isArray(response) ? response : [] + const marginCalls = alerts.filter((a: any) => a.alertType === "MARGIN_CALL").length + const liquidationCalls = alerts.filter( + (a: any) => a.alertType === "LIQUIDATION_CALL", + ).length + + return { + content: [ + { + type: "text", + text: `Credit Line Alert History retrieved. 📊 Total Alerts: ${alerts.length} ⚠️ Margin Calls: ${marginCalls} 🔴 Liquidation Calls: ${liquidationCalls} -Full Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get alert history: ${errorMessage}` }], - isError: true - }; - } +Full Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get alert history: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) - // ===================================================================== - // GET /sapi/v1/cl/transferHistory - Get Transfer History - // ===================================================================== - server.tool( - "binance_us_cl_transfer_history", - `Get transfer history for credit line account. + // ===================================================================== + // GET /sapi/v1/cl/transferHistory - Get Transfer History + // ===================================================================== + server.tool( + "binance_us_cl_transfer_history", + `Get transfer history for credit line account. ⚠️ REQUIRES INSTITUTIONAL CREDIT LINE AGREEMENT @@ -199,57 +229,75 @@ Use this to: - Track collateral movements - Audit deposit/withdrawal history - Reconcile account activity`, - { - startTime: z.number().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().optional().describe("End timestamp in milliseconds"), - limit: z.number().int().min(1).max(100).optional().default(20).describe("Max records (default: 20, max: 100)"), - transferType: z.enum(["TRANSFER_IN", "TRANSFER_OUT"]).optional().describe("Filter by transfer direction"), - asset: z.string().optional().describe("Filter by asset (e.g., BTC, USD)"), - recvWindow: z.number().int().max(60000).optional().describe("Request validity window (max: 60000)") - }, - async (params) => { - try { - const response = await makeSignedRequest("GET", "/sapi/v1/cl/transferHistory", { - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.transferType && { transferType: params.transferType }), - ...(params.asset && { asset: params.asset.toUpperCase() }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const transfers = Array.isArray(response) ? response : []; - const transfersIn = transfers.filter((t: any) => t.transferType === "TRANSFER_IN").length; - const transfersOut = transfers.filter((t: any) => t.transferType === "TRANSFER_OUT").length; - - return { - content: [{ - type: "text", - text: `Credit Line Transfer History retrieved. + { + startTime: z.number().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().optional().describe("End timestamp in milliseconds"), + limit: z + .number() + .int() + .min(1) + .max(100) + .optional() + .default(20) + .describe("Max records (default: 20, max: 100)"), + transferType: z + .enum(["TRANSFER_IN", "TRANSFER_OUT"]) + .optional() + .describe("Filter by transfer direction"), + asset: z.string().optional().describe("Filter by asset (e.g., BTC, USD)"), + recvWindow: z + .number() + .int() + .max(60000) + .optional() + .describe("Request validity window (max: 60000)"), + }, + async (params) => { + try { + const response = await makeSignedRequest("GET", "/sapi/v1/cl/transferHistory", { + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.transferType && { transferType: params.transferType }), + ...(params.asset && { asset: params.asset.toUpperCase() }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const transfers = Array.isArray(response) ? response : [] + const transfersIn = transfers.filter((t: any) => t.transferType === "TRANSFER_IN").length + const transfersOut = transfers.filter((t: any) => t.transferType === "TRANSFER_OUT").length + + return { + content: [ + { + type: "text", + text: `Credit Line Transfer History retrieved. 📊 Total Transfers: ${transfers.length} 📥 Transfers In: ${transfersIn} 📤 Transfers Out: ${transfersOut} -Full Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get transfer history: ${errorMessage}` }], - isError: true - }; - } +Full Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get transfer history: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) - // ===================================================================== - // POST /sapi/v1/cl/transfer - Execute Transfer - // ===================================================================== - server.tool( - "binance_us_cl_transfer", - `Execute a transfer in or out of the credit line account. + // ===================================================================== + // POST /sapi/v1/cl/transfer - Execute Transfer + // ===================================================================== + server.tool( + "binance_us_cl_transfer", + `Execute a transfer in or out of the credit line account. ⚠️ REQUIRES INSTITUTIONAL CREDIT LINE AGREEMENT @@ -269,29 +317,36 @@ Transfer Types: Response includes: - transferId: Unique transfer identifier - status: SUCCESS, PENDING, or FAILED`, - { - transferType: z.enum(["TRANSFER_IN", "TRANSFER_OUT"]).describe("Direction: TRANSFER_IN (deposit) or TRANSFER_OUT (withdraw)"), - transferAssetType: z.string().describe("Asset to transfer (e.g., BTC, USD)"), - quantity: z.number().positive().describe("Amount to transfer"), - recvWindow: z.number().int().max(60000).optional().describe("Request validity window (max: 60000)") - }, - async (params) => { - try { - const response = await makeSignedRequest("POST", "/sapi/v1/cl/transfer", { - transferType: params.transferType, - transferAssetType: params.transferAssetType.toUpperCase(), - quantity: params.quantity, - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const actionText = params.transferType === "TRANSFER_IN" - ? "deposited into" - : "withdrawn from"; - - return { - content: [{ - type: "text", - text: `Credit Line Transfer executed. + { + transferType: z + .enum(["TRANSFER_IN", "TRANSFER_OUT"]) + .describe("Direction: TRANSFER_IN (deposit) or TRANSFER_OUT (withdraw)"), + transferAssetType: z.string().describe("Asset to transfer (e.g., BTC, USD)"), + quantity: z.number().positive().describe("Amount to transfer"), + recvWindow: z + .number() + .int() + .max(60000) + .optional() + .describe("Request validity window (max: 60000)"), + }, + async (params) => { + try { + const response = await makeSignedRequest("POST", "/sapi/v1/cl/transfer", { + transferType: params.transferType, + transferAssetType: params.transferAssetType.toUpperCase(), + quantity: params.quantity, + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const actionText = + params.transferType === "TRANSFER_IN" ? "deposited into" : "withdrawn from" + + return { + content: [ + { + type: "text", + text: `Credit Line Transfer executed. ${params.transferType === "TRANSFER_OUT" ? "⚠️ Your LTV ratio has increased. Monitor your position." : "✅ Collateral added. Your LTV ratio has decreased."} @@ -299,25 +354,27 @@ ${params.transferType === "TRANSFER_OUT" ? "⚠️ Your LTV ratio has increased. 📋 Transfer ID: ${response.transferId} ✅ Status: ${response.status} -Full Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to execute transfer: ${errorMessage}` }], - isError: true - }; - } +Full Response: ${JSON.stringify(response, null, 2)}`, + }, + ], } - ); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - // ===================================================================== - // GET /sapi/v1/cl/liquidation/history - Get Liquidation History - // ===================================================================== - server.tool( - "binance_us_cl_liquidation_history", - `Get liquidation history for credit line account. + return { + content: [{ type: "text", text: `Failed to execute transfer: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================================== + // GET /sapi/v1/cl/liquidation/history - Get Liquidation History + // ===================================================================== + server.tool( + "binance_us_cl_liquidation_history", + `Get liquidation history for credit line account. ⚠️ REQUIRES INSTITUTIONAL CREDIT LINE AGREEMENT @@ -334,41 +391,56 @@ Use this to: - Review past liquidation events - Understand liquidation patterns - Audit risk management effectiveness`, - { - startTime: z.number().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().optional().describe("End timestamp in milliseconds"), - limit: z.number().int().min(1).max(100).optional().default(20).describe("Max records (default: 20, max: 100)"), - recvWindow: z.number().int().max(60000).optional().describe("Request validity window (max: 60000)") - }, - async (params) => { - try { - const response = await makeSignedRequest("GET", "/sapi/v1/cl/liquidation/history", { - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.recvWindow && { recvWindow: params.recvWindow }) - }); - - const liquidations = Array.isArray(response) ? response : []; - - return { - content: [{ - type: "text", - text: `Credit Line Liquidation History retrieved. + { + startTime: z.number().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().optional().describe("End timestamp in milliseconds"), + limit: z + .number() + .int() + .min(1) + .max(100) + .optional() + .default(20) + .describe("Max records (default: 20, max: 100)"), + recvWindow: z + .number() + .int() + .max(60000) + .optional() + .describe("Request validity window (max: 60000)"), + }, + async (params) => { + try { + const response = await makeSignedRequest("GET", "/sapi/v1/cl/liquidation/history", { + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.recvWindow && { recvWindow: params.recvWindow }), + }) + + const liquidations = Array.isArray(response) ? response : [] + + return { + content: [ + { + type: "text", + text: `Credit Line Liquidation History retrieved. 🔴 Total Liquidations: ${liquidations.length} ${liquidations.length > 0 ? "⚠️ Review your risk management strategy." : "✅ No liquidation events found."} -Full Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get liquidation history: ${errorMessage}` }], - isError: true - }; - } +Full Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get liquidation history: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/custodial-solution/index.ts b/src/tools/custodial-solution/index.ts index 101d1252..ceecde3e 100644 --- a/src/tools/custodial-solution/index.ts +++ b/src/tools/custodial-solution/index.ts @@ -3,31 +3,33 @@ // ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY - Not available to regular users // Only for users with a Custody Exchange Network agreement -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { makeSignedRequest } from "../../config/binanceUsClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { makeSignedRequest } from "../../config/binanceUsClient.js" /** * Register all Binance.US Custodial Solution tools - * + * * ⚠️ IMPORTANT: These endpoints require a Custodial Solution API Key * Regular Exchange API Keys will NOT work with these endpoints. - * + * * Custodial Solution API is for institutional users who have entered into * a Custody Exchange Network agreement with a participating custody partner. - * + * * Categories: * - User Account Data (balance, supported assets) * - Transfer (wallet transfer, custodian transfer, undo transfer) * - Settlement (to custodial partner) */ export function registerCustodialSolutionTools(server: McpServer) { - // ===================================================================== - // GET /sapi/v1/custodian/balance - Get Account Balance - // ===================================================================== - server.tool( - "binance_us_custodial_balance", - `Get balance information for Binance.US exchange wallet and custodial sub-account. + // ===================================================================== + // GET /sapi/v1/custodian/balance - Get Account Balance + // ===================================================================== + server.tool( + "binance_us_custodial_balance", + `Get balance information for Binance.US exchange wallet and custodial sub-account. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY - Regular API keys will not work. @@ -41,37 +43,40 @@ Each balance includes: - locked: Locked balance (in orders, etc.) - inSettlement: Amount in settlement process (custodial only) - lastUpdatedTime: Last update timestamp`, - { - rail: z.string().describe("Custodial partner identifier (all uppercase, e.g., 'FIREBLOCKS')") - }, - async ({ rail }) => { - try { - const response = await makeSignedRequest("GET", "/sapi/v1/custodian/balance", { - rail: rail.toUpperCase() - }); - - return { - content: [{ - type: "text", - text: `Custodial Balance Information:\n${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get custodial balance: ${errorMessage}` }], - isError: true - }; - } + { + rail: z.string().describe("Custodial partner identifier (all uppercase, e.g., 'FIREBLOCKS')"), + }, + async ({ rail }) => { + try { + const response = await makeSignedRequest("GET", "/sapi/v1/custodian/balance", { + rail: rail.toUpperCase(), + }) + + return { + content: [ + { + type: "text", + text: `Custodial Balance Information:\n${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get custodial balance: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) - // ===================================================================== - // GET /sapi/v1/custodian/supportedAssetList - Get Supported Assets - // ===================================================================== - server.tool( - "binance_us_custodial_supported_assets", - `Get list of assets supported for custodial transfers and settlements. + // ===================================================================== + // GET /sapi/v1/custodian/supportedAssetList - Get Supported Assets + // ===================================================================== + server.tool( + "binance_us_custodial_supported_assets", + `Get list of assets supported for custodial transfers and settlements. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -83,350 +88,425 @@ Each asset includes: - asset: Asset symbol - precision: Decimal precision - network: Supported networks for the asset`, - { - rail: z.string().describe("Custodial partner identifier (all uppercase)") - }, - async ({ rail }) => { - try { - const response = await makeSignedRequest("GET", "/sapi/v1/custodian/supportedAssetList", { - rail: rail.toUpperCase() - }); - - return { - content: [{ - type: "text", - text: `Custodial Supported Assets:\n${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get supported assets: ${errorMessage}` }], - isError: true - }; - } + { + rail: z.string().describe("Custodial partner identifier (all uppercase)"), + }, + async ({ rail }) => { + try { + const response = await makeSignedRequest("GET", "/sapi/v1/custodian/supportedAssetList", { + rail: rail.toUpperCase(), + }) + + return { + content: [ + { + type: "text", + text: `Custodial Supported Assets:\n${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get supported assets: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) - // ===================================================================== - // POST /sapi/v1/custodian/walletTransfer - Transfer From Exchange Wallet - // ===================================================================== - server.tool( - "binance_us_custodial_wallet_transfer", - `Transfer assets from your Binance.US exchange wallet to your custodial sub-account. + // ===================================================================== + // POST /sapi/v1/custodian/walletTransfer - Transfer From Exchange Wallet + // ===================================================================== + server.tool( + "binance_us_custodial_wallet_transfer", + `Transfer assets from your Binance.US exchange wallet to your custodial sub-account. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY ⚠️ This moves funds - verify details carefully! This transfers from your main Binance.US account to your custodial sub-account, which can then be traded or settled to your custodial partner.`, - { - rail: z.string().describe("Custodial partner identifier (all uppercase)"), - asset: z.string().describe("Asset to transfer (e.g., BTC, ETH)"), - amount: z.number().positive().describe("Amount to transfer"), - clientOrderId: z.string().optional().describe("Your reference ID (auto-generated if not provided)") - }, - async ({ rail, asset, amount, clientOrderId }) => { - try { - const params: Record = { - rail: rail.toUpperCase(), - asset: asset.toUpperCase(), - amount - }; - if (clientOrderId) params.clientOrderId = clientOrderId; - - const response = await makeSignedRequest("POST", "/sapi/v1/custodian/walletTransfer", params); - - return { - content: [{ - type: "text", - text: `Wallet Transfer Submitted!\n\nTransfer ID: ${response.transferId}\nAsset: ${response.asset}\nAmount: ${response.amount}\nStatus: ${response.status}\n\nFull Response:\n${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to execute wallet transfer: ${errorMessage}` }], - isError: true - }; - } + { + rail: z.string().describe("Custodial partner identifier (all uppercase)"), + asset: z.string().describe("Asset to transfer (e.g., BTC, ETH)"), + amount: z.number().positive().describe("Amount to transfer"), + clientOrderId: z + .string() + .optional() + .describe("Your reference ID (auto-generated if not provided)"), + }, + async ({ rail, asset, amount, clientOrderId }) => { + try { + const params: Record = { + rail: rail.toUpperCase(), + asset: asset.toUpperCase(), + amount, } - ); + if (clientOrderId) params.clientOrderId = clientOrderId + + const response = await makeSignedRequest( + "POST", + "/sapi/v1/custodian/walletTransfer", + params, + ) + + return { + content: [ + { + type: "text", + text: `Wallet Transfer Submitted!\n\nTransfer ID: ${response.transferId}\nAsset: ${response.asset}\nAmount: ${response.amount}\nStatus: ${response.status}\n\nFull Response:\n${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to execute wallet transfer: ${errorMessage}` }], + isError: true, + } + } + }, + ) - // ===================================================================== - // POST /sapi/v1/custodian/custodianTransfer - Transfer From Custodian - // ===================================================================== - server.tool( - "binance_us_custodial_custodian_transfer", - `Request asset transfer from a custodial partner account to Binance.US custodial sub-account. + // ===================================================================== + // POST /sapi/v1/custodian/custodianTransfer - Transfer From Custodian + // ===================================================================== + server.tool( + "binance_us_custodial_custodian_transfer", + `Request asset transfer from a custodial partner account to Binance.US custodial sub-account. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY ⚠️ This initiates a transfer request to your custody partner! This requests your custodial partner to transfer assets to your Binance.US account. The actual transfer is executed by the custody partner.`, - { - rail: z.string().describe("Custodial partner identifier (all uppercase)"), - asset: z.string().describe("Asset to transfer (e.g., BTC, ETH)"), - amount: z.number().positive().describe("Amount to transfer"), - clientOrderId: z.string().optional().describe("Your reference ID (auto-generated if not provided)") - }, - async ({ rail, asset, amount, clientOrderId }) => { - try { - const params: Record = { - rail: rail.toUpperCase(), - asset: asset.toUpperCase(), - amount - }; - if (clientOrderId) params.clientOrderId = clientOrderId; - - const response = await makeSignedRequest("POST", "/sapi/v1/custodian/custodianTransfer", params); - - return { - content: [{ - type: "text", - text: `Custodian Transfer Requested!\n\nTransfer ID: ${response.transferId}\nAsset: ${response.asset}\nAmount: ${response.amount}\nStatus: ${response.status}\n\nFull Response:\n${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to request custodian transfer: ${errorMessage}` }], - isError: true - }; - } + { + rail: z.string().describe("Custodial partner identifier (all uppercase)"), + asset: z.string().describe("Asset to transfer (e.g., BTC, ETH)"), + amount: z.number().positive().describe("Amount to transfer"), + clientOrderId: z + .string() + .optional() + .describe("Your reference ID (auto-generated if not provided)"), + }, + async ({ rail, asset, amount, clientOrderId }) => { + try { + const params: Record = { + rail: rail.toUpperCase(), + asset: asset.toUpperCase(), + amount, + } + if (clientOrderId) params.clientOrderId = clientOrderId + + const response = await makeSignedRequest( + "POST", + "/sapi/v1/custodian/custodianTransfer", + params, + ) + + return { + content: [ + { + type: "text", + text: `Custodian Transfer Requested!\n\nTransfer ID: ${response.transferId}\nAsset: ${response.asset}\nAmount: ${response.amount}\nStatus: ${response.status}\n\nFull Response:\n${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to request custodian transfer: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) - // ===================================================================== - // POST /sapi/v1/custodian/undoTransfer - Undo Transfer - // ===================================================================== - server.tool( - "binance_us_custodial_undo_transfer", - `Undo a previous transfer from your custodial partner. + // ===================================================================== + // POST /sapi/v1/custodian/undoTransfer - Undo Transfer + // ===================================================================== + server.tool( + "binance_us_custodial_undo_transfer", + `Undo a previous transfer from your custodial partner. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY ⚠️ Only certain transfers can be undone - check with your custodial partner. This reverses a previous custodian transfer by its transfer ID.`, - { - rail: z.string().describe("Custodial partner identifier (all uppercase)"), - originTransferId: z.string().describe("The transfer ID of the original transfer to undo") - }, - async ({ rail, originTransferId }) => { - try { - const response = await makeSignedRequest("POST", "/sapi/v1/custodian/undoTransfer", { - rail: rail.toUpperCase(), - originTransferId - }); - - return { - content: [{ - type: "text", - text: `Transfer Undone!\n\nUndo Transfer ID: ${response.transferId}\nAsset: ${response.asset}\nAmount: ${response.amount}\n\nFull Response:\n${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to undo transfer: ${errorMessage}` }], - isError: true - }; - } + { + rail: z.string().describe("Custodial partner identifier (all uppercase)"), + originTransferId: z.string().describe("The transfer ID of the original transfer to undo"), + }, + async ({ rail, originTransferId }) => { + try { + const response = await makeSignedRequest("POST", "/sapi/v1/custodian/undoTransfer", { + rail: rail.toUpperCase(), + originTransferId, + }) + + return { + content: [ + { + type: "text", + text: `Transfer Undone!\n\nUndo Transfer ID: ${response.transferId}\nAsset: ${response.asset}\nAmount: ${response.amount}\n\nFull Response:\n${JSON.stringify(response, null, 2)}`, + }, + ], } - ); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - // ===================================================================== - // GET /sapi/v1/custodian/walletTransferHistory - Wallet Transfer History - // ===================================================================== - server.tool( - "binance_us_custodial_wallet_transfer_history", - `Get history of transfers from Binance.US exchange wallet to custodial sub-account. + return { + content: [{ type: "text", text: `Failed to undo transfer: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================================== + // GET /sapi/v1/custodian/walletTransferHistory - Wallet Transfer History + // ===================================================================== + server.tool( + "binance_us_custodial_wallet_transfer_history", + `Get history of transfers from Binance.US exchange wallet to custodial sub-account. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY Returns transfer history with status, amounts, and timestamps.`, - { - rail: z.string().describe("Custodial partner identifier (all uppercase)"), - transferId: z.string().optional().describe("Filter by specific transfer ID"), - clientOrderId: z.string().optional().describe("Filter by your reference ID"), - asset: z.string().optional().describe("Filter by asset (e.g., BTC)"), - startTime: z.number().optional().describe("Start time in milliseconds (default: 90 days ago)"), - endTime: z.number().optional().describe("End time in milliseconds (default: now)"), - page: z.number().optional().describe("Page number (default: 1)"), - limit: z.number().optional().describe("Results per page (default: 20, max: 100)") - }, - async ({ rail, transferId, clientOrderId, asset, startTime, endTime, page, limit }) => { - try { - const params: Record = { rail: rail.toUpperCase() }; - if (transferId) params.transferId = transferId; - if (clientOrderId) params.clientOrderId = clientOrderId; - if (asset) params.asset = asset.toUpperCase(); - if (startTime) params.startTime = startTime; - if (endTime) params.endTime = endTime; - if (page) params.page = page; - if (limit) params.limit = limit; - - const response = await makeSignedRequest("GET", "/sapi/v1/custodian/walletTransferHistory", params); - - return { - content: [{ - type: "text", - text: `Wallet Transfer History:\n\nTotal: ${response.total}\n\n${JSON.stringify(response.data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get wallet transfer history: ${errorMessage}` }], - isError: true - }; - } + { + rail: z.string().describe("Custodial partner identifier (all uppercase)"), + transferId: z.string().optional().describe("Filter by specific transfer ID"), + clientOrderId: z.string().optional().describe("Filter by your reference ID"), + asset: z.string().optional().describe("Filter by asset (e.g., BTC)"), + startTime: z + .number() + .optional() + .describe("Start time in milliseconds (default: 90 days ago)"), + endTime: z.number().optional().describe("End time in milliseconds (default: now)"), + page: z.number().optional().describe("Page number (default: 1)"), + limit: z.number().optional().describe("Results per page (default: 20, max: 100)"), + }, + async ({ rail, transferId, clientOrderId, asset, startTime, endTime, page, limit }) => { + try { + const params: Record = { rail: rail.toUpperCase() } + if (transferId) params.transferId = transferId + if (clientOrderId) params.clientOrderId = clientOrderId + if (asset) params.asset = asset.toUpperCase() + if (startTime) params.startTime = startTime + if (endTime) params.endTime = endTime + if (page) params.page = page + if (limit) params.limit = limit + + const response = await makeSignedRequest( + "GET", + "/sapi/v1/custodian/walletTransferHistory", + params, + ) + + return { + content: [ + { + type: "text", + text: `Wallet Transfer History:\n\nTotal: ${response.total}\n\n${JSON.stringify(response.data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to get wallet transfer history: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) - // ===================================================================== - // GET /sapi/v1/custodian/custodianTransferHistory - Custodian Transfer History - // ===================================================================== - server.tool( - "binance_us_custodial_custodian_transfer_history", - `Get history of transfers from custodial partner, including ExpressTrade and Undo transfers. + // ===================================================================== + // GET /sapi/v1/custodian/custodianTransferHistory - Custodian Transfer History + // ===================================================================== + server.tool( + "binance_us_custodial_custodian_transfer_history", + `Get history of transfers from custodial partner, including ExpressTrade and Undo transfers. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY Returns transfer history with status, amounts, and timestamps.`, - { - rail: z.string().describe("Custodial partner identifier (all uppercase)"), - transferId: z.string().optional().describe("Filter by specific transfer ID"), - clientOrderId: z.string().optional().describe("Filter by your reference ID"), - expressTradeTransfer: z.boolean().optional().describe("Filter by ExpressTrade transfers only"), - asset: z.string().optional().describe("Filter by asset (e.g., BTC)"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - page: z.number().optional().describe("Page number (default: 1)"), - limit: z.number().optional().describe("Results per page (default: 20, max: 100)") - }, - async ({ rail, transferId, clientOrderId, expressTradeTransfer, asset, startTime, endTime, page, limit }) => { - try { - const params: Record = { rail: rail.toUpperCase() }; - if (transferId) params.transferId = transferId; - if (clientOrderId) params.clientOrderId = clientOrderId; - if (expressTradeTransfer !== undefined) params.expressTradeTransfer = expressTradeTransfer; - if (asset) params.asset = asset.toUpperCase(); - if (startTime) params.startTime = startTime; - if (endTime) params.endTime = endTime; - if (page) params.page = page; - if (limit) params.limit = limit; - - const response = await makeSignedRequest("GET", "/sapi/v1/custodian/custodianTransferHistory", params); - - return { - content: [{ - type: "text", - text: `Custodian Transfer History:\n\nTotal: ${response.total}\n\n${JSON.stringify(response.data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get custodian transfer history: ${errorMessage}` }], - isError: true - }; - } + { + rail: z.string().describe("Custodial partner identifier (all uppercase)"), + transferId: z.string().optional().describe("Filter by specific transfer ID"), + clientOrderId: z.string().optional().describe("Filter by your reference ID"), + expressTradeTransfer: z + .boolean() + .optional() + .describe("Filter by ExpressTrade transfers only"), + asset: z.string().optional().describe("Filter by asset (e.g., BTC)"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + page: z.number().optional().describe("Page number (default: 1)"), + limit: z.number().optional().describe("Results per page (default: 20, max: 100)"), + }, + async ({ + rail, + transferId, + clientOrderId, + expressTradeTransfer, + asset, + startTime, + endTime, + page, + limit, + }) => { + try { + const params: Record = { rail: rail.toUpperCase() } + if (transferId) params.transferId = transferId + if (clientOrderId) params.clientOrderId = clientOrderId + if (expressTradeTransfer !== undefined) params.expressTradeTransfer = expressTradeTransfer + if (asset) params.asset = asset.toUpperCase() + if (startTime) params.startTime = startTime + if (endTime) params.endTime = endTime + if (page) params.page = page + if (limit) params.limit = limit + + const response = await makeSignedRequest( + "GET", + "/sapi/v1/custodian/custodianTransferHistory", + params, + ) + + return { + content: [ + { + type: "text", + text: `Custodian Transfer History:\n\nTotal: ${response.total}\n\n${JSON.stringify(response.data, null, 2)}`, + }, + ], } - ); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to get custodian transfer history: ${errorMessage}` }, + ], + isError: true, + } + } + }, + ) - // ===================================================================== - // POST /sapi/v1/custodian/settlement - Request Settlement - // ===================================================================== - server.tool( - "binance_us_custodial_settlement", - `Request settlement of assets from custodial sub-account to custodial partner. + // ===================================================================== + // POST /sapi/v1/custodian/settlement - Request Settlement + // ===================================================================== + server.tool( + "binance_us_custodial_settlement", + `Request settlement of assets from custodial sub-account to custodial partner. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY ⚠️ This sends funds to your custodial partner! This settles (withdraws) assets from your Binance.US custodial sub-account to your custody partner's vault.`, - { - rail: z.string().describe("Custodial partner identifier (all uppercase)"), - asset: z.string().describe("Asset to settle (e.g., BTC, ETH)"), - amount: z.number().positive().describe("Amount to settle"), - clientOrderId: z.string().optional().describe("Your reference ID (auto-generated if not provided)") - }, - async ({ rail, asset, amount, clientOrderId }) => { - try { - const params: Record = { - rail: rail.toUpperCase(), - asset: asset.toUpperCase(), - amount - }; - if (clientOrderId) params.clientOrderId = clientOrderId; - - const response = await makeSignedRequest("POST", "/sapi/v1/custodian/settlement", params); - - return { - content: [{ - type: "text", - text: `Settlement Requested!\n\nSettlement ID: ${response.settlementId}\nAsset: ${response.asset}\nAmount: ${response.amount}\nStatus: ${response.status}\n\nFull Response:\n${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to request settlement: ${errorMessage}` }], - isError: true - }; - } + { + rail: z.string().describe("Custodial partner identifier (all uppercase)"), + asset: z.string().describe("Asset to settle (e.g., BTC, ETH)"), + amount: z.number().positive().describe("Amount to settle"), + clientOrderId: z + .string() + .optional() + .describe("Your reference ID (auto-generated if not provided)"), + }, + async ({ rail, asset, amount, clientOrderId }) => { + try { + const params: Record = { + rail: rail.toUpperCase(), + asset: asset.toUpperCase(), + amount, } - ); + if (clientOrderId) params.clientOrderId = clientOrderId + + const response = await makeSignedRequest("POST", "/sapi/v1/custodian/settlement", params) - // ===================================================================== - // GET /sapi/v1/custodian/settlementHistory - Settlement History - // ===================================================================== - server.tool( - "binance_us_custodial_settlement_history", - `Get history of settlements from custodial sub-account to custodial partner. + return { + content: [ + { + type: "text", + text: `Settlement Requested!\n\nSettlement ID: ${response.settlementId}\nAsset: ${response.asset}\nAmount: ${response.amount}\nStatus: ${response.status}\n\nFull Response:\n${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to request settlement: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================================== + // GET /sapi/v1/custodian/settlementHistory - Settlement History + // ===================================================================== + server.tool( + "binance_us_custodial_settlement_history", + `Get history of settlements from custodial sub-account to custodial partner. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY Returns settlement history with status, amounts, and timestamps.`, - { - rail: z.string().describe("Custodial partner identifier (all uppercase)"), - settlementId: z.string().optional().describe("Filter by specific settlement ID"), - clientOrderId: z.string().optional().describe("Filter by your reference ID"), - asset: z.string().optional().describe("Filter by asset (e.g., BTC)"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - page: z.number().optional().describe("Page number (default: 1)"), - limit: z.number().optional().describe("Results per page (default: 20, max: 100)") - }, - async ({ rail, settlementId, clientOrderId, asset, startTime, endTime, page, limit }) => { - try { - const params: Record = { rail: rail.toUpperCase() }; - if (settlementId) params.settlementId = settlementId; - if (clientOrderId) params.clientOrderId = clientOrderId; - if (asset) params.asset = asset.toUpperCase(); - if (startTime) params.startTime = startTime; - if (endTime) params.endTime = endTime; - if (page) params.page = page; - if (limit) params.limit = limit; - - const response = await makeSignedRequest("GET", "/sapi/v1/custodian/settlementHistory", params); - - return { - content: [{ - type: "text", - text: `Settlement History:\n\nTotal: ${response.total}\n\n${JSON.stringify(response.data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get settlement history: ${errorMessage}` }], - isError: true - }; - } + { + rail: z.string().describe("Custodial partner identifier (all uppercase)"), + settlementId: z.string().optional().describe("Filter by specific settlement ID"), + clientOrderId: z.string().optional().describe("Filter by your reference ID"), + asset: z.string().optional().describe("Filter by asset (e.g., BTC)"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + page: z.number().optional().describe("Page number (default: 1)"), + limit: z.number().optional().describe("Results per page (default: 20, max: 100)"), + }, + async ({ rail, settlementId, clientOrderId, asset, startTime, endTime, page, limit }) => { + try { + const params: Record = { rail: rail.toUpperCase() } + if (settlementId) params.settlementId = settlementId + if (clientOrderId) params.clientOrderId = clientOrderId + if (asset) params.asset = asset.toUpperCase() + if (startTime) params.startTime = startTime + if (endTime) params.endTime = endTime + if (page) params.page = page + if (limit) params.limit = limit + + const response = await makeSignedRequest( + "GET", + "/sapi/v1/custodian/settlementHistory", + params, + ) + + return { + content: [ + { + type: "text", + text: `Settlement History:\n\nTotal: ${response.total}\n\n${JSON.stringify(response.data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get settlement history: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/custodial/index.ts b/src/tools/custodial/index.ts index 3115c856..4b73cc75 100644 --- a/src/tools/custodial/index.ts +++ b/src/tools/custodial/index.ts @@ -2,47 +2,51 @@ // Binance.US Custodial Solution Tools // For institutional custody partners (e.g., Anchorage, BitGo) -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { makeSignedRequest } from "../../config/binanceUsClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { makeSignedRequest } from "../../config/binanceUsClient.js" // Common schema for rail parameter (custodial partner) -const railSchema = z.string().describe("Custodial partner name (e.g., ANCHORAGE, BITGO). Must be uppercase."); +const railSchema = z + .string() + .describe("Custodial partner name (e.g., ANCHORAGE, BITGO). Must be uppercase.") // Order type enum const orderTypeEnum = z.enum([ - "LIMIT", - "MARKET", - "STOP_LOSS", - "STOP_LOSS_LIMIT", - "TAKE_PROFIT", - "TAKE_PROFIT_LIMIT", - "LIMIT_MAKER" -]); + "LIMIT", + "MARKET", + "STOP_LOSS", + "STOP_LOSS_LIMIT", + "TAKE_PROFIT", + "TAKE_PROFIT_LIMIT", + "LIMIT_MAKER", +]) // Order side enum -const orderSideEnum = z.enum(["BUY", "SELL"]); +const orderSideEnum = z.enum(["BUY", "SELL"]) // Time in force enum -const timeInForceEnum = z.enum(["GTC", "IOC", "FOK"]); +const timeInForceEnum = z.enum(["GTC", "IOC", "FOK"]) /** * Register all Binance.US Custodial Solution tools - * + * * ⚠️ IMPORTANT: These APIs require a special Custodial Solution API key type. * Standard Binance.US API keys will NOT work with these endpoints. - * + * * Custodial Solution is designed for institutional custody partners like * Anchorage, allowing them to trade on behalf of their clients while * maintaining custody of the assets. */ export function registerCustodialTools(server: McpServer) { - // ===================================================================== - // GET /sapi/v1/custodian/balance - Get Custodial Account Balance - // ===================================================================== - server.tool( - "binance_us_cust_balance", - `Get balance information for Binance.US exchange wallet and custodial sub-account. + // ===================================================================== + // GET /sapi/v1/custodian/balance - Get Custodial Account Balance + // ===================================================================== + server.tool( + "binance_us_cust_balance", + `Get balance information for Binance.US exchange wallet and custodial sub-account. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY - Standard API keys will not work. @@ -58,37 +62,40 @@ Each balance entry contains: - locked: Locked balance - inSettlement: Amount in settlement (custodial only) - lastUpdatedTime: Last update timestamp`, - { - rail: railSchema - }, - async (params) => { - try { - const response = await makeSignedRequest("GET", "/sapi/v1/custodian/balance", { - rail: params.rail.toUpperCase() - }); - - return { - content: [{ - type: "text", - text: `Successfully retrieved custodial balance. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get custodial balance: ${errorMessage}` }], - isError: true - }; - } - } - ); - - // ===================================================================== - // GET /sapi/v1/custodian/supportedAssetList - Get Supported Assets - // ===================================================================== - server.tool( - "binance_us_cust_supported_assets", - `Get list of assets supported for custodial solution transfers and settlements. + { + rail: railSchema, + }, + async (params) => { + try { + const response = await makeSignedRequest("GET", "/sapi/v1/custodian/balance", { + rail: params.rail.toUpperCase(), + }) + + return { + content: [ + { + type: "text", + text: `Successfully retrieved custodial balance. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get custodial balance: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================================== + // GET /sapi/v1/custodian/supportedAssetList - Get Supported Assets + // ===================================================================== + server.tool( + "binance_us_cust_supported_assets", + `Get list of assets supported for custodial solution transfers and settlements. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -100,37 +107,40 @@ Each asset entry contains: - asset: Asset symbol - precision: Decimal precision - network: Supported blockchain networks`, - { - rail: railSchema - }, - async (params) => { - try { - const response = await makeSignedRequest("GET", "/sapi/v1/custodian/supportedAssetList", { - rail: params.rail.toUpperCase() - }); - - return { - content: [{ - type: "text", - text: `Successfully retrieved supported assets. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get supported assets: ${errorMessage}` }], - isError: true - }; - } - } - ); - - // ===================================================================== - // POST /sapi/v1/custodian/walletTransfer - Transfer from Exchange Wallet - // ===================================================================== - server.tool( - "binance_us_cust_wallet_transfer", - `Transfer assets from Binance.US exchange wallet to custodial sub-account. + { + rail: railSchema, + }, + async (params) => { + try { + const response = await makeSignedRequest("GET", "/sapi/v1/custodian/supportedAssetList", { + rail: params.rail.toUpperCase(), + }) + + return { + content: [ + { + type: "text", + text: `Successfully retrieved supported assets. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get supported assets: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================================== + // POST /sapi/v1/custodian/walletTransfer - Transfer from Exchange Wallet + // ===================================================================== + server.tool( + "binance_us_cust_wallet_transfer", + `Transfer assets from Binance.US exchange wallet to custodial sub-account. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -144,43 +154,49 @@ Response includes: - transferId: Unique transfer identifier - status: Transfer status (SUCCESS, PENDING, etc.) - createTime: Transfer creation timestamp`, - { - rail: railSchema, - asset: z.string().describe("Asset to transfer (e.g., BTC, ETH)"), - amount: z.number().positive().describe("Amount to transfer"), - clientOrderId: z.string().optional().describe("Your unique reference ID (auto-generated if not provided)") - }, - async (params) => { - try { - const response = await makeSignedRequest("POST", "/sapi/v1/custodian/walletTransfer", { - rail: params.rail.toUpperCase(), - asset: params.asset.toUpperCase(), - amount: params.amount, - ...(params.clientOrderId && { clientOrderId: params.clientOrderId }) - }); - - return { - content: [{ - type: "text", - text: `Wallet transfer completed. Transfer ID: ${response.transferId}, Status: ${response.status}. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to execute wallet transfer: ${errorMessage}` }], - isError: true - }; - } - } - ); - - // ===================================================================== - // POST /sapi/v1/custodian/custodianTransfer - Transfer from Custodian - // ===================================================================== - server.tool( - "binance_us_cust_transfer", - `Transfer assets from custodial partner account to Binance.US custodial sub-account. + { + rail: railSchema, + asset: z.string().describe("Asset to transfer (e.g., BTC, ETH)"), + amount: z.number().positive().describe("Amount to transfer"), + clientOrderId: z + .string() + .optional() + .describe("Your unique reference ID (auto-generated if not provided)"), + }, + async (params) => { + try { + const response = await makeSignedRequest("POST", "/sapi/v1/custodian/walletTransfer", { + rail: params.rail.toUpperCase(), + asset: params.asset.toUpperCase(), + amount: params.amount, + ...(params.clientOrderId && { clientOrderId: params.clientOrderId }), + }) + + return { + content: [ + { + type: "text", + text: `Wallet transfer completed. Transfer ID: ${response.transferId}, Status: ${response.status}. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to execute wallet transfer: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================================== + // POST /sapi/v1/custodian/custodianTransfer - Transfer from Custodian + // ===================================================================== + server.tool( + "binance_us_cust_transfer", + `Transfer assets from custodial partner account to Binance.US custodial sub-account. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -194,43 +210,51 @@ Response includes: - custodyAccountId/custodyAccountName: Custodian account details - status: Transfer status - createTime: Transfer creation timestamp`, - { - rail: railSchema, - asset: z.string().describe("Asset to transfer (e.g., BTC, ETH)"), - amount: z.number().positive().describe("Amount to transfer"), - clientOrderId: z.string().optional().describe("Your unique reference ID (auto-generated if not provided)") - }, - async (params) => { - try { - const response = await makeSignedRequest("POST", "/sapi/v1/custodian/custodianTransfer", { - rail: params.rail.toUpperCase(), - asset: params.asset.toUpperCase(), - amount: params.amount, - ...(params.clientOrderId && { clientOrderId: params.clientOrderId }) - }); - - return { - content: [{ - type: "text", - text: `Custodian transfer initiated. Transfer ID: ${response.transferId}, Status: ${response.status}. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to execute custodian transfer: ${errorMessage}` }], - isError: true - }; - } - } - ); - - // ===================================================================== - // POST /sapi/v1/custodian/undoTransfer - Undo Transfer - // ===================================================================== - server.tool( - "binance_us_cust_undo_transfer", - `Undo a previous transfer from your custodial partner. + { + rail: railSchema, + asset: z.string().describe("Asset to transfer (e.g., BTC, ETH)"), + amount: z.number().positive().describe("Amount to transfer"), + clientOrderId: z + .string() + .optional() + .describe("Your unique reference ID (auto-generated if not provided)"), + }, + async (params) => { + try { + const response = await makeSignedRequest("POST", "/sapi/v1/custodian/custodianTransfer", { + rail: params.rail.toUpperCase(), + asset: params.asset.toUpperCase(), + amount: params.amount, + ...(params.clientOrderId && { clientOrderId: params.clientOrderId }), + }) + + return { + content: [ + { + type: "text", + text: `Custodian transfer initiated. Transfer ID: ${response.transferId}, Status: ${response.status}. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to execute custodian transfer: ${errorMessage}` }, + ], + isError: true, + } + } + }, + ) + + // ===================================================================== + // POST /sapi/v1/custodian/undoTransfer - Undo Transfer + // ===================================================================== + server.tool( + "binance_us_cust_undo_transfer", + `Undo a previous transfer from your custodial partner. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -240,39 +264,42 @@ Response includes: - transferId: New transfer ID for the undo operation - asset: Asset being returned - amount: Amount being returned`, - { - rail: railSchema, - originTransferId: z.string().describe("Original transfer ID to undo") - }, - async (params) => { - try { - const response = await makeSignedRequest("POST", "/sapi/v1/custodian/undoTransfer", { - rail: params.rail.toUpperCase(), - originTransferId: params.originTransferId - }); - - return { - content: [{ - type: "text", - text: `Transfer undo completed. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to undo transfer: ${errorMessage}` }], - isError: true - }; - } - } - ); - - // ===================================================================== - // GET /sapi/v1/custodian/walletTransferHistory - Wallet Transfer History - // ===================================================================== - server.tool( - "binance_us_cust_wallet_transfer_history", - `Get history of transfers from Binance.US exchange wallet to custodial sub-account. + { + rail: railSchema, + originTransferId: z.string().describe("Original transfer ID to undo"), + }, + async (params) => { + try { + const response = await makeSignedRequest("POST", "/sapi/v1/custodian/undoTransfer", { + rail: params.rail.toUpperCase(), + originTransferId: params.originTransferId, + }) + + return { + content: [ + { + type: "text", + text: `Transfer undo completed. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to undo transfer: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================================== + // GET /sapi/v1/custodian/walletTransferHistory - Wallet Transfer History + // ===================================================================== + server.tool( + "binance_us_cust_wallet_transfer_history", + `Get history of transfers from Binance.US exchange wallet to custodial sub-account. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -282,51 +309,67 @@ Response includes: Each transfer record contains: transferId, clientOrderId, asset, amount, status, createTime, updateTime`, - { - rail: railSchema, - transferId: z.string().optional().describe("Filter by specific transfer ID"), - clientOrderId: z.string().optional().describe("Filter by client order ID"), - asset: z.string().optional().describe("Filter by asset (e.g., BTC)"), - startTime: z.number().optional().describe("Start timestamp (default: 90 days ago)"), - endTime: z.number().optional().describe("End timestamp (default: now)"), - page: z.number().int().positive().optional().default(1).describe("Page number (default: 1)"), - limit: z.number().int().min(1).max(100).optional().default(20).describe("Records per page (default: 20, max: 100)") - }, - async (params) => { - try { - const response = await makeSignedRequest("GET", "/sapi/v1/custodian/walletTransferHistory", { - rail: params.rail.toUpperCase(), - ...(params.transferId && { transferId: params.transferId }), - ...(params.clientOrderId && { clientOrderId: params.clientOrderId }), - ...(params.asset && { asset: params.asset.toUpperCase() }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.page && { page: params.page }), - ...(params.limit && { limit: params.limit }) - }); - - return { - content: [{ - type: "text", - text: `Retrieved ${response.total} wallet transfers. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get wallet transfer history: ${errorMessage}` }], - isError: true - }; - } - } - ); - - // ===================================================================== - // GET /sapi/v1/custodian/custodianTransferHistory - Custodian Transfer History - // ===================================================================== - server.tool( - "binance_us_cust_transfer_history", - `Get history of transfers from custodial partner to Binance.US custodial sub-account. + { + rail: railSchema, + transferId: z.string().optional().describe("Filter by specific transfer ID"), + clientOrderId: z.string().optional().describe("Filter by client order ID"), + asset: z.string().optional().describe("Filter by asset (e.g., BTC)"), + startTime: z.number().optional().describe("Start timestamp (default: 90 days ago)"), + endTime: z.number().optional().describe("End timestamp (default: now)"), + page: z.number().int().positive().optional().default(1).describe("Page number (default: 1)"), + limit: z + .number() + .int() + .min(1) + .max(100) + .optional() + .default(20) + .describe("Records per page (default: 20, max: 100)"), + }, + async (params) => { + try { + const response = await makeSignedRequest( + "GET", + "/sapi/v1/custodian/walletTransferHistory", + { + rail: params.rail.toUpperCase(), + ...(params.transferId && { transferId: params.transferId }), + ...(params.clientOrderId && { clientOrderId: params.clientOrderId }), + ...(params.asset && { asset: params.asset.toUpperCase() }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.page && { page: params.page }), + ...(params.limit && { limit: params.limit }), + }, + ) + + return { + content: [ + { + type: "text", + text: `Retrieved ${response.total} wallet transfers. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to get wallet transfer history: ${errorMessage}` }, + ], + isError: true, + } + } + }, + ) + + // ===================================================================== + // GET /sapi/v1/custodian/custodianTransferHistory - Custodian Transfer History + // ===================================================================== + server.tool( + "binance_us_cust_transfer_history", + `Get history of transfers from custodial partner to Binance.US custodial sub-account. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -338,90 +381,115 @@ Response includes: Each record contains: transferId, clientOrderId, asset, amount, status, expressTrade flag, createTime, updateTime`, - { - rail: railSchema, - transferId: z.string().optional().describe("Filter by specific transfer ID"), - clientOrderId: z.string().optional().describe("Filter by client order ID"), - expressTradeTransfer: z.boolean().optional().default(false).describe("Filter ExpressTrade transfers only"), - asset: z.string().optional().describe("Filter by asset (e.g., BTC)"), - startTime: z.number().optional().describe("Start timestamp (default: 90 days ago)"), - endTime: z.number().optional().describe("End timestamp (default: now)"), - page: z.number().int().positive().optional().default(1).describe("Page number (default: 1)"), - limit: z.number().int().min(1).max(100).optional().default(20).describe("Records per page (default: 20, max: 100)") - }, - async (params) => { - try { - const response = await makeSignedRequest("GET", "/sapi/v1/custodian/custodianTransferHistory", { - rail: params.rail.toUpperCase(), - ...(params.transferId && { transferId: params.transferId }), - ...(params.clientOrderId && { clientOrderId: params.clientOrderId }), - ...(params.expressTradeTransfer !== undefined && { expressTradeTransfer: params.expressTradeTransfer }), - ...(params.asset && { asset: params.asset.toUpperCase() }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.page && { page: params.page }), - ...(params.limit && { limit: params.limit }) - }); - - return { - content: [{ - type: "text", - text: `Retrieved ${response.total} custodian transfers. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get custodian transfer history: ${errorMessage}` }], - isError: true - }; - } - } - ); - - // ===================================================================== - // GET /sapi/v1/custodian/availableBalance - Get Available Balance - // ===================================================================== - server.tool( - "binance_us_cust_available_balance", - `Get available balance in the custodial sub-account for trading. + { + rail: railSchema, + transferId: z.string().optional().describe("Filter by specific transfer ID"), + clientOrderId: z.string().optional().describe("Filter by client order ID"), + expressTradeTransfer: z + .boolean() + .optional() + .default(false) + .describe("Filter ExpressTrade transfers only"), + asset: z.string().optional().describe("Filter by asset (e.g., BTC)"), + startTime: z.number().optional().describe("Start timestamp (default: 90 days ago)"), + endTime: z.number().optional().describe("End timestamp (default: now)"), + page: z.number().int().positive().optional().default(1).describe("Page number (default: 1)"), + limit: z + .number() + .int() + .min(1) + .max(100) + .optional() + .default(20) + .describe("Records per page (default: 20, max: 100)"), + }, + async (params) => { + try { + const response = await makeSignedRequest( + "GET", + "/sapi/v1/custodian/custodianTransferHistory", + { + rail: params.rail.toUpperCase(), + ...(params.transferId && { transferId: params.transferId }), + ...(params.clientOrderId && { clientOrderId: params.clientOrderId }), + ...(params.expressTradeTransfer !== undefined && { + expressTradeTransfer: params.expressTradeTransfer, + }), + ...(params.asset && { asset: params.asset.toUpperCase() }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.page && { page: params.page }), + ...(params.limit && { limit: params.limit }), + }, + ) + + return { + content: [ + { + type: "text", + text: `Retrieved ${response.total} custodian transfers. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to get custodian transfer history: ${errorMessage}` }, + ], + isError: true, + } + } + }, + ) + + // ===================================================================== + // GET /sapi/v1/custodian/availableBalance - Get Available Balance + // ===================================================================== + server.tool( + "binance_us_cust_available_balance", + `Get available balance in the custodial sub-account for trading. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY Returns the balance available for placing new orders.`, - { - rail: railSchema, - asset: z.string().optional().describe("Filter by specific asset") - }, - async (params) => { - try { - const response = await makeSignedRequest("GET", "/sapi/v1/custodian/availableBalance", { - rail: params.rail.toUpperCase(), - ...(params.asset && { asset: params.asset.toUpperCase() }) - }); - - return { - content: [{ - type: "text", - text: `Successfully retrieved available balance. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get available balance: ${errorMessage}` }], - isError: true - }; - } - } - ); - - // ===================================================================== - // POST /sapi/v1/custodian/order - Place Custodial Order - // ===================================================================== - server.tool( - "binance_us_cust_new_order", - `Place a new trade order through the custodial solution. + { + rail: railSchema, + asset: z.string().optional().describe("Filter by specific asset"), + }, + async (params) => { + try { + const response = await makeSignedRequest("GET", "/sapi/v1/custodian/availableBalance", { + rail: params.rail.toUpperCase(), + ...(params.asset && { asset: params.asset.toUpperCase() }), + }) + + return { + content: [ + { + type: "text", + text: `Successfully retrieved available balance. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get available balance: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================================== + // POST /sapi/v1/custodian/order - Place Custodial Order + // ===================================================================== + server.tool( + "binance_us_cust_new_order", + `Place a new trade order through the custodial solution. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -440,59 +508,74 @@ the full amount will be automatically transferred from the custodial partner. Response includes: symbol, orderId, status, type, side, price, quantity, executedQty, and expressTradeFlag`, - { - rail: railSchema, - symbol: z.string().describe("Trading pair (e.g., BTCUSD, ETHUSD)"), - side: orderSideEnum.describe("Order side: BUY or SELL"), - type: orderTypeEnum.describe("Order type"), - timeInForce: timeInForceEnum.optional().describe("GTC (Good Til Canceled), IOC (Immediate or Cancel), FOK (Fill or Kill)"), - quantity: z.number().positive().optional().describe("Order quantity in base asset"), - quoteOrderQty: z.number().positive().optional().describe("Order quantity in quote asset (MARKET orders only)"), - price: z.number().positive().optional().describe("Order price (required for LIMIT orders)"), - stopPrice: z.number().positive().optional().describe("Stop/trigger price for stop orders"), - icebergQty: z.number().positive().optional().describe("Iceberg order quantity"), - asset: z.string().optional().describe("Asset for ExpressTrade (the asset being sold)"), - allowExpressTrade: z.boolean().optional().default(false).describe("Enable ExpressTrade for auto-funding") - }, - async (params) => { - try { - const response = await makeSignedRequest("POST", "/sapi/v1/custodian/order", { - rail: params.rail.toUpperCase(), - symbol: params.symbol.toUpperCase(), - side: params.side, - type: params.type, - ...(params.timeInForce && { timeInForce: params.timeInForce }), - ...(params.quantity && { quantity: params.quantity }), - ...(params.quoteOrderQty && { quoteOrderQty: params.quoteOrderQty }), - ...(params.price && { price: params.price }), - ...(params.stopPrice && { stopPrice: params.stopPrice }), - ...(params.icebergQty && { icebergQty: params.icebergQty }), - ...(params.asset && { asset: params.asset.toUpperCase() }), - ...(params.allowExpressTrade !== undefined && { allowExpressTrade: params.allowExpressTrade }) - }); - - return { - content: [{ - type: "text", - text: `Custodial order placed. Order ID: ${response.orderId}, Status: ${response.status}. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to place custodial order: ${errorMessage}` }], - isError: true - }; - } - } - ); - - // ===================================================================== - // POST /sapi/v1/custodian/ocoOrder - Place Custodial OCO Order - // ===================================================================== - server.tool( - "binance_us_cust_oco_order", - `Place a new OCO (One-Cancels-the-Other) order through the custodial solution. + { + rail: railSchema, + symbol: z.string().describe("Trading pair (e.g., BTCUSD, ETHUSD)"), + side: orderSideEnum.describe("Order side: BUY or SELL"), + type: orderTypeEnum.describe("Order type"), + timeInForce: timeInForceEnum + .optional() + .describe("GTC (Good Til Canceled), IOC (Immediate or Cancel), FOK (Fill or Kill)"), + quantity: z.number().positive().optional().describe("Order quantity in base asset"), + quoteOrderQty: z + .number() + .positive() + .optional() + .describe("Order quantity in quote asset (MARKET orders only)"), + price: z.number().positive().optional().describe("Order price (required for LIMIT orders)"), + stopPrice: z.number().positive().optional().describe("Stop/trigger price for stop orders"), + icebergQty: z.number().positive().optional().describe("Iceberg order quantity"), + asset: z.string().optional().describe("Asset for ExpressTrade (the asset being sold)"), + allowExpressTrade: z + .boolean() + .optional() + .default(false) + .describe("Enable ExpressTrade for auto-funding"), + }, + async (params) => { + try { + const response = await makeSignedRequest("POST", "/sapi/v1/custodian/order", { + rail: params.rail.toUpperCase(), + symbol: params.symbol.toUpperCase(), + side: params.side, + type: params.type, + ...(params.timeInForce && { timeInForce: params.timeInForce }), + ...(params.quantity && { quantity: params.quantity }), + ...(params.quoteOrderQty && { quoteOrderQty: params.quoteOrderQty }), + ...(params.price && { price: params.price }), + ...(params.stopPrice && { stopPrice: params.stopPrice }), + ...(params.icebergQty && { icebergQty: params.icebergQty }), + ...(params.asset && { asset: params.asset.toUpperCase() }), + ...(params.allowExpressTrade !== undefined && { + allowExpressTrade: params.allowExpressTrade, + }), + }) + + return { + content: [ + { + type: "text", + text: `Custodial order placed. Order ID: ${response.orderId}, Status: ${response.status}. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to place custodial order: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================================== + // POST /sapi/v1/custodian/ocoOrder - Place Custodial OCO Order + // ===================================================================== + server.tool( + "binance_us_cust_oco_order", + `Place a new OCO (One-Cancels-the-Other) order through the custodial solution. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -508,63 +591,68 @@ Quantity: Both legs must have the same quantity (iceberg qty can differ). Note: OCO counts as 2 orders against rate limits. Response includes orderListId, orders array, and orderReports with details.`, - { - rail: railSchema, - symbol: z.string().describe("Trading pair (e.g., BTCUSD, ETHUSD)"), - side: orderSideEnum.describe("Order side: BUY or SELL"), - quantity: z.number().positive().describe("Order quantity (same for both legs)"), - price: z.number().positive().describe("Limit order price"), - stopPrice: z.number().positive().describe("Stop trigger price"), - limitClientOrderId: z.string().optional().describe("Unique ID for the limit order"), - limitIcebergQty: z.number().positive().optional().describe("Iceberg qty for limit leg"), - stopClientOrderId: z.string().optional().describe("Unique ID for the stop leg"), - stopLimitPrice: z.number().positive().optional().describe("Limit price for stop-limit leg"), - stopIcebergQty: z.number().positive().optional().describe("Iceberg qty for stop leg"), - stopLimitTimeInForce: timeInForceEnum.optional().describe("Time in force for stop-limit leg"), - asset: z.string().optional().describe("Asset for ExpressTrade"), - allowExpressTrade: z.boolean().optional().default(false).describe("Enable ExpressTrade") - }, - async (params) => { - try { - const response = await makeSignedRequest("POST", "/sapi/v1/custodian/ocoOrder", { - rail: params.rail.toUpperCase(), - symbol: params.symbol.toUpperCase(), - side: params.side, - quantity: params.quantity, - price: params.price, - stopPrice: params.stopPrice, - ...(params.limitClientOrderId && { limitClientOrderId: params.limitClientOrderId }), - ...(params.limitIcebergQty && { limitIcebergQty: params.limitIcebergQty }), - ...(params.stopClientOrderId && { stopClientOrderId: params.stopClientOrderId }), - ...(params.stopLimitPrice && { stopLimitPrice: params.stopLimitPrice }), - ...(params.stopIcebergQty && { stopIcebergQty: params.stopIcebergQty }), - ...(params.stopLimitTimeInForce && { stopLimitTimeInForce: params.stopLimitTimeInForce }), - ...(params.asset && { asset: params.asset.toUpperCase() }), - ...(params.allowExpressTrade !== undefined && { allowExpressTrade: params.allowExpressTrade }) - }); - - return { - content: [{ - type: "text", - text: `Custodial OCO order placed. Order List ID: ${response.orderListId}, Status: ${response.listOrderStatus}. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to place custodial OCO order: ${errorMessage}` }], - isError: true - }; - } - } - ); - - // ===================================================================== - // GET /sapi/v1/custodian/openOrders - Get Open Orders - // ===================================================================== - server.tool( - "binance_us_cust_open_orders", - `Get all open custodial trade orders. + { + rail: railSchema, + symbol: z.string().describe("Trading pair (e.g., BTCUSD, ETHUSD)"), + side: orderSideEnum.describe("Order side: BUY or SELL"), + quantity: z.number().positive().describe("Order quantity (same for both legs)"), + price: z.number().positive().describe("Limit order price"), + stopPrice: z.number().positive().describe("Stop trigger price"), + limitClientOrderId: z.string().optional().describe("Unique ID for the limit order"), + limitIcebergQty: z.number().positive().optional().describe("Iceberg qty for limit leg"), + stopClientOrderId: z.string().optional().describe("Unique ID for the stop leg"), + stopLimitPrice: z.number().positive().optional().describe("Limit price for stop-limit leg"), + stopIcebergQty: z.number().positive().optional().describe("Iceberg qty for stop leg"), + stopLimitTimeInForce: timeInForceEnum.optional().describe("Time in force for stop-limit leg"), + asset: z.string().optional().describe("Asset for ExpressTrade"), + allowExpressTrade: z.boolean().optional().default(false).describe("Enable ExpressTrade"), + }, + async (params) => { + try { + const response = await makeSignedRequest("POST", "/sapi/v1/custodian/ocoOrder", { + rail: params.rail.toUpperCase(), + symbol: params.symbol.toUpperCase(), + side: params.side, + quantity: params.quantity, + price: params.price, + stopPrice: params.stopPrice, + ...(params.limitClientOrderId && { limitClientOrderId: params.limitClientOrderId }), + ...(params.limitIcebergQty && { limitIcebergQty: params.limitIcebergQty }), + ...(params.stopClientOrderId && { stopClientOrderId: params.stopClientOrderId }), + ...(params.stopLimitPrice && { stopLimitPrice: params.stopLimitPrice }), + ...(params.stopIcebergQty && { stopIcebergQty: params.stopIcebergQty }), + ...(params.stopLimitTimeInForce && { stopLimitTimeInForce: params.stopLimitTimeInForce }), + ...(params.asset && { asset: params.asset.toUpperCase() }), + ...(params.allowExpressTrade !== undefined && { + allowExpressTrade: params.allowExpressTrade, + }), + }) + + return { + content: [ + { + type: "text", + text: `Custodial OCO order placed. Order List ID: ${response.orderListId}, Status: ${response.listOrderStatus}. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to place custodial OCO order: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================================== + // GET /sapi/v1/custodian/openOrders - Get Open Orders + // ===================================================================== + server.tool( + "binance_us_cust_open_orders", + `Get all open custodial trade orders. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -573,80 +661,89 @@ Response includes orderListId, orders array, and orderReports with details.`, Response is an array of open orders with: symbol, orderId, price, origQty, executedQty, status, type, side, stopPrice, time, updateTime, isWorking, expressTradeFlag`, - { - rail: railSchema, - symbol: z.string().optional().describe("Trading pair (e.g., BTCUSD). Recommended to always specify.") - }, - async (params) => { - try { - const response = await makeSignedRequest("GET", "/sapi/v1/custodian/openOrders", { - rail: params.rail.toUpperCase(), - ...(params.symbol && { symbol: params.symbol.toUpperCase() }) - }); - - return { - content: [{ - type: "text", - text: `Retrieved ${Array.isArray(response) ? response.length : 0} open orders. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get open orders: ${errorMessage}` }], - isError: true - }; - } - } - ); - - // ===================================================================== - // GET /sapi/v1/custodian/order - Get Order - // ===================================================================== - server.tool( - "binance_us_cust_get_order", - `Get details of a specific custodial trade order. + { + rail: railSchema, + symbol: z + .string() + .optional() + .describe("Trading pair (e.g., BTCUSD). Recommended to always specify."), + }, + async (params) => { + try { + const response = await makeSignedRequest("GET", "/sapi/v1/custodian/openOrders", { + rail: params.rail.toUpperCase(), + ...(params.symbol && { symbol: params.symbol.toUpperCase() }), + }) + + return { + content: [ + { + type: "text", + text: `Retrieved ${Array.isArray(response) ? response.length : 0} open orders. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get open orders: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================================== + // GET /sapi/v1/custodian/order - Get Order + // ===================================================================== + server.tool( + "binance_us_cust_get_order", + `Get details of a specific custodial trade order. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY Response includes: symbol, orderId, price, origQty, executedQty, cummulativeQuoteQty, status, timeInForce, type, side, stopPrice, icebergQty, time, updateTime, isWorking, expressTradeFlag`, - { - rail: railSchema, - symbol: z.string().describe("Trading pair (e.g., BTCUSD)"), - orderId: z.number().int().describe("Order ID to query") - }, - async (params) => { - try { - const response = await makeSignedRequest("GET", "/sapi/v1/custodian/order", { - rail: params.rail.toUpperCase(), - symbol: params.symbol.toUpperCase(), - orderId: params.orderId - }); - - return { - content: [{ - type: "text", - text: `Order retrieved. Status: ${response.status}. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get order: ${errorMessage}` }], - isError: true - }; - } - } - ); - - // ===================================================================== - // GET /sapi/v1/custodian/orderHistory - Get Order History - // ===================================================================== - server.tool( - "binance_us_cust_order_history", - `Get historical custodial trade orders. + { + rail: railSchema, + symbol: z.string().describe("Trading pair (e.g., BTCUSD)"), + orderId: z.number().int().describe("Order ID to query"), + }, + async (params) => { + try { + const response = await makeSignedRequest("GET", "/sapi/v1/custodian/order", { + rail: params.rail.toUpperCase(), + symbol: params.symbol.toUpperCase(), + orderId: params.orderId, + }) + + return { + content: [ + { + type: "text", + text: `Order retrieved. Status: ${response.status}. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get order: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================================== + // GET /sapi/v1/custodian/orderHistory - Get Order History + // ===================================================================== + server.tool( + "binance_us_cust_order_history", + `Get historical custodial trade orders. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -654,47 +751,60 @@ If symbol is not sent, orders for all symbols will be returned. Response is an array of orders with full details including status, executedQty, and expressTradeFlag.`, - { - rail: railSchema, - symbol: z.string().optional().describe("Trading pair (e.g., BTCUSD). If omitted, returns all symbols."), - startTime: z.number().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().optional().describe("End timestamp in milliseconds"), - fromId: z.number().int().optional().describe("Start from this order ID"), - limit: z.number().int().min(1).max(1000).optional().default(200).describe("Max records (default: 200)") - }, - async (params) => { - try { - const response = await makeSignedRequest("GET", "/sapi/v1/custodian/orderHistory", { - rail: params.rail.toUpperCase(), - ...(params.symbol && { symbol: params.symbol.toUpperCase() }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.fromId && { fromId: params.fromId }), - ...(params.limit && { limit: params.limit }) - }); - - return { - content: [{ - type: "text", - text: `Retrieved ${Array.isArray(response) ? response.length : 0} historical orders. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get order history: ${errorMessage}` }], - isError: true - }; - } - } - ); - - // ===================================================================== - // GET /sapi/v1/custodian/tradeHistory - Get Trade History - // ===================================================================== - server.tool( - "binance_us_cust_trade_history", - `Get historical custodial trades (filled orders). + { + rail: railSchema, + symbol: z + .string() + .optional() + .describe("Trading pair (e.g., BTCUSD). If omitted, returns all symbols."), + startTime: z.number().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().optional().describe("End timestamp in milliseconds"), + fromId: z.number().int().optional().describe("Start from this order ID"), + limit: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .default(200) + .describe("Max records (default: 200)"), + }, + async (params) => { + try { + const response = await makeSignedRequest("GET", "/sapi/v1/custodian/orderHistory", { + rail: params.rail.toUpperCase(), + ...(params.symbol && { symbol: params.symbol.toUpperCase() }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.fromId && { fromId: params.fromId }), + ...(params.limit && { limit: params.limit }), + }) + + return { + content: [ + { + type: "text", + text: `Retrieved ${Array.isArray(response) ? response.length : 0} historical orders. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get order history: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================================== + // GET /sapi/v1/custodian/tradeHistory - Get Trade History + // ===================================================================== + server.tool( + "binance_us_cust_trade_history", + `Get historical custodial trades (filled orders). ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -702,137 +812,160 @@ Returns actual executed trades with price, quantity, and commission details. Response includes for each trade: symbol, price, qty, quoteQty, time, isBuyer, isMaker, isBestMatch, orderId, commission, commissionAsset`, - { - rail: railSchema, - symbol: z.string().optional().describe("Trading pair (e.g., BTCUSD)"), - orderId: z.number().int().optional().describe("Filter by order ID"), - startTime: z.number().optional().describe("Start timestamp"), - endTime: z.number().optional().describe("End timestamp"), - fromId: z.number().int().optional().describe("Start from this trade ID"), - limit: z.number().int().min(1).max(1000).optional().default(200).describe("Max records (default: 200)") - }, - async (params) => { - try { - const response = await makeSignedRequest("GET", "/sapi/v1/custodian/tradeHistory", { - rail: params.rail.toUpperCase(), - ...(params.symbol && { symbol: params.symbol.toUpperCase() }), - ...(params.orderId && { orderId: params.orderId }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.fromId && { fromId: params.fromId }), - ...(params.limit && { limit: params.limit }) - }); - - return { - content: [{ - type: "text", - text: `Retrieved ${Array.isArray(response) ? response.length : 0} trades. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get trade history: ${errorMessage}` }], - isError: true - }; - } - } - ); - - // ===================================================================== - // DELETE /sapi/v1/custodian/cancelOrder - Cancel Order - // ===================================================================== - server.tool( - "binance_us_cust_cancel_order", - `Cancel an active custodial trade order. + { + rail: railSchema, + symbol: z.string().optional().describe("Trading pair (e.g., BTCUSD)"), + orderId: z.number().int().optional().describe("Filter by order ID"), + startTime: z.number().optional().describe("Start timestamp"), + endTime: z.number().optional().describe("End timestamp"), + fromId: z.number().int().optional().describe("Start from this trade ID"), + limit: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .default(200) + .describe("Max records (default: 200)"), + }, + async (params) => { + try { + const response = await makeSignedRequest("GET", "/sapi/v1/custodian/tradeHistory", { + rail: params.rail.toUpperCase(), + ...(params.symbol && { symbol: params.symbol.toUpperCase() }), + ...(params.orderId && { orderId: params.orderId }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.fromId && { fromId: params.fromId }), + ...(params.limit && { limit: params.limit }), + }) + + return { + content: [ + { + type: "text", + text: `Retrieved ${Array.isArray(response) ? response.length : 0} trades. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get trade history: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================================== + // DELETE /sapi/v1/custodian/cancelOrder - Cancel Order + // ===================================================================== + server.tool( + "binance_us_cust_cancel_order", + `Cancel an active custodial trade order. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY Either orderId or origClientOrderId must be provided. Response includes the canceled order details with status: CANCELED`, - { - rail: railSchema, - symbol: z.string().describe("Trading pair (e.g., BTCUSD)"), - orderId: z.number().int().optional().describe("Order ID to cancel"), - origClientOrderId: z.string().optional().describe("Original client order ID to cancel"), - newClientOrderId: z.string().optional().describe("New client order ID for this cancel operation") - }, - async (params) => { - try { - if (!params.orderId && !params.origClientOrderId) { - throw new Error("Either orderId or origClientOrderId must be provided"); - } - - const response = await makeSignedRequest("DELETE", "/sapi/v1/custodian/cancelOrder", { - rail: params.rail.toUpperCase(), - symbol: params.symbol.toUpperCase(), - ...(params.orderId && { orderId: params.orderId }), - ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), - ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }) - }); - - return { - content: [{ - type: "text", - text: `Order canceled. Order ID: ${response.orderId}, Status: ${response.status}. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to cancel order: ${errorMessage}` }], - isError: true - }; - } - } - ); - - // ===================================================================== - // DELETE /sapi/v1/custodian/cancelOrdersBySymbol - Cancel All Orders for Symbol - // ===================================================================== - server.tool( - "binance_us_cust_cancel_orders_symbol", - `Cancel all active custodial orders for a specific trading pair. + { + rail: railSchema, + symbol: z.string().describe("Trading pair (e.g., BTCUSD)"), + orderId: z.number().int().optional().describe("Order ID to cancel"), + origClientOrderId: z.string().optional().describe("Original client order ID to cancel"), + newClientOrderId: z + .string() + .optional() + .describe("New client order ID for this cancel operation"), + }, + async (params) => { + try { + if (!params.orderId && !params.origClientOrderId) { + throw new Error("Either orderId or origClientOrderId must be provided") + } + + const response = await makeSignedRequest("DELETE", "/sapi/v1/custodian/cancelOrder", { + rail: params.rail.toUpperCase(), + symbol: params.symbol.toUpperCase(), + ...(params.orderId && { orderId: params.orderId }), + ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), + ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), + }) + + return { + content: [ + { + type: "text", + text: `Order canceled. Order ID: ${response.orderId}, Status: ${response.status}. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to cancel order: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================================== + // DELETE /sapi/v1/custodian/cancelOrdersBySymbol - Cancel All Orders for Symbol + // ===================================================================== + server.tool( + "binance_us_cust_cancel_orders_symbol", + `Cancel all active custodial orders for a specific trading pair. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY This includes OCO orders. Use with caution. Response is an array of all canceled orders.`, - { - rail: railSchema, - symbol: z.string().describe("Trading pair to cancel all orders for (e.g., BTCUSD)") - }, - async (params) => { - try { - const response = await makeSignedRequest("DELETE", "/sapi/v1/custodian/cancelOrdersBySymbol", { - rail: params.rail.toUpperCase(), - symbol: params.symbol.toUpperCase() - }); - - return { - content: [{ - type: "text", - text: `All orders canceled for ${params.symbol}. Canceled ${Array.isArray(response) ? response.length : 0} orders. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to cancel orders: ${errorMessage}` }], - isError: true - }; - } - } - ); - - // ===================================================================== - // DELETE /sapi/v1/custodian/cancelOcoOrder - Cancel OCO Order - // ===================================================================== - server.tool( - "binance_us_cust_cancel_oco", - `Cancel an entire OCO (One-Cancels-the-Other) order list. + { + rail: railSchema, + symbol: z.string().describe("Trading pair to cancel all orders for (e.g., BTCUSD)"), + }, + async (params) => { + try { + const response = await makeSignedRequest( + "DELETE", + "/sapi/v1/custodian/cancelOrdersBySymbol", + { + rail: params.rail.toUpperCase(), + symbol: params.symbol.toUpperCase(), + }, + ) + + return { + content: [ + { + type: "text", + text: `All orders canceled for ${params.symbol}. Canceled ${Array.isArray(response) ? response.length : 0} orders. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to cancel orders: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================================== + // DELETE /sapi/v1/custodian/cancelOcoOrder - Cancel OCO Order + // ===================================================================== + server.tool( + "binance_us_cust_cancel_oco", + `Cancel an entire OCO (One-Cancels-the-Other) order list. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -840,45 +973,48 @@ This cancels both legs of the OCO order. Response includes orderListId, orders array, and orderReports with canceled order details.`, - { - rail: railSchema, - symbol: z.string().describe("Trading pair (e.g., BTCUSD)"), - orderListId: z.number().int().describe("OCO order list ID to cancel"), - listClientOrderId: z.string().optional().describe("List client order ID"), - newClientOrderId: z.string().optional().describe("New client order ID for cancel operation") - }, - async (params) => { - try { - const response = await makeSignedRequest("DELETE", "/sapi/v1/custodian/cancelOcoOrder", { - rail: params.rail.toUpperCase(), - symbol: params.symbol.toUpperCase(), - orderListId: params.orderListId, - ...(params.listClientOrderId && { listClientOrderId: params.listClientOrderId }), - ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }) - }); - - return { - content: [{ - type: "text", - text: `OCO order canceled. List ID: ${response.orderListId}, Status: ${response.listOrderStatus}. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to cancel OCO order: ${errorMessage}` }], - isError: true - }; - } - } - ); - - // ===================================================================== - // GET /sapi/v1/custodian/settlementSetting - Get Settlement Settings - // ===================================================================== - server.tool( - "binance_us_cust_settlement_settings", - `Get current settlement settings for custodial solution. + { + rail: railSchema, + symbol: z.string().describe("Trading pair (e.g., BTCUSD)"), + orderListId: z.number().int().describe("OCO order list ID to cancel"), + listClientOrderId: z.string().optional().describe("List client order ID"), + newClientOrderId: z.string().optional().describe("New client order ID for cancel operation"), + }, + async (params) => { + try { + const response = await makeSignedRequest("DELETE", "/sapi/v1/custodian/cancelOcoOrder", { + rail: params.rail.toUpperCase(), + symbol: params.symbol.toUpperCase(), + orderListId: params.orderListId, + ...(params.listClientOrderId && { listClientOrderId: params.listClientOrderId }), + ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), + }) + + return { + content: [ + { + type: "text", + text: `OCO order canceled. List ID: ${response.orderListId}, Status: ${response.listOrderStatus}. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to cancel OCO order: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================================== + // GET /sapi/v1/custodian/settlementSetting - Get Settlement Settings + // ===================================================================== + server.tool( + "binance_us_cust_settlement_settings", + `Get current settlement settings for custodial solution. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -888,37 +1024,40 @@ Response includes: - settlementActive: Whether auto-settlement is enabled - frequencyInHours: Settlement frequency (e.g., 24 hours) - nextTriggerTime: Timestamp of next scheduled settlement`, - { - rail: railSchema - }, - async (params) => { - try { - const response = await makeSignedRequest("GET", "/sapi/v1/custodian/settlementSetting", { - rail: params.rail.toUpperCase() - }); - - return { - content: [{ - type: "text", - text: `Settlement settings retrieved. Active: ${response.settlementActive}, Next: ${new Date(response.nextTriggerTime).toISOString()}. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get settlement settings: ${errorMessage}` }], - isError: true - }; - } - } - ); - - // ===================================================================== - // GET /sapi/v1/custodian/settlementHistory - Get Settlement History - // ===================================================================== - server.tool( - "binance_us_cust_settlement_history", - `Get historical settlement records for custodial solution. + { + rail: railSchema, + }, + async (params) => { + try { + const response = await makeSignedRequest("GET", "/sapi/v1/custodian/settlementSetting", { + rail: params.rail.toUpperCase(), + }) + + return { + content: [ + { + type: "text", + text: `Settlement settings retrieved. Active: ${response.settlementActive}, Next: ${new Date(response.nextTriggerTime).toISOString()}. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get settlement settings: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================================== + // GET /sapi/v1/custodian/settlementHistory - Get Settlement History + // ===================================================================== + server.tool( + "binance_us_cust_settlement_history", + `Get historical settlement records for custodial solution. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -933,36 +1072,46 @@ Each record contains: - triggerTime: When settlement was triggered - settlementId: Unique settlement identifier - settlementAssets: Array of assets settled with amounts and addresses`, - { - rail: railSchema, - startTime: z.number().optional().describe("Start timestamp"), - endTime: z.number().optional().describe("End timestamp"), - limit: z.number().int().min(1).max(100).optional().default(5).describe("Max records (default: 5, max: 100)"), - page: z.number().int().positive().optional().default(1).describe("Page number (default: 1)") - }, - async (params) => { - try { - const response = await makeSignedRequest("GET", "/sapi/v1/custodian/settlementHistory", { - rail: params.rail.toUpperCase(), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.limit && { limit: params.limit }), - ...(params.page && { page: params.page }) - }); - - return { - content: [{ - type: "text", - text: `Retrieved ${response.total} settlement records. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get settlement history: ${errorMessage}` }], - isError: true - }; - } - } - ); + { + rail: railSchema, + startTime: z.number().optional().describe("Start timestamp"), + endTime: z.number().optional().describe("End timestamp"), + limit: z + .number() + .int() + .min(1) + .max(100) + .optional() + .default(5) + .describe("Max records (default: 5, max: 100)"), + page: z.number().int().positive().optional().default(1).describe("Page number (default: 1)"), + }, + async (params) => { + try { + const response = await makeSignedRequest("GET", "/sapi/v1/custodian/settlementHistory", { + rail: params.rail.toUpperCase(), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.limit && { limit: params.limit }), + ...(params.page && { page: params.page }), + }) + + return { + content: [ + { + type: "text", + text: `Retrieved ${response.total} settlement records. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get settlement history: ${errorMessage}` }], + isError: true, + } + } + }, + ) } diff --git a/src/tools/general/index.ts b/src/tools/general/index.ts index 36fa8575..2d8178b3 100644 --- a/src/tools/general/index.ts +++ b/src/tools/general/index.ts @@ -1,148 +1,166 @@ // src/tools/general/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { binanceUsRequest } from "../../config/binanceUsClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { binanceUsRequest } from "../../config/binanceUsClient.js" export function registerGeneralTools(server: McpServer) { - // binance_us_ping - Test connectivity to Binance.US - server.tool( - "binance_us_ping", - "Test connectivity to the Binance.US API. Returns empty object if successful.", - {}, - async () => { - try { - const result = await binanceUsRequest("GET", "/api/v3/ping", {}, false); - return { - content: [ - { - type: "text", - text: `Binance.US API connection successful. Response: ${JSON.stringify(result)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to ping Binance.US API: ${errorMessage}` } - ], - isError: true - }; - } + // binance_us_ping - Test connectivity to Binance.US + server.tool( + "binance_us_ping", + "Test connectivity to the Binance.US API. Returns empty object if successful.", + {}, + async () => { + try { + const result = await binanceUsRequest("GET", "/api/v3/ping", {}, false) + + return { + content: [ + { + type: "text", + text: `Binance.US API connection successful. Response: ${JSON.stringify(result)}`, + }, + ], } - ); - - // binance_us_server_time - Get server time - server.tool( - "binance_us_server_time", - "Get the current server time from Binance.US exchange.", - {}, - async () => { - try { - const result = await binanceUsRequest("GET", "/api/v3/time", {}, false); - const serverTime = new Date(result.serverTime).toISOString(); - return { - content: [ - { - type: "text", - text: `Binance.US server time: ${serverTime} (${result.serverTime}). Response: ${JSON.stringify(result)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get server time: ${errorMessage}` } - ], - isError: true - }; - } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to ping Binance.US API: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // binance_us_server_time - Get server time + server.tool( + "binance_us_server_time", + "Get the current server time from Binance.US exchange.", + {}, + async () => { + try { + const result = await binanceUsRequest("GET", "/api/v3/time", {}, false) + const serverTime = new Date(result.serverTime).toISOString() + + return { + content: [ + { + type: "text", + text: `Binance.US server time: ${serverTime} (${result.serverTime}). Response: ${JSON.stringify(result)}`, + }, + ], } - ); - - // binance_us_system_status - Get system maintenance status (SIGNED) - server.tool( - "binance_us_system_status", - "Check if Binance.US system is under maintenance. Status 0 = normal, 1 = system maintenance. Requires API key authentication.", - {}, - async () => { - try { - const result = await binanceUsRequest("GET", "/sapi/v1/system/status", {}, true); - const statusText = result.status === 0 ? "Normal" : "System Maintenance"; - return { - content: [ - { - type: "text", - text: `Binance.US system status: ${statusText} (${result.status}). Response: ${JSON.stringify(result)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get system status: ${errorMessage}` } - ], - isError: true - }; - } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get server time: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // binance_us_system_status - Get system maintenance status (SIGNED) + server.tool( + "binance_us_system_status", + "Check if Binance.US system is under maintenance. Status 0 = normal, 1 = system maintenance. Requires API key authentication.", + {}, + async () => { + try { + const result = await binanceUsRequest("GET", "/sapi/v1/system/status", {}, true) + const statusText = result.status === 0 ? "Normal" : "System Maintenance" + + return { + content: [ + { + type: "text", + text: `Binance.US system status: ${statusText} (${result.status}). Response: ${JSON.stringify(result)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get system status: ${errorMessage}` }], + isError: true, } - ); - - // binance_us_exchange_info - Get exchange information - server.tool( - "binance_us_exchange_info", - "Get current exchange trading rules and trading pair information from Binance.US. Can filter by specific symbol(s) or permissions.", - { - symbol: z.string().optional().describe("Single trading pair symbol to filter (e.g., BTCUSD). Cannot be used with 'symbols' parameter."), - symbols: z.array(z.string()).optional().describe("Array of trading pair symbols to filter (e.g., ['BTCUSD', 'ETHUSD']). Cannot be used with 'symbol' parameter."), - permissions: z.array(z.string()).optional().describe("Filter by trading permissions. Default is ['SPOT'].") - }, - async ({ symbol, symbols, permissions }) => { - try { - const params: Record = {}; - - // symbol and symbols are mutually exclusive - if (symbol && symbols) { - return { - content: [ - { type: "text", text: "Error: Cannot specify both 'symbol' and 'symbols' parameters. Use one or the other." } - ], - isError: true - }; - } - - if (symbol) { - params.symbol = symbol; - } else if (symbols && symbols.length > 0) { - params.symbols = JSON.stringify(symbols); - } - - if (permissions && permissions.length > 0) { - params.permissions = permissions.join(","); - } - - const result = await binanceUsRequest("GET", "/api/v3/exchangeInfo", params, false); - - const symbolCount = result.symbols?.length || 0; - return { - content: [ - { - type: "text", - text: `Retrieved exchange info. Total symbols: ${symbolCount}. Server time: ${result.serverTime}. Timezone: ${result.timezone}. Response: ${JSON.stringify(result, null, 2)}` - } - ] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [ - { type: "text", text: `Failed to get exchange info: ${errorMessage}` } - ], - isError: true - }; - } + } + }, + ) + + // binance_us_exchange_info - Get exchange information + server.tool( + "binance_us_exchange_info", + "Get current exchange trading rules and trading pair information from Binance.US. Can filter by specific symbol(s) or permissions.", + { + symbol: z + .string() + .optional() + .describe( + "Single trading pair symbol to filter (e.g., BTCUSD). Cannot be used with 'symbols' parameter.", + ), + symbols: z + .array(z.string()) + .optional() + .describe( + "Array of trading pair symbols to filter (e.g., ['BTCUSD', 'ETHUSD']). Cannot be used with 'symbol' parameter.", + ), + permissions: z + .array(z.string()) + .optional() + .describe("Filter by trading permissions. Default is ['SPOT']."), + }, + async ({ symbol, symbols, permissions }) => { + try { + const params: Record = {} + + // symbol and symbols are mutually exclusive + if (symbol && symbols) { + return { + content: [ + { + type: "text", + text: "Error: Cannot specify both 'symbol' and 'symbols' parameters. Use one or the other.", + }, + ], + isError: true, + } + } + + if (symbol) { + params.symbol = symbol + } else if (symbols && symbols.length > 0) { + params.symbols = JSON.stringify(symbols) + } + + if (permissions && permissions.length > 0) { + params.permissions = permissions.join(",") + } + + const result = await binanceUsRequest("GET", "/api/v3/exchangeInfo", params, false) + + const symbolCount = result.symbols?.length || 0 + + return { + content: [ + { + type: "text", + text: `Retrieved exchange info. Total symbols: ${symbolCount}. Server time: ${result.serverTime}. Timezone: ${result.timezone}. Response: ${JSON.stringify(result, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get exchange info: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/market/index.ts b/src/tools/market/index.ts index f5d397aa..97ed5122 100644 --- a/src/tools/market/index.ts +++ b/src/tools/market/index.ts @@ -1,521 +1,654 @@ // src/tools/market/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { - binanceUsRequest, - formatKline, - formatAggTrade, - ORDER_BOOK_VALID_LIMITS, - KLINE_INTERVALS, - ROLLING_WINDOW_SIZES, - MAX_TRADES_LIMIT, - MAX_KLINES_LIMIT, - BinanceUsApiError, - RateLimitError, - IpBanError, - type KlineRaw, - type AggTradeResponse -} from "../../config/binanceUsClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { + type AggTradeResponse, + BinanceUsApiError, + binanceUsRequest, + formatAggTrade, + formatKline, + IpBanError, + KLINE_INTERVALS, + type KlineRaw, + MAX_KLINES_LIMIT, + MAX_TRADES_LIMIT, + ORDER_BOOK_VALID_LIMITS, + RateLimitError, + ROLLING_WINDOW_SIZES, +} from "../../config/binanceUsClient.js" /** * Format error response with helpful details */ function formatError(error: unknown): { content: { type: "text"; text: string }[]; isError: true } { - if (error instanceof RateLimitError) { - return { - content: [{ - type: "text", - text: `Rate limit exceeded. Please retry after ${error.retryAfter} seconds. Consider using WebSocket streams for real-time data.` - }], - isError: true - }; - } - if (error instanceof IpBanError) { - return { - content: [{ - type: "text", - text: `IP temporarily banned. Ban will be lifted after ${error.retryAfter} seconds. Please reduce request frequency.` - }], - isError: true - }; + if (error instanceof RateLimitError) { + return { + content: [ + { + type: "text", + text: `Rate limit exceeded. Please retry after ${error.retryAfter} seconds. Consider using WebSocket streams for real-time data.`, + }, + ], + isError: true, } - if (error instanceof BinanceUsApiError) { - return { - content: [{ - type: "text", - text: `Binance.US API Error [${error.code}]: ${error.message}` - }], - isError: true - }; + } + if (error instanceof IpBanError) { + return { + content: [ + { + type: "text", + text: `IP temporarily banned. Ban will be lifted after ${error.retryAfter} seconds. Please reduce request frequency.`, + }, + ], + isError: true, } - const errorMessage = error instanceof Error ? error.message : String(error); + } + if (error instanceof BinanceUsApiError) { return { - content: [{ type: "text", text: errorMessage }], - isError: true - }; + content: [ + { + type: "text", + text: `Binance.US API Error [${error.code}]: ${error.message}`, + }, + ], + isError: true, + } + } + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: errorMessage }], + isError: true, + } } /** * Register Market Data tools for Binance.US - * + * * These are public endpoints that don't require authentication. * Includes: order book, recent trades, klines, ticker data, etc. */ export function registerMarketTools(server: McpServer) { - // binance_us_order_book - Get order book depth - server.tool( - "binance_us_order_book", - "Get order book depth (bids and asks) for a trading pair on Binance.US. Returns price levels with quantities. Weight varies based on limit (1-100: weight 1, 101-500: weight 5, 501-1000: weight 10, 1001-5000: weight 50).", - { - symbol: z.string().toUpperCase().describe("Trading pair symbol, e.g., BTCUSD"), - limit: z.number() - .int() - .min(1) - .max(5000) - .optional() - .describe(`Number of price levels. Valid values: ${ORDER_BOOK_VALID_LIMITS.join(", ")}. Default 100, max 5000.`) - }, - async ({ symbol, limit }) => { - try { - const params: Record = { symbol }; - if (limit !== undefined) params.limit = limit; - - const result = await binanceUsRequest("GET", "/api/v3/depth", params, false); - - const bestBid = result.bids?.[0] || ["N/A", "N/A"]; - const bestAsk = result.asks?.[0] || ["N/A", "N/A"]; - - return { - content: [{ - type: "text", - text: `Order Book for ${symbol}\n` + - `━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + - `Last Update ID: ${result.lastUpdateId}\n` + - `Bids: ${result.bids?.length || 0} levels | Asks: ${result.asks?.length || 0} levels\n` + - `Best Bid: ${bestBid[0]} @ ${bestBid[1]} qty\n` + - `Best Ask: ${bestAsk[0]} @ ${bestAsk[1]} qty\n` + - `Spread: ${bestBid[0] !== "N/A" && bestAsk[0] !== "N/A" ? - (parseFloat(bestAsk[0]) - parseFloat(bestBid[0])).toFixed(8) : "N/A"}\n\n` + - `Full Response:\n${JSON.stringify(result, null, 2)}` - }] - }; - } catch (error) { - return formatError(error); - } + // binance_us_order_book - Get order book depth + server.tool( + "binance_us_order_book", + "Get order book depth (bids and asks) for a trading pair on Binance.US. Returns price levels with quantities. Weight varies based on limit (1-100: weight 1, 101-500: weight 5, 501-1000: weight 10, 1001-5000: weight 50).", + { + symbol: z.string().toUpperCase().describe("Trading pair symbol, e.g., BTCUSD"), + limit: z + .number() + .int() + .min(1) + .max(5000) + .optional() + .describe( + `Number of price levels. Valid values: ${ORDER_BOOK_VALID_LIMITS.join(", ")}. Default 100, max 5000.`, + ), + }, + async ({ symbol, limit }) => { + try { + const params: Record = { symbol } + if (limit !== undefined) params.limit = limit + + const result = await binanceUsRequest("GET", "/api/v3/depth", params, false) + + const bestBid = result.bids?.[0] || ["N/A", "N/A"] + const bestAsk = result.asks?.[0] || ["N/A", "N/A"] + + return { + content: [ + { + type: "text", + text: + `Order Book for ${symbol}\n` + + `━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + + `Last Update ID: ${result.lastUpdateId}\n` + + `Bids: ${result.bids?.length || 0} levels | Asks: ${result.asks?.length || 0} levels\n` + + `Best Bid: ${bestBid[0]} @ ${bestBid[1]} qty\n` + + `Best Ask: ${bestAsk[0]} @ ${bestAsk[1]} qty\n` + + `Spread: ${ + bestBid[0] !== "N/A" && bestAsk[0] !== "N/A" + ? (parseFloat(bestAsk[0]) - parseFloat(bestBid[0])).toFixed(8) + : "N/A" + }\n\n` + + `Full Response:\n${JSON.stringify(result, null, 2)}`, + }, + ], } - ); + } catch (error) { + return formatError(error) + } + }, + ) - // binance_us_recent_trades - Get recent trades - server.tool( - "binance_us_recent_trades", - "Get recent trades for a trading pair on Binance.US. Returns trade ID, price, quantity, time, and maker/taker info.", - { - symbol: z.string().toUpperCase().describe("Trading pair symbol, e.g., BTCUSD"), - limit: z.number().int().min(1).max(MAX_TRADES_LIMIT).optional() - .describe(`Number of trades to return. Default 500, max ${MAX_TRADES_LIMIT}.`) - }, - async ({ symbol, limit }) => { - try { - const params: Record = { symbol }; - if (limit !== undefined) params.limit = limit; - - const result = await binanceUsRequest("GET", "/api/v3/trades", params, false); - - const latestTrade = result[result.length - 1]; - const oldestTrade = result[0]; - - return { - content: [{ - type: "text", - text: `Recent Trades for ${symbol}\n` + - `━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + - `Total trades: ${result.length}\n` + - `Time range: ${new Date(oldestTrade?.time).toISOString()} to ${new Date(latestTrade?.time).toISOString()}\n` + - `Latest: ${latestTrade?.price} @ ${latestTrade?.qty} qty (ID: ${latestTrade?.id})\n\n` + - `Full Response:\n${JSON.stringify(result, null, 2)}` - }] - }; - } catch (error) { - return formatError(error); - } + // binance_us_recent_trades - Get recent trades + server.tool( + "binance_us_recent_trades", + "Get recent trades for a trading pair on Binance.US. Returns trade ID, price, quantity, time, and maker/taker info.", + { + symbol: z.string().toUpperCase().describe("Trading pair symbol, e.g., BTCUSD"), + limit: z + .number() + .int() + .min(1) + .max(MAX_TRADES_LIMIT) + .optional() + .describe(`Number of trades to return. Default 500, max ${MAX_TRADES_LIMIT}.`), + }, + async ({ symbol, limit }) => { + try { + const params: Record = { symbol } + if (limit !== undefined) params.limit = limit + + const result = await binanceUsRequest("GET", "/api/v3/trades", params, false) + + const latestTrade = result[result.length - 1] + const oldestTrade = result[0] + + return { + content: [ + { + type: "text", + text: + `Recent Trades for ${symbol}\n` + + `━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + + `Total trades: ${result.length}\n` + + `Time range: ${new Date(oldestTrade?.time).toISOString()} to ${new Date(latestTrade?.time).toISOString()}\n` + + `Latest: ${latestTrade?.price} @ ${latestTrade?.qty} qty (ID: ${latestTrade?.id})\n\n` + + `Full Response:\n${JSON.stringify(result, null, 2)}`, + }, + ], } - ); + } catch (error) { + return formatError(error) + } + }, + ) - // binance_us_historical_trades - Get older trades (MARKET_DATA) - server.tool( - "binance_us_historical_trades", - "Get older historical trades for a trading pair. Requires API key with MARKET_DATA permission.", - { - symbol: z.string().toUpperCase().describe("Trading pair symbol, e.g., BTCUSD"), - limit: z.number().int().min(1).max(MAX_TRADES_LIMIT).optional() - .describe(`Number of trades. Default 500, max ${MAX_TRADES_LIMIT}.`), - fromId: z.number().int().positive().optional() - .describe("Trade ID to fetch from (inclusive).") - }, - async ({ symbol, limit, fromId }) => { - try { - const params: Record = { symbol }; - if (limit !== undefined) params.limit = limit; - if (fromId !== undefined) params.fromId = fromId; - - const result = await binanceUsRequest("GET", "/api/v3/historicalTrades", params, false, true); - - const latestTrade = result[result.length - 1]; - const oldestTrade = result[0]; - - return { - content: [{ - type: "text", - text: `Historical Trades for ${symbol}\n` + - `━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + - `Total trades: ${result.length}\n` + - `Trade ID range: ${oldestTrade?.id} to ${latestTrade?.id}\n` + - `Time range: ${new Date(oldestTrade?.time).toISOString()} to ${new Date(latestTrade?.time).toISOString()}\n\n` + - `Full Response:\n${JSON.stringify(result, null, 2)}` - }] - }; - } catch (error) { - return formatError(error); - } + // binance_us_historical_trades - Get older trades (MARKET_DATA) + server.tool( + "binance_us_historical_trades", + "Get older historical trades for a trading pair. Requires API key with MARKET_DATA permission.", + { + symbol: z.string().toUpperCase().describe("Trading pair symbol, e.g., BTCUSD"), + limit: z + .number() + .int() + .min(1) + .max(MAX_TRADES_LIMIT) + .optional() + .describe(`Number of trades. Default 500, max ${MAX_TRADES_LIMIT}.`), + fromId: z + .number() + .int() + .positive() + .optional() + .describe("Trade ID to fetch from (inclusive)."), + }, + async ({ symbol, limit, fromId }) => { + try { + const params: Record = { symbol } + if (limit !== undefined) params.limit = limit + if (fromId !== undefined) params.fromId = fromId + + const result = await binanceUsRequest( + "GET", + "/api/v3/historicalTrades", + params, + false, + true, + ) + + const latestTrade = result[result.length - 1] + const oldestTrade = result[0] + + return { + content: [ + { + type: "text", + text: + `Historical Trades for ${symbol}\n` + + `━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + + `Total trades: ${result.length}\n` + + `Trade ID range: ${oldestTrade?.id} to ${latestTrade?.id}\n` + + `Time range: ${new Date(oldestTrade?.time).toISOString()} to ${new Date(latestTrade?.time).toISOString()}\n\n` + + `Full Response:\n${JSON.stringify(result, null, 2)}`, + }, + ], } - ); + } catch (error) { + return formatError(error) + } + }, + ) - // binance_us_agg_trades - Get aggregate trades - server.tool( - "binance_us_agg_trades", - "Get compressed aggregate trades. Trades with same time, order, and price are aggregated.", - { - symbol: z.string().toUpperCase().describe("Trading pair symbol, e.g., BTCUSD"), - fromId: z.number().int().positive().optional().describe("Agg trade ID to start from."), - startTime: z.number().int().positive().optional().describe("Start time in ms."), - endTime: z.number().int().positive().optional().describe("End time in ms."), - limit: z.number().int().min(1).max(MAX_TRADES_LIMIT).optional() - .describe(`Number of trades. Default 500, max ${MAX_TRADES_LIMIT}.`) - }, - async ({ symbol, fromId, startTime, endTime, limit }) => { - try { - const params: Record = { symbol }; - if (fromId !== undefined) params.fromId = fromId; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; - - const result: AggTradeResponse[] = await binanceUsRequest("GET", "/api/v3/aggTrades", params, false); - const formattedTrades = result.map(formatAggTrade); - - const firstTrade = result[0]; - const lastTrade = result[result.length - 1]; - const summary = firstTrade && lastTrade ? { - firstAggId: firstTrade.a, - lastAggId: lastTrade.a, - timeRange: `${new Date(firstTrade.T).toISOString()} to ${new Date(lastTrade.T).toISOString()}`, - latestPrice: lastTrade.p - } : null; - - return { - content: [{ - type: "text", - text: `Aggregate Trades for ${symbol}\n` + - `━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + - `Total trades: ${result.length}\n` + - (summary ? `Agg ID range: ${summary.firstAggId} to ${summary.lastAggId}\n` + - `Time range: ${summary.timeRange}\n` + - `Latest price: ${summary.latestPrice}\n\n` : "\n") + - `Formatted (first 10):\n${JSON.stringify(formattedTrades.slice(0, 10), null, 2)}\n\n` + - `Raw Response:\n${JSON.stringify(result, null, 2)}` - }] - }; - } catch (error) { - return formatError(error); - } + // binance_us_agg_trades - Get aggregate trades + server.tool( + "binance_us_agg_trades", + "Get compressed aggregate trades. Trades with same time, order, and price are aggregated.", + { + symbol: z.string().toUpperCase().describe("Trading pair symbol, e.g., BTCUSD"), + fromId: z.number().int().positive().optional().describe("Agg trade ID to start from."), + startTime: z.number().int().positive().optional().describe("Start time in ms."), + endTime: z.number().int().positive().optional().describe("End time in ms."), + limit: z + .number() + .int() + .min(1) + .max(MAX_TRADES_LIMIT) + .optional() + .describe(`Number of trades. Default 500, max ${MAX_TRADES_LIMIT}.`), + }, + async ({ symbol, fromId, startTime, endTime, limit }) => { + try { + const params: Record = { symbol } + if (fromId !== undefined) params.fromId = fromId + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit + + const result: AggTradeResponse[] = await binanceUsRequest( + "GET", + "/api/v3/aggTrades", + params, + false, + ) + const formattedTrades = result.map(formatAggTrade) + + const firstTrade = result[0] + const lastTrade = result[result.length - 1] + const summary = + firstTrade && lastTrade + ? { + firstAggId: firstTrade.a, + lastAggId: lastTrade.a, + timeRange: `${new Date(firstTrade.T).toISOString()} to ${new Date(lastTrade.T).toISOString()}`, + latestPrice: lastTrade.p, + } + : null + + return { + content: [ + { + type: "text", + text: + `Aggregate Trades for ${symbol}\n` + + `━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + + `Total trades: ${result.length}\n` + + (summary + ? `Agg ID range: ${summary.firstAggId} to ${summary.lastAggId}\n` + + `Time range: ${summary.timeRange}\n` + + `Latest price: ${summary.latestPrice}\n\n` + : "\n") + + `Formatted (first 10):\n${JSON.stringify(formattedTrades.slice(0, 10), null, 2)}\n\n` + + `Raw Response:\n${JSON.stringify(result, null, 2)}`, + }, + ], } - ); + } catch (error) { + return formatError(error) + } + }, + ) - // binance_us_klines - Get candlestick data - server.tool( - "binance_us_klines", - "Get Kline/candlestick data for a trading pair. Returns OHLCV data.", - { - symbol: z.string().toUpperCase().describe("Trading pair symbol, e.g., BTCUSD"), - interval: z.enum(KLINE_INTERVALS).describe(`Kline interval: ${KLINE_INTERVALS.join(", ")}`), - startTime: z.number().int().positive().optional().describe("Start time in ms"), - endTime: z.number().int().positive().optional().describe("End time in ms"), - limit: z.number().int().min(1).max(MAX_KLINES_LIMIT).optional() - .describe(`Number of klines. Default 500, max ${MAX_KLINES_LIMIT}.`) - }, - async ({ symbol, interval, startTime, endTime, limit }) => { - try { - const params: Record = { symbol, interval }; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (limit !== undefined) params.limit = limit; - - const result: KlineRaw[] = await binanceUsRequest("GET", "/api/v3/klines", params, false); - const formattedKlines = result.map(formatKline); - - const firstKline = formattedKlines[0]; - const latestKline = formattedKlines[formattedKlines.length - 1]; - - let summaryText = ""; - if (formattedKlines.length > 0 && firstKline && latestKline) { - const highs = formattedKlines.map(k => parseFloat(k.high)); - const lows = formattedKlines.map(k => parseFloat(k.low)); - const volumes = formattedKlines.map(k => parseFloat(k.volume)); - - summaryText = `Period: ${firstKline.openTimeISO} to ${latestKline.closeTimeISO}\n` + - `Latest: O:${latestKline.open} H:${latestKline.high} L:${latestKline.low} C:${latestKline.close}\n` + - `Period High: ${Math.max(...highs)} | Period Low: ${Math.min(...lows)}\n` + - `Total Volume: ${volumes.reduce((a, b) => a + b, 0).toFixed(8)}\n`; - } - - return { - content: [{ - type: "text", - text: `Klines for ${symbol} (${interval})\n` + - `━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + - `Total klines: ${result.length}\n` + - summaryText + "\n" + - `Formatted (last 5):\n${JSON.stringify(formattedKlines.slice(-5), null, 2)}\n\n` + - `Full Response:\n${JSON.stringify(formattedKlines, null, 2)}` - }] - }; - } catch (error) { - return formatError(error); - } + // binance_us_klines - Get candlestick data + server.tool( + "binance_us_klines", + "Get Kline/candlestick data for a trading pair. Returns OHLCV data.", + { + symbol: z.string().toUpperCase().describe("Trading pair symbol, e.g., BTCUSD"), + interval: z.enum(KLINE_INTERVALS).describe(`Kline interval: ${KLINE_INTERVALS.join(", ")}`), + startTime: z.number().int().positive().optional().describe("Start time in ms"), + endTime: z.number().int().positive().optional().describe("End time in ms"), + limit: z + .number() + .int() + .min(1) + .max(MAX_KLINES_LIMIT) + .optional() + .describe(`Number of klines. Default 500, max ${MAX_KLINES_LIMIT}.`), + }, + async ({ symbol, interval, startTime, endTime, limit }) => { + try { + const params: Record = { symbol, interval } + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (limit !== undefined) params.limit = limit + + const result: KlineRaw[] = await binanceUsRequest("GET", "/api/v3/klines", params, false) + const formattedKlines = result.map(formatKline) + + const firstKline = formattedKlines[0] + const latestKline = formattedKlines[formattedKlines.length - 1] + + let summaryText = "" + if (formattedKlines.length > 0 && firstKline && latestKline) { + const highs = formattedKlines.map((k) => parseFloat(k.high)) + const lows = formattedKlines.map((k) => parseFloat(k.low)) + const volumes = formattedKlines.map((k) => parseFloat(k.volume)) + + summaryText = + `Period: ${firstKline.openTimeISO} to ${latestKline.closeTimeISO}\n` + + `Latest: O:${latestKline.open} H:${latestKline.high} L:${latestKline.low} C:${latestKline.close}\n` + + `Period High: ${Math.max(...highs)} | Period Low: ${Math.min(...lows)}\n` + + `Total Volume: ${volumes.reduce((a, b) => a + b, 0).toFixed(8)}\n` } - ); - // binance_us_avg_price - Get average price - server.tool( - "binance_us_avg_price", - "Get current 5-minute rolling weighted average price.", - { - symbol: z.string().toUpperCase().describe("Trading pair symbol, e.g., BTCUSD") - }, - async ({ symbol }) => { - try { - const result = await binanceUsRequest("GET", "/api/v3/avgPrice", { symbol }, false); - - return { - content: [{ - type: "text", - text: `Average Price for ${symbol}\n` + - `━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + - `Price: ${result.price}\n` + - `Window: ${result.mins} minutes\n\n` + - `Response:\n${JSON.stringify(result, null, 2)}` - }] - }; - } catch (error) { - return formatError(error); - } + return { + content: [ + { + type: "text", + text: + `Klines for ${symbol} (${interval})\n` + + `━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + + `Total klines: ${result.length}\n` + + summaryText + + "\n" + + `Formatted (last 5):\n${JSON.stringify(formattedKlines.slice(-5), null, 2)}\n\n` + + `Full Response:\n${JSON.stringify(formattedKlines, null, 2)}`, + }, + ], } - ); + } catch (error) { + return formatError(error) + } + }, + ) - // binance_us_ticker_24hr - Get 24hr statistics - server.tool( - "binance_us_ticker_24hr", - "Get 24-hour rolling window price change statistics.", - { - symbol: z.string().toUpperCase().optional().describe("Symbol (e.g., BTCUSD). Cannot use with 'symbols'."), - symbols: z.array(z.string()).optional().describe("Array of symbols. Cannot use with 'symbol'."), - type: z.enum(["FULL", "MINI"]).optional().describe("FULL (default) or MINI (fewer fields).") - }, - async ({ symbol, symbols, type }) => { - try { - if (symbol && symbols) { - return { - content: [{ type: "text", text: "Error: Cannot specify both 'symbol' and 'symbols'." }], - isError: true - }; - } - - const params: Record = {}; - if (symbol) params.symbol = symbol; - if (symbols?.length) params.symbols = JSON.stringify(symbols.map(s => s.toUpperCase())); - if (type) params.type = type; - - const result = await binanceUsRequest("GET", "/api/v3/ticker/24hr", params, false); - - const isArray = Array.isArray(result); - let summaryText: string; - - if (isArray) { - const sorted = [...result].sort((a: any, b: any) => parseFloat(b.quoteVolume) - parseFloat(a.quoteVolume)); - const top5 = sorted.slice(0, 5); - summaryText = `Total symbols: ${result.length}\n` + - `Top 5 by volume:\n${top5.map((t: any) => ` ${t.symbol}: ${t.priceChangePercent}% | Vol: ${parseFloat(t.quoteVolume).toLocaleString()}`).join("\n")}`; - } else { - summaryText = `${result.symbol}: ${result.lastPrice} (${parseFloat(result.priceChangePercent) >= 0 ? "+" : ""}${result.priceChangePercent}%)\n` + - `High: ${result.highPrice} | Low: ${result.lowPrice}\n` + - `Volume: ${result.volume}`; - } - - return { - content: [{ - type: "text", - text: `24hr Ticker Statistics\n` + - `━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + - summaryText + "\n\n" + - `Full Response:\n${JSON.stringify(result, null, 2)}` - }] - }; - } catch (error) { - return formatError(error); - } + // binance_us_avg_price - Get average price + server.tool( + "binance_us_avg_price", + "Get current 5-minute rolling weighted average price.", + { + symbol: z.string().toUpperCase().describe("Trading pair symbol, e.g., BTCUSD"), + }, + async ({ symbol }) => { + try { + const result = await binanceUsRequest("GET", "/api/v3/avgPrice", { symbol }, false) + + return { + content: [ + { + type: "text", + text: + `Average Price for ${symbol}\n` + + `━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + + `Price: ${result.price}\n` + + `Window: ${result.mins} minutes\n\n` + + `Response:\n${JSON.stringify(result, null, 2)}`, + }, + ], } - ); + } catch (error) { + return formatError(error) + } + }, + ) - // binance_us_ticker_price - Get latest price - server.tool( - "binance_us_ticker_price", - "Get latest price for symbol(s).", - { - symbol: z.string().toUpperCase().optional().describe("Symbol (e.g., BTCUSD). Cannot use with 'symbols'."), - symbols: z.array(z.string()).optional().describe("Array of symbols. Cannot use with 'symbol'.") - }, - async ({ symbol, symbols }) => { - try { - if (symbol && symbols) { - return { - content: [{ type: "text", text: "Error: Cannot specify both 'symbol' and 'symbols'." }], - isError: true - }; - } - - const params: Record = {}; - if (symbol) params.symbol = symbol; - if (symbols?.length) params.symbols = JSON.stringify(symbols.map(s => s.toUpperCase())); - - const result = await binanceUsRequest("GET", "/api/v3/ticker/price", params, false); - - const isArray = Array.isArray(result); - const responseText = isArray - ? `Retrieved prices for ${result.length} symbols.` - : `${result.symbol}: ${result.price}`; - - return { - content: [{ - type: "text", - text: `Price Ticker\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + - responseText + "\n\n" + - `Response:\n${JSON.stringify(result, null, 2)}` - }] - }; - } catch (error) { - return formatError(error); - } + // binance_us_ticker_24hr - Get 24hr statistics + server.tool( + "binance_us_ticker_24hr", + "Get 24-hour rolling window price change statistics.", + { + symbol: z + .string() + .toUpperCase() + .optional() + .describe("Symbol (e.g., BTCUSD). Cannot use with 'symbols'."), + symbols: z + .array(z.string()) + .optional() + .describe("Array of symbols. Cannot use with 'symbol'."), + type: z.enum(["FULL", "MINI"]).optional().describe("FULL (default) or MINI (fewer fields)."), + }, + async ({ symbol, symbols, type }) => { + try { + if (symbol && symbols) { + return { + content: [{ type: "text", text: "Error: Cannot specify both 'symbol' and 'symbols'." }], + isError: true, + } } - ); - // binance_us_ticker_book - Get book ticker - server.tool( - "binance_us_ticker_book", - "Get best bid/ask prices and quantities (top of book).", - { - symbol: z.string().toUpperCase().optional().describe("Symbol (e.g., BTCUSD). Cannot use with 'symbols'."), - symbols: z.array(z.string()).optional().describe("Array of symbols. Cannot use with 'symbol'.") - }, - async ({ symbol, symbols }) => { - try { - if (symbol && symbols) { - return { - content: [{ type: "text", text: "Error: Cannot specify both 'symbol' and 'symbols'." }], - isError: true - }; - } - - const params: Record = {}; - if (symbol) params.symbol = symbol; - if (symbols?.length) params.symbols = JSON.stringify(symbols.map(s => s.toUpperCase())); - - const result = await binanceUsRequest("GET", "/api/v3/ticker/bookTicker", params, false); - - const isArray = Array.isArray(result); - let summaryText: string; - - if (isArray) { - summaryText = `Total symbols: ${result.length}`; - } else { - const spread = (parseFloat(result.askPrice) - parseFloat(result.bidPrice)).toFixed(8); - const midPrice = ((parseFloat(result.askPrice) + parseFloat(result.bidPrice)) / 2).toFixed(8); - summaryText = `${result.symbol}\n` + - `Bid: ${result.bidPrice} @ ${result.bidQty}\n` + - `Ask: ${result.askPrice} @ ${result.askQty}\n` + - `Spread: ${spread} | Mid: ${midPrice}`; - } - - return { - content: [{ - type: "text", - text: `Book Ticker\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + - summaryText + "\n\n" + - `Response:\n${JSON.stringify(result, null, 2)}` - }] - }; - } catch (error) { - return formatError(error); - } + const params: Record = {} + if (symbol) params.symbol = symbol + if (symbols?.length) params.symbols = JSON.stringify(symbols.map((s) => s.toUpperCase())) + if (type) params.type = type + + const result = await binanceUsRequest("GET", "/api/v3/ticker/24hr", params, false) + + const isArray = Array.isArray(result) + let summaryText: string + + if (isArray) { + const sorted = [...result].sort( + (a: any, b: any) => parseFloat(b.quoteVolume) - parseFloat(a.quoteVolume), + ) + const top5 = sorted.slice(0, 5) + summaryText = + `Total symbols: ${result.length}\n` + + `Top 5 by volume:\n${top5.map((t: any) => ` ${t.symbol}: ${t.priceChangePercent}% | Vol: ${parseFloat(t.quoteVolume).toLocaleString()}`).join("\n")}` + } else { + summaryText = + `${result.symbol}: ${result.lastPrice} (${parseFloat(result.priceChangePercent) >= 0 ? "+" : ""}${result.priceChangePercent}%)\n` + + `High: ${result.highPrice} | Low: ${result.lowPrice}\n` + + `Volume: ${result.volume}` } - ); - // binance_us_rolling_window - Get rolling window stats - server.tool( - "binance_us_rolling_window", - "Get rolling window price change statistics with custom window sizes (1m to 7d).", - { - symbol: z.string().toUpperCase().optional().describe("Symbol (required if 'symbols' not provided)."), - symbols: z.array(z.string()).optional().describe("Array of symbols (required if 'symbol' not provided)."), - windowSize: z.enum(ROLLING_WINDOW_SIZES).optional().describe(`Window size. Default 1d. Options: ${ROLLING_WINDOW_SIZES.join(", ")}`), - type: z.enum(["FULL", "MINI"]).optional().describe("FULL (default) or MINI.") - }, - async ({ symbol, symbols, windowSize, type }) => { - try { - if (!symbol && !symbols?.length) { - return { - content: [{ type: "text", text: "Error: Either 'symbol' or 'symbols' must be provided." }], - isError: true - }; - } - if (symbol && symbols) { - return { - content: [{ type: "text", text: "Error: Cannot specify both 'symbol' and 'symbols'." }], - isError: true - }; - } - - const params: Record = {}; - if (symbol) params.symbol = symbol; - if (symbols?.length) params.symbols = JSON.stringify(symbols.map(s => s.toUpperCase())); - if (windowSize) params.windowSize = windowSize; - if (type) params.type = type; - - const result = await binanceUsRequest("GET", "/api/v3/ticker", params, false); - - const isArray = Array.isArray(result); - const windowText = windowSize || "1d"; - let summaryText: string; - - if (isArray) { - summaryText = `Window: ${windowText}\nTotal symbols: ${result.length}`; - } else { - summaryText = `${result.symbol} (${windowText})\n` + - `Price: ${result.lastPrice} (${parseFloat(result.priceChangePercent) >= 0 ? "+" : ""}${result.priceChangePercent}%)\n` + - `High: ${result.highPrice} | Low: ${result.lowPrice}\n` + - `Volume: ${result.volume} | Trades: ${result.count}`; - } - - return { - content: [{ - type: "text", - text: `Rolling Window Statistics\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + - summaryText + "\n\n" + - `Response:\n${JSON.stringify(result, null, 2)}` - }] - }; - } catch (error) { - return formatError(error); - } + return { + content: [ + { + type: "text", + text: + `24hr Ticker Statistics\n` + + `━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + + summaryText + + "\n\n" + + `Full Response:\n${JSON.stringify(result, null, 2)}`, + }, + ], + } + } catch (error) { + return formatError(error) + } + }, + ) + + // binance_us_ticker_price - Get latest price + server.tool( + "binance_us_ticker_price", + "Get latest price for symbol(s).", + { + symbol: z + .string() + .toUpperCase() + .optional() + .describe("Symbol (e.g., BTCUSD). Cannot use with 'symbols'."), + symbols: z + .array(z.string()) + .optional() + .describe("Array of symbols. Cannot use with 'symbol'."), + }, + async ({ symbol, symbols }) => { + try { + if (symbol && symbols) { + return { + content: [{ type: "text", text: "Error: Cannot specify both 'symbol' and 'symbols'." }], + isError: true, + } + } + + const params: Record = {} + if (symbol) params.symbol = symbol + if (symbols?.length) params.symbols = JSON.stringify(symbols.map((s) => s.toUpperCase())) + + const result = await binanceUsRequest("GET", "/api/v3/ticker/price", params, false) + + const isArray = Array.isArray(result) + const responseText = isArray + ? `Retrieved prices for ${result.length} symbols.` + : `${result.symbol}: ${result.price}` + + return { + content: [ + { + type: "text", + text: + `Price Ticker\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + + responseText + + "\n\n" + + `Response:\n${JSON.stringify(result, null, 2)}`, + }, + ], + } + } catch (error) { + return formatError(error) + } + }, + ) + + // binance_us_ticker_book - Get book ticker + server.tool( + "binance_us_ticker_book", + "Get best bid/ask prices and quantities (top of book).", + { + symbol: z + .string() + .toUpperCase() + .optional() + .describe("Symbol (e.g., BTCUSD). Cannot use with 'symbols'."), + symbols: z + .array(z.string()) + .optional() + .describe("Array of symbols. Cannot use with 'symbol'."), + }, + async ({ symbol, symbols }) => { + try { + if (symbol && symbols) { + return { + content: [{ type: "text", text: "Error: Cannot specify both 'symbol' and 'symbols'." }], + isError: true, + } + } + + const params: Record = {} + if (symbol) params.symbol = symbol + if (symbols?.length) params.symbols = JSON.stringify(symbols.map((s) => s.toUpperCase())) + + const result = await binanceUsRequest("GET", "/api/v3/ticker/bookTicker", params, false) + + const isArray = Array.isArray(result) + let summaryText: string + + if (isArray) { + summaryText = `Total symbols: ${result.length}` + } else { + const spread = (parseFloat(result.askPrice) - parseFloat(result.bidPrice)).toFixed(8) + const midPrice = ( + (parseFloat(result.askPrice) + parseFloat(result.bidPrice)) / + 2 + ).toFixed(8) + summaryText = + `${result.symbol}\n` + + `Bid: ${result.bidPrice} @ ${result.bidQty}\n` + + `Ask: ${result.askPrice} @ ${result.askQty}\n` + + `Spread: ${spread} | Mid: ${midPrice}` + } + + return { + content: [ + { + type: "text", + text: + `Book Ticker\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + + summaryText + + "\n\n" + + `Response:\n${JSON.stringify(result, null, 2)}`, + }, + ], + } + } catch (error) { + return formatError(error) + } + }, + ) + + // binance_us_rolling_window - Get rolling window stats + server.tool( + "binance_us_rolling_window", + "Get rolling window price change statistics with custom window sizes (1m to 7d).", + { + symbol: z + .string() + .toUpperCase() + .optional() + .describe("Symbol (required if 'symbols' not provided)."), + symbols: z + .array(z.string()) + .optional() + .describe("Array of symbols (required if 'symbol' not provided)."), + windowSize: z + .enum(ROLLING_WINDOW_SIZES) + .optional() + .describe(`Window size. Default 1d. Options: ${ROLLING_WINDOW_SIZES.join(", ")}`), + type: z.enum(["FULL", "MINI"]).optional().describe("FULL (default) or MINI."), + }, + async ({ symbol, symbols, windowSize, type }) => { + try { + if (!symbol && !symbols?.length) { + return { + content: [ + { type: "text", text: "Error: Either 'symbol' or 'symbols' must be provided." }, + ], + isError: true, + } + } + if (symbol && symbols) { + return { + content: [{ type: "text", text: "Error: Cannot specify both 'symbol' and 'symbols'." }], + isError: true, + } + } + + const params: Record = {} + if (symbol) params.symbol = symbol + if (symbols?.length) params.symbols = JSON.stringify(symbols.map((s) => s.toUpperCase())) + if (windowSize) params.windowSize = windowSize + if (type) params.type = type + + const result = await binanceUsRequest("GET", "/api/v3/ticker", params, false) + + const isArray = Array.isArray(result) + const windowText = windowSize || "1d" + let summaryText: string + + if (isArray) { + summaryText = `Window: ${windowText}\nTotal symbols: ${result.length}` + } else { + summaryText = + `${result.symbol} (${windowText})\n` + + `Price: ${result.lastPrice} (${parseFloat(result.priceChangePercent) >= 0 ? "+" : ""}${result.priceChangePercent}%)\n` + + `High: ${result.highPrice} | Low: ${result.lowPrice}\n` + + `Volume: ${result.volume} | Trades: ${result.count}` + } + + return { + content: [ + { + type: "text", + text: + `Rolling Window Statistics\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + + summaryText + + "\n\n" + + `Response:\n${JSON.stringify(result, null, 2)}`, + }, + ], } - ); + } catch (error) { + return formatError(error) + } + }, + ) } diff --git a/src/tools/otc/index.ts b/src/tools/otc/index.ts index 3e3f0ae0..68d88ad5 100644 --- a/src/tools/otc/index.ts +++ b/src/tools/otc/index.ts @@ -2,23 +2,25 @@ // Binance.US OTC (Over-The-Counter) Trading Tools // Large block trades executed outside the regular order book -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { makeSignedRequest } from "../../config/binanceUsClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { makeSignedRequest } from "../../config/binanceUsClient.js" /** * Register all Binance.US OTC trading tools - * + * * OTC trading allows large block trades to be executed outside the regular * order book, minimizing market impact for institutional traders. */ export function registerOtcTools(server: McpServer) { - // ===================================================================== - // GET /sapi/v1/otc/coinPairs - Get Supported OTC Coin Pairs - // ===================================================================== - server.tool( - "binance_us_otc_coin_pairs", - `Get a list of supported OTC (Over-The-Counter) trading pairs on Binance.US. + // ===================================================================== + // GET /sapi/v1/otc/coinPairs - Get Supported OTC Coin Pairs + // ===================================================================== + server.tool( + "binance_us_otc_coin_pairs", + `Get a list of supported OTC (Over-The-Counter) trading pairs on Binance.US. OTC trading allows large block trades to be executed outside the regular order book, minimizing market impact. This endpoint returns available coin pairs with their @@ -30,39 +32,42 @@ Response includes: - toCoinMinAmount/toCoinMaxAmount: Min/max amounts for the buy coin Example: Convert large amounts of BTC to USDT without affecting market price.`, - { - fromCoin: z.string().optional().describe("Filter by source coin (e.g., BTC, SHIB)"), - toCoin: z.string().optional().describe("Filter by destination coin (e.g., USDT, KSHIB)") - }, - async (params) => { - try { - const response = await makeSignedRequest("GET", "/sapi/v1/otc/coinPairs", { - ...(params.fromCoin && { fromCoin: params.fromCoin.toUpperCase() }), - ...(params.toCoin && { toCoin: params.toCoin.toUpperCase() }) - }); - - return { - content: [{ - type: "text", - text: `Successfully retrieved OTC coin pairs. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get OTC coin pairs: ${errorMessage}` }], - isError: true - }; - } + { + fromCoin: z.string().optional().describe("Filter by source coin (e.g., BTC, SHIB)"), + toCoin: z.string().optional().describe("Filter by destination coin (e.g., USDT, KSHIB)"), + }, + async (params) => { + try { + const response = await makeSignedRequest("GET", "/sapi/v1/otc/coinPairs", { + ...(params.fromCoin && { fromCoin: params.fromCoin.toUpperCase() }), + ...(params.toCoin && { toCoin: params.toCoin.toUpperCase() }), + }) + + return { + content: [ + { + type: "text", + text: `Successfully retrieved OTC coin pairs. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get OTC coin pairs: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) - // ===================================================================== - // POST /sapi/v1/otc/quotes - Request Quote for OTC Trade - // ===================================================================== - server.tool( - "binance_us_otc_quote", - `Request a quote for an OTC (Over-The-Counter) trade on Binance.US. + // ===================================================================== + // POST /sapi/v1/otc/quotes - Request Quote for OTC Trade + // ===================================================================== + server.tool( + "binance_us_otc_quote", + `Request a quote for an OTC (Over-The-Counter) trade on Binance.US. This endpoint requests a price quote for converting one coin to another via OTC. The quote is valid for a limited time (check validTimestamp in response). @@ -81,43 +86,48 @@ Response includes: - inverseRatio: Inverse conversion ratio - validTimestamp: Unix timestamp when quote expires - toAmount/fromAmount: Calculated amounts for the trade`, - { - fromCoin: z.string().describe("Coin to sell (e.g., BTC, SHIB)"), - toCoin: z.string().describe("Coin to buy (e.g., USDT, KSHIB)"), - requestCoin: z.string().describe("Which coin's amount you're specifying (fromCoin or toCoin)"), - requestAmount: z.number().positive().describe("Amount of the request coin") - }, - async (params) => { - try { - const response = await makeSignedRequest("POST", "/sapi/v1/otc/quotes", { - fromCoin: params.fromCoin.toUpperCase(), - toCoin: params.toCoin.toUpperCase(), - requestCoin: params.requestCoin.toUpperCase(), - requestAmount: params.requestAmount - }); - - return { - content: [{ - type: "text", - text: `OTC Quote received successfully. ⚠️ Quote expires at timestamp ${response.validTimestamp}. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get OTC quote: ${errorMessage}` }], - isError: true - }; - } + { + fromCoin: z.string().describe("Coin to sell (e.g., BTC, SHIB)"), + toCoin: z.string().describe("Coin to buy (e.g., USDT, KSHIB)"), + requestCoin: z + .string() + .describe("Which coin's amount you're specifying (fromCoin or toCoin)"), + requestAmount: z.number().positive().describe("Amount of the request coin"), + }, + async (params) => { + try { + const response = await makeSignedRequest("POST", "/sapi/v1/otc/quotes", { + fromCoin: params.fromCoin.toUpperCase(), + toCoin: params.toCoin.toUpperCase(), + requestCoin: params.requestCoin.toUpperCase(), + requestAmount: params.requestAmount, + }) + + return { + content: [ + { + type: "text", + text: `OTC Quote received successfully. ⚠️ Quote expires at timestamp ${response.validTimestamp}. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get OTC quote: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) - // ===================================================================== - // POST /sapi/v1/otc/orders - Place OTC Trade Order - // ===================================================================== - server.tool( - "binance_us_otc_place_order", - `Place an OTC (Over-The-Counter) trade order using a previously acquired quote. + // ===================================================================== + // POST /sapi/v1/otc/orders - Place OTC Trade Order + // ===================================================================== + server.tool( + "binance_us_otc_place_order", + `Place an OTC (Over-The-Counter) trade order using a previously acquired quote. ⚠️ IMPORTANT: You must first call binance_us_otc_quote to get a quoteId before placing an order. The quote expires quickly, so place the order immediately after receiving the quote. @@ -132,37 +142,44 @@ Response includes: - orderId: Unique order identifier - createTime: Order creation timestamp - orderStatus: Current status of the order`, - { - quoteId: z.string().describe("Quote ID received from binance_us_otc_quote (e.g., '4e5446f2cc6f44ab86ab02abf19a2fd2')") - }, - async (params) => { - try { - const response = await makeSignedRequest("POST", "/sapi/v1/otc/orders", { - quoteId: params.quoteId - }); - - return { - content: [{ - type: "text", - text: `OTC order placed successfully. Order ID: ${response.orderId}, Status: ${response.orderStatus}. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to place OTC order: ${errorMessage}` }], - isError: true - }; - } + { + quoteId: z + .string() + .describe( + "Quote ID received from binance_us_otc_quote (e.g., '4e5446f2cc6f44ab86ab02abf19a2fd2')", + ), + }, + async (params) => { + try { + const response = await makeSignedRequest("POST", "/sapi/v1/otc/orders", { + quoteId: params.quoteId, + }) + + return { + content: [ + { + type: "text", + text: `OTC order placed successfully. Order ID: ${response.orderId}, Status: ${response.orderStatus}. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to place OTC order: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) - // ===================================================================== - // GET /sapi/v1/otc/orders/{orderId} - Get OTC Order Details - // ===================================================================== - server.tool( - "binance_us_otc_get_order", - `Get detailed information about a specific OTC (Over-The-Counter) trade order. + // ===================================================================== + // GET /sapi/v1/otc/orders/{orderId} - Get OTC Order Details + // ===================================================================== + server.tool( + "binance_us_otc_get_order", + `Get detailed information about a specific OTC (Over-The-Counter) trade order. Use this to check the status and details of a previously placed OTC order. @@ -174,35 +191,38 @@ Response includes: - toCoin/toAmount: Bought coin and amount - ratio/inverseRatio: Exchange rates - createTime: Order creation timestamp`, - { - orderId: z.string().describe("OTC order ID to query (e.g., '10002349')") - }, - async (params) => { - try { - const response = await makeSignedRequest("GET", `/sapi/v1/otc/orders/${params.orderId}`); - - return { - content: [{ - type: "text", - text: `OTC order details retrieved. Status: ${response.orderStatus}. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get OTC order: ${errorMessage}` }], - isError: true - }; - } + { + orderId: z.string().describe("OTC order ID to query (e.g., '10002349')"), + }, + async (params) => { + try { + const response = await makeSignedRequest("GET", `/sapi/v1/otc/orders/${params.orderId}`) + + return { + content: [ + { + type: "text", + text: `OTC order details retrieved. Status: ${response.orderStatus}. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], } - ); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - // ===================================================================== - // GET /sapi/v1/otc/orders - Get All OTC Trade Orders - // ===================================================================== - server.tool( - "binance_us_otc_all_orders", - `Query all OTC (Over-The-Counter) trade orders with optional filters. + return { + content: [{ type: "text", text: `Failed to get OTC order: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================================== + // GET /sapi/v1/otc/orders - Get All OTC Trade Orders + // ===================================================================== + server.tool( + "binance_us_otc_all_orders", + `Query all OTC (Over-The-Counter) trade orders with optional filters. Use this to retrieve your OTC trading history with various filtering options. @@ -212,49 +232,58 @@ Response includes: Each order contains: quoteId, orderId, orderStatus, fromCoin, fromAmount, toCoin, toAmount, ratio, inverseRatio, createTime`, - { - orderId: z.string().optional().describe("Filter by specific order ID"), - fromCoin: z.string().optional().describe("Filter by source coin (e.g., BTC, KSHIB)"), - toCoin: z.string().optional().describe("Filter by destination coin (e.g., USDT, SHIB)"), - startTime: z.number().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().optional().describe("End timestamp in milliseconds"), - page: z.number().int().positive().optional().describe("Page number (starts from 1)"), - limit: z.number().int().min(1).max(100).optional().describe("Records per page (default: 10, max: 100)") - }, - async (params) => { - try { - const response = await makeSignedRequest("GET", "/sapi/v1/otc/orders", { - ...(params.orderId && { orderId: params.orderId }), - ...(params.fromCoin && { fromCoin: params.fromCoin.toUpperCase() }), - ...(params.toCoin && { toCoin: params.toCoin.toUpperCase() }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.page && { page: params.page }), - ...(params.limit && { limit: params.limit }) - }); - - return { - content: [{ - type: "text", - text: `Retrieved ${response.total} OTC orders. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get OTC orders: ${errorMessage}` }], - isError: true - }; - } + { + orderId: z.string().optional().describe("Filter by specific order ID"), + fromCoin: z.string().optional().describe("Filter by source coin (e.g., BTC, KSHIB)"), + toCoin: z.string().optional().describe("Filter by destination coin (e.g., USDT, SHIB)"), + startTime: z.number().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().optional().describe("End timestamp in milliseconds"), + page: z.number().int().positive().optional().describe("Page number (starts from 1)"), + limit: z + .number() + .int() + .min(1) + .max(100) + .optional() + .describe("Records per page (default: 10, max: 100)"), + }, + async (params) => { + try { + const response = await makeSignedRequest("GET", "/sapi/v1/otc/orders", { + ...(params.orderId && { orderId: params.orderId }), + ...(params.fromCoin && { fromCoin: params.fromCoin.toUpperCase() }), + ...(params.toCoin && { toCoin: params.toCoin.toUpperCase() }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.page && { page: params.page }), + ...(params.limit && { limit: params.limit }), + }) + + return { + content: [ + { + type: "text", + text: `Retrieved ${response.total} OTC orders. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], } - ); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - // ===================================================================== - // GET /sapi/v1/ocbs/orders - Get All OCBS (Fiat) Orders - // ===================================================================== - server.tool( - "binance_us_ocbs_orders", - `Query all OCBS (One-Click-Buy-Sell) fiat orders on Binance.US. + return { + content: [{ type: "text", text: `Failed to get OTC orders: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================================== + // GET /sapi/v1/ocbs/orders - Get All OCBS (Fiat) Orders + // ===================================================================== + server.tool( + "binance_us_ocbs_orders", + `Query all OCBS (One-Click-Buy-Sell) fiat orders on Binance.US. OCBS allows direct fiat-to-crypto conversions. This endpoint retrieves your OCBS order history for fiat transactions (e.g., USD to BTC). @@ -270,36 +299,45 @@ Each order contains: - feeCoin/feeAmount: Fee details - ratio: Exchange rate - createTime: Order timestamp`, - { - orderId: z.string().optional().describe("Filter by specific order ID"), - startTime: z.number().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().optional().describe("End timestamp in milliseconds"), - page: z.number().int().positive().optional().describe("Page number (starts from 1)"), - limit: z.number().int().min(1).max(100).optional().describe("Records per page (default: 10, max: 100)") - }, - async (params) => { - try { - const response = await makeSignedRequest("GET", "/sapi/v1/ocbs/orders", { - ...(params.orderId && { orderId: params.orderId }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.page && { page: params.page }), - ...(params.limit && { limit: params.limit }) - }); - - return { - content: [{ - type: "text", - text: `Retrieved ${response.total} OCBS orders. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get OCBS orders: ${errorMessage}` }], - isError: true - }; - } + { + orderId: z.string().optional().describe("Filter by specific order ID"), + startTime: z.number().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().optional().describe("End timestamp in milliseconds"), + page: z.number().int().positive().optional().describe("Page number (starts from 1)"), + limit: z + .number() + .int() + .min(1) + .max(100) + .optional() + .describe("Records per page (default: 10, max: 100)"), + }, + async (params) => { + try { + const response = await makeSignedRequest("GET", "/sapi/v1/ocbs/orders", { + ...(params.orderId && { orderId: params.orderId }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.page && { page: params.page }), + ...(params.limit && { limit: params.limit }), + }) + + return { + content: [ + { + type: "text", + text: `Retrieved ${response.total} OCBS orders. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get OCBS orders: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/staking/index.ts b/src/tools/staking/index.ts index 1e7ebad1..16eab1d2 100644 --- a/src/tools/staking/index.ts +++ b/src/tools/staking/index.ts @@ -2,23 +2,25 @@ // Binance.US Staking Tools // Earn rewards by staking supported cryptocurrencies -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { makeSignedRequest } from "../../config/binanceUsClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { makeSignedRequest } from "../../config/binanceUsClient.js" /** * Register all Binance.US Staking tools - * + * * Staking allows users to earn rewards by locking up their cryptocurrency * to support network operations. Binance.US offers staking for various assets. */ export function registerStakingTools(server: McpServer) { - // ===================================================================== - // GET /sapi/v1/staking/asset - Get Staking Asset Information - // ===================================================================== - server.tool( - "binance_us_staking_asset_info", - `Get staking information for supported assets on Binance.US. + // ===================================================================== + // GET /sapi/v1/staking/asset - Get Staking Asset Information + // ===================================================================== + server.tool( + "binance_us_staking_asset_info", + `Get staking information for supported assets on Binance.US. Returns details about staking options including APR, APY, and staking limits. @@ -33,37 +35,43 @@ Response includes for each asset: - autoRestake: Whether rewards are automatically restaked If no asset is specified, returns information for all staking assets.`, - { - stakingAsset: z.string().optional().describe("Asset symbol (e.g., BNB, ETH). If empty, returns all staking assets") - }, - async (params) => { - try { - const response = await makeSignedRequest("GET", "/sapi/v1/staking/asset", { - ...(params.stakingAsset && { stakingAsset: params.stakingAsset.toUpperCase() }) - }); - - return { - content: [{ - type: "text", - text: `Successfully retrieved staking asset information. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get staking asset info: ${errorMessage}` }], - isError: true - }; - } + { + stakingAsset: z + .string() + .optional() + .describe("Asset symbol (e.g., BNB, ETH). If empty, returns all staking assets"), + }, + async (params) => { + try { + const response = await makeSignedRequest("GET", "/sapi/v1/staking/asset", { + ...(params.stakingAsset && { stakingAsset: params.stakingAsset.toUpperCase() }), + }) + + return { + content: [ + { + type: "text", + text: `Successfully retrieved staking asset information. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get staking asset info: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) - // ===================================================================== - // POST /sapi/v1/staking/stake - Stake Asset - // ===================================================================== - server.tool( - "binance_us_staking_stake", - `Stake a supported asset on Binance.US to earn staking rewards. + // ===================================================================== + // POST /sapi/v1/staking/stake - Stake Asset + // ===================================================================== + server.tool( + "binance_us_staking_stake", + `Stake a supported asset on Binance.US to earn staking rewards. ⚠️ IMPORTANT: - Staking locks your assets for a period of time @@ -79,41 +87,48 @@ Parameters: Response includes: - result: SUCCESS or failure status - purchaseRecordId: Record ID for the staking transaction`, - { - stakingAsset: z.string().describe("Asset symbol to stake (e.g., BNB, ETH)"), - amount: z.number().positive().describe("Amount to stake"), - autoRestake: z.boolean().optional().default(true).describe("Automatically restake rewards (default: true)") - }, - async (params) => { - try { - const response = await makeSignedRequest("POST", "/sapi/v1/staking/stake", { - stakingAsset: params.stakingAsset.toUpperCase(), - amount: params.amount, - autoRestake: params.autoRestake - }); - - return { - content: [{ - type: "text", - text: `Staking request submitted. Result: ${response.data?.result || response.result}. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to stake asset: ${errorMessage}` }], - isError: true - }; - } + { + stakingAsset: z.string().describe("Asset symbol to stake (e.g., BNB, ETH)"), + amount: z.number().positive().describe("Amount to stake"), + autoRestake: z + .boolean() + .optional() + .default(true) + .describe("Automatically restake rewards (default: true)"), + }, + async (params) => { + try { + const response = await makeSignedRequest("POST", "/sapi/v1/staking/stake", { + stakingAsset: params.stakingAsset.toUpperCase(), + amount: params.amount, + autoRestake: params.autoRestake, + }) + + return { + content: [ + { + type: "text", + text: `Staking request submitted. Result: ${response.data?.result || response.result}. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], } - ); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - // ===================================================================== - // POST /sapi/v1/staking/unstake - Unstake Asset - // ===================================================================== - server.tool( - "binance_us_staking_unstake", - `Unstake a previously staked asset on Binance.US. + return { + content: [{ type: "text", text: `Failed to stake asset: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================================== + // POST /sapi/v1/staking/unstake - Unstake Asset + // ===================================================================== + server.tool( + "binance_us_staking_unstake", + `Unstake a previously staked asset on Binance.US. ⚠️ IMPORTANT: - Unstaking may take time (check unstakingPeriod in asset info) @@ -126,39 +141,42 @@ Parameters: Response includes: - result: SUCCESS or failure status`, - { - stakingAsset: z.string().describe("Asset symbol to unstake (e.g., BNB, ETH)"), - amount: z.number().positive().describe("Amount to unstake") - }, - async (params) => { - try { - const response = await makeSignedRequest("POST", "/sapi/v1/staking/unstake", { - stakingAsset: params.stakingAsset.toUpperCase(), - amount: params.amount - }); - - return { - content: [{ - type: "text", - text: `Unstaking request submitted. Result: ${response.data?.result || response.result}. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to unstake asset: ${errorMessage}` }], - isError: true - }; - } + { + stakingAsset: z.string().describe("Asset symbol to unstake (e.g., BNB, ETH)"), + amount: z.number().positive().describe("Amount to unstake"), + }, + async (params) => { + try { + const response = await makeSignedRequest("POST", "/sapi/v1/staking/unstake", { + stakingAsset: params.stakingAsset.toUpperCase(), + amount: params.amount, + }) + + return { + content: [ + { + type: "text", + text: `Unstaking request submitted. Result: ${response.data?.result || response.result}. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], } - ); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - // ===================================================================== - // GET /sapi/v1/staking/stakingBalance - Get Staking Balance - // ===================================================================== - server.tool( - "binance_us_staking_balance", - `Get current staking balance for assets on Binance.US. + return { + content: [{ type: "text", text: `Failed to unstake asset: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================================== + // GET /sapi/v1/staking/stakingBalance - Get Staking Balance + // ===================================================================== + server.tool( + "binance_us_staking_balance", + `Get current staking balance for assets on Binance.US. Returns your current staking positions and their details. @@ -171,37 +189,43 @@ Response includes for each staked asset: - autoRestake: Whether auto-restaking is enabled If no asset is specified, returns balances for all staked assets.`, - { - asset: z.string().optional().describe("Staked asset symbol. If empty, returns all assets with balances") - }, - async (params) => { - try { - const response = await makeSignedRequest("GET", "/sapi/v1/staking/stakingBalance", { - ...(params.asset && { asset: params.asset.toUpperCase() }) - }); - - return { - content: [{ - type: "text", - text: `Successfully retrieved staking balance. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get staking balance: ${errorMessage}` }], - isError: true - }; - } + { + asset: z + .string() + .optional() + .describe("Staked asset symbol. If empty, returns all assets with balances"), + }, + async (params) => { + try { + const response = await makeSignedRequest("GET", "/sapi/v1/staking/stakingBalance", { + ...(params.asset && { asset: params.asset.toUpperCase() }), + }) + + return { + content: [ + { + type: "text", + text: `Successfully retrieved staking balance. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get staking balance: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) - // ===================================================================== - // GET /sapi/v1/staking/history - Get Staking History - // ===================================================================== - server.tool( - "binance_us_staking_history", - `Get staking transaction history for assets on Binance.US. + // ===================================================================== + // GET /sapi/v1/staking/history - Get Staking History + // ===================================================================== + server.tool( + "binance_us_staking_history", + `Get staking transaction history for assets on Binance.US. Returns a history of staking and unstaking transactions. @@ -213,45 +237,58 @@ Response includes for each transaction: - status: Transaction status (SUCCESS, PENDING, etc.) If no asset is specified, returns history for all assets.`, - { - asset: z.string().optional().describe("Asset symbol. If empty, returns all assets with history"), - startTime: z.number().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().optional().describe("End timestamp in milliseconds"), - page: z.number().int().positive().optional().default(1).describe("Page number (default: 1)"), - limit: z.number().int().min(1).max(500).optional().default(500).describe("Records per page (default: 500, max: 500)") - }, - async (params) => { - try { - const response = await makeSignedRequest("GET", "/sapi/v1/staking/history", { - ...(params.asset && { asset: params.asset.toUpperCase() }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.page && { page: params.page }), - ...(params.limit && { limit: params.limit }) - }); - - return { - content: [{ - type: "text", - text: `Successfully retrieved staking history. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get staking history: ${errorMessage}` }], - isError: true - }; - } + { + asset: z + .string() + .optional() + .describe("Asset symbol. If empty, returns all assets with history"), + startTime: z.number().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().optional().describe("End timestamp in milliseconds"), + page: z.number().int().positive().optional().default(1).describe("Page number (default: 1)"), + limit: z + .number() + .int() + .min(1) + .max(500) + .optional() + .default(500) + .describe("Records per page (default: 500, max: 500)"), + }, + async (params) => { + try { + const response = await makeSignedRequest("GET", "/sapi/v1/staking/history", { + ...(params.asset && { asset: params.asset.toUpperCase() }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.page && { page: params.page }), + ...(params.limit && { limit: params.limit }), + }) + + return { + content: [ + { + type: "text", + text: `Successfully retrieved staking history. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], } - ); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - // ===================================================================== - // GET /sapi/v1/staking/stakingRewardsHistory - Get Staking Rewards History - // ===================================================================== - server.tool( - "binance_us_staking_rewards", - `Get staking rewards history for assets on Binance.US. + return { + content: [{ type: "text", text: `Failed to get staking history: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================================== + // GET /sapi/v1/staking/stakingRewardsHistory - Get Staking Rewards History + // ===================================================================== + server.tool( + "binance_us_staking_rewards", + `Get staking rewards history for assets on Binance.US. Returns a history of staking rewards earned over time. @@ -268,36 +305,51 @@ Each reward record contains: - autoRestaked: Whether the reward was automatically restaked If no asset is specified, returns rewards for all staked assets.`, - { - asset: z.string().optional().describe("Staked asset. If empty, returns all assets with rewards"), - startTime: z.number().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().optional().describe("End timestamp in milliseconds"), - page: z.number().int().positive().optional().describe("Page/batch number"), - limit: z.number().int().min(1).max(500).optional().default(500).describe("Records per batch (default: 500)") - }, - async (params) => { - try { - const response = await makeSignedRequest("GET", "/sapi/v1/staking/stakingRewardsHistory", { - ...(params.asset && { asset: params.asset.toUpperCase() }), - ...(params.startTime && { startTime: params.startTime }), - ...(params.endTime && { endTime: params.endTime }), - ...(params.page && { page: params.page }), - ...(params.limit && { limit: params.limit }) - }); - - return { - content: [{ - type: "text", - text: `Successfully retrieved staking rewards history. Total: ${response.total || 'N/A'}. Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get staking rewards history: ${errorMessage}` }], - isError: true - }; - } + { + asset: z + .string() + .optional() + .describe("Staked asset. If empty, returns all assets with rewards"), + startTime: z.number().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().optional().describe("End timestamp in milliseconds"), + page: z.number().int().positive().optional().describe("Page/batch number"), + limit: z + .number() + .int() + .min(1) + .max(500) + .optional() + .default(500) + .describe("Records per batch (default: 500)"), + }, + async (params) => { + try { + const response = await makeSignedRequest("GET", "/sapi/v1/staking/stakingRewardsHistory", { + ...(params.asset && { asset: params.asset.toUpperCase() }), + ...(params.startTime && { startTime: params.startTime }), + ...(params.endTime && { endTime: params.endTime }), + ...(params.page && { page: params.page }), + ...(params.limit && { limit: params.limit }), + }) + + return { + content: [ + { + type: "text", + text: `Successfully retrieved staking rewards history. Total: ${response.total || "N/A"}. Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [ + { type: "text", text: `Failed to get staking rewards history: ${errorMessage}` }, + ], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/subaccount/index.ts b/src/tools/subaccount/index.ts index 4c29ea44..ef38ff14 100644 --- a/src/tools/subaccount/index.ts +++ b/src/tools/subaccount/index.ts @@ -1,11 +1,13 @@ // src/tools/subaccount/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { makeSignedRequest } from "../../config/binanceUsClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { makeSignedRequest } from "../../config/binanceUsClient.js" /** * Register all Sub-account related tools for Binance.US - * + * * Sub-account endpoints provide access to: * - List sub-accounts * - Transfer history between accounts @@ -15,243 +17,262 @@ import { makeSignedRequest } from "../../config/binanceUsClient.js"; * - Sub-account status */ export function registerSubaccountTools(server: McpServer) { - // ===================================================== - // binance_us_subaccount_list - // GET /sapi/v3/sub-account/list - // ===================================================== - server.tool( - "binance_us_subaccount_list", - "Get a list of all sub-accounts. Filter by email or status (enabled/disabled).", - { - email: z.string().optional().describe("Filter by sub-account email"), - status: z.string().optional().describe("Filter by status: 'enabled' or 'disabled'"), - page: z.number().optional().describe("Page number. Default: 1"), - limit: z.number().optional().describe("Results per page. Default: 500"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), - }, - async ({ email, status, page, limit, recvWindow }) => { - try { - const params: Record = {}; - if (email !== undefined) params.email = email; - if (status !== undefined) params.status = status; - if (page !== undefined) params.page = page; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await makeSignedRequest("GET", "/sapi/v3/sub-account/list", params); - - return { - content: [{ - type: "text", - text: `Sub-accounts:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get sub-account list: ${errorMessage}` }], - isError: true - }; - } + // ===================================================== + // binance_us_subaccount_list + // GET /sapi/v3/sub-account/list + // ===================================================== + server.tool( + "binance_us_subaccount_list", + "Get a list of all sub-accounts. Filter by email or status (enabled/disabled).", + { + email: z.string().optional().describe("Filter by sub-account email"), + status: z.string().optional().describe("Filter by status: 'enabled' or 'disabled'"), + page: z.number().optional().describe("Page number. Default: 1"), + limit: z.number().optional().describe("Results per page. Default: 500"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ email, status, page, limit, recvWindow }) => { + try { + const params: Record = {} + if (email !== undefined) params.email = email + if (status !== undefined) params.status = status + if (page !== undefined) params.page = page + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await makeSignedRequest("GET", "/sapi/v3/sub-account/list", params) + + return { + content: [ + { + type: "text", + text: `Sub-accounts:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get sub-account list: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================== + // binance_us_subaccount_transfer_history + // GET /sapi/v3/sub-account/transfer/history + // ===================================================== + server.tool( + "binance_us_subaccount_transfer_history", + "Get transfer history between master and sub-accounts.", + { + email: z.string().optional().describe("Sub-account email to filter by"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + page: z.number().optional().describe("Page number. Each page contains up to 500 records"), + limit: z.number().optional().describe("Results per page. Default: 500"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ email, startTime, endTime, page, limit, recvWindow }) => { + try { + const params: Record = {} + if (email !== undefined) params.email = email + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (page !== undefined) params.page = page + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await makeSignedRequest("GET", "/sapi/v3/sub-account/transfer/history", params) + + return { + content: [ + { + type: "text", + text: `Sub-account Transfer History:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get transfer history: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================== + // binance_us_subaccount_transfer + // POST /sapi/v3/sub-account/transfer + // ===================================================== + server.tool( + "binance_us_subaccount_transfer", + "Execute an asset transfer between master account and a sub-account. ⚠️ This moves funds between accounts!", + { + fromEmail: z.string().email().describe("Sender email address"), + toEmail: z.string().email().describe("Recipient email address"), + asset: z.string().describe("Asset symbol to transfer, e.g., BTC, ETH"), + amount: z.number().describe("Amount to transfer"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ fromEmail, toEmail, asset, amount, recvWindow }) => { + try { + const params: Record = { + fromEmail, + toEmail, + asset, + amount, } - ); + if (recvWindow !== undefined) params.recvWindow = recvWindow - // ===================================================== - // binance_us_subaccount_transfer_history - // GET /sapi/v3/sub-account/transfer/history - // ===================================================== - server.tool( - "binance_us_subaccount_transfer_history", - "Get transfer history between master and sub-accounts.", - { - email: z.string().optional().describe("Sub-account email to filter by"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - page: z.number().optional().describe("Page number. Each page contains up to 500 records"), - limit: z.number().optional().describe("Results per page. Default: 500"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), - }, - async ({ email, startTime, endTime, page, limit, recvWindow }) => { - try { - const params: Record = {}; - if (email !== undefined) params.email = email; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (page !== undefined) params.page = page; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await makeSignedRequest("GET", "/sapi/v3/sub-account/transfer/history", params); - - return { - content: [{ - type: "text", - text: `Sub-account Transfer History:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get transfer history: ${errorMessage}` }], - isError: true - }; - } + const data = await makeSignedRequest("POST", "/sapi/v3/sub-account/transfer", params) + + return { + content: [ + { + type: "text", + text: `Transfer completed successfully!\nTransaction ID: ${data.txnId}\nFrom: ${fromEmail}\nTo: ${toEmail}\nAsset: ${asset}\nAmount: ${amount}\n\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to execute transfer: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================== + // binance_us_subaccount_assets + // GET /sapi/v3/sub-account/assets + // ===================================================== + server.tool( + "binance_us_subaccount_assets", + "Get asset balances for a specific sub-account.", + { + email: z.string().email().describe("Sub-account email address"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ email, recvWindow }) => { + try { + const params: Record = { email } + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await makeSignedRequest("GET", "/sapi/v3/sub-account/assets", params) + + // Filter to show only non-zero balances + const nonZeroBalances = + data.balances?.filter( + (b: { free: string | number; locked: string | number }) => + parseFloat(String(b.free)) > 0 || parseFloat(String(b.locked)) > 0, + ) || [] + + return { + content: [ + { + type: "text", + text: `Sub-account Assets for ${email}:\n\nNon-zero balances:\n${JSON.stringify(nonZeroBalances, null, 2)}\n\nFull response:\n${JSON.stringify(data, null, 2)}`, + }, + ], } - ); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - // ===================================================== - // binance_us_subaccount_transfer - // POST /sapi/v3/sub-account/transfer - // ===================================================== - server.tool( - "binance_us_subaccount_transfer", - "Execute an asset transfer between master account and a sub-account. ⚠️ This moves funds between accounts!", - { - fromEmail: z.string().email().describe("Sender email address"), - toEmail: z.string().email().describe("Recipient email address"), - asset: z.string().describe("Asset symbol to transfer, e.g., BTC, ETH"), - amount: z.number().describe("Amount to transfer"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), - }, - async ({ fromEmail, toEmail, asset, amount, recvWindow }) => { - try { - const params: Record = { - fromEmail, - toEmail, - asset, - amount - }; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await makeSignedRequest("POST", "/sapi/v3/sub-account/transfer", params); - - return { - content: [{ - type: "text", - text: `Transfer completed successfully!\nTransaction ID: ${data.txnId}\nFrom: ${fromEmail}\nTo: ${toEmail}\nAsset: ${asset}\nAmount: ${amount}\n\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to execute transfer: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to get sub-account assets: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) + + // ===================================================== + // binance_us_subaccount_summary + // GET /sapi/v1/sub-account/spotSummary + // ===================================================== + server.tool( + "binance_us_subaccount_summary", + "Get the total USD value of assets in the master account and all sub-accounts.", + { + email: z.string().optional().describe("Filter by specific sub-account email"), + page: z.number().optional().describe("Page number"), + size: z.number().optional().describe("Results per page"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ email, page, size, recvWindow }) => { + try { + const params: Record = {} + if (email !== undefined) params.email = email + if (page !== undefined) params.page = page + if (size !== undefined) params.size = size + if (recvWindow !== undefined) params.recvWindow = recvWindow - // ===================================================== - // binance_us_subaccount_assets - // GET /sapi/v3/sub-account/assets - // ===================================================== - server.tool( - "binance_us_subaccount_assets", - "Get asset balances for a specific sub-account.", - { - email: z.string().email().describe("Sub-account email address"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), - }, - async ({ email, recvWindow }) => { - try { - const params: Record = { email }; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await makeSignedRequest("GET", "/sapi/v3/sub-account/assets", params); - - // Filter to show only non-zero balances - const nonZeroBalances = data.balances?.filter( - (b: { free: string | number; locked: string | number }) => - parseFloat(String(b.free)) > 0 || parseFloat(String(b.locked)) > 0 - ) || []; - - return { - content: [{ - type: "text", - text: `Sub-account Assets for ${email}:\n\nNon-zero balances:\n${JSON.stringify(nonZeroBalances, null, 2)}\n\nFull response:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get sub-account assets: ${errorMessage}` }], - isError: true - }; - } + const data = await makeSignedRequest("GET", "/sapi/v1/sub-account/spotSummary", params) + + return { + content: [ + { + type: "text", + text: `Sub-account Summary:\nTotal Accounts: ${data.totalCount}\nMaster Account Total Asset (USD): ${data.masterAccountTotalAsset}\n\nSub-account Details:\n${JSON.stringify(data.spotSubUserAssetBtcVoList, null, 2)}`, + }, + ], } - ); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get sub-account summary: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================== + // binance_us_subaccount_status + // GET /sapi/v1/sub-account/status + // ===================================================== + server.tool( + "binance_us_subaccount_status", + "Get status list of sub-accounts including activation status and enabled features.", + { + email: z.string().optional().describe("Sub-account email to check status for"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ email, recvWindow }) => { + try { + const params: Record = {} + if (email !== undefined) params.email = email + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await makeSignedRequest("GET", "/sapi/v1/sub-account/status", params) - // ===================================================== - // binance_us_subaccount_summary - // GET /sapi/v1/sub-account/spotSummary - // ===================================================== - server.tool( - "binance_us_subaccount_summary", - "Get the total USD value of assets in the master account and all sub-accounts.", - { - email: z.string().optional().describe("Filter by specific sub-account email"), - page: z.number().optional().describe("Page number"), - size: z.number().optional().describe("Results per page"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), - }, - async ({ email, page, size, recvWindow }) => { - try { - const params: Record = {}; - if (email !== undefined) params.email = email; - if (page !== undefined) params.page = page; - if (size !== undefined) params.size = size; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await makeSignedRequest("GET", "/sapi/v1/sub-account/spotSummary", params); - - return { - content: [{ - type: "text", - text: `Sub-account Summary:\nTotal Accounts: ${data.totalCount}\nMaster Account Total Asset (USD): ${data.masterAccountTotalAsset}\n\nSub-account Details:\n${JSON.stringify(data.spotSubUserAssetBtcVoList, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get sub-account summary: ${errorMessage}` }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Sub-account Status:\n${JSON.stringify(data, null, 2)}`, + }, + ], } - ); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - // ===================================================== - // binance_us_subaccount_status - // GET /sapi/v1/sub-account/status - // ===================================================== - server.tool( - "binance_us_subaccount_status", - "Get status list of sub-accounts including activation status and enabled features.", - { - email: z.string().optional().describe("Sub-account email to check status for"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), - }, - async ({ email, recvWindow }) => { - try { - const params: Record = {}; - if (email !== undefined) params.email = email; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await makeSignedRequest("GET", "/sapi/v1/sub-account/status", params); - - return { - content: [{ - type: "text", - text: `Sub-account Status:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get sub-account status: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to get sub-account status: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/tools/trade/index.ts b/src/tools/trade/index.ts index 12452206..8e4f8268 100644 --- a/src/tools/trade/index.ts +++ b/src/tools/trade/index.ts @@ -1,11 +1,12 @@ // src/tools/trade/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceUsOrderTools } from "./orders.js"; -import { registerBinanceUsOcoTools } from "./oco.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { registerBinanceUsOcoTools } from "./oco.js" +import { registerBinanceUsOrderTools } from "./orders.js" /** * Register all Binance.US trading tools - * + * * Standard Order Tools (8 tools): * - binance_us_new_order: Place new order * - binance_us_test_order: Test order (no execution) @@ -15,7 +16,7 @@ import { registerBinanceUsOcoTools } from "./oco.js"; * - binance_us_cancel_all_open_orders: Cancel all open orders for a symbol * - binance_us_open_orders: Get all open orders * - binance_us_all_orders: Get all orders (history) - * + * * OCO Order Tools (5 tools): * - binance_us_new_oco: Place OCO order * - binance_us_get_oco: Query OCO order @@ -24,30 +25,30 @@ import { registerBinanceUsOcoTools } from "./oco.js"; * - binance_us_all_oco_orders: Get OCO order history */ export function registerBinanceUsTradeTools(server: McpServer) { - registerBinanceUsOrderTools(server); - registerBinanceUsOcoTools(server); + registerBinanceUsOrderTools(server) + registerBinanceUsOcoTools(server) } // Re-export individual registration functions for granular control -export { registerBinanceUsOrderTools } from "./orders.js"; -export { registerBinanceUsOcoTools } from "./oco.js"; +export { registerBinanceUsOrderTools } from "./orders.js" +export { registerBinanceUsOcoTools } from "./oco.js" // Re-export individual tool registration functions export { - registerBinanceUsNewOrder, - registerBinanceUsTestOrder, - registerBinanceUsGetOrder, - registerBinanceUsCancelOrder, - registerBinanceUsCancelReplace, - registerBinanceUsCancelAllOpenOrders, - registerBinanceUsOpenOrders, - registerBinanceUsAllOrders -} from "./orders.js"; + registerBinanceUsNewOrder, + registerBinanceUsTestOrder, + registerBinanceUsGetOrder, + registerBinanceUsCancelOrder, + registerBinanceUsCancelReplace, + registerBinanceUsCancelAllOpenOrders, + registerBinanceUsOpenOrders, + registerBinanceUsAllOrders, +} from "./orders.js" export { - registerBinanceUsNewOco, - registerBinanceUsGetOco, - registerBinanceUsCancelOco, - registerBinanceUsOpenOco, - registerBinanceUsAllOcoOrders -} from "./oco.js"; + registerBinanceUsNewOco, + registerBinanceUsGetOco, + registerBinanceUsCancelOco, + registerBinanceUsOpenOco, + registerBinanceUsAllOcoOrders, +} from "./oco.js" diff --git a/src/tools/trade/oco.ts b/src/tools/trade/oco.ts index 4d8df98f..a8bc10de 100644 --- a/src/tools/trade/oco.ts +++ b/src/tools/trade/oco.ts @@ -1,481 +1,622 @@ // src/tools/trade/oco.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { makeSignedRequest, hasApiCredentials, BINANCE_US_CONFIG } from "../../config/binanceUsClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { + BINANCE_US_CONFIG, + hasApiCredentials, + makeSignedRequest, +} from "../../config/binanceUsClient.js" // Common Binance error codes for better error messages const BINANCE_ERROR_CODES: Record = { - [-1000]: "Unknown error occurred", - [-1002]: "Unauthorized - check API key permissions", - [-1003]: "Too many requests - rate limit exceeded", - [-1013]: "Invalid quantity - check LOT_SIZE filter", - [-1021]: "Invalid timestamp - check recvWindow", - [-1022]: "Invalid signature", - [-1102]: "Mandatory parameter missing", - [-1111]: "Precision over maximum for asset", - [-1121]: "Invalid symbol", - [-2010]: "New order rejected", - [-2011]: "Cancel rejected - check order status", - [-2013]: "Order does not exist", - [-2015]: "Rejected - invalid API key, IP, or permissions", - [-2018]: "Balance is insufficient", - [-2021]: "Order would immediately trigger stop price" -}; + [-1000]: "Unknown error occurred", + [-1002]: "Unauthorized - check API key permissions", + [-1003]: "Too many requests - rate limit exceeded", + [-1013]: "Invalid quantity - check LOT_SIZE filter", + [-1021]: "Invalid timestamp - check recvWindow", + [-1022]: "Invalid signature", + [-1102]: "Mandatory parameter missing", + [-1111]: "Precision over maximum for asset", + [-1121]: "Invalid symbol", + [-2010]: "New order rejected", + [-2011]: "Cancel rejected - check order status", + [-2013]: "Order does not exist", + [-2015]: "Rejected - invalid API key, IP, or permissions", + [-2018]: "Balance is insufficient", + [-2021]: "Order would immediately trigger stop price", +} /** * Get human-readable error message for Binance error code */ function getBinanceErrorMessage(code: number): string { - return BINANCE_ERROR_CODES[code] || `Unknown error code: ${code}`; + return BINANCE_ERROR_CODES[code] || `Unknown error code: ${code}` } /** * Check API credentials before making requests */ function checkCredentials(): string | null { - if (!hasApiCredentials()) { - return "❌ API credentials not configured. Please set BINANCE_US_API_KEY and BINANCE_US_API_SECRET environment variables."; - } - return null; + if (!hasApiCredentials()) { + return "❌ API credentials not configured. Please set BINANCE_US_API_KEY and BINANCE_US_API_SECRET environment variables." + } + + return null } /** * Validate recvWindow parameter */ function validateRecvWindow(recvWindow?: number): string | null { - if (recvWindow !== undefined && recvWindow > BINANCE_US_CONFIG.MAX_RECV_WINDOW) { - return `❌ recvWindow cannot exceed ${BINANCE_US_CONFIG.MAX_RECV_WINDOW}ms (60 seconds).`; - } - return null; + if (recvWindow !== undefined && recvWindow > BINANCE_US_CONFIG.MAX_RECV_WINDOW) { + return `❌ recvWindow cannot exceed ${BINANCE_US_CONFIG.MAX_RECV_WINDOW}ms (60 seconds).` + } + + return null } /** * Validate symbol format (basic check) */ function validateSymbol(symbol: string): string | null { - if (!symbol || symbol.length < 2 || symbol.length > 20) { - return "❌ Invalid symbol format. Symbol should be 2-20 characters (e.g., BTCUSD, ETHUSD)."; - } - if (!/^[A-Z0-9]+$/.test(symbol.toUpperCase())) { - return "❌ Invalid symbol format. Symbol should contain only letters and numbers."; - } - return null; + if (!symbol || symbol.length < 2 || symbol.length > 20) { + return "❌ Invalid symbol format. Symbol should be 2-20 characters (e.g., BTCUSD, ETHUSD)." + } + if (!/^[A-Z0-9]+$/.test(symbol.toUpperCase())) { + return "❌ Invalid symbol format. Symbol should contain only letters and numbers." + } + + return null } // Order side enum -const OrderSide = z.enum(["BUY", "SELL"]); +const OrderSide = z.enum(["BUY", "SELL"]) // Time in force enum -const TimeInForce = z.enum(["GTC", "IOC", "FOK"]); +const TimeInForce = z.enum(["GTC", "IOC", "FOK"]) // Response type enum -const OrderRespType = z.enum(["ACK", "RESULT", "FULL"]); +const OrderRespType = z.enum(["ACK", "RESULT", "FULL"]) // Self trade prevention mode enum -const SelfTradePreventionMode = z.enum(["EXPIRE_TAKER", "EXPIRE_MAKER", "EXPIRE_BOTH", "NONE"]); +const SelfTradePreventionMode = z.enum(["EXPIRE_TAKER", "EXPIRE_MAKER", "EXPIRE_BOTH", "NONE"]) /** * Register new OCO order tool */ export function registerBinanceUsNewOco(server: McpServer) { - server.tool( - "binance_us_new_oco", - "Place a new OCO (One-Cancels-the-Other) order on Binance.US. OCO orders combine a limit order with a stop-loss order. When one triggers, the other is automatically cancelled. Note: For SELL OCOs, limit price > stop price. For BUY OCOs, limit price < stop price.", - { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD, ETHUSD)"), - side: OrderSide.describe("Order side: BUY or SELL"), - quantity: z.number().describe("Order quantity for both legs of the OCO"), - price: z.number().describe("Limit order price"), - stopPrice: z.number().describe("Stop price that triggers the stop-loss order"), - stopLimitPrice: z.number().optional().describe("Limit price for the stop-loss leg. If provided, stopLimitTimeInForce is required."), - stopLimitTimeInForce: TimeInForce.optional().describe("Time in force for stop-limit order: GTC, IOC, or FOK. Required if stopLimitPrice is provided."), - listClientOrderId: z.string().optional().describe("Unique ID for the entire OCO order list"), - limitClientOrderId: z.string().optional().describe("Unique ID for the limit order leg"), - stopClientOrderId: z.string().optional().describe("Unique ID for the stop-loss leg"), - limitIcebergQty: z.number().optional().describe("Iceberg quantity for the limit leg"), - stopIcebergQty: z.number().optional().describe("Iceberg quantity for the stop-loss leg"), - trailingDelta: z.number().optional().describe("Trailing delta in BIPS for the stop leg"), - newOrderRespType: OrderRespType.optional().describe("Response type: ACK, RESULT, or FULL"), - selfTradePreventionMode: SelfTradePreventionMode.optional().describe("Self-trade prevention mode"), - recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)") - }, - async (params) => { - try { - // Check API credentials first - const credError = checkCredentials(); - if (credError) return { content: [{ type: "text", text: credError }], isError: true }; - - // Validate symbol and recvWindow - const symbolError = validateSymbol(params.symbol); - if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true }; - const recvWindowError = validateRecvWindow(params.recvWindow); - if (recvWindowError) return { content: [{ type: "text", text: recvWindowError }], isError: true }; - - // Validate OCO parameters - const validationError = validateOcoParams(params); - if (validationError) { - return { - content: [{ type: "text", text: validationError }], - isError: true - }; - } - - const response = await makeSignedRequest("POST", "/api/v3/order/oco", params); - - const orders = response.orders || []; - const orderReports = response.orderReports || []; - - return { - content: [{ - type: "text", - text: `✅ OCO Order placed successfully!\n\n` + - `Order List ID: ${response.orderListId}\n` + - `Symbol: ${response.symbol}\n` + - `Status: ${response.listStatusType}\n` + - `Contingency Type: ${response.contingencyType}\n` + - `\n--- Orders ---\n` + - orders.map((order: any) => - `• Order ID: ${order.orderId} | Client ID: ${order.clientOrderId}` - ).join('\n') + - `\n\n--- Order Details ---\n` + - orderReports.map((report: any) => - `• ${report.type} | Side: ${report.side} | ` + - `Qty: ${report.origQty} @ ${report.price} | ` + - `Status: ${report.status}` + - (report.stopPrice ? ` | Stop: ${report.stopPrice}` : '') - ).join('\n') + - `\n\nFull Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - const codeMatch = errorMessage.match(/code:\s*(-?\d+)/); - const additionalHelp = codeMatch && codeMatch[1] ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` : ''; - return { - content: [{ type: "text", text: `❌ Failed to place OCO order: ${errorMessage}${additionalHelp}` }], - isError: true - }; - } + server.tool( + "binance_us_new_oco", + "Place a new OCO (One-Cancels-the-Other) order on Binance.US. OCO orders combine a limit order with a stop-loss order. When one triggers, the other is automatically cancelled. Note: For SELL OCOs, limit price > stop price. For BUY OCOs, limit price < stop price.", + { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD, ETHUSD)"), + side: OrderSide.describe("Order side: BUY or SELL"), + quantity: z.number().describe("Order quantity for both legs of the OCO"), + price: z.number().describe("Limit order price"), + stopPrice: z.number().describe("Stop price that triggers the stop-loss order"), + stopLimitPrice: z + .number() + .optional() + .describe( + "Limit price for the stop-loss leg. If provided, stopLimitTimeInForce is required.", + ), + stopLimitTimeInForce: TimeInForce.optional().describe( + "Time in force for stop-limit order: GTC, IOC, or FOK. Required if stopLimitPrice is provided.", + ), + listClientOrderId: z.string().optional().describe("Unique ID for the entire OCO order list"), + limitClientOrderId: z.string().optional().describe("Unique ID for the limit order leg"), + stopClientOrderId: z.string().optional().describe("Unique ID for the stop-loss leg"), + limitIcebergQty: z.number().optional().describe("Iceberg quantity for the limit leg"), + stopIcebergQty: z.number().optional().describe("Iceberg quantity for the stop-loss leg"), + trailingDelta: z.number().optional().describe("Trailing delta in BIPS for the stop leg"), + newOrderRespType: OrderRespType.optional().describe("Response type: ACK, RESULT, or FULL"), + selfTradePreventionMode: SelfTradePreventionMode.optional().describe( + "Self-trade prevention mode", + ), + recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + }, + async (params) => { + try { + // Check API credentials first + const credError = checkCredentials() + if (credError) return { content: [{ type: "text", text: credError }], isError: true } + + // Validate symbol and recvWindow + const symbolError = validateSymbol(params.symbol) + if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true } + const recvWindowError = validateRecvWindow(params.recvWindow) + if (recvWindowError) + return { content: [{ type: "text", text: recvWindowError }], isError: true } + + // Validate OCO parameters + const validationError = validateOcoParams(params) + if (validationError) { + return { + content: [{ type: "text", text: validationError }], + isError: true, + } + } + + const response = await makeSignedRequest("POST", "/api/v3/order/oco", params) + + const orders = response.orders || [] + const orderReports = response.orderReports || [] + + return { + content: [ + { + type: "text", + text: + `✅ OCO Order placed successfully!\n\n` + + `Order List ID: ${response.orderListId}\n` + + `Symbol: ${response.symbol}\n` + + `Status: ${response.listStatusType}\n` + + `Contingency Type: ${response.contingencyType}\n` + + `\n--- Orders ---\n` + + orders + .map( + (order: any) => + `• Order ID: ${order.orderId} | Client ID: ${order.clientOrderId}`, + ) + .join("\n") + + `\n\n--- Order Details ---\n` + + orderReports + .map( + (report: any) => + `• ${report.type} | Side: ${report.side} | ` + + `Qty: ${report.origQty} @ ${report.price} | ` + + `Status: ${report.status}` + + (report.stopPrice ? ` | Stop: ${report.stopPrice}` : ""), + ) + .join("\n") + + `\n\nFull Response: ${JSON.stringify(response, null, 2)}`, + }, + ], } - ); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + const codeMatch = errorMessage.match(/code:\s*(-?\d+)/) + const additionalHelp = + codeMatch && codeMatch[1] + ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` + : "" + + return { + content: [ + { + type: "text", + text: `❌ Failed to place OCO order: ${errorMessage}${additionalHelp}`, + }, + ], + isError: true, + } + } + }, + ) } /** * Register get OCO order tool */ export function registerBinanceUsGetOco(server: McpServer) { - server.tool( - "binance_us_get_oco", - "Query a specific OCO order on Binance.US. Either orderListId or origClientOrderId must be provided.", - { - orderListId: z.number().optional().describe("The order list ID to query"), - origClientOrderId: z.string().optional().describe("The original client order ID to query"), - recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)") - }, - async (params) => { - try { - // Check API credentials first - const credError = checkCredentials(); - if (credError) return { content: [{ type: "text", text: credError }], isError: true }; - const recvWindowError = validateRecvWindow(params.recvWindow); - if (recvWindowError) return { content: [{ type: "text", text: recvWindowError }], isError: true }; - - if (!params.orderListId && !params.origClientOrderId) { - return { - content: [{ type: "text", text: "❌ Either orderListId or origClientOrderId must be provided." }], - isError: true - }; - } - - const response = await makeSignedRequest("GET", "/api/v3/orderList", params); - - const orders = response.orders || []; - - return { - content: [{ - type: "text", - text: `📋 OCO Order Details\n\n` + - `Order List ID: ${response.orderListId}\n` + - `Symbol: ${response.symbol}\n` + - `Contingency Type: ${response.contingencyType}\n` + - `List Status: ${response.listStatusType}\n` + - `List Order Status: ${response.listOrderStatus}\n` + - `Client Order ID: ${response.listClientOrderId}\n` + - `Transaction Time: ${new Date(response.transactionTime).toISOString()}\n` + - `\n--- Orders ---\n` + - orders.map((order: any) => - `• Symbol: ${order.symbol} | Order ID: ${order.orderId} | Client ID: ${order.clientOrderId}` - ).join('\n') + - `\n\nFull Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - const codeMatch = errorMessage.match(/code:\s*(-?\d+)/); - const additionalHelp = codeMatch && codeMatch[1] ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` : ''; - return { - content: [{ type: "text", text: `❌ Failed to get OCO order: ${errorMessage}${additionalHelp}` }], - isError: true - }; - } + server.tool( + "binance_us_get_oco", + "Query a specific OCO order on Binance.US. Either orderListId or origClientOrderId must be provided.", + { + orderListId: z.number().optional().describe("The order list ID to query"), + origClientOrderId: z.string().optional().describe("The original client order ID to query"), + recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + }, + async (params) => { + try { + // Check API credentials first + const credError = checkCredentials() + if (credError) return { content: [{ type: "text", text: credError }], isError: true } + const recvWindowError = validateRecvWindow(params.recvWindow) + if (recvWindowError) + return { content: [{ type: "text", text: recvWindowError }], isError: true } + + if (!params.orderListId && !params.origClientOrderId) { + return { + content: [ + { + type: "text", + text: "❌ Either orderListId or origClientOrderId must be provided.", + }, + ], + isError: true, + } + } + + const response = await makeSignedRequest("GET", "/api/v3/orderList", params) + + const orders = response.orders || [] + + return { + content: [ + { + type: "text", + text: + `📋 OCO Order Details\n\n` + + `Order List ID: ${response.orderListId}\n` + + `Symbol: ${response.symbol}\n` + + `Contingency Type: ${response.contingencyType}\n` + + `List Status: ${response.listStatusType}\n` + + `List Order Status: ${response.listOrderStatus}\n` + + `Client Order ID: ${response.listClientOrderId}\n` + + `Transaction Time: ${new Date(response.transactionTime).toISOString()}\n` + + `\n--- Orders ---\n` + + orders + .map( + (order: any) => + `• Symbol: ${order.symbol} | Order ID: ${order.orderId} | Client ID: ${order.clientOrderId}`, + ) + .join("\n") + + `\n\nFull Response: ${JSON.stringify(response, null, 2)}`, + }, + ], } - ); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + const codeMatch = errorMessage.match(/code:\s*(-?\d+)/) + const additionalHelp = + codeMatch && codeMatch[1] + ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` + : "" + + return { + content: [ + { type: "text", text: `❌ Failed to get OCO order: ${errorMessage}${additionalHelp}` }, + ], + isError: true, + } + } + }, + ) } /** * Register cancel OCO order tool */ export function registerBinanceUsCancelOco(server: McpServer) { - server.tool( - "binance_us_cancel_oco", - "Cancel an entire OCO order on Binance.US. Cancelling any individual leg will cancel the entire OCO.", - { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD)"), - orderListId: z.number().optional().describe("The order list ID to cancel"), - listClientOrderId: z.string().optional().describe("The list client order ID to cancel"), - newClientOrderId: z.string().optional().describe("New client order ID for this cancel request"), - recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)") - }, - async (params) => { - try { - // Check API credentials first - const credError = checkCredentials(); - if (credError) return { content: [{ type: "text", text: credError }], isError: true }; - const symbolError = validateSymbol(params.symbol); - if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true }; - const recvWindowError = validateRecvWindow(params.recvWindow); - if (recvWindowError) return { content: [{ type: "text", text: recvWindowError }], isError: true }; - - if (!params.orderListId && !params.listClientOrderId) { - return { - content: [{ type: "text", text: "❌ Either orderListId or listClientOrderId must be provided." }], - isError: true - }; - } - - const response = await makeSignedRequest("DELETE", "/api/v3/orderList", params); - - const orderReports = response.orderReports || []; - - return { - content: [{ - type: "text", - text: `✅ OCO Order cancelled successfully!\n\n` + - `Order List ID: ${response.orderListId}\n` + - `Symbol: ${response.symbol}\n` + - `Status: ${response.listStatusType}\n` + - `Order Status: ${response.listOrderStatus}\n` + - `\n--- Cancelled Orders ---\n` + - orderReports.map((report: any) => - `• Order ID: ${report.orderId} | ${report.type} | ` + - `Qty: ${report.origQty} @ ${report.price} | ` + - `Status: ${report.status}` - ).join('\n') + - `\n\nFull Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - const codeMatch = errorMessage.match(/code:\s*(-?\d+)/); - const additionalHelp = codeMatch && codeMatch[1] ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` : ''; - return { - content: [{ type: "text", text: `❌ Failed to cancel OCO order: ${errorMessage}${additionalHelp}` }], - isError: true - }; - } + server.tool( + "binance_us_cancel_oco", + "Cancel an entire OCO order on Binance.US. Cancelling any individual leg will cancel the entire OCO.", + { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD)"), + orderListId: z.number().optional().describe("The order list ID to cancel"), + listClientOrderId: z.string().optional().describe("The list client order ID to cancel"), + newClientOrderId: z + .string() + .optional() + .describe("New client order ID for this cancel request"), + recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + }, + async (params) => { + try { + // Check API credentials first + const credError = checkCredentials() + if (credError) return { content: [{ type: "text", text: credError }], isError: true } + const symbolError = validateSymbol(params.symbol) + if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true } + const recvWindowError = validateRecvWindow(params.recvWindow) + if (recvWindowError) + return { content: [{ type: "text", text: recvWindowError }], isError: true } + + if (!params.orderListId && !params.listClientOrderId) { + return { + content: [ + { + type: "text", + text: "❌ Either orderListId or listClientOrderId must be provided.", + }, + ], + isError: true, + } + } + + const response = await makeSignedRequest("DELETE", "/api/v3/orderList", params) + + const orderReports = response.orderReports || [] + + return { + content: [ + { + type: "text", + text: + `✅ OCO Order cancelled successfully!\n\n` + + `Order List ID: ${response.orderListId}\n` + + `Symbol: ${response.symbol}\n` + + `Status: ${response.listStatusType}\n` + + `Order Status: ${response.listOrderStatus}\n` + + `\n--- Cancelled Orders ---\n` + + orderReports + .map( + (report: any) => + `• Order ID: ${report.orderId} | ${report.type} | ` + + `Qty: ${report.origQty} @ ${report.price} | ` + + `Status: ${report.status}`, + ) + .join("\n") + + `\n\nFull Response: ${JSON.stringify(response, null, 2)}`, + }, + ], } - ); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + const codeMatch = errorMessage.match(/code:\s*(-?\d+)/) + const additionalHelp = + codeMatch && codeMatch[1] + ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` + : "" + + return { + content: [ + { + type: "text", + text: `❌ Failed to cancel OCO order: ${errorMessage}${additionalHelp}`, + }, + ], + isError: true, + } + } + }, + ) } /** * Register open OCO orders tool */ export function registerBinanceUsOpenOco(server: McpServer) { - server.tool( - "binance_us_open_oco", - "Get all open OCO orders on Binance.US.", - { - recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)") - }, - async (params) => { - try { - // Check API credentials first - const credError = checkCredentials(); - if (credError) return { content: [{ type: "text", text: credError }], isError: true }; - const recvWindowError = validateRecvWindow(params.recvWindow); - if (recvWindowError) return { content: [{ type: "text", text: recvWindowError }], isError: true }; - - const response = await makeSignedRequest("GET", "/api/v3/openOrderList", params); - - if (!response || response.length === 0) { - return { - content: [{ - type: "text", - text: `📋 No open OCO orders found` - }] - }; - } - - const ocoList = response.map((oco: any) => { - const orders = oco.orders || []; - return `\n📦 Order List ID: ${oco.orderListId}\n` + - ` Symbol: ${oco.symbol}\n` + - ` Status: ${oco.listStatusType} / ${oco.listOrderStatus}\n` + - ` Client ID: ${oco.listClientOrderId}\n` + - ` Orders:\n` + - orders.map((order: any) => - ` • Order ID: ${order.orderId} | Client ID: ${order.clientOrderId}` - ).join('\n'); - }).join('\n'); - - return { - content: [{ - type: "text", - text: `📋 Open OCO Orders\n` + - `Total: ${response.length}\n` + - `${ocoList}\n\n` + - `Full Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - const codeMatch = errorMessage.match(/code:\s*(-?\d+)/); - const additionalHelp = codeMatch && codeMatch[1] ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` : ''; - return { - content: [{ type: "text", text: `❌ Failed to get open OCO orders: ${errorMessage}${additionalHelp}` }], - isError: true - }; - } + server.tool( + "binance_us_open_oco", + "Get all open OCO orders on Binance.US.", + { + recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + }, + async (params) => { + try { + // Check API credentials first + const credError = checkCredentials() + if (credError) return { content: [{ type: "text", text: credError }], isError: true } + const recvWindowError = validateRecvWindow(params.recvWindow) + if (recvWindowError) + return { content: [{ type: "text", text: recvWindowError }], isError: true } + + const response = await makeSignedRequest("GET", "/api/v3/openOrderList", params) + + if (!response || response.length === 0) { + return { + content: [ + { + type: "text", + text: `📋 No open OCO orders found`, + }, + ], + } + } + + const ocoList = response + .map((oco: any) => { + const orders = oco.orders || [] + + return ( + `\n📦 Order List ID: ${oco.orderListId}\n` + + ` Symbol: ${oco.symbol}\n` + + ` Status: ${oco.listStatusType} / ${oco.listOrderStatus}\n` + + ` Client ID: ${oco.listClientOrderId}\n` + + ` Orders:\n` + + orders + .map( + (order: any) => + ` • Order ID: ${order.orderId} | Client ID: ${order.clientOrderId}`, + ) + .join("\n") + ) + }) + .join("\n") + + return { + content: [ + { + type: "text", + text: + `📋 Open OCO Orders\n` + + `Total: ${response.length}\n` + + `${ocoList}\n\n` + + `Full Response: ${JSON.stringify(response, null, 2)}`, + }, + ], } - ); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + const codeMatch = errorMessage.match(/code:\s*(-?\d+)/) + const additionalHelp = + codeMatch && codeMatch[1] + ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` + : "" + + return { + content: [ + { + type: "text", + text: `❌ Failed to get open OCO orders: ${errorMessage}${additionalHelp}`, + }, + ], + isError: true, + } + } + }, + ) } /** * Register all OCO orders history tool */ export function registerBinanceUsAllOcoOrders(server: McpServer) { - server.tool( - "binance_us_all_oco_orders", - "Get all OCO orders (history) on Binance.US. Returns up to 1000 orders.", - { - fromId: z.number().optional().describe("Order list ID to start from. Cannot be used with startTime/endTime."), - startTime: z.number().optional().describe("Start time in milliseconds. Cannot be used with fromId."), - endTime: z.number().optional().describe("End time in milliseconds. Cannot be used with fromId."), - limit: z.number().optional().describe("Number of results (default 500, max 1000)"), - recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)") - }, - async (params) => { - try { - // Check API credentials first - const credError = checkCredentials(); - if (credError) return { content: [{ type: "text", text: credError }], isError: true }; - const recvWindowError = validateRecvWindow(params.recvWindow); - if (recvWindowError) return { content: [{ type: "text", text: recvWindowError }], isError: true }; - - // Validate mutually exclusive parameters - if (params.fromId && (params.startTime || params.endTime)) { - return { - content: [{ type: "text", text: "❌ fromId cannot be used together with startTime or endTime." }], - isError: true - }; - } - - // Validate limit - if (params.limit !== undefined && (params.limit < 1 || params.limit > 1000)) { - return { - content: [{ type: "text", text: "❌ limit must be between 1 and 1000." }], - isError: true - }; - } - - const response = await makeSignedRequest("GET", "/api/v3/allOrderList", params); - - if (!response || response.length === 0) { - return { - content: [{ - type: "text", - text: `📋 No OCO order history found` - }] - }; - } - - const ocoList = response.slice(0, 10).map((oco: any) => { - const orders = oco.orders || []; - return `• List ID: ${oco.orderListId} | ${oco.symbol} | ` + - `Status: ${oco.listOrderStatus} | ` + - `Orders: ${orders.length} | ` + - `${new Date(oco.transactionTime).toISOString()}`; - }).join('\n'); - - return { - content: [{ - type: "text", - text: `📋 OCO Order History\n` + - `Total Retrieved: ${response.length}\n\n` + - `Recent Orders (showing up to 10):\n${ocoList}\n\n` + - `Full Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - const codeMatch = errorMessage.match(/code:\s*(-?\d+)/); - const additionalHelp = codeMatch && codeMatch[1] ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` : ''; - return { - content: [{ type: "text", text: `❌ Failed to get OCO order history: ${errorMessage}${additionalHelp}` }], - isError: true - }; - } + server.tool( + "binance_us_all_oco_orders", + "Get all OCO orders (history) on Binance.US. Returns up to 1000 orders.", + { + fromId: z + .number() + .optional() + .describe("Order list ID to start from. Cannot be used with startTime/endTime."), + startTime: z + .number() + .optional() + .describe("Start time in milliseconds. Cannot be used with fromId."), + endTime: z + .number() + .optional() + .describe("End time in milliseconds. Cannot be used with fromId."), + limit: z.number().optional().describe("Number of results (default 500, max 1000)"), + recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + }, + async (params) => { + try { + // Check API credentials first + const credError = checkCredentials() + if (credError) return { content: [{ type: "text", text: credError }], isError: true } + const recvWindowError = validateRecvWindow(params.recvWindow) + if (recvWindowError) + return { content: [{ type: "text", text: recvWindowError }], isError: true } + + // Validate mutually exclusive parameters + if (params.fromId && (params.startTime || params.endTime)) { + return { + content: [ + { + type: "text", + text: "❌ fromId cannot be used together with startTime or endTime.", + }, + ], + isError: true, + } + } + + // Validate limit + if (params.limit !== undefined && (params.limit < 1 || params.limit > 1000)) { + return { + content: [{ type: "text", text: "❌ limit must be between 1 and 1000." }], + isError: true, + } } - ); + + const response = await makeSignedRequest("GET", "/api/v3/allOrderList", params) + + if (!response || response.length === 0) { + return { + content: [ + { + type: "text", + text: `📋 No OCO order history found`, + }, + ], + } + } + + const ocoList = response + .slice(0, 10) + .map((oco: any) => { + const orders = oco.orders || [] + + return ( + `• List ID: ${oco.orderListId} | ${oco.symbol} | ` + + `Status: ${oco.listOrderStatus} | ` + + `Orders: ${orders.length} | ` + + `${new Date(oco.transactionTime).toISOString()}` + ) + }) + .join("\n") + + return { + content: [ + { + type: "text", + text: + `📋 OCO Order History\n` + + `Total Retrieved: ${response.length}\n\n` + + `Recent Orders (showing up to 10):\n${ocoList}\n\n` + + `Full Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + const codeMatch = errorMessage.match(/code:\s*(-?\d+)/) + const additionalHelp = + codeMatch && codeMatch[1] + ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` + : "" + + return { + content: [ + { + type: "text", + text: `❌ Failed to get OCO order history: ${errorMessage}${additionalHelp}`, + }, + ], + isError: true, + } + } + }, + ) } /** * Validate OCO order parameters */ function validateOcoParams(params: any): string | null { - const { side, price, stopPrice, stopLimitPrice, stopLimitTimeInForce, quantity } = params; - - // Validate quantity - if (!quantity || quantity <= 0) { - return "❌ quantity must be greater than 0."; - } - - // Validate price - if (!price || price <= 0) { - return "❌ price must be greater than 0."; - } - - // Validate stopPrice - if (!stopPrice || stopPrice <= 0) { - return "❌ stopPrice must be greater than 0."; - } - - // Validate stop limit price requires time in force - if (stopLimitPrice && !stopLimitTimeInForce) { - return "❌ stopLimitTimeInForce is required when stopLimitPrice is provided."; - } - - // Validate price restrictions based on side with helpful warnings - if (side === "SELL" && price <= stopPrice) { - return "⚠️ For SELL OCO orders, limit price should typically be greater than stop price. " + - "Price restrictions: Limit Price > Last Price > Stop Price"; - } - - if (side === "BUY" && price >= stopPrice) { - return "⚠️ For BUY OCO orders, limit price should typically be less than stop price. " + - "Price restrictions: Limit Price < Last Price < Stop Price"; - } - - return null; + const { side, price, stopPrice, stopLimitPrice, stopLimitTimeInForce, quantity } = params + + // Validate quantity + if (!quantity || quantity <= 0) { + return "❌ quantity must be greater than 0." + } + + // Validate price + if (!price || price <= 0) { + return "❌ price must be greater than 0." + } + + // Validate stopPrice + if (!stopPrice || stopPrice <= 0) { + return "❌ stopPrice must be greater than 0." + } + + // Validate stop limit price requires time in force + if (stopLimitPrice && !stopLimitTimeInForce) { + return "❌ stopLimitTimeInForce is required when stopLimitPrice is provided." + } + + // Validate price restrictions based on side with helpful warnings + if (side === "SELL" && price <= stopPrice) { + return ( + "⚠️ For SELL OCO orders, limit price should typically be greater than stop price. " + + "Price restrictions: Limit Price > Last Price > Stop Price" + ) + } + + if (side === "BUY" && price >= stopPrice) { + return ( + "⚠️ For BUY OCO orders, limit price should typically be less than stop price. " + + "Price restrictions: Limit Price < Last Price < Stop Price" + ) + } + + return null } /** * Register all OCO order tools */ export function registerBinanceUsOcoTools(server: McpServer) { - registerBinanceUsNewOco(server); - registerBinanceUsGetOco(server); - registerBinanceUsCancelOco(server); - registerBinanceUsOpenOco(server); - registerBinanceUsAllOcoOrders(server); -} \ No newline at end of file + registerBinanceUsNewOco(server) + registerBinanceUsGetOco(server) + registerBinanceUsCancelOco(server) + registerBinanceUsOpenOco(server) + registerBinanceUsAllOcoOrders(server) +} diff --git a/src/tools/trade/orders.ts b/src/tools/trade/orders.ts index e6ffa262..7cbe8193 100644 --- a/src/tools/trade/orders.ts +++ b/src/tools/trade/orders.ts @@ -1,754 +1,962 @@ // src/tools/trade/orders.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { makeSignedRequest, hasApiCredentials, BINANCE_US_CONFIG } from "../../config/binanceUsClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { + BINANCE_US_CONFIG, + hasApiCredentials, + makeSignedRequest, +} from "../../config/binanceUsClient.js" // Common Binance error codes for better error messages const BINANCE_ERROR_CODES: Record = { - [-1000]: "Unknown error occurred", - [-1001]: "Disconnected - internal error", - [-1002]: "Unauthorized - check API key permissions", - [-1003]: "Too many requests - rate limit exceeded", - [-1006]: "Unexpected response - try again", - [-1007]: "Timeout waiting for response", - [-1013]: "Invalid quantity - check LOT_SIZE filter", - [-1014]: "Unknown order composition", - [-1015]: "Too many orders - rate limit exceeded", - [-1016]: "Service shutting down", - [-1020]: "Unsupported operation", - [-1021]: "Invalid timestamp - check recvWindow", - [-1022]: "Invalid signature", - [-1100]: "Illegal characters in parameter", - [-1101]: "Too many parameters sent", - [-1102]: "Mandatory parameter missing", - [-1103]: "Unknown parameter sent", - [-1104]: "Not all parameters read", - [-1105]: "Parameter is empty", - [-1106]: "Parameter not required", - [-1111]: "Precision over maximum for asset", - [-1112]: "No orders on book for symbol", - [-1114]: "TimeInForce parameter not required", - [-1115]: "Invalid timeInForce value", - [-1116]: "Invalid orderType value", - [-1117]: "Invalid side value", - [-1118]: "New client order ID is empty", - [-1119]: "Original client order ID is empty", - [-1120]: "Invalid interval value", - [-1121]: "Invalid symbol", - [-1125]: "Invalid listen key", - [-1127]: "Listen key lookup interval too big", - [-1128]: "Invalid optional parameter combination", - [-1130]: "Invalid data sent for parameter", - [-2010]: "New order rejected", - [-2011]: "Cancel rejected - check order status", - [-2013]: "Order does not exist", - [-2014]: "API key format invalid", - [-2015]: "Rejected - invalid API key, IP, or permissions", - [-2016]: "No trading window could be found", - [-2018]: "Balance is insufficient", - [-2019]: "Margin is insufficient", - [-2020]: "Unable to fill order", - [-2021]: "Order would immediately trigger stop price", - [-2022]: "ReduceOnly rejected - position already reduced", - [-2024]: "Position does not exist", - [-2026]: "Order would immediately match and trade" -}; + [-1000]: "Unknown error occurred", + [-1001]: "Disconnected - internal error", + [-1002]: "Unauthorized - check API key permissions", + [-1003]: "Too many requests - rate limit exceeded", + [-1006]: "Unexpected response - try again", + [-1007]: "Timeout waiting for response", + [-1013]: "Invalid quantity - check LOT_SIZE filter", + [-1014]: "Unknown order composition", + [-1015]: "Too many orders - rate limit exceeded", + [-1016]: "Service shutting down", + [-1020]: "Unsupported operation", + [-1021]: "Invalid timestamp - check recvWindow", + [-1022]: "Invalid signature", + [-1100]: "Illegal characters in parameter", + [-1101]: "Too many parameters sent", + [-1102]: "Mandatory parameter missing", + [-1103]: "Unknown parameter sent", + [-1104]: "Not all parameters read", + [-1105]: "Parameter is empty", + [-1106]: "Parameter not required", + [-1111]: "Precision over maximum for asset", + [-1112]: "No orders on book for symbol", + [-1114]: "TimeInForce parameter not required", + [-1115]: "Invalid timeInForce value", + [-1116]: "Invalid orderType value", + [-1117]: "Invalid side value", + [-1118]: "New client order ID is empty", + [-1119]: "Original client order ID is empty", + [-1120]: "Invalid interval value", + [-1121]: "Invalid symbol", + [-1125]: "Invalid listen key", + [-1127]: "Listen key lookup interval too big", + [-1128]: "Invalid optional parameter combination", + [-1130]: "Invalid data sent for parameter", + [-2010]: "New order rejected", + [-2011]: "Cancel rejected - check order status", + [-2013]: "Order does not exist", + [-2014]: "API key format invalid", + [-2015]: "Rejected - invalid API key, IP, or permissions", + [-2016]: "No trading window could be found", + [-2018]: "Balance is insufficient", + [-2019]: "Margin is insufficient", + [-2020]: "Unable to fill order", + [-2021]: "Order would immediately trigger stop price", + [-2022]: "ReduceOnly rejected - position already reduced", + [-2024]: "Position does not exist", + [-2026]: "Order would immediately match and trade", +} /** * Get human-readable error message for Binance error code */ function getBinanceErrorMessage(code: number): string { - return BINANCE_ERROR_CODES[code] || `Unknown error code: ${code}`; + return BINANCE_ERROR_CODES[code] || `Unknown error code: ${code}` } /** * Check API credentials before making requests */ function checkCredentials(): string | null { - if (!hasApiCredentials()) { - return "❌ API credentials not configured. Please set BINANCE_US_API_KEY and BINANCE_US_API_SECRET environment variables."; - } - return null; + if (!hasApiCredentials()) { + return "❌ API credentials not configured. Please set BINANCE_US_API_KEY and BINANCE_US_API_SECRET environment variables." + } + + return null } /** * Validate recvWindow parameter */ function validateRecvWindow(recvWindow?: number): string | null { - if (recvWindow !== undefined && recvWindow > BINANCE_US_CONFIG.MAX_RECV_WINDOW) { - return `❌ recvWindow cannot exceed ${BINANCE_US_CONFIG.MAX_RECV_WINDOW}ms (60 seconds).`; - } - return null; + if (recvWindow !== undefined && recvWindow > BINANCE_US_CONFIG.MAX_RECV_WINDOW) { + return `❌ recvWindow cannot exceed ${BINANCE_US_CONFIG.MAX_RECV_WINDOW}ms (60 seconds).` + } + + return null } /** * Validate symbol format (basic check) */ function validateSymbol(symbol: string): string | null { - if (!symbol || symbol.length < 2 || symbol.length > 20) { - return "❌ Invalid symbol format. Symbol should be 2-20 characters (e.g., BTCUSD, ETHUSD)."; - } - if (!/^[A-Z0-9]+$/.test(symbol.toUpperCase())) { - return "❌ Invalid symbol format. Symbol should contain only letters and numbers."; - } - return null; + if (!symbol || symbol.length < 2 || symbol.length > 20) { + return "❌ Invalid symbol format. Symbol should be 2-20 characters (e.g., BTCUSD, ETHUSD)." + } + if (!/^[A-Z0-9]+$/.test(symbol.toUpperCase())) { + return "❌ Invalid symbol format. Symbol should contain only letters and numbers." + } + + return null } // Order type enum const OrderType = z.enum([ - "LIMIT", - "MARKET", - "STOP_LOSS", - "STOP_LOSS_LIMIT", - "TAKE_PROFIT", - "TAKE_PROFIT_LIMIT", - "LIMIT_MAKER" -]); + "LIMIT", + "MARKET", + "STOP_LOSS", + "STOP_LOSS_LIMIT", + "TAKE_PROFIT", + "TAKE_PROFIT_LIMIT", + "LIMIT_MAKER", +]) // Time in force enum -const TimeInForce = z.enum(["GTC", "IOC", "FOK"]); +const TimeInForce = z.enum(["GTC", "IOC", "FOK"]) // Order side enum -const OrderSide = z.enum(["BUY", "SELL"]); +const OrderSide = z.enum(["BUY", "SELL"]) // Response type enum -const OrderRespType = z.enum(["ACK", "RESULT", "FULL"]); +const OrderRespType = z.enum(["ACK", "RESULT", "FULL"]) // Self trade prevention mode enum -const SelfTradePreventionMode = z.enum(["EXPIRE_TAKER", "EXPIRE_MAKER", "EXPIRE_BOTH", "NONE"]); +const SelfTradePreventionMode = z.enum(["EXPIRE_TAKER", "EXPIRE_MAKER", "EXPIRE_BOTH", "NONE"]) // Cancel replace mode enum -const CancelReplaceMode = z.enum(["STOP_ON_FAILURE", "ALLOW_FAILURE"]); +const CancelReplaceMode = z.enum(["STOP_ON_FAILURE", "ALLOW_FAILURE"]) // Cancel restrictions enum -const CancelRestrictions = z.enum(["ONLY_NEW", "ONLY_PARTIALLY_FILLED"]); +const CancelRestrictions = z.enum(["ONLY_NEW", "ONLY_PARTIALLY_FILLED"]) /** * Register new order tool */ export function registerBinanceUsNewOrder(server: McpServer) { - server.tool( - "binance_us_new_order", - "Place a new trade order on Binance.US. Supports LIMIT, MARKET, STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, TAKE_PROFIT_LIMIT, and LIMIT_MAKER order types.", - { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD, ETHUSD)"), - side: OrderSide.describe("Order side: BUY or SELL"), - type: OrderType.describe("Order type: LIMIT, MARKET, STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, TAKE_PROFIT_LIMIT, LIMIT_MAKER"), - timeInForce: TimeInForce.optional().describe("Time in force: GTC (Good Till Cancel), IOC (Immediate Or Cancel), FOK (Fill Or Kill). Required for LIMIT orders."), - quantity: z.number().optional().describe("Order quantity in base asset. Required for most order types."), - quoteOrderQty: z.number().optional().describe("Order quantity in quote asset. Can be used for MARKET orders instead of quantity."), - price: z.number().optional().describe("Order price. Required for LIMIT and LIMIT_MAKER orders."), - newClientOrderId: z.string().optional().describe("Unique client order ID. Auto-generated if not provided."), - stopPrice: z.number().optional().describe("Stop price. Required for STOP_LOSS_LIMIT and TAKE_PROFIT_LIMIT orders."), - trailingDelta: z.number().optional().describe("Trailing delta for trailing stop orders in BIPS (1 BIP = 0.01%)."), - icebergQty: z.number().optional().describe("Iceberg quantity for iceberg orders. timeInForce must be GTC."), - newOrderRespType: OrderRespType.optional().describe("Response type: ACK, RESULT, or FULL. MARKET/LIMIT default to FULL, others to ACK."), - selfTradePreventionMode: SelfTradePreventionMode.optional().describe("Self-trade prevention mode: EXPIRE_TAKER, EXPIRE_MAKER, EXPIRE_BOTH, NONE."), - recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000).") - }, - async (params) => { - try { - // Check API credentials first - const credError = checkCredentials(); - if (credError) return { content: [{ type: "text", text: credError }], isError: true }; - - // Validate symbol - const symbolError = validateSymbol(params.symbol); - if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true }; - - // Validate recvWindow - const recvWindowError = validateRecvWindow(params.recvWindow); - if (recvWindowError) return { content: [{ type: "text", text: recvWindowError }], isError: true }; - - // Validate order type requirements - const validationError = validateOrderParams(params); - if (validationError) { - return { - content: [{ type: "text", text: validationError }], - isError: true - }; - } - - const response = await makeSignedRequest("POST", "/api/v3/order", params); - - return { - content: [{ - type: "text", - text: `✅ Order placed successfully!\n\n` + - `Order ID: ${response.orderId}\n` + - `Symbol: ${response.symbol}\n` + - `Side: ${response.side}\n` + - `Type: ${response.type}\n` + - `Status: ${response.status || 'PENDING'}\n` + - (response.price ? `Price: ${response.price}\n` : '') + - (response.origQty ? `Quantity: ${response.origQty}\n` : '') + - (response.executedQty ? `Executed: ${response.executedQty}\n` : '') + - `\nFull Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - // Try to extract Binance error code for better messaging - const codeMatch = errorMessage.match(/code:\s*(-?\d+)/); - const additionalHelp = codeMatch && codeMatch[1] ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` : ''; - return { - content: [{ type: "text", text: `❌ Failed to place order: ${errorMessage}${additionalHelp}` }], - isError: true - }; - } + server.tool( + "binance_us_new_order", + "Place a new trade order on Binance.US. Supports LIMIT, MARKET, STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, TAKE_PROFIT_LIMIT, and LIMIT_MAKER order types.", + { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD, ETHUSD)"), + side: OrderSide.describe("Order side: BUY or SELL"), + type: OrderType.describe( + "Order type: LIMIT, MARKET, STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, TAKE_PROFIT_LIMIT, LIMIT_MAKER", + ), + timeInForce: TimeInForce.optional().describe( + "Time in force: GTC (Good Till Cancel), IOC (Immediate Or Cancel), FOK (Fill Or Kill). Required for LIMIT orders.", + ), + quantity: z + .number() + .optional() + .describe("Order quantity in base asset. Required for most order types."), + quoteOrderQty: z + .number() + .optional() + .describe( + "Order quantity in quote asset. Can be used for MARKET orders instead of quantity.", + ), + price: z + .number() + .optional() + .describe("Order price. Required for LIMIT and LIMIT_MAKER orders."), + newClientOrderId: z + .string() + .optional() + .describe("Unique client order ID. Auto-generated if not provided."), + stopPrice: z + .number() + .optional() + .describe("Stop price. Required for STOP_LOSS_LIMIT and TAKE_PROFIT_LIMIT orders."), + trailingDelta: z + .number() + .optional() + .describe("Trailing delta for trailing stop orders in BIPS (1 BIP = 0.01%)."), + icebergQty: z + .number() + .optional() + .describe("Iceberg quantity for iceberg orders. timeInForce must be GTC."), + newOrderRespType: OrderRespType.optional().describe( + "Response type: ACK, RESULT, or FULL. MARKET/LIMIT default to FULL, others to ACK.", + ), + selfTradePreventionMode: SelfTradePreventionMode.optional().describe( + "Self-trade prevention mode: EXPIRE_TAKER, EXPIRE_MAKER, EXPIRE_BOTH, NONE.", + ), + recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)."), + }, + async (params) => { + try { + // Check API credentials first + const credError = checkCredentials() + if (credError) return { content: [{ type: "text", text: credError }], isError: true } + + // Validate symbol + const symbolError = validateSymbol(params.symbol) + if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true } + + // Validate recvWindow + const recvWindowError = validateRecvWindow(params.recvWindow) + if (recvWindowError) + return { content: [{ type: "text", text: recvWindowError }], isError: true } + + // Validate order type requirements + const validationError = validateOrderParams(params) + if (validationError) { + return { + content: [{ type: "text", text: validationError }], + isError: true, + } + } + + const response = await makeSignedRequest("POST", "/api/v3/order", params) + + return { + content: [ + { + type: "text", + text: + `✅ Order placed successfully!\n\n` + + `Order ID: ${response.orderId}\n` + + `Symbol: ${response.symbol}\n` + + `Side: ${response.side}\n` + + `Type: ${response.type}\n` + + `Status: ${response.status || "PENDING"}\n` + + (response.price ? `Price: ${response.price}\n` : "") + + (response.origQty ? `Quantity: ${response.origQty}\n` : "") + + (response.executedQty ? `Executed: ${response.executedQty}\n` : "") + + `\nFull Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + // Try to extract Binance error code for better messaging + const codeMatch = errorMessage.match(/code:\s*(-?\d+)/) + const additionalHelp = + codeMatch && codeMatch[1] + ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` + : "" + + return { + content: [ + { type: "text", text: `❌ Failed to place order: ${errorMessage}${additionalHelp}` }, + ], + isError: true, } - ); + } + }, + ) } /** * Register test order tool */ export function registerBinanceUsTestOrder(server: McpServer) { - server.tool( - "binance_us_test_order", - "Test a new order on Binance.US without actually placing it. Validates order parameters and signature without executing the trade.", - { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD, ETHUSD)"), - side: OrderSide.describe("Order side: BUY or SELL"), - type: OrderType.describe("Order type: LIMIT, MARKET, STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, TAKE_PROFIT_LIMIT, LIMIT_MAKER"), - timeInForce: TimeInForce.optional().describe("Time in force: GTC, IOC, or FOK"), - quantity: z.number().optional().describe("Order quantity in base asset"), - quoteOrderQty: z.number().optional().describe("Order quantity in quote asset (for MARKET orders)"), - price: z.number().optional().describe("Order price"), - newClientOrderId: z.string().optional().describe("Unique client order ID"), - stopPrice: z.number().optional().describe("Stop price for stop orders"), - trailingDelta: z.number().optional().describe("Trailing delta in BIPS"), - icebergQty: z.number().optional().describe("Iceberg quantity"), - newOrderRespType: OrderRespType.optional().describe("Response type"), - selfTradePreventionMode: SelfTradePreventionMode.optional().describe("Self-trade prevention mode"), - recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)") - }, - async (params) => { - try { - // Check API credentials first - const credError = checkCredentials(); - if (credError) return { content: [{ type: "text", text: credError }], isError: true }; - - // Validate symbol and recvWindow - const symbolError = validateSymbol(params.symbol); - if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true }; - const recvWindowError = validateRecvWindow(params.recvWindow); - if (recvWindowError) return { content: [{ type: "text", text: recvWindowError }], isError: true }; - - const validationError = validateOrderParams(params); - if (validationError) { - return { - content: [{ type: "text", text: validationError }], - isError: true - }; - } - - await makeSignedRequest("POST", "/api/v3/order/test", params); - - return { - content: [{ - type: "text", - text: `✅ Test order validated successfully!\n\n` + - `Symbol: ${params.symbol}\n` + - `Side: ${params.side}\n` + - `Type: ${params.type}\n` + - (params.quantity ? `Quantity: ${params.quantity}\n` : '') + - (params.price ? `Price: ${params.price}\n` : '') + - `\nThe order parameters are valid and can be submitted.` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - const codeMatch = errorMessage.match(/code:\s*(-?\d+)/); - const additionalHelp = codeMatch && codeMatch[1] ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` : ''; - return { - content: [{ type: "text", text: `❌ Test order validation failed: ${errorMessage}${additionalHelp}` }], - isError: true - }; - } + server.tool( + "binance_us_test_order", + "Test a new order on Binance.US without actually placing it. Validates order parameters and signature without executing the trade.", + { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD, ETHUSD)"), + side: OrderSide.describe("Order side: BUY or SELL"), + type: OrderType.describe( + "Order type: LIMIT, MARKET, STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, TAKE_PROFIT_LIMIT, LIMIT_MAKER", + ), + timeInForce: TimeInForce.optional().describe("Time in force: GTC, IOC, or FOK"), + quantity: z.number().optional().describe("Order quantity in base asset"), + quoteOrderQty: z + .number() + .optional() + .describe("Order quantity in quote asset (for MARKET orders)"), + price: z.number().optional().describe("Order price"), + newClientOrderId: z.string().optional().describe("Unique client order ID"), + stopPrice: z.number().optional().describe("Stop price for stop orders"), + trailingDelta: z.number().optional().describe("Trailing delta in BIPS"), + icebergQty: z.number().optional().describe("Iceberg quantity"), + newOrderRespType: OrderRespType.optional().describe("Response type"), + selfTradePreventionMode: SelfTradePreventionMode.optional().describe( + "Self-trade prevention mode", + ), + recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + }, + async (params) => { + try { + // Check API credentials first + const credError = checkCredentials() + if (credError) return { content: [{ type: "text", text: credError }], isError: true } + + // Validate symbol and recvWindow + const symbolError = validateSymbol(params.symbol) + if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true } + const recvWindowError = validateRecvWindow(params.recvWindow) + if (recvWindowError) + return { content: [{ type: "text", text: recvWindowError }], isError: true } + + const validationError = validateOrderParams(params) + if (validationError) { + return { + content: [{ type: "text", text: validationError }], + isError: true, + } } - ); + + await makeSignedRequest("POST", "/api/v3/order/test", params) + + return { + content: [ + { + type: "text", + text: + `✅ Test order validated successfully!\n\n` + + `Symbol: ${params.symbol}\n` + + `Side: ${params.side}\n` + + `Type: ${params.type}\n` + + (params.quantity ? `Quantity: ${params.quantity}\n` : "") + + (params.price ? `Price: ${params.price}\n` : "") + + `\nThe order parameters are valid and can be submitted.`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + const codeMatch = errorMessage.match(/code:\s*(-?\d+)/) + const additionalHelp = + codeMatch && codeMatch[1] + ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` + : "" + + return { + content: [ + { + type: "text", + text: `❌ Test order validation failed: ${errorMessage}${additionalHelp}`, + }, + ], + isError: true, + } + } + }, + ) } /** * Register get order tool */ export function registerBinanceUsGetOrder(server: McpServer) { - server.tool( - "binance_us_get_order", - "Query the status of a specific order on Binance.US. Either orderId or origClientOrderId must be provided.", - { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD)"), - orderId: z.number().optional().describe("The order ID to query"), - origClientOrderId: z.string().optional().describe("The original client order ID to query"), - recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)") - }, - async (params) => { - try { - // Check API credentials first - const credError = checkCredentials(); - if (credError) return { content: [{ type: "text", text: credError }], isError: true }; - - // Validate symbol and recvWindow - const symbolError = validateSymbol(params.symbol); - if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true }; - const recvWindowError = validateRecvWindow(params.recvWindow); - if (recvWindowError) return { content: [{ type: "text", text: recvWindowError }], isError: true }; - - if (!params.orderId && !params.origClientOrderId) { - return { - content: [{ type: "text", text: "❌ Either orderId or origClientOrderId must be provided." }], - isError: true - }; - } - - const response = await makeSignedRequest("GET", "/api/v3/order", params); - - return { - content: [{ - type: "text", - text: `📋 Order Status\n\n` + - `Order ID: ${response.orderId}\n` + - `Symbol: ${response.symbol}\n` + - `Status: ${response.status}\n` + - `Side: ${response.side}\n` + - `Type: ${response.type}\n` + - `Price: ${response.price}\n` + - `Original Qty: ${response.origQty}\n` + - `Executed Qty: ${response.executedQty}\n` + - `Time In Force: ${response.timeInForce}\n` + - (response.stopPrice !== "0.00000000" ? `Stop Price: ${response.stopPrice}\n` : '') + - `Created: ${new Date(response.time).toISOString()}\n` + - `Updated: ${new Date(response.updateTime).toISOString()}\n` + - `\nFull Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - const codeMatch = errorMessage.match(/code:\s*(-?\d+)/); - const additionalHelp = codeMatch && codeMatch[1] ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` : ''; - return { - content: [{ type: "text", text: `❌ Failed to get order: ${errorMessage}${additionalHelp}` }], - isError: true - }; - } + server.tool( + "binance_us_get_order", + "Query the status of a specific order on Binance.US. Either orderId or origClientOrderId must be provided.", + { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD)"), + orderId: z.number().optional().describe("The order ID to query"), + origClientOrderId: z.string().optional().describe("The original client order ID to query"), + recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + }, + async (params) => { + try { + // Check API credentials first + const credError = checkCredentials() + if (credError) return { content: [{ type: "text", text: credError }], isError: true } + + // Validate symbol and recvWindow + const symbolError = validateSymbol(params.symbol) + if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true } + const recvWindowError = validateRecvWindow(params.recvWindow) + if (recvWindowError) + return { content: [{ type: "text", text: recvWindowError }], isError: true } + + if (!params.orderId && !params.origClientOrderId) { + return { + content: [ + { type: "text", text: "❌ Either orderId or origClientOrderId must be provided." }, + ], + isError: true, + } + } + + const response = await makeSignedRequest("GET", "/api/v3/order", params) + + return { + content: [ + { + type: "text", + text: + `📋 Order Status\n\n` + + `Order ID: ${response.orderId}\n` + + `Symbol: ${response.symbol}\n` + + `Status: ${response.status}\n` + + `Side: ${response.side}\n` + + `Type: ${response.type}\n` + + `Price: ${response.price}\n` + + `Original Qty: ${response.origQty}\n` + + `Executed Qty: ${response.executedQty}\n` + + `Time In Force: ${response.timeInForce}\n` + + (response.stopPrice !== "0.00000000" ? `Stop Price: ${response.stopPrice}\n` : "") + + `Created: ${new Date(response.time).toISOString()}\n` + + `Updated: ${new Date(response.updateTime).toISOString()}\n` + + `\nFull Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + const codeMatch = errorMessage.match(/code:\s*(-?\d+)/) + const additionalHelp = + codeMatch && codeMatch[1] + ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` + : "" + + return { + content: [ + { type: "text", text: `❌ Failed to get order: ${errorMessage}${additionalHelp}` }, + ], + isError: true, } - ); + } + }, + ) } /** * Register cancel order tool */ export function registerBinanceUsCancelOrder(server: McpServer) { - server.tool( - "binance_us_cancel_order", - "Cancel an active order on Binance.US. Either orderId or origClientOrderId must be provided.", - { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD)"), - orderId: z.number().optional().describe("The order ID to cancel"), - origClientOrderId: z.string().optional().describe("The original client order ID to cancel"), - newClientOrderId: z.string().optional().describe("New client order ID for this cancel request"), - cancelRestrictions: CancelRestrictions.optional().describe("Cancel restrictions: ONLY_NEW or ONLY_PARTIALLY_FILLED"), - recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)") - }, - async (params) => { - try { - // Check API credentials first - const credError = checkCredentials(); - if (credError) return { content: [{ type: "text", text: credError }], isError: true }; - - // Validate symbol and recvWindow - const symbolError = validateSymbol(params.symbol); - if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true }; - const recvWindowError = validateRecvWindow(params.recvWindow); - if (recvWindowError) return { content: [{ type: "text", text: recvWindowError }], isError: true }; - - if (!params.orderId && !params.origClientOrderId) { - return { - content: [{ type: "text", text: "❌ Either orderId or origClientOrderId must be provided." }], - isError: true - }; - } - - const response = await makeSignedRequest("DELETE", "/api/v3/order", params); - - return { - content: [{ - type: "text", - text: `✅ Order cancelled successfully!\n\n` + - `Order ID: ${response.orderId}\n` + - `Symbol: ${response.symbol}\n` + - `Status: ${response.status}\n` + - `Side: ${response.side}\n` + - `Type: ${response.type}\n` + - `Price: ${response.price}\n` + - `Original Qty: ${response.origQty}\n` + - `Executed Qty: ${response.executedQty}\n` + - `\nFull Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - const codeMatch = errorMessage.match(/code:\s*(-?\d+)/); - const additionalHelp = codeMatch && codeMatch[1] ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` : ''; - return { - content: [{ type: "text", text: `❌ Failed to cancel order: ${errorMessage}${additionalHelp}` }], - isError: true - }; - } + server.tool( + "binance_us_cancel_order", + "Cancel an active order on Binance.US. Either orderId or origClientOrderId must be provided.", + { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD)"), + orderId: z.number().optional().describe("The order ID to cancel"), + origClientOrderId: z.string().optional().describe("The original client order ID to cancel"), + newClientOrderId: z + .string() + .optional() + .describe("New client order ID for this cancel request"), + cancelRestrictions: CancelRestrictions.optional().describe( + "Cancel restrictions: ONLY_NEW or ONLY_PARTIALLY_FILLED", + ), + recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + }, + async (params) => { + try { + // Check API credentials first + const credError = checkCredentials() + if (credError) return { content: [{ type: "text", text: credError }], isError: true } + + // Validate symbol and recvWindow + const symbolError = validateSymbol(params.symbol) + if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true } + const recvWindowError = validateRecvWindow(params.recvWindow) + if (recvWindowError) + return { content: [{ type: "text", text: recvWindowError }], isError: true } + + if (!params.orderId && !params.origClientOrderId) { + return { + content: [ + { type: "text", text: "❌ Either orderId or origClientOrderId must be provided." }, + ], + isError: true, + } + } + + const response = await makeSignedRequest("DELETE", "/api/v3/order", params) + + return { + content: [ + { + type: "text", + text: + `✅ Order cancelled successfully!\n\n` + + `Order ID: ${response.orderId}\n` + + `Symbol: ${response.symbol}\n` + + `Status: ${response.status}\n` + + `Side: ${response.side}\n` + + `Type: ${response.type}\n` + + `Price: ${response.price}\n` + + `Original Qty: ${response.origQty}\n` + + `Executed Qty: ${response.executedQty}\n` + + `\nFull Response: ${JSON.stringify(response, null, 2)}`, + }, + ], } - ); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + const codeMatch = errorMessage.match(/code:\s*(-?\d+)/) + const additionalHelp = + codeMatch && codeMatch[1] + ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` + : "" + + return { + content: [ + { type: "text", text: `❌ Failed to cancel order: ${errorMessage}${additionalHelp}` }, + ], + isError: true, + } + } + }, + ) } /** * Register cancel and replace order tool */ export function registerBinanceUsCancelReplace(server: McpServer) { - server.tool( - "binance_us_cancel_replace", - "Cancel an existing order and place a new order on the same symbol atomically. This is useful for modifying order parameters.", - { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD)"), - side: OrderSide.describe("Order side: BUY or SELL"), - type: OrderType.describe("Order type for the new order"), - cancelReplaceMode: CancelReplaceMode.describe("STOP_ON_FAILURE: Don't place new order if cancel fails. ALLOW_FAILURE: Place new order even if cancel fails."), - cancelOrderId: z.number().optional().describe("Order ID to cancel. Either this or cancelOrigClientOrderId required."), - cancelOrigClientOrderId: z.string().optional().describe("Client order ID to cancel. Either this or cancelOrderId required."), - timeInForce: TimeInForce.optional().describe("Time in force for new order"), - quantity: z.number().optional().describe("Quantity for new order"), - quoteOrderQty: z.number().optional().describe("Quote order quantity for new order"), - price: z.number().optional().describe("Price for new order"), - cancelNewClientOrderId: z.string().optional().describe("Client order ID for the cancel"), - newClientOrderId: z.string().optional().describe("Client order ID for the new order"), - stopPrice: z.number().optional().describe("Stop price for new order"), - trailingDelta: z.number().optional().describe("Trailing delta for new order"), - icebergQty: z.number().optional().describe("Iceberg quantity for new order"), - newOrderRespType: OrderRespType.optional().describe("Response type for new order"), - selfTradePreventionMode: SelfTradePreventionMode.optional().describe("Self-trade prevention mode"), - cancelRestrictions: CancelRestrictions.optional().describe("Cancel restrictions"), - recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)") - }, - async (params) => { - try { - // Check API credentials first - const credError = checkCredentials(); - if (credError) return { content: [{ type: "text", text: credError }], isError: true }; - - // Validate symbol and recvWindow - const symbolError = validateSymbol(params.symbol); - if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true }; - const recvWindowError = validateRecvWindow(params.recvWindow); - if (recvWindowError) return { content: [{ type: "text", text: recvWindowError }], isError: true }; - - if (!params.cancelOrderId && !params.cancelOrigClientOrderId) { - return { - content: [{ type: "text", text: "❌ Either cancelOrderId or cancelOrigClientOrderId must be provided." }], - isError: true - }; - } - - const response = await makeSignedRequest("POST", "/api/v3/order/cancelReplace", params); - - return { - content: [{ - type: "text", - text: `✅ Cancel and Replace completed!\n\n` + - `Cancel Result: ${response.cancelResult}\n` + - `New Order Result: ${response.newOrderResult}\n` + - `\n--- Cancelled Order ---\n` + - (response.cancelResponse ? - `Order ID: ${response.cancelResponse.orderId}\n` + - `Status: ${response.cancelResponse.status}\n` : - 'N/A\n') + - `\n--- New Order ---\n` + - (response.newOrderResponse ? - `Order ID: ${response.newOrderResponse.orderId}\n` + - `Status: ${response.newOrderResponse.status}\n` + - `Price: ${response.newOrderResponse.price}\n` + - `Quantity: ${response.newOrderResponse.origQty}\n` : - 'N/A\n') + - `\nFull Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - const codeMatch = errorMessage.match(/code:\s*(-?\d+)/); - const additionalHelp = codeMatch && codeMatch[1] ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` : ''; - return { - content: [{ type: "text", text: `❌ Failed to cancel and replace order: ${errorMessage}${additionalHelp}` }], - isError: true - }; - } + server.tool( + "binance_us_cancel_replace", + "Cancel an existing order and place a new order on the same symbol atomically. This is useful for modifying order parameters.", + { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD)"), + side: OrderSide.describe("Order side: BUY or SELL"), + type: OrderType.describe("Order type for the new order"), + cancelReplaceMode: CancelReplaceMode.describe( + "STOP_ON_FAILURE: Don't place new order if cancel fails. ALLOW_FAILURE: Place new order even if cancel fails.", + ), + cancelOrderId: z + .number() + .optional() + .describe("Order ID to cancel. Either this or cancelOrigClientOrderId required."), + cancelOrigClientOrderId: z + .string() + .optional() + .describe("Client order ID to cancel. Either this or cancelOrderId required."), + timeInForce: TimeInForce.optional().describe("Time in force for new order"), + quantity: z.number().optional().describe("Quantity for new order"), + quoteOrderQty: z.number().optional().describe("Quote order quantity for new order"), + price: z.number().optional().describe("Price for new order"), + cancelNewClientOrderId: z.string().optional().describe("Client order ID for the cancel"), + newClientOrderId: z.string().optional().describe("Client order ID for the new order"), + stopPrice: z.number().optional().describe("Stop price for new order"), + trailingDelta: z.number().optional().describe("Trailing delta for new order"), + icebergQty: z.number().optional().describe("Iceberg quantity for new order"), + newOrderRespType: OrderRespType.optional().describe("Response type for new order"), + selfTradePreventionMode: SelfTradePreventionMode.optional().describe( + "Self-trade prevention mode", + ), + cancelRestrictions: CancelRestrictions.optional().describe("Cancel restrictions"), + recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + }, + async (params) => { + try { + // Check API credentials first + const credError = checkCredentials() + if (credError) return { content: [{ type: "text", text: credError }], isError: true } + + // Validate symbol and recvWindow + const symbolError = validateSymbol(params.symbol) + if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true } + const recvWindowError = validateRecvWindow(params.recvWindow) + if (recvWindowError) + return { content: [{ type: "text", text: recvWindowError }], isError: true } + + if (!params.cancelOrderId && !params.cancelOrigClientOrderId) { + return { + content: [ + { + type: "text", + text: "❌ Either cancelOrderId or cancelOrigClientOrderId must be provided.", + }, + ], + isError: true, + } + } + + const response = await makeSignedRequest("POST", "/api/v3/order/cancelReplace", params) + + return { + content: [ + { + type: "text", + text: + `✅ Cancel and Replace completed!\n\n` + + `Cancel Result: ${response.cancelResult}\n` + + `New Order Result: ${response.newOrderResult}\n` + + `\n--- Cancelled Order ---\n` + + (response.cancelResponse + ? `Order ID: ${response.cancelResponse.orderId}\n` + + `Status: ${response.cancelResponse.status}\n` + : "N/A\n") + + `\n--- New Order ---\n` + + (response.newOrderResponse + ? `Order ID: ${response.newOrderResponse.orderId}\n` + + `Status: ${response.newOrderResponse.status}\n` + + `Price: ${response.newOrderResponse.price}\n` + + `Quantity: ${response.newOrderResponse.origQty}\n` + : "N/A\n") + + `\nFull Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + const codeMatch = errorMessage.match(/code:\s*(-?\d+)/) + const additionalHelp = + codeMatch && codeMatch[1] + ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` + : "" + + return { + content: [ + { + type: "text", + text: `❌ Failed to cancel and replace order: ${errorMessage}${additionalHelp}`, + }, + ], + isError: true, } - ); + } + }, + ) } /** * Register open orders tool */ export function registerBinanceUsOpenOrders(server: McpServer) { - server.tool( - "binance_us_open_orders", - "Get all open orders on Binance.US. Can be filtered by symbol. Warning: Querying without symbol is heavier on rate limits (weight 40 vs 3).", - { - symbol: z.string().optional().describe("Trading pair symbol to filter by (e.g., BTCUSD). If omitted, returns all open orders."), - recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)") - }, - async (params) => { - try { - // Check API credentials first - const credError = checkCredentials(); - if (credError) return { content: [{ type: "text", text: credError }], isError: true }; - - // Validate optional symbol and recvWindow - if (params.symbol) { - const symbolError = validateSymbol(params.symbol); - if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true }; - } - const recvWindowError = validateRecvWindow(params.recvWindow); - if (recvWindowError) return { content: [{ type: "text", text: recvWindowError }], isError: true }; - - const response = await makeSignedRequest("GET", "/api/v3/openOrders", params); - - if (!response || response.length === 0) { - return { - content: [{ - type: "text", - text: params.symbol - ? `📋 No open orders found for ${params.symbol}` - : `📋 No open orders found` - }] - }; - } - - const orderList = response.map((order: any) => - `• ${order.symbol} | ${order.side} ${order.type} | ` + - `Qty: ${order.origQty} @ ${order.price} | ` + - `Status: ${order.status} | ID: ${order.orderId}` - ).join('\n'); - - return { - content: [{ - type: "text", - text: `📋 Open Orders${params.symbol ? ` for ${params.symbol}` : ''}\n` + - `Total: ${response.length}\n\n` + - `${orderList}\n\n` + - `Full Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - const codeMatch = errorMessage.match(/code:\s*(-?\d+)/); - const additionalHelp = codeMatch && codeMatch[1] ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` : ''; - return { - content: [{ type: "text", text: `❌ Failed to get open orders: ${errorMessage}${additionalHelp}` }], - isError: true - }; - } + server.tool( + "binance_us_open_orders", + "Get all open orders on Binance.US. Can be filtered by symbol. Warning: Querying without symbol is heavier on rate limits (weight 40 vs 3).", + { + symbol: z + .string() + .optional() + .describe( + "Trading pair symbol to filter by (e.g., BTCUSD). If omitted, returns all open orders.", + ), + recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + }, + async (params) => { + try { + // Check API credentials first + const credError = checkCredentials() + if (credError) return { content: [{ type: "text", text: credError }], isError: true } + + // Validate optional symbol and recvWindow + if (params.symbol) { + const symbolError = validateSymbol(params.symbol) + if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true } + } + const recvWindowError = validateRecvWindow(params.recvWindow) + if (recvWindowError) + return { content: [{ type: "text", text: recvWindowError }], isError: true } + + const response = await makeSignedRequest("GET", "/api/v3/openOrders", params) + + if (!response || response.length === 0) { + return { + content: [ + { + type: "text", + text: params.symbol + ? `📋 No open orders found for ${params.symbol}` + : `📋 No open orders found`, + }, + ], + } + } + + const orderList = response + .map( + (order: any) => + `• ${order.symbol} | ${order.side} ${order.type} | ` + + `Qty: ${order.origQty} @ ${order.price} | ` + + `Status: ${order.status} | ID: ${order.orderId}`, + ) + .join("\n") + + return { + content: [ + { + type: "text", + text: + `📋 Open Orders${params.symbol ? ` for ${params.symbol}` : ""}\n` + + `Total: ${response.length}\n\n` + + `${orderList}\n\n` + + `Full Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + const codeMatch = errorMessage.match(/code:\s*(-?\d+)/) + const additionalHelp = + codeMatch && codeMatch[1] + ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` + : "" + + return { + content: [ + { + type: "text", + text: `❌ Failed to get open orders: ${errorMessage}${additionalHelp}`, + }, + ], + isError: true, } - ); + } + }, + ) } /** * Register all orders history tool */ export function registerBinanceUsAllOrders(server: McpServer) { - server.tool( - "binance_us_all_orders", - "Get all orders (active, canceled, or filled) for a symbol on Binance.US. Returns order history.", - { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD)"), - orderId: z.number().optional().describe("Order ID to start from. Gets orders >= this orderId."), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Number of orders to return (default 500, max 1000)"), - recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)") - }, - async (params) => { - try { - // Check API credentials first - const credError = checkCredentials(); - if (credError) return { content: [{ type: "text", text: credError }], isError: true }; - - // Validate symbol and recvWindow - const symbolError = validateSymbol(params.symbol); - if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true }; - const recvWindowError = validateRecvWindow(params.recvWindow); - if (recvWindowError) return { content: [{ type: "text", text: recvWindowError }], isError: true }; - - // Validate limit - if (params.limit !== undefined && (params.limit < 1 || params.limit > 1000)) { - return { - content: [{ type: "text", text: "❌ limit must be between 1 and 1000." }], - isError: true - }; - } - - const response = await makeSignedRequest("GET", "/api/v3/allOrders", params); - - if (!response || response.length === 0) { - return { - content: [{ - type: "text", - text: `📋 No orders found for ${params.symbol}` - }] - }; - } - - const orderList = response.slice(0, 10).map((order: any) => - `• ${order.side} ${order.type} | Qty: ${order.origQty} @ ${order.price} | ` + - `Status: ${order.status} | ID: ${order.orderId} | ${new Date(order.time).toISOString()}` - ).join('\n'); - - return { - content: [{ - type: "text", - text: `📋 Order History for ${params.symbol}\n` + - `Total Retrieved: ${response.length}\n\n` + - `Recent Orders (showing up to 10):\n${orderList}\n\n` + - `Full Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - const codeMatch = errorMessage.match(/code:\s*(-?\d+)/); - const additionalHelp = codeMatch && codeMatch[1] ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` : ''; - return { - content: [{ type: "text", text: `❌ Failed to get order history: ${errorMessage}${additionalHelp}` }], - isError: true - }; - } + server.tool( + "binance_us_all_orders", + "Get all orders (active, canceled, or filled) for a symbol on Binance.US. Returns order history.", + { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD)"), + orderId: z + .number() + .optional() + .describe("Order ID to start from. Gets orders >= this orderId."), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Number of orders to return (default 500, max 1000)"), + recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + }, + async (params) => { + try { + // Check API credentials first + const credError = checkCredentials() + if (credError) return { content: [{ type: "text", text: credError }], isError: true } + + // Validate symbol and recvWindow + const symbolError = validateSymbol(params.symbol) + if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true } + const recvWindowError = validateRecvWindow(params.recvWindow) + if (recvWindowError) + return { content: [{ type: "text", text: recvWindowError }], isError: true } + + // Validate limit + if (params.limit !== undefined && (params.limit < 1 || params.limit > 1000)) { + return { + content: [{ type: "text", text: "❌ limit must be between 1 and 1000." }], + isError: true, + } } - ); + + const response = await makeSignedRequest("GET", "/api/v3/allOrders", params) + + if (!response || response.length === 0) { + return { + content: [ + { + type: "text", + text: `📋 No orders found for ${params.symbol}`, + }, + ], + } + } + + const orderList = response + .slice(0, 10) + .map( + (order: any) => + `• ${order.side} ${order.type} | Qty: ${order.origQty} @ ${order.price} | ` + + `Status: ${order.status} | ID: ${order.orderId} | ${new Date(order.time).toISOString()}`, + ) + .join("\n") + + return { + content: [ + { + type: "text", + text: + `📋 Order History for ${params.symbol}\n` + + `Total Retrieved: ${response.length}\n\n` + + `Recent Orders (showing up to 10):\n${orderList}\n\n` + + `Full Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + const codeMatch = errorMessage.match(/code:\s*(-?\d+)/) + const additionalHelp = + codeMatch && codeMatch[1] + ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` + : "" + + return { + content: [ + { + type: "text", + text: `❌ Failed to get order history: ${errorMessage}${additionalHelp}`, + }, + ], + isError: true, + } + } + }, + ) } /** * Validate order parameters based on order type */ function validateOrderParams(params: any): string | null { - const { type, timeInForce, quantity, quoteOrderQty, price, stopPrice, trailingDelta, icebergQty } = params; - - switch (type) { - case "LIMIT": - if (!timeInForce) return "❌ LIMIT orders require timeInForce parameter."; - if (!quantity) return "❌ LIMIT orders require quantity parameter."; - if (!price) return "❌ LIMIT orders require price parameter."; - break; - - case "MARKET": - if (!quantity && !quoteOrderQty) return "❌ MARKET orders require either quantity or quoteOrderQty."; - break; - - case "STOP_LOSS": - if (!quantity) return "❌ STOP_LOSS orders require quantity parameter."; - if (!stopPrice && !trailingDelta) return "❌ STOP_LOSS orders require stopPrice or trailingDelta."; - break; - - case "STOP_LOSS_LIMIT": - if (!timeInForce) return "❌ STOP_LOSS_LIMIT orders require timeInForce parameter."; - if (!quantity) return "❌ STOP_LOSS_LIMIT orders require quantity parameter."; - if (!price) return "❌ STOP_LOSS_LIMIT orders require price parameter."; - if (!stopPrice && !trailingDelta) return "❌ STOP_LOSS_LIMIT orders require stopPrice or trailingDelta."; - break; - - case "TAKE_PROFIT": - if (!quantity) return "❌ TAKE_PROFIT orders require quantity parameter."; - if (!stopPrice && !trailingDelta) return "❌ TAKE_PROFIT orders require stopPrice or trailingDelta."; - break; - - case "TAKE_PROFIT_LIMIT": - if (!timeInForce) return "❌ TAKE_PROFIT_LIMIT orders require timeInForce parameter."; - if (!quantity) return "❌ TAKE_PROFIT_LIMIT orders require quantity parameter."; - if (!price) return "❌ TAKE_PROFIT_LIMIT orders require price parameter."; - if (!stopPrice && !trailingDelta) return "❌ TAKE_PROFIT_LIMIT orders require stopPrice or trailingDelta."; - break; - - case "LIMIT_MAKER": - if (!quantity) return "❌ LIMIT_MAKER orders require quantity parameter."; - if (!price) return "❌ LIMIT_MAKER orders require price parameter."; - break; - } - - // Iceberg order validation - if (icebergQty && timeInForce !== "GTC") { - return "❌ Iceberg orders must have timeInForce set to GTC."; - } - - return null; + const { + type, + timeInForce, + quantity, + quoteOrderQty, + price, + stopPrice, + trailingDelta, + icebergQty, + } = params + + switch (type) { + case "LIMIT": + if (!timeInForce) return "❌ LIMIT orders require timeInForce parameter." + if (!quantity) return "❌ LIMIT orders require quantity parameter." + if (!price) return "❌ LIMIT orders require price parameter." + break + + case "MARKET": + if (!quantity && !quoteOrderQty) + return "❌ MARKET orders require either quantity or quoteOrderQty." + break + + case "STOP_LOSS": + if (!quantity) return "❌ STOP_LOSS orders require quantity parameter." + if (!stopPrice && !trailingDelta) + return "❌ STOP_LOSS orders require stopPrice or trailingDelta." + break + + case "STOP_LOSS_LIMIT": + if (!timeInForce) return "❌ STOP_LOSS_LIMIT orders require timeInForce parameter." + if (!quantity) return "❌ STOP_LOSS_LIMIT orders require quantity parameter." + if (!price) return "❌ STOP_LOSS_LIMIT orders require price parameter." + if (!stopPrice && !trailingDelta) + return "❌ STOP_LOSS_LIMIT orders require stopPrice or trailingDelta." + break + + case "TAKE_PROFIT": + if (!quantity) return "❌ TAKE_PROFIT orders require quantity parameter." + if (!stopPrice && !trailingDelta) + return "❌ TAKE_PROFIT orders require stopPrice or trailingDelta." + break + + case "TAKE_PROFIT_LIMIT": + if (!timeInForce) return "❌ TAKE_PROFIT_LIMIT orders require timeInForce parameter." + if (!quantity) return "❌ TAKE_PROFIT_LIMIT orders require quantity parameter." + if (!price) return "❌ TAKE_PROFIT_LIMIT orders require price parameter." + if (!stopPrice && !trailingDelta) + return "❌ TAKE_PROFIT_LIMIT orders require stopPrice or trailingDelta." + break + + case "LIMIT_MAKER": + if (!quantity) return "❌ LIMIT_MAKER orders require quantity parameter." + if (!price) return "❌ LIMIT_MAKER orders require price parameter." + break + } + + // Iceberg order validation + if (icebergQty && timeInForce !== "GTC") { + return "❌ Iceberg orders must have timeInForce set to GTC." + } + + return null } /** * Register cancel all open orders for symbol tool */ export function registerBinanceUsCancelAllOpenOrders(server: McpServer) { - server.tool( - "binance_us_cancel_all_open_orders", - "Cancel all active orders on a symbol on Binance.US. This includes OCO orders. Use with caution - this will cancel ALL open orders for the specified symbol.", - { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD). Required - all open orders for this symbol will be cancelled."), - recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)") - }, - async (params) => { - try { - // Check API credentials first - const credError = checkCredentials(); - if (credError) return { content: [{ type: "text", text: credError }], isError: true }; - - // Validate symbol - const symbolError = validateSymbol(params.symbol); - if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true }; - - // Validate recvWindow - const recvWindowError = validateRecvWindow(params.recvWindow); - if (recvWindowError) return { content: [{ type: "text", text: recvWindowError }], isError: true }; - - const response = await makeSignedRequest("DELETE", "/api/v3/openOrders", params); - - if (!response || response.length === 0) { - return { - content: [{ - type: "text", - text: `📋 No open orders found to cancel for ${params.symbol}` - }] - }; - } - - const cancelledList = response.map((order: any) => - `• Order ID: ${order.orderId} | ${order.side} ${order.type} | ` + - `Qty: ${order.origQty} @ ${order.price} | Status: ${order.status}` - ).join('\n'); - - return { - content: [{ - type: "text", - text: `✅ Cancelled ${response.length} orders for ${params.symbol}!\n\n` + - `Cancelled Orders:\n${cancelledList}\n\n` + - `Full Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - const codeMatch = errorMessage.match(/code:\s*(-?\d+)/); - const additionalHelp = codeMatch && codeMatch[1] ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` : ''; - return { - content: [{ type: "text", text: `❌ Failed to cancel all open orders: ${errorMessage}${additionalHelp}` }], - isError: true - }; - } + server.tool( + "binance_us_cancel_all_open_orders", + "Cancel all active orders on a symbol on Binance.US. This includes OCO orders. Use with caution - this will cancel ALL open orders for the specified symbol.", + { + symbol: z + .string() + .describe( + "Trading pair symbol (e.g., BTCUSD). Required - all open orders for this symbol will be cancelled.", + ), + recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + }, + async (params) => { + try { + // Check API credentials first + const credError = checkCredentials() + if (credError) return { content: [{ type: "text", text: credError }], isError: true } + + // Validate symbol + const symbolError = validateSymbol(params.symbol) + if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true } + + // Validate recvWindow + const recvWindowError = validateRecvWindow(params.recvWindow) + if (recvWindowError) + return { content: [{ type: "text", text: recvWindowError }], isError: true } + + const response = await makeSignedRequest("DELETE", "/api/v3/openOrders", params) + + if (!response || response.length === 0) { + return { + content: [ + { + type: "text", + text: `📋 No open orders found to cancel for ${params.symbol}`, + }, + ], + } + } + + const cancelledList = response + .map( + (order: any) => + `• Order ID: ${order.orderId} | ${order.side} ${order.type} | ` + + `Qty: ${order.origQty} @ ${order.price} | Status: ${order.status}`, + ) + .join("\n") + + return { + content: [ + { + type: "text", + text: + `✅ Cancelled ${response.length} orders for ${params.symbol}!\n\n` + + `Cancelled Orders:\n${cancelledList}\n\n` + + `Full Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + const codeMatch = errorMessage.match(/code:\s*(-?\d+)/) + const additionalHelp = + codeMatch && codeMatch[1] + ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` + : "" + + return { + content: [ + { + type: "text", + text: `❌ Failed to cancel all open orders: ${errorMessage}${additionalHelp}`, + }, + ], + isError: true, } - ); + } + }, + ) } /** * Register all standard order tools */ export function registerBinanceUsOrderTools(server: McpServer) { - registerBinanceUsNewOrder(server); - registerBinanceUsTestOrder(server); - registerBinanceUsGetOrder(server); - registerBinanceUsCancelOrder(server); - registerBinanceUsCancelReplace(server); - registerBinanceUsCancelAllOpenOrders(server); - registerBinanceUsOpenOrders(server); - registerBinanceUsAllOrders(server); + registerBinanceUsNewOrder(server) + registerBinanceUsTestOrder(server) + registerBinanceUsGetOrder(server) + registerBinanceUsCancelOrder(server) + registerBinanceUsCancelReplace(server) + registerBinanceUsCancelAllOpenOrders(server) + registerBinanceUsOpenOrders(server) + registerBinanceUsAllOrders(server) } diff --git a/src/tools/userdata-stream/index.ts b/src/tools/userdata-stream/index.ts index 07871924..9a80a953 100644 --- a/src/tools/userdata-stream/index.ts +++ b/src/tools/userdata-stream/index.ts @@ -2,33 +2,35 @@ // User Data Stream management for real-time account updates // These endpoints manage listen keys for WebSocket user data streams -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { makeSignedRequest, BINANCE_US_CONFIG } from "../../config/binanceUsClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { BINANCE_US_CONFIG, makeSignedRequest } from "../../config/binanceUsClient.js" /** * Register User Data Stream tools for Binance.US - * + * * User Data Streams provide real-time updates for: * - Account balance updates * - Order updates (new, filled, canceled, etc.) * - Position updates - * + * * Workflow: * 1. Create a listen key using binance_us_create_listen_key * 2. Connect to WebSocket: wss://stream.binance.us:9443/ws/ * 3. Keep-alive every 30 minutes using binance_us_keepalive_listen_key * 4. Close when done using binance_us_close_listen_key - * + * * Listen keys expire after 60 minutes without a keep-alive. */ export function registerUserDataStreamTools(server: McpServer) { - // ===================================================================== - // POST /api/v3/userDataStream - Create Listen Key - // ===================================================================== - server.tool( - "binance_us_create_listen_key", - `Create a new listen key for User Data Stream WebSocket connection. + // ===================================================================== + // POST /api/v3/userDataStream - Create Listen Key + // ===================================================================== + server.tool( + "binance_us_create_listen_key", + `Create a new listen key for User Data Stream WebSocket connection. The listen key is used to subscribe to real-time account updates via WebSocket. Connect to: ${BINANCE_US_CONFIG.WS_URL}/ws/ @@ -45,17 +47,18 @@ The stream sends updates for: - executionReport: Order/trade updates This endpoint requires API key but does NOT require signature.`, - {}, - async () => { - try { - // This endpoint only requires API key, not signature - // But we use makeSignedRequest since it adds the API key header - const response = await makeSignedRequest("POST", "/api/v3/userDataStream", {}); - - return { - content: [{ - type: "text", - text: `Listen key created successfully! + {}, + async () => { + try { + // This endpoint only requires API key, not signature + // But we use makeSignedRequest since it adds the API key header + const response = await makeSignedRequest("POST", "/api/v3/userDataStream", {}) + + return { + content: [ + { + type: "text", + text: `Listen key created successfully! Listen Key: ${response.listenKey} @@ -66,25 +69,27 @@ WebSocket URL: ${BINANCE_US_CONFIG.WS_URL}/ws/${response.listenKey} 2. Close the stream when done (use binance_us_close_listen_key) 3. The key expires after 60 minutes without keep-alive -Response: ${JSON.stringify(response, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to create listen key: ${errorMessage}` }], - isError: true - }; - } +Response: ${JSON.stringify(response, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to create listen key: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) - // ===================================================================== - // PUT /api/v3/userDataStream - Keep-alive Listen Key - // ===================================================================== - server.tool( - "binance_us_keepalive_listen_key", - `Extend the validity of a listen key by 60 minutes. + // ===================================================================== + // PUT /api/v3/userDataStream - Keep-alive Listen Key + // ===================================================================== + server.tool( + "binance_us_keepalive_listen_key", + `Extend the validity of a listen key by 60 minutes. ⚠️ IMPORTANT: - Call this every 30 minutes to prevent the stream from closing @@ -92,135 +97,143 @@ Response: ${JSON.stringify(response, null, 2)}` - This resets the 60-minute expiration timer This endpoint requires API key but does NOT require signature.`, - { - listenKey: z.string().describe("The listen key to keep alive") - }, - async ({ listenKey }) => { - try { - await makeSignedRequest("PUT", "/api/v3/userDataStream", { listenKey }); - - return { - content: [{ - type: "text", - text: `Listen key extended successfully! + { + listenKey: z.string().describe("The listen key to keep alive"), + }, + async ({ listenKey }) => { + try { + await makeSignedRequest("PUT", "/api/v3/userDataStream", { listenKey }) + + return { + content: [ + { + type: "text", + text: `Listen key extended successfully! Listen Key: ${listenKey} New expiration: 60 minutes from now -Remember to call this again in 30 minutes to maintain the connection.` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to extend listen key: ${errorMessage}` }], - isError: true - }; - } +Remember to call this again in 30 minutes to maintain the connection.`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to extend listen key: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) - // ===================================================================== - // DELETE /api/v3/userDataStream - Close Listen Key - // ===================================================================== - server.tool( - "binance_us_close_listen_key", - `Close a User Data Stream by invalidating the listen key. + // ===================================================================== + // DELETE /api/v3/userDataStream - Close Listen Key + // ===================================================================== + server.tool( + "binance_us_close_listen_key", + `Close a User Data Stream by invalidating the listen key. Use this when you're done receiving real-time updates. After closing, the WebSocket connection will be terminated. This endpoint requires API key but does NOT require signature.`, - { - listenKey: z.string().describe("The listen key to close/invalidate") - }, - async ({ listenKey }) => { - try { - await makeSignedRequest("DELETE", "/api/v3/userDataStream", { listenKey }); - - return { - content: [{ - type: "text", - text: `Listen key closed successfully! + { + listenKey: z.string().describe("The listen key to close/invalidate"), + }, + async ({ listenKey }) => { + try { + await makeSignedRequest("DELETE", "/api/v3/userDataStream", { listenKey }) + + return { + content: [ + { + type: "text", + text: `Listen key closed successfully! The User Data Stream has been terminated. Listen Key ${listenKey} is no longer valid. -To receive real-time updates again, create a new listen key.` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to close listen key: ${errorMessage}` }], - isError: true - }; - } +To receive real-time updates again, create a new listen key.`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to close listen key: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) - // ===================================================================== - // Informational tool about WebSocket streams - // ===================================================================== - server.tool( - "binance_us_websocket_info", - `Get information about available WebSocket streams on Binance.US. + // ===================================================================== + // Informational tool about WebSocket streams + // ===================================================================== + server.tool( + "binance_us_websocket_info", + `Get information about available WebSocket streams on Binance.US. Returns details about: - Market data streams (public) - User data streams (requires listen key) - Connection URLs and limits`, - {}, - async () => { - const info = { - baseUrl: BINANCE_US_CONFIG.WS_URL, - marketDataStreams: { - description: "Public market data streams (no authentication required)", - singleStream: `${BINANCE_US_CONFIG.WS_URL}/ws/`, - multipleStreams: `${BINANCE_US_CONFIG.WS_URL}/stream?streams=/`, - availableStreams: [ - "@aggTrade - Aggregate trade stream", - "@trade - Trade stream", - "@kline_ - Kline/candlestick stream", - "@miniTicker - Individual mini ticker", - "!miniTicker@arr - All market mini tickers", - "@ticker - Individual ticker", - "!ticker@arr - All market tickers", - "@ticker_ - Rolling window ticker (1h, 4h)", - "@bookTicker - Individual book ticker", - "@depth - Partial book depth (5, 10, 20)", - "@depth@100ms - Fast partial book depth", - "@depth - Diff depth stream", - "@depth@100ms - Fast diff depth stream" - ] - }, - userDataStream: { - description: "Private account/order updates (requires listen key)", - url: `${BINANCE_US_CONFIG.WS_URL}/ws/`, - events: [ - "outboundAccountPosition - Account balance changes", - "balanceUpdate - Deposits/withdrawals", - "executionReport - Order updates" - ], - notes: [ - "Use binance_us_create_listen_key to get a listen key", - "Keep-alive every 30 minutes", - "Keys expire after 60 minutes without keep-alive" - ] - }, - limits: { - maxConnections: 5, - maxStreamsPerConnection: 1024, - messageLimit: "5 messages per second per connection" - } - }; - - return { - content: [{ - type: "text", - text: `Binance.US WebSocket Information:\n\n${JSON.stringify(info, null, 2)}` - }] - }; - } - ); + {}, + async () => { + const info = { + baseUrl: BINANCE_US_CONFIG.WS_URL, + marketDataStreams: { + description: "Public market data streams (no authentication required)", + singleStream: `${BINANCE_US_CONFIG.WS_URL}/ws/`, + multipleStreams: `${BINANCE_US_CONFIG.WS_URL}/stream?streams=/`, + availableStreams: [ + "@aggTrade - Aggregate trade stream", + "@trade - Trade stream", + "@kline_ - Kline/candlestick stream", + "@miniTicker - Individual mini ticker", + "!miniTicker@arr - All market mini tickers", + "@ticker - Individual ticker", + "!ticker@arr - All market tickers", + "@ticker_ - Rolling window ticker (1h, 4h)", + "@bookTicker - Individual book ticker", + "@depth - Partial book depth (5, 10, 20)", + "@depth@100ms - Fast partial book depth", + "@depth - Diff depth stream", + "@depth@100ms - Fast diff depth stream", + ], + }, + userDataStream: { + description: "Private account/order updates (requires listen key)", + url: `${BINANCE_US_CONFIG.WS_URL}/ws/`, + events: [ + "outboundAccountPosition - Account balance changes", + "balanceUpdate - Deposits/withdrawals", + "executionReport - Order updates", + ], + notes: [ + "Use binance_us_create_listen_key to get a listen key", + "Keep-alive every 30 minutes", + "Keys expire after 60 minutes without keep-alive", + ], + }, + limits: { + maxConnections: 5, + maxStreamsPerConnection: 1024, + messageLimit: "5 messages per second per connection", + }, + } + + return { + content: [ + { + type: "text", + text: `Binance.US WebSocket Information:\n\n${JSON.stringify(info, null, 2)}`, + }, + ], + } + }, + ) } diff --git a/src/tools/wallet/index.ts b/src/tools/wallet/index.ts index ecd70ae0..a0cbec03 100644 --- a/src/tools/wallet/index.ts +++ b/src/tools/wallet/index.ts @@ -1,11 +1,13 @@ // src/tools/wallet/index.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod"; -import { makeSignedRequest } from "../../config/binanceUsClient.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" + +import { z } from "zod" + +import { makeSignedRequest } from "../../config/binanceUsClient.js" /** * Register all Wallet-related tools for Binance.US - * + * * Wallet endpoints provide access to: * - Asset configuration and network status * - Crypto withdrawals @@ -15,252 +17,291 @@ import { makeSignedRequest } from "../../config/binanceUsClient.js"; * - Deposit addresses */ export function registerWalletTools(server: McpServer) { - // ===================================================== - // binance_us_asset_config - // GET /sapi/v1/capital/config/getall - // ===================================================== - server.tool( - "binance_us_asset_config", - "Get details of all crypto assets including fees, withdrawal limits, and network status. Shows deposit/withdrawal enabled status per network.", - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), - }, - async ({ recvWindow }) => { - try { - const params: Record = {}; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await makeSignedRequest("GET", "/sapi/v1/capital/config/getall", params); - - return { - content: [{ - type: "text", - text: `Asset Configuration:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get asset config: ${errorMessage}` }], - isError: true - }; - } + // ===================================================== + // binance_us_asset_config + // GET /sapi/v1/capital/config/getall + // ===================================================== + server.tool( + "binance_us_asset_config", + "Get details of all crypto assets including fees, withdrawal limits, and network status. Shows deposit/withdrawal enabled status per network.", + { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ recvWindow }) => { + try { + const params: Record = {} + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await makeSignedRequest("GET", "/sapi/v1/capital/config/getall", params) + + return { + content: [ + { + type: "text", + text: `Asset Configuration:\n${JSON.stringify(data, null, 2)}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to get asset config: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================== + // binance_us_withdraw_crypto + // POST /sapi/v1/capital/withdraw/apply + // ===================================================== + server.tool( + "binance_us_withdraw_crypto", + "Submit a crypto withdrawal request. Requires withdrawal permission on API key. ⚠️ This action transfers funds OUT of your account - verify address carefully!", + { + coin: z.string().describe("Asset symbol, e.g., BTC, ETH, USDT"), + network: z + .string() + .describe( + "Withdrawal network, e.g., ERC20, BEP20, BTC. Ensure address type matches network!", + ), + address: z.string().describe("Withdrawal destination address"), + amount: z.number().describe("Withdrawal amount"), + addressTag: z.string().optional().describe("Memo/tag for coins like XRP, XMR, etc."), + withdrawOrderId: z + .string() + .optional() + .describe("Client ID for the withdrawal (for your reference)"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ coin, network, address, amount, addressTag, withdrawOrderId, recvWindow }) => { + try { + const params: Record = { + coin, + network, + address, + amount, + } + if (addressTag !== undefined) params.addressTag = addressTag + if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await makeSignedRequest("POST", "/sapi/v1/capital/withdraw/apply", params) + + return { + content: [ + { + type: "text", + text: `Withdrawal request submitted successfully!\nWithdrawal ID: ${data.id}\nCoin: ${coin}\nAmount: ${amount}\nNetwork: ${network}\nAddress: ${address}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to submit withdrawal: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================== + // binance_us_withdraw_fiat + // POST /sapi/v1/fiatpayment/withdraw/apply + // ===================================================== + server.tool( + "binance_us_withdraw_fiat", + "Submit a USD withdrawal request via BITGO. ⚠️ This action transfers USD OUT of your account!", + { + paymentAccount: z.string().describe("The account to withdraw funds to"), + amount: z.number().describe("USD amount to withdraw"), + paymentMethod: z + .literal("BITGO") + .default("BITGO") + .describe("Payment method (default: BITGO)"), + fiatCurrency: z.literal("USD").default("USD").describe("Fiat currency (default: USD)"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ paymentAccount, amount, paymentMethod, fiatCurrency, recvWindow }) => { + try { + const params: Record = { + paymentMethod: paymentMethod || "BITGO", + paymentAccount, + amount, + fiatCurrency: fiatCurrency || "USD", + } + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await makeSignedRequest("POST", "/sapi/v1/fiatpayment/withdraw/apply", params) + + return { + content: [ + { + type: "text", + text: `Fiat withdrawal submitted!\nOrder ID: ${data.orderId}\nChannel: ${data.channelCode}\nAmount: ${data.amount} ${data.currencyCode}\nStatus: ${data.orderStatus}`, + }, + ], + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) + + return { + content: [{ type: "text", text: `Failed to submit fiat withdrawal: ${errorMessage}` }], + isError: true, + } + } + }, + ) + + // ===================================================== + // binance_us_withdraw_history + // GET /sapi/v1/capital/withdraw/history + // ===================================================== + server.tool( + "binance_us_withdraw_history", + "Get crypto withdrawal history. Filter by coin, status, or time range.", + { + coin: z.string().optional().describe("Filter by coin symbol"), + withdrawOrderId: z.string().optional().describe("Filter by client withdrawal ID"), + status: z + .number() + .optional() + .describe( + "Status filter: 0=email sent, 1=canceled, 2=awaiting approval, 3=rejected, 4=processing, 5=failure, 6=completed", + ), + startTime: z.number().optional().describe("Start time in ms. Default: 90 days ago"), + endTime: z.number().optional().describe("End time in ms. Default: now"), + offset: z.number().optional().describe("Pagination offset. Default: 0"), + limit: z.number().optional().describe("Number of results. Default: 1000, Max: 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ coin, withdrawOrderId, status, startTime, endTime, offset, limit, recvWindow }) => { + try { + const params: Record = {} + if (coin !== undefined) params.coin = coin + if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId + if (status !== undefined) params.status = status + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (offset !== undefined) params.offset = offset + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await makeSignedRequest("GET", "/sapi/v1/capital/withdraw/history", params) + + return { + content: [ + { + type: "text", + text: `Withdrawal History:\n${JSON.stringify(data, null, 2)}`, + }, + ], } - ); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - // ===================================================== - // binance_us_withdraw_crypto - // POST /sapi/v1/capital/withdraw/apply - // ===================================================== - server.tool( - "binance_us_withdraw_crypto", - "Submit a crypto withdrawal request. Requires withdrawal permission on API key. ⚠️ This action transfers funds OUT of your account - verify address carefully!", - { - coin: z.string().describe("Asset symbol, e.g., BTC, ETH, USDT"), - network: z.string().describe("Withdrawal network, e.g., ERC20, BEP20, BTC. Ensure address type matches network!"), - address: z.string().describe("Withdrawal destination address"), - amount: z.number().describe("Withdrawal amount"), - addressTag: z.string().optional().describe("Memo/tag for coins like XRP, XMR, etc."), - withdrawOrderId: z.string().optional().describe("Client ID for the withdrawal (for your reference)"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), - }, - async ({ coin, network, address, amount, addressTag, withdrawOrderId, recvWindow }) => { - try { - const params: Record = { - coin, - network, - address, - amount - }; - if (addressTag !== undefined) params.addressTag = addressTag; - if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await makeSignedRequest("POST", "/sapi/v1/capital/withdraw/apply", params); - - return { - content: [{ - type: "text", - text: `Withdrawal request submitted successfully!\nWithdrawal ID: ${data.id}\nCoin: ${coin}\nAmount: ${amount}\nNetwork: ${network}\nAddress: ${address}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to submit withdrawal: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to get withdrawal history: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) + + // ===================================================== + // binance_us_deposit_history + // GET /sapi/v1/capital/deposit/hisrec + // ===================================================== + server.tool( + "binance_us_deposit_history", + "Get crypto deposit history. Filter by coin, status, or time range.", + { + coin: z.string().optional().describe("Filter by coin symbol"), + status: z + .number() + .optional() + .describe("Status filter: 0=pending, 1=success, 6=credited but cannot withdraw"), + startTime: z.number().optional().describe("Start time in ms. Default: 90 days ago"), + endTime: z.number().optional().describe("End time in ms. Default: now"), + offset: z.number().optional().describe("Pagination offset. Default: 0"), + limit: z.number().optional().describe("Number of results. Default: 1000, Max: 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { + try { + const params: Record = {} + if (coin !== undefined) params.coin = coin + if (status !== undefined) params.status = status + if (startTime !== undefined) params.startTime = startTime + if (endTime !== undefined) params.endTime = endTime + if (offset !== undefined) params.offset = offset + if (limit !== undefined) params.limit = limit + if (recvWindow !== undefined) params.recvWindow = recvWindow - // ===================================================== - // binance_us_withdraw_fiat - // POST /sapi/v1/fiatpayment/withdraw/apply - // ===================================================== - server.tool( - "binance_us_withdraw_fiat", - "Submit a USD withdrawal request via BITGO. ⚠️ This action transfers USD OUT of your account!", - { - paymentAccount: z.string().describe("The account to withdraw funds to"), - amount: z.number().describe("USD amount to withdraw"), - paymentMethod: z.literal("BITGO").default("BITGO").describe("Payment method (default: BITGO)"), - fiatCurrency: z.literal("USD").default("USD").describe("Fiat currency (default: USD)"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), - }, - async ({ paymentAccount, amount, paymentMethod, fiatCurrency, recvWindow }) => { - try { - const params: Record = { - paymentMethod: paymentMethod || "BITGO", - paymentAccount, - amount, - fiatCurrency: fiatCurrency || "USD" - }; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await makeSignedRequest("POST", "/sapi/v1/fiatpayment/withdraw/apply", params); - - return { - content: [{ - type: "text", - text: `Fiat withdrawal submitted!\nOrder ID: ${data.orderId}\nChannel: ${data.channelCode}\nAmount: ${data.amount} ${data.currencyCode}\nStatus: ${data.orderStatus}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to submit fiat withdrawal: ${errorMessage}` }], - isError: true - }; - } + const data = await makeSignedRequest("GET", "/sapi/v1/capital/deposit/hisrec", params) + + return { + content: [ + { + type: "text", + text: `Deposit History:\n${JSON.stringify(data, null, 2)}`, + }, + ], } - ); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - // ===================================================== - // binance_us_withdraw_history - // GET /sapi/v1/capital/withdraw/history - // ===================================================== - server.tool( - "binance_us_withdraw_history", - "Get crypto withdrawal history. Filter by coin, status, or time range.", - { - coin: z.string().optional().describe("Filter by coin symbol"), - withdrawOrderId: z.string().optional().describe("Filter by client withdrawal ID"), - status: z.number().optional().describe("Status filter: 0=email sent, 1=canceled, 2=awaiting approval, 3=rejected, 4=processing, 5=failure, 6=completed"), - startTime: z.number().optional().describe("Start time in ms. Default: 90 days ago"), - endTime: z.number().optional().describe("End time in ms. Default: now"), - offset: z.number().optional().describe("Pagination offset. Default: 0"), - limit: z.number().optional().describe("Number of results. Default: 1000, Max: 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), - }, - async ({ coin, withdrawOrderId, status, startTime, endTime, offset, limit, recvWindow }) => { - try { - const params: Record = {}; - if (coin !== undefined) params.coin = coin; - if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId; - if (status !== undefined) params.status = status; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (offset !== undefined) params.offset = offset; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await makeSignedRequest("GET", "/sapi/v1/capital/withdraw/history", params); - - return { - content: [{ - type: "text", - text: `Withdrawal History:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get withdrawal history: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to get deposit history: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) + + // ===================================================== + // binance_us_deposit_address + // GET /sapi/v1/capital/deposit/address + // ===================================================== + server.tool( + "binance_us_deposit_address", + "Get a deposit address for a specific crypto asset. Use this to receive funds into your Binance.US account.", + { + coin: z.string().describe("Coin symbol to get deposit address for, e.g., BTC, ETH"), + network: z + .string() + .optional() + .describe("Specific network to get address for, e.g., ERC20, BEP20"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, + async ({ coin, network, recvWindow }) => { + try { + const params: Record = { coin } + if (network !== undefined) params.network = network + if (recvWindow !== undefined) params.recvWindow = recvWindow + + const data = await makeSignedRequest("GET", "/sapi/v1/capital/deposit/address", params) - // ===================================================== - // binance_us_deposit_history - // GET /sapi/v1/capital/deposit/hisrec - // ===================================================== - server.tool( - "binance_us_deposit_history", - "Get crypto deposit history. Filter by coin, status, or time range.", - { - coin: z.string().optional().describe("Filter by coin symbol"), - status: z.number().optional().describe("Status filter: 0=pending, 1=success, 6=credited but cannot withdraw"), - startTime: z.number().optional().describe("Start time in ms. Default: 90 days ago"), - endTime: z.number().optional().describe("End time in ms. Default: now"), - offset: z.number().optional().describe("Pagination offset. Default: 0"), - limit: z.number().optional().describe("Number of results. Default: 1000, Max: 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), - }, - async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { - try { - const params: Record = {}; - if (coin !== undefined) params.coin = coin; - if (status !== undefined) params.status = status; - if (startTime !== undefined) params.startTime = startTime; - if (endTime !== undefined) params.endTime = endTime; - if (offset !== undefined) params.offset = offset; - if (limit !== undefined) params.limit = limit; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await makeSignedRequest("GET", "/sapi/v1/capital/deposit/hisrec", params); - - return { - content: [{ - type: "text", - text: `Deposit History:\n${JSON.stringify(data, null, 2)}` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get deposit history: ${errorMessage}` }], - isError: true - }; - } + return { + content: [ + { + type: "text", + text: `Deposit Address for ${coin}:\nAddress: ${data.address}\nTag/Memo: ${data.tag || "N/A"}\nURL: ${data.url || "N/A"}\n\n⚠️ Only send ${coin} to this address. Sending other assets may result in permanent loss.`, + }, + ], } - ); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error) - // ===================================================== - // binance_us_deposit_address - // GET /sapi/v1/capital/deposit/address - // ===================================================== - server.tool( - "binance_us_deposit_address", - "Get a deposit address for a specific crypto asset. Use this to receive funds into your Binance.US account.", - { - coin: z.string().describe("Coin symbol to get deposit address for, e.g., BTC, ETH"), - network: z.string().optional().describe("Specific network to get address for, e.g., ERC20, BEP20"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), - }, - async ({ coin, network, recvWindow }) => { - try { - const params: Record = { coin }; - if (network !== undefined) params.network = network; - if (recvWindow !== undefined) params.recvWindow = recvWindow; - - const data = await makeSignedRequest("GET", "/sapi/v1/capital/deposit/address", params); - - return { - content: [{ - type: "text", - text: `Deposit Address for ${coin}:\nAddress: ${data.address}\nTag/Memo: ${data.tag || "N/A"}\nURL: ${data.url || "N/A"}\n\n⚠️ Only send ${coin} to this address. Sending other assets may result in permanent loss.` - }] - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get deposit address: ${errorMessage}` }], - isError: true - }; - } + return { + content: [{ type: "text", text: `Failed to get deposit address: ${errorMessage}` }], + isError: true, } - ); + } + }, + ) } diff --git a/src/utils/logger.ts b/src/utils/logger.ts index 8aa8a671..83fa542c 100644 --- a/src/utils/logger.ts +++ b/src/utils/logger.ts @@ -6,7 +6,7 @@ const LOG_LEVELS: Record = { DEBUG: 0, INFO: 1, WARN: 2, - ERROR: 3 + ERROR: 3, } const currentLevel = (process.env.LOG_LEVEL as LogLevel) || "INFO" @@ -17,7 +17,8 @@ function shouldLog(level: LogLevel): boolean { function formatMessage(level: LogLevel, message: string, ...args: unknown[]): string { const timestamp = new Date().toISOString() - const formattedArgs = args.length > 0 ? " " + args.map(a => JSON.stringify(a)).join(" ") : "" + const formattedArgs = args.length > 0 ? " " + args.map((a) => JSON.stringify(a)).join(" ") : "" + return `[${timestamp}] [${level}] ${message}${formattedArgs}` } @@ -41,7 +42,7 @@ const Logger = { if (shouldLog("ERROR")) { console.error(formatMessage("ERROR", message, ...args)) } - } + }, } export default Logger From dffc150ca046fcebca25774d6e535be5848cdda5 Mon Sep 17 00:00:00 2001 From: netpoe Date: Tue, 10 Mar 2026 12:19:41 -0600 Subject: [PATCH 02/16] refactor: disable no-explicit-any rule in ESLint, update server handling in index.ts, and enhance SSE server type definitions --- eslint.config.js | 2 +- src/index.ts | 14 +++++++------- src/server/sse.ts | 32 +++++++++++++++++--------------- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 9cc2c5e7..8d43dbb0 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -42,7 +42,7 @@ export default tseslint.config( "error", { prefer: "type-imports", fixStyle: "separate-type-imports" }, ], - "@typescript-eslint/no-explicit-any": "warn", + "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-unused-vars": [ "error", { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }, diff --git a/src/index.ts b/src/index.ts index 10caa1f4..bc01295b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,6 @@ #!/usr/bin/env node import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { Server } from "http" import { startSSEServer } from "./server/sse.js" import { startStdioServer } from "./server/stdio.js" @@ -9,7 +10,6 @@ const args = process.argv.slice(2) // Transport mode flags const sseMode = args.includes("--sse") || args.includes("-s") -// Default to stdio mode (for Claude Desktop) function printUsage() { console.log(` @@ -42,21 +42,22 @@ async function main() { process.exit(0) } - let server: McpServer | undefined + let handle: McpServer | Server | undefined if (sseMode) { Logger.info("Starting in SSE mode") - server = await startSSEServer() + handle = await startSSEServer() } else { - // Default: stdio mode for Claude Desktop - server = await startStdioServer() + handle = await startStdioServer() } - if (!server) { + if (!handle) { Logger.error("Failed to start server") process.exit(1) } + const server = handle + const handleShutdown = async () => { if ("close" in server && typeof server.close === "function") { await server.close() @@ -64,7 +65,6 @@ async function main() { process.exit(0) } - // Handle process termination process.on("SIGINT", handleShutdown) process.on("SIGTERM", handleShutdown) } diff --git a/src/server/sse.ts b/src/server/sse.ts index 63389146..cf0a0e66 100644 --- a/src/server/sse.ts +++ b/src/server/sse.ts @@ -1,3 +1,5 @@ +import type { Server } from "http" + import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js" import cors from "cors" import express from "express" @@ -12,29 +14,27 @@ import "dotenv/config" const PORT = process.env.PORT || 3002 // Start the server in SSE mode -export const startSSEServer = async () => { +export const startSSEServer = async (): Promise => { try { const app = express() app.use(cors()) app.use(express.json()) - const server = startServer() - - // Store active transports + // Store active transports and their associated server instances const transports = new Map() - // SSE endpoint + // SSE endpoint — each connection gets its own McpServer instance app.get("/sse", async (req, res) => { - const sessionId = (req.query.sessionId as string) || crypto.randomUUID() - - Logger.info(`New SSE connection: ${sessionId}`) - + const server = startServer() const transport = new SSEServerTransport("/message", res) - transports.set(sessionId, transport) - res.on("close", () => { - Logger.info(`SSE connection closed: ${sessionId}`) - transports.delete(sessionId) + Logger.info(`New SSE connection: ${transport.sessionId}`) + transports.set(transport.sessionId, transport) + + res.on("close", async () => { + Logger.info(`SSE connection closed: ${transport.sessionId}`) + transports.delete(transport.sessionId) + await server.close() }) await server.connect(transport) @@ -59,13 +59,15 @@ export const startSSEServer = async () => { res.json({ status: "ok", mode: "sse" }) }) - app.listen(PORT, () => { + const httpServer = app.listen(PORT, () => { Logger.info(`Binance MCP Server running on SSE mode at http://localhost:${PORT}`) Logger.info(`SSE endpoint: http://localhost:${PORT}/sse`) }) - return server + return httpServer } catch (error) { Logger.error("Error starting Binance MCP SSE server:", error) + + return undefined } } From e85b264dabcca957aa1e1fecc121d652c1e160df Mon Sep 17 00:00:00 2001 From: netpoe Date: Tue, 10 Mar 2026 12:48:21 -0600 Subject: [PATCH 03/16] feat: add Binance Testnet support with environment variable configuration, update server descriptions, and enhance error handling for unsupported endpoints --- src/config/binanceClient.ts | 29 +++++++++--- src/config/client.ts | 4 +- src/config/testnet.ts | 90 +++++++++++++++++++++++++++++++++++++ src/index.ts | 4 ++ src/init.ts | 39 +++++++++++++--- src/server/base.ts | 14 +++--- 6 files changed, 159 insertions(+), 21 deletions(-) create mode 100644 src/config/testnet.ts diff --git a/src/config/binanceClient.ts b/src/config/binanceClient.ts index eac5dbb4..f21d638a 100644 --- a/src/config/binanceClient.ts +++ b/src/config/binanceClient.ts @@ -15,16 +15,19 @@ import { Pay } from "@binance/pay" import { Rebate } from "@binance/rebate" import { SimpleEarn } from "@binance/simple-earn" // src/config/binanceClient.ts -// Existing SDK packages import { Spot } from "@binance/spot" import { Staking } from "@binance/staking" import { SubAccount } from "@binance/sub-account" import { VIPLoan } from "@binance/vip-loan" import { Wallet } from "@binance/wallet" +import { assertNotTestnet, IS_TESTNET, URLS } from "./testnet.js" + +export { assertNotTestnet, IS_TESTNET } + const API_KEY = process.env.BINANCE_API_KEY ?? "" const API_SECRET = process.env.BINANCE_API_SECRET ?? "" -const BASE_URL = "https://api.binance.com" +const BASE_URL = URLS.SPOT_BASE_URL const configurationRestAPI = { apiKey: API_KEY, @@ -80,6 +83,13 @@ async function makeSignedRequest( endpoint: string, params: Record = {}, ): Promise { + if (IS_TESTNET && endpoint.startsWith("/sapi")) { + throw new Error( + `[Testnet] Endpoint ${endpoint} is not available on the Binance Spot Test Network. ` + + `Only /api endpoints are supported.`, + ) + } + const timestamp = Date.now() const queryParams = { ...params, timestamp } const queryString = new URLSearchParams( @@ -105,6 +115,13 @@ async function makeSignedRequest( } async function makePublicRequest(endpoint: string, params: Record = {}): Promise { + if (IS_TESTNET && endpoint.startsWith("/sapi")) { + throw new Error( + `[Testnet] Endpoint ${endpoint} is not available on the Binance Spot Test Network. ` + + `Only /api endpoints are supported.`, + ) + } + const queryString = new URLSearchParams( Object.fromEntries(Object.entries(params).map(([k, v]) => [k, String(v)])), ).toString() @@ -247,9 +264,8 @@ export const marginClient = { makeSignedRequest("GET", "/sapi/v1/margin/interestRateHistory", params), } -// Helper for Futures API with different base URLs -const FUTURES_USD_BASE_URL = "https://fapi.binance.com" -const FUTURES_COIN_BASE_URL = "https://dapi.binance.com" +const FUTURES_USD_BASE_URL = URLS.FUTURES_USD_BASE_URL +const FUTURES_COIN_BASE_URL = URLS.FUTURES_COIN_BASE_URL async function makeFuturesSignedRequest( baseUrl: string, @@ -522,8 +538,7 @@ export const subAccountApiClient = { makeSignedRequest("POST", "/sapi/v1/sub-account/subAccountApi/ipRestriction", params), } -// Options client wrapper -const OPTIONS_BASE_URL = "https://eapi.binance.com" +const OPTIONS_BASE_URL = URLS.OPTIONS_BASE_URL export const optionsClient = { // Market Data diff --git a/src/config/client.ts b/src/config/client.ts index 3e18250d..3b02518b 100644 --- a/src/config/client.ts +++ b/src/config/client.ts @@ -1,9 +1,11 @@ import { Algo } from "@binance/algo" import { Spot } from "@binance/connector-typescript" +import { URLS } from "./testnet.js" + const API_KEY = process.env.BINANCE_API_KEY const API_SECRET = process.env.BINANCE_API_SECRET -const BASE_URL = "https://api.binance.com" +const BASE_URL = URLS.SPOT_BASE_URL export const spotClient = new Spot(API_KEY, API_SECRET, { baseURL: BASE_URL }) export const algoClient = new Algo({ diff --git a/src/config/testnet.ts b/src/config/testnet.ts new file mode 100644 index 00000000..a81bbe38 --- /dev/null +++ b/src/config/testnet.ts @@ -0,0 +1,90 @@ +// src/config/testnet.ts +// Binance Testnet configuration +// Reference: https://testnet.binance.vision + +import Logger from "../utils/logger.js" + +export const IS_TESTNET = process.env.BINANCE_TESTNET === "true" + +// Spot Testnet — only /api endpoints are supported (NOT /sapi) +const TESTNET_SPOT_BASE_URL = "https://testnet.binance.vision" +const TESTNET_SPOT_WS_API_URL = "wss://ws-api.testnet.binance.vision/ws-api/v3" +const TESTNET_SPOT_WS_STREAM_URL = "wss://stream.testnet.binance.vision" + +// Futures Testnet — both USD-M (/fapi) and COIN-M (/dapi) share the same host +const TESTNET_FUTURES_BASE_URL = "https://testnet.binancefuture.com" + +// Production URLs +const PROD_SPOT_BASE_URL = "https://api.binance.com" +const PROD_SPOT_WS_API_URL = "wss://ws-api.binance.com/ws-api/v3" +const PROD_SPOT_WS_STREAM_URL = "wss://stream.binance.com" +const PROD_FUTURES_USD_BASE_URL = "https://fapi.binance.com" +const PROD_FUTURES_COIN_BASE_URL = "https://dapi.binance.com" +const PROD_OPTIONS_BASE_URL = "https://eapi.binance.com" + +export const URLS = { + SPOT_BASE_URL: IS_TESTNET ? TESTNET_SPOT_BASE_URL : PROD_SPOT_BASE_URL, + SPOT_WS_API_URL: IS_TESTNET ? TESTNET_SPOT_WS_API_URL : PROD_SPOT_WS_API_URL, + SPOT_WS_STREAM_URL: IS_TESTNET ? TESTNET_SPOT_WS_STREAM_URL : PROD_SPOT_WS_STREAM_URL, + FUTURES_USD_BASE_URL: IS_TESTNET ? TESTNET_FUTURES_BASE_URL : PROD_FUTURES_USD_BASE_URL, + FUTURES_COIN_BASE_URL: IS_TESTNET ? TESTNET_FUTURES_BASE_URL : PROD_FUTURES_COIN_BASE_URL, + // No testnet for options — always production + OPTIONS_BASE_URL: PROD_OPTIONS_BASE_URL, +} as const + +/** + * Endpoints using /sapi are NOT available on the Spot Test Network. + * This list of modules rely on /sapi and will not work in testnet mode. + */ +export const SAPI_ONLY_MODULES = [ + "Algo Trading", + "Auto-Invest", + "C2C (P2P)", + "Convert", + "Copy Trading", + "Crypto Loans", + "Dual Investment", + "Fiat", + "Gift Card", + "Margin", + "Mining", + "NFT", + "Pay", + "Portfolio Margin", + "Rebate", + "Simple Earn", + "Staking", + "Sub-Account", + "VIP Loan", + "Wallet", +] as const + +/** + * Throws a descriptive error when a /sapi endpoint is called in testnet mode. + */ +export function assertNotTestnet(moduleName: string): void { + if (IS_TESTNET) { + throw new Error( + `[Testnet] ${moduleName} is not available on the Binance Spot Test Network. ` + + `Only /api endpoints are supported. See https://testnet.binance.vision`, + ) + } +} + +/** + * Log testnet status on startup. + */ +export function logTestnetStatus(): void { + if (IS_TESTNET) { + Logger.info("=== BINANCE TESTNET MODE ===") + Logger.info(`Spot REST API: ${URLS.SPOT_BASE_URL}`) + Logger.info(`Spot WS API: ${URLS.SPOT_WS_API_URL}`) + Logger.info(`Spot WS Stream: ${URLS.SPOT_WS_STREAM_URL}`) + Logger.info(`Futures USD-M: ${URLS.FUTURES_USD_BASE_URL}`) + Logger.info(`Futures COIN-M: ${URLS.FUTURES_COIN_BASE_URL}`) + Logger.info(`Options: ${URLS.OPTIONS_BASE_URL} (no testnet available)`) + Logger.warn( + `The following modules use /sapi and are NOT available on testnet: ${SAPI_ONLY_MODULES.join(", ")}`, + ) + } +} diff --git a/src/index.ts b/src/index.ts index bc01295b..39e26e36 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,6 +2,7 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" import type { Server } from "http" +import { logTestnetStatus } from "./config/testnet.js" import { startSSEServer } from "./server/sse.js" import { startStdioServer } from "./server/stdio.js" import Logger from "./utils/logger.js" @@ -25,6 +26,7 @@ Environment Variables: PORT Server port for SSE mode (default: 3002) BINANCE_API_KEY Binance API key BINANCE_API_SECRET Binance API secret + BINANCE_TESTNET Set to "true" to use Binance Spot Test Network LOG_LEVEL Logging level (DEBUG, INFO, WARN, ERROR) Examples: @@ -42,6 +44,8 @@ async function main() { process.exit(0) } + logTestnetStatus() + let handle: McpServer | Server | undefined if (sseMode) { diff --git a/src/init.ts b/src/init.ts index eff41cbd..73ffd90b 100644 --- a/src/init.ts +++ b/src/init.ts @@ -35,6 +35,7 @@ const showBanner = () => { interface UserInputs { BINANCE_API_KEY: string BINANCE_API_SECRET: string + BINANCE_TESTNET: boolean } // Ask for credentials @@ -52,6 +53,12 @@ const getInputs = async (): Promise => { message: " 🔐 Enter your BINANCE API SECRET:", validate: (val: string) => (val.trim() === "" ? "BINANCE API SECRET is required!" : true), }, + { + type: "confirm", + name: "BINANCE_TESTNET", + message: "🧪 Use Binance Spot Test Network? (testnet.binance.vision)", + initial: false, + }, ] return (await prompts(questions, { onCancel })) as UserInputs @@ -61,10 +68,12 @@ const getInputs = async (): Promise => { const generateEnvFile = async ( BINANCE_API_KEY: string, BINANCE_API_SECRET: string, + BINANCE_TESTNET: boolean, ): Promise => { const envContent = ` BINANCE_API_KEY=${BINANCE_API_KEY} BINANCE_API_SECRET=${BINANCE_API_SECRET} +BINANCE_TESTNET=${BINANCE_TESTNET} `.trim() await fs.writeFile(".env", envContent) @@ -75,17 +84,24 @@ BINANCE_API_SECRET=${BINANCE_API_SECRET} const generateConfig = async ( BINANCE_API_KEY: string, BINANCE_API_SECRET: string, + BINANCE_TESTNET: boolean, ): Promise => { const indexPath = path.resolve(__dirname, "..", "build", "index.js") // one level up from cli/ + const env: Record = { + BINANCE_API_KEY: BINANCE_API_KEY, + BINANCE_API_SECRET: BINANCE_API_SECRET, + } + + if (BINANCE_TESTNET) { + env.BINANCE_TESTNET = "true" + } + return { "binance-mcp": { command: "bun", args: ["run", indexPath], - env: { - BINANCE_API_KEY: BINANCE_API_KEY, - BINANCE_API_SECRET: BINANCE_API_SECRET, - }, + env, disabled: false, autoApprove: [], }, @@ -152,11 +168,20 @@ const saveFallbackConfig = async (config: object): Promise => { const init = async () => { showBanner() - const { BINANCE_API_KEY, BINANCE_API_SECRET } = await getInputs() + const { BINANCE_API_KEY, BINANCE_API_SECRET, BINANCE_TESTNET } = await getInputs() + + await generateEnvFile(BINANCE_API_KEY, BINANCE_API_SECRET, BINANCE_TESTNET) - await generateEnvFile(BINANCE_API_KEY, BINANCE_API_SECRET) + if (BINANCE_TESTNET) { + console.log( + yellow( + "🧪 Testnet mode enabled — API calls will go to testnet.binance.vision. " + + "Only /api endpoints (spot trading & market data) are available.", + ), + ) + } - const config = await generateConfig(BINANCE_API_KEY, BINANCE_API_SECRET) + const config = await generateConfig(BINANCE_API_KEY, BINANCE_API_SECRET, BINANCE_TESTNET) const { setupClaude } = await prompts( { diff --git a/src/server/base.ts b/src/server/base.ts index df0289c3..1fc00d25 100644 --- a/src/server/base.ts +++ b/src/server/base.ts @@ -2,20 +2,22 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" import { registerBinance } from "../binance.js" +import { IS_TESTNET } from "../config/testnet.js" import Logger from "../utils/logger.js" -// Create and start the MCP server export const startServer = () => { try { - // Create a new MCP server instance + const name = IS_TESTNET ? "binance-mcp (TESTNET)" : "binance-mcp" + const description = IS_TESTNET + ? "MCP server for Binance Spot Test Network — only /api endpoints (spot trading & market data) are available" + : "MCP server for Binance exchange - spot trading, staking, wallet, NFT, pay, mining, and more" + const server = new McpServer({ - name: "binance-mcp", + name, version: "1.0.0", - description: - "MCP server for Binance exchange - spot trading, staking, wallet, NFT, pay, mining, and more", + description, }) - // Register all Binance modules registerBinance(server) return server From c5c0eb8ff41589b1812435dea68184e550154043 Mon Sep 17 00:00:00 2001 From: netpoe Date: Tue, 10 Mar 2026 12:54:31 -0600 Subject: [PATCH 04/16] fix: enable semicolons in Prettier config, enforce semicolon usage in ESLint, and update import statements across multiple files for consistency --- .prettierrc | 2 +- .vscode/settings.json | 8 + eslint.config.js | 1 + src/binance.ts | 74 +-- src/config/binanceClient.ts | 178 +++--- src/config/binanceUsClient.ts | 400 ++++++------ src/config/client.ts | 16 +- src/config/testnet.ts | 46 +- src/config/types.ts | 577 +++++++++--------- src/index.ts | 50 +- src/init.ts | 132 ++-- src/modules/algo/future-algo/TwapNewTrade.ts | 18 +- src/modules/algo/future-algo/VPNewTrade.ts | 18 +- .../algo/future-algo/cancelAlgoOrder.ts | 18 +- .../algo/future-algo/currentAlgoOpenOrders.ts | 18 +- .../algo/future-algo/historicalAlgoOrder.ts | 18 +- src/modules/algo/future-algo/index.ts | 26 +- src/modules/algo/future-algo/subOrders.ts | 18 +- src/modules/algo/index.ts | 12 +- .../algo/spot-algo/cancelOpenTWAPOrder.ts | 18 +- .../algo/spot-algo/currentAlgoOpenOrders.ts | 18 +- .../algo/spot-algo/historicalAlgoOrders.ts | 18 +- src/modules/algo/spot-algo/index.ts | 22 +- src/modules/algo/spot-algo/spotTWAPOrder.ts | 18 +- src/modules/algo/spot-algo/subOrders.ts | 18 +- src/modules/auto-invest/changePlanStatus.ts | 20 +- src/modules/auto-invest/createPlan.ts | 18 +- src/modules/auto-invest/editPlan.ts | 18 +- src/modules/auto-invest/getHistoryList.ts | 46 +- src/modules/auto-invest/getIndexInfo.ts | 38 +- .../getIndexLinkedPlanPositionDetails.ts | 50 +- .../auto-invest/getIndexUserSummary.ts | 30 +- src/modules/auto-invest/getPlanList.ts | 50 +- src/modules/auto-invest/getSourceAssetList.ts | 40 +- src/modules/auto-invest/getTargetAssetList.ts | 38 +- .../auto-invest/getTargetAssetRoiData.ts | 36 +- src/modules/auto-invest/index.ts | 6 +- src/modules/auto-invest/oneTimeTransaction.ts | 20 +- src/modules/auto-invest/rebalanceHistory.ts | 38 +- src/modules/auto-invest/redemption.ts | 18 +- src/modules/c2c/C2C/getAds.ts | 18 +- src/modules/c2c/C2C/getC2CTradeHistory.ts | 18 +- src/modules/c2c/index.ts | 8 +- src/modules/convert/index.ts | 12 +- src/modules/convert/market-data-api/index.ts | 10 +- .../market-data-api/listAllConvertPairs.ts | 18 +- .../queryOrderQuantityPrecisionPerAsset.ts | 18 +- src/modules/convert/trade-api/acceptQuote.ts | 18 +- .../convert/trade-api/cancelLimitOrder.ts | 18 +- .../trade-api/getConvertTradeHistory.ts | 18 +- src/modules/convert/trade-api/index.ts | 30 +- src/modules/convert/trade-api/orderStatus.ts | 18 +- .../convert/trade-api/placeLimitOrder.ts | 18 +- .../convert/trade-api/queryLimitOpenOrders.ts | 18 +- .../convert/trade-api/sendQuoteRequest.ts | 18 +- .../FutureCopyTrading-api/followTrader.ts | 18 +- .../FutureCopyTrading-api/getCopyOrders.ts | 18 +- .../FutureCopyTrading-api/getCopyPositions.ts | 18 +- .../getFollowingTraders.ts | 18 +- .../getFuturesLeadTraderStatus.ts | 18 +- .../getFuturesLeadTradingSymbolWhitelist.ts | 18 +- .../FutureCopyTrading-api/getLeadTraders.ts | 18 +- .../getTraderPerformance.ts | 18 +- .../getTraderPositions.ts | 18 +- .../getTraderSymbolStats.ts | 18 +- .../FutureCopyTrading-api/index.ts | 10 +- .../FutureCopyTrading-api/unfollowTrader.ts | 18 +- src/modules/copy-trading/index.ts | 8 +- .../crypto-loans/flexible/adjustLTV.ts | 18 +- src/modules/crypto-loans/flexible/borrow.ts | 18 +- .../crypto-loans/flexible/getBorrowHistory.ts | 18 +- .../flexible/getFlexibleCollateralAssets.ts | 18 +- .../flexible/getFlexibleLoanAssets.ts | 18 +- .../crypto-loans/flexible/getOngoingOrders.ts | 18 +- .../crypto-loans/flexible/getRepayHistory.ts | 18 +- src/modules/crypto-loans/flexible/index.ts | 34 +- src/modules/crypto-loans/flexible/repay.ts | 18 +- src/modules/crypto-loans/index.ts | 6 +- src/modules/dual-investment/index.ts | 12 +- .../getDualInvestmentProductList.ts | 18 +- .../dual-investment/market-api/index.ts | 6 +- .../trade-api/changeAutoCompoundStatus.ts | 18 +- .../trade-api/checkDualInvestmentAccounts.ts | 18 +- .../trade-api/getDualInvestmentPositions.ts | 18 +- .../dual-investment/trade-api/index.ts | 18 +- .../subscribeDualInvestmentProducts.ts | 18 +- .../fiat-api/getFiatDepositWithdrawHistory.ts | 18 +- .../fiat/fiat-api/getFiatPaymentsHistory.ts | 18 +- src/modules/fiat/index.ts | 12 +- src/modules/futures-coinm/index.ts | 6 +- src/modules/futures-usdm/index.ts | 6 +- src/modules/gift-card/index.ts | 6 +- src/modules/margin/index.ts | 6 +- src/modules/mining/index.ts | 56 +- src/modules/mining/mining-api/accountList.ts | 18 +- .../mining/mining-api/acquiringAlgorithm.ts | 16 +- .../mining/mining-api/acquiringCoinname.ts | 16 +- .../cancelHashrateResaleConfiguration.ts | 18 +- src/modules/mining/mining-api/earningsList.ts | 18 +- .../mining/mining-api/extraBonusList.ts | 18 +- .../mining/mining-api/hashrateResaleDetail.ts | 18 +- .../mining/mining-api/hashrateResaleList.ts | 18 +- .../mining-api/hashrateResaleRequest.ts | 18 +- .../mining/mining-api/miningAccountEarning.ts | 18 +- .../mining-api/requestForDetailMinerList.ts | 18 +- .../mining/mining-api/requestForMinerList.ts | 18 +- .../mining/mining-api/statisticList.ts | 18 +- src/modules/nft/index.ts | 20 +- src/modules/nft/nft-api/getNFTAsset.ts | 18 +- .../nft/nft-api/getNFTDepositHistory.ts | 18 +- .../nft/nft-api/getNFTTransactionHistory.ts | 18 +- .../nft/nft-api/getNFTWithdrawHistory.ts | 18 +- src/modules/options/account-api/getAccount.ts | 46 +- .../options/account-api/getBillHistory.ts | 40 +- .../options/account-api/getIncomeAsyn.ts | 18 +- .../options/account-api/getIncomeAsynId.ts | 30 +- .../options/account-api/getPosition.ts | 42 +- src/modules/options/account-api/index.ts | 22 +- src/modules/options/index.ts | 6 +- src/modules/options/market-api/depth.ts | 36 +- .../options/market-api/exchangeInfo.ts | 38 +- .../options/market-api/exerciseHistory.ts | 38 +- .../options/market-api/historicalTrades.ts | 32 +- src/modules/options/market-api/index.ts | 46 +- src/modules/options/market-api/indexPrice.ts | 36 +- src/modules/options/market-api/klines.ts | 36 +- src/modules/options/market-api/mark.ts | 50 +- src/modules/options/market-api/ping.ts | 16 +- src/modules/options/market-api/ticker.ts | 48 +- src/modules/options/market-api/time.ts | 18 +- src/modules/options/market-api/trades.ts | 32 +- src/modules/options/trade-api/batchOrders.ts | 36 +- .../options/trade-api/cancelAllOrders.ts | 18 +- .../options/trade-api/cancelBatchOrders.ts | 36 +- .../options/trade-api/cancelBySymbol.ts | 18 +- src/modules/options/trade-api/cancelOrder.ts | 20 +- .../options/trade-api/getHistoryOrders.ts | 42 +- .../options/trade-api/getOpenOrders.ts | 40 +- .../options/trade-api/getUserTrades.ts | 44 +- src/modules/options/trade-api/index.ts | 38 +- src/modules/options/trade-api/newOrder.ts | 18 +- .../options/userdata-api/createListenKey.ts | 16 +- .../options/userdata-api/deleteListenKey.ts | 18 +- src/modules/options/userdata-api/index.ts | 14 +- .../options/userdata-api/renewListenKey.ts | 18 +- src/modules/pay/index.ts | 8 +- src/modules/pay/pay-api/createOrder.ts | 18 +- src/modules/pay/pay-api/getHistory.ts | 18 +- src/modules/pay/pay-api/getPayTradeHistory.ts | 18 +- src/modules/pay/pay-api/queryOrder.ts | 18 +- .../account/getAccountInfo.ts | 34 +- .../portfolio-margin/account/getBalance.ts | 38 +- .../portfolio-margin/account/getCmAccount.ts | 44 +- .../portfolio-margin/account/getCmPosition.ts | 46 +- .../account/getMarginAccount.ts | 52 +- .../account/getMaxBorrowable.ts | 18 +- .../account/getMaxWithdraw.ts | 18 +- .../portfolio-margin/account/getUmAccount.ts | 44 +- .../portfolio-margin/account/getUmPosition.ts | 46 +- src/modules/portfolio-margin/account/index.ts | 38 +- .../cm-trade/cancelAllOrders.ts | 18 +- .../portfolio-margin/cm-trade/cancelOrder.ts | 20 +- .../cm-trade/changeLeverage.ts | 18 +- .../cm-trade/changeMarginType.ts | 18 +- .../portfolio-margin/cm-trade/getAllOrders.ts | 38 +- .../cm-trade/getOpenOrders.ts | 38 +- .../portfolio-margin/cm-trade/getOrder.ts | 38 +- .../cm-trade/getUserTrades.ts | 44 +- .../portfolio-margin/cm-trade/index.ts | 38 +- .../portfolio-margin/cm-trade/newOrder.ts | 18 +- src/modules/portfolio-margin/index.ts | 6 +- .../margin-trade/cancelAllOrders.ts | 18 +- .../margin-trade/cancelOrder.ts | 20 +- .../margin-trade/getAllOrders.ts | 36 +- .../margin-trade/getOpenOrders.ts | 38 +- .../portfolio-margin/margin-trade/getOrder.ts | 36 +- .../margin-trade/getUserTrades.ts | 42 +- .../portfolio-margin/margin-trade/index.ts | 38 +- .../margin-trade/marginLoan.ts | 18 +- .../margin-trade/marginRepay.ts | 18 +- .../portfolio-margin/margin-trade/newOrder.ts | 18 +- .../um-trade/cancelAllOrders.ts | 18 +- .../portfolio-margin/um-trade/cancelOrder.ts | 20 +- .../um-trade/changeLeverage.ts | 18 +- .../um-trade/changeMarginType.ts | 18 +- .../portfolio-margin/um-trade/getAllOrders.ts | 36 +- .../um-trade/getOpenOrders.ts | 38 +- .../portfolio-margin/um-trade/getOrder.ts | 38 +- .../um-trade/getUserTrades.ts | 42 +- .../portfolio-margin/um-trade/index.ts | 38 +- .../portfolio-margin/um-trade/newOrder.ts | 18 +- .../userdata/createListenKey.ts | 16 +- .../userdata/deleteListenKey.ts | 18 +- .../portfolio-margin/userdata/index.ts | 14 +- .../userdata/renewListenKey.ts | 18 +- src/modules/rebate/index.ts | 8 +- .../rebate-api/getSpotRebateHistoryRecords.ts | 18 +- .../account-api/getFlexibleProductPosition.ts | 18 +- src/modules/simple-earn/account-api/index.ts | 10 +- .../simpleEarnFlexibleProductList.ts | 18 +- src/modules/simple-earn/account/getAccount.ts | 18 +- .../account/getCollateralRecord.ts | 18 +- .../simple-earn/account/getRewardRecord.ts | 18 +- src/modules/simple-earn/account/index.ts | 14 +- src/modules/simple-earn/earn-api/index.ts | 10 +- .../earn-api/redeemFlexibleProduct.ts | 22 +- .../earn-api/subscribeFlexibleProduct.ts | 18 +- .../flexible/getFlexiblePosition.ts | 18 +- .../flexible/getFlexibleProductList.ts | 18 +- .../getFlexibleSubscriptionPreview.ts | 18 +- .../simple-earn/flexible/getRateHistory.ts | 18 +- .../flexible/getRedemptionRecord.ts | 18 +- .../flexible/getSubscriptionRecord.ts | 18 +- src/modules/simple-earn/flexible/index.ts | 34 +- .../simple-earn/flexible/redeemFlexible.ts | 18 +- .../simple-earn/flexible/subscribeFlexible.ts | 18 +- src/modules/simple-earn/index.ts | 12 +- .../locked/getLockedPersonalQuota.ts | 18 +- .../simple-earn/locked/getLockedPosition.ts | 18 +- .../locked/getLockedProductList.ts | 18 +- .../locked/getLockedSubscriptionPreview.ts | 18 +- .../simple-earn/locked/getRedemptionRecord.ts | 18 +- .../locked/getSubscriptionRecord.ts | 18 +- src/modules/simple-earn/locked/index.ts | 38 +- .../simple-earn/locked/redeemLocked.ts | 18 +- .../simple-earn/locked/setAutoSubscribe.ts | 18 +- .../simple-earn/locked/subscribeLocked.ts | 18 +- .../spot/account-api/accountCommission.ts | 22 +- src/modules/spot/account-api/getAccount.ts | 25 +- src/modules/spot/account-api/index.ts | 26 +- src/modules/spot/account-api/myAllocations.ts | 30 +- .../spot/account-api/myPreventedMatches.ts | 30 +- src/modules/spot/account-api/myTrades.ts | 32 +- .../spot/account-api/rateLimitOrder.ts | 22 +- src/modules/spot/general-api/exchangeInfo.ts | 30 +- src/modules/spot/general-api/index.ts | 14 +- src/modules/spot/general-api/ping.ts | 16 +- src/modules/spot/general-api/time.ts | 18 +- src/modules/spot/index.ts | 24 +- src/modules/spot/market-api/aggTrades.ts | 28 +- src/modules/spot/market-api/avgPrice.ts | 18 +- src/modules/spot/market-api/depth.ts | 22 +- src/modules/spot/market-api/getTrades.ts | 22 +- .../spot/market-api/historicalTrades.ts | 24 +- src/modules/spot/market-api/index.ts | 50 +- src/modules/spot/market-api/klines.ts | 26 +- src/modules/spot/market-api/ticker.ts | 28 +- src/modules/spot/market-api/ticker24hr.ts | 26 +- .../spot/market-api/tickerBookTicker.ts | 26 +- src/modules/spot/market-api/tickerPrice.ts | 26 +- .../spot/market-api/tickerTradingDay.ts | 26 +- src/modules/spot/market-api/uiKlines.ts | 26 +- src/modules/spot/trade-api/allOrders.ts | 28 +- .../spot/trade-api/deleteOpenOrders.ts | 18 +- src/modules/spot/trade-api/deleteOrder.ts | 24 +- src/modules/spot/trade-api/getOpenOrders.ts | 22 +- src/modules/spot/trade-api/getOrder.ts | 24 +- src/modules/spot/trade-api/index.ts | 34 +- src/modules/spot/trade-api/newOrder.ts | 34 +- src/modules/spot/trade-api/openOrderList.ts | 22 +- src/modules/spot/trade-api/orderOco.ts | 32 +- .../deleteUserDataStream.ts | 18 +- src/modules/spot/userdatastream-api/index.ts | 14 +- .../userdatastream-api/newUserDataStream.ts | 16 +- .../userdatastream-api/putUserDataStream.ts | 18 +- .../ETH-staking-api/ethStakingAccount.ts | 18 +- .../getCurrentEthStakingQuota.ts | 18 +- .../getEthRedemptionHistory.ts | 18 +- .../ETH-staking-api/getEthStakingHistory.ts | 18 +- .../ETH-staking-api/getWbethRateHistory.ts | 18 +- .../ETH-staking-api/getWbethRewardsHistory.ts | 18 +- .../ETH-staking-api/getWbethUnwrapHistory.ts | 18 +- .../ETH-staking-api/getWbethWrapHistory.ts | 18 +- src/modules/staking/ETH-staking-api/index.ts | 46 +- .../staking/ETH-staking-api/redeemEth.ts | 18 +- .../ETH-staking-api/subscribeEthStaking.ts | 18 +- .../staking/ETH-staking-api/wrapBeth.ts | 18 +- .../SOL-staking-api/claimBoostRewards.ts | 18 +- .../SOL-staking-api/getBnsolRateHistory.ts | 18 +- .../SOL-staking-api/getBnsolRewardsHistory.ts | 18 +- .../SOL-staking-api/getBoostRewardsHistory.ts | 18 +- .../getSolRedemptionHistory.ts | 18 +- .../SOL-staking-api/getSolStakingHistory.ts | 18 +- .../getSolStakingQuotaDetails.ts | 18 +- .../SOL-staking-api/getUnclaimedRewards.ts | 18 +- src/modules/staking/SOL-staking-api/index.ts | 46 +- .../staking/SOL-staking-api/redeemSol.ts | 18 +- .../SOL-staking-api/solStakingAccount.ts | 18 +- .../SOL-staking-api/subscribeSolStaking.ts | 18 +- src/modules/staking/index.ts | 12 +- src/modules/sub-account/index.ts | 6 +- src/modules/vip-loan/index.ts | 16 +- .../market-api/getBorrowInterestRate.ts | 18 +- .../market-api/getCollateralAssetData.ts | 18 +- .../market-api/getLoanableAssetsData.ts | 18 +- src/modules/vip-loan/market-api/index.ts | 14 +- src/modules/vip-loan/trade-api/index.ts | 14 +- .../vip-loan/trade-api/vipLoanBorrow.ts | 18 +- .../vip-loan/trade-api/vipLoanRenew.ts | 18 +- .../vip-loan/trade-api/vipLoanRepay.ts | 18 +- .../checkVIPLoanCollateralAccount.ts | 18 +- .../getVIPLoanOngoingOrders.ts | 18 +- .../vip-loan/userInformation-api/index.ts | 14 +- .../queryApplicationStatus.ts | 18 +- .../account-api/accountApiTradingStatus.ts | 22 +- src/modules/wallet/account-api/accountInfo.ts | 22 +- .../wallet/account-api/accountStatus.ts | 22 +- .../account-api/dailyAccountSnapshot.ts | 28 +- .../account-api/disableFastWithdrawSwitch.ts | 22 +- .../account-api/enableFastWithdrawSwitch.ts | 22 +- .../wallet/account-api/getApiKeyPermission.ts | 22 +- src/modules/wallet/account-api/index.ts | 30 +- src/modules/wallet/asset-api/assetDetail.ts | 24 +- .../wallet/asset-api/assetDividendRecord.ts | 30 +- src/modules/wallet/asset-api/dustTransfer.ts | 22 +- src/modules/wallet/asset-api/dustlog.ts | 26 +- src/modules/wallet/asset-api/fundingWallet.ts | 26 +- .../getAssetsThatCanBeConvertedIntoBnb.ts | 22 +- .../getCloudMiningPaymentAndRefundHistory.ts | 26 +- .../wallet/asset-api/getOpenSymbolList.ts | 16 +- src/modules/wallet/asset-api/index.ts | 62 +- .../asset-api/queryUserDelegationHistory.ts | 26 +- .../queryUserUniversalTransferHistory.ts | 34 +- .../asset-api/queryUserWalletBalance.ts | 22 +- ...ggleBnbBurnOnSpotTradeAndMarginInterest.ts | 26 +- src/modules/wallet/asset-api/tradeFee.ts | 24 +- src/modules/wallet/asset-api/userAsset.ts | 24 +- .../wallet/asset-api/userUniversalTransfer.ts | 26 +- .../wallet/capital-api/allCoinsInformation.ts | 22 +- .../wallet/capital-api/depositAddress.ts | 24 +- .../wallet/capital-api/depositHistory.ts | 34 +- .../fetchDepositAddressListWithNetwork.ts | 24 +- .../capital-api/fetchWithdrawAddressList.ts | 16 +- src/modules/wallet/capital-api/index.ts | 34 +- .../oneClickArrivalDepositApply.ts | 24 +- src/modules/wallet/capital-api/withdraw.ts | 34 +- .../wallet/capital-api/withdrawHistory.ts | 36 +- src/modules/wallet/index.ts | 24 +- .../getSymbolsDelistScheduleForSpot.ts | 16 +- src/modules/wallet/others-api/index.ts | 10 +- src/modules/wallet/others-api/systemStatus.ts | 16 +- .../wallet/travel-rule-api/brokerWithdraw.ts | 28 +- .../depositHistoryTravelRule.ts | 34 +- src/modules/wallet/travel-rule-api/index.ts | 34 +- .../travel-rule-api/onboardedVaspList.ts | 16 +- .../submitDepositQuestionnaire.ts | 22 +- .../submitDepositQuestionnaireTravelRule.ts | 22 +- .../travel-rule-api/withdrawHistoryV1.ts | 34 +- .../travel-rule-api/withdrawHistoryV2.ts | 34 +- .../travel-rule-api/withdrawTravelRule.ts | 30 +- src/server/base.ts | 24 +- src/server/sse.ts | 74 +-- src/server/stdio.ts | 34 +- src/tools/account/index.ts | 90 +-- .../binance-algo/future-algo/TwapNewTrade.ts | 18 +- .../binance-algo/future-algo/VPNewTrade.ts | 18 +- .../future-algo/cancelAlgoOrder.ts | 18 +- .../future-algo/currentAlgoOpenOrders.ts | 18 +- .../future-algo/historicalAlgoOrder.ts | 18 +- src/tools/binance-algo/future-algo/index.ts | 26 +- .../binance-algo/future-algo/subOrders.ts | 18 +- src/tools/binance-algo/index.ts | 10 +- .../spot-algo/cancelOpenTWAPOrder.ts | 18 +- .../spot-algo/currentAlgoOpenOrders.ts | 18 +- .../spot-algo/historicalAlgoOrders.ts | 18 +- src/tools/binance-algo/spot-algo/index.ts | 22 +- .../binance-algo/spot-algo/spotTWAPOrder.ts | 18 +- src/tools/binance-algo/spot-algo/subOrders.ts | 18 +- .../changeIndexPlanStatus.ts | 18 +- .../binance-auto-invest/changePlanStatus.ts | 20 +- src/tools/binance-auto-invest/createPlan.ts | 22 +- src/tools/binance-auto-invest/editPlan.ts | 32 +- .../binance-auto-invest/getHistoryList.ts | 18 +- src/tools/binance-auto-invest/getIndexInfo.ts | 18 +- .../getIndexLinkedPlanPositionDetails.ts | 18 +- .../getIndexLinkedPlanPositionList.ts | 20 +- .../getIndexLinkedPlanRebalanceHistory.ts | 28 +- .../getIndexUserSummary.ts | 18 +- .../binance-auto-invest/getOneTimePlans.ts | 22 +- src/tools/binance-auto-invest/getPlanList.ts | 22 +- .../binance-auto-invest/getSourceAssetList.ts | 28 +- .../getSubscriptionHistory.ts | 34 +- .../binance-auto-invest/getTargetAssetList.ts | 26 +- .../binance-auto-invest/getTargetAssetROI.ts | 20 +- .../getTargetAssetRoiData.ts | 18 +- src/tools/binance-auto-invest/index.ts | 50 +- .../binance-auto-invest/oneTimeTransaction.ts | 18 +- .../binance-auto-invest/rebalanceHistory.ts | 18 +- .../redeemIndexLinkedPlan.ts | 22 +- src/tools/binance-auto-invest/redemption.ts | 18 +- .../binance-c2c/C2C/getC2CTradeHistory.ts | 18 +- src/tools/binance-c2c/index.ts | 6 +- src/tools/binance-convert/index.ts | 10 +- .../binance-convert/market-data-api/index.ts | 10 +- .../market-data-api/listAllConvertPairs.ts | 18 +- .../queryOrderQuantityPrecisionPerAsset.ts | 18 +- .../binance-convert/trade-api/acceptQuote.ts | 18 +- .../trade-api/cancelLimitOrder.ts | 18 +- .../trade-api/getConvertTradeHistory.ts | 18 +- src/tools/binance-convert/trade-api/index.ts | 30 +- .../binance-convert/trade-api/orderStatus.ts | 18 +- .../trade-api/placeLimitOrder.ts | 18 +- .../trade-api/queryLimitOpenOrders.ts | 18 +- .../trade-api/sendQuoteRequest.ts | 18 +- .../FutureCopyTrading-api/followTrader.ts | 18 +- .../FutureCopyTrading-api/getCopyOrders.ts | 18 +- .../FutureCopyTrading-api/getCopyPositions.ts | 18 +- .../getFollowingTraders.ts | 18 +- .../getFuturesLeadTraderStatus.ts | 18 +- .../getFuturesLeadTradingSymbolWhitelist.ts | 18 +- .../FutureCopyTrading-api/getLeadTraders.ts | 18 +- .../getTraderPerformance.ts | 18 +- .../FutureCopyTrading-api/index.ts | 10 +- .../FutureCopyTrading-api/unfollowTrader.ts | 18 +- src/tools/binance-copy-trading/index.ts | 6 +- .../fixed-api/adjustLTV.ts | 20 +- .../binance-crypto-loans/fixed-api/borrow.ts | 20 +- .../fixed-api/checkCollateralRate.ts | 18 +- .../fixed-api/customizeMarginCall.ts | 18 +- .../fixed-api/getBorrowHistory.ts | 18 +- .../fixed-api/getFixedCollateralData.ts | 18 +- .../fixed-api/getFixedLoanData.ts | 18 +- .../fixed-api/getOngoingOrders.ts | 18 +- .../fixed-api/getRepayHistory.ts | 18 +- .../binance-crypto-loans/fixed-api/index.ts | 42 +- .../binance-crypto-loans/fixed-api/repay.ts | 18 +- .../flexible-api/adjustLTV.ts | 20 +- .../flexible-api/borrow.ts | 20 +- .../flexible-api/getBorrowHistory.ts | 18 +- .../getFlexibleCollateralAssets.ts | 18 +- .../flexible-api/getFlexibleLoanAssets.ts | 18 +- .../flexible-api/getOngoingOrders.ts | 18 +- .../flexible-api/getRepayHistory.ts | 18 +- .../flexible-api/index.ts | 34 +- .../flexible-api/repay.ts | 18 +- .../flexibleLoanAdjustLTV.ts | 20 +- .../flexibleLoanBorrow.ts | 24 +- .../flexibleLoanBorrowHistory.ts | 32 +- .../flexibleLoanCollateralAssets.ts | 22 +- .../flexibleLoanLTVAdjustmentHistory.ts | 32 +- .../flexibleLoanLoanableAssets.ts | 18 +- .../flexibleLoanOngoingOrders.ts | 28 +- .../binance-crypto-loans/flexibleLoanRepay.ts | 24 +- .../flexibleLoanRepayHistory.ts | 32 +- .../getCollateralAssetsData.ts | 24 +- .../getCollateralRepayRate.ts | 20 +- .../getLoanableAssetsData.ts | 24 +- src/tools/binance-crypto-loans/index.ts | 50 +- src/tools/binance-dual-investment/index.ts | 10 +- .../getDualInvestmentProductList.ts | 18 +- .../market-api/index.ts | 6 +- .../trade-api/changeAutoCompoundStatus.ts | 18 +- .../trade-api/checkDualInvestmentAccounts.ts | 18 +- .../trade-api/getDualInvestmentPositions.ts | 18 +- .../trade-api/index.ts | 18 +- .../subscribeDualInvestmentProducts.ts | 18 +- .../fiat-api/getFiatDepositWithdrawHistory.ts | 18 +- .../fiat-api/getFiatPaymentsHistory.ts | 18 +- src/tools/binance-fiat/index.ts | 10 +- .../account-api/account.ts | 18 +- .../account-api/adlQuantile.ts | 18 +- .../account-api/balance.ts | 18 +- .../account-api/commissionRate.ts | 18 +- .../account-api/forceOrders.ts | 18 +- .../account-api/income.ts | 18 +- .../account-api/index.ts | 42 +- .../account-api/leverageBracket.ts | 18 +- .../account-api/positionMode.ts | 20 +- .../account-api/positionRisk.ts | 18 +- .../account-api/userTrades.ts | 18 +- src/tools/binance-futures-coinm/account.ts | 16 +- .../binance-futures-coinm/adlQuantile.ts | 20 +- src/tools/binance-futures-coinm/aggTrades.ts | 26 +- src/tools/binance-futures-coinm/allOrders.ts | 30 +- src/tools/binance-futures-coinm/balance.ts | 16 +- .../binance-futures-coinm/batchOrders.ts | 16 +- src/tools/binance-futures-coinm/bookTicker.ts | 22 +- .../binance-futures-coinm/cancelAllOrders.ts | 16 +- .../cancelBatchOrders.ts | 22 +- .../binance-futures-coinm/cancelOrder.ts | 16 +- .../binance-futures-coinm/commissionRate.ts | 16 +- .../binance-futures-coinm/continuousKlines.ts | 24 +- src/tools/binance-futures-coinm/depth.ts | 20 +- .../binance-futures-coinm/exchangeInfo.ts | 14 +- .../binance-futures-coinm/forceOrders.ts | 28 +- .../binance-futures-coinm/fundingRate.ts | 26 +- src/tools/binance-futures-coinm/getOrder.ts | 16 +- .../binance-futures-coinm/historicalTrades.ts | 22 +- src/tools/binance-futures-coinm/income.ts | 28 +- src/tools/binance-futures-coinm/index.ts | 158 ++--- .../binance-futures-coinm/indexPriceKlines.ts | 24 +- src/tools/binance-futures-coinm/klines.ts | 24 +- src/tools/binance-futures-coinm/leverage.ts | 16 +- src/tools/binance-futures-coinm/listenKey.ts | 34 +- src/tools/binance-futures-coinm/marginType.ts | 16 +- .../binance-futures-coinm/markPriceKlines.ts | 24 +- .../market-api/aggTrades.ts | 18 +- .../market-api/bookTicker.ts | 18 +- .../market-api/continuousKlines.ts | 18 +- .../binance-futures-coinm/market-api/depth.ts | 18 +- .../market-api/exchangeInfo.ts | 18 +- .../market-api/fundingRate.ts | 18 +- .../market-api/historicalTrades.ts | 18 +- .../binance-futures-coinm/market-api/index.ts | 74 +-- .../market-api/indexPriceKlines.ts | 18 +- .../market-api/klines.ts | 18 +- .../market-api/markPriceKlines.ts | 18 +- .../market-api/openInterest.ts | 18 +- .../market-api/openInterestHist.ts | 18 +- .../binance-futures-coinm/market-api/ping.ts | 16 +- .../market-api/premiumIndex.ts | 18 +- .../market-api/ticker24hr.ts | 18 +- .../market-api/tickerPrice.ts | 18 +- .../binance-futures-coinm/market-api/time.ts | 16 +- .../market-api/trades.ts | 18 +- src/tools/binance-futures-coinm/newOrder.ts | 16 +- .../binance-futures-coinm/openInterest.ts | 16 +- src/tools/binance-futures-coinm/openOrders.ts | 16 +- src/tools/binance-futures-coinm/ping.ts | 14 +- .../binance-futures-coinm/positionMargin.ts | 20 +- .../binance-futures-coinm/positionMode.ts | 16 +- .../binance-futures-coinm/positionRisk.ts | 16 +- .../binance-futures-coinm/premiumIndex.ts | 20 +- src/tools/binance-futures-coinm/ticker24hr.ts | 22 +- .../binance-futures-coinm/tickerPrice.ts | 22 +- src/tools/binance-futures-coinm/time.ts | 14 +- .../trade-api/allOrders.ts | 18 +- .../trade-api/batchOrders.ts | 22 +- .../trade-api/cancelAllOrders.ts | 18 +- .../trade-api/cancelBatchOrders.ts | 20 +- .../trade-api/cancelOrder.ts | 20 +- .../trade-api/changeLeverage.ts | 18 +- .../trade-api/changeMarginType.ts | 18 +- .../trade-api/changePositionMode.ts | 20 +- .../trade-api/countdownCancelAll.ts | 18 +- .../trade-api/getAllOrders.ts | 22 +- .../trade-api/getOrder.ts | 20 +- .../binance-futures-coinm/trade-api/index.ts | 58 +- .../trade-api/modifyIsolatedPositionMargin.ts | 20 +- .../trade-api/newOrder.ts | 18 +- .../trade-api/openOrder.ts | 20 +- .../trade-api/openOrders.ts | 18 +- src/tools/binance-futures-coinm/trades.ts | 20 +- src/tools/binance-futures-coinm/userTrades.ts | 32 +- .../userdatastream-api/closeListenKey.ts | 18 +- .../userdatastream-api/createListenKey.ts | 18 +- .../userdatastream-api/index.ts | 14 +- .../userdatastream-api/keepAliveListenKey.ts | 18 +- .../account-api/account.ts | 18 +- .../account-api/adlQuantile.ts | 18 +- .../account-api/apiTradingStatus.ts | 18 +- .../account-api/balance.ts | 18 +- .../account-api/commissionRate.ts | 18 +- .../account-api/downloadId.ts | 18 +- .../account-api/forceOrders.ts | 18 +- .../account-api/income.ts | 18 +- .../binance-futures-usdm/account-api/index.ts | 66 +- .../account-api/leverage.ts | 18 +- .../account-api/leverageBracket.ts | 18 +- .../account-api/marginType.ts | 18 +- .../account-api/multiAssetsMode.ts | 18 +- .../account-api/positionMargin.ts | 30 +- .../account-api/positionMode.ts | 18 +- .../account-api/positionRisk.ts | 18 +- .../account-api/userTrades.ts | 18 +- src/tools/binance-futures-usdm/account.ts | 14 +- src/tools/binance-futures-usdm/adlQuantile.ts | 20 +- src/tools/binance-futures-usdm/aggTrades.ts | 26 +- src/tools/binance-futures-usdm/allOrders.ts | 26 +- src/tools/binance-futures-usdm/balance.ts | 14 +- src/tools/binance-futures-usdm/batchOrders.ts | 16 +- src/tools/binance-futures-usdm/bookTicker.ts | 20 +- .../binance-futures-usdm/cancelAllOrders.ts | 16 +- .../binance-futures-usdm/cancelBatchOrders.ts | 22 +- src/tools/binance-futures-usdm/cancelOrder.ts | 22 +- .../binance-futures-usdm/commissionRate.ts | 16 +- .../binance-futures-usdm/continuousKlines.ts | 24 +- src/tools/binance-futures-usdm/depth.ts | 20 +- .../binance-futures-usdm/exchangeInfo.ts | 14 +- src/tools/binance-futures-usdm/forceOrders.ts | 28 +- src/tools/binance-futures-usdm/fundingRate.ts | 26 +- src/tools/binance-futures-usdm/getOrder.ts | 22 +- .../binance-futures-usdm/historicalTrades.ts | 22 +- src/tools/binance-futures-usdm/income.ts | 28 +- src/tools/binance-futures-usdm/index.ts | 162 ++--- .../binance-futures-usdm/indexPriceKlines.ts | 24 +- src/tools/binance-futures-usdm/klines.ts | 24 +- src/tools/binance-futures-usdm/leverage.ts | 16 +- src/tools/binance-futures-usdm/listenKey.ts | 34 +- src/tools/binance-futures-usdm/marginType.ts | 16 +- .../binance-futures-usdm/markPriceKlines.ts | 24 +- .../market-api/aggTrades.ts | 18 +- .../market-api/assetIndex.ts | 18 +- .../market-api/continuousKlines.ts | 18 +- .../binance-futures-usdm/market-api/depth.ts | 18 +- .../market-api/exchangeInfo.ts | 16 +- .../market-api/fundingInfo.ts | 16 +- .../market-api/fundingRate.ts | 18 +- .../market-api/globalLongShortAccountRatio.ts | 18 +- .../market-api/historicalTrades.ts | 18 +- .../binance-futures-usdm/market-api/index.ts | 106 ++-- .../market-api/indexInfo.ts | 18 +- .../market-api/indexPriceKlines.ts | 18 +- .../binance-futures-usdm/market-api/klines.ts | 18 +- .../market-api/lvtKlines.ts | 18 +- .../market-api/markPriceKlines.ts | 18 +- .../market-api/openInterest.ts | 18 +- .../market-api/openInterestHist.ts | 18 +- .../binance-futures-usdm/market-api/ping.ts | 16 +- .../market-api/premiumIndex.ts | 18 +- .../market-api/takerLongShortRatio.ts | 18 +- .../market-api/ticker24hr.ts | 18 +- .../market-api/tickerBookTicker.ts | 18 +- .../market-api/tickerPrice.ts | 18 +- .../binance-futures-usdm/market-api/time.ts | 16 +- .../market-api/topLongShortAccountRatio.ts | 18 +- .../market-api/topLongShortPositionRatio.ts | 18 +- .../binance-futures-usdm/market-api/trades.ts | 18 +- .../binance-futures-usdm/multiAssetsMode.ts | 16 +- src/tools/binance-futures-usdm/newOrder.ts | 44 +- .../binance-futures-usdm/openInterest.ts | 16 +- src/tools/binance-futures-usdm/openOrders.ts | 20 +- src/tools/binance-futures-usdm/ping.ts | 14 +- .../binance-futures-usdm/positionMargin.ts | 20 +- .../binance-futures-usdm/positionMode.ts | 16 +- .../binance-futures-usdm/positionRisk.ts | 20 +- .../binance-futures-usdm/premiumIndex.ts | 20 +- src/tools/binance-futures-usdm/ticker24hr.ts | 20 +- src/tools/binance-futures-usdm/tickerPrice.ts | 20 +- src/tools/binance-futures-usdm/time.ts | 14 +- .../trade-api/allOrders.ts | 16 +- .../trade-api/batchOrders.ts | 26 +- .../trade-api/cancelAllOpenOrders.ts | 16 +- .../trade-api/cancelAllOrders.ts | 18 +- .../trade-api/cancelBatchOrders.ts | 28 +- .../trade-api/cancelOrder.ts | 20 +- .../trade-api/changeLeverage.ts | 18 +- .../trade-api/changeMarginType.ts | 18 +- .../trade-api/changeMultiAssetsMode.ts | 20 +- .../trade-api/changePositionMode.ts | 20 +- .../trade-api/countdownCancelAll.ts | 20 +- .../trade-api/getAllOrders.ts | 20 +- .../trade-api/getOpenOrder.ts | 20 +- .../trade-api/getOpenOrders.ts | 22 +- .../trade-api/getOrder.ts | 20 +- .../binance-futures-usdm/trade-api/index.ts | 70 +-- .../trade-api/modifyIsolatedPositionMargin.ts | 20 +- .../trade-api/modifyOrder.ts | 20 +- .../trade-api/newOrder.ts | 18 +- .../trade-api/openOrder.ts | 18 +- .../trade-api/openOrders.ts | 16 +- .../trade-api/positionMarginHistory.ts | 18 +- src/tools/binance-futures-usdm/trades.ts | 20 +- src/tools/binance-futures-usdm/userTrades.ts | 28 +- .../userdatastream-api/closeListenKey.ts | 18 +- .../userdatastream-api/createListenKey.ts | 18 +- .../userdatastream-api/index.ts | 14 +- .../userdatastream-api/keepAliveListenKey.ts | 18 +- src/tools/binance-gift-card/buyCode.ts | 20 +- src/tools/binance-gift-card/createCode.ts | 20 +- .../binance-gift-card/createDualTokenCode.ts | 22 +- .../createDualTokenGiftCard.ts | 18 +- src/tools/binance-gift-card/createGiftCard.ts | 18 +- src/tools/binance-gift-card/getTokenLimit.ts | 20 +- src/tools/binance-gift-card/index.ts | 30 +- src/tools/binance-gift-card/redeemCode.ts | 22 +- .../redeemDualTokenGiftCard.ts | 18 +- src/tools/binance-gift-card/redeemGiftCard.ts | 18 +- src/tools/binance-gift-card/rsaPublicKey.ts | 20 +- src/tools/binance-gift-card/tokenLimit.ts | 18 +- src/tools/binance-gift-card/verify.ts | 20 +- src/tools/binance-gift-card/verifyGiftCard.ts | 24 +- .../cross-margin-api/crossMarginAccount.ts | 16 +- .../cross-margin-api/crossMarginAllAssets.ts | 22 +- .../cross-margin-api/crossMarginAllOrders.ts | 16 +- .../crossMarginAvailableInventory.ts | 16 +- .../cross-margin-api/crossMarginBorrow.ts | 16 +- .../crossMarginCancelAllOrders.ts | 16 +- .../crossMarginCancelOrder.ts | 16 +- .../crossMarginCapitalFlow.ts | 16 +- .../cross-margin-api/crossMarginDelist.ts | 16 +- .../cross-margin-api/crossMarginDustLog.ts | 16 +- .../cross-margin-api/crossMarginFee.ts | 16 +- .../crossMarginForceLiquidationRec.ts | 16 +- .../crossMarginInterestHistory.ts | 16 +- .../crossMarginInterestRateHistory.ts | 16 +- .../cross-margin-api/crossMarginLoanRecord.ts | 16 +- .../crossMarginMaxBorrowable.ts | 16 +- .../crossMarginMaxTransferable.ts | 16 +- .../cross-margin-api/crossMarginMyTrades.ts | 16 +- .../cross-margin-api/crossMarginNewOrder.ts | 16 +- .../cross-margin-api/crossMarginOpenOrders.ts | 16 +- .../cross-margin-api/crossMarginPairs.ts | 16 +- .../cross-margin-api/crossMarginPriceIndex.ts | 16 +- .../cross-margin-api/crossMarginRepay.ts | 16 +- .../crossMarginRepayRecord.ts | 16 +- .../crossMarginSmallLiabilityExchange.ts | 16 +- ...rossMarginSmallLiabilityExchangeHistory.ts | 16 +- .../cross-margin-api/crossMarginTransfer.ts | 16 +- .../binance-margin/cross-margin-api/index.ts | 106 ++-- src/tools/binance-margin/index.ts | 10 +- .../disableIsolatedMarginAccount.ts | 18 +- .../enableIsolatedMarginAccount.ts | 18 +- .../isolated-margin-api/getBnbBurnStatus.ts | 16 +- .../isolated-margin-api/index.ts | 58 +- .../isolatedMarginAccount.ts | 16 +- .../isolatedMarginAccountLimit.ts | 16 +- .../isolatedMarginAllOrders.ts | 16 +- .../isolatedMarginAllPairs.ts | 16 +- .../isolatedMarginAllSymbols.ts | 18 +- .../isolatedMarginBorrow.ts | 18 +- .../isolatedMarginCancelOrder.ts | 16 +- .../isolated-margin-api/isolatedMarginFee.ts | 16 +- .../isolatedMarginMyTrades.ts | 16 +- .../isolatedMarginNewOrder.ts | 16 +- .../isolatedMarginOpenOrders.ts | 16 +- .../isolated-margin-api/isolatedMarginPair.ts | 16 +- .../isolatedMarginRepay.ts | 18 +- .../isolatedMarginSymbol.ts | 18 +- .../isolatedMarginTierData.ts | 16 +- .../isolatedMarginTransfer.ts | 16 +- .../isolatedMarginTransferHistory.ts | 18 +- .../isolated-margin-api/toggleBnbBurn.ts | 16 +- .../binance-margin/margin-order-api/index.ts | 22 +- .../margin-order-api/marginCancelOco.ts | 20 +- .../margin-order-api/marginGetAllOco.ts | 18 +- .../margin-order-api/marginGetOco.ts | 20 +- .../margin-order-api/marginGetOpenOco.ts | 18 +- .../margin-order-api/marginNewOco.ts | 18 +- src/tools/binance-mining/index.ts | 54 +- .../binance-mining/mining-api/accountList.ts | 18 +- .../mining-api/acquiringAlgorithm.ts | 16 +- .../mining-api/acquiringCoinname.ts | 16 +- .../cancelHashrateResaleConfiguration.ts | 18 +- .../binance-mining/mining-api/earningsList.ts | 18 +- .../mining-api/extraBonusList.ts | 18 +- .../mining-api/hashrateResaleDetail.ts | 18 +- .../mining-api/hashrateResaleList.ts | 18 +- .../mining-api/hashrateResaleRequest.ts | 18 +- .../mining-api/miningAccountEarning.ts | 18 +- .../mining-api/requestForDetailMinerList.ts | 18 +- .../mining-api/requestForMinerList.ts | 18 +- .../mining-api/statisticList.ts | 18 +- src/tools/binance-nft/index.ts | 18 +- src/tools/binance-nft/nft-api/getNFTAsset.ts | 18 +- .../nft-api/getNFTDepositHistory.ts | 18 +- .../nft-api/getNFTTransactionHistory.ts | 18 +- .../nft-api/getNFTWithdrawHistory.ts | 18 +- src/tools/binance-options/account.ts | 14 +- src/tools/binance-options/batchOrders.ts | 18 +- src/tools/binance-options/bill.ts | 28 +- src/tools/binance-options/cancelAllOrders.ts | 18 +- .../binance-options/cancelBatchOrders.ts | 22 +- src/tools/binance-options/cancelOrder.ts | 22 +- src/tools/binance-options/depth.ts | 20 +- src/tools/binance-options/exchangeInfo.ts | 20 +- src/tools/binance-options/exerciseHistory.ts | 26 +- src/tools/binance-options/exerciseRecord.ts | 26 +- src/tools/binance-options/getOrder.ts | 22 +- src/tools/binance-options/historicalTrades.ts | 22 +- src/tools/binance-options/historyOrders.ts | 26 +- src/tools/binance-options/index.ts | 110 ++-- src/tools/binance-options/indexPrice.ts | 18 +- src/tools/binance-options/klines.ts | 24 +- src/tools/binance-options/listenKey.ts | 36 +- src/tools/binance-options/mark.ts | 20 +- src/tools/binance-options/newOrder.ts | 30 +- src/tools/binance-options/openInterest.ts | 18 +- src/tools/binance-options/openOrders.ts | 20 +- src/tools/binance-options/ping.ts | 14 +- src/tools/binance-options/position.ts | 20 +- src/tools/binance-options/ticker.ts | 20 +- src/tools/binance-options/time.ts | 14 +- src/tools/binance-options/trades.ts | 20 +- src/tools/binance-options/userTrades.ts | 28 +- src/tools/binance-pay/index.ts | 6 +- .../binance-pay/pay-api/getPayTradeHistory.ts | 18 +- .../binance-portfolio-margin/bnbTransfer.ts | 20 +- .../changeAutoRepayFutures.ts | 20 +- .../fundAutoCollection.ts | 20 +- .../fundCollection.ts | 20 +- .../getAccountBalance.ts | 22 +- .../getAutoRepayFuturesStatus.ts | 20 +- .../getCollateralRate.ts | 20 +- .../getPortfolioMarginAccount.ts | 20 +- .../getPortfolioMarginAssetIndexPrice.ts | 22 +- .../getPortfolioMarginAssetLeverage.ts | 20 +- .../getPortfolioMarginBankruptcyLoanAmount.ts | 20 +- .../getPortfolioMarginInterestHistory.ts | 28 +- src/tools/binance-portfolio-margin/index.ts | 58 +- .../repayFuturesNegativeBalance.ts | 20 +- .../repayPortfolioMarginBankruptcyLoan.ts | 20 +- src/tools/binance-rebate/index.ts | 6 +- .../rebate-api/getSpotRebateHistoryRecords.ts | 18 +- .../account-api/getFlexibleProductPosition.ts | 18 +- .../binance-simple-earn/account-api/index.ts | 10 +- .../simpleEarnFlexibleProductList.ts | 18 +- .../binance-simple-earn/earn-api/index.ts | 10 +- .../earn-api/redeemFlexibleProduct.ts | 22 +- .../earn-api/subscribeFlexibleProduct.ts | 18 +- src/tools/binance-simple-earn/index.ts | 10 +- .../account-api/accountCommission.ts | 22 +- .../binance-spot/account-api/getAccount.ts | 25 +- src/tools/binance-spot/account-api/index.ts | 26 +- .../binance-spot/account-api/myAllocations.ts | 30 +- .../account-api/myPreventedMatches.ts | 30 +- .../binance-spot/account-api/myTrades.ts | 32 +- .../account-api/rateLimitOrder.ts | 22 +- .../binance-spot/general-api/exchangeInfo.ts | 30 +- src/tools/binance-spot/general-api/index.ts | 14 +- src/tools/binance-spot/general-api/ping.ts | 16 +- src/tools/binance-spot/general-api/time.ts | 18 +- src/tools/binance-spot/index.ts | 22 +- .../binance-spot/market-api/aggTrades.ts | 28 +- src/tools/binance-spot/market-api/avgPrice.ts | 18 +- src/tools/binance-spot/market-api/depth.ts | 22 +- .../binance-spot/market-api/getTrades.ts | 22 +- .../market-api/historicalTrades.ts | 24 +- src/tools/binance-spot/market-api/index.ts | 50 +- src/tools/binance-spot/market-api/klines.ts | 26 +- src/tools/binance-spot/market-api/ticker.ts | 28 +- .../binance-spot/market-api/ticker24hr.ts | 26 +- .../market-api/tickerBookTicker.ts | 26 +- .../binance-spot/market-api/tickerPrice.ts | 26 +- .../market-api/tickerTradingDay.ts | 26 +- src/tools/binance-spot/market-api/uiKlines.ts | 26 +- src/tools/binance-spot/trade-api/allOrders.ts | 28 +- .../trade-api/deleteOpenOrders.ts | 18 +- .../binance-spot/trade-api/deleteOrder.ts | 24 +- .../binance-spot/trade-api/getOpenOrders.ts | 22 +- src/tools/binance-spot/trade-api/getOrder.ts | 24 +- src/tools/binance-spot/trade-api/index.ts | 34 +- src/tools/binance-spot/trade-api/newOrder.ts | 34 +- .../binance-spot/trade-api/openOrderList.ts | 22 +- src/tools/binance-spot/trade-api/orderOco.ts | 32 +- .../deleteUserDataStream.ts | 18 +- .../binance-spot/userdatastream-api/index.ts | 14 +- .../userdatastream-api/newUserDataStream.ts | 16 +- .../userdatastream-api/putUserDataStream.ts | 18 +- .../ETH-staking-api/ethStakingAccount.ts | 18 +- .../getCurrentEthStakingQuota.ts | 18 +- .../getEthRedemptionHistory.ts | 18 +- .../ETH-staking-api/getEthStakingHistory.ts | 18 +- .../ETH-staking-api/getWbethRateHistory.ts | 18 +- .../ETH-staking-api/getWbethRewardsHistory.ts | 18 +- .../ETH-staking-api/getWbethUnwrapHistory.ts | 18 +- .../ETH-staking-api/getWbethWrapHistory.ts | 18 +- .../binance-staking/ETH-staking-api/index.ts | 46 +- .../ETH-staking-api/redeemEth.ts | 18 +- .../ETH-staking-api/subscribeEthStaking.ts | 18 +- .../ETH-staking-api/wrapBeth.ts | 18 +- .../SOL-staking-api/claimBoostRewards.ts | 18 +- .../SOL-staking-api/getBnsolRateHistory.ts | 18 +- .../SOL-staking-api/getBnsolRewardsHistory.ts | 18 +- .../SOL-staking-api/getBoostRewardsHistory.ts | 18 +- .../getSolRedemptionHistory.ts | 18 +- .../SOL-staking-api/getSolStakingHistory.ts | 18 +- .../getSolStakingQuotaDetails.ts | 18 +- .../SOL-staking-api/getUnclaimedRewards.ts | 18 +- .../binance-staking/SOL-staking-api/index.ts | 46 +- .../SOL-staking-api/redeemSol.ts | 18 +- .../SOL-staking-api/solStakingAccount.ts | 18 +- .../SOL-staking-api/subscribeSolStaking.ts | 18 +- src/tools/binance-staking/index.ts | 10 +- .../assets-api/getFuturesAssetsSummary.ts | 18 +- .../assets-api/getFuturesPositionRisk.ts | 18 +- .../assets-api/getMarginAssetsSummary.ts | 18 +- .../assets-api/getSpotAssetsSummary.ts | 18 +- .../assets-api/getSubAccountAssets.ts | 18 +- .../binance-sub-account/assets-api/index.ts | 22 +- src/tools/binance-sub-account/createApiKey.ts | 24 +- .../createVirtualSubAccount.ts | 20 +- src/tools/binance-sub-account/deleteApiKey.ts | 20 +- .../deposit-api/getDepositAddress.ts | 18 +- .../deposit-api/getDepositHistory.ts | 18 +- .../binance-sub-account/deposit-api/index.ts | 10 +- .../binance-sub-account/enableFutures.ts | 20 +- src/tools/binance-sub-account/enableMargin.ts | 20 +- .../getApiKeyIpRestriction.ts | 20 +- .../getSubAccountAssets.ts | 20 +- .../getSubAccountDepositAddress.ts | 22 +- .../getSubAccountDepositHistory.ts | 32 +- .../getSubAccountFuturesPositionRisk.ts | 22 +- .../getSubAccountFuturesSummary.ts | 22 +- .../binance-sub-account/getSubAccountList.ts | 28 +- .../getSubAccountMarginSummary.ts | 22 +- .../getSubAccountSpotSummary.ts | 26 +- .../getSubAccountStatus.ts | 22 +- .../getSubAccountTransferHistory.ts | 30 +- .../getUniversalTransferHistory.ts | 32 +- src/tools/binance-sub-account/index.ts | 86 +-- .../management-api/createSubAccount.ts | 18 +- .../management-api/enableFutures.ts | 18 +- .../management-api/enableMargin.ts | 18 +- .../getSubAccountApiPermission.ts | 18 +- .../management-api/getSubAccountList.ts | 18 +- .../management-api/getSubAccountStatus.ts | 18 +- .../management-api/index.ts | 26 +- .../transfer-api/futuresTransfer.ts | 18 +- .../transfer-api/getTransferHistory.ts | 18 +- .../binance-sub-account/transfer-api/index.ts | 22 +- .../transfer-api/transferToMaster.ts | 18 +- .../transfer-api/transferToSubAccount.ts | 18 +- .../transfer-api/universalTransfer.ts | 18 +- .../binance-sub-account/transferToMaster.ts | 20 +- .../transferToSubAccount.ts | 20 +- .../binance-sub-account/universalTransfer.ts | 26 +- .../updateIpRestriction.ts | 22 +- src/tools/binance-vip-loan/index.ts | 14 +- .../market-api/getBorrowInterestRate.ts | 18 +- .../market-api/getCollateralAssetData.ts | 18 +- .../market-api/getLoanableAssetsData.ts | 18 +- .../binance-vip-loan/market-api/index.ts | 14 +- src/tools/binance-vip-loan/trade-api/index.ts | 14 +- .../trade-api/vipLoanBorrow.ts | 18 +- .../trade-api/vipLoanRenew.ts | 18 +- .../trade-api/vipLoanRepay.ts | 18 +- .../checkVIPLoanCollateralAccount.ts | 18 +- .../getVIPLoanOngoingOrders.ts | 18 +- .../userInformation-api/index.ts | 14 +- .../queryApplicationStatus.ts | 18 +- .../account-api/accountApiTradingStatus.ts | 22 +- .../binance-wallet/account-api/accountInfo.ts | 22 +- .../account-api/accountStatus.ts | 22 +- .../account-api/dailyAccountSnapshot.ts | 28 +- .../account-api/disableFastWithdrawSwitch.ts | 22 +- .../account-api/enableFastWithdrawSwitch.ts | 22 +- .../account-api/getApiKeyPermission.ts | 22 +- src/tools/binance-wallet/account-api/index.ts | 30 +- .../binance-wallet/asset-api/assetDetail.ts | 24 +- .../asset-api/assetDividendRecord.ts | 30 +- .../binance-wallet/asset-api/dustTransfer.ts | 22 +- src/tools/binance-wallet/asset-api/dustlog.ts | 26 +- .../binance-wallet/asset-api/fundingWallet.ts | 26 +- .../getAssetsThatCanBeConvertedIntoBnb.ts | 22 +- .../getCloudMiningPaymentAndRefundHistory.ts | 26 +- .../asset-api/getOpenSymbolList.ts | 16 +- src/tools/binance-wallet/asset-api/index.ts | 62 +- .../asset-api/queryUserDelegationHistory.ts | 26 +- .../queryUserUniversalTransferHistory.ts | 34 +- .../asset-api/queryUserWalletBalance.ts | 22 +- ...ggleBnbBurnOnSpotTradeAndMarginInterest.ts | 26 +- .../binance-wallet/asset-api/tradeFee.ts | 24 +- .../binance-wallet/asset-api/userAsset.ts | 24 +- .../asset-api/userUniversalTransfer.ts | 26 +- .../capital-api/allCoinsInformation.ts | 22 +- .../capital-api/depositAddress.ts | 24 +- .../capital-api/depositHistory.ts | 34 +- .../fetchDepositAddressListWithNetwork.ts | 24 +- .../capital-api/fetchWithdrawAddressList.ts | 16 +- src/tools/binance-wallet/capital-api/index.ts | 34 +- .../oneClickArrivalDepositApply.ts | 24 +- .../binance-wallet/capital-api/withdraw.ts | 34 +- .../capital-api/withdrawHistory.ts | 36 +- src/tools/binance-wallet/index.ts | 22 +- .../getSymbolsDelistScheduleForSpot.ts | 16 +- src/tools/binance-wallet/others-api/index.ts | 10 +- .../binance-wallet/others-api/systemStatus.ts | 16 +- .../travel-rule-api/brokerWithdraw.ts | 28 +- .../depositHistoryTravelRule.ts | 34 +- .../binance-wallet/travel-rule-api/index.ts | 34 +- .../travel-rule-api/onboardedVaspList.ts | 16 +- .../submitDepositQuestionnaire.ts | 22 +- .../submitDepositQuestionnaireTravelRule.ts | 22 +- .../travel-rule-api/withdrawHistoryV1.ts | 34 +- .../travel-rule-api/withdrawHistoryV2.ts | 34 +- .../travel-rule-api/withdrawTravelRule.ts | 30 +- src/tools/binanceAccountInfo.ts | 28 +- src/tools/binanceOrderBook.ts | 16 +- src/tools/binanceSpotPlaceOrder.ts | 20 +- ...nanceTimeWeightedAveragePriceFutureAlgo.ts | 18 +- src/tools/credit-line/index.ts | 114 ++-- src/tools/creditline/index.ts | 86 +-- src/tools/custodial-solution/index.ts | 158 ++--- src/tools/custodial/index.ts | 206 +++---- src/tools/general/index.ts | 62 +- src/tools/market/index.ts | 242 ++++---- src/tools/otc/index.ts | 66 +- src/tools/staking/index.ts | 66 +- src/tools/subaccount/index.ts | 122 ++-- src/tools/trade/index.ts | 18 +- src/tools/trade/oco.ts | 212 +++---- src/tools/trade/orders.ts | 346 +++++------ src/tools/userdata-stream/index.ts | 42 +- src/tools/wallet/index.ts | 122 ++-- src/utils/json.ts | 3 + src/utils/logger.ts | 26 +- 987 files changed, 12389 insertions(+), 12366 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 src/utils/json.ts diff --git a/.prettierrc b/.prettierrc index 80b05da9..672d96f2 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,5 +1,5 @@ { - "semi": false, + "semi": true, "singleQuote": false, "trailingComma": "all", "printWidth": 100, diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..ee9373a9 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,8 @@ +{ + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.fixAll.eslint": "explicit" + }, + "eslint.useFlatConfig": true +} diff --git a/eslint.config.js b/eslint.config.js index 8d43dbb0..fd991e9a 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -42,6 +42,7 @@ export default tseslint.config( "error", { prefer: "type-imports", fixStyle: "separate-type-imports" }, ], + "@stylistic/semi": ["error", "always"], "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-unused-vars": [ "error", diff --git a/src/binance.ts b/src/binance.ts index 67a519d3..a68d1bf8 100644 --- a/src/binance.ts +++ b/src/binance.ts @@ -1,27 +1,27 @@ // src/binance.ts // Central registration file for all Binance modules -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceAlgoTools } from "./modules/algo/index.js" -import { registerBinanceC2CTradeHistoryTools } from "./modules/c2c/index.js" -import { registerBinanceConvertTools } from "./modules/convert/index.js" -import { registerBinanceCopyTradingTools } from "./modules/copy-trading/index.js" -import { registerBinanceDualInvestmentTools } from "./modules/dual-investment/index.js" -import { registerBinanceFiatDepositWithdrawHistoryTools } from "./modules/fiat/index.js" -import { registerGiftCard } from "./modules/gift-card/index.js" -import { registerBinanceMiningTools } from "./modules/mining/index.js" -import { registerBinanceNFTTools } from "./modules/nft/index.js" -import { registerBinancePayTools } from "./modules/pay/index.js" -import { registerPortfolioMargin } from "./modules/portfolio-margin/index.js" -import { registerBinanceRebateTools } from "./modules/rebate/index.js" -import { registerBinanceSimpleEarnTools } from "./modules/simple-earn/index.js" +import { registerBinanceAlgoTools } from "./modules/algo/index.js"; +import { registerBinanceC2CTradeHistoryTools } from "./modules/c2c/index.js"; +import { registerBinanceConvertTools } from "./modules/convert/index.js"; +import { registerBinanceCopyTradingTools } from "./modules/copy-trading/index.js"; +import { registerBinanceDualInvestmentTools } from "./modules/dual-investment/index.js"; +import { registerBinanceFiatDepositWithdrawHistoryTools } from "./modules/fiat/index.js"; +import { registerGiftCard } from "./modules/gift-card/index.js"; +import { registerBinanceMiningTools } from "./modules/mining/index.js"; +import { registerBinanceNFTTools } from "./modules/nft/index.js"; +import { registerBinancePayTools } from "./modules/pay/index.js"; +import { registerPortfolioMargin } from "./modules/portfolio-margin/index.js"; +import { registerBinanceRebateTools } from "./modules/rebate/index.js"; +import { registerBinanceSimpleEarnTools } from "./modules/simple-earn/index.js"; // Import module registration functions -import { registerBinanceSpotTools } from "./modules/spot/index.js" -import { registerBinanceStakingTools } from "./modules/staking/index.js" -import { registerSubAccount } from "./modules/sub-account/index.js" -import { registerBinanceVipLoanTools } from "./modules/vip-loan/index.js" -import { registerBinanceWalletTools } from "./modules/wallet/index.js" +import { registerBinanceSpotTools } from "./modules/spot/index.js"; +import { registerBinanceStakingTools } from "./modules/staking/index.js"; +import { registerSubAccount } from "./modules/sub-account/index.js"; +import { registerBinanceVipLoanTools } from "./modules/vip-loan/index.js"; +import { registerBinanceWalletTools } from "./modules/wallet/index.js"; // NOTE: The following modules are disabled due to missing/incompatible npm packages: // - Margin (@binance/margin doesn't exist, needs refactoring to use connector-typescript) @@ -36,36 +36,36 @@ import { registerBinanceWalletTools } from "./modules/wallet/index.js" */ export function registerBinance(server: McpServer) { // Core trading modules - registerBinanceSpotTools(server) - registerBinanceAlgoTools(server) + registerBinanceSpotTools(server); + registerBinanceAlgoTools(server); // Earn & Investment modules - registerBinanceSimpleEarnTools(server) - registerBinanceDualInvestmentTools(server) - registerBinanceStakingTools(server) + registerBinanceSimpleEarnTools(server); + registerBinanceDualInvestmentTools(server); + registerBinanceStakingTools(server); // Trading modules - registerBinanceC2CTradeHistoryTools(server) - registerBinanceConvertTools(server) - registerBinanceCopyTradingTools(server) + registerBinanceC2CTradeHistoryTools(server); + registerBinanceConvertTools(server); + registerBinanceCopyTradingTools(server); // Wallet & Finance modules - registerBinanceWalletTools(server) - registerBinanceFiatDepositWithdrawHistoryTools(server) - registerBinanceVipLoanTools(server) + registerBinanceWalletTools(server); + registerBinanceFiatDepositWithdrawHistoryTools(server); + registerBinanceVipLoanTools(server); // Portfolio Margin module - registerPortfolioMargin(server) + registerPortfolioMargin(server); // Gift Card module - registerGiftCard(server) + registerGiftCard(server); // Sub-Account Management module - registerSubAccount(server) + registerSubAccount(server); // Other modules - registerBinanceNFTTools(server) - registerBinancePayTools(server) - registerBinanceRebateTools(server) - registerBinanceMiningTools(server) + registerBinanceNFTTools(server); + registerBinancePayTools(server); + registerBinanceRebateTools(server); + registerBinanceMiningTools(server); } diff --git a/src/config/binanceClient.ts b/src/config/binanceClient.ts index f21d638a..931b9aa1 100644 --- a/src/config/binanceClient.ts +++ b/src/config/binanceClient.ts @@ -1,81 +1,81 @@ -import crypto from "crypto" - -import { Algo } from "@binance/algo" -import { AutoInvest } from "@binance/auto-invest" -import { C2C } from "@binance/c2c" -import { Spot as ConnectorSpot } from "@binance/connector-typescript" -import { Convert } from "@binance/convert" -import { CopyTrading } from "@binance/copy-trading" -import { CryptoLoan } from "@binance/crypto-loan" -import { DualInvestment } from "@binance/dual-investment" -import { Fiat } from "@binance/fiat" -import { Mining } from "@binance/mining" -import { NFT } from "@binance/nft" -import { Pay } from "@binance/pay" -import { Rebate } from "@binance/rebate" -import { SimpleEarn } from "@binance/simple-earn" +import crypto from "crypto"; + +import { Algo } from "@binance/algo"; +import { AutoInvest } from "@binance/auto-invest"; +import { C2C } from "@binance/c2c"; +import { Spot as ConnectorSpot } from "@binance/connector-typescript"; +import { Convert } from "@binance/convert"; +import { CopyTrading } from "@binance/copy-trading"; +import { CryptoLoan } from "@binance/crypto-loan"; +import { DualInvestment } from "@binance/dual-investment"; +import { Fiat } from "@binance/fiat"; +import { Mining } from "@binance/mining"; +import { NFT } from "@binance/nft"; +import { Pay } from "@binance/pay"; +import { Rebate } from "@binance/rebate"; +import { SimpleEarn } from "@binance/simple-earn"; // src/config/binanceClient.ts -import { Spot } from "@binance/spot" -import { Staking } from "@binance/staking" -import { SubAccount } from "@binance/sub-account" -import { VIPLoan } from "@binance/vip-loan" -import { Wallet } from "@binance/wallet" +import { Spot } from "@binance/spot"; +import { Staking } from "@binance/staking"; +import { SubAccount } from "@binance/sub-account"; +import { VIPLoan } from "@binance/vip-loan"; +import { Wallet } from "@binance/wallet"; -import { assertNotTestnet, IS_TESTNET, URLS } from "./testnet.js" +import { assertNotTestnet, IS_TESTNET, URLS } from "./testnet.js"; -export { assertNotTestnet, IS_TESTNET } +export { assertNotTestnet, IS_TESTNET }; -const API_KEY = process.env.BINANCE_API_KEY ?? "" -const API_SECRET = process.env.BINANCE_API_SECRET ?? "" -const BASE_URL = URLS.SPOT_BASE_URL +const API_KEY = process.env.BINANCE_API_KEY ?? ""; +const API_SECRET = process.env.BINANCE_API_SECRET ?? ""; +const BASE_URL = URLS.SPOT_BASE_URL; const configurationRestAPI = { apiKey: API_KEY, apiSecret: API_SECRET, basePath: BASE_URL, -} +}; // Spot Trading -export const spotClient = new Spot({ configurationRestAPI }) +export const spotClient = new Spot({ configurationRestAPI }); // Connector-typescript client (for margin and other APIs) -export const connectorClient = new ConnectorSpot(API_KEY, API_SECRET, { baseURL: BASE_URL }) +export const connectorClient = new ConnectorSpot(API_KEY, API_SECRET, { baseURL: BASE_URL }); // Algo Trading -export const algoClient = new Algo({ configurationRestAPI }) +export const algoClient = new Algo({ configurationRestAPI }); // Earn & Investment -export const simpleEarnClient = new SimpleEarn({ configurationRestAPI }) -export const dualInvestmentClient = new DualInvestment({ configurationRestAPI }) -export const stakingClient = new Staking({ configurationRestAPI }) -export const autoInvestClient = new AutoInvest({ configurationRestAPI }) +export const simpleEarnClient = new SimpleEarn({ configurationRestAPI }); +export const dualInvestmentClient = new DualInvestment({ configurationRestAPI }); +export const stakingClient = new Staking({ configurationRestAPI }); +export const autoInvestClient = new AutoInvest({ configurationRestAPI }); // Trading -export const c2cClient = new C2C({ configurationRestAPI }) -export const convertClient = new Convert({ configurationRestAPI }) -export const copyTradingClient = new CopyTrading({ configurationRestAPI }) +export const c2cClient = new C2C({ configurationRestAPI }); +export const convertClient = new Convert({ configurationRestAPI }); +export const copyTradingClient = new CopyTrading({ configurationRestAPI }); // Loans -export const vipLoanClient = new VIPLoan({ configurationRestAPI }) -export const cryptoLoanClient = new CryptoLoan({ configurationRestAPI }) +export const vipLoanClient = new VIPLoan({ configurationRestAPI }); +export const cryptoLoanClient = new CryptoLoan({ configurationRestAPI }); // Wallet & Finance -export const walletClient = new Wallet({ configurationRestAPI }) -export const fiatClient = new Fiat({ configurationRestAPI }) +export const walletClient = new Wallet({ configurationRestAPI }); +export const fiatClient = new Fiat({ configurationRestAPI }); // Sub-Account Management -export const subAccountClient = new SubAccount({ configurationRestAPI }) +export const subAccountClient = new SubAccount({ configurationRestAPI }); // Other -export const nftClient = new NFT({ configurationRestAPI }) -export const payClient = new Pay({ configurationRestAPI }) -export const rebateClient = new Rebate({ configurationRestAPI }) -export const miningClient = new Mining({ configurationRestAPI }) +export const nftClient = new NFT({ configurationRestAPI }); +export const payClient = new Pay({ configurationRestAPI }); +export const rebateClient = new Rebate({ configurationRestAPI }); +export const miningClient = new Mining({ configurationRestAPI }); // Generic REST client for APIs without dedicated packages // (Margin, Futures, Options, Gift Card, Portfolio Margin) function generateSignature(queryString: string): string { - return crypto.createHmac("sha256", API_SECRET).update(queryString).digest("hex") + return crypto.createHmac("sha256", API_SECRET).update(queryString).digest("hex"); } async function makeSignedRequest( @@ -87,16 +87,16 @@ async function makeSignedRequest( throw new Error( `[Testnet] Endpoint ${endpoint} is not available on the Binance Spot Test Network. ` + `Only /api endpoints are supported.`, - ) + ); } - const timestamp = Date.now() - const queryParams = { ...params, timestamp } + const timestamp = Date.now(); + const queryParams = { ...params, timestamp }; const queryString = new URLSearchParams( Object.fromEntries(Object.entries(queryParams).map(([k, v]) => [k, String(v)])), - ).toString() - const signature = generateSignature(queryString) - const url = `${BASE_URL}${endpoint}?${queryString}&signature=${signature}` + ).toString(); + const signature = generateSignature(queryString); + const url = `${BASE_URL}${endpoint}?${queryString}&signature=${signature}`; const response = await fetch(url, { method, @@ -104,14 +104,14 @@ async function makeSignedRequest( "X-MBX-APIKEY": API_KEY, "Content-Type": "application/json", }, - }) + }); if (!response.ok) { - const errorData = await response.json().catch(() => ({})) - throw new Error(`Binance API error: ${response.status} - ${JSON.stringify(errorData)}`) + const errorData = await response.json().catch(() => ({})); + throw new Error(`Binance API error: ${response.status} - ${JSON.stringify(errorData)}`); } - return response.json() + return response.json(); } async function makePublicRequest(endpoint: string, params: Record = {}): Promise { @@ -119,27 +119,27 @@ async function makePublicRequest(endpoint: string, params: Record = throw new Error( `[Testnet] Endpoint ${endpoint} is not available on the Binance Spot Test Network. ` + `Only /api endpoints are supported.`, - ) + ); } const queryString = new URLSearchParams( Object.fromEntries(Object.entries(params).map(([k, v]) => [k, String(v)])), - ).toString() - const url = `${BASE_URL}${endpoint}${queryString ? "?" + queryString : ""}` + ).toString(); + const url = `${BASE_URL}${endpoint}${queryString ? "?" + queryString : ""}`; const response = await fetch(url, { method: "GET", headers: { "Content-Type": "application/json", }, - }) + }); if (!response.ok) { - const errorData = await response.json().catch(() => ({})) - throw new Error(`Binance API error: ${response.status} - ${JSON.stringify(errorData)}`) + const errorData = await response.json().catch(() => ({})); + throw new Error(`Binance API error: ${response.status} - ${JSON.stringify(errorData)}`); } - return response.json() + return response.json(); } // Portfolio Margin client wrapper @@ -172,7 +172,7 @@ export const portfolioMarginClient = { makeSignedRequest("GET", "/sapi/v1/portfolio/margin-asset-leverage", params), getBalance: (params: Record = {}) => makeSignedRequest("GET", "/sapi/v1/portfolio/balance", params), -} +}; // Gift Card client wrapper export const giftCardClient = { @@ -190,7 +190,7 @@ export const giftCardClient = { makeSignedRequest("POST", "/sapi/v1/giftcard/buyCode", params), getTokenLimit: (params: Record = {}) => makeSignedRequest("GET", "/sapi/v1/giftcard/buyCode/token-limit", params), -} +}; // Margin client wrapper export const marginClient = { @@ -262,10 +262,10 @@ export const marginClient = { makePublicRequest("/sapi/v1/margin/allAssets", params), getInterestRateHistory: (params: Record = {}) => makeSignedRequest("GET", "/sapi/v1/margin/interestRateHistory", params), -} +}; -const FUTURES_USD_BASE_URL = URLS.FUTURES_USD_BASE_URL -const FUTURES_COIN_BASE_URL = URLS.FUTURES_COIN_BASE_URL +const FUTURES_USD_BASE_URL = URLS.FUTURES_USD_BASE_URL; +const FUTURES_COIN_BASE_URL = URLS.FUTURES_COIN_BASE_URL; async function makeFuturesSignedRequest( baseUrl: string, @@ -273,13 +273,13 @@ async function makeFuturesSignedRequest( endpoint: string, params: Record = {}, ): Promise { - const timestamp = Date.now() - const queryParams = { ...params, timestamp } + const timestamp = Date.now(); + const queryParams = { ...params, timestamp }; const queryString = new URLSearchParams( Object.fromEntries(Object.entries(queryParams).map(([k, v]) => [k, String(v)])), - ).toString() - const signature = generateSignature(queryString) - const url = `${baseUrl}${endpoint}?${queryString}&signature=${signature}` + ).toString(); + const signature = generateSignature(queryString); + const url = `${baseUrl}${endpoint}?${queryString}&signature=${signature}`; const response = await fetch(url, { method, @@ -287,14 +287,14 @@ async function makeFuturesSignedRequest( "X-MBX-APIKEY": API_KEY, "Content-Type": "application/json", }, - }) + }); if (!response.ok) { - const errorData = await response.json().catch(() => ({})) - throw new Error(`Binance API error: ${response.status} - ${JSON.stringify(errorData)}`) + const errorData = await response.json().catch(() => ({})); + throw new Error(`Binance API error: ${response.status} - ${JSON.stringify(errorData)}`); } - return response.json() + return response.json(); } async function makeFuturesPublicRequest( @@ -304,20 +304,20 @@ async function makeFuturesPublicRequest( ): Promise { const queryString = new URLSearchParams( Object.fromEntries(Object.entries(params).map(([k, v]) => [k, String(v)])), - ).toString() - const url = `${baseUrl}${endpoint}${queryString ? "?" + queryString : ""}` + ).toString(); + const url = `${baseUrl}${endpoint}${queryString ? "?" + queryString : ""}`; const response = await fetch(url, { method: "GET", headers: { "Content-Type": "application/json" }, - }) + }); if (!response.ok) { - const errorData = await response.json().catch(() => ({})) - throw new Error(`Binance API error: ${response.status} - ${JSON.stringify(errorData)}`) + const errorData = await response.json().catch(() => ({})); + throw new Error(`Binance API error: ${response.status} - ${JSON.stringify(errorData)}`); } - return response.json() + return response.json(); } // Futures USD-M client wrapper @@ -404,7 +404,7 @@ export const futuresClient = { makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "PUT", "/fapi/v1/listenKey", {}), closeListenKey: () => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "DELETE", "/fapi/v1/listenKey", {}), -} +}; // Futures COIN-M client wrapper (delivery) export const deliveryClient = { @@ -490,7 +490,7 @@ export const deliveryClient = { makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "PUT", "/dapi/v1/listenKey", {}), closeListenKey: () => makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "DELETE", "/dapi/v1/listenKey", {}), -} +}; // Sub-Account client wrapper (using REST API) export const subAccountApiClient = { @@ -536,9 +536,9 @@ export const subAccountApiClient = { makeSignedRequest("GET", "/sapi/v1/sub-account/subAccountApi/ipRestriction", params), updateSubAccountApiKeyIpRestriction: (params: Record) => makeSignedRequest("POST", "/sapi/v1/sub-account/subAccountApi/ipRestriction", params), -} +}; -const OPTIONS_BASE_URL = URLS.OPTIONS_BASE_URL +const OPTIONS_BASE_URL = URLS.OPTIONS_BASE_URL; export const optionsClient = { // Market Data @@ -591,4 +591,4 @@ export const optionsClient = { makeFuturesSignedRequest(OPTIONS_BASE_URL, "PUT", "/eapi/v1/listenKey", {}), closeListenKey: () => makeFuturesSignedRequest(OPTIONS_BASE_URL, "DELETE", "/eapi/v1/listenKey", {}), -} +}; diff --git a/src/config/binanceUsClient.ts b/src/config/binanceUsClient.ts index 47861d97..6b145703 100644 --- a/src/config/binanceUsClient.ts +++ b/src/config/binanceUsClient.ts @@ -1,5 +1,5 @@ // src/config/binanceUsClient.ts -import crypto from "crypto" +import crypto from "crypto"; /** * Binance.US API Client Configuration @@ -25,11 +25,11 @@ export const BINANCE_US_CONFIG = { WS_URL: "wss://stream.binance.us:9443", DEFAULT_RECV_WINDOW: 5000, MAX_RECV_WINDOW: 60000, -} as const +} as const; -const API_KEY = process.env.BINANCE_US_API_KEY || "" -const API_SECRET = process.env.BINANCE_US_API_SECRET || "" -const BASE_URL = BINANCE_US_CONFIG.BASE_URL +const API_KEY = process.env.BINANCE_US_API_KEY || ""; +const API_SECRET = process.env.BINANCE_US_API_SECRET || ""; +const BASE_URL = BINANCE_US_CONFIG.BASE_URL; // ============================================================================ // Type Definitions @@ -37,34 +37,34 @@ const BASE_URL = BINANCE_US_CONFIG.BASE_URL /** Rate limit information from API response headers */ export interface RateLimitInfo { - usedWeight: number - weightLimit: number - orderCount?: number - retryAfter?: number + usedWeight: number; + weightLimit: number; + orderCount?: number; + retryAfter?: number; } /** API response wrapper with rate limit info */ export interface BinanceUsResponse { - data: T - rateLimitInfo?: RateLimitInfo + data: T; + rateLimitInfo?: RateLimitInfo; } /** Ping response (empty object) */ -export type PingResponse = Record +export type PingResponse = Record; /** Server time response */ export interface ServerTimeResponse { - serverTime: number + serverTime: number; } /** System status response */ export interface SystemStatusResponse { - status: 0 | 1 // 0: normal, 1: system maintenance + status: 0 | 1; // 0: normal, 1: system maintenance } /** Symbol information in exchange info */ export interface SymbolInfo { - symbol: string + symbol: string; status: | "PRE_TRADING" | "TRADING" @@ -72,79 +72,79 @@ export interface SymbolInfo { | "END_OF_DAY" | "HALT" | "AUCTION_MATCH" - | "BREAK" - baseAsset: string - baseAssetPrecision: number - quoteAsset: string - quotePrecision: number - quoteAssetPrecision: number - baseCommissionPrecision: number - quoteCommissionPrecision: number - orderTypes: string[] - icebergAllowed: boolean - ocoAllowed: boolean - quoteOrderQtyMarketAllowed: boolean - allowTrailingStop: boolean - cancelReplaceAllowed: boolean - isSpotTradingAllowed: boolean - isMarginTradingAllowed: boolean - filters: any[] - permissions: string[] + | "BREAK"; + baseAsset: string; + baseAssetPrecision: number; + quoteAsset: string; + quotePrecision: number; + quoteAssetPrecision: number; + baseCommissionPrecision: number; + quoteCommissionPrecision: number; + orderTypes: string[]; + icebergAllowed: boolean; + ocoAllowed: boolean; + quoteOrderQtyMarketAllowed: boolean; + allowTrailingStop: boolean; + cancelReplaceAllowed: boolean; + isSpotTradingAllowed: boolean; + isMarginTradingAllowed: boolean; + filters: any[]; + permissions: string[]; } /** Exchange information response */ export interface ExchangeInfoResponse { - timezone: string - serverTime: number - rateLimits: any[] - exchangeFilters: any[] - symbols: SymbolInfo[] - permissions: string[] - defaultSelfTradePreventionMode?: string - allowedSelfTradePreventionModes?: string[] + timezone: string; + serverTime: number; + rateLimits: any[]; + exchangeFilters: any[]; + symbols: SymbolInfo[]; + permissions: string[]; + defaultSelfTradePreventionMode?: string; + allowedSelfTradePreventionModes?: string[]; } /** Order book response */ export interface OrderBookResponse { - lastUpdateId: number - bids: [string, string][] // [price, quantity][] - asks: [string, string][] // [price, quantity][] + lastUpdateId: number; + bids: [string, string][]; // [price, quantity][] + asks: [string, string][]; // [price, quantity][] } /** Trade response */ export interface TradeResponse { - id: number - price: string - qty: string - quoteQty: string - time: number - isBuyerMaker: boolean - isBestMatch: boolean + id: number; + price: string; + qty: string; + quoteQty: string; + time: number; + isBuyerMaker: boolean; + isBestMatch: boolean; } /** Aggregate trade response */ export interface AggTradeResponse { - a: number // Aggregate tradeId - p: string // Price - q: string // Quantity - f: number // First tradeId - l: number // Last tradeId - T: number // Timestamp - m: boolean // Was the buyer the maker? - M: boolean // Was the trade the best price match? + a: number; // Aggregate tradeId + p: string; // Price + q: string; // Quantity + f: number; // First tradeId + l: number; // Last tradeId + T: number; // Timestamp + m: boolean; // Was the buyer the maker? + M: boolean; // Was the trade the best price match? } /** Formatted aggregate trade (human-readable) */ export interface FormattedAggTrade { - aggregateTradeId: number - price: string - quantity: string - firstTradeId: number - lastTradeId: number - timestamp: number - timestampISO: string - isBuyerMaker: boolean - isBestMatch: boolean + aggregateTradeId: number; + price: string; + quantity: string; + firstTradeId: number; + lastTradeId: number; + timestamp: number; + timestampISO: string; + isBuyerMaker: boolean; + isBestMatch: boolean; } /** Raw kline data (array format from API) */ @@ -161,88 +161,88 @@ export type KlineRaw = [ string, // 9: Taker buy base asset volume string, // 10: Taker buy quote asset volume string, // 11: Ignore -] +]; /** Formatted kline (human-readable) */ export interface FormattedKline { - openTime: number - openTimeISO: string - open: string - high: string - low: string - close: string - volume: string - closeTime: number - closeTimeISO: string - quoteAssetVolume: string - numberOfTrades: number - takerBuyBaseVolume: string - takerBuyQuoteVolume: string + openTime: number; + openTimeISO: string; + open: string; + high: string; + low: string; + close: string; + volume: string; + closeTime: number; + closeTimeISO: string; + quoteAssetVolume: string; + numberOfTrades: number; + takerBuyBaseVolume: string; + takerBuyQuoteVolume: string; } /** Average price response */ export interface AvgPriceResponse { - mins: number - price: string + mins: number; + price: string; } /** Ticker price response */ export interface TickerPriceResponse { - symbol: string - price: string + symbol: string; + price: string; } /** Book ticker response */ export interface BookTickerResponse { - symbol: string - bidPrice: string - bidQty: string - askPrice: string - askQty: string + symbol: string; + bidPrice: string; + bidQty: string; + askPrice: string; + askQty: string; } /** 24hr ticker response */ export interface Ticker24hrResponse { - symbol: string - priceChange: string - priceChangePercent: string - weightedAvgPrice: string - prevClosePrice: string - lastPrice: string - lastQty: string - bidPrice: string - bidQty: string - askPrice: string - askQty: string - openPrice: string - highPrice: string - lowPrice: string - volume: string - quoteVolume: string - openTime: number - closeTime: number - firstId: number - lastId: number - count: number + symbol: string; + priceChange: string; + priceChangePercent: string; + weightedAvgPrice: string; + prevClosePrice: string; + lastPrice: string; + lastQty: string; + bidPrice: string; + bidQty: string; + askPrice: string; + askQty: string; + openPrice: string; + highPrice: string; + lowPrice: string; + volume: string; + quoteVolume: string; + openTime: number; + closeTime: number; + firstId: number; + lastId: number; + count: number; } /** Rolling window ticker response */ export interface RollingWindowTickerResponse { - symbol: string - priceChange: string - priceChangePercent: string - weightedAvgPrice: string - openPrice: string - highPrice: string - lowPrice: string - lastPrice: string - volume: string - quoteVolume: string - openTime: number - closeTime: number - firstId: number - lastId: number - count: number + symbol: string; + priceChange: string; + priceChangePercent: string; + weightedAvgPrice: string; + openPrice: string; + highPrice: string; + lowPrice: string; + lastPrice: string; + volume: string; + quoteVolume: string; + openTime: number; + closeTime: number; + firstId: number; + lastId: number; + count: number; } // ============================================================================ @@ -257,8 +257,8 @@ export class BinanceUsApiError extends Error { public readonly httpStatus: number, public readonly rateLimitInfo?: RateLimitInfo, ) { - super(message) - this.name = "BinanceUsApiError" + super(message); + this.name = "BinanceUsApiError"; } } @@ -269,8 +269,8 @@ export class RateLimitError extends BinanceUsApiError { public readonly retryAfter: number, rateLimitInfo?: RateLimitInfo, ) { - super(-1003, message, 429, rateLimitInfo) - this.name = "RateLimitError" + super(-1003, message, 429, rateLimitInfo); + this.name = "RateLimitError"; } } @@ -281,8 +281,8 @@ export class IpBanError extends BinanceUsApiError { public readonly retryAfter: number, rateLimitInfo?: RateLimitInfo, ) { - super(-1003, message, 418, rateLimitInfo) - this.name = "IpBanError" + super(-1003, message, 418, rateLimitInfo); + this.name = "IpBanError"; } } @@ -294,7 +294,7 @@ export class IpBanError extends BinanceUsApiError { * Generate HMAC SHA256 signature for Binance.US API requests */ export function generateSignature(queryString: string): string { - return crypto.createHmac("sha256", API_SECRET).update(queryString).digest("hex") + return crypto.createHmac("sha256", API_SECRET).update(queryString).digest("hex"); } /** @@ -304,46 +304,46 @@ export function buildQueryString(params: Record): string { const filteredParams = Object.entries(params) .filter(([_, value]) => value !== undefined && value !== null) .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`) - .join("&") + .join("&"); - return filteredParams + return filteredParams; } /** * Check if API credentials are configured */ export function hasApiCredentials(): boolean { - return !!(API_KEY && API_SECRET) + return !!(API_KEY && API_SECRET); } /** * Check if API key is configured (for MARKET_DATA requests) */ export function hasApiKey(): boolean { - return !!API_KEY + return !!API_KEY; } /** * Get current timestamp in milliseconds */ export function getTimestamp(): number { - return Date.now() + return Date.now(); } /** * Parse rate limit info from response headers */ function parseRateLimitInfo(headers: Headers): RateLimitInfo | undefined { - const usedWeight = headers.get("X-MBX-USED-WEIGHT-1M") - const retryAfter = headers.get("Retry-After") + const usedWeight = headers.get("X-MBX-USED-WEIGHT-1M"); + const retryAfter = headers.get("Retry-After"); - if (!usedWeight && !retryAfter) return undefined + if (!usedWeight && !retryAfter) return undefined; return { usedWeight: usedWeight ? parseInt(usedWeight, 10) : 0, weightLimit: 1200, // Default weight limit per minute retryAfter: retryAfter ? parseInt(retryAfter, 10) : undefined, - } + }; } /** @@ -364,7 +364,7 @@ export function formatKline(kline: KlineRaw): FormattedKline { numberOfTrades: kline[8], takerBuyBaseVolume: kline[9], takerBuyQuoteVolume: kline[10], - } + }; } /** @@ -381,7 +381,7 @@ export function formatAggTrade(trade: AggTradeResponse): FormattedAggTrade { timestampISO: new Date(trade.T).toISOString(), isBuyerMaker: trade.m, isBestMatch: trade.M, - } + }; } // ============================================================================ @@ -407,78 +407,78 @@ export async function makeSignedRequest( -2015, "API credentials required. Set BINANCE_US_API_KEY and BINANCE_US_API_SECRET environment variables.", 401, - ) + ); } // Validate recvWindow if (recvWindow > BINANCE_US_CONFIG.MAX_RECV_WINDOW) { - recvWindow = BINANCE_US_CONFIG.MAX_RECV_WINDOW + recvWindow = BINANCE_US_CONFIG.MAX_RECV_WINDOW; } // Add timestamp and recvWindow to params - const timestamp = Date.now() - const paramsWithTimestamp = { ...params, timestamp, recvWindow } + const timestamp = Date.now(); + const paramsWithTimestamp = { ...params, timestamp, recvWindow }; // Build query string and generate signature - const queryString = buildQueryString(paramsWithTimestamp) - const signature = generateSignature(queryString) - const signedQueryString = `${queryString}&signature=${signature}` + const queryString = buildQueryString(paramsWithTimestamp); + const signature = generateSignature(queryString); + const signedQueryString = `${queryString}&signature=${signature}`; // Build URL and headers const url = method === "GET" || method === "DELETE" ? `${BASE_URL}${endpoint}?${signedQueryString}` - : `${BASE_URL}${endpoint}` + : `${BASE_URL}${endpoint}`; const headers: HeadersInit = { "X-MBX-APIKEY": API_KEY, "Content-Type": "application/x-www-form-urlencoded", - } + }; const fetchOptions: RequestInit = { method, headers, - } + }; // For POST and PUT requests, send data in body if (method === "POST" || method === "PUT") { - fetchOptions.body = signedQueryString + fetchOptions.body = signedQueryString; } - const response = await fetch(url, fetchOptions) - const rateLimitInfo = parseRateLimitInfo(response.headers) + const response = await fetch(url, fetchOptions); + const rateLimitInfo = parseRateLimitInfo(response.headers); // Handle rate limiting (429) if (response.status === 429) { - const retryAfter = parseInt(response.headers.get("Retry-After") || "60", 10) + const retryAfter = parseInt(response.headers.get("Retry-After") || "60", 10); throw new RateLimitError( `Rate limit exceeded. Retry after ${retryAfter} seconds.`, retryAfter, rateLimitInfo, - ) + ); } // Handle IP ban (418) if (response.status === 418) { - const retryAfter = parseInt(response.headers.get("Retry-After") || "120", 10) + const retryAfter = parseInt(response.headers.get("Retry-After") || "120", 10); throw new IpBanError( `IP temporarily banned. Ban lifted after ${retryAfter} seconds.`, retryAfter, rateLimitInfo, - ) + ); } if (!response.ok) { - const errorData = await response.json().catch(() => ({ msg: response.statusText })) + const errorData = await response.json().catch(() => ({ msg: response.statusText })); throw new BinanceUsApiError( errorData.code || response.status, errorData.msg || response.statusText, response.status, rateLimitInfo, - ) + ); } - return response.json() + return response.json(); } /** @@ -489,43 +489,43 @@ export async function makePublicRequest( endpoint: string, params: Record = {}, ): Promise { - const queryString = buildQueryString(params) - const url = queryString ? `${BASE_URL}${endpoint}?${queryString}` : `${BASE_URL}${endpoint}` + const queryString = buildQueryString(params); + const url = queryString ? `${BASE_URL}${endpoint}?${queryString}` : `${BASE_URL}${endpoint}`; - const response = await fetch(url, { method }) - const rateLimitInfo = parseRateLimitInfo(response.headers) + const response = await fetch(url, { method }); + const rateLimitInfo = parseRateLimitInfo(response.headers); // Handle rate limiting (429) if (response.status === 429) { - const retryAfter = parseInt(response.headers.get("Retry-After") || "60", 10) + const retryAfter = parseInt(response.headers.get("Retry-After") || "60", 10); throw new RateLimitError( `Rate limit exceeded. Retry after ${retryAfter} seconds.`, retryAfter, rateLimitInfo, - ) + ); } // Handle IP ban (418) if (response.status === 418) { - const retryAfter = parseInt(response.headers.get("Retry-After") || "120", 10) + const retryAfter = parseInt(response.headers.get("Retry-After") || "120", 10); throw new IpBanError( `IP temporarily banned. Ban lifted after ${retryAfter} seconds.`, retryAfter, rateLimitInfo, - ) + ); } if (!response.ok) { - const errorData = await response.json().catch(() => ({ msg: response.statusText })) + const errorData = await response.json().catch(() => ({ msg: response.statusText })); throw new BinanceUsApiError( errorData.code || response.status, errorData.msg || response.statusText, response.status, rateLimitInfo, - ) + ); } - return response.json() + return response.json(); } export const binanceUsConfig = { @@ -533,7 +533,7 @@ export const binanceUsConfig = { apiSecret: API_SECRET, baseUrl: BASE_URL, wsUrl: BINANCE_US_CONFIG.WS_URL, -} +}; /** * Make a MARKET_DATA request (requires API key but no signature) @@ -549,50 +549,50 @@ export async function makeMarketDataRequest( -2015, "API key required for MARKET_DATA endpoints. Set BINANCE_US_API_KEY environment variable.", 401, - ) + ); } - const queryString = buildQueryString(params) - const url = queryString ? `${BASE_URL}${endpoint}?${queryString}` : `${BASE_URL}${endpoint}` + const queryString = buildQueryString(params); + const url = queryString ? `${BASE_URL}${endpoint}?${queryString}` : `${BASE_URL}${endpoint}`; const headers: HeadersInit = { "X-MBX-APIKEY": API_KEY, - } + }; - const response = await fetch(url, { method, headers }) - const rateLimitInfo = parseRateLimitInfo(response.headers) + const response = await fetch(url, { method, headers }); + const rateLimitInfo = parseRateLimitInfo(response.headers); // Handle rate limiting (429) if (response.status === 429) { - const retryAfter = parseInt(response.headers.get("Retry-After") || "60", 10) + const retryAfter = parseInt(response.headers.get("Retry-After") || "60", 10); throw new RateLimitError( `Rate limit exceeded. Retry after ${retryAfter} seconds.`, retryAfter, rateLimitInfo, - ) + ); } // Handle IP ban (418) if (response.status === 418) { - const retryAfter = parseInt(response.headers.get("Retry-After") || "120", 10) + const retryAfter = parseInt(response.headers.get("Retry-After") || "120", 10); throw new IpBanError( `IP temporarily banned. Ban lifted after ${retryAfter} seconds.`, retryAfter, rateLimitInfo, - ) + ); } if (!response.ok) { - const errorData = await response.json().catch(() => ({ msg: response.statusText })) + const errorData = await response.json().catch(() => ({ msg: response.statusText })); throw new BinanceUsApiError( errorData.code || response.status, errorData.msg || response.statusText, response.status, rateLimitInfo, - ) + ); } - return response.json() + return response.json(); } /** @@ -613,11 +613,11 @@ export async function binanceUsRequest( recvWindow?: number, ): Promise { if (signed) { - return makeSignedRequest(method, path, params, recvWindow) as Promise + return makeSignedRequest(method, path, params, recvWindow) as Promise; } else if (apiKeyRequired) { - return makeMarketDataRequest("GET", path, params) as Promise + return makeMarketDataRequest("GET", path, params) as Promise; } else { - return makePublicRequest("GET", path, params) as Promise + return makePublicRequest("GET", path, params) as Promise; } } @@ -626,7 +626,7 @@ export async function binanceUsRequest( // ============================================================================ /** Valid limit values for order book depth endpoint */ -export const ORDER_BOOK_VALID_LIMITS = [5, 10, 20, 50, 100, 500, 1000, 5000] as const +export const ORDER_BOOK_VALID_LIMITS = [5, 10, 20, 50, 100, 500, 1000, 5000] as const; /** Valid kline intervals */ export const KLINE_INTERVALS = [ @@ -645,7 +645,7 @@ export const KLINE_INTERVALS = [ "3d", "1w", "1M", -] as const +] as const; /** Valid rolling window sizes */ export const ROLLING_WINDOW_SIZES = [ @@ -665,12 +665,12 @@ export const ROLLING_WINDOW_SIZES = [ "1d", "3d", "7d", -] as const +] as const; /** Max results for trade endpoints */ -export const MAX_TRADES_LIMIT = 1000 -export const DEFAULT_TRADES_LIMIT = 500 +export const MAX_TRADES_LIMIT = 1000; +export const DEFAULT_TRADES_LIMIT = 500; /** Max results for klines endpoint */ -export const MAX_KLINES_LIMIT = 1000 -export const DEFAULT_KLINES_LIMIT = 500 +export const MAX_KLINES_LIMIT = 1000; +export const DEFAULT_KLINES_LIMIT = 500; diff --git a/src/config/client.ts b/src/config/client.ts index 3b02518b..7aad5b90 100644 --- a/src/config/client.ts +++ b/src/config/client.ts @@ -1,17 +1,17 @@ -import { Algo } from "@binance/algo" -import { Spot } from "@binance/connector-typescript" +import { Algo } from "@binance/algo"; +import { Spot } from "@binance/connector-typescript"; -import { URLS } from "./testnet.js" +import { URLS } from "./testnet.js"; -const API_KEY = process.env.BINANCE_API_KEY -const API_SECRET = process.env.BINANCE_API_SECRET -const BASE_URL = URLS.SPOT_BASE_URL +const API_KEY = process.env.BINANCE_API_KEY; +const API_SECRET = process.env.BINANCE_API_SECRET; +const BASE_URL = URLS.SPOT_BASE_URL; -export const spotClient = new Spot(API_KEY, API_SECRET, { baseURL: BASE_URL }) +export const spotClient = new Spot(API_KEY, API_SECRET, { baseURL: BASE_URL }); export const algoClient = new Algo({ configurationRestAPI: { apiKey: API_KEY ?? "", apiSecret: API_SECRET ?? "", basePath: BASE_URL, }, -}) +}); diff --git a/src/config/testnet.ts b/src/config/testnet.ts index a81bbe38..4784e747 100644 --- a/src/config/testnet.ts +++ b/src/config/testnet.ts @@ -2,25 +2,25 @@ // Binance Testnet configuration // Reference: https://testnet.binance.vision -import Logger from "../utils/logger.js" +import Logger from "../utils/logger.js"; -export const IS_TESTNET = process.env.BINANCE_TESTNET === "true" +export const IS_TESTNET = process.env.BINANCE_TESTNET === "true"; // Spot Testnet — only /api endpoints are supported (NOT /sapi) -const TESTNET_SPOT_BASE_URL = "https://testnet.binance.vision" -const TESTNET_SPOT_WS_API_URL = "wss://ws-api.testnet.binance.vision/ws-api/v3" -const TESTNET_SPOT_WS_STREAM_URL = "wss://stream.testnet.binance.vision" +const TESTNET_SPOT_BASE_URL = "https://testnet.binance.vision"; +const TESTNET_SPOT_WS_API_URL = "wss://ws-api.testnet.binance.vision/ws-api/v3"; +const TESTNET_SPOT_WS_STREAM_URL = "wss://stream.testnet.binance.vision"; // Futures Testnet — both USD-M (/fapi) and COIN-M (/dapi) share the same host -const TESTNET_FUTURES_BASE_URL = "https://testnet.binancefuture.com" +const TESTNET_FUTURES_BASE_URL = "https://testnet.binancefuture.com"; // Production URLs -const PROD_SPOT_BASE_URL = "https://api.binance.com" -const PROD_SPOT_WS_API_URL = "wss://ws-api.binance.com/ws-api/v3" -const PROD_SPOT_WS_STREAM_URL = "wss://stream.binance.com" -const PROD_FUTURES_USD_BASE_URL = "https://fapi.binance.com" -const PROD_FUTURES_COIN_BASE_URL = "https://dapi.binance.com" -const PROD_OPTIONS_BASE_URL = "https://eapi.binance.com" +const PROD_SPOT_BASE_URL = "https://api.binance.com"; +const PROD_SPOT_WS_API_URL = "wss://ws-api.binance.com/ws-api/v3"; +const PROD_SPOT_WS_STREAM_URL = "wss://stream.binance.com"; +const PROD_FUTURES_USD_BASE_URL = "https://fapi.binance.com"; +const PROD_FUTURES_COIN_BASE_URL = "https://dapi.binance.com"; +const PROD_OPTIONS_BASE_URL = "https://eapi.binance.com"; export const URLS = { SPOT_BASE_URL: IS_TESTNET ? TESTNET_SPOT_BASE_URL : PROD_SPOT_BASE_URL, @@ -30,7 +30,7 @@ export const URLS = { FUTURES_COIN_BASE_URL: IS_TESTNET ? TESTNET_FUTURES_BASE_URL : PROD_FUTURES_COIN_BASE_URL, // No testnet for options — always production OPTIONS_BASE_URL: PROD_OPTIONS_BASE_URL, -} as const +} as const; /** * Endpoints using /sapi are NOT available on the Spot Test Network. @@ -57,7 +57,7 @@ export const SAPI_ONLY_MODULES = [ "Sub-Account", "VIP Loan", "Wallet", -] as const +] as const; /** * Throws a descriptive error when a /sapi endpoint is called in testnet mode. @@ -67,7 +67,7 @@ export function assertNotTestnet(moduleName: string): void { throw new Error( `[Testnet] ${moduleName} is not available on the Binance Spot Test Network. ` + `Only /api endpoints are supported. See https://testnet.binance.vision`, - ) + ); } } @@ -76,15 +76,15 @@ export function assertNotTestnet(moduleName: string): void { */ export function logTestnetStatus(): void { if (IS_TESTNET) { - Logger.info("=== BINANCE TESTNET MODE ===") - Logger.info(`Spot REST API: ${URLS.SPOT_BASE_URL}`) - Logger.info(`Spot WS API: ${URLS.SPOT_WS_API_URL}`) - Logger.info(`Spot WS Stream: ${URLS.SPOT_WS_STREAM_URL}`) - Logger.info(`Futures USD-M: ${URLS.FUTURES_USD_BASE_URL}`) - Logger.info(`Futures COIN-M: ${URLS.FUTURES_COIN_BASE_URL}`) - Logger.info(`Options: ${URLS.OPTIONS_BASE_URL} (no testnet available)`) + Logger.info("=== BINANCE TESTNET MODE ==="); + Logger.info(`Spot REST API: ${URLS.SPOT_BASE_URL}`); + Logger.info(`Spot WS API: ${URLS.SPOT_WS_API_URL}`); + Logger.info(`Spot WS Stream: ${URLS.SPOT_WS_STREAM_URL}`); + Logger.info(`Futures USD-M: ${URLS.FUTURES_USD_BASE_URL}`); + Logger.info(`Futures COIN-M: ${URLS.FUTURES_COIN_BASE_URL}`); + Logger.info(`Options: ${URLS.OPTIONS_BASE_URL} (no testnet available)`); Logger.warn( `The following modules use /sapi and are NOT available on testnet: ${SAPI_ONLY_MODULES.join(", ")}`, - ) + ); } } diff --git a/src/config/types.ts b/src/config/types.ts index 3bc6d4f1..3794bd01 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -5,57 +5,57 @@ * API Response wrapper */ export interface BinanceUsApiResponse { - success: boolean - data?: T - error?: BinanceUsApiError + success: boolean; + data?: T; + error?: BinanceUsApiError; } export interface BinanceUsApiError { - code: number - msg: string + code: number; + msg: string; } /** * Rate Limit Information */ export interface RateLimitInfo { - rateLimitType: "REQUEST_WEIGHT" | "ORDERS" | "RAW_REQUESTS" - interval: "SECOND" | "MINUTE" | "HOUR" | "DAY" - intervalNum: number - limit: number + rateLimitType: "REQUEST_WEIGHT" | "ORDERS" | "RAW_REQUESTS"; + interval: "SECOND" | "MINUTE" | "HOUR" | "DAY"; + intervalNum: number; + limit: number; } /** * Exchange Information */ export interface ExchangeInfo { - timezone: string - serverTime: number - rateLimits: RateLimitInfo[] - exchangeFilters: unknown[] - symbols: SymbolInfo[] + timezone: string; + serverTime: number; + rateLimits: RateLimitInfo[]; + exchangeFilters: unknown[]; + symbols: SymbolInfo[]; } export interface SymbolInfo { - symbol: string - status: SymbolStatus - baseAsset: string - baseAssetPrecision: number - quoteAsset: string - quotePrecision: number - quoteAssetPrecision: number - orderTypes: OrderType[] - icebergAllowed: boolean - ocoAllowed: boolean - quoteOrderQtyMarketAllowed: boolean - allowTrailingStop: boolean - cancelReplaceAllowed: boolean - isSpotTradingAllowed: boolean - isMarginTradingAllowed: boolean - filters: SymbolFilter[] - permissions: string[] - defaultSelfTradePreventionMode: string - allowedSelfTradePreventionModes: string[] + symbol: string; + status: SymbolStatus; + baseAsset: string; + baseAssetPrecision: number; + quoteAsset: string; + quotePrecision: number; + quoteAssetPrecision: number; + orderTypes: OrderType[]; + icebergAllowed: boolean; + ocoAllowed: boolean; + quoteOrderQtyMarketAllowed: boolean; + allowTrailingStop: boolean; + cancelReplaceAllowed: boolean; + isSpotTradingAllowed: boolean; + isMarginTradingAllowed: boolean; + filters: SymbolFilter[]; + permissions: string[]; + defaultSelfTradePreventionMode: string; + allowedSelfTradePreventionModes: string[]; } export type SymbolStatus = @@ -65,13 +65,18 @@ export type SymbolStatus = | "END_OF_DAY" | "HALT" | "AUCTION_MATCH" - | "BREAK" + | "BREAK"; -export type OrderType = "LIMIT" | "MARKET" | "STOP_LOSS_LIMIT" | "TAKE_PROFIT_LIMIT" | "LIMIT_MAKER" +export type OrderType = + | "LIMIT" + | "MARKET" + | "STOP_LOSS_LIMIT" + | "TAKE_PROFIT_LIMIT" + | "LIMIT_MAKER"; -export type OrderSide = "BUY" | "SELL" +export type OrderSide = "BUY" | "SELL"; -export type TimeInForce = "GTC" | "IOC" | "FOK" +export type TimeInForce = "GTC" | "IOC" | "FOK"; export type OrderStatus = | "NEW" @@ -81,47 +86,47 @@ export type OrderStatus = | "PENDING_CANCEL" | "REJECTED" | "EXPIRED" - | "EXPIRED_IN_MATCH" + | "EXPIRED_IN_MATCH"; export interface SymbolFilter { - filterType: string - [key: string]: unknown + filterType: string; + [key: string]: unknown; } /** * Order Book */ export interface OrderBook { - lastUpdateId: number - bids: [string, string][] // [price, quantity][] - asks: [string, string][] // [price, quantity][] + lastUpdateId: number; + bids: [string, string][]; // [price, quantity][] + asks: [string, string][]; // [price, quantity][] } /** * Trade */ export interface Trade { - id: number - price: string - qty: string - quoteQty: string - time: number - isBuyerMaker: boolean - isBestMatch: boolean + id: number; + price: string; + qty: string; + quoteQty: string; + time: number; + isBuyerMaker: boolean; + isBestMatch: boolean; } /** * Aggregate Trade */ export interface AggregateTrade { - a: number // Aggregate tradeId - p: string // Price - q: string // Quantity - f: number // First tradeId - l: number // Last tradeId - T: number // Timestamp - m: boolean // Was the buyer the maker? - M: boolean // Was the trade the best price match? + a: number; // Aggregate tradeId + p: string; // Price + q: string; // Quantity + f: number; // First tradeId + l: number; // Last tradeId + T: number; // Timestamp + m: boolean; // Was the buyer the maker? + M: boolean; // Was the trade the best price match? } /** @@ -140,353 +145,353 @@ export type Kline = [ string, // Taker buy base asset volume string, // Taker buy quote asset volume string, // Ignore -] +]; /** * 24hr Ticker */ export interface Ticker24hr { - symbol: string - priceChange: string - priceChangePercent: string - weightedAvgPrice: string - prevClosePrice: string - lastPrice: string - lastQty: string - bidPrice: string - bidQty: string - askPrice: string - askQty: string - openPrice: string - highPrice: string - lowPrice: string - volume: string - quoteVolume: string - openTime: number - closeTime: number - firstId: number - lastId: number - count: number + symbol: string; + priceChange: string; + priceChangePercent: string; + weightedAvgPrice: string; + prevClosePrice: string; + lastPrice: string; + lastQty: string; + bidPrice: string; + bidQty: string; + askPrice: string; + askQty: string; + openPrice: string; + highPrice: string; + lowPrice: string; + volume: string; + quoteVolume: string; + openTime: number; + closeTime: number; + firstId: number; + lastId: number; + count: number; } /** * Price Ticker */ export interface PriceTicker { - symbol: string - price: string + symbol: string; + price: string; } /** * Book Ticker */ export interface BookTicker { - symbol: string - bidPrice: string - bidQty: string - askPrice: string - askQty: string + symbol: string; + bidPrice: string; + bidQty: string; + askPrice: string; + askQty: string; } /** * Account Information */ export interface AccountInfo { - makerCommission: number - takerCommission: number - buyerCommission: number - sellerCommission: number + makerCommission: number; + takerCommission: number; + buyerCommission: number; + sellerCommission: number; commissionRates: { - maker: string - taker: string - buyer: string - seller: string - } - canTrade: boolean - canWithdraw: boolean - canDeposit: boolean - brokered: boolean - requireSelfTradePrevention: boolean - updateTime: number - accountType: string - balances: Balance[] - permissions: string[] - tradeGroupId?: number + maker: string; + taker: string; + buyer: string; + seller: string; + }; + canTrade: boolean; + canWithdraw: boolean; + canDeposit: boolean; + brokered: boolean; + requireSelfTradePrevention: boolean; + updateTime: number; + accountType: string; + balances: Balance[]; + permissions: string[]; + tradeGroupId?: number; } export interface Balance { - asset: string - free: string - locked: string + asset: string; + free: string; + locked: string; } /** * Order */ export interface Order { - symbol: string - orderId: number - orderListId: number - clientOrderId: string - transactTime?: number - price: string - origQty: string - executedQty: string - cummulativeQuoteQty: string - status: OrderStatus - timeInForce: TimeInForce - type: OrderType - side: OrderSide - stopPrice?: string - icebergQty?: string - time: number - updateTime: number - isWorking: boolean - workingTime?: number - origQuoteOrderQty: string - selfTradePreventionMode: string - preventedMatchId?: number - preventedQuantity?: string + symbol: string; + orderId: number; + orderListId: number; + clientOrderId: string; + transactTime?: number; + price: string; + origQty: string; + executedQty: string; + cummulativeQuoteQty: string; + status: OrderStatus; + timeInForce: TimeInForce; + type: OrderType; + side: OrderSide; + stopPrice?: string; + icebergQty?: string; + time: number; + updateTime: number; + isWorking: boolean; + workingTime?: number; + origQuoteOrderQty: string; + selfTradePreventionMode: string; + preventedMatchId?: number; + preventedQuantity?: string; } /** * OCO Order */ export interface OcoOrder { - orderListId: number - contingencyType: string - listStatusType: string - listOrderStatus: string - listClientOrderId: string - transactionTime: number - symbol: string + orderListId: number; + contingencyType: string; + listStatusType: string; + listOrderStatus: string; + listClientOrderId: string; + transactionTime: number; + symbol: string; orders: { - symbol: string - orderId: number - clientOrderId: string - }[] - orderReports?: Order[] + symbol: string; + orderId: number; + clientOrderId: string; + }[]; + orderReports?: Order[]; } /** * User Trade */ export interface UserTrade { - symbol: string - id: number - orderId: number - orderListId: number - price: string - qty: string - quoteQty: string - commission: string - commissionAsset: string - time: number - isBuyer: boolean - isMaker: boolean - isBestMatch: boolean + symbol: string; + id: number; + orderId: number; + orderListId: number; + price: string; + qty: string; + quoteQty: string; + commission: string; + commissionAsset: string; + time: number; + isBuyer: boolean; + isMaker: boolean; + isBestMatch: boolean; } /** * Deposit/Withdrawal */ export interface DepositHistory { - amount: string - coin: string - network: string - status: number - address: string - addressTag: string - txId: string - insertTime: number - transferType: number - confirmTimes: string + amount: string; + coin: string; + network: string; + status: number; + address: string; + addressTag: string; + txId: string; + insertTime: number; + transferType: number; + confirmTimes: string; } export interface WithdrawHistory { - address: string - amount: string - applyTime: string - coin: string - id: string - withdrawOrderId?: string - network: string - transferType: number - status: number - transactionFee: string - txId: string - confirmNo?: number + address: string; + amount: string; + applyTime: string; + coin: string; + id: string; + withdrawOrderId?: string; + network: string; + transferType: number; + status: number; + transactionFee: string; + txId: string; + confirmNo?: number; } /** * Asset Configuration */ export interface AssetConfig { - coin: string - depositAllEnable: boolean - withdrawAllEnable: boolean - name: string - free: string - locked: string - freeze: string - withdrawing: string - ipoing: string - ipoable: string - storage: string - isLegalMoney: boolean - trading: boolean - networkList: NetworkInfo[] + coin: string; + depositAllEnable: boolean; + withdrawAllEnable: boolean; + name: string; + free: string; + locked: string; + freeze: string; + withdrawing: string; + ipoing: string; + ipoable: string; + storage: string; + isLegalMoney: boolean; + trading: boolean; + networkList: NetworkInfo[]; } export interface NetworkInfo { - network: string - coin: string - withdrawIntegerMultiple: string - isDefault: boolean - depositEnable: boolean - withdrawEnable: boolean - depositDesc: string - withdrawDesc: string - specialTips: string - specialWithdrawTips: string - name: string - resetAddressStatus: boolean - addressRegex: string - addressRule: string - memoRegex: string - withdrawFee: string - withdrawMin: string - withdrawMax: string - minConfirm: number - unLockConfirm: number - sameAddress: boolean - estimatedArrivalTime: number - busy: boolean - country: string + network: string; + coin: string; + withdrawIntegerMultiple: string; + isDefault: boolean; + depositEnable: boolean; + withdrawEnable: boolean; + depositDesc: string; + withdrawDesc: string; + specialTips: string; + specialWithdrawTips: string; + name: string; + resetAddressStatus: boolean; + addressRegex: string; + addressRule: string; + memoRegex: string; + withdrawFee: string; + withdrawMin: string; + withdrawMax: string; + minConfirm: number; + unLockConfirm: number; + sameAddress: boolean; + estimatedArrivalTime: number; + busy: boolean; + country: string; } /** * Staking */ export interface StakingAsset { - stakingAsset: string - rewardAsset: string - apr: string - apy: string - unstakingPeriod: number - minStakingAmount: string - maxStakingAmount: string - autoRestake: boolean + stakingAsset: string; + rewardAsset: string; + apr: string; + apy: string; + unstakingPeriod: number; + minStakingAmount: string; + maxStakingAmount: string; + autoRestake: boolean; } export interface StakingBalance { - stakingAsset: string - holdingInStaking: string - pendingRedemption: string + stakingAsset: string; + holdingInStaking: string; + pendingRedemption: string; } /** * OTC Trading */ export interface OtcCoinPair { - fromCoin: string - toCoin: string - fromCoinMinAmount: string - fromCoinMaxAmount: string - toCoinMinAmount: string - toCoinMaxAmount: string + fromCoin: string; + toCoin: string; + fromCoinMinAmount: string; + fromCoinMaxAmount: string; + toCoinMinAmount: string; + toCoinMaxAmount: string; } export interface OtcQuote { - symbol: string - ratio: string - inverseRatio: string - validTimestamp: number - toAmount: string - fromAmount: string + symbol: string; + ratio: string; + inverseRatio: string; + validTimestamp: number; + toAmount: string; + fromAmount: string; } /** * User Data Stream */ export interface ListenKeyResponse { - listenKey: string + listenKey: string; } /** * Custodial Solution Types (Unique to Binance.US) */ export interface CustodialAccountInfo { - email: string - canTrade: boolean - canWithdraw: boolean - canDeposit: boolean - balances: Balance[] + email: string; + canTrade: boolean; + canWithdraw: boolean; + canDeposit: boolean; + balances: Balance[]; } export interface CustodialTransfer { - txnId: string - clientTranId?: string - asset: string - amount: string - fromEmail: string - toEmail: string - status: string - timestamp: number + txnId: string; + clientTranId?: string; + asset: string; + amount: string; + fromEmail: string; + toEmail: string; + status: string; + timestamp: number; } /** * Credit Line Types (Unique to Binance.US) */ export interface CreditLineAccount { - collaterals: CreditLineCollateral[] - loans: CreditLineLoan[] - creditLimit: string - availableCredit: string - usedCredit: string - status: string + collaterals: CreditLineCollateral[]; + loans: CreditLineLoan[]; + creditLimit: string; + availableCredit: string; + usedCredit: string; + status: string; } export interface CreditLineCollateral { - asset: string - amount: string - collateralValue: string + asset: string; + amount: string; + collateralValue: string; } export interface CreditLineLoan { - loanAsset: string - loanAmount: string - interestRate: string - accrueInterest: string + loanAsset: string; + loanAmount: string; + interestRate: string; + accrueInterest: string; } export interface CreditLineAlert { - alertId: string - alertType: string - alertTime: number - message: string + alertId: string; + alertType: string; + alertTime: number; + message: string; } /** * Sub-Account Types */ export interface SubAccount { - email: string - isFreeze: boolean - createTime: number - isManagedSubAccount: boolean - isAssetManagementSubAccount: boolean + email: string; + isFreeze: boolean; + createTime: number; + isManagedSubAccount: boolean; + isAssetManagementSubAccount: boolean; } export interface SubAccountTransfer { - tranId: number - clientTranId?: string - fromEmail: string - toEmail: string - asset: string - amount: string - timestamp: number - status: string + tranId: number; + clientTranId?: string; + fromEmail: string; + toEmail: string; + asset: string; + amount: string; + timestamp: number; + status: string; } /** @@ -513,6 +518,6 @@ export const ERROR_CODES = { BAD_API_KEY_FMT: -2014, REJECTED_MBX_KEY: -2015, ORDER_ARCHIVED: -2026, -} as const +} as const; -export type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES] +export type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES]; diff --git a/src/index.ts b/src/index.ts index 39e26e36..046bdf94 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,16 +1,16 @@ #!/usr/bin/env node -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" -import type { Server } from "http" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; +import type { Server } from "http"; -import { logTestnetStatus } from "./config/testnet.js" -import { startSSEServer } from "./server/sse.js" -import { startStdioServer } from "./server/stdio.js" -import Logger from "./utils/logger.js" +import { logTestnetStatus } from "./config/testnet.js"; +import { startSSEServer } from "./server/sse.js"; +import { startStdioServer } from "./server/stdio.js"; +import Logger from "./utils/logger.js"; -const args = process.argv.slice(2) +const args = process.argv.slice(2); // Transport mode flags -const sseMode = args.includes("--sse") || args.includes("-s") +const sseMode = args.includes("--sse") || args.includes("-s"); function printUsage() { console.log(` @@ -35,42 +35,42 @@ Examples: # SSE mode binance-mcp --sse -`) +`); } async function main() { if (args.includes("--help")) { - printUsage() - process.exit(0) + printUsage(); + process.exit(0); } - logTestnetStatus() + logTestnetStatus(); - let handle: McpServer | Server | undefined + let handle: McpServer | Server | undefined; if (sseMode) { - Logger.info("Starting in SSE mode") - handle = await startSSEServer() + Logger.info("Starting in SSE mode"); + handle = await startSSEServer(); } else { - handle = await startStdioServer() + handle = await startStdioServer(); } if (!handle) { - Logger.error("Failed to start server") - process.exit(1) + Logger.error("Failed to start server"); + process.exit(1); } - const server = handle + const server = handle; const handleShutdown = async () => { if ("close" in server && typeof server.close === "function") { - await server.close() + await server.close(); } - process.exit(0) - } + process.exit(0); + }; - process.on("SIGINT", handleShutdown) - process.on("SIGTERM", handleShutdown) + process.on("SIGINT", handleShutdown); + process.on("SIGTERM", handleShutdown); } -main() +main(); diff --git a/src/init.ts b/src/init.ts index 73ffd90b..29398d4c 100644 --- a/src/init.ts +++ b/src/init.ts @@ -1,41 +1,41 @@ -import type { PromptObject } from "prompts" +import type { PromptObject } from "prompts"; -import os from "os" -import path from "path" -import { fileURLToPath } from "url" +import os from "os"; +import path from "path"; +import { fileURLToPath } from "url"; -import chalk from "chalk" -import dotenv from "dotenv" -import figlet from "figlet" -import fs from "fs-extra" -import prompts from "prompts" -dotenv.config() +import chalk from "chalk"; +import dotenv from "dotenv"; +import figlet from "figlet"; +import fs from "fs-extra"; +import prompts from "prompts"; +dotenv.config(); // Binance Gold Color -const yellow = chalk.hex("#F0B90B") +const yellow = chalk.hex("#F0B90B"); // ESModule __dirname workaround -const __filename = fileURLToPath(import.meta.url) -const __dirname = path.dirname(__filename) +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); // Cancel handler const onCancel = () => { - console.log(chalk.red("\n❌ Configuration cancelled by user (Ctrl+C or ESC). Exiting...")) - process.exit(0) -} + console.log(chalk.red("\n❌ Configuration cancelled by user (Ctrl+C or ESC). Exiting...")); + process.exit(0); +}; // Show Banner const showBanner = () => { - const banner = figlet.textSync("Binance MCP ", { font: "Big" }) - console.log(yellow(banner)) - console.log(yellow("🚀 Welcome to the Binance MCP Configurator\n")) -} + const banner = figlet.textSync("Binance MCP ", { font: "Big" }); + console.log(yellow(banner)); + console.log(yellow("🚀 Welcome to the Binance MCP Configurator\n")); +}; // User Input Types interface UserInputs { - BINANCE_API_KEY: string - BINANCE_API_SECRET: string - BINANCE_TESTNET: boolean + BINANCE_API_KEY: string; + BINANCE_API_SECRET: string; + BINANCE_TESTNET: boolean; } // Ask for credentials @@ -59,10 +59,10 @@ const getInputs = async (): Promise => { message: "🧪 Use Binance Spot Test Network? (testnet.binance.vision)", initial: false, }, - ] + ]; - return (await prompts(questions, { onCancel })) as UserInputs -} + return (await prompts(questions, { onCancel })) as UserInputs; +}; // Generate .env file const generateEnvFile = async ( @@ -74,11 +74,11 @@ const generateEnvFile = async ( BINANCE_API_KEY=${BINANCE_API_KEY} BINANCE_API_SECRET=${BINANCE_API_SECRET} BINANCE_TESTNET=${BINANCE_TESTNET} -`.trim() +`.trim(); - await fs.writeFile(".env", envContent) - console.log(yellow("✅ .env file generated.")) -} + await fs.writeFile(".env", envContent); + console.log(yellow("✅ .env file generated.")); +}; // Generate config object const generateConfig = async ( @@ -86,15 +86,15 @@ const generateConfig = async ( BINANCE_API_SECRET: string, BINANCE_TESTNET: boolean, ): Promise => { - const indexPath = path.resolve(__dirname, "..", "build", "index.js") // one level up from cli/ + const indexPath = path.resolve(__dirname, "..", "build", "index.js"); // one level up from cli/ const env: Record = { BINANCE_API_KEY: BINANCE_API_KEY, BINANCE_API_SECRET: BINANCE_API_SECRET, - } + }; if (BINANCE_TESTNET) { - env.BINANCE_TESTNET = "true" + env.BINANCE_TESTNET = "true"; } return { @@ -105,25 +105,25 @@ const generateConfig = async ( disabled: false, autoApprove: [], }, - } -} + }; +}; // Configure Claude Desktop const configureClaude = async (config: object): Promise => { - const userHome = os.homedir() - let claudePath - const platform = os.platform() + const userHome = os.homedir(); + let claudePath; + const platform = os.platform(); if (platform == "darwin") { claudePath = path.join( userHome, "Library/Application Support/Claude/claude_desktop_config.json", - ) + ); } else if (platform == "win32") { - claudePath = path.join(userHome, "AppData", "Roaming", "Claude", "claude_desktop_config.json") + claudePath = path.join(userHome, "AppData", "Roaming", "Claude", "claude_desktop_config.json"); } else { - console.log(chalk.red("❌ Unsupported platform.")) + console.log(chalk.red("❌ Unsupported platform.")); - return false + return false; } if (!fs.existsSync(claudePath)) { @@ -131,46 +131,46 @@ const configureClaude = async (config: object): Promise => { chalk.yellow( "⚠️ Claude config file not found. Creating a new one with default configuration.", ), - ) + ); // Create a default configuration object const defaultConfig = { mcpServers: {}, - } + }; // Write the default configuration to the file - await fs.writeJSON(claudePath, defaultConfig, { spaces: 2 }) + await fs.writeJSON(claudePath, defaultConfig, { spaces: 2 }); } - const jsonData = fs.readFileSync(claudePath, "utf8") - const data = JSON.parse(jsonData) + const jsonData = fs.readFileSync(claudePath, "utf8"); + const data = JSON.parse(jsonData); data.mcpServers = { ...data.mcpServers, ...config, - } + }; - await fs.writeJSON(claudePath, data, { spaces: 2 }) + await fs.writeJSON(claudePath, data, { spaces: 2 }); console.log( yellow( "✅ Binance MCP configured for Claude Desktop. Please RESTART your Claude to enjoy it 🎉", ), - ) + ); - return true -} + return true; +}; // Save fallback config file const saveFallbackConfig = async (config: object): Promise => { - await fs.writeJSON("config.json", config, { spaces: 2 }) - console.log(yellow("📁 Saved config.json in root project folder.")) -} + await fs.writeJSON("config.json", config, { spaces: 2 }); + console.log(yellow("📁 Saved config.json in root project folder.")); +}; // Main logic const init = async () => { - showBanner() + showBanner(); - const { BINANCE_API_KEY, BINANCE_API_SECRET, BINANCE_TESTNET } = await getInputs() + const { BINANCE_API_KEY, BINANCE_API_SECRET, BINANCE_TESTNET } = await getInputs(); - await generateEnvFile(BINANCE_API_KEY, BINANCE_API_SECRET, BINANCE_TESTNET) + await generateEnvFile(BINANCE_API_KEY, BINANCE_API_SECRET, BINANCE_TESTNET); if (BINANCE_TESTNET) { console.log( @@ -178,10 +178,10 @@ const init = async () => { "🧪 Testnet mode enabled — API calls will go to testnet.binance.vision. " + "Only /api endpoints (spot trading & market data) are available.", ), - ) + ); } - const config = await generateConfig(BINANCE_API_KEY, BINANCE_API_SECRET, BINANCE_TESTNET) + const config = await generateConfig(BINANCE_API_KEY, BINANCE_API_SECRET, BINANCE_TESTNET); const { setupClaude } = await prompts( { @@ -191,16 +191,16 @@ const init = async () => { initial: true, }, { onCancel }, - ) + ); if (setupClaude) { - const success = await configureClaude(config) + const success = await configureClaude(config); if (!success) { - await saveFallbackConfig(config) + await saveFallbackConfig(config); } } else { - await saveFallbackConfig(config) + await saveFallbackConfig(config); } -} +}; -init() +init(); diff --git a/src/modules/algo/future-algo/TwapNewTrade.ts b/src/modules/algo/future-algo/TwapNewTrade.ts index 4be4e66d..cc8c2713 100644 --- a/src/modules/algo/future-algo/TwapNewTrade.ts +++ b/src/modules/algo/future-algo/TwapNewTrade.ts @@ -1,9 +1,9 @@ // src/tools/binance-algo/future-algo/TwapNewTrade.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { algoClient } from "../../../config/binanceClient.js" +import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceTwapNewTrade(server: McpServer) { server.tool( @@ -60,9 +60,9 @@ export function registerBinanceTwapNewTrade(server: McpServer) { ...(params.reduceOnly !== undefined && { reduceOnly: params.reduceOnly }), ...(params.limitPrice !== undefined && { limitPrice: params.limitPrice }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -73,9 +73,9 @@ export function registerBinanceTwapNewTrade(server: McpServer) { }. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -85,8 +85,8 @@ export function registerBinanceTwapNewTrade(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/algo/future-algo/VPNewTrade.ts b/src/modules/algo/future-algo/VPNewTrade.ts index d9ab7294..007c0f01 100644 --- a/src/modules/algo/future-algo/VPNewTrade.ts +++ b/src/modules/algo/future-algo/VPNewTrade.ts @@ -1,9 +1,9 @@ // src/tools/binance-algo/future-algo/VPNewTrade.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { algoClient } from "../../../config/binanceClient.js" +import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceVPNewTrade(server: McpServer) { server.tool( @@ -55,9 +55,9 @@ export function registerBinanceVPNewTrade(server: McpServer) { ...(params.reduceOnly !== undefined && { reduceOnly: params.reduceOnly }), ...(params.limitPrice !== undefined && { limitPrice: params.limitPrice }), recvWindow: params.recvWindow, - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -68,9 +68,9 @@ export function registerBinanceVPNewTrade(server: McpServer) { }. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -80,8 +80,8 @@ export function registerBinanceVPNewTrade(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/algo/future-algo/cancelAlgoOrder.ts b/src/modules/algo/future-algo/cancelAlgoOrder.ts index e068f8bb..d41e0867 100644 --- a/src/modules/algo/future-algo/cancelAlgoOrder.ts +++ b/src/modules/algo/future-algo/cancelAlgoOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-algo/future-algo/cancelAlgoOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { algoClient } from "../../../config/binanceClient.js" +import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceFutureCancelAlgoOrder(server: McpServer) { server.tool( @@ -18,9 +18,9 @@ export function registerBinanceFutureCancelAlgoOrder(server: McpServer) { const response = await algoClient.restAPI.cancelAlgoOrderFutureAlgo({ algoId: params.algoId, ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,9 +29,9 @@ export function registerBinanceFutureCancelAlgoOrder(server: McpServer) { text: `Algo order ${params.algoId} canceled successfully. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -41,8 +41,8 @@ export function registerBinanceFutureCancelAlgoOrder(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/algo/future-algo/currentAlgoOpenOrders.ts b/src/modules/algo/future-algo/currentAlgoOpenOrders.ts index 39890130..1001a67b 100644 --- a/src/modules/algo/future-algo/currentAlgoOpenOrders.ts +++ b/src/modules/algo/future-algo/currentAlgoOpenOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-algo/future-algo/currentAlgoOpenOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { algoClient } from "../../../config/binanceClient.js" +import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceFutureCurrentAlgoOpenOrders(server: McpServer) { server.tool( @@ -16,9 +16,9 @@ export function registerBinanceFutureCurrentAlgoOpenOrders(server: McpServer) { try { const response = await algoClient.restAPI.queryCurrentAlgoOpenOrdersFutureAlgo({ ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -27,9 +27,9 @@ export function registerBinanceFutureCurrentAlgoOpenOrders(server: McpServer) { text: `Currently active algorithmic orders. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -39,8 +39,8 @@ export function registerBinanceFutureCurrentAlgoOpenOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/algo/future-algo/historicalAlgoOrder.ts b/src/modules/algo/future-algo/historicalAlgoOrder.ts index 50583309..edafa7a9 100644 --- a/src/modules/algo/future-algo/historicalAlgoOrder.ts +++ b/src/modules/algo/future-algo/historicalAlgoOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-algo/future-algo/historicalAlgoOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { algoClient } from "../../../config/binanceClient.js" +import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceFutureHistoricalAlgoOrder(server: McpServer) { server.tool( @@ -43,9 +43,9 @@ export function registerBinanceFutureHistoricalAlgoOrder(server: McpServer) { ...(params.page !== undefined && { page: params.page }), ...(params.pageSize !== undefined && { pageSize: params.pageSize }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -54,9 +54,9 @@ export function registerBinanceFutureHistoricalAlgoOrder(server: McpServer) { text: `Historical Algo Orders retrieves successfully. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -66,8 +66,8 @@ export function registerBinanceFutureHistoricalAlgoOrder(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/algo/future-algo/index.ts b/src/modules/algo/future-algo/index.ts index 4369d2aa..503ac247 100644 --- a/src/modules/algo/future-algo/index.ts +++ b/src/modules/algo/future-algo/index.ts @@ -1,29 +1,29 @@ // src/tools/binance-spot/market-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceFutureCancelAlgoOrder } from "./cancelAlgoOrder.js" -import { registerBinanceFutureCurrentAlgoOpenOrders } from "./currentAlgoOpenOrders.js" -import { registerBinanceFutureHistoricalAlgoOrder } from "./historicalAlgoOrder.js" -import { registerBinanceFutureSubOrders } from "./subOrders.js" -import { registerBinanceTwapNewTrade } from "./TwapNewTrade.js" -import { registerBinanceVPNewTrade } from "./VPNewTrade.js" +import { registerBinanceFutureCancelAlgoOrder } from "./cancelAlgoOrder.js"; +import { registerBinanceFutureCurrentAlgoOpenOrders } from "./currentAlgoOpenOrders.js"; +import { registerBinanceFutureHistoricalAlgoOrder } from "./historicalAlgoOrder.js"; +import { registerBinanceFutureSubOrders } from "./subOrders.js"; +import { registerBinanceTwapNewTrade } from "./TwapNewTrade.js"; +import { registerBinanceVPNewTrade } from "./VPNewTrade.js"; export function registerBinanceAlgoFutureApiTools(server: McpServer) { // Registers a new VP (Volume Participation) trade - registerBinanceVPNewTrade(server) + registerBinanceVPNewTrade(server); // Registers a new TWAP (Time-Weighted Average Price) trade - registerBinanceTwapNewTrade(server) + registerBinanceTwapNewTrade(server); // Registers functionality to cancel an algorithmic order - registerBinanceFutureCancelAlgoOrder(server) + registerBinanceFutureCancelAlgoOrder(server); // Registers API to query sub-orders of an algorithmic order - registerBinanceFutureSubOrders(server) + registerBinanceFutureSubOrders(server); // Registers API to retrieve currently open algorithmic orders - registerBinanceFutureCurrentAlgoOpenOrders(server) + registerBinanceFutureCurrentAlgoOpenOrders(server); // Registers API to fetch historical algorithmic orders - registerBinanceFutureHistoricalAlgoOrder(server) + registerBinanceFutureHistoricalAlgoOrder(server); } diff --git a/src/modules/algo/future-algo/subOrders.ts b/src/modules/algo/future-algo/subOrders.ts index 4a46a1d7..e0306890 100644 --- a/src/modules/algo/future-algo/subOrders.ts +++ b/src/modules/algo/future-algo/subOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-algo/future-algo/subOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { algoClient } from "../../../config/binanceClient.js" +import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceFutureSubOrders(server: McpServer) { server.tool( @@ -29,9 +29,9 @@ export function registerBinanceFutureSubOrders(server: McpServer) { page: params.page, pageSize: params.pageSize, ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -42,9 +42,9 @@ export function registerBinanceFutureSubOrders(server: McpServer) { }. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -54,8 +54,8 @@ export function registerBinanceFutureSubOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/algo/index.ts b/src/modules/algo/index.ts index 4dae6dbb..feaa771c 100644 --- a/src/modules/algo/index.ts +++ b/src/modules/algo/index.ts @@ -1,14 +1,14 @@ // src/tools/binance-spot/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceAlgoFutureApiTools } from "./future-algo/index.js" -import { registerBinanceAlgoSpotApiTools } from "./spot-algo/index.js" +import { registerBinanceAlgoFutureApiTools } from "./future-algo/index.js"; +import { registerBinanceAlgoSpotApiTools } from "./spot-algo/index.js"; export function registerBinanceAlgoTools(server: McpServer) { // Algo API tools - registerBinanceAlgoFutureApiTools(server) - registerBinanceAlgoSpotApiTools(server) + registerBinanceAlgoFutureApiTools(server); + registerBinanceAlgoSpotApiTools(server); } // Alias for binance.ts compatibility -export { registerBinanceAlgoTools as registerAlgo } +export { registerBinanceAlgoTools as registerAlgo }; diff --git a/src/modules/algo/spot-algo/cancelOpenTWAPOrder.ts b/src/modules/algo/spot-algo/cancelOpenTWAPOrder.ts index 3517999e..3652e326 100644 --- a/src/modules/algo/spot-algo/cancelOpenTWAPOrder.ts +++ b/src/modules/algo/spot-algo/cancelOpenTWAPOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-algo/spot-algo/cancelOpenTWAPOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { algoClient } from "../../../config/binanceClient.js" +import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceSpotCancelOpenTWAPOrder(server: McpServer) { server.tool( @@ -18,9 +18,9 @@ export function registerBinanceSpotCancelOpenTWAPOrder(server: McpServer) { const response = await algoClient.restAPI.cancelAlgoOrderSpotAlgo({ algoId: params.algoId, ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,9 +29,9 @@ export function registerBinanceSpotCancelOpenTWAPOrder(server: McpServer) { text: `Algo order ${params.algoId} canceled successfully. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -41,8 +41,8 @@ export function registerBinanceSpotCancelOpenTWAPOrder(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/algo/spot-algo/currentAlgoOpenOrders.ts b/src/modules/algo/spot-algo/currentAlgoOpenOrders.ts index 14b6d6cc..28bca403 100644 --- a/src/modules/algo/spot-algo/currentAlgoOpenOrders.ts +++ b/src/modules/algo/spot-algo/currentAlgoOpenOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-algo/spot-algo/currentAlgoOpenOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { algoClient } from "../../../config/binanceClient.js" +import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceSpotCurrentAlgoOpenOrders(server: McpServer) { server.tool( @@ -16,9 +16,9 @@ export function registerBinanceSpotCurrentAlgoOpenOrders(server: McpServer) { try { const response = await algoClient.restAPI.queryCurrentAlgoOpenOrdersSpotAlgo({ ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,9 +29,9 @@ export function registerBinanceSpotCurrentAlgoOpenOrders(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -41,8 +41,8 @@ export function registerBinanceSpotCurrentAlgoOpenOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/algo/spot-algo/historicalAlgoOrders.ts b/src/modules/algo/spot-algo/historicalAlgoOrders.ts index 543a9c62..bcdba16c 100644 --- a/src/modules/algo/spot-algo/historicalAlgoOrders.ts +++ b/src/modules/algo/spot-algo/historicalAlgoOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-algo/spot-algo/historicalAlgoOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { algoClient } from "../../../config/binanceClient.js" +import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceSpotHistoricalAlgoOrders(server: McpServer) { server.tool( @@ -43,9 +43,9 @@ export function registerBinanceSpotHistoricalAlgoOrders(server: McpServer) { ...(params.page && { page: params.page }), ...(params.pageSize && { pageSize: params.pageSize }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -56,9 +56,9 @@ export function registerBinanceSpotHistoricalAlgoOrders(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -68,8 +68,8 @@ export function registerBinanceSpotHistoricalAlgoOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/algo/spot-algo/index.ts b/src/modules/algo/spot-algo/index.ts index a8f1e420..366e4f7d 100644 --- a/src/modules/algo/spot-algo/index.ts +++ b/src/modules/algo/spot-algo/index.ts @@ -1,25 +1,25 @@ // src/tools/binance-spot/market-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceSpotCancelOpenTWAPOrder } from "./cancelOpenTWAPOrder.js" -import { registerBinanceSpotCurrentAlgoOpenOrders } from "./currentAlgoOpenOrders.js" -import { registerBinanceSpotHistoricalAlgoOrders } from "./historicalAlgoOrders.js" -import { registerBinanceSpotTwapNewTrade } from "./spotTWAPOrder.js" -import { registerBinanceSpotSubOrders } from "./subOrders.js" +import { registerBinanceSpotCancelOpenTWAPOrder } from "./cancelOpenTWAPOrder.js"; +import { registerBinanceSpotCurrentAlgoOpenOrders } from "./currentAlgoOpenOrders.js"; +import { registerBinanceSpotHistoricalAlgoOrders } from "./historicalAlgoOrders.js"; +import { registerBinanceSpotTwapNewTrade } from "./spotTWAPOrder.js"; +import { registerBinanceSpotSubOrders } from "./subOrders.js"; export function registerBinanceAlgoSpotApiTools(server: McpServer) { // Register the TWAP (Time-Weighted Average Price) tool for placing new spot algo orders - registerBinanceSpotTwapNewTrade(server) + registerBinanceSpotTwapNewTrade(server); // Register the tool for canceling open TWAP spot algo orders - registerBinanceSpotCancelOpenTWAPOrder(server) + registerBinanceSpotCancelOpenTWAPOrder(server); // Register the tool to handle sub-orders created under a parent algo order - registerBinanceSpotSubOrders(server) + registerBinanceSpotSubOrders(server); // Register the tool to fetch currently open algo orders for spot trading - registerBinanceSpotCurrentAlgoOpenOrders(server) + registerBinanceSpotCurrentAlgoOpenOrders(server); // Register the tool to fetch historical algo orders for spot trading - registerBinanceSpotHistoricalAlgoOrders(server) + registerBinanceSpotHistoricalAlgoOrders(server); } diff --git a/src/modules/algo/spot-algo/spotTWAPOrder.ts b/src/modules/algo/spot-algo/spotTWAPOrder.ts index 03510e6c..05f6b156 100644 --- a/src/modules/algo/spot-algo/spotTWAPOrder.ts +++ b/src/modules/algo/spot-algo/spotTWAPOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-algo/spot-algo/spotTwapNewTrade.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { algoClient } from "../../../config/binanceClient.js" +import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceSpotTwapNewTrade(server: McpServer) { server.tool( @@ -46,9 +46,9 @@ export function registerBinanceSpotTwapNewTrade(server: McpServer) { duration: params.duration, ...(params.clientAlgoId !== undefined && { clientAlgoId: params.clientAlgoId }), ...(params.limitPrice !== undefined && { limitPrice: params.limitPrice }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -59,9 +59,9 @@ export function registerBinanceSpotTwapNewTrade(server: McpServer) { }. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -71,8 +71,8 @@ export function registerBinanceSpotTwapNewTrade(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/algo/spot-algo/subOrders.ts b/src/modules/algo/spot-algo/subOrders.ts index 2c7ac0c4..03bd51f7 100644 --- a/src/modules/algo/spot-algo/subOrders.ts +++ b/src/modules/algo/spot-algo/subOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-algo/spot-algo/subOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { algoClient } from "../../../config/binanceClient.js" +import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceSpotSubOrders(server: McpServer) { server.tool( @@ -29,9 +29,9 @@ export function registerBinanceSpotSubOrders(server: McpServer) { ...(params.page !== undefined && { page: params.page }), ...(params.pageSize !== undefined && { pageSize: params.pageSize }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -42,9 +42,9 @@ export function registerBinanceSpotSubOrders(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -54,8 +54,8 @@ export function registerBinanceSpotSubOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/auto-invest/changePlanStatus.ts b/src/modules/auto-invest/changePlanStatus.ts index c8a51a7b..91337e6b 100644 --- a/src/modules/auto-invest/changePlanStatus.ts +++ b/src/modules/auto-invest/changePlanStatus.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/auto-invest/changePlanStatus.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerAutoInvestChangePlanStatus(server: McpServer) { server.tool( @@ -28,11 +28,11 @@ export function registerAutoInvestChangePlanStatus(server: McpServer) { planId: params.planId, status: params.status, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - const statusText = params.status === "ONGOING" ? "resumed" : "paused" + const statusText = params.status === "ONGOING" ? "resumed" : "paused"; return { content: [ @@ -41,9 +41,9 @@ export function registerAutoInvestChangePlanStatus(server: McpServer) { text: `✅ Auto-invest plan ${statusText}!\n\nPlan ID: ${params.planId}\nNew Status: ${params.status}\n\nResponse: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -53,8 +53,8 @@ export function registerAutoInvestChangePlanStatus(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/auto-invest/createPlan.ts b/src/modules/auto-invest/createPlan.ts index 1ef727e4..203e8197 100644 --- a/src/modules/auto-invest/createPlan.ts +++ b/src/modules/auto-invest/createPlan.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/auto-invest/createPlan.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerAutoInvestCreatePlan(server: McpServer) { server.tool( @@ -55,9 +55,9 @@ export function registerAutoInvestCreatePlan(server: McpServer) { flexibleAllowedToUse: params.flexibleAllowedToUse, }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -66,9 +66,9 @@ export function registerAutoInvestCreatePlan(server: McpServer) { text: `✅ Auto-invest plan created!\n\nPlan ID: ${data.planId}\nNext Execution: ${data.nextExecutionDateTime || "Scheduled"}\n\nYour recurring investment plan is now active.`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -78,8 +78,8 @@ export function registerAutoInvestCreatePlan(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/auto-invest/editPlan.ts b/src/modules/auto-invest/editPlan.ts index dc3982f1..a7df3faf 100644 --- a/src/modules/auto-invest/editPlan.ts +++ b/src/modules/auto-invest/editPlan.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/auto-invest/editPlan.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerAutoInvestEditPlan(server: McpServer) { server.tool( @@ -53,9 +53,9 @@ export function registerAutoInvestEditPlan(server: McpServer) { flexibleAllowedToUse: params.flexibleAllowedToUse, }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -64,9 +64,9 @@ export function registerAutoInvestEditPlan(server: McpServer) { text: `✅ Auto-invest plan updated!\n\nPlan ID: ${params.planId}\nNext Execution: ${data.nextExecutionDateTime || "Scheduled"}\n\nYour plan has been modified.`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -76,8 +76,8 @@ export function registerAutoInvestEditPlan(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/auto-invest/getHistoryList.ts b/src/modules/auto-invest/getHistoryList.ts index ae773010..09222360 100644 --- a/src/modules/auto-invest/getHistoryList.ts +++ b/src/modules/auto-invest/getHistoryList.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/auto-invest/getHistoryList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerAutoInvestGetHistoryList(server: McpServer) { server.tool( @@ -45,31 +45,31 @@ export function registerAutoInvestGetHistoryList(server: McpServer) { ...(params.size && { size: params.size }), ...(params.current && { current: params.current }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Auto-Invest Transaction History\n\n` + let result = `✅ Auto-Invest Transaction History\n\n`; - const history = data.list || data.data || data + const history = data.list || data.data || data; if (Array.isArray(history) && history.length > 0) { - result += `Total transactions: ${data.total || history.length}\n\n` + result += `Total transactions: ${data.total || history.length}\n\n`; history.slice(0, 20).forEach((tx: any, index: number) => { - result += `**${index + 1}. Transaction ID: ${tx.id || tx.transactionId}**\n` - result += ` Plan ID: ${tx.planId}\n` - result += ` Target Asset: ${tx.targetAsset}\n` - result += ` Source Asset: ${tx.sourceAsset}\n` - result += ` Source Amount: ${tx.sourceAmount || tx.sourceAssetAmount}\n` - result += ` Target Amount: ${tx.targetAmount || tx.targetAssetAmount}\n` - result += ` Status: ${tx.status}\n` - result += ` Time: ${tx.transactionDateTime || new Date(tx.time).toISOString()}\n\n` - }) + result += `**${index + 1}. Transaction ID: ${tx.id || tx.transactionId}**\n`; + result += ` Plan ID: ${tx.planId}\n`; + result += ` Target Asset: ${tx.targetAsset}\n`; + result += ` Source Asset: ${tx.sourceAsset}\n`; + result += ` Source Amount: ${tx.sourceAmount || tx.sourceAssetAmount}\n`; + result += ` Target Amount: ${tx.targetAmount || tx.targetAssetAmount}\n`; + result += ` Status: ${tx.status}\n`; + result += ` Time: ${tx.transactionDateTime || new Date(tx.time).toISOString()}\n\n`; + }); if (history.length > 20) { - result += `... and ${history.length - 20} more transactions` + result += `... and ${history.length - 20} more transactions`; } } else { - result += `No transaction history found` + result += `No transaction history found`; } return { @@ -79,9 +79,9 @@ export function registerAutoInvestGetHistoryList(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -91,8 +91,8 @@ export function registerAutoInvestGetHistoryList(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/auto-invest/getIndexInfo.ts b/src/modules/auto-invest/getIndexInfo.ts index c51600f1..2cc94533 100644 --- a/src/modules/auto-invest/getIndexInfo.ts +++ b/src/modules/auto-invest/getIndexInfo.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/auto-invest/getIndexInfo.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerAutoInvestGetIndexInfo(server: McpServer) { server.tool( @@ -24,28 +24,28 @@ export function registerAutoInvestGetIndexInfo(server: McpServer) { const response = await autoInvestClient.restAPI.indexInfo({ ...(params.indexId && { indexId: params.indexId }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Auto-Invest Index Information\n\n` + let result = `✅ Auto-Invest Index Information\n\n`; if (data.indexId) { - result += `**Index ID: ${data.indexId}**\n` - result += `Status: ${data.status}\n\n` + result += `**Index ID: ${data.indexId}**\n`; + result += `Status: ${data.status}\n\n`; if (data.assetAllocation && Array.isArray(data.assetAllocation)) { - result += `**Asset Allocation**\n` + result += `**Asset Allocation**\n`; data.assetAllocation.forEach((asset: any) => { - result += `- ${asset.targetAsset}: ${asset.allocation}%\n` - }) + result += `- ${asset.targetAsset}: ${asset.allocation}%\n`; + }); } } else if (Array.isArray(data)) { data.forEach((index: any) => { - result += `**Index ID: ${index.indexId}**\n` - result += `Status: ${index.status}\n\n` - }) + result += `**Index ID: ${index.indexId}**\n`; + result += `Status: ${index.status}\n\n`; + }); } else { - result += `Index Info: ${JSON.stringify(data)}` + result += `Index Info: ${JSON.stringify(data)}`; } return { @@ -55,9 +55,9 @@ export function registerAutoInvestGetIndexInfo(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -67,8 +67,8 @@ export function registerAutoInvestGetIndexInfo(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/auto-invest/getIndexLinkedPlanPositionDetails.ts b/src/modules/auto-invest/getIndexLinkedPlanPositionDetails.ts index 243e3d09..8af4df8c 100644 --- a/src/modules/auto-invest/getIndexLinkedPlanPositionDetails.ts +++ b/src/modules/auto-invest/getIndexLinkedPlanPositionDetails.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/auto-invest/getIndexLinkedPlanPositionDetails.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerAutoInvestGetIndexLinkedPlanPositionDetails(server: McpServer) { server.tool( @@ -24,31 +24,31 @@ export function registerAutoInvestGetIndexLinkedPlanPositionDetails(server: McpS const response = await autoInvestClient.restAPI.planId({ planId: params.planId, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Auto-Invest Plan Details\n\n` - result += `Plan ID: ${params.planId}\n\n` + let result = `✅ Auto-Invest Plan Details\n\n`; + result += `Plan ID: ${params.planId}\n\n`; if (data) { - result += `**Plan Configuration**\n` - result += `Type: ${data.planType || "N/A"}\n` - result += `Status: ${data.status || "N/A"}\n` - result += `Source Asset: ${data.sourceAsset || "N/A"}\n` - result += `Subscription Amount: ${data.subscriptionAmount || "N/A"}\n` - result += `Cycle: ${data.subscriptionCycle || "N/A"}\n` - result += `Next Execution: ${data.nextExecutionDateTime || "N/A"}\n\n` + result += `**Plan Configuration**\n`; + result += `Type: ${data.planType || "N/A"}\n`; + result += `Status: ${data.status || "N/A"}\n`; + result += `Source Asset: ${data.sourceAsset || "N/A"}\n`; + result += `Subscription Amount: ${data.subscriptionAmount || "N/A"}\n`; + result += `Cycle: ${data.subscriptionCycle || "N/A"}\n`; + result += `Next Execution: ${data.nextExecutionDateTime || "N/A"}\n\n`; if (data.details && Array.isArray(data.details)) { - result += `**Position Details**\n` + result += `**Position Details**\n`; data.details.forEach((detail: any) => { - result += `**${detail.targetAsset}** (${detail.percentage}%)\n` - result += ` Purchased Amount: ${detail.purchasedAmount || "0"}\n` - result += ` Average Price: ${detail.avgPrice || "N/A"}\n` - result += ` Current Value: ${detail.currentValue || "N/A"}\n` - result += ` PnL: ${detail.pnl || "N/A"}\n\n` - }) + result += `**${detail.targetAsset}** (${detail.percentage}%)\n`; + result += ` Purchased Amount: ${detail.purchasedAmount || "0"}\n`; + result += ` Average Price: ${detail.avgPrice || "N/A"}\n`; + result += ` Current Value: ${detail.currentValue || "N/A"}\n`; + result += ` PnL: ${detail.pnl || "N/A"}\n\n`; + }); } } @@ -59,9 +59,9 @@ export function registerAutoInvestGetIndexLinkedPlanPositionDetails(server: McpS text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -71,8 +71,8 @@ export function registerAutoInvestGetIndexLinkedPlanPositionDetails(server: McpS }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/auto-invest/getIndexUserSummary.ts b/src/modules/auto-invest/getIndexUserSummary.ts index ea2ba3d9..d71bd812 100644 --- a/src/modules/auto-invest/getIndexUserSummary.ts +++ b/src/modules/auto-invest/getIndexUserSummary.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/auto-invest/getIndexUserSummary.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerAutoInvestGetIndexUserSummary(server: McpServer) { server.tool( @@ -24,18 +24,18 @@ export function registerAutoInvestGetIndexUserSummary(server: McpServer) { const response = await autoInvestClient.restAPI.indexUserSummary({ indexId: params.indexId, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Auto-Invest Index User Summary\n\n` - result += `Index ID: ${params.indexId}\n\n` + let result = `✅ Auto-Invest Index User Summary\n\n`; + result += `Index ID: ${params.indexId}\n\n`; if (data) { - result += `Total Invested: ${data.totalInvestedInUSD || data.totalInvested || "N/A"}\n` - result += `Current Value: ${data.currentInvestedInUSD || data.currentValue || "N/A"}\n` - result += `PnL: ${data.pnlInUSD || data.pnl || "N/A"}\n` - result += `ROI: ${data.roi || "N/A"}%\n` + result += `Total Invested: ${data.totalInvestedInUSD || data.totalInvested || "N/A"}\n`; + result += `Current Value: ${data.currentInvestedInUSD || data.currentValue || "N/A"}\n`; + result += `PnL: ${data.pnlInUSD || data.pnl || "N/A"}\n`; + result += `ROI: ${data.roi || "N/A"}%\n`; } return { @@ -45,9 +45,9 @@ export function registerAutoInvestGetIndexUserSummary(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -57,8 +57,8 @@ export function registerAutoInvestGetIndexUserSummary(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/auto-invest/getPlanList.ts b/src/modules/auto-invest/getPlanList.ts index 07e06457..d3e93e3e 100644 --- a/src/modules/auto-invest/getPlanList.ts +++ b/src/modules/auto-invest/getPlanList.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/auto-invest/getPlanList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerAutoInvestGetPlanList(server: McpServer) { server.tool( @@ -27,35 +27,35 @@ export function registerAutoInvestGetPlanList(server: McpServer) { const response = await autoInvestClient.restAPI.planList({ ...(params.planType && { planType: params.planType }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Auto-Invest Plans\n\n` + let result = `✅ Auto-Invest Plans\n\n`; - const plans = data.planList || data.plans || data + const plans = data.planList || data.plans || data; if (Array.isArray(plans) && plans.length > 0) { - result += `Total plans: ${plans.length}\n\n` + result += `Total plans: ${plans.length}\n\n`; plans.forEach((plan: any, index: number) => { - result += `**${index + 1}. Plan ID: ${plan.planId}**\n` - result += ` Type: ${plan.planType}\n` - result += ` Status: ${plan.status}\n` - result += ` Source Asset: ${plan.sourceAsset}\n` - result += ` Subscription Amount: ${plan.subscriptionAmount}\n` - result += ` Cycle: ${plan.subscriptionCycle}\n` - result += ` Next Execution: ${plan.nextExecutionDateTime || "N/A"}\n\n` + result += `**${index + 1}. Plan ID: ${plan.planId}**\n`; + result += ` Type: ${plan.planType}\n`; + result += ` Status: ${plan.status}\n`; + result += ` Source Asset: ${plan.sourceAsset}\n`; + result += ` Subscription Amount: ${plan.subscriptionAmount}\n`; + result += ` Cycle: ${plan.subscriptionCycle}\n`; + result += ` Next Execution: ${plan.nextExecutionDateTime || "N/A"}\n\n`; if (plan.details && Array.isArray(plan.details)) { - result += ` **Target Assets:**\n` + result += ` **Target Assets:**\n`; plan.details.forEach((detail: any) => { - result += ` - ${detail.targetAsset}: ${detail.percentage}%\n` - }) - result += "\n" + result += ` - ${detail.targetAsset}: ${detail.percentage}%\n`; + }); + result += "\n"; } - }) + }); } else { - result += `No auto-invest plans found` + result += `No auto-invest plans found`; } return { @@ -65,9 +65,9 @@ export function registerAutoInvestGetPlanList(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -77,8 +77,8 @@ export function registerAutoInvestGetPlanList(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/auto-invest/getSourceAssetList.ts b/src/modules/auto-invest/getSourceAssetList.ts index 2f7493c8..dc991fd2 100644 --- a/src/modules/auto-invest/getSourceAssetList.ts +++ b/src/modules/auto-invest/getSourceAssetList.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/auto-invest/getSourceAssetList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerAutoInvestGetSourceAssetList(server: McpServer) { server.tool( @@ -35,27 +35,27 @@ export function registerAutoInvestGetSourceAssetList(server: McpServer) { flexibleAllowedToUse: params.flexibleAllowedToUse, }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Auto-Invest Source Assets\n\n` + let result = `✅ Auto-Invest Source Assets\n\n`; if (data.sourceAssetList && Array.isArray(data.sourceAssetList)) { - result += `Total: ${data.sourceAssetList.length} assets\n\n` + result += `Total: ${data.sourceAssetList.length} assets\n\n`; data.sourceAssetList.forEach((asset: any) => { - result += `**${asset.sourceAsset}**\n` - result += ` Free Amount: ${asset.freeAmount}\n` - result += ` Min Amount: ${asset.minAmount}\n` - result += ` Max Amount: ${asset.maxAmount}\n\n` - }) + result += `**${asset.sourceAsset}**\n`; + result += ` Free Amount: ${asset.freeAmount}\n`; + result += ` Min Amount: ${asset.minAmount}\n`; + result += ` Max Amount: ${asset.maxAmount}\n\n`; + }); } else if (Array.isArray(data)) { data.forEach((asset: any) => { - result += `**${asset.sourceAsset || asset.asset}**\n` - result += ` Available: ${asset.freeAmount || "N/A"}\n\n` - }) + result += `**${asset.sourceAsset || asset.asset}**\n`; + result += ` Available: ${asset.freeAmount || "N/A"}\n\n`; + }); } else { - result += `Source Assets: ${JSON.stringify(data)}` + result += `Source Assets: ${JSON.stringify(data)}`; } return { @@ -65,9 +65,9 @@ export function registerAutoInvestGetSourceAssetList(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -77,8 +77,8 @@ export function registerAutoInvestGetSourceAssetList(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/auto-invest/getTargetAssetList.ts b/src/modules/auto-invest/getTargetAssetList.ts index ba261fef..b693fcc4 100644 --- a/src/modules/auto-invest/getTargetAssetList.ts +++ b/src/modules/auto-invest/getTargetAssetList.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/auto-invest/getTargetAssetList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerAutoInvestGetTargetAssetList(server: McpServer) { server.tool( @@ -34,26 +34,26 @@ export function registerAutoInvestGetTargetAssetList(server: McpServer) { ...(params.size && { size: params.size }), ...(params.current && { current: params.current }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Auto-Invest Target Assets\n\n` + let result = `✅ Auto-Invest Target Assets\n\n`; if (data.data && Array.isArray(data.data) && data.data.length > 0) { - result += `Total assets: ${data.total || data.data.length}\n\n` + result += `Total assets: ${data.total || data.data.length}\n\n`; data.data.forEach((asset: any) => { - result += `**${asset.targetAsset}**\n` - result += ` ROI: ${asset.roiAndDimensionTypeList ? "Available" : "N/A"}\n` - result += ` Available: ${asset.available !== false}\n\n` - }) + result += `**${asset.targetAsset}**\n`; + result += ` ROI: ${asset.roiAndDimensionTypeList ? "Available" : "N/A"}\n`; + result += ` Available: ${asset.available !== false}\n\n`; + }); } else if (Array.isArray(data) && data.length > 0) { data.forEach((asset: any) => { - result += `**${asset.targetAsset || asset.asset}**\n` - result += ` Available: ${asset.available !== false}\n\n` - }) + result += `**${asset.targetAsset || asset.asset}**\n`; + result += ` Available: ${asset.available !== false}\n\n`; + }); } else { - result += `No target assets found` + result += `No target assets found`; } return { @@ -63,9 +63,9 @@ export function registerAutoInvestGetTargetAssetList(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -75,8 +75,8 @@ export function registerAutoInvestGetTargetAssetList(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/auto-invest/getTargetAssetRoiData.ts b/src/modules/auto-invest/getTargetAssetRoiData.ts index ebacd2a5..ba3f3ff5 100644 --- a/src/modules/auto-invest/getTargetAssetRoiData.ts +++ b/src/modules/auto-invest/getTargetAssetRoiData.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/auto-invest/getTargetAssetRoiData.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerAutoInvestGetTargetAssetRoiData(server: McpServer) { server.tool( @@ -28,25 +28,25 @@ export function registerAutoInvestGetTargetAssetRoiData(server: McpServer) { targetAsset: params.targetAsset, hisRoiType: params.hisRoiType, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Auto-Invest ROI Data - ${params.targetAsset}\n\n` - result += `Period: ${params.hisRoiType}\n\n` + let result = `✅ Auto-Invest ROI Data - ${params.targetAsset}\n\n`; + result += `Period: ${params.hisRoiType}\n\n`; if (Array.isArray(data) && data.length > 0) { data.forEach((item: any) => { - result += `Date: ${item.date}\n` - result += ` Simulated ROI: ${item.simulatedRoi}%\n\n` - }) + result += `Date: ${item.date}\n`; + result += ` Simulated ROI: ${item.simulatedRoi}%\n\n`; + }); } else if (data.data && Array.isArray(data.data)) { data.data.forEach((item: any) => { - result += `Date: ${item.date}\n` - result += ` Simulated ROI: ${item.simulatedRoi}%\n\n` - }) + result += `Date: ${item.date}\n`; + result += ` Simulated ROI: ${item.simulatedRoi}%\n\n`; + }); } else { - result += `ROI Data: ${JSON.stringify(data)}` + result += `ROI Data: ${JSON.stringify(data)}`; } return { @@ -56,9 +56,9 @@ export function registerAutoInvestGetTargetAssetRoiData(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -68,8 +68,8 @@ export function registerAutoInvestGetTargetAssetRoiData(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/auto-invest/index.ts b/src/modules/auto-invest/index.ts index 3a74a6f3..3054df49 100644 --- a/src/modules/auto-invest/index.ts +++ b/src/modules/auto-invest/index.ts @@ -1,8 +1,8 @@ // src/modules/auto-invest/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceAutoInvestTools } from "../../tools/binance-auto-invest/index.js" +import { registerBinanceAutoInvestTools } from "../../tools/binance-auto-invest/index.js"; export function registerAutoInvest(server: McpServer) { - registerBinanceAutoInvestTools(server) + registerBinanceAutoInvestTools(server); } diff --git a/src/modules/auto-invest/oneTimeTransaction.ts b/src/modules/auto-invest/oneTimeTransaction.ts index ca1e5b8b..c1ce3cda 100644 --- a/src/modules/auto-invest/oneTimeTransaction.ts +++ b/src/modules/auto-invest/oneTimeTransaction.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/auto-invest/oneTimeTransaction.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerAutoInvestOneTimeTransaction(server: McpServer) { server.tool( @@ -46,10 +46,10 @@ export function registerAutoInvestOneTimeTransaction(server: McpServer) { ...(params.indexId && { indexId: params.indexId }), ...(params.details && { details: JSON.stringify(params.details) }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - } + }; - const response = await autoInvestClient.restAPI.oneOff(requestParams) - const data = await response.data() + const response = await autoInvestClient.restAPI.oneOff(requestParams); + const data = await response.data(); return { content: [ @@ -58,9 +58,9 @@ export function registerAutoInvestOneTimeTransaction(server: McpServer) { text: `✅ One-time auto-invest purchase executed!\n\nTransaction ID: ${data.transactionId || data.tranId || "Completed"}\nAmount: ${params.subscriptionAmount} ${params.sourceAsset}\n\nResponse: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -70,8 +70,8 @@ export function registerAutoInvestOneTimeTransaction(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/auto-invest/rebalanceHistory.ts b/src/modules/auto-invest/rebalanceHistory.ts index 1bb6f1cb..65bfeca3 100644 --- a/src/modules/auto-invest/rebalanceHistory.ts +++ b/src/modules/auto-invest/rebalanceHistory.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/auto-invest/rebalanceHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerAutoInvestRebalanceHistory(server: McpServer) { server.tool( @@ -36,27 +36,27 @@ export function registerAutoInvestRebalanceHistory(server: McpServer) { ...(params.size && { size: params.size }), ...(params.current && { current: params.current }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Auto-Invest Rebalance History\n\n` + let result = `✅ Auto-Invest Rebalance History\n\n`; - const history = data.list || data.data || data + const history = data.list || data.data || data; if (Array.isArray(history) && history.length > 0) { - result += `Total rebalances: ${data.total || history.length}\n\n` + result += `Total rebalances: ${data.total || history.length}\n\n`; history.forEach((rebalance: any, index: number) => { - result += `**${index + 1}. Rebalance ID: ${rebalance.id || rebalance.rebalanceId}**\n` - result += ` Status: ${rebalance.status}\n` - result += ` Time: ${rebalance.rebalanceDateTime || new Date(rebalance.time).toISOString()}\n` + result += `**${index + 1}. Rebalance ID: ${rebalance.id || rebalance.rebalanceId}**\n`; + result += ` Status: ${rebalance.status}\n`; + result += ` Time: ${rebalance.rebalanceDateTime || new Date(rebalance.time).toISOString()}\n`; if (rebalance.details) { - result += ` Details: ${JSON.stringify(rebalance.details)}\n` + result += ` Details: ${JSON.stringify(rebalance.details)}\n`; } - result += "\n" - }) + result += "\n"; + }); } else { - result += `No rebalance history found` + result += `No rebalance history found`; } return { @@ -66,9 +66,9 @@ export function registerAutoInvestRebalanceHistory(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -78,8 +78,8 @@ export function registerAutoInvestRebalanceHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/auto-invest/redemption.ts b/src/modules/auto-invest/redemption.ts index 5a1f395a..7860d1da 100644 --- a/src/modules/auto-invest/redemption.ts +++ b/src/modules/auto-invest/redemption.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/auto-invest/redemption.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerAutoInvestRedemption(server: McpServer) { server.tool( @@ -26,9 +26,9 @@ export function registerAutoInvestRedemption(server: McpServer) { indexId: params.indexId, redemptionPercentage: params.redemptionPercentage, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -37,9 +37,9 @@ export function registerAutoInvestRedemption(server: McpServer) { text: `✅ Auto-invest redemption successful!\n\nIndex ID: ${params.indexId}\nRedemption Percentage: ${params.redemptionPercentage}%\nTransaction ID: ${data.transactionId || data.redemptionId || "Completed"}\n\nResponse: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -49,8 +49,8 @@ export function registerAutoInvestRedemption(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/c2c/C2C/getAds.ts b/src/modules/c2c/C2C/getAds.ts index 11fbc2aa..75cdbcdc 100644 --- a/src/modules/c2c/C2C/getAds.ts +++ b/src/modules/c2c/C2C/getAds.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/c2c/C2C/getAds.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { c2cClient } from "../../../config/binanceClient.js" +import { c2cClient } from "../../../config/binanceClient.js"; export function registerBinanceC2CGetAds(server: McpServer) { server.tool( @@ -32,9 +32,9 @@ export function registerBinanceC2CGetAds(server: McpServer) { ...(params.page && { page: params.page }), ...(params.rows && { rows: params.rows }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -43,9 +43,9 @@ export function registerBinanceC2CGetAds(server: McpServer) { text: `📋 C2C Advertisements\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -55,8 +55,8 @@ export function registerBinanceC2CGetAds(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/c2c/C2C/getC2CTradeHistory.ts b/src/modules/c2c/C2C/getC2CTradeHistory.ts index d3fac5ea..1049e84a 100644 --- a/src/modules/c2c/C2C/getC2CTradeHistory.ts +++ b/src/modules/c2c/C2C/getC2CTradeHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-c2c/getC2CTradeHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { c2cClient } from "../../../config/binanceClient.js" +import { c2cClient } from "../../../config/binanceClient.js"; export function registerBinanceGetC2CTradeHistory(server: McpServer) { server.tool( @@ -22,8 +22,8 @@ export function registerBinanceGetC2CTradeHistory(server: McpServer) { ...(params.endTime !== undefined && { endTime: params.endTime }), ...(params.page !== undefined && { page: params.page }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -32,9 +32,9 @@ export function registerBinanceGetC2CTradeHistory(server: McpServer) { text: `Successfully retrieved the past C2C trades. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -44,8 +44,8 @@ export function registerBinanceGetC2CTradeHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/c2c/index.ts b/src/modules/c2c/index.ts index e2880732..a450b1fe 100644 --- a/src/modules/c2c/index.ts +++ b/src/modules/c2c/index.ts @@ -1,11 +1,11 @@ // src/tools/binance-c2c/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetC2CTradeHistory } from "./C2C/getC2CTradeHistory.js" +import { registerBinanceGetC2CTradeHistory } from "./C2C/getC2CTradeHistory.js"; export function registerBinanceC2CTradeHistoryTools(server: McpServer) { - registerBinanceGetC2CTradeHistory(server) + registerBinanceGetC2CTradeHistory(server); } // Alias for binance.ts compatibility -export { registerBinanceC2CTradeHistoryTools as registerC2C } +export { registerBinanceC2CTradeHistoryTools as registerC2C }; diff --git a/src/modules/convert/index.ts b/src/modules/convert/index.ts index 58912a82..40d63ed8 100644 --- a/src/modules/convert/index.ts +++ b/src/modules/convert/index.ts @@ -1,16 +1,16 @@ // src/tools/binance-convert/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceConvertMarketDataTools } from "./market-data-api/index.js" -import { registerBinanceConvertTradeTools } from "./trade-api/index.js" +import { registerBinanceConvertMarketDataTools } from "./market-data-api/index.js"; +import { registerBinanceConvertTradeTools } from "./trade-api/index.js"; export function registerBinanceConvertTools(server: McpServer) { // Register tools for accessing market data from Binance Convert - registerBinanceConvertMarketDataTools(server) + registerBinanceConvertMarketDataTools(server); // Register tools for performing trades on Binance Convert - registerBinanceConvertTradeTools(server) + registerBinanceConvertTradeTools(server); } // Alias for binance.ts compatibility -export { registerBinanceConvertTools as registerConvert } +export { registerBinanceConvertTools as registerConvert }; diff --git a/src/modules/convert/market-data-api/index.ts b/src/modules/convert/market-data-api/index.ts index c9bcf504..325cb54b 100644 --- a/src/modules/convert/market-data-api/index.ts +++ b/src/modules/convert/market-data-api/index.ts @@ -1,13 +1,13 @@ // src/tools/binance-convert/market-data-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceConvertGetListAllConvertPairs } from "./listAllConvertPairs.js" -import { registerBinanceConvertQueryOrderQuantityPrecisionPerAsset } from "./queryOrderQuantityPrecisionPerAsset.js" +import { registerBinanceConvertGetListAllConvertPairs } from "./listAllConvertPairs.js"; +import { registerBinanceConvertQueryOrderQuantityPrecisionPerAsset } from "./queryOrderQuantityPrecisionPerAsset.js"; export function registerBinanceConvertMarketDataTools(server: McpServer) { // Register the route to get a list of all supported convert trading pairs - registerBinanceConvertGetListAllConvertPairs(server) + registerBinanceConvertGetListAllConvertPairs(server); // Register the route to get quantity precision details for each asset - registerBinanceConvertQueryOrderQuantityPrecisionPerAsset(server) + registerBinanceConvertQueryOrderQuantityPrecisionPerAsset(server); } diff --git a/src/modules/convert/market-data-api/listAllConvertPairs.ts b/src/modules/convert/market-data-api/listAllConvertPairs.ts index 845a72b6..25de6bef 100644 --- a/src/modules/convert/market-data-api/listAllConvertPairs.ts +++ b/src/modules/convert/market-data-api/listAllConvertPairs.ts @@ -1,9 +1,9 @@ // src/tools/binance-convert/market-data-api/listAllConvertPairs.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { convertClient } from "../../../config/binanceClient.js" +import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertGetListAllConvertPairs(server: McpServer) { server.tool( @@ -18,9 +18,9 @@ export function registerBinanceConvertGetListAllConvertPairs(server: McpServer) const response = await convertClient.restAPI.listAllConvertPairs({ ...(params.fromAsset && { fromAsset: params.fromAsset }), ...(params.toAsset && { toAsset: params.toAsset }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,9 +29,9 @@ export function registerBinanceConvertGetListAllConvertPairs(server: McpServer) text: `Successfully queried available conversion pairs. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -41,8 +41,8 @@ export function registerBinanceConvertGetListAllConvertPairs(server: McpServer) }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/convert/market-data-api/queryOrderQuantityPrecisionPerAsset.ts b/src/modules/convert/market-data-api/queryOrderQuantityPrecisionPerAsset.ts index dc097eb2..21ac758a 100644 --- a/src/modules/convert/market-data-api/queryOrderQuantityPrecisionPerAsset.ts +++ b/src/modules/convert/market-data-api/queryOrderQuantityPrecisionPerAsset.ts @@ -1,9 +1,9 @@ // src/tools/binance-convert/market-data-api/queryOrderQuantityPrecisionPerAsset.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { convertClient } from "../../../config/binanceClient.js" +import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertQueryOrderQuantityPrecisionPerAsset(server: McpServer) { server.tool( @@ -21,9 +21,9 @@ export function registerBinanceConvertQueryOrderQuantityPrecisionPerAsset(server try { const response = await convertClient.restAPI.queryOrderQuantityPrecisionPerAsset({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -34,9 +34,9 @@ export function registerBinanceConvertQueryOrderQuantityPrecisionPerAsset(server )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -46,8 +46,8 @@ export function registerBinanceConvertQueryOrderQuantityPrecisionPerAsset(server }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/convert/trade-api/acceptQuote.ts b/src/modules/convert/trade-api/acceptQuote.ts index b7ff1b5a..23deb653 100644 --- a/src/modules/convert/trade-api/acceptQuote.ts +++ b/src/modules/convert/trade-api/acceptQuote.ts @@ -1,9 +1,9 @@ // src/tools/binance-convert/trade-api/acceptQuote.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { convertClient } from "../../../config/binanceClient.js" +import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertAcceptQuote(server: McpServer) { server.tool( @@ -23,8 +23,8 @@ export function registerBinanceConvertAcceptQuote(server: McpServer) { const response = await convertClient.restAPI.acceptQuote({ quoteId: params.quoteId, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -33,9 +33,9 @@ export function registerBinanceConvertAcceptQuote(server: McpServer) { text: `Successfully executed the token conversion. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -45,8 +45,8 @@ export function registerBinanceConvertAcceptQuote(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/convert/trade-api/cancelLimitOrder.ts b/src/modules/convert/trade-api/cancelLimitOrder.ts index 1a097a79..7982e671 100644 --- a/src/modules/convert/trade-api/cancelLimitOrder.ts +++ b/src/modules/convert/trade-api/cancelLimitOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-convert/trade-api/cancelLimitOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { convertClient } from "../../../config/binanceClient.js" +import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertCancelLimitOrder(server: McpServer) { server.tool( @@ -23,8 +23,8 @@ export function registerBinanceConvertCancelLimitOrder(server: McpServer) { const response = await convertClient.restAPI.cancelLimitOrder({ orderId: params.orderId, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -33,9 +33,9 @@ export function registerBinanceConvertCancelLimitOrder(server: McpServer) { text: `Canceled the placed limit order. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -45,8 +45,8 @@ export function registerBinanceConvertCancelLimitOrder(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/convert/trade-api/getConvertTradeHistory.ts b/src/modules/convert/trade-api/getConvertTradeHistory.ts index 458bba40..5eafcf10 100644 --- a/src/modules/convert/trade-api/getConvertTradeHistory.ts +++ b/src/modules/convert/trade-api/getConvertTradeHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-convert/trade-api/getConvertTradeHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { convertClient } from "../../../config/binanceClient.js" +import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceGetConvertTradeHistory(server: McpServer) { server.tool( @@ -27,9 +27,9 @@ export function registerBinanceGetConvertTradeHistory(server: McpServer) { endTime: params.endTime, ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -40,9 +40,9 @@ export function registerBinanceGetConvertTradeHistory(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -52,8 +52,8 @@ export function registerBinanceGetConvertTradeHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/convert/trade-api/index.ts b/src/modules/convert/trade-api/index.ts index 3b5e9db9..86128d99 100644 --- a/src/modules/convert/trade-api/index.ts +++ b/src/modules/convert/trade-api/index.ts @@ -1,33 +1,33 @@ // src/tools/binance-convert/trade-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceConvertAcceptQuote } from "./acceptQuote.js" -import { registerBinanceConvertCancelLimitOrder } from "./cancelLimitOrder.js" -import { registerBinanceGetConvertTradeHistory } from "./getConvertTradeHistory.js" -import { registerBinanceConvertOrderStatus } from "./orderStatus.js" -import { registerBinanceConvertPlaceLimitOrder } from "./placeLimitOrder.js" -import { registerBinanceConvertQueryLimitOpenOrders } from "./queryLimitOpenOrders.js" -import { registerBinanceConvertSendQuoteRequest } from "./sendQuoteRequest.js" +import { registerBinanceConvertAcceptQuote } from "./acceptQuote.js"; +import { registerBinanceConvertCancelLimitOrder } from "./cancelLimitOrder.js"; +import { registerBinanceGetConvertTradeHistory } from "./getConvertTradeHistory.js"; +import { registerBinanceConvertOrderStatus } from "./orderStatus.js"; +import { registerBinanceConvertPlaceLimitOrder } from "./placeLimitOrder.js"; +import { registerBinanceConvertQueryLimitOpenOrders } from "./queryLimitOpenOrders.js"; +import { registerBinanceConvertSendQuoteRequest } from "./sendQuoteRequest.js"; export function registerBinanceConvertTradeTools(server: McpServer) { // Register the route to accept a quote for a convert trade - registerBinanceConvertAcceptQuote(server) + registerBinanceConvertAcceptQuote(server); // Register the route to cancel an existing convert limit order - registerBinanceConvertCancelLimitOrder(server) + registerBinanceConvertCancelLimitOrder(server); // Register the route to get the convert trade history - registerBinanceGetConvertTradeHistory(server) + registerBinanceGetConvertTradeHistory(server); // Register the route to check the status of a convert order - registerBinanceConvertOrderStatus(server) + registerBinanceConvertOrderStatus(server); // Register the route to place a new convert limit order - registerBinanceConvertPlaceLimitOrder(server) + registerBinanceConvertPlaceLimitOrder(server); // Register the route to query currently open convert limit orders - registerBinanceConvertQueryLimitOpenOrders(server) + registerBinanceConvertQueryLimitOpenOrders(server); // Register the route to send a quote request for a convert trade - registerBinanceConvertSendQuoteRequest(server) + registerBinanceConvertSendQuoteRequest(server); } diff --git a/src/modules/convert/trade-api/orderStatus.ts b/src/modules/convert/trade-api/orderStatus.ts index 2a6521a6..2f0db587 100644 --- a/src/modules/convert/trade-api/orderStatus.ts +++ b/src/modules/convert/trade-api/orderStatus.ts @@ -1,9 +1,9 @@ // src/tools/binance-convert/trade-api/orderStatus.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { convertClient } from "../../../config/binanceClient.js" +import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertOrderStatus(server: McpServer) { server.tool( @@ -18,9 +18,9 @@ export function registerBinanceConvertOrderStatus(server: McpServer) { const response = await convertClient.restAPI.orderStatus({ ...(params.orderId && { orderId: params.orderId }), ...(params.quoteId && { quoteId: params.quoteId }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -31,9 +31,9 @@ export function registerBinanceConvertOrderStatus(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -43,8 +43,8 @@ export function registerBinanceConvertOrderStatus(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/convert/trade-api/placeLimitOrder.ts b/src/modules/convert/trade-api/placeLimitOrder.ts index 775c1b66..54896a32 100644 --- a/src/modules/convert/trade-api/placeLimitOrder.ts +++ b/src/modules/convert/trade-api/placeLimitOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-convert/trade-api/placeLimitOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { convertClient } from "../../../config/binanceClient.js" +import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertPlaceLimitOrder(server: McpServer) { server.tool( @@ -53,9 +53,9 @@ export function registerBinanceConvertPlaceLimitOrder(server: McpServer) { ...(params.quoteAmount !== undefined && { quoteAmount: params.quoteAmount }), ...(params.walletType && { walletType: params.walletType }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -64,9 +64,9 @@ export function registerBinanceConvertPlaceLimitOrder(server: McpServer) { text: `Successfully placed the limit order. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -76,8 +76,8 @@ export function registerBinanceConvertPlaceLimitOrder(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/convert/trade-api/queryLimitOpenOrders.ts b/src/modules/convert/trade-api/queryLimitOpenOrders.ts index 84e405af..a55f4f73 100644 --- a/src/modules/convert/trade-api/queryLimitOpenOrders.ts +++ b/src/modules/convert/trade-api/queryLimitOpenOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-convert/trade-api/queryLimitOpenOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { convertClient } from "../../../config/binanceClient.js" +import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertQueryLimitOpenOrders(server: McpServer) { server.tool( @@ -21,9 +21,9 @@ export function registerBinanceConvertQueryLimitOpenOrders(server: McpServer) { try { const response = await convertClient.restAPI.queryLimitOpenOrders({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -34,9 +34,9 @@ export function registerBinanceConvertQueryLimitOpenOrders(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -46,8 +46,8 @@ export function registerBinanceConvertQueryLimitOpenOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/convert/trade-api/sendQuoteRequest.ts b/src/modules/convert/trade-api/sendQuoteRequest.ts index 8b7c40c7..e7ae7a91 100644 --- a/src/modules/convert/trade-api/sendQuoteRequest.ts +++ b/src/modules/convert/trade-api/sendQuoteRequest.ts @@ -1,9 +1,9 @@ // src/tools/binance-convert/trade-api/sendQuoteRequest.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { convertClient } from "../../../config/binanceClient.js" +import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertSendQuoteRequest(server: McpServer) { server.tool( @@ -43,9 +43,9 @@ export function registerBinanceConvertSendQuoteRequest(server: McpServer) { ...(params.walletType && { walletType: params.walletType }), ...(params.validTime && { validTime: params.validTime }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -56,9 +56,9 @@ export function registerBinanceConvertSendQuoteRequest(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -68,8 +68,8 @@ export function registerBinanceConvertSendQuoteRequest(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/copy-trading/FutureCopyTrading-api/followTrader.ts b/src/modules/copy-trading/FutureCopyTrading-api/followTrader.ts index 8f20dc19..a63b969c 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/followTrader.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/followTrader.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/copy-trading/FutureCopyTrading-api/followTrader.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { copyTradingClient } from "../../../config/binanceClient.js" +import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceCopyTradingFollowTrader(server: McpServer) { server.tool( @@ -41,9 +41,9 @@ export function registerBinanceCopyTradingFollowTrader(server: McpServer) { ...(params.stopLossRatio && { stopLossRatio: params.stopLossRatio }), ...(params.takeProfitRatio && { takeProfitRatio: params.takeProfitRatio }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const _data = await response.data() + const _data = await response.data(); return { content: [ @@ -52,9 +52,9 @@ export function registerBinanceCopyTradingFollowTrader(server: McpServer) { text: `✅ Now Following Trader!\n\nPortfolio: ${params.leadPortfolioId}\nCopy Ratio: ${params.copyRatio}x\nStop Loss: ${params.stopLossRatio ? params.stopLossRatio * 100 + "%" : "Not set"}\nTake Profit: ${params.takeProfitRatio ? params.takeProfitRatio * 100 + "%" : "Not set"}\n\n⚠️ Your trades will now automatically copy this trader.`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -64,8 +64,8 @@ export function registerBinanceCopyTradingFollowTrader(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getCopyOrders.ts b/src/modules/copy-trading/FutureCopyTrading-api/getCopyOrders.ts index dab694e3..ad7b80ba 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getCopyOrders.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getCopyOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/copy-trading/FutureCopyTrading-api/getCopyOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { copyTradingClient } from "../../../config/binanceClient.js" +import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceCopyTradingGetCopyOrders(server: McpServer) { server.tool( @@ -30,9 +30,9 @@ export function registerBinanceCopyTradingGetCopyOrders(server: McpServer) { ...(params.pageNumber && { pageNumber: params.pageNumber }), ...(params.pageSize && { pageSize: params.pageSize }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -41,9 +41,9 @@ export function registerBinanceCopyTradingGetCopyOrders(server: McpServer) { text: `📋 Copy Trading Orders\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -53,8 +53,8 @@ export function registerBinanceCopyTradingGetCopyOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getCopyPositions.ts b/src/modules/copy-trading/FutureCopyTrading-api/getCopyPositions.ts index 6e294740..47ba1390 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getCopyPositions.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getCopyPositions.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/copy-trading/FutureCopyTrading-api/getCopyPositions.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { copyTradingClient } from "../../../config/binanceClient.js" +import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceCopyTradingGetCopyPositions(server: McpServer) { server.tool( @@ -22,9 +22,9 @@ export function registerBinanceCopyTradingGetCopyPositions(server: McpServer) { try { const response = await copyTradingClient.restAPI.getCopyPositions({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -33,9 +33,9 @@ export function registerBinanceCopyTradingGetCopyPositions(server: McpServer) { text: `📈 Your Copy Trading Positions\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -45,8 +45,8 @@ export function registerBinanceCopyTradingGetCopyPositions(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getFollowingTraders.ts b/src/modules/copy-trading/FutureCopyTrading-api/getFollowingTraders.ts index bbb58675..931d5617 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getFollowingTraders.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getFollowingTraders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/copy-trading/FutureCopyTrading-api/getFollowingTraders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { copyTradingClient } from "../../../config/binanceClient.js" +import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceCopyTradingGetFollowingTraders(server: McpServer) { server.tool( @@ -22,9 +22,9 @@ export function registerBinanceCopyTradingGetFollowingTraders(server: McpServer) try { const response = await copyTradingClient.restAPI.getFollowingTraders({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -33,9 +33,9 @@ export function registerBinanceCopyTradingGetFollowingTraders(server: McpServer) text: `👥 Traders You're Following\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -45,8 +45,8 @@ export function registerBinanceCopyTradingGetFollowingTraders(server: McpServer) }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts b/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts index 57786147..d824f411 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts @@ -1,9 +1,9 @@ // src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { copyTradingClient } from "../../../config/binanceClient.js" +import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetFuturesLeadTraderStatus(server: McpServer) { server.tool( @@ -16,9 +16,9 @@ export function registerBinanceGetFuturesLeadTraderStatus(server: McpServer) { try { const response = await copyTradingClient.restAPI.getFuturesLeadTraderStatus({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,9 +29,9 @@ export function registerBinanceGetFuturesLeadTraderStatus(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -41,8 +41,8 @@ export function registerBinanceGetFuturesLeadTraderStatus(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts b/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts index 925b449f..5efe5667 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts @@ -1,9 +1,9 @@ // src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { copyTradingClient } from "../../../config/binanceClient.js" +import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetFuturesLeadTradingSymbolWhitelist(server: McpServer) { server.tool( @@ -16,9 +16,9 @@ export function registerBinanceGetFuturesLeadTradingSymbolWhitelist(server: McpS try { const response = await copyTradingClient.restAPI.getFuturesLeadTradingSymbolWhitelist({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -27,9 +27,9 @@ export function registerBinanceGetFuturesLeadTradingSymbolWhitelist(server: McpS text: `Successfully retrieved trading pairs. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -39,8 +39,8 @@ export function registerBinanceGetFuturesLeadTradingSymbolWhitelist(server: McpS }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getLeadTraders.ts b/src/modules/copy-trading/FutureCopyTrading-api/getLeadTraders.ts index b4820e90..dc946882 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getLeadTraders.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getLeadTraders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/copy-trading/FutureCopyTrading-api/getLeadTraders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { copyTradingClient } from "../../../config/binanceClient.js" +import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetLeadTraders(server: McpServer) { server.tool( @@ -30,9 +30,9 @@ export function registerBinanceGetLeadTraders(server: McpServer) { ...(params.pageNumber && { pageNumber: params.pageNumber }), ...(params.pageSize && { pageSize: params.pageSize }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -41,9 +41,9 @@ export function registerBinanceGetLeadTraders(server: McpServer) { text: `👥 Lead Traders\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -53,8 +53,8 @@ export function registerBinanceGetLeadTraders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getTraderPerformance.ts b/src/modules/copy-trading/FutureCopyTrading-api/getTraderPerformance.ts index 1e87be5c..a6785301 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getTraderPerformance.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getTraderPerformance.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/copy-trading/FutureCopyTrading-api/getTraderPerformance.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { copyTradingClient } from "../../../config/binanceClient.js" +import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetTraderPerformance(server: McpServer) { server.tool( @@ -26,9 +26,9 @@ export function registerBinanceGetTraderPerformance(server: McpServer) { leadPortfolioId: params.leadPortfolioId, ...(params.tradeType && { tradeType: params.tradeType }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -37,9 +37,9 @@ export function registerBinanceGetTraderPerformance(server: McpServer) { text: `📊 Trader Performance\n\nPortfolio: ${params.leadPortfolioId}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -49,8 +49,8 @@ export function registerBinanceGetTraderPerformance(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getTraderPositions.ts b/src/modules/copy-trading/FutureCopyTrading-api/getTraderPositions.ts index e1d601c5..f084a767 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getTraderPositions.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getTraderPositions.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/copy-trading/FutureCopyTrading-api/getTraderPositions.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { copyTradingClient } from "../../../config/binanceClient.js" +import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetTraderPositions(server: McpServer) { server.tool( @@ -26,9 +26,9 @@ export function registerBinanceGetTraderPositions(server: McpServer) { leadPortfolioId: params.leadPortfolioId, ...(params.tradeType && { tradeType: params.tradeType }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -37,9 +37,9 @@ export function registerBinanceGetTraderPositions(server: McpServer) { text: `📈 Trader Positions\n\nPortfolio: ${params.leadPortfolioId}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -49,8 +49,8 @@ export function registerBinanceGetTraderPositions(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getTraderSymbolStats.ts b/src/modules/copy-trading/FutureCopyTrading-api/getTraderSymbolStats.ts index 71090402..10ba5762 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getTraderSymbolStats.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getTraderSymbolStats.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/copy-trading/FutureCopyTrading-api/getTraderSymbolStats.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { copyTradingClient } from "../../../config/binanceClient.js" +import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetTraderSymbolStats(server: McpServer) { server.tool( @@ -26,9 +26,9 @@ export function registerBinanceGetTraderSymbolStats(server: McpServer) { leadPortfolioId: params.leadPortfolioId, ...(params.tradeType && { tradeType: params.tradeType }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -37,9 +37,9 @@ export function registerBinanceGetTraderSymbolStats(server: McpServer) { text: `📊 Trader Symbol Statistics\n\nPortfolio: ${params.leadPortfolioId}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -49,8 +49,8 @@ export function registerBinanceGetTraderSymbolStats(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/copy-trading/FutureCopyTrading-api/index.ts b/src/modules/copy-trading/FutureCopyTrading-api/index.ts index c7be5c17..27f03171 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/index.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/index.ts @@ -1,14 +1,14 @@ // src/tools/binance-copy-trading/FutureCopyTrading-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetFuturesLeadTraderStatus } from "./getFuturesLeadTraderStatus.js" -import { registerBinanceGetFuturesLeadTradingSymbolWhitelist } from "./getFuturesLeadTradingSymbolWhitelist.js" +import { registerBinanceGetFuturesLeadTraderStatus } from "./getFuturesLeadTraderStatus.js"; +import { registerBinanceGetFuturesLeadTradingSymbolWhitelist } from "./getFuturesLeadTradingSymbolWhitelist.js"; // Registers Binance Futures Copy Trading API tools with the MCP server. export function registerBinanceFutureCopyTradingApiTools(server: McpServer) { // Registers an endpoint to get the status of a lead trader in futures copy trading - registerBinanceGetFuturesLeadTraderStatus(server) + registerBinanceGetFuturesLeadTraderStatus(server); // Registers an endpoint to get the whitelist of symbols available for futures copy trading - registerBinanceGetFuturesLeadTradingSymbolWhitelist(server) + registerBinanceGetFuturesLeadTradingSymbolWhitelist(server); } diff --git a/src/modules/copy-trading/FutureCopyTrading-api/unfollowTrader.ts b/src/modules/copy-trading/FutureCopyTrading-api/unfollowTrader.ts index 343b3347..5096f3d4 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/unfollowTrader.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/unfollowTrader.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/copy-trading/FutureCopyTrading-api/unfollowTrader.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { copyTradingClient } from "../../../config/binanceClient.js" +import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceCopyTradingUnfollowTrader(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerBinanceCopyTradingUnfollowTrader(server: McpServer) { const response = await copyTradingClient.restAPI.unfollowTrader({ leadPortfolioId: params.leadPortfolioId, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const _data = await response.data() + const _data = await response.data(); return { content: [ @@ -35,9 +35,9 @@ export function registerBinanceCopyTradingUnfollowTrader(server: McpServer) { text: `✅ Stopped Following Trader!\n\nPortfolio: ${params.leadPortfolioId}\n\n💡 Note: Existing positions from copy trading are still open. You may want to close them manually.`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -47,8 +47,8 @@ export function registerBinanceCopyTradingUnfollowTrader(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/copy-trading/index.ts b/src/modules/copy-trading/index.ts index 73dce807..47d93dc3 100644 --- a/src/modules/copy-trading/index.ts +++ b/src/modules/copy-trading/index.ts @@ -1,13 +1,13 @@ // src/tools/binance-copy-trading/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceFutureCopyTradingApiTools } from "./FutureCopyTrading-api/index.js" +import { registerBinanceFutureCopyTradingApiTools } from "./FutureCopyTrading-api/index.js"; // Registers all Binance Copy Trading related tools with the MCP server. export function registerBinanceCopyTradingTools(server: McpServer) { // Register the Binance Futures Copy Trading API tools with the given server. - registerBinanceFutureCopyTradingApiTools(server) + registerBinanceFutureCopyTradingApiTools(server); } // Alias for binance.ts compatibility -export { registerBinanceCopyTradingTools as registerCopyTrading } +export { registerBinanceCopyTradingTools as registerCopyTrading }; diff --git a/src/modules/crypto-loans/flexible/adjustLTV.ts b/src/modules/crypto-loans/flexible/adjustLTV.ts index eb86c208..3f5f90ad 100644 --- a/src/modules/crypto-loans/flexible/adjustLTV.ts +++ b/src/modules/crypto-loans/flexible/adjustLTV.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/crypto-loans/flexible/adjustLTV.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../../config/binanceClient.js" +import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerFlexibleLoanAdjustLTV(server: McpServer) { server.tool( @@ -32,9 +32,9 @@ export function registerFlexibleLoanAdjustLTV(server: McpServer) { adjustmentAmount: params.adjustmentAmount, direction: params.direction, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -43,9 +43,9 @@ export function registerFlexibleLoanAdjustLTV(server: McpServer) { text: `✅ LTV Adjusted!\n\nDirection: ${params.direction}\nAmount: ${params.adjustmentAmount} ${params.collateralCoin}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -55,8 +55,8 @@ export function registerFlexibleLoanAdjustLTV(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/crypto-loans/flexible/borrow.ts b/src/modules/crypto-loans/flexible/borrow.ts index 66961310..01a196c1 100644 --- a/src/modules/crypto-loans/flexible/borrow.ts +++ b/src/modules/crypto-loans/flexible/borrow.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/crypto-loans/flexible/borrow.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../../config/binanceClient.js" +import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerFlexibleLoanBorrow(server: McpServer) { server.tool( @@ -36,9 +36,9 @@ export function registerFlexibleLoanBorrow(server: McpServer) { ...(params.loanAmount && { loanAmount: params.loanAmount }), ...(params.collateralAmount && { collateralAmount: params.collateralAmount }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -47,9 +47,9 @@ export function registerFlexibleLoanBorrow(server: McpServer) { text: `✅ Flexible Loan Borrowed!\n\nLoan Coin: ${params.loanCoin}\nCollateral: ${params.collateralCoin}\n\n⚠️ Remember to monitor your LTV ratio and repay to avoid liquidation.\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -59,8 +59,8 @@ export function registerFlexibleLoanBorrow(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/crypto-loans/flexible/getBorrowHistory.ts b/src/modules/crypto-loans/flexible/getBorrowHistory.ts index 14a80099..077e5c36 100644 --- a/src/modules/crypto-loans/flexible/getBorrowHistory.ts +++ b/src/modules/crypto-loans/flexible/getBorrowHistory.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/crypto-loans/flexible/getBorrowHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../../config/binanceClient.js" +import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerFlexibleLoanBorrowHistory(server: McpServer) { server.tool( @@ -34,9 +34,9 @@ export function registerFlexibleLoanBorrowHistory(server: McpServer) { ...(params.current && { current: params.current }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -45,9 +45,9 @@ export function registerFlexibleLoanBorrowHistory(server: McpServer) { text: `📜 Flexible Loan Borrow History\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -57,8 +57,8 @@ export function registerFlexibleLoanBorrowHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/crypto-loans/flexible/getFlexibleCollateralAssets.ts b/src/modules/crypto-loans/flexible/getFlexibleCollateralAssets.ts index 87479c0a..3f350770 100644 --- a/src/modules/crypto-loans/flexible/getFlexibleCollateralAssets.ts +++ b/src/modules/crypto-loans/flexible/getFlexibleCollateralAssets.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/crypto-loans/flexible/getFlexibleCollateralAssets.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../../config/binanceClient.js" +import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerFlexibleCollateralAssets(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerFlexibleCollateralAssets(server: McpServer) { const response = await cryptoLoanClient.restAPI.getFlexibleCollateralAssets({ ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,9 +35,9 @@ export function registerFlexibleCollateralAssets(server: McpServer) { text: `🔒 Flexible Loan Collateral Assets\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -47,8 +47,8 @@ export function registerFlexibleCollateralAssets(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/crypto-loans/flexible/getFlexibleLoanAssets.ts b/src/modules/crypto-loans/flexible/getFlexibleLoanAssets.ts index 8aee566d..4cfba523 100644 --- a/src/modules/crypto-loans/flexible/getFlexibleLoanAssets.ts +++ b/src/modules/crypto-loans/flexible/getFlexibleLoanAssets.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/crypto-loans/flexible/getFlexibleLoanAssets.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../../config/binanceClient.js" +import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerFlexibleLoanAssets(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerFlexibleLoanAssets(server: McpServer) { const response = await cryptoLoanClient.restAPI.getFlexibleLoanAssets({ ...(params.loanCoin && { loanCoin: params.loanCoin }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,9 +35,9 @@ export function registerFlexibleLoanAssets(server: McpServer) { text: `💰 Flexible Loan Assets\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -47,8 +47,8 @@ export function registerFlexibleLoanAssets(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/crypto-loans/flexible/getOngoingOrders.ts b/src/modules/crypto-loans/flexible/getOngoingOrders.ts index 72f55f1b..8e3c52d9 100644 --- a/src/modules/crypto-loans/flexible/getOngoingOrders.ts +++ b/src/modules/crypto-loans/flexible/getOngoingOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/crypto-loans/flexible/getOngoingOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../../config/binanceClient.js" +import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerFlexibleLoanOngoingOrders(server: McpServer) { server.tool( @@ -30,9 +30,9 @@ export function registerFlexibleLoanOngoingOrders(server: McpServer) { ...(params.current && { current: params.current }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -41,9 +41,9 @@ export function registerFlexibleLoanOngoingOrders(server: McpServer) { text: `📊 Ongoing Flexible Loans\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -53,8 +53,8 @@ export function registerFlexibleLoanOngoingOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/crypto-loans/flexible/getRepayHistory.ts b/src/modules/crypto-loans/flexible/getRepayHistory.ts index 1e64c2dd..17008e3f 100644 --- a/src/modules/crypto-loans/flexible/getRepayHistory.ts +++ b/src/modules/crypto-loans/flexible/getRepayHistory.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/crypto-loans/flexible/getRepayHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../../config/binanceClient.js" +import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerFlexibleLoanRepayHistory(server: McpServer) { server.tool( @@ -34,9 +34,9 @@ export function registerFlexibleLoanRepayHistory(server: McpServer) { ...(params.current && { current: params.current }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -45,9 +45,9 @@ export function registerFlexibleLoanRepayHistory(server: McpServer) { text: `📜 Flexible Loan Repay History\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -57,8 +57,8 @@ export function registerFlexibleLoanRepayHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/crypto-loans/flexible/index.ts b/src/modules/crypto-loans/flexible/index.ts index 199128f2..8ea04b2c 100644 --- a/src/modules/crypto-loans/flexible/index.ts +++ b/src/modules/crypto-loans/flexible/index.ts @@ -5,24 +5,24 @@ * @license Apache-2.0 */ // src/modules/crypto-loans/flexible/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerFlexibleLoanAdjustLTV } from "./adjustLTV.js" -import { registerFlexibleLoanBorrow } from "./borrow.js" -import { registerFlexibleLoanBorrowHistory } from "./getBorrowHistory.js" -import { registerFlexibleCollateralAssets } from "./getFlexibleCollateralAssets.js" -import { registerFlexibleLoanAssets } from "./getFlexibleLoanAssets.js" -import { registerFlexibleLoanOngoingOrders } from "./getOngoingOrders.js" -import { registerFlexibleLoanRepayHistory } from "./getRepayHistory.js" -import { registerFlexibleLoanRepay } from "./repay.js" +import { registerFlexibleLoanAdjustLTV } from "./adjustLTV.js"; +import { registerFlexibleLoanBorrow } from "./borrow.js"; +import { registerFlexibleLoanBorrowHistory } from "./getBorrowHistory.js"; +import { registerFlexibleCollateralAssets } from "./getFlexibleCollateralAssets.js"; +import { registerFlexibleLoanAssets } from "./getFlexibleLoanAssets.js"; +import { registerFlexibleLoanOngoingOrders } from "./getOngoingOrders.js"; +import { registerFlexibleLoanRepayHistory } from "./getRepayHistory.js"; +import { registerFlexibleLoanRepay } from "./repay.js"; export function registerCryptoLoansFlexibleTools(server: McpServer) { - registerFlexibleLoanAssets(server) - registerFlexibleCollateralAssets(server) - registerFlexibleLoanBorrow(server) - registerFlexibleLoanRepay(server) - registerFlexibleLoanAdjustLTV(server) - registerFlexibleLoanOngoingOrders(server) - registerFlexibleLoanBorrowHistory(server) - registerFlexibleLoanRepayHistory(server) + registerFlexibleLoanAssets(server); + registerFlexibleCollateralAssets(server); + registerFlexibleLoanBorrow(server); + registerFlexibleLoanRepay(server); + registerFlexibleLoanAdjustLTV(server); + registerFlexibleLoanOngoingOrders(server); + registerFlexibleLoanBorrowHistory(server); + registerFlexibleLoanRepayHistory(server); } diff --git a/src/modules/crypto-loans/flexible/repay.ts b/src/modules/crypto-loans/flexible/repay.ts index 54c8f843..8b807f21 100644 --- a/src/modules/crypto-loans/flexible/repay.ts +++ b/src/modules/crypto-loans/flexible/repay.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/crypto-loans/flexible/repay.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../../config/binanceClient.js" +import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerFlexibleLoanRepay(server: McpServer) { server.tool( @@ -34,9 +34,9 @@ export function registerFlexibleLoanRepay(server: McpServer) { }), ...(params.fullRepayment !== undefined && { fullRepayment: params.fullRepayment }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -45,9 +45,9 @@ export function registerFlexibleLoanRepay(server: McpServer) { text: `✅ Loan Repayment Successful!\n\nRepaid: ${params.repayAmount} ${params.loanCoin}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -57,8 +57,8 @@ export function registerFlexibleLoanRepay(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/crypto-loans/index.ts b/src/modules/crypto-loans/index.ts index 87939007..9070882b 100644 --- a/src/modules/crypto-loans/index.ts +++ b/src/modules/crypto-loans/index.ts @@ -1,8 +1,8 @@ // src/modules/crypto-loans/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceCryptoLoansTools } from "../../tools/binance-crypto-loans/index.js" +import { registerBinanceCryptoLoansTools } from "../../tools/binance-crypto-loans/index.js"; export function registerCryptoLoans(server: McpServer) { - registerBinanceCryptoLoansTools(server) + registerBinanceCryptoLoansTools(server); } diff --git a/src/modules/dual-investment/index.ts b/src/modules/dual-investment/index.ts index 3ceddc92..5b1a0b12 100644 --- a/src/modules/dual-investment/index.ts +++ b/src/modules/dual-investment/index.ts @@ -1,13 +1,13 @@ // src/tools/binance-dual-investment/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceDualInvestmentMarketApiTools } from "./market-api/index.js" -import { registerBinanceDualInvestmentTradeApiTools } from "./trade-api/index.js" +import { registerBinanceDualInvestmentMarketApiTools } from "./market-api/index.js"; +import { registerBinanceDualInvestmentTradeApiTools } from "./trade-api/index.js"; export function registerBinanceDualInvestmentTools(server: McpServer) { - registerBinanceDualInvestmentTradeApiTools(server) - registerBinanceDualInvestmentMarketApiTools(server) + registerBinanceDualInvestmentTradeApiTools(server); + registerBinanceDualInvestmentMarketApiTools(server); } // Alias for binance.ts compatibility -export { registerBinanceDualInvestmentTools as registerDualInvestment } +export { registerBinanceDualInvestmentTools as registerDualInvestment }; diff --git a/src/modules/dual-investment/market-api/getDualInvestmentProductList.ts b/src/modules/dual-investment/market-api/getDualInvestmentProductList.ts index b9d20a31..0af64c24 100644 --- a/src/modules/dual-investment/market-api/getDualInvestmentProductList.ts +++ b/src/modules/dual-investment/market-api/getDualInvestmentProductList.ts @@ -1,9 +1,9 @@ // src/tools/binance-dual-investment/market-api/getDualInvestmentProductList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { dualInvestmentClient } from "../../../config/binanceClient.js" +import { dualInvestmentClient } from "../../../config/binanceClient.js"; export function registerBinanceGetDualInvestmentProductList(server: McpServer) { server.tool( @@ -37,9 +37,9 @@ export function registerBinanceGetDualInvestmentProductList(server: McpServer) { ...(params.pageSize && { pageSize: params.pageSize }), ...(params.pageIndex && { pageIndex: params.pageIndex }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -50,9 +50,9 @@ export function registerBinanceGetDualInvestmentProductList(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -62,8 +62,8 @@ export function registerBinanceGetDualInvestmentProductList(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/dual-investment/market-api/index.ts b/src/modules/dual-investment/market-api/index.ts index b2d90200..f5465f8a 100644 --- a/src/modules/dual-investment/market-api/index.ts +++ b/src/modules/dual-investment/market-api/index.ts @@ -1,8 +1,8 @@ // src/tools/binance-dual-investment/market-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetDualInvestmentProductList } from "./getDualInvestmentProductList.js" +import { registerBinanceGetDualInvestmentProductList } from "./getDualInvestmentProductList.js"; export function registerBinanceDualInvestmentMarketApiTools(server: McpServer) { - registerBinanceGetDualInvestmentProductList(server) + registerBinanceGetDualInvestmentProductList(server); } diff --git a/src/modules/dual-investment/trade-api/changeAutoCompoundStatus.ts b/src/modules/dual-investment/trade-api/changeAutoCompoundStatus.ts index b47051eb..97749554 100644 --- a/src/modules/dual-investment/trade-api/changeAutoCompoundStatus.ts +++ b/src/modules/dual-investment/trade-api/changeAutoCompoundStatus.ts @@ -1,9 +1,9 @@ // src/tools/binance-dual-investment/trade-api/changeAutoCompoundStatus.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { dualInvestmentClient } from "../../../config/binanceClient.js" +import { dualInvestmentClient } from "../../../config/binanceClient.js"; export function registerBinanceChangeAutoCompoundStatus(server: McpServer) { server.tool( @@ -28,9 +28,9 @@ export function registerBinanceChangeAutoCompoundStatus(server: McpServer) { positionId: params.positionId, autoCompoundPlan: params.autoCompoundPlan, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -41,9 +41,9 @@ export function registerBinanceChangeAutoCompoundStatus(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -53,8 +53,8 @@ export function registerBinanceChangeAutoCompoundStatus(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/dual-investment/trade-api/checkDualInvestmentAccounts.ts b/src/modules/dual-investment/trade-api/checkDualInvestmentAccounts.ts index a37c71f5..4fa4e18b 100644 --- a/src/modules/dual-investment/trade-api/checkDualInvestmentAccounts.ts +++ b/src/modules/dual-investment/trade-api/checkDualInvestmentAccounts.ts @@ -1,9 +1,9 @@ // src/tools/binance-dual-investment/trade-api/checkDualInvestmentAccounts.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { dualInvestmentClient } from "../../../config/binanceClient.js" +import { dualInvestmentClient } from "../../../config/binanceClient.js"; export function registerBinanceCheckDualInvestmentAccounts(server: McpServer) { server.tool( @@ -21,9 +21,9 @@ export function registerBinanceCheckDualInvestmentAccounts(server: McpServer) { try { const response = await dualInvestmentClient.restAPI.checkDualInvestmentAccounts({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -34,9 +34,9 @@ export function registerBinanceCheckDualInvestmentAccounts(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -46,8 +46,8 @@ export function registerBinanceCheckDualInvestmentAccounts(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/dual-investment/trade-api/getDualInvestmentPositions.ts b/src/modules/dual-investment/trade-api/getDualInvestmentPositions.ts index 8a24b7b8..f7138155 100644 --- a/src/modules/dual-investment/trade-api/getDualInvestmentPositions.ts +++ b/src/modules/dual-investment/trade-api/getDualInvestmentPositions.ts @@ -1,9 +1,9 @@ // src/tools/binance-dual-investment/trade-api/getDualInvestmentPositions.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { dualInvestmentClient } from "../../../config/binanceClient.js" +import { dualInvestmentClient } from "../../../config/binanceClient.js"; export function registerBinanceGetDualInvestmentPositions(server: McpServer) { server.tool( @@ -46,9 +46,9 @@ export function registerBinanceGetDualInvestmentPositions(server: McpServer) { ...(params.pageSize && { pageSize: params.pageSize }), ...(params.pageIndex && { pageIndex: params.pageIndex }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -59,9 +59,9 @@ export function registerBinanceGetDualInvestmentPositions(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -71,8 +71,8 @@ export function registerBinanceGetDualInvestmentPositions(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/dual-investment/trade-api/index.ts b/src/modules/dual-investment/trade-api/index.ts index 157890bc..97d55f6c 100644 --- a/src/modules/dual-investment/trade-api/index.ts +++ b/src/modules/dual-investment/trade-api/index.ts @@ -1,14 +1,14 @@ // src/tools/binance-dual-investment/trade-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceChangeAutoCompoundStatus } from "./changeAutoCompoundStatus.js" -import { registerBinanceCheckDualInvestmentAccounts } from "./checkDualInvestmentAccounts.js" -import { registerBinanceGetDualInvestmentPositions } from "./getDualInvestmentPositions.js" -import { registerBinanceSubscribeDualInvestmentProducts } from "./subscribeDualInvestmentProducts.js" +import { registerBinanceChangeAutoCompoundStatus } from "./changeAutoCompoundStatus.js"; +import { registerBinanceCheckDualInvestmentAccounts } from "./checkDualInvestmentAccounts.js"; +import { registerBinanceGetDualInvestmentPositions } from "./getDualInvestmentPositions.js"; +import { registerBinanceSubscribeDualInvestmentProducts } from "./subscribeDualInvestmentProducts.js"; export function registerBinanceDualInvestmentTradeApiTools(server: McpServer) { - registerBinanceSubscribeDualInvestmentProducts(server) - registerBinanceCheckDualInvestmentAccounts(server) - registerBinanceGetDualInvestmentPositions(server) - registerBinanceChangeAutoCompoundStatus(server) + registerBinanceSubscribeDualInvestmentProducts(server); + registerBinanceCheckDualInvestmentAccounts(server); + registerBinanceGetDualInvestmentPositions(server); + registerBinanceChangeAutoCompoundStatus(server); } diff --git a/src/modules/dual-investment/trade-api/subscribeDualInvestmentProducts.ts b/src/modules/dual-investment/trade-api/subscribeDualInvestmentProducts.ts index 41221ba1..b9b179fc 100644 --- a/src/modules/dual-investment/trade-api/subscribeDualInvestmentProducts.ts +++ b/src/modules/dual-investment/trade-api/subscribeDualInvestmentProducts.ts @@ -1,9 +1,9 @@ // src/tools/binance-dual-investment/trade-api/subscribeDualInvestmentProducts.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { dualInvestmentClient } from "../../../config/binanceClient.js" +import { dualInvestmentClient } from "../../../config/binanceClient.js"; export function registerBinanceSubscribeDualInvestmentProducts(server: McpServer) { server.tool( @@ -31,9 +31,9 @@ export function registerBinanceSubscribeDualInvestmentProducts(server: McpServer depositAmount: params.depositAmount, autoCompoundPlan: params.autoCompoundPlan, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -44,9 +44,9 @@ export function registerBinanceSubscribeDualInvestmentProducts(server: McpServer )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -56,8 +56,8 @@ export function registerBinanceSubscribeDualInvestmentProducts(server: McpServer }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/fiat/fiat-api/getFiatDepositWithdrawHistory.ts b/src/modules/fiat/fiat-api/getFiatDepositWithdrawHistory.ts index bb1dd8d2..df6445a1 100644 --- a/src/modules/fiat/fiat-api/getFiatDepositWithdrawHistory.ts +++ b/src/modules/fiat/fiat-api/getFiatDepositWithdrawHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-fiat/fiat-api/getFiatDepositWithdrawHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { fiatClient } from "../../../config/binanceClient.js" +import { fiatClient } from "../../../config/binanceClient.js"; export function registerBinanceGetFiatDepositWithdrawHistory(server: McpServer) { server.tool( @@ -33,9 +33,9 @@ export function registerBinanceGetFiatDepositWithdrawHistory(server: McpServer) ...(params.page && { page: params.page }), ...(params.rows && { rows: params.rows }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -46,9 +46,9 @@ export function registerBinanceGetFiatDepositWithdrawHistory(server: McpServer) )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -58,8 +58,8 @@ export function registerBinanceGetFiatDepositWithdrawHistory(server: McpServer) }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/fiat/fiat-api/getFiatPaymentsHistory.ts b/src/modules/fiat/fiat-api/getFiatPaymentsHistory.ts index 952e542f..0629c1c4 100644 --- a/src/modules/fiat/fiat-api/getFiatPaymentsHistory.ts +++ b/src/modules/fiat/fiat-api/getFiatPaymentsHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-fiat/fiat-api/getFiatPaymentsHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { fiatClient } from "../../../config/binanceClient.js" +import { fiatClient } from "../../../config/binanceClient.js"; export function registerBinanceGetFiatPaymentsHistory(server: McpServer) { server.tool( @@ -31,9 +31,9 @@ export function registerBinanceGetFiatPaymentsHistory(server: McpServer) { ...(params.page && { page: params.page }), ...(params.rows && { rows: params.rows }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -44,9 +44,9 @@ export function registerBinanceGetFiatPaymentsHistory(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -56,8 +56,8 @@ export function registerBinanceGetFiatPaymentsHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/fiat/index.ts b/src/modules/fiat/index.ts index e013e5f3..bda7e93b 100644 --- a/src/modules/fiat/index.ts +++ b/src/modules/fiat/index.ts @@ -1,13 +1,13 @@ // src/tools/binance-fiat/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetFiatDepositWithdrawHistory } from "./fiat-api/getFiatDepositWithdrawHistory.js" -import { registerBinanceGetFiatPaymentsHistory } from "./fiat-api/getFiatPaymentsHistory.js" +import { registerBinanceGetFiatDepositWithdrawHistory } from "./fiat-api/getFiatDepositWithdrawHistory.js"; +import { registerBinanceGetFiatPaymentsHistory } from "./fiat-api/getFiatPaymentsHistory.js"; export function registerBinanceFiatDepositWithdrawHistoryTools(server: McpServer) { - registerBinanceGetFiatDepositWithdrawHistory(server) - registerBinanceGetFiatPaymentsHistory(server) + registerBinanceGetFiatDepositWithdrawHistory(server); + registerBinanceGetFiatPaymentsHistory(server); } // Alias for binance.ts compatibility -export { registerBinanceFiatDepositWithdrawHistoryTools as registerFiat } +export { registerBinanceFiatDepositWithdrawHistoryTools as registerFiat }; diff --git a/src/modules/futures-coinm/index.ts b/src/modules/futures-coinm/index.ts index 22526810..918d049a 100644 --- a/src/modules/futures-coinm/index.ts +++ b/src/modules/futures-coinm/index.ts @@ -1,8 +1,8 @@ // src/modules/futures-coinm/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceFuturesCOINMTools } from "../../tools/binance-futures-coinm/index.js" +import { registerBinanceFuturesCOINMTools } from "../../tools/binance-futures-coinm/index.js"; export function registerFuturesCOINM(server: McpServer) { - registerBinanceFuturesCOINMTools(server) + registerBinanceFuturesCOINMTools(server); } diff --git a/src/modules/futures-usdm/index.ts b/src/modules/futures-usdm/index.ts index 9ce9f819..940524d0 100644 --- a/src/modules/futures-usdm/index.ts +++ b/src/modules/futures-usdm/index.ts @@ -1,8 +1,8 @@ // src/modules/futures-usdm/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceFuturesUSDMTools } from "../../tools/binance-futures-usdm/index.js" +import { registerBinanceFuturesUSDMTools } from "../../tools/binance-futures-usdm/index.js"; export function registerFuturesUSDM(server: McpServer) { - registerBinanceFuturesUSDMTools(server) + registerBinanceFuturesUSDMTools(server); } diff --git a/src/modules/gift-card/index.ts b/src/modules/gift-card/index.ts index c777e988..88cdbe38 100644 --- a/src/modules/gift-card/index.ts +++ b/src/modules/gift-card/index.ts @@ -1,8 +1,8 @@ // src/modules/gift-card/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGiftCardTools } from "../../tools/binance-gift-card/index.js" +import { registerBinanceGiftCardTools } from "../../tools/binance-gift-card/index.js"; export function registerGiftCard(server: McpServer) { - registerBinanceGiftCardTools(server) + registerBinanceGiftCardTools(server); } diff --git a/src/modules/margin/index.ts b/src/modules/margin/index.ts index a32fd8f6..c1e4cdc7 100644 --- a/src/modules/margin/index.ts +++ b/src/modules/margin/index.ts @@ -1,8 +1,8 @@ // src/modules/margin/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceMarginTools } from "../../tools/binance-margin/index.js" +import { registerBinanceMarginTools } from "../../tools/binance-margin/index.js"; export function registerMargin(server: McpServer) { - registerBinanceMarginTools(server) + registerBinanceMarginTools(server); } diff --git a/src/modules/mining/index.ts b/src/modules/mining/index.ts index de3474d9..c77b10a6 100644 --- a/src/modules/mining/index.ts +++ b/src/modules/mining/index.ts @@ -1,35 +1,35 @@ // src/tools/binance-mining/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceAccountList } from "./mining-api/accountList.js" -import { registerBinanceAcquiringAlgorithm } from "./mining-api/acquiringAlgorithm.js" -import { registerBinanceAcquiringCoinName } from "./mining-api/acquiringCoinname.js" -import { registerBinanceCancelHashRateResaleConfiguration } from "./mining-api/cancelHashrateResaleConfiguration.js" -import { registerBinanceEarningsList } from "./mining-api/earningsList.js" -import { registerBinanceExtraBonusList } from "./mining-api/extraBonusList.js" -import { registerBinanceHashRateResaleDetail } from "./mining-api/hashrateResaleDetail.js" -import { registerBinanceHashRateResaleList } from "./mining-api/hashrateResaleList.js" -import { registerBinanceHashRateResaleRequest } from "./mining-api/hashrateResaleRequest.js" -import { registerBinanceMiningAccountEarning } from "./mining-api/miningAccountEarning.js" -import { registerBinanceRequestForDetailMinerList } from "./mining-api/requestForDetailMinerList.js" -import { registerBinanceRequestForMinerList } from "./mining-api/requestForMinerList.js" -import { registerBinanceStatisticList } from "./mining-api/statisticList.js" +import { registerBinanceAccountList } from "./mining-api/accountList.js"; +import { registerBinanceAcquiringAlgorithm } from "./mining-api/acquiringAlgorithm.js"; +import { registerBinanceAcquiringCoinName } from "./mining-api/acquiringCoinname.js"; +import { registerBinanceCancelHashRateResaleConfiguration } from "./mining-api/cancelHashrateResaleConfiguration.js"; +import { registerBinanceEarningsList } from "./mining-api/earningsList.js"; +import { registerBinanceExtraBonusList } from "./mining-api/extraBonusList.js"; +import { registerBinanceHashRateResaleDetail } from "./mining-api/hashrateResaleDetail.js"; +import { registerBinanceHashRateResaleList } from "./mining-api/hashrateResaleList.js"; +import { registerBinanceHashRateResaleRequest } from "./mining-api/hashrateResaleRequest.js"; +import { registerBinanceMiningAccountEarning } from "./mining-api/miningAccountEarning.js"; +import { registerBinanceRequestForDetailMinerList } from "./mining-api/requestForDetailMinerList.js"; +import { registerBinanceRequestForMinerList } from "./mining-api/requestForMinerList.js"; +import { registerBinanceStatisticList } from "./mining-api/statisticList.js"; export function registerBinanceMiningTools(server: McpServer) { - registerBinanceAcquiringAlgorithm(server) - registerBinanceAcquiringCoinName(server) - registerBinanceHashRateResaleList(server) - registerBinanceRequestForMinerList(server) - registerBinanceRequestForDetailMinerList(server) - registerBinanceExtraBonusList(server) - registerBinanceEarningsList(server) - registerBinanceCancelHashRateResaleConfiguration(server) - registerBinanceHashRateResaleDetail(server) - registerBinanceMiningAccountEarning(server) - registerBinanceStatisticList(server) - registerBinanceHashRateResaleRequest(server) - registerBinanceAccountList(server) + registerBinanceAcquiringAlgorithm(server); + registerBinanceAcquiringCoinName(server); + registerBinanceHashRateResaleList(server); + registerBinanceRequestForMinerList(server); + registerBinanceRequestForDetailMinerList(server); + registerBinanceExtraBonusList(server); + registerBinanceEarningsList(server); + registerBinanceCancelHashRateResaleConfiguration(server); + registerBinanceHashRateResaleDetail(server); + registerBinanceMiningAccountEarning(server); + registerBinanceStatisticList(server); + registerBinanceHashRateResaleRequest(server); + registerBinanceAccountList(server); } // Alias for binance.ts compatibility -export { registerBinanceMiningTools as registerMining } +export { registerBinanceMiningTools as registerMining }; diff --git a/src/modules/mining/mining-api/accountList.ts b/src/modules/mining/mining-api/accountList.ts index cb48f137..5d43881a 100644 --- a/src/modules/mining/mining-api/accountList.ts +++ b/src/modules/mining/mining-api/accountList.ts @@ -1,9 +1,9 @@ // src/tools/binance-mining/mining-api/accountList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { miningClient } from "../../../config/binanceClient.js" +import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceAccountList(server: McpServer) { server.tool( @@ -20,9 +20,9 @@ export function registerBinanceAccountList(server: McpServer) { algo: params.algo, userName: params.userName, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -33,9 +33,9 @@ export function registerBinanceAccountList(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -45,8 +45,8 @@ export function registerBinanceAccountList(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/mining/mining-api/acquiringAlgorithm.ts b/src/modules/mining/mining-api/acquiringAlgorithm.ts index 4551274c..c02d7f3a 100644 --- a/src/modules/mining/mining-api/acquiringAlgorithm.ts +++ b/src/modules/mining/mining-api/acquiringAlgorithm.ts @@ -1,7 +1,7 @@ // src/tools/binance-mining/mining-api/acquiringAlgorithm.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js" +import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceAcquiringAlgorithm(server: McpServer) { server.tool( @@ -10,9 +10,9 @@ export function registerBinanceAcquiringAlgorithm(server: McpServer) { {}, async () => { try { - const response = await miningClient.restAPI.acquiringAlgorithm() + const response = await miningClient.restAPI.acquiringAlgorithm(); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -23,9 +23,9 @@ export function registerBinanceAcquiringAlgorithm(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -35,8 +35,8 @@ export function registerBinanceAcquiringAlgorithm(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/mining/mining-api/acquiringCoinname.ts b/src/modules/mining/mining-api/acquiringCoinname.ts index aef4b04c..f5ff7b69 100644 --- a/src/modules/mining/mining-api/acquiringCoinname.ts +++ b/src/modules/mining/mining-api/acquiringCoinname.ts @@ -1,7 +1,7 @@ // src/tools/binance-mining/mining-api/acquiringCoinname.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js" +import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceAcquiringCoinName(server: McpServer) { server.tool( @@ -10,9 +10,9 @@ export function registerBinanceAcquiringCoinName(server: McpServer) { {}, async () => { try { - const response = await miningClient.restAPI.acquiringCoinname() + const response = await miningClient.restAPI.acquiringCoinname(); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -21,9 +21,9 @@ export function registerBinanceAcquiringCoinName(server: McpServer) { text: `Successfully fetched supported mining coins. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -33,8 +33,8 @@ export function registerBinanceAcquiringCoinName(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/mining/mining-api/cancelHashrateResaleConfiguration.ts b/src/modules/mining/mining-api/cancelHashrateResaleConfiguration.ts index 5dd7d120..7ec167a4 100644 --- a/src/modules/mining/mining-api/cancelHashrateResaleConfiguration.ts +++ b/src/modules/mining/mining-api/cancelHashrateResaleConfiguration.ts @@ -1,9 +1,9 @@ // src/tools/binance-mining/mining-api/cancelHashrateResaleConfiguration.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { miningClient } from "../../../config/binanceClient.js" +import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceCancelHashRateResaleConfiguration(server: McpServer) { server.tool( @@ -20,9 +20,9 @@ export function registerBinanceCancelHashRateResaleConfiguration(server: McpServ configId: params.configId, userName: params.userName, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -33,9 +33,9 @@ export function registerBinanceCancelHashRateResaleConfiguration(server: McpServ )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -45,8 +45,8 @@ export function registerBinanceCancelHashRateResaleConfiguration(server: McpServ }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/mining/mining-api/earningsList.ts b/src/modules/mining/mining-api/earningsList.ts index 3afee161..2e768d70 100644 --- a/src/modules/mining/mining-api/earningsList.ts +++ b/src/modules/mining/mining-api/earningsList.ts @@ -1,9 +1,9 @@ // src/tools/binance-mining/mining-api/earningsList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { miningClient } from "../../../config/binanceClient.js" +import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceEarningsList(server: McpServer) { server.tool( @@ -44,9 +44,9 @@ export function registerBinanceEarningsList(server: McpServer) { ...(params.pageIndex && { pageIndex: params.pageIndex }), ...(params.pageSize && { pageSize: params.pageSize }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -57,9 +57,9 @@ export function registerBinanceEarningsList(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -69,8 +69,8 @@ export function registerBinanceEarningsList(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/mining/mining-api/extraBonusList.ts b/src/modules/mining/mining-api/extraBonusList.ts index a49e7c0d..a8a2c38c 100644 --- a/src/modules/mining/mining-api/extraBonusList.ts +++ b/src/modules/mining/mining-api/extraBonusList.ts @@ -1,9 +1,9 @@ // src/tools/binance-mining/mining-api/extraBonusList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { miningClient } from "../../../config/binanceClient.js" +import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceExtraBonusList(server: McpServer) { server.tool( @@ -39,8 +39,8 @@ export function registerBinanceExtraBonusList(server: McpServer) { ...(params.pageIndex && { pageIndex: params.pageIndex }), ...(params.pageSize && { pageSize: params.pageSize }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -51,9 +51,9 @@ export function registerBinanceExtraBonusList(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -63,8 +63,8 @@ export function registerBinanceExtraBonusList(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/mining/mining-api/hashrateResaleDetail.ts b/src/modules/mining/mining-api/hashrateResaleDetail.ts index 770d81c9..b5b37a68 100644 --- a/src/modules/mining/mining-api/hashrateResaleDetail.ts +++ b/src/modules/mining/mining-api/hashrateResaleDetail.ts @@ -1,9 +1,9 @@ // src/tools/binance-mining/mining-api/hashrateResaleDetail.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { miningClient } from "../../../config/binanceClient.js" +import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceHashRateResaleDetail(server: McpServer) { server.tool( @@ -35,9 +35,9 @@ export function registerBinanceHashRateResaleDetail(server: McpServer) { ...(params.pageIndex && { pageIndex: params.pageIndex }), ...(params.pageSize && { pageSize: params.pageSize }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -48,9 +48,9 @@ export function registerBinanceHashRateResaleDetail(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -60,8 +60,8 @@ export function registerBinanceHashRateResaleDetail(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/mining/mining-api/hashrateResaleList.ts b/src/modules/mining/mining-api/hashrateResaleList.ts index b5b6ab27..7c91d0bc 100644 --- a/src/modules/mining/mining-api/hashrateResaleList.ts +++ b/src/modules/mining/mining-api/hashrateResaleList.ts @@ -1,9 +1,9 @@ // src/tools/binance-mining/mining-api/hashrateResaleList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { miningClient } from "../../../config/binanceClient.js" +import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceHashRateResaleList(server: McpServer) { server.tool( @@ -31,9 +31,9 @@ export function registerBinanceHashRateResaleList(server: McpServer) { ...(params.pageIndex && { pageIndex: params.pageIndex }), ...(params.pageSize && { pageSize: params.pageSize }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -44,9 +44,9 @@ export function registerBinanceHashRateResaleList(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -56,8 +56,8 @@ export function registerBinanceHashRateResaleList(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/mining/mining-api/hashrateResaleRequest.ts b/src/modules/mining/mining-api/hashrateResaleRequest.ts index 73c3b099..e8029938 100644 --- a/src/modules/mining/mining-api/hashrateResaleRequest.ts +++ b/src/modules/mining/mining-api/hashrateResaleRequest.ts @@ -1,9 +1,9 @@ // src/tools/binance-mining/mining-api/hashrateResaleRequest.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { miningClient } from "../../../config/binanceClient.js" +import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceHashRateResaleRequest(server: McpServer) { server.tool( @@ -35,9 +35,9 @@ export function registerBinanceHashRateResaleRequest(server: McpServer) { toPoolUser: params.toPoolUser, hashRate: params.hashRate, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -48,9 +48,9 @@ export function registerBinanceHashRateResaleRequest(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -60,8 +60,8 @@ export function registerBinanceHashRateResaleRequest(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/mining/mining-api/miningAccountEarning.ts b/src/modules/mining/mining-api/miningAccountEarning.ts index 17f4e9ac..5b1d4e86 100644 --- a/src/modules/mining/mining-api/miningAccountEarning.ts +++ b/src/modules/mining/mining-api/miningAccountEarning.ts @@ -1,9 +1,9 @@ // src/tools/binance-mining/mining-api/miningAccountEarning.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { miningClient } from "../../../config/binanceClient.js" +import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceMiningAccountEarning(server: McpServer) { server.tool( @@ -32,9 +32,9 @@ export function registerBinanceMiningAccountEarning(server: McpServer) { ...(params.pageIndex && { pageIndex: params.pageIndex }), ...(params.pageSize && { pageSize: params.pageSize }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -45,9 +45,9 @@ export function registerBinanceMiningAccountEarning(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -57,8 +57,8 @@ export function registerBinanceMiningAccountEarning(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/mining/mining-api/requestForDetailMinerList.ts b/src/modules/mining/mining-api/requestForDetailMinerList.ts index a45268a5..5302c9aa 100644 --- a/src/modules/mining/mining-api/requestForDetailMinerList.ts +++ b/src/modules/mining/mining-api/requestForDetailMinerList.ts @@ -1,9 +1,9 @@ // src/tools/binance-mining/mining-api/requestForDetailMinerList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { miningClient } from "../../../config/binanceClient.js" +import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceRequestForDetailMinerList(server: McpServer) { server.tool( @@ -22,9 +22,9 @@ export function registerBinanceRequestForDetailMinerList(server: McpServer) { userName: params.userName, workerName: params.workerName, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,9 +35,9 @@ export function registerBinanceRequestForDetailMinerList(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -47,8 +47,8 @@ export function registerBinanceRequestForDetailMinerList(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/mining/mining-api/requestForMinerList.ts b/src/modules/mining/mining-api/requestForMinerList.ts index f83cb473..b344712a 100644 --- a/src/modules/mining/mining-api/requestForMinerList.ts +++ b/src/modules/mining/mining-api/requestForMinerList.ts @@ -1,9 +1,9 @@ // src/tools/binance-mining/mining-api/requestForMinerList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { miningClient } from "../../../config/binanceClient.js" +import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceRequestForMinerList(server: McpServer) { server.tool( @@ -53,9 +53,9 @@ export function registerBinanceRequestForMinerList(server: McpServer) { ...(params.sortColumn && { sortColumn: params.sortColumn }), ...(params.workerStatus && { workerStatus: params.workerStatus }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -66,9 +66,9 @@ export function registerBinanceRequestForMinerList(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -78,8 +78,8 @@ export function registerBinanceRequestForMinerList(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/mining/mining-api/statisticList.ts b/src/modules/mining/mining-api/statisticList.ts index 0b7e4631..6957833f 100644 --- a/src/modules/mining/mining-api/statisticList.ts +++ b/src/modules/mining/mining-api/statisticList.ts @@ -1,9 +1,9 @@ // src/tools/binance-mining/mining-api/statisticList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { miningClient } from "../../../config/binanceClient.js" +import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceStatisticList(server: McpServer) { server.tool( @@ -24,8 +24,8 @@ export function registerBinanceStatisticList(server: McpServer) { algo: params.algo, userName: params.userName, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -36,9 +36,9 @@ export function registerBinanceStatisticList(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -48,8 +48,8 @@ export function registerBinanceStatisticList(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/nft/index.ts b/src/modules/nft/index.ts index e2bf6eb7..40ca3a2e 100644 --- a/src/modules/nft/index.ts +++ b/src/modules/nft/index.ts @@ -1,17 +1,17 @@ // src/tools/binance-fiat/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetNFTAsset } from "./nft-api/getNFTAsset.js" -import { registerBinanceGetNFTDepositHistory } from "./nft-api/getNFTDepositHistory.js" -import { registerBinanceGetNFTTransactionHistory } from "./nft-api/getNFTTransactionHistory.js" -import { registerBinanceGetNFTWithdrawHistory } from "./nft-api/getNFTWithdrawHistory.js" +import { registerBinanceGetNFTAsset } from "./nft-api/getNFTAsset.js"; +import { registerBinanceGetNFTDepositHistory } from "./nft-api/getNFTDepositHistory.js"; +import { registerBinanceGetNFTTransactionHistory } from "./nft-api/getNFTTransactionHistory.js"; +import { registerBinanceGetNFTWithdrawHistory } from "./nft-api/getNFTWithdrawHistory.js"; export function registerBinanceNFTTools(server: McpServer) { - registerBinanceGetNFTDepositHistory(server) - registerBinanceGetNFTWithdrawHistory(server) - registerBinanceGetNFTTransactionHistory(server) - registerBinanceGetNFTAsset(server) + registerBinanceGetNFTDepositHistory(server); + registerBinanceGetNFTWithdrawHistory(server); + registerBinanceGetNFTTransactionHistory(server); + registerBinanceGetNFTAsset(server); } // Alias for binance.ts compatibility -export { registerBinanceNFTTools as registerNFT } +export { registerBinanceNFTTools as registerNFT }; diff --git a/src/modules/nft/nft-api/getNFTAsset.ts b/src/modules/nft/nft-api/getNFTAsset.ts index dc5cc49c..335bc2c3 100644 --- a/src/modules/nft/nft-api/getNFTAsset.ts +++ b/src/modules/nft/nft-api/getNFTAsset.ts @@ -1,9 +1,9 @@ // src/tools/binance-nft/nft-api/getNFTAsset.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { nftClient } from "../../../config/binanceClient.js" +import { nftClient } from "../../../config/binanceClient.js"; export function registerBinanceGetNFTAsset(server: McpServer) { server.tool( @@ -25,9 +25,9 @@ export function registerBinanceGetNFTAsset(server: McpServer) { ...(params.limit && { limit: params.limit }), ...(params.page && { page: params.page }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -38,9 +38,9 @@ export function registerBinanceGetNFTAsset(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -50,8 +50,8 @@ export function registerBinanceGetNFTAsset(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/nft/nft-api/getNFTDepositHistory.ts b/src/modules/nft/nft-api/getNFTDepositHistory.ts index a01bc6a2..57fec721 100644 --- a/src/modules/nft/nft-api/getNFTDepositHistory.ts +++ b/src/modules/nft/nft-api/getNFTDepositHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-nft/nft-api/getNFTDepositHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { nftClient } from "../../../config/binanceClient.js" +import { nftClient } from "../../../config/binanceClient.js"; export function registerBinanceGetNFTDepositHistory(server: McpServer) { server.tool( @@ -29,9 +29,9 @@ export function registerBinanceGetNFTDepositHistory(server: McpServer) { ...(params.limit && { limit: params.limit }), ...(params.page && { page: params.page }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -42,9 +42,9 @@ export function registerBinanceGetNFTDepositHistory(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -54,8 +54,8 @@ export function registerBinanceGetNFTDepositHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/nft/nft-api/getNFTTransactionHistory.ts b/src/modules/nft/nft-api/getNFTTransactionHistory.ts index 8c755bc9..0320072f 100644 --- a/src/modules/nft/nft-api/getNFTTransactionHistory.ts +++ b/src/modules/nft/nft-api/getNFTTransactionHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-nft/nft-api/getNFTTransactionHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { nftClient } from "../../../config/binanceClient.js" +import { nftClient } from "../../../config/binanceClient.js"; export function registerBinanceGetNFTTransactionHistory(server: McpServer) { server.tool( @@ -35,9 +35,9 @@ export function registerBinanceGetNFTTransactionHistory(server: McpServer) { ...(params.limit && { limit: params.limit }), ...(params.page && { page: params.page }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -46,9 +46,9 @@ export function registerBinanceGetNFTTransactionHistory(server: McpServer) { text: `Successfully retrieved NFT transaction history. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -58,8 +58,8 @@ export function registerBinanceGetNFTTransactionHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/nft/nft-api/getNFTWithdrawHistory.ts b/src/modules/nft/nft-api/getNFTWithdrawHistory.ts index 6cf2bdb7..b14b3cd9 100644 --- a/src/modules/nft/nft-api/getNFTWithdrawHistory.ts +++ b/src/modules/nft/nft-api/getNFTWithdrawHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-nft/nft-api/getNFTWithdrawHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { nftClient } from "../../../config/binanceClient.js" +import { nftClient } from "../../../config/binanceClient.js"; export function registerBinanceGetNFTWithdrawHistory(server: McpServer) { server.tool( @@ -29,9 +29,9 @@ export function registerBinanceGetNFTWithdrawHistory(server: McpServer) { ...(params.limit && { limit: params.limit }), ...(params.page && { page: params.page }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -42,9 +42,9 @@ export function registerBinanceGetNFTWithdrawHistory(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -54,8 +54,8 @@ export function registerBinanceGetNFTWithdrawHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/options/account-api/getAccount.ts b/src/modules/options/account-api/getAccount.ts index d1081ddf..6809abbe 100644 --- a/src/modules/options/account-api/getAccount.ts +++ b/src/modules/options/account-api/getAccount.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/options/account-api/getAccount.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../../config/binanceClient.js" +import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsGetAccount(server: McpServer) { server.tool( @@ -22,27 +22,27 @@ export function registerOptionsGetAccount(server: McpServer) { try { const response = await optionsClient.restAPI.account({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Options Account Information\n\n` + let result = `✅ Options Account Information\n\n`; if (data) { - result += `**Account Details**\n` - result += `Asset: ${data.asset}\n` - result += `Margin Balance: ${data.marginBalance}\n` - result += `Equity: ${data.equity}\n` - result += `Available: ${data.available}\n` - result += `Unrealized PnL: ${data.unrealizedPNL}\n` - result += `Maintenance Margin: ${data.maintenanceMargin}\n` - result += `Initial Margin: ${data.initialMargin}\n\n` + result += `**Account Details**\n`; + result += `Asset: ${data.asset}\n`; + result += `Margin Balance: ${data.marginBalance}\n`; + result += `Equity: ${data.equity}\n`; + result += `Available: ${data.available}\n`; + result += `Unrealized PnL: ${data.unrealizedPNL}\n`; + result += `Maintenance Margin: ${data.maintenanceMargin}\n`; + result += `Initial Margin: ${data.initialMargin}\n\n`; - result += `**Greeks**\n` - result += `Delta: ${data.delta || "N/A"}\n` - result += `Theta: ${data.theta || "N/A"}\n` - result += `Gamma: ${data.gamma || "N/A"}\n` - result += `Vega: ${data.vega || "N/A"}\n` + result += `**Greeks**\n`; + result += `Delta: ${data.delta || "N/A"}\n`; + result += `Theta: ${data.theta || "N/A"}\n`; + result += `Gamma: ${data.gamma || "N/A"}\n`; + result += `Vega: ${data.vega || "N/A"}\n`; } return { @@ -52,9 +52,9 @@ export function registerOptionsGetAccount(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -64,8 +64,8 @@ export function registerOptionsGetAccount(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/options/account-api/getBillHistory.ts b/src/modules/options/account-api/getBillHistory.ts index c6ecf835..4a431c14 100644 --- a/src/modules/options/account-api/getBillHistory.ts +++ b/src/modules/options/account-api/getBillHistory.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/options/account-api/getBillHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../../config/binanceClient.js" +import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsGetBillHistory(server: McpServer) { server.tool( @@ -38,27 +38,27 @@ export function registerOptionsGetBillHistory(server: McpServer) { ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Options Bill History\n\n` + let result = `✅ Options Bill History\n\n`; if (Array.isArray(data) && data.length > 0) { - result += `Total records: ${data.length}\n\n` + result += `Total records: ${data.length}\n\n`; data.slice(0, 20).forEach((record: any, index: number) => { - result += `**${index + 1}. ${record.type}**\n` - result += ` ID: ${record.id}\n` - result += ` Amount: ${record.amount} ${record.currency}\n` - result += ` Balance: ${record.balance}\n` - if (record.symbol) result += ` Symbol: ${record.symbol}\n` - result += ` Time: ${new Date(record.createTime).toISOString()}\n\n` - }) + result += `**${index + 1}. ${record.type}**\n`; + result += ` ID: ${record.id}\n`; + result += ` Amount: ${record.amount} ${record.currency}\n`; + result += ` Balance: ${record.balance}\n`; + if (record.symbol) result += ` Symbol: ${record.symbol}\n`; + result += ` Time: ${new Date(record.createTime).toISOString()}\n\n`; + }); if (data.length > 20) { - result += `... and ${data.length - 20} more records` + result += `... and ${data.length - 20} more records`; } } else { - result += `No bill history found` + result += `No bill history found`; } return { @@ -68,9 +68,9 @@ export function registerOptionsGetBillHistory(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -80,8 +80,8 @@ export function registerOptionsGetBillHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/options/account-api/getIncomeAsyn.ts b/src/modules/options/account-api/getIncomeAsyn.ts index a2eef35d..8a138e17 100644 --- a/src/modules/options/account-api/getIncomeAsyn.ts +++ b/src/modules/options/account-api/getIncomeAsyn.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/options/account-api/getIncomeAsyn.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../../config/binanceClient.js" +import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsGetIncomeAsyn(server: McpServer) { server.tool( @@ -26,9 +26,9 @@ export function registerOptionsGetIncomeAsyn(server: McpServer) { startTime: params.startTime, endTime: params.endTime, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -37,9 +37,9 @@ export function registerOptionsGetIncomeAsyn(server: McpServer) { text: `✅ Options Income Download Request Submitted\n\nDownload ID: ${data.downloadId || data.id}\n\nUse BinanceOptionsGetIncomeAsynId with this ID to retrieve the download URL.`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -49,8 +49,8 @@ export function registerOptionsGetIncomeAsyn(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/options/account-api/getIncomeAsynId.ts b/src/modules/options/account-api/getIncomeAsynId.ts index 9df80c85..f8038037 100644 --- a/src/modules/options/account-api/getIncomeAsynId.ts +++ b/src/modules/options/account-api/getIncomeAsynId.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/options/account-api/getIncomeAsynId.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../../config/binanceClient.js" +import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsGetIncomeAsynId(server: McpServer) { server.tool( @@ -24,19 +24,19 @@ export function registerOptionsGetIncomeAsynId(server: McpServer) { const response = await optionsClient.restAPI.incomeAsynId({ downloadId: params.downloadId, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Options Income Download Status\n\n` - result += `Download ID: ${params.downloadId}\n` - result += `Status: ${data.status}\n` + let result = `✅ Options Income Download Status\n\n`; + result += `Download ID: ${params.downloadId}\n`; + result += `Status: ${data.status}\n`; if (data.url) { - result += `\n**Download URL**: ${data.url}\n` - result += `\nNote: URL is valid for a limited time.` + result += `\n**Download URL**: ${data.url}\n`; + result += `\nNote: URL is valid for a limited time.`; } else if (data.status === "processing") { - result += `\nThe download is still being processed. Please try again in a few moments.` + result += `\nThe download is still being processed. Please try again in a few moments.`; } return { @@ -46,9 +46,9 @@ export function registerOptionsGetIncomeAsynId(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -58,8 +58,8 @@ export function registerOptionsGetIncomeAsynId(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/options/account-api/getPosition.ts b/src/modules/options/account-api/getPosition.ts index f127d8cc..33d74956 100644 --- a/src/modules/options/account-api/getPosition.ts +++ b/src/modules/options/account-api/getPosition.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/options/account-api/getPosition.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../../config/binanceClient.js" +import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsGetPosition(server: McpServer) { server.tool( @@ -26,26 +26,26 @@ export function registerOptionsGetPosition(server: McpServer) { ...(params.symbol && { symbol: params.symbol }), ...(params.underlying && { underlying: params.underlying }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Options Positions\n\n` + let result = `✅ Options Positions\n\n`; if (Array.isArray(data) && data.length > 0) { - result += `Total positions: ${data.length}\n\n` + result += `Total positions: ${data.length}\n\n`; data.forEach((pos: any, index: number) => { - result += `**${index + 1}. ${pos.symbol}**\n` - result += ` Side: ${pos.side}\n` - result += ` Quantity: ${pos.quantity}\n` - result += ` Entry Price: ${pos.entryPrice}\n` - result += ` Mark Price: ${pos.markPrice}\n` - result += ` Unrealized PnL: ${pos.unrealizedPNL}\n` - result += ` Maintenance Margin: ${pos.maintMargin}\n` - result += ` Expiry Date: ${pos.expiryDate}\n\n` - }) + result += `**${index + 1}. ${pos.symbol}**\n`; + result += ` Side: ${pos.side}\n`; + result += ` Quantity: ${pos.quantity}\n`; + result += ` Entry Price: ${pos.entryPrice}\n`; + result += ` Mark Price: ${pos.markPrice}\n`; + result += ` Unrealized PnL: ${pos.unrealizedPNL}\n`; + result += ` Maintenance Margin: ${pos.maintMargin}\n`; + result += ` Expiry Date: ${pos.expiryDate}\n\n`; + }); } else { - result += `No positions found` + result += `No positions found`; } return { @@ -55,9 +55,9 @@ export function registerOptionsGetPosition(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -67,8 +67,8 @@ export function registerOptionsGetPosition(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/options/account-api/index.ts b/src/modules/options/account-api/index.ts index 25b14262..2f9dfaac 100644 --- a/src/modules/options/account-api/index.ts +++ b/src/modules/options/account-api/index.ts @@ -5,18 +5,18 @@ * @license Apache-2.0 */ // src/modules/options/account-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerOptionsGetAccount } from "./getAccount.js" -import { registerOptionsGetBillHistory } from "./getBillHistory.js" -import { registerOptionsGetIncomeAsyn } from "./getIncomeAsyn.js" -import { registerOptionsGetIncomeAsynId } from "./getIncomeAsynId.js" -import { registerOptionsGetPosition } from "./getPosition.js" +import { registerOptionsGetAccount } from "./getAccount.js"; +import { registerOptionsGetBillHistory } from "./getBillHistory.js"; +import { registerOptionsGetIncomeAsyn } from "./getIncomeAsyn.js"; +import { registerOptionsGetIncomeAsynId } from "./getIncomeAsynId.js"; +import { registerOptionsGetPosition } from "./getPosition.js"; export function registerOptionsAccountApi(server: McpServer) { - registerOptionsGetAccount(server) - registerOptionsGetPosition(server) - registerOptionsGetBillHistory(server) - registerOptionsGetIncomeAsyn(server) - registerOptionsGetIncomeAsynId(server) + registerOptionsGetAccount(server); + registerOptionsGetPosition(server); + registerOptionsGetBillHistory(server); + registerOptionsGetIncomeAsyn(server); + registerOptionsGetIncomeAsynId(server); } diff --git a/src/modules/options/index.ts b/src/modules/options/index.ts index acc6b8e3..664cdfe9 100644 --- a/src/modules/options/index.ts +++ b/src/modules/options/index.ts @@ -1,8 +1,8 @@ // src/modules/options/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceOptionsTools } from "../../tools/binance-options/index.js" +import { registerBinanceOptionsTools } from "../../tools/binance-options/index.js"; export function registerOptions(server: McpServer) { - registerBinanceOptionsTools(server) + registerBinanceOptionsTools(server); } diff --git a/src/modules/options/market-api/depth.ts b/src/modules/options/market-api/depth.ts index 28402d2c..4057042c 100644 --- a/src/modules/options/market-api/depth.ts +++ b/src/modules/options/market-api/depth.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/options/market-api/depth.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../../config/binanceClient.js" +import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsMarketDepth(server: McpServer) { server.tool( @@ -30,29 +30,29 @@ export function registerOptionsMarketDepth(server: McpServer) { const response = await optionsClient.restAPI.depth({ symbol: params.symbol, ...(params.limit && { limit: params.limit }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Options Order Book - ${params.symbol}\n\n` + let result = `✅ Options Order Book - ${params.symbol}\n\n`; // Format asks (sell orders) - result += `**Asks (Sell Orders)**:\n` + result += `**Asks (Sell Orders)**:\n`; if (data.asks && data.asks.length > 0) { data.asks.slice(0, 10).forEach((ask: [string, string]) => { - result += ` Price: ${ask[0]} | Qty: ${ask[1]}\n` - }) + result += ` Price: ${ask[0]} | Qty: ${ask[1]}\n`; + }); } else { - result += ` No asks available\n` + result += ` No asks available\n`; } - result += `\n**Bids (Buy Orders)**:\n` + result += `\n**Bids (Buy Orders)**:\n`; if (data.bids && data.bids.length > 0) { data.bids.slice(0, 10).forEach((bid: [string, string]) => { - result += ` Price: ${bid[0]} | Qty: ${bid[1]}\n` - }) + result += ` Price: ${bid[0]} | Qty: ${bid[1]}\n`; + }); } else { - result += ` No bids available\n` + result += ` No bids available\n`; } return { @@ -62,9 +62,9 @@ export function registerOptionsMarketDepth(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -74,8 +74,8 @@ export function registerOptionsMarketDepth(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/options/market-api/exchangeInfo.ts b/src/modules/options/market-api/exchangeInfo.ts index 7180d199..d795f193 100644 --- a/src/modules/options/market-api/exchangeInfo.ts +++ b/src/modules/options/market-api/exchangeInfo.ts @@ -5,9 +5,9 @@ * @license Apache-2.0 */ // src/modules/options/market-api/exchangeInfo.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js" +import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsMarketExchangeInfo(server: McpServer) { server.tool( @@ -16,29 +16,29 @@ export function registerOptionsMarketExchangeInfo(server: McpServer) { {}, async () => { try { - const response = await optionsClient.restAPI.exchangeInfo() - const data = await response.data() + const response = await optionsClient.restAPI.exchangeInfo(); + const data = await response.data(); // Summarize the response - const optionSymbols = data.optionSymbols || [] - const assets = data.optionAssets || [] + const optionSymbols = data.optionSymbols || []; + const assets = data.optionAssets || []; - let summary = `✅ Options Exchange Information\n\n` - summary += `**Timezone**: ${data.timezone}\n` - summary += `**Server Time**: ${new Date(data.serverTime).toISOString()}\n\n` - summary += `**Available Assets**: ${assets.length}\n` - summary += `**Option Contracts**: ${optionSymbols.length}\n\n` + let summary = `✅ Options Exchange Information\n\n`; + summary += `**Timezone**: ${data.timezone}\n`; + summary += `**Server Time**: ${new Date(data.serverTime).toISOString()}\n\n`; + summary += `**Available Assets**: ${assets.length}\n`; + summary += `**Option Contracts**: ${optionSymbols.length}\n\n`; if (assets.length > 0) { - summary += `**Assets**: ${assets.map((a: any) => a.name || a).join(", ")}\n\n` + summary += `**Assets**: ${assets.map((a: any) => a.name || a).join(", ")}\n\n`; } // Show first few contracts as examples if (optionSymbols.length > 0) { - summary += `**Sample Contracts** (first 5):\n` + summary += `**Sample Contracts** (first 5):\n`; optionSymbols.slice(0, 5).forEach((sym: any) => { - summary += `- ${sym.symbol}: ${sym.underlying} ${sym.side} Strike: ${sym.strikePrice} Expiry: ${sym.expiryDate}\n` - }) + summary += `- ${sym.symbol}: ${sym.underlying} ${sym.side} Strike: ${sym.strikePrice} Expiry: ${sym.expiryDate}\n`; + }); } return { @@ -48,9 +48,9 @@ export function registerOptionsMarketExchangeInfo(server: McpServer) { text: summary, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -60,8 +60,8 @@ export function registerOptionsMarketExchangeInfo(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/options/market-api/exerciseHistory.ts b/src/modules/options/market-api/exerciseHistory.ts index fa61d9c2..fdfd36c1 100644 --- a/src/modules/options/market-api/exerciseHistory.ts +++ b/src/modules/options/market-api/exerciseHistory.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/options/market-api/exerciseHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../../config/binanceClient.js" +import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsMarketExerciseHistory(server: McpServer) { server.tool( @@ -34,24 +34,24 @@ export function registerOptionsMarketExerciseHistory(server: McpServer) { ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Options Exercise History\n\n` + let result = `✅ Options Exercise History\n\n`; if (Array.isArray(data) && data.length > 0) { - result += `Total records: ${data.length}\n\n` + result += `Total records: ${data.length}\n\n`; data.forEach((record: any) => { - const exerciseTime = new Date(record.expiryDate).toISOString() - result += `**${record.symbol}**\n` - result += ` Strike Price: ${record.strikePrice}\n` - result += ` Real Strike Price: ${record.realStrikePrice}\n` - result += ` Exercise Price: ${record.exercisePrice}\n` - result += ` Expiry Date: ${exerciseTime}\n\n` - }) + const exerciseTime = new Date(record.expiryDate).toISOString(); + result += `**${record.symbol}**\n`; + result += ` Strike Price: ${record.strikePrice}\n`; + result += ` Real Strike Price: ${record.realStrikePrice}\n`; + result += ` Exercise Price: ${record.exercisePrice}\n`; + result += ` Expiry Date: ${exerciseTime}\n\n`; + }); } else { - result += `No exercise history found` + result += `No exercise history found`; } return { @@ -61,9 +61,9 @@ export function registerOptionsMarketExerciseHistory(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -73,8 +73,8 @@ export function registerOptionsMarketExerciseHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/options/market-api/historicalTrades.ts b/src/modules/options/market-api/historicalTrades.ts index f18a3577..ad905961 100644 --- a/src/modules/options/market-api/historicalTrades.ts +++ b/src/modules/options/market-api/historicalTrades.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/options/market-api/historicalTrades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../../config/binanceClient.js" +import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsMarketHistoricalTrades(server: McpServer) { server.tool( @@ -36,23 +36,23 @@ export function registerOptionsMarketHistoricalTrades(server: McpServer) { symbol: params.symbol, ...(params.limit && { limit: params.limit }), ...(params.fromId && { fromId: params.fromId }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Historical Trades - ${params.symbol}\n\n` + let result = `✅ Historical Trades - ${params.symbol}\n\n`; if (Array.isArray(data) && data.length > 0) { - result += `Total trades returned: ${data.length}\n\n` + result += `Total trades returned: ${data.length}\n\n`; data.slice(0, 20).forEach((trade: any, index: number) => { - const time = new Date(trade.time).toISOString() - result += `${index + 1}. ID: ${trade.id} | Price: ${trade.price} | Qty: ${trade.qty} | Time: ${time}\n` - }) + const time = new Date(trade.time).toISOString(); + result += `${index + 1}. ID: ${trade.id} | Price: ${trade.price} | Qty: ${trade.qty} | Time: ${time}\n`; + }); if (data.length > 20) { - result += `\n... and ${data.length - 20} more trades` + result += `\n... and ${data.length - 20} more trades`; } } else { - result += `No historical trades found` + result += `No historical trades found`; } return { @@ -62,9 +62,9 @@ export function registerOptionsMarketHistoricalTrades(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -74,8 +74,8 @@ export function registerOptionsMarketHistoricalTrades(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/options/market-api/index.ts b/src/modules/options/market-api/index.ts index 73767068..e93f287d 100644 --- a/src/modules/options/market-api/index.ts +++ b/src/modules/options/market-api/index.ts @@ -5,30 +5,30 @@ * @license Apache-2.0 */ // src/modules/options/market-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerOptionsMarketDepth } from "./depth.js" -import { registerOptionsMarketExchangeInfo } from "./exchangeInfo.js" -import { registerOptionsMarketExerciseHistory } from "./exerciseHistory.js" -import { registerOptionsMarketHistoricalTrades } from "./historicalTrades.js" -import { registerOptionsMarketIndex } from "./indexPrice.js" -import { registerOptionsMarketKlines } from "./klines.js" -import { registerOptionsMarketMark } from "./mark.js" -import { registerOptionsMarketPing } from "./ping.js" -import { registerOptionsMarketTicker } from "./ticker.js" -import { registerOptionsMarketTime } from "./time.js" -import { registerOptionsMarketTrades } from "./trades.js" +import { registerOptionsMarketDepth } from "./depth.js"; +import { registerOptionsMarketExchangeInfo } from "./exchangeInfo.js"; +import { registerOptionsMarketExerciseHistory } from "./exerciseHistory.js"; +import { registerOptionsMarketHistoricalTrades } from "./historicalTrades.js"; +import { registerOptionsMarketIndex } from "./indexPrice.js"; +import { registerOptionsMarketKlines } from "./klines.js"; +import { registerOptionsMarketMark } from "./mark.js"; +import { registerOptionsMarketPing } from "./ping.js"; +import { registerOptionsMarketTicker } from "./ticker.js"; +import { registerOptionsMarketTime } from "./time.js"; +import { registerOptionsMarketTrades } from "./trades.js"; export function registerOptionsMarketApi(server: McpServer) { - registerOptionsMarketPing(server) - registerOptionsMarketTime(server) - registerOptionsMarketExchangeInfo(server) - registerOptionsMarketDepth(server) - registerOptionsMarketTrades(server) - registerOptionsMarketHistoricalTrades(server) - registerOptionsMarketKlines(server) - registerOptionsMarketMark(server) - registerOptionsMarketTicker(server) - registerOptionsMarketIndex(server) - registerOptionsMarketExerciseHistory(server) + registerOptionsMarketPing(server); + registerOptionsMarketTime(server); + registerOptionsMarketExchangeInfo(server); + registerOptionsMarketDepth(server); + registerOptionsMarketTrades(server); + registerOptionsMarketHistoricalTrades(server); + registerOptionsMarketKlines(server); + registerOptionsMarketMark(server); + registerOptionsMarketTicker(server); + registerOptionsMarketIndex(server); + registerOptionsMarketExerciseHistory(server); } diff --git a/src/modules/options/market-api/indexPrice.ts b/src/modules/options/market-api/indexPrice.ts index 668d9242..06f2872c 100644 --- a/src/modules/options/market-api/indexPrice.ts +++ b/src/modules/options/market-api/indexPrice.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/options/market-api/indexPrice.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../../config/binanceClient.js" +import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsMarketIndex(server: McpServer) { server.tool( @@ -22,26 +22,26 @@ export function registerOptionsMarketIndex(server: McpServer) { try { const response = await optionsClient.restAPI.index({ underlying: params.underlying, - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Options Index Price\n\n` + let result = `✅ Options Index Price\n\n`; if (Array.isArray(data)) { data.forEach((item: any) => { - result += `**${item.underlying || item.indexSymbol}**\n` - result += `Index Price: ${item.indexPrice}\n` + result += `**${item.underlying || item.indexSymbol}**\n`; + result += `Index Price: ${item.indexPrice}\n`; if (item.time) { - result += `Time: ${new Date(item.time).toISOString()}\n` + result += `Time: ${new Date(item.time).toISOString()}\n`; } - result += "\n" - }) + result += "\n"; + }); } else if (data) { - result += `**${data.underlying || data.indexSymbol || params.underlying}**\n` - result += `Index Price: ${data.indexPrice}\n` + result += `**${data.underlying || data.indexSymbol || params.underlying}**\n`; + result += `Index Price: ${data.indexPrice}\n`; if (data.time) { - result += `Time: ${new Date(data.time).toISOString()}\n` + result += `Time: ${new Date(data.time).toISOString()}\n`; } } @@ -52,9 +52,9 @@ export function registerOptionsMarketIndex(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -64,8 +64,8 @@ export function registerOptionsMarketIndex(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/options/market-api/klines.ts b/src/modules/options/market-api/klines.ts index 4141f20f..a72702bc 100644 --- a/src/modules/options/market-api/klines.ts +++ b/src/modules/options/market-api/klines.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/options/market-api/klines.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../../config/binanceClient.js" +import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsMarketKlines(server: McpServer) { server.tool( @@ -38,27 +38,27 @@ export function registerOptionsMarketKlines(server: McpServer) { ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Klines - ${params.symbol} (${params.interval})\n\n` + let result = `✅ Klines - ${params.symbol} (${params.interval})\n\n`; if (Array.isArray(data) && data.length > 0) { - result += `Total candles: ${data.length}\n\n` - result += `| Open Time | Open | High | Low | Close | Volume |\n` - result += `|-----------|------|------|-----|-------|--------|\n` + result += `Total candles: ${data.length}\n\n`; + result += `| Open Time | Open | High | Low | Close | Volume |\n`; + result += `|-----------|------|------|-----|-------|--------|\n`; data.slice(-10).forEach((kline: any) => { - const openTime = new Date(kline[0]).toISOString().slice(0, 16) - result += `| ${openTime} | ${kline[1]} | ${kline[2]} | ${kline[3]} | ${kline[4]} | ${kline[5]} |\n` - }) + const openTime = new Date(kline[0]).toISOString().slice(0, 16); + result += `| ${openTime} | ${kline[1]} | ${kline[2]} | ${kline[3]} | ${kline[4]} | ${kline[5]} |\n`; + }); if (data.length > 10) { - result += `\nShowing last 10 of ${data.length} candles` + result += `\nShowing last 10 of ${data.length} candles`; } } else { - result += `No kline data found` + result += `No kline data found`; } return { @@ -68,9 +68,9 @@ export function registerOptionsMarketKlines(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -80,8 +80,8 @@ export function registerOptionsMarketKlines(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/options/market-api/mark.ts b/src/modules/options/market-api/mark.ts index 0f384050..360d6e62 100644 --- a/src/modules/options/market-api/mark.ts +++ b/src/modules/options/market-api/mark.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/options/market-api/mark.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../../config/binanceClient.js" +import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsMarketMark(server: McpServer) { server.tool( @@ -27,32 +27,32 @@ export function registerOptionsMarketMark(server: McpServer) { try { const response = await optionsClient.restAPI.mark({ ...(params.symbol && { symbol: params.symbol }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Options Mark Prices\n\n` + let result = `✅ Options Mark Prices\n\n`; if (Array.isArray(data)) { - result += `Total contracts: ${data.length}\n\n` + result += `Total contracts: ${data.length}\n\n`; data.slice(0, 20).forEach((item: any) => { - result += `**${item.symbol}**\n` - result += ` Mark Price: ${item.markPrice}\n` - result += ` Bid IV: ${item.bidIV} | Ask IV: ${item.askIV}\n` - result += ` Mark IV: ${item.markIV}\n` - result += ` Delta: ${item.delta} | Theta: ${item.theta}\n` - result += ` Gamma: ${item.gamma} | Vega: ${item.vega}\n\n` - }) + result += `**${item.symbol}**\n`; + result += ` Mark Price: ${item.markPrice}\n`; + result += ` Bid IV: ${item.bidIV} | Ask IV: ${item.askIV}\n`; + result += ` Mark IV: ${item.markIV}\n`; + result += ` Delta: ${item.delta} | Theta: ${item.theta}\n`; + result += ` Gamma: ${item.gamma} | Vega: ${item.vega}\n\n`; + }); if (data.length > 20) { - result += `... and ${data.length - 20} more contracts` + result += `... and ${data.length - 20} more contracts`; } } else if (data) { - result += `**${data.symbol}**\n` - result += `Mark Price: ${data.markPrice}\n` - result += `Bid IV: ${data.bidIV} | Ask IV: ${data.askIV}\n` - result += `Mark IV: ${data.markIV}\n` - result += `Delta: ${data.delta} | Theta: ${data.theta}\n` - result += `Gamma: ${data.gamma} | Vega: ${data.vega}\n` + result += `**${data.symbol}**\n`; + result += `Mark Price: ${data.markPrice}\n`; + result += `Bid IV: ${data.bidIV} | Ask IV: ${data.askIV}\n`; + result += `Mark IV: ${data.markIV}\n`; + result += `Delta: ${data.delta} | Theta: ${data.theta}\n`; + result += `Gamma: ${data.gamma} | Vega: ${data.vega}\n`; } return { @@ -62,9 +62,9 @@ export function registerOptionsMarketMark(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -74,8 +74,8 @@ export function registerOptionsMarketMark(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/options/market-api/ping.ts b/src/modules/options/market-api/ping.ts index 4372ced6..bbd5a58d 100644 --- a/src/modules/options/market-api/ping.ts +++ b/src/modules/options/market-api/ping.ts @@ -5,9 +5,9 @@ * @license Apache-2.0 */ // src/modules/options/market-api/ping.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js" +import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsMarketPing(server: McpServer) { server.tool( @@ -16,8 +16,8 @@ export function registerOptionsMarketPing(server: McpServer) { {}, async () => { try { - const response = await optionsClient.restAPI.ping() - const data = await response.data() + const response = await optionsClient.restAPI.ping(); + const data = await response.data(); return { content: [ @@ -26,9 +26,9 @@ export function registerOptionsMarketPing(server: McpServer) { text: `✅ Options API connectivity test successful!\n\nResponse: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -38,8 +38,8 @@ export function registerOptionsMarketPing(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/options/market-api/ticker.ts b/src/modules/options/market-api/ticker.ts index e60c86d7..f36445c0 100644 --- a/src/modules/options/market-api/ticker.ts +++ b/src/modules/options/market-api/ticker.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/options/market-api/ticker.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../../config/binanceClient.js" +import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsMarketTicker(server: McpServer) { server.tool( @@ -27,34 +27,34 @@ export function registerOptionsMarketTicker(server: McpServer) { try { const response = await optionsClient.restAPI.ticker({ ...(params.symbol && { symbol: params.symbol }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Options 24hr Ticker Statistics\n\n` + let result = `✅ Options 24hr Ticker Statistics\n\n`; const formatTicker = (ticker: any) => { - let str = `**${ticker.symbol}**\n` - str += ` Price Change: ${ticker.priceChange} (${ticker.priceChangePercent}%)\n` - str += ` Last Price: ${ticker.lastPrice}\n` - str += ` High: ${ticker.high} | Low: ${ticker.low}\n` - str += ` Volume: ${ticker.volume}\n` - str += ` Quote Volume: ${ticker.quoteVolume}\n` - str += ` Open Interest: ${ticker.openInterest}\n` + let str = `**${ticker.symbol}**\n`; + str += ` Price Change: ${ticker.priceChange} (${ticker.priceChangePercent}%)\n`; + str += ` Last Price: ${ticker.lastPrice}\n`; + str += ` High: ${ticker.high} | Low: ${ticker.low}\n`; + str += ` Volume: ${ticker.volume}\n`; + str += ` Quote Volume: ${ticker.quoteVolume}\n`; + str += ` Open Interest: ${ticker.openInterest}\n`; - return str - } + return str; + }; if (Array.isArray(data)) { - result += `Total contracts: ${data.length}\n\n` + result += `Total contracts: ${data.length}\n\n`; data.slice(0, 15).forEach((ticker: any) => { - result += formatTicker(ticker) + "\n" - }) + result += formatTicker(ticker) + "\n"; + }); if (data.length > 15) { - result += `... and ${data.length - 15} more contracts` + result += `... and ${data.length - 15} more contracts`; } } else if (data) { - result += formatTicker(data) + result += formatTicker(data); } return { @@ -64,9 +64,9 @@ export function registerOptionsMarketTicker(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -76,8 +76,8 @@ export function registerOptionsMarketTicker(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/options/market-api/time.ts b/src/modules/options/market-api/time.ts index fcacecce..76337b9d 100644 --- a/src/modules/options/market-api/time.ts +++ b/src/modules/options/market-api/time.ts @@ -5,9 +5,9 @@ * @license Apache-2.0 */ // src/modules/options/market-api/time.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js" +import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsMarketTime(server: McpServer) { server.tool( @@ -16,10 +16,10 @@ export function registerOptionsMarketTime(server: McpServer) { {}, async () => { try { - const response = await optionsClient.restAPI.time() - const data = await response.data() + const response = await optionsClient.restAPI.time(); + const data = await response.data(); - const serverTime = new Date(data.serverTime).toISOString() + const serverTime = new Date(data.serverTime).toISOString(); return { content: [ @@ -28,9 +28,9 @@ export function registerOptionsMarketTime(server: McpServer) { text: `✅ Options Server Time\n\nTimestamp: ${data.serverTime}\nUTC: ${serverTime}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -40,8 +40,8 @@ export function registerOptionsMarketTime(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/options/market-api/trades.ts b/src/modules/options/market-api/trades.ts index 17f88219..cc9b2fd4 100644 --- a/src/modules/options/market-api/trades.ts +++ b/src/modules/options/market-api/trades.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/options/market-api/trades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../../config/binanceClient.js" +import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsMarketTrades(server: McpServer) { server.tool( @@ -30,23 +30,23 @@ export function registerOptionsMarketTrades(server: McpServer) { const response = await optionsClient.restAPI.trades({ symbol: params.symbol, ...(params.limit && { limit: params.limit }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Recent Trades - ${params.symbol}\n\n` + let result = `✅ Recent Trades - ${params.symbol}\n\n`; if (Array.isArray(data) && data.length > 0) { - result += `Total trades returned: ${data.length}\n\n` + result += `Total trades returned: ${data.length}\n\n`; data.slice(0, 20).forEach((trade: any, index: number) => { - const time = new Date(trade.time).toISOString() - result += `${index + 1}. Price: ${trade.price} | Qty: ${trade.qty} | Time: ${time}\n` - }) + const time = new Date(trade.time).toISOString(); + result += `${index + 1}. Price: ${trade.price} | Qty: ${trade.qty} | Time: ${time}\n`; + }); if (data.length > 20) { - result += `\n... and ${data.length - 20} more trades` + result += `\n... and ${data.length - 20} more trades`; } } else { - result += `No recent trades found` + result += `No recent trades found`; } return { @@ -56,9 +56,9 @@ export function registerOptionsMarketTrades(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -68,8 +68,8 @@ export function registerOptionsMarketTrades(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/options/trade-api/batchOrders.ts b/src/modules/options/trade-api/batchOrders.ts index a19dccb9..a1cd1bf7 100644 --- a/src/modules/options/trade-api/batchOrders.ts +++ b/src/modules/options/trade-api/batchOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/options/trade-api/batchOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../../config/binanceClient.js" +import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsBatchOrders(server: McpServer) { server.tool( @@ -40,25 +40,25 @@ export function registerOptionsBatchOrders(server: McpServer) { const response = await optionsClient.restAPI.batchOrders({ orders: JSON.stringify(params.orders), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Batch Options Orders Placed\n\n` + let result = `✅ Batch Options Orders Placed\n\n`; if (Array.isArray(data)) { data.forEach((order: any, index: number) => { if (order.orderId) { - result += `Order ${index + 1}: ✅ Success\n` - result += ` Order ID: ${order.orderId}\n` - result += ` Symbol: ${order.symbol}\n` - result += ` Side: ${order.side} | Qty: ${order.quantity}\n` - result += ` Price: ${order.price} | Status: ${order.status}\n\n` + result += `Order ${index + 1}: ✅ Success\n`; + result += ` Order ID: ${order.orderId}\n`; + result += ` Symbol: ${order.symbol}\n`; + result += ` Side: ${order.side} | Qty: ${order.quantity}\n`; + result += ` Price: ${order.price} | Status: ${order.status}\n\n`; } else { - result += `Order ${index + 1}: ❌ Failed\n` - result += ` Error: ${order.msg || "Unknown error"}\n\n` + result += `Order ${index + 1}: ❌ Failed\n`; + result += ` Error: ${order.msg || "Unknown error"}\n\n`; } - }) + }); } return { @@ -68,9 +68,9 @@ export function registerOptionsBatchOrders(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -80,8 +80,8 @@ export function registerOptionsBatchOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/options/trade-api/cancelAllOrders.ts b/src/modules/options/trade-api/cancelAllOrders.ts index 639b8ed6..cd6489d3 100644 --- a/src/modules/options/trade-api/cancelAllOrders.ts +++ b/src/modules/options/trade-api/cancelAllOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/options/trade-api/cancelAllOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../../config/binanceClient.js" +import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsCancelAllOrders(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerOptionsCancelAllOrders(server: McpServer) { const response = await optionsClient.restAPI.cancelAllOpenOrders({ symbol: params.symbol, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,9 +35,9 @@ export function registerOptionsCancelAllOrders(server: McpServer) { text: `✅ All open orders cancelled for ${params.symbol}\n\nResponse: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -47,8 +47,8 @@ export function registerOptionsCancelAllOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/options/trade-api/cancelBatchOrders.ts b/src/modules/options/trade-api/cancelBatchOrders.ts index 0cf7ad44..eff4472d 100644 --- a/src/modules/options/trade-api/cancelBatchOrders.ts +++ b/src/modules/options/trade-api/cancelBatchOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/options/trade-api/cancelBatchOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../../config/binanceClient.js" +import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsCancelBatchOrders(server: McpServer) { server.tool( @@ -38,7 +38,7 @@ export function registerOptionsCancelBatchOrders(server: McpServer) { }, ], isError: true, - } + }; } const response = await optionsClient.restAPI.cancelBatchOrders({ @@ -46,24 +46,24 @@ export function registerOptionsCancelBatchOrders(server: McpServer) { ...(params.orderIds && { orderIds: JSON.stringify(params.orderIds) }), ...(params.clientOrderIds && { clientOrderIds: JSON.stringify(params.clientOrderIds) }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Batch Options Orders Cancelled\n\n` + let result = `✅ Batch Options Orders Cancelled\n\n`; if (Array.isArray(data)) { data.forEach((order: any, index: number) => { if (order.orderId && !order.code) { - result += `Order ${index + 1}: ✅ Cancelled\n` - result += ` Order ID: ${order.orderId}\n` - result += ` Symbol: ${order.symbol}\n` - result += ` Status: ${order.status}\n\n` + result += `Order ${index + 1}: ✅ Cancelled\n`; + result += ` Order ID: ${order.orderId}\n`; + result += ` Symbol: ${order.symbol}\n`; + result += ` Status: ${order.status}\n\n`; } else { - result += `Order ${index + 1}: ❌ Failed\n` - result += ` Error: ${order.msg || "Unknown error"}\n\n` + result += `Order ${index + 1}: ❌ Failed\n`; + result += ` Error: ${order.msg || "Unknown error"}\n\n`; } - }) + }); } return { @@ -73,9 +73,9 @@ export function registerOptionsCancelBatchOrders(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -85,8 +85,8 @@ export function registerOptionsCancelBatchOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/options/trade-api/cancelBySymbol.ts b/src/modules/options/trade-api/cancelBySymbol.ts index 9e7ea442..a9983c94 100644 --- a/src/modules/options/trade-api/cancelBySymbol.ts +++ b/src/modules/options/trade-api/cancelBySymbol.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/options/trade-api/cancelBySymbol.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../../config/binanceClient.js" +import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsCancelBySymbol(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerOptionsCancelBySymbol(server: McpServer) { const response = await optionsClient.restAPI.cancelAllOpenOrdersByUnderlying({ underlying: params.underlying, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,9 +35,9 @@ export function registerOptionsCancelBySymbol(server: McpServer) { text: `✅ All open orders cancelled for underlying ${params.underlying}\n\nResponse: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -47,8 +47,8 @@ export function registerOptionsCancelBySymbol(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/options/trade-api/cancelOrder.ts b/src/modules/options/trade-api/cancelOrder.ts index 5a913a6a..70aa7357 100644 --- a/src/modules/options/trade-api/cancelOrder.ts +++ b/src/modules/options/trade-api/cancelOrder.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/options/trade-api/cancelOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../../config/binanceClient.js" +import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsCancelOrder(server: McpServer) { server.tool( @@ -32,7 +32,7 @@ export function registerOptionsCancelOrder(server: McpServer) { }, ], isError: true, - } + }; } const response = await optionsClient.restAPI.cancelOrder({ @@ -40,9 +40,9 @@ export function registerOptionsCancelOrder(server: McpServer) { ...(params.orderId && { orderId: params.orderId }), ...(params.clientOrderId && { clientOrderId: params.clientOrderId }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -51,9 +51,9 @@ export function registerOptionsCancelOrder(server: McpServer) { text: `✅ Options order cancelled!\n\nOrder ID: ${data.orderId}\nSymbol: ${data.symbol}\nSide: ${data.side}\nQuantity: ${data.quantity}\nPrice: ${data.price}\nStatus: ${data.status}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -63,8 +63,8 @@ export function registerOptionsCancelOrder(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/options/trade-api/getHistoryOrders.ts b/src/modules/options/trade-api/getHistoryOrders.ts index e33363f0..825ffe76 100644 --- a/src/modules/options/trade-api/getHistoryOrders.ts +++ b/src/modules/options/trade-api/getHistoryOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/options/trade-api/getHistoryOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../../config/binanceClient.js" +import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsGetHistoryOrders(server: McpServer) { server.tool( @@ -38,28 +38,28 @@ export function registerOptionsGetHistoryOrders(server: McpServer) { ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Options Order History - ${params.symbol}\n\n` + let result = `✅ Options Order History - ${params.symbol}\n\n`; if (Array.isArray(data) && data.length > 0) { - result += `Total orders: ${data.length}\n\n` + result += `Total orders: ${data.length}\n\n`; data.slice(0, 20).forEach((order: any, index: number) => { - result += `**${index + 1}. Order ID: ${order.orderId}**\n` - result += ` Side: ${order.side} | Type: ${order.type}\n` - result += ` Price: ${order.price} | Qty: ${order.quantity}\n` - result += ` Executed Qty: ${order.executedQty}\n` - result += ` Avg Price: ${order.avgPrice}\n` - result += ` Status: ${order.status}\n` - result += ` Time: ${new Date(order.createTime).toISOString()}\n\n` - }) + result += `**${index + 1}. Order ID: ${order.orderId}**\n`; + result += ` Side: ${order.side} | Type: ${order.type}\n`; + result += ` Price: ${order.price} | Qty: ${order.quantity}\n`; + result += ` Executed Qty: ${order.executedQty}\n`; + result += ` Avg Price: ${order.avgPrice}\n`; + result += ` Status: ${order.status}\n`; + result += ` Time: ${new Date(order.createTime).toISOString()}\n\n`; + }); if (data.length > 20) { - result += `... and ${data.length - 20} more orders` + result += `... and ${data.length - 20} more orders`; } } else { - result += `No historical orders found` + result += `No historical orders found`; } return { @@ -69,9 +69,9 @@ export function registerOptionsGetHistoryOrders(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -81,8 +81,8 @@ export function registerOptionsGetHistoryOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/options/trade-api/getOpenOrders.ts b/src/modules/options/trade-api/getOpenOrders.ts index 908cad82..3e6d834d 100644 --- a/src/modules/options/trade-api/getOpenOrders.ts +++ b/src/modules/options/trade-api/getOpenOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/options/trade-api/getOpenOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../../config/binanceClient.js" +import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsGetOpenOrders(server: McpServer) { server.tool( @@ -26,25 +26,25 @@ export function registerOptionsGetOpenOrders(server: McpServer) { ...(params.symbol && { symbol: params.symbol }), ...(params.underlying && { underlying: params.underlying }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Open Options Orders\n\n` + let result = `✅ Open Options Orders\n\n`; if (Array.isArray(data) && data.length > 0) { - result += `Total open orders: ${data.length}\n\n` + result += `Total open orders: ${data.length}\n\n`; data.forEach((order: any, index: number) => { - result += `**${index + 1}. ${order.symbol}**\n` - result += ` Order ID: ${order.orderId}\n` - result += ` Side: ${order.side} | Type: ${order.type}\n` - result += ` Price: ${order.price} | Qty: ${order.quantity}\n` - result += ` Executed Qty: ${order.executedQty}\n` - result += ` Status: ${order.status}\n` - result += ` Time: ${new Date(order.createTime).toISOString()}\n\n` - }) + result += `**${index + 1}. ${order.symbol}**\n`; + result += ` Order ID: ${order.orderId}\n`; + result += ` Side: ${order.side} | Type: ${order.type}\n`; + result += ` Price: ${order.price} | Qty: ${order.quantity}\n`; + result += ` Executed Qty: ${order.executedQty}\n`; + result += ` Status: ${order.status}\n`; + result += ` Time: ${new Date(order.createTime).toISOString()}\n\n`; + }); } else { - result += `No open orders found` + result += `No open orders found`; } return { @@ -54,9 +54,9 @@ export function registerOptionsGetOpenOrders(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -66,8 +66,8 @@ export function registerOptionsGetOpenOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/options/trade-api/getUserTrades.ts b/src/modules/options/trade-api/getUserTrades.ts index cb967d00..e59e46cc 100644 --- a/src/modules/options/trade-api/getUserTrades.ts +++ b/src/modules/options/trade-api/getUserTrades.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/options/trade-api/getUserTrades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../../config/binanceClient.js" +import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsGetUserTrades(server: McpServer) { server.tool( @@ -40,29 +40,29 @@ export function registerOptionsGetUserTrades(server: McpServer) { ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Options Trade History\n\n` + let result = `✅ Options Trade History\n\n`; if (Array.isArray(data) && data.length > 0) { - result += `Total trades: ${data.length}\n\n` + result += `Total trades: ${data.length}\n\n`; data.slice(0, 20).forEach((trade: any, index: number) => { - result += `**${index + 1}. ${trade.symbol}**\n` - result += ` Trade ID: ${trade.id}\n` - result += ` Order ID: ${trade.orderId}\n` - result += ` Side: ${trade.side}\n` - result += ` Price: ${trade.price} | Qty: ${trade.quantity}\n` - result += ` Fee: ${trade.fee} ${trade.feeAsset}\n` - result += ` Realized PnL: ${trade.realizedProfit}\n` - result += ` Time: ${new Date(trade.time).toISOString()}\n\n` - }) + result += `**${index + 1}. ${trade.symbol}**\n`; + result += ` Trade ID: ${trade.id}\n`; + result += ` Order ID: ${trade.orderId}\n`; + result += ` Side: ${trade.side}\n`; + result += ` Price: ${trade.price} | Qty: ${trade.quantity}\n`; + result += ` Fee: ${trade.fee} ${trade.feeAsset}\n`; + result += ` Realized PnL: ${trade.realizedProfit}\n`; + result += ` Time: ${new Date(trade.time).toISOString()}\n\n`; + }); if (data.length > 20) { - result += `... and ${data.length - 20} more trades` + result += `... and ${data.length - 20} more trades`; } } else { - result += `No trades found` + result += `No trades found`; } return { @@ -72,9 +72,9 @@ export function registerOptionsGetUserTrades(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -84,8 +84,8 @@ export function registerOptionsGetUserTrades(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/options/trade-api/index.ts b/src/modules/options/trade-api/index.ts index a3f52f02..aa3200a0 100644 --- a/src/modules/options/trade-api/index.ts +++ b/src/modules/options/trade-api/index.ts @@ -5,26 +5,26 @@ * @license Apache-2.0 */ // src/modules/options/trade-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerOptionsBatchOrders } from "./batchOrders.js" -import { registerOptionsCancelAllOrders } from "./cancelAllOrders.js" -import { registerOptionsCancelBatchOrders } from "./cancelBatchOrders.js" -import { registerOptionsCancelBySymbol } from "./cancelBySymbol.js" -import { registerOptionsCancelOrder } from "./cancelOrder.js" -import { registerOptionsGetHistoryOrders } from "./getHistoryOrders.js" -import { registerOptionsGetOpenOrders } from "./getOpenOrders.js" -import { registerOptionsGetUserTrades } from "./getUserTrades.js" -import { registerOptionsNewOrder } from "./newOrder.js" +import { registerOptionsBatchOrders } from "./batchOrders.js"; +import { registerOptionsCancelAllOrders } from "./cancelAllOrders.js"; +import { registerOptionsCancelBatchOrders } from "./cancelBatchOrders.js"; +import { registerOptionsCancelBySymbol } from "./cancelBySymbol.js"; +import { registerOptionsCancelOrder } from "./cancelOrder.js"; +import { registerOptionsGetHistoryOrders } from "./getHistoryOrders.js"; +import { registerOptionsGetOpenOrders } from "./getOpenOrders.js"; +import { registerOptionsGetUserTrades } from "./getUserTrades.js"; +import { registerOptionsNewOrder } from "./newOrder.js"; export function registerOptionsTradeApi(server: McpServer) { - registerOptionsNewOrder(server) - registerOptionsBatchOrders(server) - registerOptionsCancelOrder(server) - registerOptionsCancelBatchOrders(server) - registerOptionsCancelAllOrders(server) - registerOptionsCancelBySymbol(server) - registerOptionsGetOpenOrders(server) - registerOptionsGetHistoryOrders(server) - registerOptionsGetUserTrades(server) + registerOptionsNewOrder(server); + registerOptionsBatchOrders(server); + registerOptionsCancelOrder(server); + registerOptionsCancelBatchOrders(server); + registerOptionsCancelAllOrders(server); + registerOptionsCancelBySymbol(server); + registerOptionsGetOpenOrders(server); + registerOptionsGetHistoryOrders(server); + registerOptionsGetUserTrades(server); } diff --git a/src/modules/options/trade-api/newOrder.ts b/src/modules/options/trade-api/newOrder.ts index 1ba6f341..4a5512e2 100644 --- a/src/modules/options/trade-api/newOrder.ts +++ b/src/modules/options/trade-api/newOrder.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/options/trade-api/newOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../../config/binanceClient.js" +import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsNewOrder(server: McpServer) { server.tool( @@ -45,9 +45,9 @@ export function registerOptionsNewOrder(server: McpServer) { ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), ...(params.isMmp !== undefined && { isMmp: params.isMmp }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -56,9 +56,9 @@ export function registerOptionsNewOrder(server: McpServer) { text: `✅ Options order placed!\n\nOrder ID: ${data.orderId}\nSymbol: ${data.symbol}\nSide: ${data.side}\nType: ${data.type}\nQuantity: ${data.quantity}\nPrice: ${data.price}\nStatus: ${data.status}\nClient Order ID: ${data.clientOrderId || "N/A"}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -68,8 +68,8 @@ export function registerOptionsNewOrder(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/options/userdata-api/createListenKey.ts b/src/modules/options/userdata-api/createListenKey.ts index 6d6ca2b8..e722ad36 100644 --- a/src/modules/options/userdata-api/createListenKey.ts +++ b/src/modules/options/userdata-api/createListenKey.ts @@ -5,9 +5,9 @@ * @license Apache-2.0 */ // src/modules/options/userdata-api/createListenKey.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../../config/binanceClient.js" +import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsCreateListenKey(server: McpServer) { server.tool( @@ -16,8 +16,8 @@ export function registerOptionsCreateListenKey(server: McpServer) { {}, async () => { try { - const response = await optionsClient.restAPI.createListenKey() - const data = await response.data() + const response = await optionsClient.restAPI.createListenKey(); + const data = await response.data(); return { content: [ @@ -26,9 +26,9 @@ export function registerOptionsCreateListenKey(server: McpServer) { text: `✅ Options Listen Key Created\n\nListen Key: ${data.listenKey}\n\n**Note**: This listen key is valid for 60 minutes. Use BinanceOptionsRenewListenKey to extend validity. Use this key to connect to the WebSocket user data stream.`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -38,8 +38,8 @@ export function registerOptionsCreateListenKey(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/options/userdata-api/deleteListenKey.ts b/src/modules/options/userdata-api/deleteListenKey.ts index 18b2b0b4..9fab2770 100644 --- a/src/modules/options/userdata-api/deleteListenKey.ts +++ b/src/modules/options/userdata-api/deleteListenKey.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/options/userdata-api/deleteListenKey.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../../config/binanceClient.js" +import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsDeleteListenKey(server: McpServer) { server.tool( @@ -25,8 +25,8 @@ export function registerOptionsDeleteListenKey(server: McpServer) { try { const response = await optionsClient.restAPI.deleteListenKey({ ...(params.listenKey && { listenKey: params.listenKey }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -35,9 +35,9 @@ export function registerOptionsDeleteListenKey(server: McpServer) { text: `✅ Options Listen Key Deleted\n\nThe listen key has been invalidated and the user data stream will be closed.\n\nResponse: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -47,8 +47,8 @@ export function registerOptionsDeleteListenKey(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/options/userdata-api/index.ts b/src/modules/options/userdata-api/index.ts index 66faf721..baa10558 100644 --- a/src/modules/options/userdata-api/index.ts +++ b/src/modules/options/userdata-api/index.ts @@ -5,14 +5,14 @@ * @license Apache-2.0 */ // src/modules/options/userdata-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerOptionsCreateListenKey } from "./createListenKey.js" -import { registerOptionsDeleteListenKey } from "./deleteListenKey.js" -import { registerOptionsRenewListenKey } from "./renewListenKey.js" +import { registerOptionsCreateListenKey } from "./createListenKey.js"; +import { registerOptionsDeleteListenKey } from "./deleteListenKey.js"; +import { registerOptionsRenewListenKey } from "./renewListenKey.js"; export function registerOptionsUserdataApi(server: McpServer) { - registerOptionsCreateListenKey(server) - registerOptionsRenewListenKey(server) - registerOptionsDeleteListenKey(server) + registerOptionsCreateListenKey(server); + registerOptionsRenewListenKey(server); + registerOptionsDeleteListenKey(server); } diff --git a/src/modules/options/userdata-api/renewListenKey.ts b/src/modules/options/userdata-api/renewListenKey.ts index da60776d..d78e408b 100644 --- a/src/modules/options/userdata-api/renewListenKey.ts +++ b/src/modules/options/userdata-api/renewListenKey.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/options/userdata-api/renewListenKey.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../../config/binanceClient.js" +import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsRenewListenKey(server: McpServer) { server.tool( @@ -25,8 +25,8 @@ export function registerOptionsRenewListenKey(server: McpServer) { try { const response = await optionsClient.restAPI.renewListenKey({ ...(params.listenKey && { listenKey: params.listenKey }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -35,9 +35,9 @@ export function registerOptionsRenewListenKey(server: McpServer) { text: `✅ Options Listen Key Renewed\n\nThe listen key validity has been extended by 60 minutes.\n\nResponse: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -47,8 +47,8 @@ export function registerOptionsRenewListenKey(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/pay/index.ts b/src/modules/pay/index.ts index e6dbf79d..9a791d5a 100644 --- a/src/modules/pay/index.ts +++ b/src/modules/pay/index.ts @@ -1,11 +1,11 @@ // src/tools/binance-pay/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetPayTradeHistory } from "./pay-api/getPayTradeHistory.js" +import { registerBinanceGetPayTradeHistory } from "./pay-api/getPayTradeHistory.js"; export function registerBinancePayTools(server: McpServer) { - registerBinanceGetPayTradeHistory(server) + registerBinanceGetPayTradeHistory(server); } // Alias for binance.ts compatibility -export { registerBinancePayTools as registerPay } +export { registerBinancePayTools as registerPay }; diff --git a/src/modules/pay/pay-api/createOrder.ts b/src/modules/pay/pay-api/createOrder.ts index 0d21f44a..dd5f7ddf 100644 --- a/src/modules/pay/pay-api/createOrder.ts +++ b/src/modules/pay/pay-api/createOrder.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/pay/pay-api/createOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { payClient } from "../../../config/binanceClient.js" +import { payClient } from "../../../config/binanceClient.js"; export function registerBinancePayCreateOrder(server: McpServer) { server.tool( @@ -36,9 +36,9 @@ export function registerBinancePayCreateOrder(server: McpServer) { ...(params.goodsName && { goodsName: params.goodsName }), ...(params.goodsDetail && { goodsDetail: params.goodsDetail }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -47,9 +47,9 @@ export function registerBinancePayCreateOrder(server: McpServer) { text: `✅ Binance Pay Order Created!\n\nOrder ID: ${params.orderId}\nCurrency: ${params.currency}\nAmount: ${params.totalAmount}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -59,8 +59,8 @@ export function registerBinancePayCreateOrder(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/pay/pay-api/getHistory.ts b/src/modules/pay/pay-api/getHistory.ts index 3cbc01df..b2f17e42 100644 --- a/src/modules/pay/pay-api/getHistory.ts +++ b/src/modules/pay/pay-api/getHistory.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/pay/pay-api/getHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { payClient } from "../../../config/binanceClient.js" +import { payClient } from "../../../config/binanceClient.js"; export function registerBinancePayGetHistory(server: McpServer) { server.tool( @@ -34,9 +34,9 @@ export function registerBinancePayGetHistory(server: McpServer) { ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -45,9 +45,9 @@ export function registerBinancePayGetHistory(server: McpServer) { text: `📜 Binance Pay Transaction History\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -57,8 +57,8 @@ export function registerBinancePayGetHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/pay/pay-api/getPayTradeHistory.ts b/src/modules/pay/pay-api/getPayTradeHistory.ts index e55a6c73..479cd14d 100644 --- a/src/modules/pay/pay-api/getPayTradeHistory.ts +++ b/src/modules/pay/pay-api/getPayTradeHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-pay/pay-api/getPayTradeHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { payClient } from "../../../config/binanceClient.js" +import { payClient } from "../../../config/binanceClient.js"; export function registerBinanceGetPayTradeHistory(server: McpServer) { server.tool( @@ -27,9 +27,9 @@ export function registerBinanceGetPayTradeHistory(server: McpServer) { ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -38,9 +38,9 @@ export function registerBinanceGetPayTradeHistory(server: McpServer) { text: `Successfully retrieved Binance Pay trade history. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -50,8 +50,8 @@ export function registerBinanceGetPayTradeHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/pay/pay-api/queryOrder.ts b/src/modules/pay/pay-api/queryOrder.ts index bb67e9a5..bf9fd4b0 100644 --- a/src/modules/pay/pay-api/queryOrder.ts +++ b/src/modules/pay/pay-api/queryOrder.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/pay/pay-api/queryOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { payClient } from "../../../config/binanceClient.js" +import { payClient } from "../../../config/binanceClient.js"; export function registerBinancePayQueryOrder(server: McpServer) { server.tool( @@ -28,9 +28,9 @@ export function registerBinancePayQueryOrder(server: McpServer) { ...(params.prepayId && { prepayId: params.prepayId }), ...(params.merchantTradeNo && { merchantTradeNo: params.merchantTradeNo }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -39,9 +39,9 @@ export function registerBinancePayQueryOrder(server: McpServer) { text: `📋 Binance Pay Order Status\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -51,8 +51,8 @@ export function registerBinancePayQueryOrder(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/account/getAccountInfo.ts b/src/modules/portfolio-margin/account/getAccountInfo.ts index a6232191..85928852 100644 --- a/src/modules/portfolio-margin/account/getAccountInfo.ts +++ b/src/modules/portfolio-margin/account/getAccountInfo.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/account/getAccountInfo.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginGetAccountInfo(server: McpServer) { server.tool( @@ -22,22 +22,22 @@ export function registerPortfolioMarginGetAccountInfo(server: McpServer) { try { const response = await portfolioMarginClient.restAPI.account({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Portfolio Margin Account Information\n\n` + let result = `✅ Portfolio Margin Account Information\n\n`; if (data) { - result += `**Account Status**\n` - result += `UniMMR: ${data.uniMMR}\n` - result += `Account Equity: ${data.accountEquity}\n` - result += `Actual Equity: ${data.actualEquity}\n` - result += `Account Maint. Margin: ${data.accountMaintMargin}\n` - result += `Account Status: ${data.accountStatus}\n\n` + result += `**Account Status**\n`; + result += `UniMMR: ${data.uniMMR}\n`; + result += `Account Equity: ${data.accountEquity}\n`; + result += `Actual Equity: ${data.actualEquity}\n`; + result += `Account Maint. Margin: ${data.accountMaintMargin}\n`; + result += `Account Status: ${data.accountStatus}\n\n`; if (data.accountType) { - result += `Account Type: ${data.accountType}\n` + result += `Account Type: ${data.accountType}\n`; } } @@ -48,9 +48,9 @@ export function registerPortfolioMarginGetAccountInfo(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -60,8 +60,8 @@ export function registerPortfolioMarginGetAccountInfo(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/account/getBalance.ts b/src/modules/portfolio-margin/account/getBalance.ts index 0f9597af..cdf2c075 100644 --- a/src/modules/portfolio-margin/account/getBalance.ts +++ b/src/modules/portfolio-margin/account/getBalance.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/account/getBalance.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginGetBalance(server: McpServer) { server.tool( @@ -27,25 +27,25 @@ export function registerPortfolioMarginGetBalance(server: McpServer) { const response = await portfolioMarginClient.restAPI.balance({ ...(params.asset && { asset: params.asset }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Portfolio Margin Balance\n\n` + let result = `✅ Portfolio Margin Balance\n\n`; if (Array.isArray(data) && data.length > 0) { - result += `| Asset | Total | Available | In Order | Borrowed |\n` - result += `|-------|-------|-----------|----------|----------|\n` + result += `| Asset | Total | Available | In Order | Borrowed |\n`; + result += `|-------|-------|-----------|----------|----------|\n`; data.forEach((balance: any) => { - result += `| ${balance.asset} | ${balance.totalWalletBalance || balance.balance} | ${balance.availableBalance || "N/A"} | ${balance.crossWalletBalance || "N/A"} | ${balance.borrowed || "0"} |\n` - }) + result += `| ${balance.asset} | ${balance.totalWalletBalance || balance.balance} | ${balance.availableBalance || "N/A"} | ${balance.crossWalletBalance || "N/A"} | ${balance.borrowed || "0"} |\n`; + }); } else if (data && !Array.isArray(data)) { - result += `**${data.asset}**\n` - result += `Total Balance: ${data.totalWalletBalance || data.balance}\n` - result += `Available: ${data.availableBalance || "N/A"}\n` - result += `Borrowed: ${data.borrowed || "0"}\n` + result += `**${data.asset}**\n`; + result += `Total Balance: ${data.totalWalletBalance || data.balance}\n`; + result += `Available: ${data.availableBalance || "N/A"}\n`; + result += `Borrowed: ${data.borrowed || "0"}\n`; } else { - result += `No balance information found` + result += `No balance information found`; } return { @@ -55,9 +55,9 @@ export function registerPortfolioMarginGetBalance(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -67,8 +67,8 @@ export function registerPortfolioMarginGetBalance(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/account/getCmAccount.ts b/src/modules/portfolio-margin/account/getCmAccount.ts index 5ab2f909..841becbf 100644 --- a/src/modules/portfolio-margin/account/getCmAccount.ts +++ b/src/modules/portfolio-margin/account/getCmAccount.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/account/getCmAccount.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginGetCmAccount(server: McpServer) { server.tool( @@ -22,33 +22,33 @@ export function registerPortfolioMarginGetCmAccount(server: McpServer) { try { const response = await portfolioMarginClient.restAPI.cmAccount({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Portfolio Margin CM (COIN-M) Account\n\n` + let result = `✅ Portfolio Margin CM (COIN-M) Account\n\n`; if (data) { - result += `**Account Overview**\n` + result += `**Account Overview**\n`; if (data.assets && data.assets.length > 0) { - result += `\n**Assets**\n` + result += `\n**Assets**\n`; data.assets.forEach((asset: any) => { - result += `**${asset.asset}**\n` - result += ` Wallet Balance: ${asset.walletBalance}\n` - result += ` Unrealized Profit: ${asset.unrealizedProfit}\n` - result += ` Margin Balance: ${asset.marginBalance}\n` - result += ` Maint Margin: ${asset.maintMargin}\n` - result += ` Available Balance: ${asset.availableBalance}\n\n` - }) + result += `**${asset.asset}**\n`; + result += ` Wallet Balance: ${asset.walletBalance}\n`; + result += ` Unrealized Profit: ${asset.unrealizedProfit}\n`; + result += ` Margin Balance: ${asset.marginBalance}\n`; + result += ` Maint Margin: ${asset.maintMargin}\n`; + result += ` Available Balance: ${asset.availableBalance}\n\n`; + }); } if (data.positions && data.positions.length > 0) { - result += `\n**Positions**\n` + result += `\n**Positions**\n`; data.positions .filter((p: any) => parseFloat(p.positionAmt) !== 0) .forEach((pos: any) => { - result += `- ${pos.symbol}: ${pos.positionAmt} @ ${pos.entryPrice}\n` - }) + result += `- ${pos.symbol}: ${pos.positionAmt} @ ${pos.entryPrice}\n`; + }); } } @@ -59,9 +59,9 @@ export function registerPortfolioMarginGetCmAccount(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -71,8 +71,8 @@ export function registerPortfolioMarginGetCmAccount(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/account/getCmPosition.ts b/src/modules/portfolio-margin/account/getCmPosition.ts index df89717d..bdb012a3 100644 --- a/src/modules/portfolio-margin/account/getCmPosition.ts +++ b/src/modules/portfolio-margin/account/getCmPosition.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/account/getCmPosition.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginGetCmPosition(server: McpServer) { server.tool( @@ -26,32 +26,32 @@ export function registerPortfolioMarginGetCmPosition(server: McpServer) { ...(params.marginAsset && { marginAsset: params.marginAsset }), ...(params.pair && { pair: params.pair }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Portfolio Margin CM Position Risk\n\n` + let result = `✅ Portfolio Margin CM Position Risk\n\n`; if (Array.isArray(data) && data.length > 0) { - const activePositions = data.filter((p: any) => parseFloat(p.positionAmt) !== 0) + const activePositions = data.filter((p: any) => parseFloat(p.positionAmt) !== 0); if (activePositions.length > 0) { - result += `Active Positions: ${activePositions.length}\n\n` + result += `Active Positions: ${activePositions.length}\n\n`; activePositions.forEach((pos: any) => { - result += `**${pos.symbol}**\n` - result += ` Position: ${pos.positionAmt} contracts\n` - result += ` Entry Price: ${pos.entryPrice}\n` - result += ` Mark Price: ${pos.markPrice}\n` - result += ` Unrealized PnL: ${pos.unrealizedProfit}\n` - result += ` Liquidation Price: ${pos.liquidationPrice}\n` - result += ` Leverage: ${pos.leverage}x\n` - result += ` Margin Type: ${pos.marginType}\n\n` - }) + result += `**${pos.symbol}**\n`; + result += ` Position: ${pos.positionAmt} contracts\n`; + result += ` Entry Price: ${pos.entryPrice}\n`; + result += ` Mark Price: ${pos.markPrice}\n`; + result += ` Unrealized PnL: ${pos.unrealizedProfit}\n`; + result += ` Liquidation Price: ${pos.liquidationPrice}\n`; + result += ` Leverage: ${pos.leverage}x\n`; + result += ` Margin Type: ${pos.marginType}\n\n`; + }); } else { - result += `No active CM positions` + result += `No active CM positions`; } } else { - result += `No position data found` + result += `No position data found`; } return { @@ -61,9 +61,9 @@ export function registerPortfolioMarginGetCmPosition(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -73,8 +73,8 @@ export function registerPortfolioMarginGetCmPosition(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/account/getMarginAccount.ts b/src/modules/portfolio-margin/account/getMarginAccount.ts index c188af03..d35453b7 100644 --- a/src/modules/portfolio-margin/account/getMarginAccount.ts +++ b/src/modules/portfolio-margin/account/getMarginAccount.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/account/getMarginAccount.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginGetMarginAccount(server: McpServer) { server.tool( @@ -22,36 +22,36 @@ export function registerPortfolioMarginGetMarginAccount(server: McpServer) { try { const response = await portfolioMarginClient.restAPI.marginAccount({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Portfolio Margin - Cross Margin Account\n\n` + let result = `✅ Portfolio Margin - Cross Margin Account\n\n`; if (data) { - result += `**Account Overview**\n` - result += `Borrow Enabled: ${data.borrowEnabled}\n` - result += `Trade Enabled: ${data.tradeEnabled}\n` - result += `Transfer Enabled: ${data.transferEnabled}\n` - result += `Margin Level: ${data.marginLevel}\n` - result += `Total Asset (BTC): ${data.totalAssetOfBtc}\n` - result += `Total Liability (BTC): ${data.totalLiabilityOfBtc}\n` - result += `Total Net Asset (BTC): ${data.totalNetAssetOfBtc}\n\n` + result += `**Account Overview**\n`; + result += `Borrow Enabled: ${data.borrowEnabled}\n`; + result += `Trade Enabled: ${data.tradeEnabled}\n`; + result += `Transfer Enabled: ${data.transferEnabled}\n`; + result += `Margin Level: ${data.marginLevel}\n`; + result += `Total Asset (BTC): ${data.totalAssetOfBtc}\n`; + result += `Total Liability (BTC): ${data.totalLiabilityOfBtc}\n`; + result += `Total Net Asset (BTC): ${data.totalNetAssetOfBtc}\n\n`; if (data.userAssets && data.userAssets.length > 0) { - result += `**Assets with Balance**\n` + result += `**Assets with Balance**\n`; const assetsWithBalance = data.userAssets.filter( (a: any) => parseFloat(a.free) > 0 || parseFloat(a.locked) > 0 || parseFloat(a.borrowed) > 0, - ) + ); assetsWithBalance.slice(0, 15).forEach((asset: any) => { - result += `**${asset.asset}**\n` - result += ` Free: ${asset.free} | Locked: ${asset.locked}\n` - result += ` Borrowed: ${asset.borrowed} | Interest: ${asset.interest}\n` - result += ` Net Asset: ${asset.netAsset}\n\n` - }) + result += `**${asset.asset}**\n`; + result += ` Free: ${asset.free} | Locked: ${asset.locked}\n`; + result += ` Borrowed: ${asset.borrowed} | Interest: ${asset.interest}\n`; + result += ` Net Asset: ${asset.netAsset}\n\n`; + }); if (assetsWithBalance.length > 15) { - result += `... and ${assetsWithBalance.length - 15} more assets` + result += `... and ${assetsWithBalance.length - 15} more assets`; } } } @@ -63,9 +63,9 @@ export function registerPortfolioMarginGetMarginAccount(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -75,8 +75,8 @@ export function registerPortfolioMarginGetMarginAccount(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/account/getMaxBorrowable.ts b/src/modules/portfolio-margin/account/getMaxBorrowable.ts index ecd5b9dc..c0f3acd6 100644 --- a/src/modules/portfolio-margin/account/getMaxBorrowable.ts +++ b/src/modules/portfolio-margin/account/getMaxBorrowable.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/account/getMaxBorrowable.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginGetMaxBorrowable(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerPortfolioMarginGetMaxBorrowable(server: McpServer) { const response = await portfolioMarginClient.restAPI.marginMaxBorrowable({ asset: params.asset, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,9 +35,9 @@ export function registerPortfolioMarginGetMaxBorrowable(server: McpServer) { text: `✅ Portfolio Margin Max Borrowable\n\nAsset: ${params.asset}\nMax Borrowable Amount: ${data.amount}\nBorrowed: ${data.borrowedAmount || "0"}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -47,8 +47,8 @@ export function registerPortfolioMarginGetMaxBorrowable(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/account/getMaxWithdraw.ts b/src/modules/portfolio-margin/account/getMaxWithdraw.ts index 1661572f..0119f922 100644 --- a/src/modules/portfolio-margin/account/getMaxWithdraw.ts +++ b/src/modules/portfolio-margin/account/getMaxWithdraw.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/account/getMaxWithdraw.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginGetMaxWithdraw(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerPortfolioMarginGetMaxWithdraw(server: McpServer) { const response = await portfolioMarginClient.restAPI.marginMaxWithdraw({ asset: params.asset, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,9 +35,9 @@ export function registerPortfolioMarginGetMaxWithdraw(server: McpServer) { text: `✅ Portfolio Margin Max Withdraw\n\nAsset: ${params.asset}\nMax Withdraw Amount: ${data.amount}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -47,8 +47,8 @@ export function registerPortfolioMarginGetMaxWithdraw(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/account/getUmAccount.ts b/src/modules/portfolio-margin/account/getUmAccount.ts index 7b990b53..b2abcb39 100644 --- a/src/modules/portfolio-margin/account/getUmAccount.ts +++ b/src/modules/portfolio-margin/account/getUmAccount.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/account/getUmAccount.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginGetUmAccount(server: McpServer) { server.tool( @@ -22,28 +22,28 @@ export function registerPortfolioMarginGetUmAccount(server: McpServer) { try { const response = await portfolioMarginClient.restAPI.umAccount({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Portfolio Margin UM (USDT-M) Account\n\n` + let result = `✅ Portfolio Margin UM (USDT-M) Account\n\n`; if (data) { - result += `**Account Overview**\n` - result += `Total Wallet Balance: ${data.totalWalletBalance}\n` - result += `Total Unrealized Profit: ${data.totalUnrealizedProfit}\n` - result += `Total Margin Balance: ${data.totalMarginBalance}\n` - result += `Total Position Initial Margin: ${data.totalPositionInitialMargin}\n` - result += `Total Open Order Initial Margin: ${data.totalOpenOrderInitialMargin}\n` - result += `Total Cross Wallet Balance: ${data.totalCrossWalletBalance}\n` - result += `Available Balance: ${data.availableBalance}\n` - result += `Max Withdraw Amount: ${data.maxWithdrawAmount}\n\n` + result += `**Account Overview**\n`; + result += `Total Wallet Balance: ${data.totalWalletBalance}\n`; + result += `Total Unrealized Profit: ${data.totalUnrealizedProfit}\n`; + result += `Total Margin Balance: ${data.totalMarginBalance}\n`; + result += `Total Position Initial Margin: ${data.totalPositionInitialMargin}\n`; + result += `Total Open Order Initial Margin: ${data.totalOpenOrderInitialMargin}\n`; + result += `Total Cross Wallet Balance: ${data.totalCrossWalletBalance}\n`; + result += `Available Balance: ${data.availableBalance}\n`; + result += `Max Withdraw Amount: ${data.maxWithdrawAmount}\n\n`; if (data.assets && data.assets.length > 0) { - result += `**Assets**\n` + result += `**Assets**\n`; data.assets.slice(0, 10).forEach((asset: any) => { - result += `- ${asset.asset}: Balance ${asset.walletBalance}, Available ${asset.availableBalance}\n` - }) + result += `- ${asset.asset}: Balance ${asset.walletBalance}, Available ${asset.availableBalance}\n`; + }); } } @@ -54,9 +54,9 @@ export function registerPortfolioMarginGetUmAccount(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -66,8 +66,8 @@ export function registerPortfolioMarginGetUmAccount(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/account/getUmPosition.ts b/src/modules/portfolio-margin/account/getUmPosition.ts index fcd67cc2..3c382210 100644 --- a/src/modules/portfolio-margin/account/getUmPosition.ts +++ b/src/modules/portfolio-margin/account/getUmPosition.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/account/getUmPosition.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginGetUmPosition(server: McpServer) { server.tool( @@ -24,32 +24,32 @@ export function registerPortfolioMarginGetUmPosition(server: McpServer) { const response = await portfolioMarginClient.restAPI.umPositionRisk({ ...(params.symbol && { symbol: params.symbol }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Portfolio Margin UM Position Risk\n\n` + let result = `✅ Portfolio Margin UM Position Risk\n\n`; if (Array.isArray(data) && data.length > 0) { - const activePositions = data.filter((p: any) => parseFloat(p.positionAmt) !== 0) + const activePositions = data.filter((p: any) => parseFloat(p.positionAmt) !== 0); if (activePositions.length > 0) { - result += `Active Positions: ${activePositions.length}\n\n` + result += `Active Positions: ${activePositions.length}\n\n`; activePositions.forEach((pos: any) => { - result += `**${pos.symbol}**\n` - result += ` Position: ${pos.positionAmt}\n` - result += ` Entry Price: ${pos.entryPrice}\n` - result += ` Mark Price: ${pos.markPrice}\n` - result += ` Unrealized PnL: ${pos.unrealizedProfit}\n` - result += ` Liquidation Price: ${pos.liquidationPrice}\n` - result += ` Leverage: ${pos.leverage}x\n` - result += ` Margin Type: ${pos.marginType}\n\n` - }) + result += `**${pos.symbol}**\n`; + result += ` Position: ${pos.positionAmt}\n`; + result += ` Entry Price: ${pos.entryPrice}\n`; + result += ` Mark Price: ${pos.markPrice}\n`; + result += ` Unrealized PnL: ${pos.unrealizedProfit}\n`; + result += ` Liquidation Price: ${pos.liquidationPrice}\n`; + result += ` Leverage: ${pos.leverage}x\n`; + result += ` Margin Type: ${pos.marginType}\n\n`; + }); } else { - result += `No active UM positions` + result += `No active UM positions`; } } else { - result += `No position data found` + result += `No position data found`; } return { @@ -59,9 +59,9 @@ export function registerPortfolioMarginGetUmPosition(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -71,8 +71,8 @@ export function registerPortfolioMarginGetUmPosition(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/account/index.ts b/src/modules/portfolio-margin/account/index.ts index d7bee058..1e96762c 100644 --- a/src/modules/portfolio-margin/account/index.ts +++ b/src/modules/portfolio-margin/account/index.ts @@ -5,26 +5,26 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/account/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerPortfolioMarginGetAccountInfo } from "./getAccountInfo.js" -import { registerPortfolioMarginGetBalance } from "./getBalance.js" -import { registerPortfolioMarginGetCmAccount } from "./getCmAccount.js" -import { registerPortfolioMarginGetCmPosition } from "./getCmPosition.js" -import { registerPortfolioMarginGetMarginAccount } from "./getMarginAccount.js" -import { registerPortfolioMarginGetMaxBorrowable } from "./getMaxBorrowable.js" -import { registerPortfolioMarginGetMaxWithdraw } from "./getMaxWithdraw.js" -import { registerPortfolioMarginGetUmAccount } from "./getUmAccount.js" -import { registerPortfolioMarginGetUmPosition } from "./getUmPosition.js" +import { registerPortfolioMarginGetAccountInfo } from "./getAccountInfo.js"; +import { registerPortfolioMarginGetBalance } from "./getBalance.js"; +import { registerPortfolioMarginGetCmAccount } from "./getCmAccount.js"; +import { registerPortfolioMarginGetCmPosition } from "./getCmPosition.js"; +import { registerPortfolioMarginGetMarginAccount } from "./getMarginAccount.js"; +import { registerPortfolioMarginGetMaxBorrowable } from "./getMaxBorrowable.js"; +import { registerPortfolioMarginGetMaxWithdraw } from "./getMaxWithdraw.js"; +import { registerPortfolioMarginGetUmAccount } from "./getUmAccount.js"; +import { registerPortfolioMarginGetUmPosition } from "./getUmPosition.js"; export function registerPortfolioMarginAccountApi(server: McpServer) { - registerPortfolioMarginGetAccountInfo(server) - registerPortfolioMarginGetBalance(server) - registerPortfolioMarginGetMaxBorrowable(server) - registerPortfolioMarginGetMaxWithdraw(server) - registerPortfolioMarginGetUmAccount(server) - registerPortfolioMarginGetCmAccount(server) - registerPortfolioMarginGetUmPosition(server) - registerPortfolioMarginGetCmPosition(server) - registerPortfolioMarginGetMarginAccount(server) + registerPortfolioMarginGetAccountInfo(server); + registerPortfolioMarginGetBalance(server); + registerPortfolioMarginGetMaxBorrowable(server); + registerPortfolioMarginGetMaxWithdraw(server); + registerPortfolioMarginGetUmAccount(server); + registerPortfolioMarginGetCmAccount(server); + registerPortfolioMarginGetUmPosition(server); + registerPortfolioMarginGetCmPosition(server); + registerPortfolioMarginGetMarginAccount(server); } diff --git a/src/modules/portfolio-margin/cm-trade/cancelAllOrders.ts b/src/modules/portfolio-margin/cm-trade/cancelAllOrders.ts index 7e298256..ae7d8dba 100644 --- a/src/modules/portfolio-margin/cm-trade/cancelAllOrders.ts +++ b/src/modules/portfolio-margin/cm-trade/cancelAllOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/cm-trade/cancelAllOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginCmCancelAllOrders(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerPortfolioMarginCmCancelAllOrders(server: McpServer) { const response = await portfolioMarginClient.restAPI.cmCancelAllOpenOrders({ symbol: params.symbol, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,9 +35,9 @@ export function registerPortfolioMarginCmCancelAllOrders(server: McpServer) { text: `✅ All Portfolio Margin CM orders cancelled for ${params.symbol}\n\nResponse: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -47,8 +47,8 @@ export function registerPortfolioMarginCmCancelAllOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/cm-trade/cancelOrder.ts b/src/modules/portfolio-margin/cm-trade/cancelOrder.ts index e2c4b659..c5c9f8c4 100644 --- a/src/modules/portfolio-margin/cm-trade/cancelOrder.ts +++ b/src/modules/portfolio-margin/cm-trade/cancelOrder.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/cm-trade/cancelOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginCmCancelOrder(server: McpServer) { server.tool( @@ -32,7 +32,7 @@ export function registerPortfolioMarginCmCancelOrder(server: McpServer) { }, ], isError: true, - } + }; } const response = await portfolioMarginClient.restAPI.cmCancelOrder({ @@ -40,9 +40,9 @@ export function registerPortfolioMarginCmCancelOrder(server: McpServer) { ...(params.orderId && { orderId: params.orderId }), ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -51,9 +51,9 @@ export function registerPortfolioMarginCmCancelOrder(server: McpServer) { text: `✅ Portfolio Margin CM Order Cancelled!\n\nOrder ID: ${data.orderId}\nSymbol: ${data.symbol}\nStatus: ${data.status}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -63,8 +63,8 @@ export function registerPortfolioMarginCmCancelOrder(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/cm-trade/changeLeverage.ts b/src/modules/portfolio-margin/cm-trade/changeLeverage.ts index 1f510fc3..7bbf0540 100644 --- a/src/modules/portfolio-margin/cm-trade/changeLeverage.ts +++ b/src/modules/portfolio-margin/cm-trade/changeLeverage.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/cm-trade/changeLeverage.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginCmChangeLeverage(server: McpServer) { server.tool( @@ -26,9 +26,9 @@ export function registerPortfolioMarginCmChangeLeverage(server: McpServer) { symbol: params.symbol, leverage: params.leverage, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -37,9 +37,9 @@ export function registerPortfolioMarginCmChangeLeverage(server: McpServer) { text: `✅ Portfolio Margin CM Leverage Changed!\n\nSymbol: ${data.symbol}\nNew Leverage: ${data.leverage}x\nMax Qty: ${data.maxQty}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -49,8 +49,8 @@ export function registerPortfolioMarginCmChangeLeverage(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/cm-trade/changeMarginType.ts b/src/modules/portfolio-margin/cm-trade/changeMarginType.ts index 83f01239..11c25050 100644 --- a/src/modules/portfolio-margin/cm-trade/changeMarginType.ts +++ b/src/modules/portfolio-margin/cm-trade/changeMarginType.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/cm-trade/changeMarginType.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginCmChangeMarginType(server: McpServer) { server.tool( @@ -26,9 +26,9 @@ export function registerPortfolioMarginCmChangeMarginType(server: McpServer) { symbol: params.symbol, marginType: params.marginType, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -37,9 +37,9 @@ export function registerPortfolioMarginCmChangeMarginType(server: McpServer) { text: `✅ Portfolio Margin CM Margin Type Changed!\n\nSymbol: ${params.symbol}\nNew Margin Type: ${params.marginType}\n\nResponse: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -49,8 +49,8 @@ export function registerPortfolioMarginCmChangeMarginType(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/cm-trade/getAllOrders.ts b/src/modules/portfolio-margin/cm-trade/getAllOrders.ts index 9152854b..46858f7f 100644 --- a/src/modules/portfolio-margin/cm-trade/getAllOrders.ts +++ b/src/modules/portfolio-margin/cm-trade/getAllOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/cm-trade/getAllOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginCmGetAllOrders(server: McpServer) { server.tool( @@ -40,26 +40,26 @@ export function registerPortfolioMarginCmGetAllOrders(server: McpServer) { ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Portfolio Margin CM All Orders\n\n` + let result = `✅ Portfolio Margin CM All Orders\n\n`; if (Array.isArray(data) && data.length > 0) { - result += `Total orders: ${data.length}\n\n` + result += `Total orders: ${data.length}\n\n`; data.slice(0, 20).forEach((order: any, index: number) => { - result += `**${index + 1}. ${order.symbol}**\n` - result += ` Order ID: ${order.orderId}\n` - result += ` Side: ${order.side} | Type: ${order.type}\n` - result += ` Price: ${order.price} | Qty: ${order.origQty}\n` - result += ` Executed: ${order.executedQty} | Status: ${order.status}\n\n` - }) + result += `**${index + 1}. ${order.symbol}**\n`; + result += ` Order ID: ${order.orderId}\n`; + result += ` Side: ${order.side} | Type: ${order.type}\n`; + result += ` Price: ${order.price} | Qty: ${order.origQty}\n`; + result += ` Executed: ${order.executedQty} | Status: ${order.status}\n\n`; + }); if (data.length > 20) { - result += `... and ${data.length - 20} more orders` + result += `... and ${data.length - 20} more orders`; } } else { - result += `No orders found` + result += `No orders found`; } return { @@ -69,9 +69,9 @@ export function registerPortfolioMarginCmGetAllOrders(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -81,8 +81,8 @@ export function registerPortfolioMarginCmGetAllOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/cm-trade/getOpenOrders.ts b/src/modules/portfolio-margin/cm-trade/getOpenOrders.ts index a4a35938..491a9bc0 100644 --- a/src/modules/portfolio-margin/cm-trade/getOpenOrders.ts +++ b/src/modules/portfolio-margin/cm-trade/getOpenOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/cm-trade/getOpenOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginCmGetOpenOrders(server: McpServer) { server.tool( @@ -26,24 +26,24 @@ export function registerPortfolioMarginCmGetOpenOrders(server: McpServer) { ...(params.symbol && { symbol: params.symbol }), ...(params.pair && { pair: params.pair }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Portfolio Margin CM Open Orders\n\n` + let result = `✅ Portfolio Margin CM Open Orders\n\n`; if (Array.isArray(data) && data.length > 0) { - result += `Total open orders: ${data.length}\n\n` + result += `Total open orders: ${data.length}\n\n`; data.forEach((order: any, index: number) => { - result += `**${index + 1}. ${order.symbol}**\n` - result += ` Order ID: ${order.orderId}\n` - result += ` Side: ${order.side} | Type: ${order.type}\n` - result += ` Price: ${order.price} | Qty: ${order.origQty}\n` - result += ` Executed: ${order.executedQty}\n` - result += ` Status: ${order.status}\n\n` - }) + result += `**${index + 1}. ${order.symbol}**\n`; + result += ` Order ID: ${order.orderId}\n`; + result += ` Side: ${order.side} | Type: ${order.type}\n`; + result += ` Price: ${order.price} | Qty: ${order.origQty}\n`; + result += ` Executed: ${order.executedQty}\n`; + result += ` Status: ${order.status}\n\n`; + }); } else { - result += `No open orders found` + result += `No open orders found`; } return { @@ -53,9 +53,9 @@ export function registerPortfolioMarginCmGetOpenOrders(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -65,8 +65,8 @@ export function registerPortfolioMarginCmGetOpenOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/cm-trade/getOrder.ts b/src/modules/portfolio-margin/cm-trade/getOrder.ts index 2c8516de..35695500 100644 --- a/src/modules/portfolio-margin/cm-trade/getOrder.ts +++ b/src/modules/portfolio-margin/cm-trade/getOrder.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/cm-trade/getOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginCmGetOrder(server: McpServer) { server.tool( @@ -32,7 +32,7 @@ export function registerPortfolioMarginCmGetOrder(server: McpServer) { }, ], isError: true, - } + }; } const response = await portfolioMarginClient.restAPI.cmOrder({ @@ -40,19 +40,19 @@ export function registerPortfolioMarginCmGetOrder(server: McpServer) { ...(params.orderId && { orderId: params.orderId }), ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Portfolio Margin CM Order Details\n\n` - result += `Order ID: ${data.orderId}\n` - result += `Symbol: ${data.symbol}\n` - result += `Side: ${data.side} | Type: ${data.type}\n` - result += `Price: ${data.price} | Qty: ${data.origQty}\n` - result += `Executed Qty: ${data.executedQty}\n` - result += `Avg Price: ${data.avgPrice}\n` - result += `Status: ${data.status}\n` - result += `Time: ${new Date(data.time).toISOString()}` + let result = `✅ Portfolio Margin CM Order Details\n\n`; + result += `Order ID: ${data.orderId}\n`; + result += `Symbol: ${data.symbol}\n`; + result += `Side: ${data.side} | Type: ${data.type}\n`; + result += `Price: ${data.price} | Qty: ${data.origQty}\n`; + result += `Executed Qty: ${data.executedQty}\n`; + result += `Avg Price: ${data.avgPrice}\n`; + result += `Status: ${data.status}\n`; + result += `Time: ${new Date(data.time).toISOString()}`; return { content: [ @@ -61,9 +61,9 @@ export function registerPortfolioMarginCmGetOrder(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -73,8 +73,8 @@ export function registerPortfolioMarginCmGetOrder(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/cm-trade/getUserTrades.ts b/src/modules/portfolio-margin/cm-trade/getUserTrades.ts index 19ce908f..1fd6c12a 100644 --- a/src/modules/portfolio-margin/cm-trade/getUserTrades.ts +++ b/src/modules/portfolio-margin/cm-trade/getUserTrades.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/cm-trade/getUserTrades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginCmGetUserTrades(server: McpServer) { server.tool( @@ -40,29 +40,29 @@ export function registerPortfolioMarginCmGetUserTrades(server: McpServer) { ...(params.fromId && { fromId: params.fromId }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Portfolio Margin CM Trade History\n\n` + let result = `✅ Portfolio Margin CM Trade History\n\n`; if (Array.isArray(data) && data.length > 0) { - result += `Total trades: ${data.length}\n\n` + result += `Total trades: ${data.length}\n\n`; data.slice(0, 20).forEach((trade: any, index: number) => { - result += `**${index + 1}. ${trade.symbol}**\n` - result += ` Trade ID: ${trade.id}\n` - result += ` Order ID: ${trade.orderId}\n` - result += ` Side: ${trade.side} | Price: ${trade.price}\n` - result += ` Qty: ${trade.qty} | Base Qty: ${trade.baseQty}\n` - result += ` Realized PnL: ${trade.realizedPnl}\n` - result += ` Commission: ${trade.commission} ${trade.commissionAsset}\n` - result += ` Time: ${new Date(trade.time).toISOString()}\n\n` - }) + result += `**${index + 1}. ${trade.symbol}**\n`; + result += ` Trade ID: ${trade.id}\n`; + result += ` Order ID: ${trade.orderId}\n`; + result += ` Side: ${trade.side} | Price: ${trade.price}\n`; + result += ` Qty: ${trade.qty} | Base Qty: ${trade.baseQty}\n`; + result += ` Realized PnL: ${trade.realizedPnl}\n`; + result += ` Commission: ${trade.commission} ${trade.commissionAsset}\n`; + result += ` Time: ${new Date(trade.time).toISOString()}\n\n`; + }); if (data.length > 20) { - result += `... and ${data.length - 20} more trades` + result += `... and ${data.length - 20} more trades`; } } else { - result += `No trades found` + result += `No trades found`; } return { @@ -72,9 +72,9 @@ export function registerPortfolioMarginCmGetUserTrades(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -84,8 +84,8 @@ export function registerPortfolioMarginCmGetUserTrades(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/cm-trade/index.ts b/src/modules/portfolio-margin/cm-trade/index.ts index a9c74975..3105bbf5 100644 --- a/src/modules/portfolio-margin/cm-trade/index.ts +++ b/src/modules/portfolio-margin/cm-trade/index.ts @@ -5,26 +5,26 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/cm-trade/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerPortfolioMarginCmCancelAllOrders } from "./cancelAllOrders.js" -import { registerPortfolioMarginCmCancelOrder } from "./cancelOrder.js" -import { registerPortfolioMarginCmChangeLeverage } from "./changeLeverage.js" -import { registerPortfolioMarginCmChangeMarginType } from "./changeMarginType.js" -import { registerPortfolioMarginCmGetAllOrders } from "./getAllOrders.js" -import { registerPortfolioMarginCmGetOpenOrders } from "./getOpenOrders.js" -import { registerPortfolioMarginCmGetOrder } from "./getOrder.js" -import { registerPortfolioMarginCmGetUserTrades } from "./getUserTrades.js" -import { registerPortfolioMarginCmNewOrder } from "./newOrder.js" +import { registerPortfolioMarginCmCancelAllOrders } from "./cancelAllOrders.js"; +import { registerPortfolioMarginCmCancelOrder } from "./cancelOrder.js"; +import { registerPortfolioMarginCmChangeLeverage } from "./changeLeverage.js"; +import { registerPortfolioMarginCmChangeMarginType } from "./changeMarginType.js"; +import { registerPortfolioMarginCmGetAllOrders } from "./getAllOrders.js"; +import { registerPortfolioMarginCmGetOpenOrders } from "./getOpenOrders.js"; +import { registerPortfolioMarginCmGetOrder } from "./getOrder.js"; +import { registerPortfolioMarginCmGetUserTrades } from "./getUserTrades.js"; +import { registerPortfolioMarginCmNewOrder } from "./newOrder.js"; export function registerPortfolioMarginCmTradeApi(server: McpServer) { - registerPortfolioMarginCmNewOrder(server) - registerPortfolioMarginCmCancelOrder(server) - registerPortfolioMarginCmCancelAllOrders(server) - registerPortfolioMarginCmGetOrder(server) - registerPortfolioMarginCmGetAllOrders(server) - registerPortfolioMarginCmGetOpenOrders(server) - registerPortfolioMarginCmGetUserTrades(server) - registerPortfolioMarginCmChangeLeverage(server) - registerPortfolioMarginCmChangeMarginType(server) + registerPortfolioMarginCmNewOrder(server); + registerPortfolioMarginCmCancelOrder(server); + registerPortfolioMarginCmCancelAllOrders(server); + registerPortfolioMarginCmGetOrder(server); + registerPortfolioMarginCmGetAllOrders(server); + registerPortfolioMarginCmGetOpenOrders(server); + registerPortfolioMarginCmGetUserTrades(server); + registerPortfolioMarginCmChangeLeverage(server); + registerPortfolioMarginCmChangeMarginType(server); } diff --git a/src/modules/portfolio-margin/cm-trade/newOrder.ts b/src/modules/portfolio-margin/cm-trade/newOrder.ts index ae006b3e..f575a436 100644 --- a/src/modules/portfolio-margin/cm-trade/newOrder.ts +++ b/src/modules/portfolio-margin/cm-trade/newOrder.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/cm-trade/newOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginCmNewOrder(server: McpServer) { server.tool( @@ -55,9 +55,9 @@ export function registerPortfolioMarginCmNewOrder(server: McpServer) { ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), ...(params.positionSide && { positionSide: params.positionSide }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -66,9 +66,9 @@ export function registerPortfolioMarginCmNewOrder(server: McpServer) { text: `✅ Portfolio Margin CM Order Placed!\n\nOrder ID: ${data.orderId}\nSymbol: ${data.symbol}\nSide: ${data.side}\nType: ${data.type}\nQuantity: ${data.origQty}\nPrice: ${data.price || "MARKET"}\nStatus: ${data.status}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -78,8 +78,8 @@ export function registerPortfolioMarginCmNewOrder(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/index.ts b/src/modules/portfolio-margin/index.ts index 0d11473e..a99301c4 100644 --- a/src/modules/portfolio-margin/index.ts +++ b/src/modules/portfolio-margin/index.ts @@ -1,8 +1,8 @@ // src/modules/portfolio-margin/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinancePortfolioMarginTools } from "../../tools/binance-portfolio-margin/index.js" +import { registerBinancePortfolioMarginTools } from "../../tools/binance-portfolio-margin/index.js"; export function registerPortfolioMargin(server: McpServer) { - registerBinancePortfolioMarginTools(server) + registerBinancePortfolioMarginTools(server); } diff --git a/src/modules/portfolio-margin/margin-trade/cancelAllOrders.ts b/src/modules/portfolio-margin/margin-trade/cancelAllOrders.ts index 5dbacf95..5ac587c8 100644 --- a/src/modules/portfolio-margin/margin-trade/cancelAllOrders.ts +++ b/src/modules/portfolio-margin/margin-trade/cancelAllOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/margin-trade/cancelAllOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginMarginCancelAllOrders(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerPortfolioMarginMarginCancelAllOrders(server: McpServer) const response = await portfolioMarginClient.restAPI.marginCancelAllOpenOrders({ symbol: params.symbol, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,9 +35,9 @@ export function registerPortfolioMarginMarginCancelAllOrders(server: McpServer) text: `✅ All Portfolio Margin margin orders cancelled for ${params.symbol}\n\nResponse: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -47,8 +47,8 @@ export function registerPortfolioMarginMarginCancelAllOrders(server: McpServer) }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/margin-trade/cancelOrder.ts b/src/modules/portfolio-margin/margin-trade/cancelOrder.ts index f2a57e7f..0f4bb11e 100644 --- a/src/modules/portfolio-margin/margin-trade/cancelOrder.ts +++ b/src/modules/portfolio-margin/margin-trade/cancelOrder.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/margin-trade/cancelOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginMarginCancelOrder(server: McpServer) { server.tool( @@ -32,7 +32,7 @@ export function registerPortfolioMarginMarginCancelOrder(server: McpServer) { }, ], isError: true, - } + }; } const response = await portfolioMarginClient.restAPI.marginCancelOrder({ @@ -40,9 +40,9 @@ export function registerPortfolioMarginMarginCancelOrder(server: McpServer) { ...(params.orderId && { orderId: params.orderId }), ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -51,9 +51,9 @@ export function registerPortfolioMarginMarginCancelOrder(server: McpServer) { text: `✅ Portfolio Margin Margin Order Cancelled!\n\nOrder ID: ${data.orderId}\nSymbol: ${data.symbol}\nStatus: ${data.status}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -63,8 +63,8 @@ export function registerPortfolioMarginMarginCancelOrder(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/margin-trade/getAllOrders.ts b/src/modules/portfolio-margin/margin-trade/getAllOrders.ts index cb86cc69..733d1495 100644 --- a/src/modules/portfolio-margin/margin-trade/getAllOrders.ts +++ b/src/modules/portfolio-margin/margin-trade/getAllOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/margin-trade/getAllOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginMarginGetAllOrders(server: McpServer) { server.tool( @@ -38,25 +38,25 @@ export function registerPortfolioMarginMarginGetAllOrders(server: McpServer) { ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Portfolio Margin Margin All Orders - ${params.symbol}\n\n` + let result = `✅ Portfolio Margin Margin All Orders - ${params.symbol}\n\n`; if (Array.isArray(data) && data.length > 0) { - result += `Total orders: ${data.length}\n\n` + result += `Total orders: ${data.length}\n\n`; data.slice(0, 20).forEach((order: any, index: number) => { - result += `**${index + 1}. Order ID: ${order.orderId}**\n` - result += ` Side: ${order.side} | Type: ${order.type}\n` - result += ` Price: ${order.price} | Qty: ${order.origQty}\n` - result += ` Executed: ${order.executedQty} | Status: ${order.status}\n\n` - }) + result += `**${index + 1}. Order ID: ${order.orderId}**\n`; + result += ` Side: ${order.side} | Type: ${order.type}\n`; + result += ` Price: ${order.price} | Qty: ${order.origQty}\n`; + result += ` Executed: ${order.executedQty} | Status: ${order.status}\n\n`; + }); if (data.length > 20) { - result += `... and ${data.length - 20} more orders` + result += `... and ${data.length - 20} more orders`; } } else { - result += `No orders found` + result += `No orders found`; } return { @@ -66,9 +66,9 @@ export function registerPortfolioMarginMarginGetAllOrders(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -78,8 +78,8 @@ export function registerPortfolioMarginMarginGetAllOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/margin-trade/getOpenOrders.ts b/src/modules/portfolio-margin/margin-trade/getOpenOrders.ts index 33e7cdab..9f689513 100644 --- a/src/modules/portfolio-margin/margin-trade/getOpenOrders.ts +++ b/src/modules/portfolio-margin/margin-trade/getOpenOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/margin-trade/getOpenOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginMarginGetOpenOrders(server: McpServer) { server.tool( @@ -24,24 +24,24 @@ export function registerPortfolioMarginMarginGetOpenOrders(server: McpServer) { const response = await portfolioMarginClient.restAPI.marginOpenOrders({ ...(params.symbol && { symbol: params.symbol }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Portfolio Margin Margin Open Orders\n\n` + let result = `✅ Portfolio Margin Margin Open Orders\n\n`; if (Array.isArray(data) && data.length > 0) { - result += `Total open orders: ${data.length}\n\n` + result += `Total open orders: ${data.length}\n\n`; data.forEach((order: any, index: number) => { - result += `**${index + 1}. ${order.symbol}**\n` - result += ` Order ID: ${order.orderId}\n` - result += ` Side: ${order.side} | Type: ${order.type}\n` - result += ` Price: ${order.price} | Qty: ${order.origQty}\n` - result += ` Executed: ${order.executedQty}\n` - result += ` Status: ${order.status}\n\n` - }) + result += `**${index + 1}. ${order.symbol}**\n`; + result += ` Order ID: ${order.orderId}\n`; + result += ` Side: ${order.side} | Type: ${order.type}\n`; + result += ` Price: ${order.price} | Qty: ${order.origQty}\n`; + result += ` Executed: ${order.executedQty}\n`; + result += ` Status: ${order.status}\n\n`; + }); } else { - result += `No open orders found` + result += `No open orders found`; } return { @@ -51,9 +51,9 @@ export function registerPortfolioMarginMarginGetOpenOrders(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -63,8 +63,8 @@ export function registerPortfolioMarginMarginGetOpenOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/margin-trade/getOrder.ts b/src/modules/portfolio-margin/margin-trade/getOrder.ts index 9d7d74c8..6b56ee43 100644 --- a/src/modules/portfolio-margin/margin-trade/getOrder.ts +++ b/src/modules/portfolio-margin/margin-trade/getOrder.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/margin-trade/getOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginMarginGetOrder(server: McpServer) { server.tool( @@ -32,7 +32,7 @@ export function registerPortfolioMarginMarginGetOrder(server: McpServer) { }, ], isError: true, - } + }; } const response = await portfolioMarginClient.restAPI.marginOrder({ @@ -40,18 +40,18 @@ export function registerPortfolioMarginMarginGetOrder(server: McpServer) { ...(params.orderId && { orderId: params.orderId }), ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Portfolio Margin Margin Order Details\n\n` - result += `Order ID: ${data.orderId}\n` - result += `Symbol: ${data.symbol}\n` - result += `Side: ${data.side} | Type: ${data.type}\n` - result += `Price: ${data.price} | Qty: ${data.origQty}\n` - result += `Executed Qty: ${data.executedQty}\n` - result += `Status: ${data.status}\n` - result += `Time: ${new Date(data.time).toISOString()}` + let result = `✅ Portfolio Margin Margin Order Details\n\n`; + result += `Order ID: ${data.orderId}\n`; + result += `Symbol: ${data.symbol}\n`; + result += `Side: ${data.side} | Type: ${data.type}\n`; + result += `Price: ${data.price} | Qty: ${data.origQty}\n`; + result += `Executed Qty: ${data.executedQty}\n`; + result += `Status: ${data.status}\n`; + result += `Time: ${new Date(data.time).toISOString()}`; return { content: [ @@ -60,9 +60,9 @@ export function registerPortfolioMarginMarginGetOrder(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -72,8 +72,8 @@ export function registerPortfolioMarginMarginGetOrder(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/margin-trade/getUserTrades.ts b/src/modules/portfolio-margin/margin-trade/getUserTrades.ts index ccb71ec5..a666b15a 100644 --- a/src/modules/portfolio-margin/margin-trade/getUserTrades.ts +++ b/src/modules/portfolio-margin/margin-trade/getUserTrades.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/margin-trade/getUserTrades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginMarginGetUserTrades(server: McpServer) { server.tool( @@ -38,28 +38,28 @@ export function registerPortfolioMarginMarginGetUserTrades(server: McpServer) { ...(params.fromId && { fromId: params.fromId }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Portfolio Margin Margin Trade History - ${params.symbol}\n\n` + let result = `✅ Portfolio Margin Margin Trade History - ${params.symbol}\n\n`; if (Array.isArray(data) && data.length > 0) { - result += `Total trades: ${data.length}\n\n` + result += `Total trades: ${data.length}\n\n`; data.slice(0, 20).forEach((trade: any, index: number) => { - result += `**${index + 1}. Trade ID: ${trade.id}**\n` - result += ` Order ID: ${trade.orderId}\n` - result += ` Price: ${trade.price} | Qty: ${trade.qty}\n` - result += ` Quote Qty: ${trade.quoteQty}\n` - result += ` Commission: ${trade.commission} ${trade.commissionAsset}\n` - result += ` Is Buyer: ${trade.isBuyer} | Is Maker: ${trade.isMaker}\n` - result += ` Time: ${new Date(trade.time).toISOString()}\n\n` - }) + result += `**${index + 1}. Trade ID: ${trade.id}**\n`; + result += ` Order ID: ${trade.orderId}\n`; + result += ` Price: ${trade.price} | Qty: ${trade.qty}\n`; + result += ` Quote Qty: ${trade.quoteQty}\n`; + result += ` Commission: ${trade.commission} ${trade.commissionAsset}\n`; + result += ` Is Buyer: ${trade.isBuyer} | Is Maker: ${trade.isMaker}\n`; + result += ` Time: ${new Date(trade.time).toISOString()}\n\n`; + }); if (data.length > 20) { - result += `... and ${data.length - 20} more trades` + result += `... and ${data.length - 20} more trades`; } } else { - result += `No trades found` + result += `No trades found`; } return { @@ -69,9 +69,9 @@ export function registerPortfolioMarginMarginGetUserTrades(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -81,8 +81,8 @@ export function registerPortfolioMarginMarginGetUserTrades(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/margin-trade/index.ts b/src/modules/portfolio-margin/margin-trade/index.ts index 3da3d783..d4c4baed 100644 --- a/src/modules/portfolio-margin/margin-trade/index.ts +++ b/src/modules/portfolio-margin/margin-trade/index.ts @@ -5,26 +5,26 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/margin-trade/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerPortfolioMarginMarginCancelAllOrders } from "./cancelAllOrders.js" -import { registerPortfolioMarginMarginCancelOrder } from "./cancelOrder.js" -import { registerPortfolioMarginMarginGetAllOrders } from "./getAllOrders.js" -import { registerPortfolioMarginMarginGetOpenOrders } from "./getOpenOrders.js" -import { registerPortfolioMarginMarginGetOrder } from "./getOrder.js" -import { registerPortfolioMarginMarginGetUserTrades } from "./getUserTrades.js" -import { registerPortfolioMarginMarginLoan } from "./marginLoan.js" -import { registerPortfolioMarginMarginRepay } from "./marginRepay.js" -import { registerPortfolioMarginMarginNewOrder } from "./newOrder.js" +import { registerPortfolioMarginMarginCancelAllOrders } from "./cancelAllOrders.js"; +import { registerPortfolioMarginMarginCancelOrder } from "./cancelOrder.js"; +import { registerPortfolioMarginMarginGetAllOrders } from "./getAllOrders.js"; +import { registerPortfolioMarginMarginGetOpenOrders } from "./getOpenOrders.js"; +import { registerPortfolioMarginMarginGetOrder } from "./getOrder.js"; +import { registerPortfolioMarginMarginGetUserTrades } from "./getUserTrades.js"; +import { registerPortfolioMarginMarginLoan } from "./marginLoan.js"; +import { registerPortfolioMarginMarginRepay } from "./marginRepay.js"; +import { registerPortfolioMarginMarginNewOrder } from "./newOrder.js"; export function registerPortfolioMarginMarginTradeApi(server: McpServer) { - registerPortfolioMarginMarginNewOrder(server) - registerPortfolioMarginMarginCancelOrder(server) - registerPortfolioMarginMarginCancelAllOrders(server) - registerPortfolioMarginMarginGetOrder(server) - registerPortfolioMarginMarginGetAllOrders(server) - registerPortfolioMarginMarginGetOpenOrders(server) - registerPortfolioMarginMarginLoan(server) - registerPortfolioMarginMarginRepay(server) - registerPortfolioMarginMarginGetUserTrades(server) + registerPortfolioMarginMarginNewOrder(server); + registerPortfolioMarginMarginCancelOrder(server); + registerPortfolioMarginMarginCancelAllOrders(server); + registerPortfolioMarginMarginGetOrder(server); + registerPortfolioMarginMarginGetAllOrders(server); + registerPortfolioMarginMarginGetOpenOrders(server); + registerPortfolioMarginMarginLoan(server); + registerPortfolioMarginMarginRepay(server); + registerPortfolioMarginMarginGetUserTrades(server); } diff --git a/src/modules/portfolio-margin/margin-trade/marginLoan.ts b/src/modules/portfolio-margin/margin-trade/marginLoan.ts index b234f161..9c46c51d 100644 --- a/src/modules/portfolio-margin/margin-trade/marginLoan.ts +++ b/src/modules/portfolio-margin/margin-trade/marginLoan.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/margin-trade/marginLoan.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginMarginLoan(server: McpServer) { server.tool( @@ -26,9 +26,9 @@ export function registerPortfolioMarginMarginLoan(server: McpServer) { asset: params.asset, amount: params.amount, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -37,9 +37,9 @@ export function registerPortfolioMarginMarginLoan(server: McpServer) { text: `✅ Portfolio Margin Loan Successful!\n\nTransaction ID: ${data.tranId}\nAsset: ${params.asset}\nAmount: ${params.amount}\n\n⚠️ Note: Borrowed funds will accrue interest.`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -49,8 +49,8 @@ export function registerPortfolioMarginMarginLoan(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/margin-trade/marginRepay.ts b/src/modules/portfolio-margin/margin-trade/marginRepay.ts index 20297772..4ee1f2e9 100644 --- a/src/modules/portfolio-margin/margin-trade/marginRepay.ts +++ b/src/modules/portfolio-margin/margin-trade/marginRepay.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/margin-trade/marginRepay.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginMarginRepay(server: McpServer) { server.tool( @@ -26,9 +26,9 @@ export function registerPortfolioMarginMarginRepay(server: McpServer) { asset: params.asset, amount: params.amount, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -37,9 +37,9 @@ export function registerPortfolioMarginMarginRepay(server: McpServer) { text: `✅ Portfolio Margin Repayment Successful!\n\nTransaction ID: ${data.tranId}\nAsset: ${params.asset}\nAmount: ${params.amount}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -49,8 +49,8 @@ export function registerPortfolioMarginMarginRepay(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/margin-trade/newOrder.ts b/src/modules/portfolio-margin/margin-trade/newOrder.ts index 399856bf..2d44fbe8 100644 --- a/src/modules/portfolio-margin/margin-trade/newOrder.ts +++ b/src/modules/portfolio-margin/margin-trade/newOrder.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/margin-trade/newOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginMarginNewOrder(server: McpServer) { server.tool( @@ -55,9 +55,9 @@ export function registerPortfolioMarginMarginNewOrder(server: McpServer) { ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), ...(params.sideEffectType && { sideEffectType: params.sideEffectType }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -66,9 +66,9 @@ export function registerPortfolioMarginMarginNewOrder(server: McpServer) { text: `✅ Portfolio Margin Margin Order Placed!\n\nOrder ID: ${data.orderId}\nSymbol: ${data.symbol}\nSide: ${data.side}\nType: ${data.type}\nQuantity: ${data.origQty}\nPrice: ${data.price || "MARKET"}\nStatus: ${data.status}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -78,8 +78,8 @@ export function registerPortfolioMarginMarginNewOrder(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/um-trade/cancelAllOrders.ts b/src/modules/portfolio-margin/um-trade/cancelAllOrders.ts index 03fad42c..999a9d82 100644 --- a/src/modules/portfolio-margin/um-trade/cancelAllOrders.ts +++ b/src/modules/portfolio-margin/um-trade/cancelAllOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/um-trade/cancelAllOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginUmCancelAllOrders(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerPortfolioMarginUmCancelAllOrders(server: McpServer) { const response = await portfolioMarginClient.restAPI.umCancelAllOpenOrders({ symbol: params.symbol, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,9 +35,9 @@ export function registerPortfolioMarginUmCancelAllOrders(server: McpServer) { text: `✅ All Portfolio Margin UM orders cancelled for ${params.symbol}\n\nResponse: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -47,8 +47,8 @@ export function registerPortfolioMarginUmCancelAllOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/um-trade/cancelOrder.ts b/src/modules/portfolio-margin/um-trade/cancelOrder.ts index 2bdf71b8..dae64324 100644 --- a/src/modules/portfolio-margin/um-trade/cancelOrder.ts +++ b/src/modules/portfolio-margin/um-trade/cancelOrder.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/um-trade/cancelOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginUmCancelOrder(server: McpServer) { server.tool( @@ -32,7 +32,7 @@ export function registerPortfolioMarginUmCancelOrder(server: McpServer) { }, ], isError: true, - } + }; } const response = await portfolioMarginClient.restAPI.umCancelOrder({ @@ -40,9 +40,9 @@ export function registerPortfolioMarginUmCancelOrder(server: McpServer) { ...(params.orderId && { orderId: params.orderId }), ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -51,9 +51,9 @@ export function registerPortfolioMarginUmCancelOrder(server: McpServer) { text: `✅ Portfolio Margin UM Order Cancelled!\n\nOrder ID: ${data.orderId}\nSymbol: ${data.symbol}\nStatus: ${data.status}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -63,8 +63,8 @@ export function registerPortfolioMarginUmCancelOrder(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/um-trade/changeLeverage.ts b/src/modules/portfolio-margin/um-trade/changeLeverage.ts index 734830ee..4571e579 100644 --- a/src/modules/portfolio-margin/um-trade/changeLeverage.ts +++ b/src/modules/portfolio-margin/um-trade/changeLeverage.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/um-trade/changeLeverage.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginUmChangeLeverage(server: McpServer) { server.tool( @@ -26,9 +26,9 @@ export function registerPortfolioMarginUmChangeLeverage(server: McpServer) { symbol: params.symbol, leverage: params.leverage, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -37,9 +37,9 @@ export function registerPortfolioMarginUmChangeLeverage(server: McpServer) { text: `✅ Portfolio Margin UM Leverage Changed!\n\nSymbol: ${data.symbol}\nNew Leverage: ${data.leverage}x\nMax Notional Value: ${data.maxNotionalValue}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -49,8 +49,8 @@ export function registerPortfolioMarginUmChangeLeverage(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/um-trade/changeMarginType.ts b/src/modules/portfolio-margin/um-trade/changeMarginType.ts index 935376ba..f0ab1897 100644 --- a/src/modules/portfolio-margin/um-trade/changeMarginType.ts +++ b/src/modules/portfolio-margin/um-trade/changeMarginType.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/um-trade/changeMarginType.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginUmChangeMarginType(server: McpServer) { server.tool( @@ -26,9 +26,9 @@ export function registerPortfolioMarginUmChangeMarginType(server: McpServer) { symbol: params.symbol, marginType: params.marginType, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -37,9 +37,9 @@ export function registerPortfolioMarginUmChangeMarginType(server: McpServer) { text: `✅ Portfolio Margin UM Margin Type Changed!\n\nSymbol: ${params.symbol}\nNew Margin Type: ${params.marginType}\n\nResponse: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -49,8 +49,8 @@ export function registerPortfolioMarginUmChangeMarginType(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/um-trade/getAllOrders.ts b/src/modules/portfolio-margin/um-trade/getAllOrders.ts index a38741ef..001bc607 100644 --- a/src/modules/portfolio-margin/um-trade/getAllOrders.ts +++ b/src/modules/portfolio-margin/um-trade/getAllOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/um-trade/getAllOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginUmGetAllOrders(server: McpServer) { server.tool( @@ -38,25 +38,25 @@ export function registerPortfolioMarginUmGetAllOrders(server: McpServer) { ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Portfolio Margin UM All Orders - ${params.symbol}\n\n` + let result = `✅ Portfolio Margin UM All Orders - ${params.symbol}\n\n`; if (Array.isArray(data) && data.length > 0) { - result += `Total orders: ${data.length}\n\n` + result += `Total orders: ${data.length}\n\n`; data.slice(0, 20).forEach((order: any, index: number) => { - result += `**${index + 1}. Order ID: ${order.orderId}**\n` - result += ` Side: ${order.side} | Type: ${order.type}\n` - result += ` Price: ${order.price} | Qty: ${order.origQty}\n` - result += ` Executed: ${order.executedQty} | Status: ${order.status}\n\n` - }) + result += `**${index + 1}. Order ID: ${order.orderId}**\n`; + result += ` Side: ${order.side} | Type: ${order.type}\n`; + result += ` Price: ${order.price} | Qty: ${order.origQty}\n`; + result += ` Executed: ${order.executedQty} | Status: ${order.status}\n\n`; + }); if (data.length > 20) { - result += `... and ${data.length - 20} more orders` + result += `... and ${data.length - 20} more orders`; } } else { - result += `No orders found` + result += `No orders found`; } return { @@ -66,9 +66,9 @@ export function registerPortfolioMarginUmGetAllOrders(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -78,8 +78,8 @@ export function registerPortfolioMarginUmGetAllOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/um-trade/getOpenOrders.ts b/src/modules/portfolio-margin/um-trade/getOpenOrders.ts index 48b3c6e9..d3aa19a1 100644 --- a/src/modules/portfolio-margin/um-trade/getOpenOrders.ts +++ b/src/modules/portfolio-margin/um-trade/getOpenOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/um-trade/getOpenOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginUmGetOpenOrders(server: McpServer) { server.tool( @@ -24,24 +24,24 @@ export function registerPortfolioMarginUmGetOpenOrders(server: McpServer) { const response = await portfolioMarginClient.restAPI.umOpenOrders({ ...(params.symbol && { symbol: params.symbol }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Portfolio Margin UM Open Orders\n\n` + let result = `✅ Portfolio Margin UM Open Orders\n\n`; if (Array.isArray(data) && data.length > 0) { - result += `Total open orders: ${data.length}\n\n` + result += `Total open orders: ${data.length}\n\n`; data.forEach((order: any, index: number) => { - result += `**${index + 1}. ${order.symbol}**\n` - result += ` Order ID: ${order.orderId}\n` - result += ` Side: ${order.side} | Type: ${order.type}\n` - result += ` Price: ${order.price} | Qty: ${order.origQty}\n` - result += ` Executed: ${order.executedQty}\n` - result += ` Status: ${order.status}\n\n` - }) + result += `**${index + 1}. ${order.symbol}**\n`; + result += ` Order ID: ${order.orderId}\n`; + result += ` Side: ${order.side} | Type: ${order.type}\n`; + result += ` Price: ${order.price} | Qty: ${order.origQty}\n`; + result += ` Executed: ${order.executedQty}\n`; + result += ` Status: ${order.status}\n\n`; + }); } else { - result += `No open orders found` + result += `No open orders found`; } return { @@ -51,9 +51,9 @@ export function registerPortfolioMarginUmGetOpenOrders(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -63,8 +63,8 @@ export function registerPortfolioMarginUmGetOpenOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/um-trade/getOrder.ts b/src/modules/portfolio-margin/um-trade/getOrder.ts index af640b31..8da97df6 100644 --- a/src/modules/portfolio-margin/um-trade/getOrder.ts +++ b/src/modules/portfolio-margin/um-trade/getOrder.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/um-trade/getOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginUmGetOrder(server: McpServer) { server.tool( @@ -32,7 +32,7 @@ export function registerPortfolioMarginUmGetOrder(server: McpServer) { }, ], isError: true, - } + }; } const response = await portfolioMarginClient.restAPI.umOrder({ @@ -40,19 +40,19 @@ export function registerPortfolioMarginUmGetOrder(server: McpServer) { ...(params.orderId && { orderId: params.orderId }), ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Portfolio Margin UM Order Details\n\n` - result += `Order ID: ${data.orderId}\n` - result += `Symbol: ${data.symbol}\n` - result += `Side: ${data.side} | Type: ${data.type}\n` - result += `Price: ${data.price} | Qty: ${data.origQty}\n` - result += `Executed Qty: ${data.executedQty}\n` - result += `Avg Price: ${data.avgPrice}\n` - result += `Status: ${data.status}\n` - result += `Time: ${new Date(data.time).toISOString()}` + let result = `✅ Portfolio Margin UM Order Details\n\n`; + result += `Order ID: ${data.orderId}\n`; + result += `Symbol: ${data.symbol}\n`; + result += `Side: ${data.side} | Type: ${data.type}\n`; + result += `Price: ${data.price} | Qty: ${data.origQty}\n`; + result += `Executed Qty: ${data.executedQty}\n`; + result += `Avg Price: ${data.avgPrice}\n`; + result += `Status: ${data.status}\n`; + result += `Time: ${new Date(data.time).toISOString()}`; return { content: [ @@ -61,9 +61,9 @@ export function registerPortfolioMarginUmGetOrder(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -73,8 +73,8 @@ export function registerPortfolioMarginUmGetOrder(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/um-trade/getUserTrades.ts b/src/modules/portfolio-margin/um-trade/getUserTrades.ts index a2daa314..ede71702 100644 --- a/src/modules/portfolio-margin/um-trade/getUserTrades.ts +++ b/src/modules/portfolio-margin/um-trade/getUserTrades.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/um-trade/getUserTrades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginUmGetUserTrades(server: McpServer) { server.tool( @@ -38,28 +38,28 @@ export function registerPortfolioMarginUmGetUserTrades(server: McpServer) { ...(params.fromId && { fromId: params.fromId }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let result = `✅ Portfolio Margin UM Trade History - ${params.symbol}\n\n` + let result = `✅ Portfolio Margin UM Trade History - ${params.symbol}\n\n`; if (Array.isArray(data) && data.length > 0) { - result += `Total trades: ${data.length}\n\n` + result += `Total trades: ${data.length}\n\n`; data.slice(0, 20).forEach((trade: any, index: number) => { - result += `**${index + 1}. Trade ID: ${trade.id}**\n` - result += ` Order ID: ${trade.orderId}\n` - result += ` Side: ${trade.side} | Price: ${trade.price}\n` - result += ` Qty: ${trade.qty} | Quote Qty: ${trade.quoteQty}\n` - result += ` Realized PnL: ${trade.realizedPnl}\n` - result += ` Commission: ${trade.commission} ${trade.commissionAsset}\n` - result += ` Time: ${new Date(trade.time).toISOString()}\n\n` - }) + result += `**${index + 1}. Trade ID: ${trade.id}**\n`; + result += ` Order ID: ${trade.orderId}\n`; + result += ` Side: ${trade.side} | Price: ${trade.price}\n`; + result += ` Qty: ${trade.qty} | Quote Qty: ${trade.quoteQty}\n`; + result += ` Realized PnL: ${trade.realizedPnl}\n`; + result += ` Commission: ${trade.commission} ${trade.commissionAsset}\n`; + result += ` Time: ${new Date(trade.time).toISOString()}\n\n`; + }); if (data.length > 20) { - result += `... and ${data.length - 20} more trades` + result += `... and ${data.length - 20} more trades`; } } else { - result += `No trades found` + result += `No trades found`; } return { @@ -69,9 +69,9 @@ export function registerPortfolioMarginUmGetUserTrades(server: McpServer) { text: result, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -81,8 +81,8 @@ export function registerPortfolioMarginUmGetUserTrades(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/um-trade/index.ts b/src/modules/portfolio-margin/um-trade/index.ts index ee247537..ebbff269 100644 --- a/src/modules/portfolio-margin/um-trade/index.ts +++ b/src/modules/portfolio-margin/um-trade/index.ts @@ -5,26 +5,26 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/um-trade/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerPortfolioMarginUmCancelAllOrders } from "./cancelAllOrders.js" -import { registerPortfolioMarginUmCancelOrder } from "./cancelOrder.js" -import { registerPortfolioMarginUmChangeLeverage } from "./changeLeverage.js" -import { registerPortfolioMarginUmChangeMarginType } from "./changeMarginType.js" -import { registerPortfolioMarginUmGetAllOrders } from "./getAllOrders.js" -import { registerPortfolioMarginUmGetOpenOrders } from "./getOpenOrders.js" -import { registerPortfolioMarginUmGetOrder } from "./getOrder.js" -import { registerPortfolioMarginUmGetUserTrades } from "./getUserTrades.js" -import { registerPortfolioMarginUmNewOrder } from "./newOrder.js" +import { registerPortfolioMarginUmCancelAllOrders } from "./cancelAllOrders.js"; +import { registerPortfolioMarginUmCancelOrder } from "./cancelOrder.js"; +import { registerPortfolioMarginUmChangeLeverage } from "./changeLeverage.js"; +import { registerPortfolioMarginUmChangeMarginType } from "./changeMarginType.js"; +import { registerPortfolioMarginUmGetAllOrders } from "./getAllOrders.js"; +import { registerPortfolioMarginUmGetOpenOrders } from "./getOpenOrders.js"; +import { registerPortfolioMarginUmGetOrder } from "./getOrder.js"; +import { registerPortfolioMarginUmGetUserTrades } from "./getUserTrades.js"; +import { registerPortfolioMarginUmNewOrder } from "./newOrder.js"; export function registerPortfolioMarginUmTradeApi(server: McpServer) { - registerPortfolioMarginUmNewOrder(server) - registerPortfolioMarginUmCancelOrder(server) - registerPortfolioMarginUmCancelAllOrders(server) - registerPortfolioMarginUmGetOrder(server) - registerPortfolioMarginUmGetAllOrders(server) - registerPortfolioMarginUmGetOpenOrders(server) - registerPortfolioMarginUmGetUserTrades(server) - registerPortfolioMarginUmChangeLeverage(server) - registerPortfolioMarginUmChangeMarginType(server) + registerPortfolioMarginUmNewOrder(server); + registerPortfolioMarginUmCancelOrder(server); + registerPortfolioMarginUmCancelAllOrders(server); + registerPortfolioMarginUmGetOrder(server); + registerPortfolioMarginUmGetAllOrders(server); + registerPortfolioMarginUmGetOpenOrders(server); + registerPortfolioMarginUmGetUserTrades(server); + registerPortfolioMarginUmChangeLeverage(server); + registerPortfolioMarginUmChangeMarginType(server); } diff --git a/src/modules/portfolio-margin/um-trade/newOrder.ts b/src/modules/portfolio-margin/um-trade/newOrder.ts index 3954aab0..62a1eb0b 100644 --- a/src/modules/portfolio-margin/um-trade/newOrder.ts +++ b/src/modules/portfolio-margin/um-trade/newOrder.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/um-trade/newOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginUmNewOrder(server: McpServer) { server.tool( @@ -55,9 +55,9 @@ export function registerPortfolioMarginUmNewOrder(server: McpServer) { ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), ...(params.positionSide && { positionSide: params.positionSide }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -66,9 +66,9 @@ export function registerPortfolioMarginUmNewOrder(server: McpServer) { text: `✅ Portfolio Margin UM Order Placed!\n\nOrder ID: ${data.orderId}\nSymbol: ${data.symbol}\nSide: ${data.side}\nType: ${data.type}\nQuantity: ${data.origQty}\nPrice: ${data.price || "MARKET"}\nStatus: ${data.status}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -78,8 +78,8 @@ export function registerPortfolioMarginUmNewOrder(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/userdata/createListenKey.ts b/src/modules/portfolio-margin/userdata/createListenKey.ts index fde32ec0..322fa887 100644 --- a/src/modules/portfolio-margin/userdata/createListenKey.ts +++ b/src/modules/portfolio-margin/userdata/createListenKey.ts @@ -5,9 +5,9 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/userdata/createListenKey.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginCreateListenKey(server: McpServer) { server.tool( @@ -16,8 +16,8 @@ export function registerPortfolioMarginCreateListenKey(server: McpServer) { {}, async () => { try { - const response = await portfolioMarginClient.restAPI.createListenKey() - const data = await response.data() + const response = await portfolioMarginClient.restAPI.createListenKey(); + const data = await response.data(); return { content: [ @@ -26,9 +26,9 @@ export function registerPortfolioMarginCreateListenKey(server: McpServer) { text: `✅ Portfolio Margin Listen Key Created\n\nListen Key: ${data.listenKey}\n\n**Note**: This listen key is valid for 60 minutes. Use BinancePortfolioMarginRenewListenKey to extend validity.`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -38,8 +38,8 @@ export function registerPortfolioMarginCreateListenKey(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/userdata/deleteListenKey.ts b/src/modules/portfolio-margin/userdata/deleteListenKey.ts index 46df9ad5..76f0324b 100644 --- a/src/modules/portfolio-margin/userdata/deleteListenKey.ts +++ b/src/modules/portfolio-margin/userdata/deleteListenKey.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/userdata/deleteListenKey.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginDeleteListenKey(server: McpServer) { server.tool( @@ -22,8 +22,8 @@ export function registerPortfolioMarginDeleteListenKey(server: McpServer) { try { const response = await portfolioMarginClient.restAPI.deleteListenKey({ ...(params.listenKey && { listenKey: params.listenKey }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -32,9 +32,9 @@ export function registerPortfolioMarginDeleteListenKey(server: McpServer) { text: `✅ Portfolio Margin Listen Key Deleted\n\nThe listen key has been invalidated.\n\nResponse: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -44,8 +44,8 @@ export function registerPortfolioMarginDeleteListenKey(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/portfolio-margin/userdata/index.ts b/src/modules/portfolio-margin/userdata/index.ts index 5cf34224..d66fc97c 100644 --- a/src/modules/portfolio-margin/userdata/index.ts +++ b/src/modules/portfolio-margin/userdata/index.ts @@ -5,14 +5,14 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/userdata/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerPortfolioMarginCreateListenKey } from "./createListenKey.js" -import { registerPortfolioMarginDeleteListenKey } from "./deleteListenKey.js" -import { registerPortfolioMarginRenewListenKey } from "./renewListenKey.js" +import { registerPortfolioMarginCreateListenKey } from "./createListenKey.js"; +import { registerPortfolioMarginDeleteListenKey } from "./deleteListenKey.js"; +import { registerPortfolioMarginRenewListenKey } from "./renewListenKey.js"; export function registerPortfolioMarginUserdataApi(server: McpServer) { - registerPortfolioMarginCreateListenKey(server) - registerPortfolioMarginRenewListenKey(server) - registerPortfolioMarginDeleteListenKey(server) + registerPortfolioMarginCreateListenKey(server); + registerPortfolioMarginRenewListenKey(server); + registerPortfolioMarginDeleteListenKey(server); } diff --git a/src/modules/portfolio-margin/userdata/renewListenKey.ts b/src/modules/portfolio-margin/userdata/renewListenKey.ts index f1da3d9d..69b4cb68 100644 --- a/src/modules/portfolio-margin/userdata/renewListenKey.ts +++ b/src/modules/portfolio-margin/userdata/renewListenKey.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/portfolio-margin/userdata/renewListenKey.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../../config/binanceClient.js" +import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginRenewListenKey(server: McpServer) { server.tool( @@ -22,8 +22,8 @@ export function registerPortfolioMarginRenewListenKey(server: McpServer) { try { const response = await portfolioMarginClient.restAPI.renewListenKey({ ...(params.listenKey && { listenKey: params.listenKey }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -32,9 +32,9 @@ export function registerPortfolioMarginRenewListenKey(server: McpServer) { text: `✅ Portfolio Margin Listen Key Renewed\n\nThe listen key validity has been extended by 60 minutes.\n\nResponse: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -44,8 +44,8 @@ export function registerPortfolioMarginRenewListenKey(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/rebate/index.ts b/src/modules/rebate/index.ts index bd20b0df..5a20e726 100644 --- a/src/modules/rebate/index.ts +++ b/src/modules/rebate/index.ts @@ -1,11 +1,11 @@ // src/tools/binance-rebate/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetSpotRebateHistoryRecords } from "./rebate-api/getSpotRebateHistoryRecords.js" +import { registerBinanceGetSpotRebateHistoryRecords } from "./rebate-api/getSpotRebateHistoryRecords.js"; export function registerBinanceRebateTools(server: McpServer) { - registerBinanceGetSpotRebateHistoryRecords(server) + registerBinanceGetSpotRebateHistoryRecords(server); } // Alias for binance.ts compatibility -export { registerBinanceRebateTools as registerRebate } +export { registerBinanceRebateTools as registerRebate }; diff --git a/src/modules/rebate/rebate-api/getSpotRebateHistoryRecords.ts b/src/modules/rebate/rebate-api/getSpotRebateHistoryRecords.ts index 9a5e6b22..e0855594 100644 --- a/src/modules/rebate/rebate-api/getSpotRebateHistoryRecords.ts +++ b/src/modules/rebate/rebate-api/getSpotRebateHistoryRecords.ts @@ -1,9 +1,9 @@ // src/tools/binance-pay/rebate-api/getSpotRebateHistoryRecords.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { rebateClient } from "../../../config/binanceClient.js" +import { rebateClient } from "../../../config/binanceClient.js"; export function registerBinanceGetSpotRebateHistoryRecords(server: McpServer) { server.tool( @@ -22,9 +22,9 @@ export function registerBinanceGetSpotRebateHistoryRecords(server: McpServer) { ...(params.endTime && { endTime: params.endTime }), ...(params.page && { page: params.page }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,9 +35,9 @@ export function registerBinanceGetSpotRebateHistoryRecords(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -47,8 +47,8 @@ export function registerBinanceGetSpotRebateHistoryRecords(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/simple-earn/account-api/getFlexibleProductPosition.ts b/src/modules/simple-earn/account-api/getFlexibleProductPosition.ts index 5f2208fc..3b657330 100644 --- a/src/modules/simple-earn/account-api/getFlexibleProductPosition.ts +++ b/src/modules/simple-earn/account-api/getFlexibleProductPosition.ts @@ -1,9 +1,9 @@ // src/tools/binance-simple-earn/account-api/getFlexibleProductPosition.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { simpleEarnClient } from "../../../config/binanceClient.js" +import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerBinanceGetFlexibleProductPosition(server: McpServer) { server.tool( @@ -37,9 +37,9 @@ export function registerBinanceGetFlexibleProductPosition(server: McpServer) { ...(params.current && { current: params.current }), ...(params.size && { size: params.size }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -50,9 +50,9 @@ export function registerBinanceGetFlexibleProductPosition(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -62,8 +62,8 @@ export function registerBinanceGetFlexibleProductPosition(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/simple-earn/account-api/index.ts b/src/modules/simple-earn/account-api/index.ts index c3800c9b..ce694ad7 100644 --- a/src/modules/simple-earn/account-api/index.ts +++ b/src/modules/simple-earn/account-api/index.ts @@ -1,13 +1,13 @@ // src/tools/binance-simple-earn/account-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetFlexibleProductPosition } from "./getFlexibleProductPosition.js" -import { registerBinanceSimpleEarnFlexibleProductList } from "./simpleEarnFlexibleProductList.js" +import { registerBinanceGetFlexibleProductPosition } from "./getFlexibleProductPosition.js"; +import { registerBinanceSimpleEarnFlexibleProductList } from "./simpleEarnFlexibleProductList.js"; export function registerBinanceSimpleEarnAccountApiTools(server: McpServer) { // Registers a tool to get the list of flexible earning products - registerBinanceSimpleEarnFlexibleProductList(server) + registerBinanceSimpleEarnFlexibleProductList(server); // Registers a tool to get the user's position in flexible earning products - registerBinanceGetFlexibleProductPosition(server) + registerBinanceGetFlexibleProductPosition(server); } diff --git a/src/modules/simple-earn/account-api/simpleEarnFlexibleProductList.ts b/src/modules/simple-earn/account-api/simpleEarnFlexibleProductList.ts index a76d9793..0ad34c15 100644 --- a/src/modules/simple-earn/account-api/simpleEarnFlexibleProductList.ts +++ b/src/modules/simple-earn/account-api/simpleEarnFlexibleProductList.ts @@ -1,9 +1,9 @@ // src/tools/binance-simple-earn/account-api/simpleEarnFlexibleProductList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { simpleEarnClient } from "../../../config/binanceClient.js" +import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerBinanceSimpleEarnFlexibleProductList(server: McpServer) { server.tool( @@ -35,9 +35,9 @@ export function registerBinanceSimpleEarnFlexibleProductList(server: McpServer) ...(params.current && { current: params.current }), ...(params.size && { size: params.size }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -48,9 +48,9 @@ export function registerBinanceSimpleEarnFlexibleProductList(server: McpServer) )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -60,8 +60,8 @@ export function registerBinanceSimpleEarnFlexibleProductList(server: McpServer) }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/simple-earn/account/getAccount.ts b/src/modules/simple-earn/account/getAccount.ts index 35ae6815..68f3c7c1 100644 --- a/src/modules/simple-earn/account/getAccount.ts +++ b/src/modules/simple-earn/account/getAccount.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/simple-earn/account/getAccount.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { simpleEarnClient } from "../../../config/binanceClient.js" +import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnAccount(server: McpServer) { server.tool( @@ -22,9 +22,9 @@ export function registerSimpleEarnAccount(server: McpServer) { try { const response = await simpleEarnClient.restAPI.getSimpleEarnAccount({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -33,9 +33,9 @@ export function registerSimpleEarnAccount(server: McpServer) { text: `💰 Simple Earn Account Overview\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -45,8 +45,8 @@ export function registerSimpleEarnAccount(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/simple-earn/account/getCollateralRecord.ts b/src/modules/simple-earn/account/getCollateralRecord.ts index 3fde64c5..8f935693 100644 --- a/src/modules/simple-earn/account/getCollateralRecord.ts +++ b/src/modules/simple-earn/account/getCollateralRecord.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/simple-earn/account/getCollateralRecord.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { simpleEarnClient } from "../../../config/binanceClient.js" +import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnCollateralRecord(server: McpServer) { server.tool( @@ -34,9 +34,9 @@ export function registerSimpleEarnCollateralRecord(server: McpServer) { ...(params.current && { current: params.current }), ...(params.size && { size: params.size }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -45,9 +45,9 @@ export function registerSimpleEarnCollateralRecord(server: McpServer) { text: `📜 Collateral Records\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -57,8 +57,8 @@ export function registerSimpleEarnCollateralRecord(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/simple-earn/account/getRewardRecord.ts b/src/modules/simple-earn/account/getRewardRecord.ts index ab07dbfa..5f334819 100644 --- a/src/modules/simple-earn/account/getRewardRecord.ts +++ b/src/modules/simple-earn/account/getRewardRecord.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/simple-earn/account/getRewardRecord.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { simpleEarnClient } from "../../../config/binanceClient.js" +import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnRewardRecord(server: McpServer) { server.tool( @@ -36,9 +36,9 @@ export function registerSimpleEarnRewardRecord(server: McpServer) { ...(params.current && { current: params.current }), ...(params.size && { size: params.size }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -47,9 +47,9 @@ export function registerSimpleEarnRewardRecord(server: McpServer) { text: `🎁 Reward Records\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -59,8 +59,8 @@ export function registerSimpleEarnRewardRecord(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/simple-earn/account/index.ts b/src/modules/simple-earn/account/index.ts index 8b481963..cff375cf 100644 --- a/src/modules/simple-earn/account/index.ts +++ b/src/modules/simple-earn/account/index.ts @@ -5,14 +5,14 @@ * @license Apache-2.0 */ // src/modules/simple-earn/account/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerSimpleEarnAccount } from "./getAccount.js" -import { registerSimpleEarnCollateralRecord } from "./getCollateralRecord.js" -import { registerSimpleEarnRewardRecord } from "./getRewardRecord.js" +import { registerSimpleEarnAccount } from "./getAccount.js"; +import { registerSimpleEarnCollateralRecord } from "./getCollateralRecord.js"; +import { registerSimpleEarnRewardRecord } from "./getRewardRecord.js"; export function registerSimpleEarnAccountTools(server: McpServer) { - registerSimpleEarnAccount(server) - registerSimpleEarnCollateralRecord(server) - registerSimpleEarnRewardRecord(server) + registerSimpleEarnAccount(server); + registerSimpleEarnCollateralRecord(server); + registerSimpleEarnRewardRecord(server); } diff --git a/src/modules/simple-earn/earn-api/index.ts b/src/modules/simple-earn/earn-api/index.ts index 219084b7..3c1f18b4 100644 --- a/src/modules/simple-earn/earn-api/index.ts +++ b/src/modules/simple-earn/earn-api/index.ts @@ -1,13 +1,13 @@ // src/tools/binance-simple-earn/earn-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceRedeemFlexibleProduct } from "./redeemFlexibleProduct.js" -import { registerBinanceSubscribeFlexibleProduct } from "./subscribeFlexibleProduct.js" +import { registerBinanceRedeemFlexibleProduct } from "./redeemFlexibleProduct.js"; +import { registerBinanceSubscribeFlexibleProduct } from "./subscribeFlexibleProduct.js"; export function registerBinanceSimpleEarnApiTools(server: McpServer) { // Register the route for subscribing to a flexible earn product - registerBinanceSubscribeFlexibleProduct(server) + registerBinanceSubscribeFlexibleProduct(server); // Register the route for redeeming from a flexible earn product - registerBinanceRedeemFlexibleProduct(server) + registerBinanceRedeemFlexibleProduct(server); } diff --git a/src/modules/simple-earn/earn-api/redeemFlexibleProduct.ts b/src/modules/simple-earn/earn-api/redeemFlexibleProduct.ts index bdb4d1cc..0ffd3e25 100644 --- a/src/modules/simple-earn/earn-api/redeemFlexibleProduct.ts +++ b/src/modules/simple-earn/earn-api/redeemFlexibleProduct.ts @@ -1,9 +1,9 @@ // src/tools/binance-simple-earn/earn-api/redeemFlexibleProduct.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { simpleEarnClient } from "../../../config/binanceClient.js" +import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerBinanceRedeemFlexibleProduct(server: McpServer) { server.tool( @@ -25,7 +25,7 @@ export function registerBinanceRedeemFlexibleProduct(server: McpServer) { }, async (params) => { try { - const { productId, redeemAll = false, amount, destAccount, recvWindow } = params + const { productId, redeemAll = false, amount, destAccount, recvWindow } = params; // Defensive check if (!redeemAll && (amount === undefined || amount <= 0)) { @@ -37,7 +37,7 @@ export function registerBinanceRedeemFlexibleProduct(server: McpServer) { }, ], isError: true, - } + }; } const response = await simpleEarnClient.restAPI.redeemFlexibleProduct({ @@ -46,9 +46,9 @@ export function registerBinanceRedeemFlexibleProduct(server: McpServer) { ...(amount !== undefined && { amount }), ...(destAccount && { destAccount }), ...(recvWindow && { recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -59,9 +59,9 @@ export function registerBinanceRedeemFlexibleProduct(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -71,8 +71,8 @@ export function registerBinanceRedeemFlexibleProduct(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/simple-earn/earn-api/subscribeFlexibleProduct.ts b/src/modules/simple-earn/earn-api/subscribeFlexibleProduct.ts index 3532c8eb..7d269ed4 100644 --- a/src/modules/simple-earn/earn-api/subscribeFlexibleProduct.ts +++ b/src/modules/simple-earn/earn-api/subscribeFlexibleProduct.ts @@ -1,9 +1,9 @@ // src/tools/binance-simple-earn/earn-api/subscribeFlexibleProduct.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { simpleEarnClient } from "../../../config/binanceClient.js" +import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerBinanceSubscribeFlexibleProduct(server: McpServer) { server.tool( @@ -27,9 +27,9 @@ export function registerBinanceSubscribeFlexibleProduct(server: McpServer) { ...(params.autoSubscribe !== undefined && { autoSubscribe: params.autoSubscribe }), ...(params.sourceAccount && { sourceAccount: params.sourceAccount }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -40,9 +40,9 @@ export function registerBinanceSubscribeFlexibleProduct(server: McpServer) { } and amount${params.amount}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -52,8 +52,8 @@ export function registerBinanceSubscribeFlexibleProduct(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/simple-earn/flexible/getFlexiblePosition.ts b/src/modules/simple-earn/flexible/getFlexiblePosition.ts index c9328fc6..a8a7f377 100644 --- a/src/modules/simple-earn/flexible/getFlexiblePosition.ts +++ b/src/modules/simple-earn/flexible/getFlexiblePosition.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/simple-earn/flexible/getFlexiblePosition.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { simpleEarnClient } from "../../../config/binanceClient.js" +import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnFlexiblePosition(server: McpServer) { server.tool( @@ -30,9 +30,9 @@ export function registerSimpleEarnFlexiblePosition(server: McpServer) { ...(params.current && { current: params.current }), ...(params.size && { size: params.size }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -41,9 +41,9 @@ export function registerSimpleEarnFlexiblePosition(server: McpServer) { text: `📊 Your Flexible Earn Positions\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -53,8 +53,8 @@ export function registerSimpleEarnFlexiblePosition(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/simple-earn/flexible/getFlexibleProductList.ts b/src/modules/simple-earn/flexible/getFlexibleProductList.ts index 3f066cef..fa33b856 100644 --- a/src/modules/simple-earn/flexible/getFlexibleProductList.ts +++ b/src/modules/simple-earn/flexible/getFlexibleProductList.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/simple-earn/flexible/getFlexibleProductList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { simpleEarnClient } from "../../../config/binanceClient.js" +import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnFlexibleProductList(server: McpServer) { server.tool( @@ -34,9 +34,9 @@ export function registerSimpleEarnFlexibleProductList(server: McpServer) { ...(params.current && { current: params.current }), ...(params.size && { size: params.size }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -45,9 +45,9 @@ export function registerSimpleEarnFlexibleProductList(server: McpServer) { text: `📋 Simple Earn Flexible Products\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -57,8 +57,8 @@ export function registerSimpleEarnFlexibleProductList(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/simple-earn/flexible/getFlexibleSubscriptionPreview.ts b/src/modules/simple-earn/flexible/getFlexibleSubscriptionPreview.ts index 3021571e..52870c41 100644 --- a/src/modules/simple-earn/flexible/getFlexibleSubscriptionPreview.ts +++ b/src/modules/simple-earn/flexible/getFlexibleSubscriptionPreview.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/simple-earn/flexible/getFlexibleSubscriptionPreview.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { simpleEarnClient } from "../../../config/binanceClient.js" +import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnFlexibleSubscriptionPreview(server: McpServer) { server.tool( @@ -26,9 +26,9 @@ export function registerSimpleEarnFlexibleSubscriptionPreview(server: McpServer) productId: params.productId, amount: params.amount, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -37,9 +37,9 @@ export function registerSimpleEarnFlexibleSubscriptionPreview(server: McpServer) text: `🔮 Subscription Preview\n\nProduct ID: ${params.productId}\nAmount: ${params.amount}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -49,8 +49,8 @@ export function registerSimpleEarnFlexibleSubscriptionPreview(server: McpServer) }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/simple-earn/flexible/getRateHistory.ts b/src/modules/simple-earn/flexible/getRateHistory.ts index b45a4799..2417d689 100644 --- a/src/modules/simple-earn/flexible/getRateHistory.ts +++ b/src/modules/simple-earn/flexible/getRateHistory.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/simple-earn/flexible/getRateHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { simpleEarnClient } from "../../../config/binanceClient.js" +import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnFlexibleRateHistory(server: McpServer) { server.tool( @@ -32,9 +32,9 @@ export function registerSimpleEarnFlexibleRateHistory(server: McpServer) { ...(params.current && { current: params.current }), ...(params.size && { size: params.size }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -43,9 +43,9 @@ export function registerSimpleEarnFlexibleRateHistory(server: McpServer) { text: `📈 Flexible Product Rate History\n\nProduct ID: ${params.productId}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -55,8 +55,8 @@ export function registerSimpleEarnFlexibleRateHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/simple-earn/flexible/getRedemptionRecord.ts b/src/modules/simple-earn/flexible/getRedemptionRecord.ts index 45f3910b..17af75ef 100644 --- a/src/modules/simple-earn/flexible/getRedemptionRecord.ts +++ b/src/modules/simple-earn/flexible/getRedemptionRecord.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/simple-earn/flexible/getRedemptionRecord.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { simpleEarnClient } from "../../../config/binanceClient.js" +import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnFlexibleRedemptionRecord(server: McpServer) { server.tool( @@ -36,9 +36,9 @@ export function registerSimpleEarnFlexibleRedemptionRecord(server: McpServer) { ...(params.current && { current: params.current }), ...(params.size && { size: params.size }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -47,9 +47,9 @@ export function registerSimpleEarnFlexibleRedemptionRecord(server: McpServer) { text: `📜 Flexible Redemption Records\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -59,8 +59,8 @@ export function registerSimpleEarnFlexibleRedemptionRecord(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/simple-earn/flexible/getSubscriptionRecord.ts b/src/modules/simple-earn/flexible/getSubscriptionRecord.ts index d7405194..c4fd3460 100644 --- a/src/modules/simple-earn/flexible/getSubscriptionRecord.ts +++ b/src/modules/simple-earn/flexible/getSubscriptionRecord.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/simple-earn/flexible/getSubscriptionRecord.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { simpleEarnClient } from "../../../config/binanceClient.js" +import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnFlexibleSubscriptionRecord(server: McpServer) { server.tool( @@ -36,9 +36,9 @@ export function registerSimpleEarnFlexibleSubscriptionRecord(server: McpServer) ...(params.current && { current: params.current }), ...(params.size && { size: params.size }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -47,9 +47,9 @@ export function registerSimpleEarnFlexibleSubscriptionRecord(server: McpServer) text: `📜 Flexible Subscription Records\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -59,8 +59,8 @@ export function registerSimpleEarnFlexibleSubscriptionRecord(server: McpServer) }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/simple-earn/flexible/index.ts b/src/modules/simple-earn/flexible/index.ts index 097acc91..26818904 100644 --- a/src/modules/simple-earn/flexible/index.ts +++ b/src/modules/simple-earn/flexible/index.ts @@ -5,24 +5,24 @@ * @license Apache-2.0 */ // src/modules/simple-earn/flexible/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerSimpleEarnFlexiblePosition } from "./getFlexiblePosition.js" -import { registerSimpleEarnFlexibleProductList } from "./getFlexibleProductList.js" -import { registerSimpleEarnFlexibleSubscriptionPreview } from "./getFlexibleSubscriptionPreview.js" -import { registerSimpleEarnFlexibleRateHistory } from "./getRateHistory.js" -import { registerSimpleEarnFlexibleRedemptionRecord } from "./getRedemptionRecord.js" -import { registerSimpleEarnFlexibleSubscriptionRecord } from "./getSubscriptionRecord.js" -import { registerSimpleEarnRedeemFlexible } from "./redeemFlexible.js" -import { registerSimpleEarnSubscribeFlexible } from "./subscribeFlexible.js" +import { registerSimpleEarnFlexiblePosition } from "./getFlexiblePosition.js"; +import { registerSimpleEarnFlexibleProductList } from "./getFlexibleProductList.js"; +import { registerSimpleEarnFlexibleSubscriptionPreview } from "./getFlexibleSubscriptionPreview.js"; +import { registerSimpleEarnFlexibleRateHistory } from "./getRateHistory.js"; +import { registerSimpleEarnFlexibleRedemptionRecord } from "./getRedemptionRecord.js"; +import { registerSimpleEarnFlexibleSubscriptionRecord } from "./getSubscriptionRecord.js"; +import { registerSimpleEarnRedeemFlexible } from "./redeemFlexible.js"; +import { registerSimpleEarnSubscribeFlexible } from "./subscribeFlexible.js"; export function registerSimpleEarnFlexibleTools(server: McpServer) { - registerSimpleEarnFlexibleProductList(server) - registerSimpleEarnSubscribeFlexible(server) - registerSimpleEarnRedeemFlexible(server) - registerSimpleEarnFlexiblePosition(server) - registerSimpleEarnFlexibleSubscriptionPreview(server) - registerSimpleEarnFlexibleRateHistory(server) - registerSimpleEarnFlexibleSubscriptionRecord(server) - registerSimpleEarnFlexibleRedemptionRecord(server) + registerSimpleEarnFlexibleProductList(server); + registerSimpleEarnSubscribeFlexible(server); + registerSimpleEarnRedeemFlexible(server); + registerSimpleEarnFlexiblePosition(server); + registerSimpleEarnFlexibleSubscriptionPreview(server); + registerSimpleEarnFlexibleRateHistory(server); + registerSimpleEarnFlexibleSubscriptionRecord(server); + registerSimpleEarnFlexibleRedemptionRecord(server); } diff --git a/src/modules/simple-earn/flexible/redeemFlexible.ts b/src/modules/simple-earn/flexible/redeemFlexible.ts index 30602c48..01015463 100644 --- a/src/modules/simple-earn/flexible/redeemFlexible.ts +++ b/src/modules/simple-earn/flexible/redeemFlexible.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/simple-earn/flexible/redeemFlexible.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { simpleEarnClient } from "../../../config/binanceClient.js" +import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnRedeemFlexible(server: McpServer) { server.tool( @@ -37,9 +37,9 @@ export function registerSimpleEarnRedeemFlexible(server: McpServer) { ...(params.amount && { amount: params.amount }), ...(params.destAccount && { destAccount: params.destAccount }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -48,9 +48,9 @@ export function registerSimpleEarnRedeemFlexible(server: McpServer) { text: `✅ Flexible Product Redemption Successful!\n\nProduct ID: ${params.productId}\nAmount: ${params.redeemAll ? "All" : params.amount}\nRedemption ID: ${data.redeemId || "N/A"}\n\n💡 Funds will be credited to your ${params.destAccount || "SPOT"} account shortly.`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -60,8 +60,8 @@ export function registerSimpleEarnRedeemFlexible(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/simple-earn/flexible/subscribeFlexible.ts b/src/modules/simple-earn/flexible/subscribeFlexible.ts index 4f381a8f..4ccc384a 100644 --- a/src/modules/simple-earn/flexible/subscribeFlexible.ts +++ b/src/modules/simple-earn/flexible/subscribeFlexible.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/simple-earn/flexible/subscribeFlexible.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { simpleEarnClient } from "../../../config/binanceClient.js" +import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnSubscribeFlexible(server: McpServer) { server.tool( @@ -36,9 +36,9 @@ export function registerSimpleEarnSubscribeFlexible(server: McpServer) { ...(params.autoSubscribe !== undefined && { autoSubscribe: params.autoSubscribe }), ...(params.sourceAccount && { sourceAccount: params.sourceAccount }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -47,9 +47,9 @@ export function registerSimpleEarnSubscribeFlexible(server: McpServer) { text: `✅ Flexible Product Subscription Successful!\n\nProduct ID: ${params.productId}\nAmount: ${params.amount}\nPurchase ID: ${data.purchaseId || "N/A"}\n\n💡 Your funds will start earning rewards within 24 hours.`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -59,8 +59,8 @@ export function registerSimpleEarnSubscribeFlexible(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/simple-earn/index.ts b/src/modules/simple-earn/index.ts index a50c7ea9..ce4705ac 100644 --- a/src/modules/simple-earn/index.ts +++ b/src/modules/simple-earn/index.ts @@ -1,16 +1,16 @@ // src/tools/binance-simple-earn/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceSimpleEarnAccountApiTools } from "./account-api/index.js" -import { registerBinanceSimpleEarnApiTools } from "./earn-api/index.js" +import { registerBinanceSimpleEarnAccountApiTools } from "./account-api/index.js"; +import { registerBinanceSimpleEarnApiTools } from "./earn-api/index.js"; export function registerBinanceSimpleEarnTools(server: McpServer) { // Registers core API tools like subscribing to flexible products - registerBinanceSimpleEarnApiTools(server) + registerBinanceSimpleEarnApiTools(server); // Registers account-related tools like viewing product lists and positions - registerBinanceSimpleEarnAccountApiTools(server) + registerBinanceSimpleEarnAccountApiTools(server); } // Alias for binance.ts compatibility -export { registerBinanceSimpleEarnTools as registerSimpleEarn } +export { registerBinanceSimpleEarnTools as registerSimpleEarn }; diff --git a/src/modules/simple-earn/locked/getLockedPersonalQuota.ts b/src/modules/simple-earn/locked/getLockedPersonalQuota.ts index ee55e664..5a94f6d9 100644 --- a/src/modules/simple-earn/locked/getLockedPersonalQuota.ts +++ b/src/modules/simple-earn/locked/getLockedPersonalQuota.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/simple-earn/locked/getLockedPersonalQuota.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { simpleEarnClient } from "../../../config/binanceClient.js" +import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnLockedPersonalQuota(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerSimpleEarnLockedPersonalQuota(server: McpServer) { const response = await simpleEarnClient.restAPI.getLockedPersonalLeftQuota({ projectId: params.projectId, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,9 +35,9 @@ export function registerSimpleEarnLockedPersonalQuota(server: McpServer) { text: `📊 Personal Quota for Project ${params.projectId}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -47,8 +47,8 @@ export function registerSimpleEarnLockedPersonalQuota(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/simple-earn/locked/getLockedPosition.ts b/src/modules/simple-earn/locked/getLockedPosition.ts index 65ce81e2..d7ae6a68 100644 --- a/src/modules/simple-earn/locked/getLockedPosition.ts +++ b/src/modules/simple-earn/locked/getLockedPosition.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/simple-earn/locked/getLockedPosition.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { simpleEarnClient } from "../../../config/binanceClient.js" +import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnLockedPosition(server: McpServer) { server.tool( @@ -32,9 +32,9 @@ export function registerSimpleEarnLockedPosition(server: McpServer) { ...(params.current && { current: params.current }), ...(params.size && { size: params.size }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -43,9 +43,9 @@ export function registerSimpleEarnLockedPosition(server: McpServer) { text: `📊 Your Locked Earn Positions\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -55,8 +55,8 @@ export function registerSimpleEarnLockedPosition(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/simple-earn/locked/getLockedProductList.ts b/src/modules/simple-earn/locked/getLockedProductList.ts index ed0d2208..3df600b1 100644 --- a/src/modules/simple-earn/locked/getLockedProductList.ts +++ b/src/modules/simple-earn/locked/getLockedProductList.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/simple-earn/locked/getLockedProductList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { simpleEarnClient } from "../../../config/binanceClient.js" +import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnLockedProductList(server: McpServer) { server.tool( @@ -34,9 +34,9 @@ export function registerSimpleEarnLockedProductList(server: McpServer) { ...(params.current && { current: params.current }), ...(params.size && { size: params.size }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -45,9 +45,9 @@ export function registerSimpleEarnLockedProductList(server: McpServer) { text: `📋 Simple Earn Locked Products\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -57,8 +57,8 @@ export function registerSimpleEarnLockedProductList(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/simple-earn/locked/getLockedSubscriptionPreview.ts b/src/modules/simple-earn/locked/getLockedSubscriptionPreview.ts index a3be3f6c..d609758a 100644 --- a/src/modules/simple-earn/locked/getLockedSubscriptionPreview.ts +++ b/src/modules/simple-earn/locked/getLockedSubscriptionPreview.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/simple-earn/locked/getLockedSubscriptionPreview.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { simpleEarnClient } from "../../../config/binanceClient.js" +import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnLockedSubscriptionPreview(server: McpServer) { server.tool( @@ -28,9 +28,9 @@ export function registerSimpleEarnLockedSubscriptionPreview(server: McpServer) { amount: params.amount, ...(params.autoSubscribe !== undefined && { autoSubscribe: params.autoSubscribe }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -39,9 +39,9 @@ export function registerSimpleEarnLockedSubscriptionPreview(server: McpServer) { text: `🔮 Locked Subscription Preview\n\nProject ID: ${params.projectId}\nAmount: ${params.amount}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -51,8 +51,8 @@ export function registerSimpleEarnLockedSubscriptionPreview(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/simple-earn/locked/getRedemptionRecord.ts b/src/modules/simple-earn/locked/getRedemptionRecord.ts index f868f809..bd6c6152 100644 --- a/src/modules/simple-earn/locked/getRedemptionRecord.ts +++ b/src/modules/simple-earn/locked/getRedemptionRecord.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/simple-earn/locked/getRedemptionRecord.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { simpleEarnClient } from "../../../config/binanceClient.js" +import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnLockedRedemptionRecord(server: McpServer) { server.tool( @@ -36,9 +36,9 @@ export function registerSimpleEarnLockedRedemptionRecord(server: McpServer) { ...(params.current && { current: params.current }), ...(params.size && { size: params.size }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -47,9 +47,9 @@ export function registerSimpleEarnLockedRedemptionRecord(server: McpServer) { text: `📜 Locked Redemption Records\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -59,8 +59,8 @@ export function registerSimpleEarnLockedRedemptionRecord(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/simple-earn/locked/getSubscriptionRecord.ts b/src/modules/simple-earn/locked/getSubscriptionRecord.ts index d2032293..e968deae 100644 --- a/src/modules/simple-earn/locked/getSubscriptionRecord.ts +++ b/src/modules/simple-earn/locked/getSubscriptionRecord.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/simple-earn/locked/getSubscriptionRecord.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { simpleEarnClient } from "../../../config/binanceClient.js" +import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnLockedSubscriptionRecord(server: McpServer) { server.tool( @@ -34,9 +34,9 @@ export function registerSimpleEarnLockedSubscriptionRecord(server: McpServer) { ...(params.current && { current: params.current }), ...(params.size && { size: params.size }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -45,9 +45,9 @@ export function registerSimpleEarnLockedSubscriptionRecord(server: McpServer) { text: `📜 Locked Subscription Records\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -57,8 +57,8 @@ export function registerSimpleEarnLockedSubscriptionRecord(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/simple-earn/locked/index.ts b/src/modules/simple-earn/locked/index.ts index bea4c81c..a404ca4d 100644 --- a/src/modules/simple-earn/locked/index.ts +++ b/src/modules/simple-earn/locked/index.ts @@ -5,26 +5,26 @@ * @license Apache-2.0 */ // src/modules/simple-earn/locked/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerSimpleEarnLockedPersonalQuota } from "./getLockedPersonalQuota.js" -import { registerSimpleEarnLockedPosition } from "./getLockedPosition.js" -import { registerSimpleEarnLockedProductList } from "./getLockedProductList.js" -import { registerSimpleEarnLockedSubscriptionPreview } from "./getLockedSubscriptionPreview.js" -import { registerSimpleEarnLockedRedemptionRecord } from "./getRedemptionRecord.js" -import { registerSimpleEarnLockedSubscriptionRecord } from "./getSubscriptionRecord.js" -import { registerSimpleEarnRedeemLocked } from "./redeemLocked.js" -import { registerSimpleEarnSetAutoSubscribe } from "./setAutoSubscribe.js" -import { registerSimpleEarnSubscribeLocked } from "./subscribeLocked.js" +import { registerSimpleEarnLockedPersonalQuota } from "./getLockedPersonalQuota.js"; +import { registerSimpleEarnLockedPosition } from "./getLockedPosition.js"; +import { registerSimpleEarnLockedProductList } from "./getLockedProductList.js"; +import { registerSimpleEarnLockedSubscriptionPreview } from "./getLockedSubscriptionPreview.js"; +import { registerSimpleEarnLockedRedemptionRecord } from "./getRedemptionRecord.js"; +import { registerSimpleEarnLockedSubscriptionRecord } from "./getSubscriptionRecord.js"; +import { registerSimpleEarnRedeemLocked } from "./redeemLocked.js"; +import { registerSimpleEarnSetAutoSubscribe } from "./setAutoSubscribe.js"; +import { registerSimpleEarnSubscribeLocked } from "./subscribeLocked.js"; export function registerSimpleEarnLockedTools(server: McpServer) { - registerSimpleEarnLockedProductList(server) - registerSimpleEarnSubscribeLocked(server) - registerSimpleEarnRedeemLocked(server) - registerSimpleEarnLockedPosition(server) - registerSimpleEarnLockedSubscriptionPreview(server) - registerSimpleEarnSetAutoSubscribe(server) - registerSimpleEarnLockedPersonalQuota(server) - registerSimpleEarnLockedSubscriptionRecord(server) - registerSimpleEarnLockedRedemptionRecord(server) + registerSimpleEarnLockedProductList(server); + registerSimpleEarnSubscribeLocked(server); + registerSimpleEarnRedeemLocked(server); + registerSimpleEarnLockedPosition(server); + registerSimpleEarnLockedSubscriptionPreview(server); + registerSimpleEarnSetAutoSubscribe(server); + registerSimpleEarnLockedPersonalQuota(server); + registerSimpleEarnLockedSubscriptionRecord(server); + registerSimpleEarnLockedRedemptionRecord(server); } diff --git a/src/modules/simple-earn/locked/redeemLocked.ts b/src/modules/simple-earn/locked/redeemLocked.ts index e9a88b57..c043cfd8 100644 --- a/src/modules/simple-earn/locked/redeemLocked.ts +++ b/src/modules/simple-earn/locked/redeemLocked.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/simple-earn/locked/redeemLocked.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { simpleEarnClient } from "../../../config/binanceClient.js" +import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnRedeemLocked(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerSimpleEarnRedeemLocked(server: McpServer) { const response = await simpleEarnClient.restAPI.redeemLockedProduct({ positionId: params.positionId, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,9 +35,9 @@ export function registerSimpleEarnRedeemLocked(server: McpServer) { text: `✅ Locked Product Redemption Initiated!\n\nPosition ID: ${params.positionId}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -47,8 +47,8 @@ export function registerSimpleEarnRedeemLocked(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/simple-earn/locked/setAutoSubscribe.ts b/src/modules/simple-earn/locked/setAutoSubscribe.ts index 046d9ab1..f19acc06 100644 --- a/src/modules/simple-earn/locked/setAutoSubscribe.ts +++ b/src/modules/simple-earn/locked/setAutoSubscribe.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/simple-earn/locked/setAutoSubscribe.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { simpleEarnClient } from "../../../config/binanceClient.js" +import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnSetAutoSubscribe(server: McpServer) { server.tool( @@ -26,9 +26,9 @@ export function registerSimpleEarnSetAutoSubscribe(server: McpServer) { positionId: params.positionId, autoSubscribe: params.autoSubscribe, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -37,9 +37,9 @@ export function registerSimpleEarnSetAutoSubscribe(server: McpServer) { text: `✅ Auto-Subscribe Updated!\n\nPosition ID: ${params.positionId}\nAuto-Subscribe: ${params.autoSubscribe ? "Enabled" : "Disabled"}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -49,8 +49,8 @@ export function registerSimpleEarnSetAutoSubscribe(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/simple-earn/locked/subscribeLocked.ts b/src/modules/simple-earn/locked/subscribeLocked.ts index 95112435..971c2709 100644 --- a/src/modules/simple-earn/locked/subscribeLocked.ts +++ b/src/modules/simple-earn/locked/subscribeLocked.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/modules/simple-earn/locked/subscribeLocked.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { simpleEarnClient } from "../../../config/binanceClient.js" +import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnSubscribeLocked(server: McpServer) { server.tool( @@ -33,9 +33,9 @@ export function registerSimpleEarnSubscribeLocked(server: McpServer) { ...(params.autoSubscribe !== undefined && { autoSubscribe: params.autoSubscribe }), ...(params.sourceAccount && { sourceAccount: params.sourceAccount }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -44,9 +44,9 @@ export function registerSimpleEarnSubscribeLocked(server: McpServer) { text: `✅ Locked Product Subscription Successful!\n\nProject ID: ${params.projectId}\nAmount: ${params.amount}\nPosition ID: ${data.positionId || "N/A"}\n\n⚠️ Your funds are now locked. Rewards will be distributed based on the product terms.`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -56,8 +56,8 @@ export function registerSimpleEarnSubscribeLocked(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/account-api/accountCommission.ts b/src/modules/spot/account-api/accountCommission.ts index f4a179c2..b0603a78 100644 --- a/src/modules/spot/account-api/accountCommission.ts +++ b/src/modules/spot/account-api/accountCommission.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/account-api/accountCommission.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceAccountCommission(server: McpServer) { server.tool( @@ -15,12 +15,12 @@ export function registerBinanceAccountCommission(server: McpServer) { }, async ({ symbol, recvWindow }) => { try { - const params: any = { symbol } - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = { symbol }; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await spotClient.restAPI.accountCommission(params) + const response = await spotClient.restAPI.accountCommission(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,17 +29,17 @@ export function registerBinanceAccountCommission(server: McpServer) { text: `Retrieved account commission rates for ${symbol}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve account commission rates: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/account-api/getAccount.ts b/src/modules/spot/account-api/getAccount.ts index 556a3e19..d0db5720 100644 --- a/src/modules/spot/account-api/getAccount.ts +++ b/src/modules/spot/account-api/getAccount.ts @@ -1,9 +1,10 @@ // src/tools/binance-spot/account-api/getAccount.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; +import { safeJsonStringify } from "../../../utils/json.js"; export function registerBinanceGetAccount(server: McpServer) { server.tool( @@ -14,31 +15,31 @@ export function registerBinanceGetAccount(server: McpServer) { }, async ({ recvWindow }) => { try { - const params: any = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await spotClient.restAPI.getAccount(params) + const response = await spotClient.restAPI.getAccount(params); - const data = await response.data() + const data = await response.data(); return { content: [ { type: "text", - text: `Retrieved account information. Account contains ${data.balances?.length || 0} balances. Response: ${JSON.stringify(data)}`, + text: `Retrieved account information. Account contains ${data.balances?.length || 0} balances. Response: ${safeJsonStringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve account information: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/account-api/index.ts b/src/modules/spot/account-api/index.ts index 2be3a54f..53d31c2c 100644 --- a/src/modules/spot/account-api/index.ts +++ b/src/modules/spot/account-api/index.ts @@ -1,18 +1,18 @@ // src/tools/binance-spot/account-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceAccountCommission } from "./accountCommission.js" -import { registerBinanceGetAccount } from "./getAccount.js" -import { registerBinanceMyAllocations } from "./myAllocations.js" -import { registerBinanceMyPreventedMatches } from "./myPreventedMatches.js" -import { registerBinanceMyTrades } from "./myTrades.js" -import { registerBinanceRateLimitOrder } from "./rateLimitOrder.js" +import { registerBinanceAccountCommission } from "./accountCommission.js"; +import { registerBinanceGetAccount } from "./getAccount.js"; +import { registerBinanceMyAllocations } from "./myAllocations.js"; +import { registerBinanceMyPreventedMatches } from "./myPreventedMatches.js"; +import { registerBinanceMyTrades } from "./myTrades.js"; +import { registerBinanceRateLimitOrder } from "./rateLimitOrder.js"; export function registerBinanceAccountApiTools(server: McpServer) { - registerBinanceMyPreventedMatches(server) - registerBinanceGetAccount(server) - registerBinanceMyAllocations(server) - registerBinanceRateLimitOrder(server) - registerBinanceAccountCommission(server) - registerBinanceMyTrades(server) + registerBinanceMyPreventedMatches(server); + registerBinanceGetAccount(server); + registerBinanceMyAllocations(server); + registerBinanceRateLimitOrder(server); + registerBinanceAccountCommission(server); + registerBinanceMyTrades(server); } diff --git a/src/modules/spot/account-api/myAllocations.ts b/src/modules/spot/account-api/myAllocations.ts index 81a00914..2d1668a3 100644 --- a/src/modules/spot/account-api/myAllocations.ts +++ b/src/modules/spot/account-api/myAllocations.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/account-api/myAllocations.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceMyAllocations(server: McpServer) { server.tool( @@ -19,17 +19,17 @@ export function registerBinanceMyAllocations(server: McpServer) { }, async ({ symbol, allocationId, orderId, fromAllocationId, limit, recvWindow }) => { try { - const params: any = { symbol } + const params: any = { symbol }; - if (allocationId !== undefined) params.allocationId = allocationId - if (orderId !== undefined) params.orderId = orderId - if (fromAllocationId !== undefined) params.fromAllocationId = fromAllocationId - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + if (allocationId !== undefined) params.allocationId = allocationId; + if (orderId !== undefined) params.orderId = orderId; + if (fromAllocationId !== undefined) params.fromAllocationId = fromAllocationId; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await spotClient.restAPI.myAllocations(params) + const response = await spotClient.restAPI.myAllocations(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -38,15 +38,15 @@ export function registerBinanceMyAllocations(server: McpServer) { text: `Retrieved SOR allocations for ${symbol}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve SOR allocations: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/account-api/myPreventedMatches.ts b/src/modules/spot/account-api/myPreventedMatches.ts index 61403e30..0181e33e 100644 --- a/src/modules/spot/account-api/myPreventedMatches.ts +++ b/src/modules/spot/account-api/myPreventedMatches.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/account-api/myPreventedMatches.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceMyPreventedMatches(server: McpServer) { server.tool( @@ -19,17 +19,17 @@ export function registerBinanceMyPreventedMatches(server: McpServer) { }, async ({ symbol, preventedMatchId, orderId, fromPreventedMatchId, limit, recvWindow }) => { try { - const params: any = { symbol } + const params: any = { symbol }; - if (preventedMatchId !== undefined) params.preventedMatchId = preventedMatchId - if (orderId !== undefined) params.orderId = orderId - if (fromPreventedMatchId !== undefined) params.fromPreventedMatchId = fromPreventedMatchId - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + if (preventedMatchId !== undefined) params.preventedMatchId = preventedMatchId; + if (orderId !== undefined) params.orderId = orderId; + if (fromPreventedMatchId !== undefined) params.fromPreventedMatchId = fromPreventedMatchId; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await spotClient.restAPI.myPreventedMatches(params) + const response = await spotClient.restAPI.myPreventedMatches(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -38,17 +38,17 @@ export function registerBinanceMyPreventedMatches(server: McpServer) { text: `Retrieved prevented matches for ${symbol}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve prevented matches: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/account-api/myTrades.ts b/src/modules/spot/account-api/myTrades.ts index bfe95f19..81e110b9 100644 --- a/src/modules/spot/account-api/myTrades.ts +++ b/src/modules/spot/account-api/myTrades.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/account-api/myTrades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceMyTrades(server: McpServer) { server.tool( @@ -20,18 +20,18 @@ export function registerBinanceMyTrades(server: McpServer) { }, async ({ symbol, orderId, startTime, endTime, fromId, limit, recvWindow }) => { try { - const params: any = { symbol } + const params: any = { symbol }; - if (orderId !== undefined) params.orderId = orderId - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (fromId !== undefined) params.fromId = fromId - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + if (orderId !== undefined) params.orderId = orderId; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (fromId !== undefined) params.fromId = fromId; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await spotClient.restAPI.myTrades(params) + const response = await spotClient.restAPI.myTrades(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -40,15 +40,15 @@ export function registerBinanceMyTrades(server: McpServer) { text: `Retrieved trades for ${symbol}. Total trades: ${data.length}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve account trades: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/account-api/rateLimitOrder.ts b/src/modules/spot/account-api/rateLimitOrder.ts index bd415e83..83fe3be2 100644 --- a/src/modules/spot/account-api/rateLimitOrder.ts +++ b/src/modules/spot/account-api/rateLimitOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/account-api/rateLimitOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceRateLimitOrder(server: McpServer) { server.tool( @@ -14,12 +14,12 @@ export function registerBinanceRateLimitOrder(server: McpServer) { }, async ({ recvWindow }) => { try { - const params: any = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await spotClient.restAPI.rateLimitOrder(params) + const response = await spotClient.restAPI.rateLimitOrder(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -28,17 +28,17 @@ export function registerBinanceRateLimitOrder(server: McpServer) { text: `Retrieved current order count usage. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve order count usage: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/general-api/exchangeInfo.ts b/src/modules/spot/general-api/exchangeInfo.ts index 9967eebe..33b2abcb 100644 --- a/src/modules/spot/general-api/exchangeInfo.ts +++ b/src/modules/spot/general-api/exchangeInfo.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/general-api/exchangeInfo.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceExchangeInfo(server: McpServer) { server.tool( @@ -16,18 +16,18 @@ export function registerBinanceExchangeInfo(server: McpServer) { }, async ({ symbol, symbols, permissions }) => { try { - const params: any = {} + const params: any = {}; - if (symbol) params.symbol = symbol - if (symbols) params.symbols = symbols - if (permissions) params.permissions = permissions + if (symbol) params.symbol = symbol; + if (symbols) params.symbols = symbols; + if (permissions) params.permissions = permissions; - const response = await spotClient.restAPI.exchangeInfo(params) + const response = await spotClient.restAPI.exchangeInfo(params); - const data = await response.data() + const data = await response.data(); - const symbolCount = data.symbols?.length || 0 - const exchangeFiltersCount = data.exchangeFilters?.length || 0 + const symbolCount = data.symbols?.length || 0; + const exchangeFiltersCount = data.exchangeFilters?.length || 0; return { content: [ @@ -36,17 +36,17 @@ export function registerBinanceExchangeInfo(server: McpServer) { text: `Retrieved exchange information. Total symbols: ${symbolCount}, Exchange filters: ${exchangeFiltersCount}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve exchange information: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/general-api/index.ts b/src/modules/spot/general-api/index.ts index 471676d4..3cecf4b7 100644 --- a/src/modules/spot/general-api/index.ts +++ b/src/modules/spot/general-api/index.ts @@ -1,12 +1,12 @@ // src/tools/binance-spot/general-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceExchangeInfo } from "./exchangeInfo.js" -import { registerBinancePing } from "./ping.js" -import { registerBinanceTime } from "./time.js" +import { registerBinanceExchangeInfo } from "./exchangeInfo.js"; +import { registerBinancePing } from "./ping.js"; +import { registerBinanceTime } from "./time.js"; export function registerBinanceGeneralApiTools(server: McpServer) { - registerBinancePing(server) - registerBinanceTime(server) - registerBinanceExchangeInfo(server) + registerBinancePing(server); + registerBinanceTime(server); + registerBinanceExchangeInfo(server); } diff --git a/src/modules/spot/general-api/ping.ts b/src/modules/spot/general-api/ping.ts index 1e0aa465..ebce997e 100644 --- a/src/modules/spot/general-api/ping.ts +++ b/src/modules/spot/general-api/ping.ts @@ -1,14 +1,14 @@ // src/tools/binance-spot/general-api/ping.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinancePing(server: McpServer) { server.tool("BinancePing", "Test connectivity to the Binance API.", {}, async () => { try { - const response = await spotClient.restAPI.ping() + const response = await spotClient.restAPI.ping(); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -17,14 +17,14 @@ export function registerBinancePing(server: McpServer) { text: `Successfully pinged Binance API. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to ping Binance API: ${errorMessage}` }], isError: true, - } + }; } - }) + }); } diff --git a/src/modules/spot/general-api/time.ts b/src/modules/spot/general-api/time.ts index 3c0aa903..01df870a 100644 --- a/src/modules/spot/general-api/time.ts +++ b/src/modules/spot/general-api/time.ts @@ -1,17 +1,17 @@ // src/tools/binance-spot/general-api/time.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceTime(server: McpServer) { server.tool("BinanceTime", "Get the current server time from Binance API.", {}, async () => { try { - const response = await spotClient.restAPI.time() + const response = await spotClient.restAPI.time(); - const data = await response.data() + const data = await response.data(); // @ts-expect-error - serverTime not in generated type definition - const serverTime = new Date(data.serverTime).toISOString() + const serverTime = new Date(data.serverTime).toISOString(); return { content: [ @@ -22,14 +22,14 @@ export function registerBinanceTime(server: McpServer) { }). Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve server time: ${errorMessage}` }], isError: true, - } + }; } - }) + }); } diff --git a/src/modules/spot/index.ts b/src/modules/spot/index.ts index 6b58ea53..d87bcea7 100644 --- a/src/modules/spot/index.ts +++ b/src/modules/spot/index.ts @@ -1,28 +1,28 @@ // src/tools/binance-spot/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceAccountApiTools } from "./account-api/index.js" -import { registerBinanceGeneralApiTools } from "./general-api/index.js" -import { registerBinanceMarketApiTools } from "./market-api/index.js" -import { registerBinanceTradeApiTools } from "./trade-api/index.js" -import { registerBinanceUserDataStreamApiTools } from "./userdatastream-api/index.js" +import { registerBinanceAccountApiTools } from "./account-api/index.js"; +import { registerBinanceGeneralApiTools } from "./general-api/index.js"; +import { registerBinanceMarketApiTools } from "./market-api/index.js"; +import { registerBinanceTradeApiTools } from "./trade-api/index.js"; +import { registerBinanceUserDataStreamApiTools } from "./userdatastream-api/index.js"; export function registerBinanceSpotTools(server: McpServer) { // Trade API tools - registerBinanceTradeApiTools(server) + registerBinanceTradeApiTools(server); // Market API tools - registerBinanceMarketApiTools(server) + registerBinanceMarketApiTools(server); // Account API tools - registerBinanceAccountApiTools(server) + registerBinanceAccountApiTools(server); // User Data Stream API tools - registerBinanceUserDataStreamApiTools(server) + registerBinanceUserDataStreamApiTools(server); // General API tools - registerBinanceGeneralApiTools(server) + registerBinanceGeneralApiTools(server); } // Alias for binance.ts compatibility -export { registerBinanceSpotTools as registerSpot } +export { registerBinanceSpotTools as registerSpot }; diff --git a/src/modules/spot/market-api/aggTrades.ts b/src/modules/spot/market-api/aggTrades.ts index 3a1a49ef..378358ef 100644 --- a/src/modules/spot/market-api/aggTrades.ts +++ b/src/modules/spot/market-api/aggTrades.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/market-api/aggTrades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceAggTrades(server: McpServer) { server.tool( @@ -18,16 +18,16 @@ export function registerBinanceAggTrades(server: McpServer) { }, async ({ symbol, fromId, startTime, endTime, limit }) => { try { - const params: any = { symbol } + const params: any = { symbol }; - if (fromId !== undefined) params.fromId = fromId - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + if (fromId !== undefined) params.fromId = fromId; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const response = await spotClient.restAPI.aggTrades(params) + const response = await spotClient.restAPI.aggTrades(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -36,15 +36,15 @@ export function registerBinanceAggTrades(server: McpServer) { text: `Retrieved aggregate trades for ${symbol}. Total trades: ${data.length}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve aggregate trades: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/market-api/avgPrice.ts b/src/modules/spot/market-api/avgPrice.ts index 80ed5102..6603c81b 100644 --- a/src/modules/spot/market-api/avgPrice.ts +++ b/src/modules/spot/market-api/avgPrice.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/market-api/avgPrice.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceAvgPrice(server: McpServer) { server.tool( @@ -16,9 +16,9 @@ export function registerBinanceAvgPrice(server: McpServer) { try { const response = await spotClient.restAPI.avgPrice({ symbol: symbol, - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -27,15 +27,15 @@ export function registerBinanceAvgPrice(server: McpServer) { text: `Retrieved current average price for ${symbol}. Average price: ${data.price}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve average price: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/market-api/depth.ts b/src/modules/spot/market-api/depth.ts index 6df7e4b5..31b78959 100644 --- a/src/modules/spot/market-api/depth.ts +++ b/src/modules/spot/market-api/depth.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/market-api/depth.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceDepth(server: McpServer) { server.tool( @@ -15,12 +15,12 @@ export function registerBinanceDepth(server: McpServer) { }, async ({ symbol, limit }) => { try { - const params: any = { symbol } - if (limit !== undefined) params.limit = limit + const params: any = { symbol }; + if (limit !== undefined) params.limit = limit; - const response = await spotClient.restAPI.depth(params) + const response = await spotClient.restAPI.depth(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,15 +29,15 @@ export function registerBinanceDepth(server: McpServer) { text: `Retrieved order book depth for ${symbol}. Bids: ${data.bids?.length || 0}, Asks: ${data.asks?.length || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve order book depth: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/market-api/getTrades.ts b/src/modules/spot/market-api/getTrades.ts index 6f65b5e4..2e1ed4c1 100644 --- a/src/modules/spot/market-api/getTrades.ts +++ b/src/modules/spot/market-api/getTrades.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/market-api/getTrades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceGetTrades(server: McpServer) { server.tool( @@ -15,13 +15,13 @@ export function registerBinanceGetTrades(server: McpServer) { }, async ({ symbol, limit }) => { try { - const params: any = { symbol } + const params: any = { symbol }; - if (limit !== undefined) params.limit = limit + if (limit !== undefined) params.limit = limit; - const response = await spotClient.restAPI.getTrades(params) + const response = await spotClient.restAPI.getTrades(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -30,15 +30,15 @@ export function registerBinanceGetTrades(server: McpServer) { text: `Retrieved recent trades for ${symbol}. Total trades: ${data.length}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve recent trades: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/market-api/historicalTrades.ts b/src/modules/spot/market-api/historicalTrades.ts index ca14bb87..07a7b27d 100644 --- a/src/modules/spot/market-api/historicalTrades.ts +++ b/src/modules/spot/market-api/historicalTrades.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/market-api/historicalTrades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceHistoricalTrades(server: McpServer) { server.tool( @@ -16,14 +16,14 @@ export function registerBinanceHistoricalTrades(server: McpServer) { }, async ({ symbol, limit, fromId }) => { try { - const params: any = { symbol } + const params: any = { symbol }; - if (limit !== undefined) params.limit = limit - if (fromId !== undefined) params.fromId = fromId + if (limit !== undefined) params.limit = limit; + if (fromId !== undefined) params.fromId = fromId; - const response = await spotClient.restAPI.historicalTrades(params) + const response = await spotClient.restAPI.historicalTrades(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -32,17 +32,17 @@ export function registerBinanceHistoricalTrades(server: McpServer) { text: `Retrieved historical trades for ${symbol}. Total trades: ${data.length}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve historical trades: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/market-api/index.ts b/src/modules/spot/market-api/index.ts index 4ccede7d..51efb908 100644 --- a/src/modules/spot/market-api/index.ts +++ b/src/modules/spot/market-api/index.ts @@ -1,30 +1,30 @@ // src/tools/binance-spot/market-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceAggTrades } from "./aggTrades.js" -import { registerBinanceAvgPrice } from "./avgPrice.js" -import { registerBinanceDepth } from "./depth.js" -import { registerBinanceGetTrades } from "./getTrades.js" -import { registerBinanceHistoricalTrades } from "./historicalTrades.js" -import { registerBinanceKlines } from "./klines.js" -import { registerBinanceTicker24hr } from "./ticker24hr.js" -import { registerBinanceTicker } from "./ticker.js" -import { registerBinanceTickerBookTicker } from "./tickerBookTicker.js" -import { registerBinanceTickerPrice } from "./tickerPrice.js" -import { registerBinanceTickerTradingDay } from "./tickerTradingDay.js" -import { registerBinanceUiKlines } from "./uiKlines.js" +import { registerBinanceAggTrades } from "./aggTrades.js"; +import { registerBinanceAvgPrice } from "./avgPrice.js"; +import { registerBinanceDepth } from "./depth.js"; +import { registerBinanceGetTrades } from "./getTrades.js"; +import { registerBinanceHistoricalTrades } from "./historicalTrades.js"; +import { registerBinanceKlines } from "./klines.js"; +import { registerBinanceTicker24hr } from "./ticker24hr.js"; +import { registerBinanceTicker } from "./ticker.js"; +import { registerBinanceTickerBookTicker } from "./tickerBookTicker.js"; +import { registerBinanceTickerPrice } from "./tickerPrice.js"; +import { registerBinanceTickerTradingDay } from "./tickerTradingDay.js"; +import { registerBinanceUiKlines } from "./uiKlines.js"; export function registerBinanceMarketApiTools(server: McpServer) { - registerBinanceKlines(server) - registerBinanceTicker24hr(server) - registerBinanceDepth(server) - registerBinanceAggTrades(server) - registerBinanceTickerTradingDay(server) - registerBinanceUiKlines(server) - registerBinanceTickerBookTicker(server) - registerBinanceAvgPrice(server) - registerBinanceTickerPrice(server) - registerBinanceTicker(server) - registerBinanceHistoricalTrades(server) - registerBinanceGetTrades(server) + registerBinanceKlines(server); + registerBinanceTicker24hr(server); + registerBinanceDepth(server); + registerBinanceAggTrades(server); + registerBinanceTickerTradingDay(server); + registerBinanceUiKlines(server); + registerBinanceTickerBookTicker(server); + registerBinanceAvgPrice(server); + registerBinanceTickerPrice(server); + registerBinanceTicker(server); + registerBinanceHistoricalTrades(server); + registerBinanceGetTrades(server); } diff --git a/src/modules/spot/market-api/klines.ts b/src/modules/spot/market-api/klines.ts index 1eb9eb49..8ab84f65 100644 --- a/src/modules/spot/market-api/klines.ts +++ b/src/modules/spot/market-api/klines.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/market-api/klines.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceKlines(server: McpServer) { server.tool( @@ -39,15 +39,15 @@ export function registerBinanceKlines(server: McpServer) { const params: any = { symbol, interval, - } + }; - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const response = await spotClient.restAPI.klines(params) + const response = await spotClient.restAPI.klines(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -56,15 +56,15 @@ export function registerBinanceKlines(server: McpServer) { text: `Retrieved klines for ${symbol} with ${interval} interval. Total candles: ${data.length}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve klines: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/market-api/ticker.ts b/src/modules/spot/market-api/ticker.ts index 05d15f05..fca26210 100644 --- a/src/modules/spot/market-api/ticker.ts +++ b/src/modules/spot/market-api/ticker.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/market-api/ticker.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceTicker(server: McpServer) { server.tool( @@ -18,18 +18,18 @@ export function registerBinanceTicker(server: McpServer) { }, async ({ symbol, windowSize }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol - if (windowSize) params.windowSize = windowSize + const params: any = {}; + if (symbol) params.symbol = symbol; + if (windowSize) params.windowSize = windowSize; - const response = await spotClient.restAPI.ticker(params) + const response = await spotClient.restAPI.ticker(params); - const data = await response.data() + const data = await response.data(); - const isArray = Array.isArray(data) + const isArray = Array.isArray(data); const responseText = isArray ? `Retrieved ticker statistics for all symbols${windowSize ? ` with window size ${windowSize}` : ""}. Total items: ${data.length}.` - : `Retrieved ticker statistics for ${symbol}${windowSize ? ` with window size ${windowSize}` : ""}.` + : `Retrieved ticker statistics for ${symbol}${windowSize ? ` with window size ${windowSize}` : ""}.`; return { content: [ @@ -38,17 +38,17 @@ export function registerBinanceTicker(server: McpServer) { text: `${responseText} Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve ticker statistics: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/market-api/ticker24hr.ts b/src/modules/spot/market-api/ticker24hr.ts index 58f1d5ed..bb9cf669 100644 --- a/src/modules/spot/market-api/ticker24hr.ts +++ b/src/modules/spot/market-api/ticker24hr.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/market-api/ticker24hr.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceTicker24hr(server: McpServer) { server.tool( @@ -14,17 +14,17 @@ export function registerBinanceTicker24hr(server: McpServer) { }, async ({ symbol }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol + const params: any = {}; + if (symbol) params.symbol = symbol; - const response = await spotClient.restAPI.ticker24hr(params) + const response = await spotClient.restAPI.ticker24hr(params); - const data = await response.data() + const data = await response.data(); - const isArray = Array.isArray(data) + const isArray = Array.isArray(data); const responseText = isArray ? `Retrieved 24hr statistics for all symbols. Total items: ${data.length}.` - : `Retrieved 24hr statistics for ${symbol}.` + : `Retrieved 24hr statistics for ${symbol}.`; return { content: [ @@ -33,15 +33,15 @@ export function registerBinanceTicker24hr(server: McpServer) { text: `${responseText} Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve 24hr ticker: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/market-api/tickerBookTicker.ts b/src/modules/spot/market-api/tickerBookTicker.ts index 9fede0b8..0c59dc80 100644 --- a/src/modules/spot/market-api/tickerBookTicker.ts +++ b/src/modules/spot/market-api/tickerBookTicker.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/market-api/tickerBookTicker.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceTickerBookTicker(server: McpServer) { server.tool( @@ -14,17 +14,17 @@ export function registerBinanceTickerBookTicker(server: McpServer) { }, async ({ symbol }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol + const params: any = {}; + if (symbol) params.symbol = symbol; - const response = await spotClient.restAPI.tickerBookTicker(params) + const response = await spotClient.restAPI.tickerBookTicker(params); - const data = await response.data() + const data = await response.data(); - const isArray = Array.isArray(data) + const isArray = Array.isArray(data); const responseText = isArray ? `Retrieved best price/quantity on the order book for all symbols. Total items: ${data.length}.` - : `Retrieved best price/quantity on the order book for ${symbol}.` + : `Retrieved best price/quantity on the order book for ${symbol}.`; return { content: [ @@ -33,15 +33,15 @@ export function registerBinanceTickerBookTicker(server: McpServer) { text: `${responseText} Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve book ticker: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/market-api/tickerPrice.ts b/src/modules/spot/market-api/tickerPrice.ts index d57a9323..1480cdcb 100644 --- a/src/modules/spot/market-api/tickerPrice.ts +++ b/src/modules/spot/market-api/tickerPrice.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/market-api/tickerPrice.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceTickerPrice(server: McpServer) { server.tool( @@ -14,17 +14,17 @@ export function registerBinanceTickerPrice(server: McpServer) { }, async ({ symbol }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol + const params: any = {}; + if (symbol) params.symbol = symbol; - const response = await spotClient.restAPI.tickerPrice(params) + const response = await spotClient.restAPI.tickerPrice(params); - const data = await response.data() + const data = await response.data(); - const isArray = Array.isArray(data) + const isArray = Array.isArray(data); const responseText = isArray ? `Retrieved latest prices for all symbols. Total items: ${data.length}.` - : `Retrieved latest price for ${symbol}: ${data.price}.` + : `Retrieved latest price for ${symbol}: ${data.price}.`; return { content: [ @@ -33,15 +33,15 @@ export function registerBinanceTickerPrice(server: McpServer) { text: `${responseText} Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve ticker price: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/market-api/tickerTradingDay.ts b/src/modules/spot/market-api/tickerTradingDay.ts index 9e21de6f..8ec97804 100644 --- a/src/modules/spot/market-api/tickerTradingDay.ts +++ b/src/modules/spot/market-api/tickerTradingDay.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/market-api/tickerTradingDay.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceTickerTradingDay(server: McpServer) { server.tool( @@ -14,17 +14,17 @@ export function registerBinanceTickerTradingDay(server: McpServer) { }, async ({ symbol }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol + const params: any = {}; + if (symbol) params.symbol = symbol; - const response = await spotClient.restAPI.tickerTradingDay(params) + const response = await spotClient.restAPI.tickerTradingDay(params); - const data = await response.data() + const data = await response.data(); - const isArray = Array.isArray(data) + const isArray = Array.isArray(data); const responseText = isArray ? `Retrieved trading day statistics for all symbols. Total items: ${data.length}.` - : `Retrieved trading day statistics for ${symbol}.` + : `Retrieved trading day statistics for ${symbol}.`; return { content: [ @@ -33,17 +33,17 @@ export function registerBinanceTickerTradingDay(server: McpServer) { text: `${responseText} Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve trading day statistics: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/market-api/uiKlines.ts b/src/modules/spot/market-api/uiKlines.ts index 886a3d75..10cc184e 100644 --- a/src/modules/spot/market-api/uiKlines.ts +++ b/src/modules/spot/market-api/uiKlines.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/market-api/uiKlines.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceUiKlines(server: McpServer) { server.tool( @@ -39,15 +39,15 @@ export function registerBinanceUiKlines(server: McpServer) { const params: any = { symbol, interval, - } + }; - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const response = await spotClient.restAPI.uiKlines(params) + const response = await spotClient.restAPI.uiKlines(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -56,15 +56,15 @@ export function registerBinanceUiKlines(server: McpServer) { text: `Retrieved UI klines for ${symbol} with ${interval} interval. Total candles: ${data.length}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve UI klines: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/trade-api/allOrders.ts b/src/modules/spot/trade-api/allOrders.ts index 1a4b3f19..939a32f8 100644 --- a/src/modules/spot/trade-api/allOrders.ts +++ b/src/modules/spot/trade-api/allOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/trade-api/allOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceAllOrders(server: McpServer) { server.tool( @@ -21,16 +21,16 @@ export function registerBinanceAllOrders(server: McpServer) { }, async ({ symbol, orderId, startTime, endTime, limit }) => { try { - const params: any = { symbol } + const params: any = { symbol }; - if (orderId !== undefined) params.orderId = orderId - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + if (orderId !== undefined) params.orderId = orderId; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const response = await spotClient.restAPI.allOrders(params) + const response = await spotClient.restAPI.allOrders(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -39,15 +39,15 @@ export function registerBinanceAllOrders(server: McpServer) { text: `Retrieved all orders for ${symbol}. Total orders: ${data.length}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve all orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/trade-api/deleteOpenOrders.ts b/src/modules/spot/trade-api/deleteOpenOrders.ts index 95920e81..1d37e077 100644 --- a/src/modules/spot/trade-api/deleteOpenOrders.ts +++ b/src/modules/spot/trade-api/deleteOpenOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/trade-api/deleteOpenOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceDeleteOpenOrders(server: McpServer) { server.tool( @@ -16,9 +16,9 @@ export function registerBinanceDeleteOpenOrders(server: McpServer) { try { const response = await spotClient.restAPI.deleteOpenOrders({ symbol: symbol, - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -27,15 +27,15 @@ export function registerBinanceDeleteOpenOrders(server: McpServer) { text: `Successfully canceled all open orders for ${symbol}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to cancel open orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/trade-api/deleteOrder.ts b/src/modules/spot/trade-api/deleteOrder.ts index cbf5490d..8bbe0e5f 100644 --- a/src/modules/spot/trade-api/deleteOrder.ts +++ b/src/modules/spot/trade-api/deleteOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/trade-api/deleteOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceDeleteOrder(server: McpServer) { server.tool( @@ -16,14 +16,14 @@ export function registerBinanceDeleteOrder(server: McpServer) { }, async ({ symbol, orderId, origClientOrderId }) => { try { - const params: any = { symbol } + const params: any = { symbol }; - if (orderId) params.orderId = orderId - if (origClientOrderId) params.origClientOrderId = origClientOrderId + if (orderId) params.orderId = orderId; + if (origClientOrderId) params.origClientOrderId = origClientOrderId; - const response = await spotClient.restAPI.deleteOrder(params) + const response = await spotClient.restAPI.deleteOrder(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -32,15 +32,15 @@ export function registerBinanceDeleteOrder(server: McpServer) { text: `Order successfully canceled. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to cancel order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/trade-api/getOpenOrders.ts b/src/modules/spot/trade-api/getOpenOrders.ts index 70e079a7..5d30259d 100644 --- a/src/modules/spot/trade-api/getOpenOrders.ts +++ b/src/modules/spot/trade-api/getOpenOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/trade-api/getOpenOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceGetOpenOrders(server: McpServer) { server.tool( @@ -14,12 +14,12 @@ export function registerBinanceGetOpenOrders(server: McpServer) { }, async ({ symbol }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol + const params: any = {}; + if (symbol) params.symbol = symbol; - const response = await spotClient.restAPI.getOpenOrders(params) + const response = await spotClient.restAPI.getOpenOrders(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -28,15 +28,15 @@ export function registerBinanceGetOpenOrders(server: McpServer) { text: `Retrieved open orders${symbol ? ` for ${symbol}` : ""}. Total open orders: ${data.length}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve open orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/trade-api/getOrder.ts b/src/modules/spot/trade-api/getOrder.ts index 1c83ac75..e76b7bf5 100644 --- a/src/modules/spot/trade-api/getOrder.ts +++ b/src/modules/spot/trade-api/getOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/trade-api/getOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceGetOrder(server: McpServer) { server.tool( @@ -16,14 +16,14 @@ export function registerBinanceGetOrder(server: McpServer) { }, async ({ symbol, orderId, origClientOrderId }) => { try { - const params: any = { symbol } + const params: any = { symbol }; - if (orderId) params.orderId = orderId - if (origClientOrderId) params.origClientOrderId = origClientOrderId + if (orderId) params.orderId = orderId; + if (origClientOrderId) params.origClientOrderId = origClientOrderId; - const response = await spotClient.restAPI.getOrder(params) + const response = await spotClient.restAPI.getOrder(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -32,17 +32,17 @@ export function registerBinanceGetOrder(server: McpServer) { text: `Order information retrieved successfully. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve order information: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/trade-api/index.ts b/src/modules/spot/trade-api/index.ts index d7dc679c..dac0fe57 100644 --- a/src/modules/spot/trade-api/index.ts +++ b/src/modules/spot/trade-api/index.ts @@ -1,22 +1,22 @@ // src/tools/binance-spot/trade-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceAllOrders } from "./allOrders.js" -import { registerBinanceDeleteOpenOrders } from "./deleteOpenOrders.js" -import { registerBinanceDeleteOrder } from "./deleteOrder.js" -import { registerBinanceGetOpenOrders } from "./getOpenOrders.js" -import { registerBinanceGetOrder } from "./getOrder.js" -import { registerBinanceNewOrder } from "./newOrder.js" -import { registerBinanceOpenOrderList } from "./openOrderList.js" -import { registerBinanceOrderOco } from "./orderOco.js" +import { registerBinanceAllOrders } from "./allOrders.js"; +import { registerBinanceDeleteOpenOrders } from "./deleteOpenOrders.js"; +import { registerBinanceDeleteOrder } from "./deleteOrder.js"; +import { registerBinanceGetOpenOrders } from "./getOpenOrders.js"; +import { registerBinanceGetOrder } from "./getOrder.js"; +import { registerBinanceNewOrder } from "./newOrder.js"; +import { registerBinanceOpenOrderList } from "./openOrderList.js"; +import { registerBinanceOrderOco } from "./orderOco.js"; export function registerBinanceTradeApiTools(server: McpServer) { - registerBinanceDeleteOrder(server) - registerBinanceAllOrders(server) - registerBinanceOpenOrderList(server) - registerBinanceNewOrder(server) - registerBinanceGetOrder(server) - registerBinanceGetOpenOrders(server) - registerBinanceDeleteOpenOrders(server) - registerBinanceOrderOco(server) + registerBinanceDeleteOrder(server); + registerBinanceAllOrders(server); + registerBinanceOpenOrderList(server); + registerBinanceNewOrder(server); + registerBinanceGetOrder(server); + registerBinanceGetOpenOrders(server); + registerBinanceDeleteOpenOrders(server); + registerBinanceOrderOco(server); } diff --git a/src/modules/spot/trade-api/newOrder.ts b/src/modules/spot/trade-api/newOrder.ts index 9080a015..c61a2350 100644 --- a/src/modules/spot/trade-api/newOrder.ts +++ b/src/modules/spot/trade-api/newOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/trade-api/newOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceNewOrder(server: McpServer) { server.tool( @@ -51,19 +51,19 @@ export function registerBinanceNewOrder(server: McpServer) { side, type, quantity, - } + }; - if (timeInForce) params.timeInForce = timeInForce - if (quoteOrderQty !== undefined) params.quoteOrderQty = quoteOrderQty - if (price !== undefined) params.price = price - if (newClientOrderId) params.newClientOrderId = newClientOrderId - if (stopPrice !== undefined) params.stopPrice = stopPrice - if (icebergQty !== undefined) params.icebergQty = icebergQty - if (newOrderRespType) params.newOrderRespType = newOrderRespType + if (timeInForce) params.timeInForce = timeInForce; + if (quoteOrderQty !== undefined) params.quoteOrderQty = quoteOrderQty; + if (price !== undefined) params.price = price; + if (newClientOrderId) params.newClientOrderId = newClientOrderId; + if (stopPrice !== undefined) params.stopPrice = stopPrice; + if (icebergQty !== undefined) params.icebergQty = icebergQty; + if (newOrderRespType) params.newOrderRespType = newOrderRespType; - const response = await spotClient.restAPI.newOrder(params) + const response = await spotClient.restAPI.newOrder(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -72,15 +72,15 @@ export function registerBinanceNewOrder(server: McpServer) { text: `New order successfully created. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to create new order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/trade-api/openOrderList.ts b/src/modules/spot/trade-api/openOrderList.ts index 1ba07a57..2a8c3ee9 100644 --- a/src/modules/spot/trade-api/openOrderList.ts +++ b/src/modules/spot/trade-api/openOrderList.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/trade-api/openOrderList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceOpenOrderList(server: McpServer) { server.tool( @@ -14,12 +14,12 @@ export function registerBinanceOpenOrderList(server: McpServer) { }, async ({ symbol }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol + const params: any = {}; + if (symbol) params.symbol = symbol; - const response = await spotClient.restAPI.openOrderList(params) + const response = await spotClient.restAPI.openOrderList(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -28,15 +28,15 @@ export function registerBinanceOpenOrderList(server: McpServer) { text: `Retrieved open OCO orders${symbol ? ` for ${symbol}` : ""}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve open OCO orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/trade-api/orderOco.ts b/src/modules/spot/trade-api/orderOco.ts index bfca8250..42803c26 100644 --- a/src/modules/spot/trade-api/orderOco.ts +++ b/src/modules/spot/trade-api/orderOco.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/trade-api/orderOco.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceOrderOco(server: McpServer) { server.tool( @@ -45,18 +45,18 @@ export function registerBinanceOrderOco(server: McpServer) { quantity, price, stopPrice, - } + }; - if (stopLimitPrice !== undefined) params.stopLimitPrice = stopLimitPrice - if (stopLimitTimeInForce) params.stopLimitTimeInForce = stopLimitTimeInForce - if (newClientOrderId) params.newClientOrderId = newClientOrderId - if (stopClientOrderId) params.stopClientOrderId = stopClientOrderId - if (limitIcebergQty !== undefined) params.limitIcebergQty = limitIcebergQty - if (stopIcebergQty !== undefined) params.stopIcebergQty = stopIcebergQty + if (stopLimitPrice !== undefined) params.stopLimitPrice = stopLimitPrice; + if (stopLimitTimeInForce) params.stopLimitTimeInForce = stopLimitTimeInForce; + if (newClientOrderId) params.newClientOrderId = newClientOrderId; + if (stopClientOrderId) params.stopClientOrderId = stopClientOrderId; + if (limitIcebergQty !== undefined) params.limitIcebergQty = limitIcebergQty; + if (stopIcebergQty !== undefined) params.stopIcebergQty = stopIcebergQty; - const response = await spotClient.restAPI.orderOco(params) + const response = await spotClient.restAPI.orderOco(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -65,15 +65,15 @@ export function registerBinanceOrderOco(server: McpServer) { text: `OCO order successfully created. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to create OCO order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/userdatastream-api/deleteUserDataStream.ts b/src/modules/spot/userdatastream-api/deleteUserDataStream.ts index 45f9c877..823a10cd 100644 --- a/src/modules/spot/userdatastream-api/deleteUserDataStream.ts +++ b/src/modules/spot/userdatastream-api/deleteUserDataStream.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/userdatastream-api/deleteUserDataStream.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceDeleteUserDataStream(server: McpServer) { server.tool( @@ -16,9 +16,9 @@ export function registerBinanceDeleteUserDataStream(server: McpServer) { try { const response = await spotClient.restAPI.deleteUserDataStream({ listenKey: listenKey, - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -27,15 +27,15 @@ export function registerBinanceDeleteUserDataStream(server: McpServer) { text: `Successfully closed user data stream with listen key: ${listenKey}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to close user data stream: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/userdatastream-api/index.ts b/src/modules/spot/userdatastream-api/index.ts index a321fb5d..288eaa88 100644 --- a/src/modules/spot/userdatastream-api/index.ts +++ b/src/modules/spot/userdatastream-api/index.ts @@ -1,12 +1,12 @@ // src/tools/binance-spot/userdatastream-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceDeleteUserDataStream } from "./deleteUserDataStream.js" -import { registerBinanceNewUserDataStream } from "./newUserDataStream.js" -import { registerBinancePutUserDataStream } from "./putUserDataStream.js" +import { registerBinanceDeleteUserDataStream } from "./deleteUserDataStream.js"; +import { registerBinanceNewUserDataStream } from "./newUserDataStream.js"; +import { registerBinancePutUserDataStream } from "./putUserDataStream.js"; export function registerBinanceUserDataStreamApiTools(server: McpServer) { - registerBinanceNewUserDataStream(server) - registerBinanceDeleteUserDataStream(server) - registerBinancePutUserDataStream(server) + registerBinanceNewUserDataStream(server); + registerBinanceDeleteUserDataStream(server); + registerBinancePutUserDataStream(server); } diff --git a/src/modules/spot/userdatastream-api/newUserDataStream.ts b/src/modules/spot/userdatastream-api/newUserDataStream.ts index e01448e8..053ed45c 100644 --- a/src/modules/spot/userdatastream-api/newUserDataStream.ts +++ b/src/modules/spot/userdatastream-api/newUserDataStream.ts @@ -1,7 +1,7 @@ // src/tools/binance-spot/userdatastream-api/newUserDataStream.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceNewUserDataStream(server: McpServer) { server.tool( @@ -10,9 +10,9 @@ export function registerBinanceNewUserDataStream(server: McpServer) { {}, async () => { try { - const response = await spotClient.restAPI.newUserDataStream() + const response = await spotClient.restAPI.newUserDataStream(); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -21,15 +21,15 @@ export function registerBinanceNewUserDataStream(server: McpServer) { text: `Created new listen key for user data stream. Listen key: ${data.listenKey}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to create user data stream: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/spot/userdatastream-api/putUserDataStream.ts b/src/modules/spot/userdatastream-api/putUserDataStream.ts index 4f054acd..3579e98d 100644 --- a/src/modules/spot/userdatastream-api/putUserDataStream.ts +++ b/src/modules/spot/userdatastream-api/putUserDataStream.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/userdatastream-api/putUserDataStream.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinancePutUserDataStream(server: McpServer) { server.tool( @@ -16,9 +16,9 @@ export function registerBinancePutUserDataStream(server: McpServer) { try { const response = await spotClient.restAPI.putUserDataStream({ listenKey: listenKey, - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -27,17 +27,17 @@ export function registerBinancePutUserDataStream(server: McpServer) { text: `Successfully extended validity of listen key: ${listenKey}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to extend listen key validity: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/staking/ETH-staking-api/ethStakingAccount.ts b/src/modules/staking/ETH-staking-api/ethStakingAccount.ts index f2c6820f..b6b73263 100644 --- a/src/modules/staking/ETH-staking-api/ethStakingAccount.ts +++ b/src/modules/staking/ETH-staking-api/ethStakingAccount.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/ETH-staking-api/ethStakingAccount.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceEthStakingAccount(server: McpServer) { server.tool( @@ -16,9 +16,9 @@ export function registerBinanceEthStakingAccount(server: McpServer) { try { const response = await stakingClient.restAPI.ethStakingAccount({ ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,9 +29,9 @@ export function registerBinanceEthStakingAccount(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -41,8 +41,8 @@ export function registerBinanceEthStakingAccount(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/staking/ETH-staking-api/getCurrentEthStakingQuota.ts b/src/modules/staking/ETH-staking-api/getCurrentEthStakingQuota.ts index f64b1532..cb23363b 100644 --- a/src/modules/staking/ETH-staking-api/getCurrentEthStakingQuota.ts +++ b/src/modules/staking/ETH-staking-api/getCurrentEthStakingQuota.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/ETH-staking-api/getCurrentEthStakingQuota.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetCurrentEthStakingQuota(server: McpServer) { server.tool( @@ -16,9 +16,9 @@ export function registerBinanceGetCurrentEthStakingQuota(server: McpServer) { try { const response = await stakingClient.restAPI.getCurrentEthStakingQuota({ ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,9 +29,9 @@ export function registerBinanceGetCurrentEthStakingQuota(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -41,8 +41,8 @@ export function registerBinanceGetCurrentEthStakingQuota(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/staking/ETH-staking-api/getEthRedemptionHistory.ts b/src/modules/staking/ETH-staking-api/getEthRedemptionHistory.ts index 4e47b3ee..4ca27d3d 100644 --- a/src/modules/staking/ETH-staking-api/getEthRedemptionHistory.ts +++ b/src/modules/staking/ETH-staking-api/getEthRedemptionHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/ETH-staking-api/getEthRedemptionHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetEthRedemptionHistory(server: McpServer) { server.tool( @@ -45,9 +45,9 @@ export function registerBinanceGetEthRedemptionHistory(server: McpServer) { ...(params.endTime !== undefined && { endTime: params.endTime }), ...(params.current !== undefined && { current: params.current }), ...(params.size !== undefined && { size: params.size }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -58,9 +58,9 @@ export function registerBinanceGetEthRedemptionHistory(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -70,8 +70,8 @@ export function registerBinanceGetEthRedemptionHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/staking/ETH-staking-api/getEthStakingHistory.ts b/src/modules/staking/ETH-staking-api/getEthStakingHistory.ts index 80d93ebb..6f2405f4 100644 --- a/src/modules/staking/ETH-staking-api/getEthStakingHistory.ts +++ b/src/modules/staking/ETH-staking-api/getEthStakingHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/ETH-staking-api/getEthStakingHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetEthStakingHistory(server: McpServer) { server.tool( @@ -45,9 +45,9 @@ export function registerBinanceGetEthStakingHistory(server: McpServer) { ...(params.endTime !== undefined && { endTime: params.endTime }), ...(params.current !== undefined && { current: params.current }), ...(params.size !== undefined && { size: params.size }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -58,9 +58,9 @@ export function registerBinanceGetEthStakingHistory(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -70,8 +70,8 @@ export function registerBinanceGetEthStakingHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/staking/ETH-staking-api/getWbethRateHistory.ts b/src/modules/staking/ETH-staking-api/getWbethRateHistory.ts index a9c69bef..4f354623 100644 --- a/src/modules/staking/ETH-staking-api/getWbethRateHistory.ts +++ b/src/modules/staking/ETH-staking-api/getWbethRateHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/ETH-staking-api/getWbethRateHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetWbethRateHistory(server: McpServer) { server.tool( @@ -42,9 +42,9 @@ export function registerBinanceGetWbethRateHistory(server: McpServer) { ...(params.endTime !== undefined && { endTime: params.endTime }), ...(params.current !== undefined && { current: params.current }), ...(params.size !== undefined && { size: params.size }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -55,9 +55,9 @@ export function registerBinanceGetWbethRateHistory(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -67,8 +67,8 @@ export function registerBinanceGetWbethRateHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/staking/ETH-staking-api/getWbethRewardsHistory.ts b/src/modules/staking/ETH-staking-api/getWbethRewardsHistory.ts index 79a83b5a..697014e7 100644 --- a/src/modules/staking/ETH-staking-api/getWbethRewardsHistory.ts +++ b/src/modules/staking/ETH-staking-api/getWbethRewardsHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/ETH-staking-api/getWbethRewardsHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetWbethRewardsHistory(server: McpServer) { server.tool( @@ -45,9 +45,9 @@ export function registerBinanceGetWbethRewardsHistory(server: McpServer) { ...(params.endTime !== undefined && { endTime: params.endTime }), ...(params.current !== undefined && { current: params.current }), ...(params.size !== undefined && { size: params.size }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -58,9 +58,9 @@ export function registerBinanceGetWbethRewardsHistory(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -70,8 +70,8 @@ export function registerBinanceGetWbethRewardsHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/staking/ETH-staking-api/getWbethUnwrapHistory.ts b/src/modules/staking/ETH-staking-api/getWbethUnwrapHistory.ts index 7bdf1f01..d36db1e5 100644 --- a/src/modules/staking/ETH-staking-api/getWbethUnwrapHistory.ts +++ b/src/modules/staking/ETH-staking-api/getWbethUnwrapHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/ETH-staking-api/getWbethUnwrapHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetWbethUnwrapHistory(server: McpServer) { server.tool( @@ -41,9 +41,9 @@ export function registerBinanceGetWbethUnwrapHistory(server: McpServer) { ...(params.current !== undefined && { current: params.current }), ...(params.size !== undefined && { size: params.size }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -54,9 +54,9 @@ export function registerBinanceGetWbethUnwrapHistory(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -66,8 +66,8 @@ export function registerBinanceGetWbethUnwrapHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/staking/ETH-staking-api/getWbethWrapHistory.ts b/src/modules/staking/ETH-staking-api/getWbethWrapHistory.ts index 0901f741..29d4e678 100644 --- a/src/modules/staking/ETH-staking-api/getWbethWrapHistory.ts +++ b/src/modules/staking/ETH-staking-api/getWbethWrapHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/ETH-staking-api/getWbethWrapHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetWbethWrapHistory(server: McpServer) { server.tool( @@ -37,9 +37,9 @@ export function registerBinanceGetWbethWrapHistory(server: McpServer) { ...(params.current !== undefined && { current: params.current }), ...(params.size !== undefined && { size: params.size }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -50,9 +50,9 @@ export function registerBinanceGetWbethWrapHistory(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -62,8 +62,8 @@ export function registerBinanceGetWbethWrapHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/staking/ETH-staking-api/index.ts b/src/modules/staking/ETH-staking-api/index.ts index ce933182..9430f1f2 100644 --- a/src/modules/staking/ETH-staking-api/index.ts +++ b/src/modules/staking/ETH-staking-api/index.ts @@ -1,28 +1,28 @@ // src/tools/binance-staking/ETH-staking-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceEthStakingAccount } from "./ethStakingAccount.js" -import { registerBinanceGetCurrentEthStakingQuota } from "./getCurrentEthStakingQuota.js" -import { registerBinanceGetEthRedemptionHistory } from "./getEthRedemptionHistory.js" -import { registerBinanceGetEthStakingHistory } from "./getEthStakingHistory.js" -import { registerBinanceGetWbethRateHistory } from "./getWbethRateHistory.js" -import { registerBinanceGetWbethRewardsHistory } from "./getWbethRewardsHistory.js" -import { registerBinanceGetWbethUnwrapHistory } from "./getWbethUnwrapHistory.js" -import { registerBinanceGetWbethWrapHistory } from "./getWbethWrapHistory.js" -import { registerBinanceRedeemEth } from "./redeemEth.js" -import { registerBinanceSubscribeEthStaking } from "./subscribeEthStaking.js" -import { registerBinanceWrapBeth } from "./wrapBeth.js" +import { registerBinanceEthStakingAccount } from "./ethStakingAccount.js"; +import { registerBinanceGetCurrentEthStakingQuota } from "./getCurrentEthStakingQuota.js"; +import { registerBinanceGetEthRedemptionHistory } from "./getEthRedemptionHistory.js"; +import { registerBinanceGetEthStakingHistory } from "./getEthStakingHistory.js"; +import { registerBinanceGetWbethRateHistory } from "./getWbethRateHistory.js"; +import { registerBinanceGetWbethRewardsHistory } from "./getWbethRewardsHistory.js"; +import { registerBinanceGetWbethUnwrapHistory } from "./getWbethUnwrapHistory.js"; +import { registerBinanceGetWbethWrapHistory } from "./getWbethWrapHistory.js"; +import { registerBinanceRedeemEth } from "./redeemEth.js"; +import { registerBinanceSubscribeEthStaking } from "./subscribeEthStaking.js"; +import { registerBinanceWrapBeth } from "./wrapBeth.js"; export function registerBinanceETHStakingApiTools(server: McpServer) { - registerBinanceEthStakingAccount(server) - registerBinanceGetCurrentEthStakingQuota(server) - registerBinanceGetEthRedemptionHistory(server) - registerBinanceGetEthStakingHistory(server) - registerBinanceGetWbethRateHistory(server) - registerBinanceGetWbethRewardsHistory(server) - registerBinanceGetWbethUnwrapHistory(server) - registerBinanceGetWbethWrapHistory(server) - registerBinanceRedeemEth(server) - registerBinanceSubscribeEthStaking(server) - registerBinanceWrapBeth(server) + registerBinanceEthStakingAccount(server); + registerBinanceGetCurrentEthStakingQuota(server); + registerBinanceGetEthRedemptionHistory(server); + registerBinanceGetEthStakingHistory(server); + registerBinanceGetWbethRateHistory(server); + registerBinanceGetWbethRewardsHistory(server); + registerBinanceGetWbethUnwrapHistory(server); + registerBinanceGetWbethWrapHistory(server); + registerBinanceRedeemEth(server); + registerBinanceSubscribeEthStaking(server); + registerBinanceWrapBeth(server); } diff --git a/src/modules/staking/ETH-staking-api/redeemEth.ts b/src/modules/staking/ETH-staking-api/redeemEth.ts index 33fc2e31..53d22e97 100644 --- a/src/modules/staking/ETH-staking-api/redeemEth.ts +++ b/src/modules/staking/ETH-staking-api/redeemEth.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/ETH-staking-api/redeemEth.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceRedeemEth(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerBinanceRedeemEth(server: McpServer) { amount: params.amount, asset: params.asset, ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,9 +35,9 @@ export function registerBinanceRedeemEth(server: McpServer) { text: `Successfully redeemed WBETH or BETH for ETH. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -47,8 +47,8 @@ export function registerBinanceRedeemEth(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/staking/ETH-staking-api/subscribeEthStaking.ts b/src/modules/staking/ETH-staking-api/subscribeEthStaking.ts index f288528d..b9c9272d 100644 --- a/src/modules/staking/ETH-staking-api/subscribeEthStaking.ts +++ b/src/modules/staking/ETH-staking-api/subscribeEthStaking.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/ETH-staking-api/subscribeEthStaking.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceSubscribeEthStaking(server: McpServer) { server.tool( @@ -18,9 +18,9 @@ export function registerBinanceSubscribeEthStaking(server: McpServer) { const response = await stakingClient.restAPI.subscribeEthStaking({ amount: params.amount, ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,9 +29,9 @@ export function registerBinanceSubscribeEthStaking(server: McpServer) { text: `Successfully staked ETH and receive WBETH. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -41,8 +41,8 @@ export function registerBinanceSubscribeEthStaking(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/staking/ETH-staking-api/wrapBeth.ts b/src/modules/staking/ETH-staking-api/wrapBeth.ts index 01845a0c..596c5486 100644 --- a/src/modules/staking/ETH-staking-api/wrapBeth.ts +++ b/src/modules/staking/ETH-staking-api/wrapBeth.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/ETHStaking-api/wrapBeth.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceWrapBeth(server: McpServer) { server.tool( @@ -18,9 +18,9 @@ export function registerBinanceWrapBeth(server: McpServer) { const response = await stakingClient.restAPI.wrapBeth({ amount: params.amount, ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,9 +29,9 @@ export function registerBinanceWrapBeth(server: McpServer) { text: `Successfully convert BETH into WBETH. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -41,8 +41,8 @@ export function registerBinanceWrapBeth(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/staking/SOL-staking-api/claimBoostRewards.ts b/src/modules/staking/SOL-staking-api/claimBoostRewards.ts index 2cb0f0d9..f79e096c 100644 --- a/src/modules/staking/SOL-staking-api/claimBoostRewards.ts +++ b/src/modules/staking/SOL-staking-api/claimBoostRewards.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/SOL-staking-api/claimBoostRewards.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceClaimBoostRewards(server: McpServer) { server.tool( @@ -16,9 +16,9 @@ export function registerBinanceClaimBoostRewards(server: McpServer) { try { const response = await stakingClient.restAPI.claimBoostRewards({ ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,9 +29,9 @@ export function registerBinanceClaimBoostRewards(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -41,8 +41,8 @@ export function registerBinanceClaimBoostRewards(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/staking/SOL-staking-api/getBnsolRateHistory.ts b/src/modules/staking/SOL-staking-api/getBnsolRateHistory.ts index 7ee8fbc6..12381dac 100644 --- a/src/modules/staking/SOL-staking-api/getBnsolRateHistory.ts +++ b/src/modules/staking/SOL-staking-api/getBnsolRateHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/SOL-staking-api/getBnsolRateHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetBnsolRateHistory(server: McpServer) { server.tool( @@ -37,9 +37,9 @@ export function registerBinanceGetBnsolRateHistory(server: McpServer) { ...(params.current !== undefined && { current: params.current }), ...(params.size !== undefined && { size: params.size }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -50,9 +50,9 @@ export function registerBinanceGetBnsolRateHistory(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -62,8 +62,8 @@ export function registerBinanceGetBnsolRateHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/staking/SOL-staking-api/getBnsolRewardsHistory.ts b/src/modules/staking/SOL-staking-api/getBnsolRewardsHistory.ts index 277f7189..a11cfcab 100644 --- a/src/modules/staking/SOL-staking-api/getBnsolRewardsHistory.ts +++ b/src/modules/staking/SOL-staking-api/getBnsolRewardsHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/SOL-staking-api/getBnsolRewardsHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetBnsolRewardsHistory(server: McpServer) { server.tool( @@ -42,9 +42,9 @@ export function registerBinanceGetBnsolRewardsHistory(server: McpServer) { ...(params.size !== undefined && { size: params.size }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), ...(params.type && { type: params.type }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -55,9 +55,9 @@ export function registerBinanceGetBnsolRewardsHistory(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -67,8 +67,8 @@ export function registerBinanceGetBnsolRewardsHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/staking/SOL-staking-api/getBoostRewardsHistory.ts b/src/modules/staking/SOL-staking-api/getBoostRewardsHistory.ts index b4659629..674bcca5 100644 --- a/src/modules/staking/SOL-staking-api/getBoostRewardsHistory.ts +++ b/src/modules/staking/SOL-staking-api/getBoostRewardsHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/SOL-staking-api/getBoostRewardsHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetBoostRewardsHistory(server: McpServer) { server.tool( @@ -42,8 +42,8 @@ export function registerBinanceGetBoostRewardsHistory(server: McpServer) { ...(params.current !== undefined && { current: params.current }), ...(params.size !== undefined && { size: params.size }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -54,9 +54,9 @@ export function registerBinanceGetBoostRewardsHistory(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -66,8 +66,8 @@ export function registerBinanceGetBoostRewardsHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/staking/SOL-staking-api/getSolRedemptionHistory.ts b/src/modules/staking/SOL-staking-api/getSolRedemptionHistory.ts index 03e91757..de4997af 100644 --- a/src/modules/staking/SOL-staking-api/getSolRedemptionHistory.ts +++ b/src/modules/staking/SOL-staking-api/getSolRedemptionHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/SOL-staking-api/getSolRedemptionHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetSolRedemptionHistory(server: McpServer) { server.tool( @@ -37,9 +37,9 @@ export function registerBinanceGetSolRedemptionHistory(server: McpServer) { ...(params.current !== undefined && { current: params.current }), ...(params.size !== undefined && { size: params.size }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -48,9 +48,9 @@ export function registerBinanceGetSolRedemptionHistory(server: McpServer) { text: `Successfully retrieved SOL redemption history. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -60,8 +60,8 @@ export function registerBinanceGetSolRedemptionHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/staking/SOL-staking-api/getSolStakingHistory.ts b/src/modules/staking/SOL-staking-api/getSolStakingHistory.ts index e20e2c7c..4ebfba7b 100644 --- a/src/modules/staking/SOL-staking-api/getSolStakingHistory.ts +++ b/src/modules/staking/SOL-staking-api/getSolStakingHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/SOL-staking-api/getSolStakingHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetSolStakingHistory(server: McpServer) { server.tool( @@ -37,9 +37,9 @@ export function registerBinanceGetSolStakingHistory(server: McpServer) { ...(params.current !== undefined && { current: params.current }), ...(params.size !== undefined && { size: params.size }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -48,9 +48,9 @@ export function registerBinanceGetSolStakingHistory(server: McpServer) { text: `Successfully retrieved SOL staking history. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -60,8 +60,8 @@ export function registerBinanceGetSolStakingHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/staking/SOL-staking-api/getSolStakingQuotaDetails.ts b/src/modules/staking/SOL-staking-api/getSolStakingQuotaDetails.ts index 84ed7ce3..d2757f96 100644 --- a/src/modules/staking/SOL-staking-api/getSolStakingQuotaDetails.ts +++ b/src/modules/staking/SOL-staking-api/getSolStakingQuotaDetails.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/SOL-staking-api/getSolStakingQuotaDetails.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetSolStakingQuotaDetails(server: McpServer) { server.tool( @@ -16,9 +16,9 @@ export function registerBinanceGetSolStakingQuotaDetails(server: McpServer) { try { const response = await stakingClient.restAPI.getSolStakingQuotaDetails({ ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -27,9 +27,9 @@ export function registerBinanceGetSolStakingQuotaDetails(server: McpServer) { text: `Successfully retrieved current SOL staking quota. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -39,8 +39,8 @@ export function registerBinanceGetSolStakingQuotaDetails(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/staking/SOL-staking-api/getUnclaimedRewards.ts b/src/modules/staking/SOL-staking-api/getUnclaimedRewards.ts index 93687ff9..8d022775 100644 --- a/src/modules/staking/SOL-staking-api/getUnclaimedRewards.ts +++ b/src/modules/staking/SOL-staking-api/getUnclaimedRewards.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/SOL-staking-api/getUnclaimedRewards.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetUnclaimedRewards(server: McpServer) { server.tool( @@ -16,9 +16,9 @@ export function registerBinanceGetUnclaimedRewards(server: McpServer) { try { const response = await stakingClient.restAPI.getUnclaimedRewards({ ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,9 +29,9 @@ export function registerBinanceGetUnclaimedRewards(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -41,8 +41,8 @@ export function registerBinanceGetUnclaimedRewards(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/staking/SOL-staking-api/index.ts b/src/modules/staking/SOL-staking-api/index.ts index 117dd8e1..1485119d 100644 --- a/src/modules/staking/SOL-staking-api/index.ts +++ b/src/modules/staking/SOL-staking-api/index.ts @@ -1,28 +1,28 @@ // src/tools/binance-staking/SOL-staking-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceClaimBoostRewards } from "./claimBoostRewards.js" -import { registerBinanceGetBnsolRateHistory } from "./getBnsolRateHistory.js" -import { registerBinanceGetBnsolRewardsHistory } from "./getBnsolRewardsHistory.js" -import { registerBinanceGetBoostRewardsHistory } from "./getBoostRewardsHistory.js" -import { registerBinanceGetSolRedemptionHistory } from "./getSolRedemptionHistory.js" -import { registerBinanceGetSolStakingHistory } from "./getSolStakingHistory.js" -import { registerBinanceGetSolStakingQuotaDetails } from "./getSolStakingQuotaDetails.js" -import { registerBinanceGetUnclaimedRewards } from "./getUnclaimedRewards.js" -import { registerBinanceRedeemSol } from "./redeemSol.js" -import { registerBinanceSolStakingAccount } from "./solStakingAccount.js" -import { registerBinanceSubscribeSolStaking } from "./subscribeSolStaking.js" +import { registerBinanceClaimBoostRewards } from "./claimBoostRewards.js"; +import { registerBinanceGetBnsolRateHistory } from "./getBnsolRateHistory.js"; +import { registerBinanceGetBnsolRewardsHistory } from "./getBnsolRewardsHistory.js"; +import { registerBinanceGetBoostRewardsHistory } from "./getBoostRewardsHistory.js"; +import { registerBinanceGetSolRedemptionHistory } from "./getSolRedemptionHistory.js"; +import { registerBinanceGetSolStakingHistory } from "./getSolStakingHistory.js"; +import { registerBinanceGetSolStakingQuotaDetails } from "./getSolStakingQuotaDetails.js"; +import { registerBinanceGetUnclaimedRewards } from "./getUnclaimedRewards.js"; +import { registerBinanceRedeemSol } from "./redeemSol.js"; +import { registerBinanceSolStakingAccount } from "./solStakingAccount.js"; +import { registerBinanceSubscribeSolStaking } from "./subscribeSolStaking.js"; export function registerBinanceSOLStakingApiTools(server: McpServer) { - registerBinanceClaimBoostRewards(server) - registerBinanceGetBnsolRateHistory(server) - registerBinanceGetBnsolRewardsHistory(server) - registerBinanceGetBoostRewardsHistory(server) - registerBinanceGetSolRedemptionHistory(server) - registerBinanceGetSolStakingHistory(server) - registerBinanceGetSolStakingQuotaDetails(server) - registerBinanceGetUnclaimedRewards(server) - registerBinanceRedeemSol(server) - registerBinanceSolStakingAccount(server) - registerBinanceSubscribeSolStaking(server) + registerBinanceClaimBoostRewards(server); + registerBinanceGetBnsolRateHistory(server); + registerBinanceGetBnsolRewardsHistory(server); + registerBinanceGetBoostRewardsHistory(server); + registerBinanceGetSolRedemptionHistory(server); + registerBinanceGetSolStakingHistory(server); + registerBinanceGetSolStakingQuotaDetails(server); + registerBinanceGetUnclaimedRewards(server); + registerBinanceRedeemSol(server); + registerBinanceSolStakingAccount(server); + registerBinanceSubscribeSolStaking(server); } diff --git a/src/modules/staking/SOL-staking-api/redeemSol.ts b/src/modules/staking/SOL-staking-api/redeemSol.ts index ef2d7608..9121ac3c 100644 --- a/src/modules/staking/SOL-staking-api/redeemSol.ts +++ b/src/modules/staking/SOL-staking-api/redeemSol.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/SOL-staking-api/getUnclaimedRewards.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceRedeemSol(server: McpServer) { server.tool( @@ -22,9 +22,9 @@ export function registerBinanceRedeemSol(server: McpServer) { const response = await stakingClient.restAPI.redeemSol({ amount: params.amount, ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,9 +35,9 @@ export function registerBinanceRedeemSol(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -47,8 +47,8 @@ export function registerBinanceRedeemSol(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/staking/SOL-staking-api/solStakingAccount.ts b/src/modules/staking/SOL-staking-api/solStakingAccount.ts index 9674b5e3..65e2d89b 100644 --- a/src/modules/staking/SOL-staking-api/solStakingAccount.ts +++ b/src/modules/staking/SOL-staking-api/solStakingAccount.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/SOL-staking-api/solStakingAccount.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceSolStakingAccount(server: McpServer) { server.tool( @@ -16,9 +16,9 @@ export function registerBinanceSolStakingAccount(server: McpServer) { try { const response = await stakingClient.restAPI.solStakingAccount({ ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -27,9 +27,9 @@ export function registerBinanceSolStakingAccount(server: McpServer) { text: `Successfully retrieve SOL staking account details: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -39,8 +39,8 @@ export function registerBinanceSolStakingAccount(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/staking/SOL-staking-api/subscribeSolStaking.ts b/src/modules/staking/SOL-staking-api/subscribeSolStaking.ts index 81b31bf7..6ac11d78 100644 --- a/src/modules/staking/SOL-staking-api/subscribeSolStaking.ts +++ b/src/modules/staking/SOL-staking-api/subscribeSolStaking.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/SOL-staking-api/subscribeSolStaking.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceSubscribeSolStaking(server: McpServer) { server.tool( @@ -18,9 +18,9 @@ export function registerBinanceSubscribeSolStaking(server: McpServer) { const response = await stakingClient.restAPI.subscribeSolStaking({ amount: params.amount, ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,9 +29,9 @@ export function registerBinanceSubscribeSolStaking(server: McpServer) { text: `Successfully stake SOL and receive BNSOL in return: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -41,8 +41,8 @@ export function registerBinanceSubscribeSolStaking(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/staking/index.ts b/src/modules/staking/index.ts index 24764d95..d44b79ef 100644 --- a/src/modules/staking/index.ts +++ b/src/modules/staking/index.ts @@ -1,13 +1,13 @@ // src/tools/binance-staking/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceETHStakingApiTools } from "./ETH-staking-api/index.js" -import { registerBinanceSOLStakingApiTools } from "./SOL-staking-api/index.js" +import { registerBinanceETHStakingApiTools } from "./ETH-staking-api/index.js"; +import { registerBinanceSOLStakingApiTools } from "./SOL-staking-api/index.js"; export function registerBinanceStakingTools(server: McpServer) { - registerBinanceETHStakingApiTools(server) - registerBinanceSOLStakingApiTools(server) + registerBinanceETHStakingApiTools(server); + registerBinanceSOLStakingApiTools(server); } // Alias for binance.ts compatibility -export { registerBinanceStakingTools as registerStaking } +export { registerBinanceStakingTools as registerStaking }; diff --git a/src/modules/sub-account/index.ts b/src/modules/sub-account/index.ts index 65954ee2..3ebd3f25 100644 --- a/src/modules/sub-account/index.ts +++ b/src/modules/sub-account/index.ts @@ -1,8 +1,8 @@ // src/modules/sub-account/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceSubAccountTools } from "../../tools/binance-sub-account/index.js" +import { registerBinanceSubAccountTools } from "../../tools/binance-sub-account/index.js"; export function registerSubAccount(server: McpServer) { - registerBinanceSubAccountTools(server) + registerBinanceSubAccountTools(server); } diff --git a/src/modules/vip-loan/index.ts b/src/modules/vip-loan/index.ts index 64a53cad..a15c905e 100644 --- a/src/modules/vip-loan/index.ts +++ b/src/modules/vip-loan/index.ts @@ -1,15 +1,15 @@ // src/tools/binance-vip-loan/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceVipLoanMarketApiTools } from "./market-api/index.js" -import { registerBinanceVipLoanTradeApiTools } from "./trade-api/index.js" -import { registerBinanceVipLoanUserInformationApiTools } from "./userInformation-api/index.js" +import { registerBinanceVipLoanMarketApiTools } from "./market-api/index.js"; +import { registerBinanceVipLoanTradeApiTools } from "./trade-api/index.js"; +import { registerBinanceVipLoanUserInformationApiTools } from "./userInformation-api/index.js"; export function registerBinanceVipLoanTools(server: McpServer) { - registerBinanceVipLoanMarketApiTools(server) - registerBinanceVipLoanTradeApiTools(server) - registerBinanceVipLoanUserInformationApiTools(server) + registerBinanceVipLoanMarketApiTools(server); + registerBinanceVipLoanTradeApiTools(server); + registerBinanceVipLoanUserInformationApiTools(server); } // Alias for binance.ts compatibility -export { registerBinanceVipLoanTools as registerVipLoan } +export { registerBinanceVipLoanTools as registerVipLoan }; diff --git a/src/modules/vip-loan/market-api/getBorrowInterestRate.ts b/src/modules/vip-loan/market-api/getBorrowInterestRate.ts index bececb1b..d4c0a1c7 100644 --- a/src/modules/vip-loan/market-api/getBorrowInterestRate.ts +++ b/src/modules/vip-loan/market-api/getBorrowInterestRate.ts @@ -1,9 +1,9 @@ // src/tools/binance-vip-loan/market-api/getBorrowInterestRate.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { vipLoanClient } from "../../../config/binanceClient.js" +import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceGetBorrowInterestRate(server: McpServer) { server.tool( @@ -18,9 +18,9 @@ export function registerBinanceGetBorrowInterestRate(server: McpServer) { const response = await vipLoanClient.restAPI.getBorrowInterestRate({ loanCoin: params.loanCoin, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -31,9 +31,9 @@ export function registerBinanceGetBorrowInterestRate(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -43,8 +43,8 @@ export function registerBinanceGetBorrowInterestRate(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/vip-loan/market-api/getCollateralAssetData.ts b/src/modules/vip-loan/market-api/getCollateralAssetData.ts index b3ac53ff..012f657a 100644 --- a/src/modules/vip-loan/market-api/getCollateralAssetData.ts +++ b/src/modules/vip-loan/market-api/getCollateralAssetData.ts @@ -1,9 +1,9 @@ // src/tools/binance-vip-loan/market-api/getCollateralAssetData.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { vipLoanClient } from "../../../config/binanceClient.js" +import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceGetCollateralAssetData(server: McpServer) { server.tool( @@ -18,9 +18,9 @@ export function registerBinanceGetCollateralAssetData(server: McpServer) { const response = await vipLoanClient.restAPI.getCollateralAssetData({ ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -31,9 +31,9 @@ export function registerBinanceGetCollateralAssetData(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -43,8 +43,8 @@ export function registerBinanceGetCollateralAssetData(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/vip-loan/market-api/getLoanableAssetsData.ts b/src/modules/vip-loan/market-api/getLoanableAssetsData.ts index 69acff8d..f5a7c1c5 100644 --- a/src/modules/vip-loan/market-api/getLoanableAssetsData.ts +++ b/src/modules/vip-loan/market-api/getLoanableAssetsData.ts @@ -1,9 +1,9 @@ // src/tools/binance-vip-loan/market-api/getLoanableAssetsData.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { vipLoanClient } from "../../../config/binanceClient.js" +import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceGetLoanableAssetsData(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerBinanceGetLoanableAssetsData(server: McpServer) { ...(params.loanCoin && { loanCoin: params.loanCoin }), ...(params.vipLevel && { vipLevel: params.vipLevel }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -37,9 +37,9 @@ export function registerBinanceGetLoanableAssetsData(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -49,8 +49,8 @@ export function registerBinanceGetLoanableAssetsData(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/vip-loan/market-api/index.ts b/src/modules/vip-loan/market-api/index.ts index ffc74390..5ee3c97f 100644 --- a/src/modules/vip-loan/market-api/index.ts +++ b/src/modules/vip-loan/market-api/index.ts @@ -1,12 +1,12 @@ // src/tools/binance-vip-loan/market-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetBorrowInterestRate } from "./getBorrowInterestRate.js" -import { registerBinanceGetCollateralAssetData } from "./getCollateralAssetData.js" -import { registerBinanceGetLoanableAssetsData } from "./getLoanableAssetsData.js" +import { registerBinanceGetBorrowInterestRate } from "./getBorrowInterestRate.js"; +import { registerBinanceGetCollateralAssetData } from "./getCollateralAssetData.js"; +import { registerBinanceGetLoanableAssetsData } from "./getLoanableAssetsData.js"; export function registerBinanceVipLoanMarketApiTools(server: McpServer) { - registerBinanceGetBorrowInterestRate(server) - registerBinanceGetCollateralAssetData(server) - registerBinanceGetLoanableAssetsData(server) + registerBinanceGetBorrowInterestRate(server); + registerBinanceGetCollateralAssetData(server); + registerBinanceGetLoanableAssetsData(server); } diff --git a/src/modules/vip-loan/trade-api/index.ts b/src/modules/vip-loan/trade-api/index.ts index 85a97036..95c9cb6c 100644 --- a/src/modules/vip-loan/trade-api/index.ts +++ b/src/modules/vip-loan/trade-api/index.ts @@ -1,12 +1,12 @@ // src/tools/binance-vip-loan/trade-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceVipLoanBorrow } from "./vipLoanBorrow.js" -import { registerBinanceVipLoanRenew } from "./vipLoanRenew.js" -import { registerBinanceVipLoanRepay } from "./vipLoanRepay.js" +import { registerBinanceVipLoanBorrow } from "./vipLoanBorrow.js"; +import { registerBinanceVipLoanRenew } from "./vipLoanRenew.js"; +import { registerBinanceVipLoanRepay } from "./vipLoanRepay.js"; export function registerBinanceVipLoanTradeApiTools(server: McpServer) { - registerBinanceVipLoanRenew(server) - registerBinanceVipLoanRepay(server) - registerBinanceVipLoanBorrow(server) + registerBinanceVipLoanRenew(server); + registerBinanceVipLoanRepay(server); + registerBinanceVipLoanBorrow(server); } diff --git a/src/modules/vip-loan/trade-api/vipLoanBorrow.ts b/src/modules/vip-loan/trade-api/vipLoanBorrow.ts index 032e83c4..d47f03de 100644 --- a/src/modules/vip-loan/trade-api/vipLoanBorrow.ts +++ b/src/modules/vip-loan/trade-api/vipLoanBorrow.ts @@ -1,9 +1,9 @@ // src/tools/binance-vip-loan/trade-api/vipLoanBorrow.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { vipLoanClient } from "../../../config/binanceClient.js" +import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceVipLoanBorrow(server: McpServer) { server.tool( @@ -37,9 +37,9 @@ export function registerBinanceVipLoanBorrow(server: McpServer) { isFlexibleRate: params.isFlexibleRate, ...(params.loanTerm !== undefined && { loanTerm: params.loanTerm }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -50,9 +50,9 @@ export function registerBinanceVipLoanBorrow(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -62,8 +62,8 @@ export function registerBinanceVipLoanBorrow(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/vip-loan/trade-api/vipLoanRenew.ts b/src/modules/vip-loan/trade-api/vipLoanRenew.ts index 2699fbb4..7ffcc0ad 100644 --- a/src/modules/vip-loan/trade-api/vipLoanRenew.ts +++ b/src/modules/vip-loan/trade-api/vipLoanRenew.ts @@ -1,9 +1,9 @@ // src/tools/binance-vip-loan/trade-api/vipLoanRenew.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { vipLoanClient } from "../../../config/binanceClient.js" +import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceVipLoanRenew(server: McpServer) { server.tool( @@ -26,8 +26,8 @@ export function registerBinanceVipLoanRenew(server: McpServer) { orderId: params.orderId, loanTerm: params.loanTerm, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -36,9 +36,9 @@ export function registerBinanceVipLoanRenew(server: McpServer) { text: `Successfully renew an existing VIP loan. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -48,8 +48,8 @@ export function registerBinanceVipLoanRenew(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/vip-loan/trade-api/vipLoanRepay.ts b/src/modules/vip-loan/trade-api/vipLoanRepay.ts index 8f8d7041..11fa3f64 100644 --- a/src/modules/vip-loan/trade-api/vipLoanRepay.ts +++ b/src/modules/vip-loan/trade-api/vipLoanRepay.ts @@ -1,9 +1,9 @@ // src/tools/binance-vip-loan/trade-api/vipLoanRepay.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { vipLoanClient } from "../../../config/binanceClient.js" +import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceVipLoanRepay(server: McpServer) { server.tool( @@ -20,9 +20,9 @@ export function registerBinanceVipLoanRepay(server: McpServer) { orderId: params.orderId, amount: params.amount, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -31,9 +31,9 @@ export function registerBinanceVipLoanRepay(server: McpServer) { text: `Successfully repay the active loan. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -43,8 +43,8 @@ export function registerBinanceVipLoanRepay(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/vip-loan/userInformation-api/checkVIPLoanCollateralAccount.ts b/src/modules/vip-loan/userInformation-api/checkVIPLoanCollateralAccount.ts index ca85b235..4d3b2b01 100644 --- a/src/modules/vip-loan/userInformation-api/checkVIPLoanCollateralAccount.ts +++ b/src/modules/vip-loan/userInformation-api/checkVIPLoanCollateralAccount.ts @@ -1,9 +1,9 @@ // src/tools/binance-vip-loan/userInformation-api/checkVIPLoanCollateralAccount.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { vipLoanClient } from "../../../config/binanceClient.js" +import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCheckVIPLoanCollateralAccount(server: McpServer) { server.tool( @@ -22,9 +22,9 @@ export function registerBinanceCheckVIPLoanCollateralAccount(server: McpServer) collateralAccountId: params.collateralAccountId, }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,9 +35,9 @@ export function registerBinanceCheckVIPLoanCollateralAccount(server: McpServer) )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -47,8 +47,8 @@ export function registerBinanceCheckVIPLoanCollateralAccount(server: McpServer) }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/vip-loan/userInformation-api/getVIPLoanOngoingOrders.ts b/src/modules/vip-loan/userInformation-api/getVIPLoanOngoingOrders.ts index 4effee4e..6f984328 100644 --- a/src/modules/vip-loan/userInformation-api/getVIPLoanOngoingOrders.ts +++ b/src/modules/vip-loan/userInformation-api/getVIPLoanOngoingOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-vip-loan/userInformation-api/getVIPLoanOngoingOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { vipLoanClient } from "../../../config/binanceClient.js" +import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceGetVIPLoanOngoingOrders(server: McpServer) { server.tool( @@ -42,9 +42,9 @@ export function registerBinanceGetVIPLoanOngoingOrders(server: McpServer) { ...(params.current !== undefined && { current: params.current }), ...(params.limit !== undefined && { limit: params.limit }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -55,9 +55,9 @@ export function registerBinanceGetVIPLoanOngoingOrders(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -67,8 +67,8 @@ export function registerBinanceGetVIPLoanOngoingOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/vip-loan/userInformation-api/index.ts b/src/modules/vip-loan/userInformation-api/index.ts index 82cd64ab..fcffe103 100644 --- a/src/modules/vip-loan/userInformation-api/index.ts +++ b/src/modules/vip-loan/userInformation-api/index.ts @@ -1,12 +1,12 @@ // src/tools/binance-vip-loan/userInformation-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceCheckVIPLoanCollateralAccount } from "./checkVIPLoanCollateralAccount.js" -import { registerBinanceGetVIPLoanOngoingOrders } from "./getVIPLoanOngoingOrders.js" -import { registerBinanceQueryApplicationStatus } from "./queryApplicationStatus.js" +import { registerBinanceCheckVIPLoanCollateralAccount } from "./checkVIPLoanCollateralAccount.js"; +import { registerBinanceGetVIPLoanOngoingOrders } from "./getVIPLoanOngoingOrders.js"; +import { registerBinanceQueryApplicationStatus } from "./queryApplicationStatus.js"; export function registerBinanceVipLoanUserInformationApiTools(server: McpServer) { - registerBinanceCheckVIPLoanCollateralAccount(server) - registerBinanceGetVIPLoanOngoingOrders(server) - registerBinanceQueryApplicationStatus(server) + registerBinanceCheckVIPLoanCollateralAccount(server); + registerBinanceGetVIPLoanOngoingOrders(server); + registerBinanceQueryApplicationStatus(server); } diff --git a/src/modules/vip-loan/userInformation-api/queryApplicationStatus.ts b/src/modules/vip-loan/userInformation-api/queryApplicationStatus.ts index aa8a6295..9288868f 100644 --- a/src/modules/vip-loan/userInformation-api/queryApplicationStatus.ts +++ b/src/modules/vip-loan/userInformation-api/queryApplicationStatus.ts @@ -1,9 +1,9 @@ // src/tools/binance-vip-loan/userInformation-api/queryApplicationStatus.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { vipLoanClient } from "../../../config/binanceClient.js" +import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceQueryApplicationStatus(server: McpServer) { server.tool( @@ -26,9 +26,9 @@ export function registerBinanceQueryApplicationStatus(server: McpServer) { ...(params.current !== undefined && { current: params.current }), ...(params.limit !== undefined && { limit: params.limit }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -39,9 +39,9 @@ export function registerBinanceQueryApplicationStatus(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -51,8 +51,8 @@ export function registerBinanceQueryApplicationStatus(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/account-api/accountApiTradingStatus.ts b/src/modules/wallet/account-api/accountApiTradingStatus.ts index c24c0226..d677bf15 100644 --- a/src/modules/wallet/account-api/accountApiTradingStatus.ts +++ b/src/modules/wallet/account-api/accountApiTradingStatus.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/account-api/accountApiTradingStatus.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletAccountApiTradingStatus(server: McpServer) { server.tool( @@ -14,11 +14,11 @@ export function registerBinanceWalletAccountApiTradingStatus(server: McpServer) }, async ({ recvWindow }) => { try { - const params: any = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.accountApiTradingStatus(params) - const data = await response.data() + const response = await walletClient.restAPI.accountApiTradingStatus(params); + const data = await response.data(); return { content: [ @@ -27,9 +27,9 @@ export function registerBinanceWalletAccountApiTradingStatus(server: McpServer) text: `Retrieved account API trading status. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -39,8 +39,8 @@ export function registerBinanceWalletAccountApiTradingStatus(server: McpServer) }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/account-api/accountInfo.ts b/src/modules/wallet/account-api/accountInfo.ts index 39b964df..ce607633 100644 --- a/src/modules/wallet/account-api/accountInfo.ts +++ b/src/modules/wallet/account-api/accountInfo.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/account-api/accountInfo.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletAccountInfo(server: McpServer) { server.tool( @@ -14,11 +14,11 @@ export function registerBinanceWalletAccountInfo(server: McpServer) { }, async ({ recvWindow }) => { try { - const params: any = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.accountInfo(params) - const data = await response.data() + const response = await walletClient.restAPI.accountInfo(params); + const data = await response.data(); return { content: [ @@ -27,9 +27,9 @@ export function registerBinanceWalletAccountInfo(server: McpServer) { text: `Retrieved wallet account information. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -39,8 +39,8 @@ export function registerBinanceWalletAccountInfo(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/account-api/accountStatus.ts b/src/modules/wallet/account-api/accountStatus.ts index 4cefe42b..fd202436 100644 --- a/src/modules/wallet/account-api/accountStatus.ts +++ b/src/modules/wallet/account-api/accountStatus.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/account-api/accountStatus.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletAccountStatus(server: McpServer) { server.tool( @@ -14,11 +14,11 @@ export function registerBinanceWalletAccountStatus(server: McpServer) { }, async ({ recvWindow }) => { try { - const params: any = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.accountStatus(params) - const data = await response.data() + const response = await walletClient.restAPI.accountStatus(params); + const data = await response.data(); return { content: [ @@ -27,17 +27,17 @@ export function registerBinanceWalletAccountStatus(server: McpServer) { text: `Retrieved wallet account status. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve wallet account status: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/account-api/dailyAccountSnapshot.ts b/src/modules/wallet/account-api/dailyAccountSnapshot.ts index 145e3db8..39fe678f 100644 --- a/src/modules/wallet/account-api/dailyAccountSnapshot.ts +++ b/src/modules/wallet/account-api/dailyAccountSnapshot.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/account-api/dailyAccountSnapshot.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletDailyAccountSnapshot(server: McpServer) { server.tool( @@ -18,14 +18,14 @@ export function registerBinanceWalletDailyAccountSnapshot(server: McpServer) { }, async ({ type, startTime, endTime, limit, recvWindow }) => { try { - const params: any = { type } - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = { type }; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.dailyAccountSnapshot(params) - const data = await response.data() + const response = await walletClient.restAPI.dailyAccountSnapshot(params); + const data = await response.data(); return { content: [ @@ -34,17 +34,17 @@ export function registerBinanceWalletDailyAccountSnapshot(server: McpServer) { text: `Retrieved daily account snapshot for ${type}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve daily account snapshot: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/account-api/disableFastWithdrawSwitch.ts b/src/modules/wallet/account-api/disableFastWithdrawSwitch.ts index f348aaa2..66915d9a 100644 --- a/src/modules/wallet/account-api/disableFastWithdrawSwitch.ts +++ b/src/modules/wallet/account-api/disableFastWithdrawSwitch.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/account-api/disableFastWithdrawSwitch.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletDisableFastWithdrawSwitch(server: McpServer) { server.tool( @@ -14,11 +14,11 @@ export function registerBinanceWalletDisableFastWithdrawSwitch(server: McpServer }, async ({ recvWindow }) => { try { - const params: any = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.disableFastWithdrawSwitch(params) - const data = await response.data() + const response = await walletClient.restAPI.disableFastWithdrawSwitch(params); + const data = await response.data(); return { content: [ @@ -27,17 +27,17 @@ export function registerBinanceWalletDisableFastWithdrawSwitch(server: McpServer text: `Disabled fast withdraw switch. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to disable fast withdraw switch: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/account-api/enableFastWithdrawSwitch.ts b/src/modules/wallet/account-api/enableFastWithdrawSwitch.ts index 08b0430f..657cf9ee 100644 --- a/src/modules/wallet/account-api/enableFastWithdrawSwitch.ts +++ b/src/modules/wallet/account-api/enableFastWithdrawSwitch.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/account-api/enableFastWithdrawSwitch.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletEnableFastWithdrawSwitch(server: McpServer) { server.tool( @@ -14,11 +14,11 @@ export function registerBinanceWalletEnableFastWithdrawSwitch(server: McpServer) }, async ({ recvWindow }) => { try { - const params: any = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.enableFastWithdrawSwitch(params) - const data = await response.data() + const response = await walletClient.restAPI.enableFastWithdrawSwitch(params); + const data = await response.data(); return { content: [ @@ -27,17 +27,17 @@ export function registerBinanceWalletEnableFastWithdrawSwitch(server: McpServer) text: `Enabled fast withdraw switch. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to enable fast withdraw switch: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/account-api/getApiKeyPermission.ts b/src/modules/wallet/account-api/getApiKeyPermission.ts index 782053fb..bda72cb5 100644 --- a/src/modules/wallet/account-api/getApiKeyPermission.ts +++ b/src/modules/wallet/account-api/getApiKeyPermission.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/account-api/getApiKeyPermission.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletGetApiKeyPermission(server: McpServer) { server.tool( @@ -14,11 +14,11 @@ export function registerBinanceWalletGetApiKeyPermission(server: McpServer) { }, async ({ recvWindow }) => { try { - const params: any = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.getApiKeyPermission(params) - const data = await response.data() + const response = await walletClient.restAPI.getApiKeyPermission(params); + const data = await response.data(); return { content: [ @@ -27,17 +27,17 @@ export function registerBinanceWalletGetApiKeyPermission(server: McpServer) { text: `Retrieved API key permission. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve API key permission: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/account-api/index.ts b/src/modules/wallet/account-api/index.ts index c01341a4..d454e39c 100644 --- a/src/modules/wallet/account-api/index.ts +++ b/src/modules/wallet/account-api/index.ts @@ -1,20 +1,20 @@ // src/tools/binance-wallet/account-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceWalletAccountApiTradingStatus } from "./accountApiTradingStatus.js" -import { registerBinanceWalletAccountInfo } from "./accountInfo.js" -import { registerBinanceWalletAccountStatus } from "./accountStatus.js" -import { registerBinanceWalletDailyAccountSnapshot } from "./dailyAccountSnapshot.js" -import { registerBinanceWalletDisableFastWithdrawSwitch } from "./disableFastWithdrawSwitch.js" -import { registerBinanceWalletEnableFastWithdrawSwitch } from "./enableFastWithdrawSwitch.js" -import { registerBinanceWalletGetApiKeyPermission } from "./getApiKeyPermission.js" +import { registerBinanceWalletAccountApiTradingStatus } from "./accountApiTradingStatus.js"; +import { registerBinanceWalletAccountInfo } from "./accountInfo.js"; +import { registerBinanceWalletAccountStatus } from "./accountStatus.js"; +import { registerBinanceWalletDailyAccountSnapshot } from "./dailyAccountSnapshot.js"; +import { registerBinanceWalletDisableFastWithdrawSwitch } from "./disableFastWithdrawSwitch.js"; +import { registerBinanceWalletEnableFastWithdrawSwitch } from "./enableFastWithdrawSwitch.js"; +import { registerBinanceWalletGetApiKeyPermission } from "./getApiKeyPermission.js"; export function registerBinanceWalletAccountApiTools(server: McpServer) { - registerBinanceWalletDailyAccountSnapshot(server) - registerBinanceWalletGetApiKeyPermission(server) - registerBinanceWalletAccountInfo(server) - registerBinanceWalletAccountStatus(server) - registerBinanceWalletAccountApiTradingStatus(server) - registerBinanceWalletEnableFastWithdrawSwitch(server) - registerBinanceWalletDisableFastWithdrawSwitch(server) + registerBinanceWalletDailyAccountSnapshot(server); + registerBinanceWalletGetApiKeyPermission(server); + registerBinanceWalletAccountInfo(server); + registerBinanceWalletAccountStatus(server); + registerBinanceWalletAccountApiTradingStatus(server); + registerBinanceWalletEnableFastWithdrawSwitch(server); + registerBinanceWalletDisableFastWithdrawSwitch(server); } diff --git a/src/modules/wallet/asset-api/assetDetail.ts b/src/modules/wallet/asset-api/assetDetail.ts index 33f3dd6b..c49f28fa 100644 --- a/src/modules/wallet/asset-api/assetDetail.ts +++ b/src/modules/wallet/asset-api/assetDetail.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/asset-api/assetDetail.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletAssetDetail(server: McpServer) { server.tool( @@ -15,12 +15,12 @@ export function registerBinanceWalletAssetDetail(server: McpServer) { }, async ({ asset, recvWindow }) => { try { - const params: any = {} - if (asset !== undefined) params.asset = asset - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (asset !== undefined) params.asset = asset; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.assetDetail(params) - const data = await response.data() + const response = await walletClient.restAPI.assetDetail(params); + const data = await response.data(); return { content: [ @@ -29,15 +29,15 @@ export function registerBinanceWalletAssetDetail(server: McpServer) { text: `Retrieved asset details. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve asset details: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/asset-api/assetDividendRecord.ts b/src/modules/wallet/asset-api/assetDividendRecord.ts index 038cf6aa..6944e01b 100644 --- a/src/modules/wallet/asset-api/assetDividendRecord.ts +++ b/src/modules/wallet/asset-api/assetDividendRecord.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/asset-api/assetDividendRecord.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletAssetDividendRecord(server: McpServer) { server.tool( @@ -18,15 +18,15 @@ export function registerBinanceWalletAssetDividendRecord(server: McpServer) { }, async ({ asset, startTime, endTime, limit, recvWindow }) => { try { - const params: any = {} - if (asset !== undefined) params.asset = asset - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (asset !== undefined) params.asset = asset; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.assetDividendRecord(params) - const data = await response.data() + const response = await walletClient.restAPI.assetDividendRecord(params); + const data = await response.data(); return { content: [ @@ -35,17 +35,17 @@ export function registerBinanceWalletAssetDividendRecord(server: McpServer) { text: `Retrieved asset dividend record. Total records: ${data.total || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve asset dividend record: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/asset-api/dustTransfer.ts b/src/modules/wallet/asset-api/dustTransfer.ts index bc1ebf68..965f940e 100644 --- a/src/modules/wallet/asset-api/dustTransfer.ts +++ b/src/modules/wallet/asset-api/dustTransfer.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/asset-api/dustTransfer.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletDustTransfer(server: McpServer) { server.tool( @@ -15,11 +15,11 @@ export function registerBinanceWalletDustTransfer(server: McpServer) { }, async ({ asset, recvWindow }) => { try { - const params: any = { asset } - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = { asset }; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.dustTransfer(params) - const data = await response.data() + const response = await walletClient.restAPI.dustTransfer(params); + const data = await response.data(); return { content: [ @@ -28,15 +28,15 @@ export function registerBinanceWalletDustTransfer(server: McpServer) { text: `Dust transfer completed. Total BNB received: ${data.totalServiceCharge || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to process dust transfer: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/asset-api/dustlog.ts b/src/modules/wallet/asset-api/dustlog.ts index f86dd243..62ede583 100644 --- a/src/modules/wallet/asset-api/dustlog.ts +++ b/src/modules/wallet/asset-api/dustlog.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/asset-api/dustlog.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletDustlog(server: McpServer) { server.tool( @@ -16,13 +16,13 @@ export function registerBinanceWalletDustlog(server: McpServer) { }, async ({ startTime, endTime, recvWindow }) => { try { - const params: any = {} - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.dustlog(params) - const data = await response.data() + const response = await walletClient.restAPI.dustlog(params); + const data = await response.data(); return { content: [ @@ -31,15 +31,15 @@ export function registerBinanceWalletDustlog(server: McpServer) { text: `Retrieved dust log. Total transfers: ${data.total || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve dust log: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/asset-api/fundingWallet.ts b/src/modules/wallet/asset-api/fundingWallet.ts index 28ecfab4..0a11d347 100644 --- a/src/modules/wallet/asset-api/fundingWallet.ts +++ b/src/modules/wallet/asset-api/fundingWallet.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/asset-api/fundingWallet.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletFundingWallet(server: McpServer) { server.tool( @@ -16,13 +16,13 @@ export function registerBinanceWalletFundingWallet(server: McpServer) { }, async ({ asset, needBtcValuation, recvWindow }) => { try { - const params: any = {} - if (asset !== undefined) params.asset = asset - if (needBtcValuation !== undefined) params.needBtcValuation = needBtcValuation - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (asset !== undefined) params.asset = asset; + if (needBtcValuation !== undefined) params.needBtcValuation = needBtcValuation; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.fundingWallet(params) - const data = await response.data() + const response = await walletClient.restAPI.fundingWallet(params); + const data = await response.data(); return { content: [ @@ -31,17 +31,17 @@ export function registerBinanceWalletFundingWallet(server: McpServer) { text: `Retrieved funding wallet balance. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve funding wallet balance: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts b/src/modules/wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts index aa233936..41a83029 100644 --- a/src/modules/wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts +++ b/src/modules/wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletGetAssetsThatCanBeConvertedIntoBnb(server: McpServer) { server.tool( @@ -14,11 +14,11 @@ export function registerBinanceWalletGetAssetsThatCanBeConvertedIntoBnb(server: }, async ({ recvWindow }) => { try { - const params: any = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.getAssetsThatCanBeConvertedIntoBnb(params) - const data = await response.data() + const response = await walletClient.restAPI.getAssetsThatCanBeConvertedIntoBnb(params); + const data = await response.data(); return { content: [ @@ -27,17 +27,17 @@ export function registerBinanceWalletGetAssetsThatCanBeConvertedIntoBnb(server: text: `Retrieved assets that can be converted to BNB. Total: ${data.details?.length || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve convertible assets: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts b/src/modules/wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts index 52652ef4..90b98913 100644 --- a/src/modules/wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts +++ b/src/modules/wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletGetCloudMiningPaymentAndRefundHistory(server: McpServer) { server.tool( @@ -21,13 +21,13 @@ export function registerBinanceWalletGetCloudMiningPaymentAndRefundHistory(serve const params: any = { startTime, endTime, - } - if (page !== undefined) params.page = page - if (pageSize !== undefined) params.pageSize = pageSize - if (recvWindow !== undefined) params.recvWindow = recvWindow + }; + if (page !== undefined) params.page = page; + if (pageSize !== undefined) params.pageSize = pageSize; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.getCloudMiningPaymentAndRefundHistory(params) - const data = await response.data() + const response = await walletClient.restAPI.getCloudMiningPaymentAndRefundHistory(params); + const data = await response.data(); return { content: [ @@ -36,17 +36,17 @@ export function registerBinanceWalletGetCloudMiningPaymentAndRefundHistory(serve text: `Retrieved cloud mining payment and refund history. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve cloud mining history: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/asset-api/getOpenSymbolList.ts b/src/modules/wallet/asset-api/getOpenSymbolList.ts index f79ebab2..0e112d72 100644 --- a/src/modules/wallet/asset-api/getOpenSymbolList.ts +++ b/src/modules/wallet/asset-api/getOpenSymbolList.ts @@ -1,13 +1,13 @@ // src/tools/binance-wallet/asset-api/getOpenSymbolList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletGetOpenSymbolList(server: McpServer) { server.tool("BinanceWalletGetOpenSymbolList", "Get open symbol list.", {}, async () => { try { - const response = await walletClient.restAPI.getOpenSymbolList() - const data = await response.data() + const response = await walletClient.restAPI.getOpenSymbolList(); + const data = await response.data(); return { content: [ @@ -16,14 +16,14 @@ export function registerBinanceWalletGetOpenSymbolList(server: McpServer) { text: `Retrieved open symbol list. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve open symbol list: ${errorMessage}` }], isError: true, - } + }; } - }) + }); } diff --git a/src/modules/wallet/asset-api/index.ts b/src/modules/wallet/asset-api/index.ts index e736e603..d06e8cd3 100644 --- a/src/modules/wallet/asset-api/index.ts +++ b/src/modules/wallet/asset-api/index.ts @@ -1,36 +1,36 @@ // src/tools/binance-wallet/asset-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceWalletAssetDetail } from "./assetDetail.js" -import { registerBinanceWalletAssetDividendRecord } from "./assetDividendRecord.js" -import { registerBinanceWalletDustlog } from "./dustlog.js" -import { registerBinanceWalletDustTransfer } from "./dustTransfer.js" -import { registerBinanceWalletFundingWallet } from "./fundingWallet.js" -import { registerBinanceWalletGetAssetsThatCanBeConvertedIntoBnb } from "./getAssetsThatCanBeConvertedIntoBnb.js" -import { registerBinanceWalletGetCloudMiningPaymentAndRefundHistory } from "./getCloudMiningPaymentAndRefundHistory.js" -import { registerBinanceWalletGetOpenSymbolList } from "./getOpenSymbolList.js" -import { registerBinanceWalletQueryUserDelegationHistory } from "./queryUserDelegationHistory.js" -import { registerBinanceWalletQueryUserUniversalTransferHistory } from "./queryUserUniversalTransferHistory.js" -import { registerBinanceWalletQueryUserWalletBalance } from "./queryUserWalletBalance.js" -import { registerBinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest } from "./toggleBnbBurnOnSpotTradeAndMarginInterest.js" -import { registerBinanceWalletTradeFee } from "./tradeFee.js" -import { registerBinanceWalletUserAsset } from "./userAsset.js" -import { registerBinanceWalletUserUniversalTransfer } from "./userUniversalTransfer.js" +import { registerBinanceWalletAssetDetail } from "./assetDetail.js"; +import { registerBinanceWalletAssetDividendRecord } from "./assetDividendRecord.js"; +import { registerBinanceWalletDustlog } from "./dustlog.js"; +import { registerBinanceWalletDustTransfer } from "./dustTransfer.js"; +import { registerBinanceWalletFundingWallet } from "./fundingWallet.js"; +import { registerBinanceWalletGetAssetsThatCanBeConvertedIntoBnb } from "./getAssetsThatCanBeConvertedIntoBnb.js"; +import { registerBinanceWalletGetCloudMiningPaymentAndRefundHistory } from "./getCloudMiningPaymentAndRefundHistory.js"; +import { registerBinanceWalletGetOpenSymbolList } from "./getOpenSymbolList.js"; +import { registerBinanceWalletQueryUserDelegationHistory } from "./queryUserDelegationHistory.js"; +import { registerBinanceWalletQueryUserUniversalTransferHistory } from "./queryUserUniversalTransferHistory.js"; +import { registerBinanceWalletQueryUserWalletBalance } from "./queryUserWalletBalance.js"; +import { registerBinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest } from "./toggleBnbBurnOnSpotTradeAndMarginInterest.js"; +import { registerBinanceWalletTradeFee } from "./tradeFee.js"; +import { registerBinanceWalletUserAsset } from "./userAsset.js"; +import { registerBinanceWalletUserUniversalTransfer } from "./userUniversalTransfer.js"; export function registerBinanceWalletAssetApiTools(server: McpServer) { - registerBinanceWalletUserAsset(server) - registerBinanceWalletFundingWallet(server) - registerBinanceWalletAssetDetail(server) - registerBinanceWalletTradeFee(server) - registerBinanceWalletUserUniversalTransfer(server) - registerBinanceWalletQueryUserUniversalTransferHistory(server) - registerBinanceWalletDustTransfer(server) - registerBinanceWalletDustlog(server) - registerBinanceWalletAssetDividendRecord(server) - registerBinanceWalletGetAssetsThatCanBeConvertedIntoBnb(server) - registerBinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest(server) - registerBinanceWalletGetCloudMiningPaymentAndRefundHistory(server) - registerBinanceWalletQueryUserDelegationHistory(server) - registerBinanceWalletGetOpenSymbolList(server) - registerBinanceWalletQueryUserWalletBalance(server) + registerBinanceWalletUserAsset(server); + registerBinanceWalletFundingWallet(server); + registerBinanceWalletAssetDetail(server); + registerBinanceWalletTradeFee(server); + registerBinanceWalletUserUniversalTransfer(server); + registerBinanceWalletQueryUserUniversalTransferHistory(server); + registerBinanceWalletDustTransfer(server); + registerBinanceWalletDustlog(server); + registerBinanceWalletAssetDividendRecord(server); + registerBinanceWalletGetAssetsThatCanBeConvertedIntoBnb(server); + registerBinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest(server); + registerBinanceWalletGetCloudMiningPaymentAndRefundHistory(server); + registerBinanceWalletQueryUserDelegationHistory(server); + registerBinanceWalletGetOpenSymbolList(server); + registerBinanceWalletQueryUserWalletBalance(server); } diff --git a/src/modules/wallet/asset-api/queryUserDelegationHistory.ts b/src/modules/wallet/asset-api/queryUserDelegationHistory.ts index 733e68ec..58d0767d 100644 --- a/src/modules/wallet/asset-api/queryUserDelegationHistory.ts +++ b/src/modules/wallet/asset-api/queryUserDelegationHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/asset-api/queryUserDelegationHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletQueryUserDelegationHistory(server: McpServer) { server.tool( @@ -23,13 +23,13 @@ export function registerBinanceWalletQueryUserDelegationHistory(server: McpServe email, startTime, endTime, - } - if (page !== undefined) params.page = page - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + }; + if (page !== undefined) params.page = page; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.queryUserDelegationHistory(params) - const data = await response.data() + const response = await walletClient.restAPI.queryUserDelegationHistory(params); + const data = await response.data(); return { content: [ @@ -38,17 +38,17 @@ export function registerBinanceWalletQueryUserDelegationHistory(server: McpServe text: `Retrieved user delegation history. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve user delegation history: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/asset-api/queryUserUniversalTransferHistory.ts b/src/modules/wallet/asset-api/queryUserUniversalTransferHistory.ts index f8c0bb20..f5c23c09 100644 --- a/src/modules/wallet/asset-api/queryUserUniversalTransferHistory.ts +++ b/src/modules/wallet/asset-api/queryUserUniversalTransferHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/asset-api/queryUserUniversalTransferHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletQueryUserUniversalTransferHistory(server: McpServer) { server.tool( @@ -21,17 +21,17 @@ export function registerBinanceWalletQueryUserUniversalTransferHistory(server: M }, async ({ type, startTime, endTime, current, size, fromSymbol, toSymbol, recvWindow }) => { try { - const params: any = { type } - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (current !== undefined) params.current = current - if (size !== undefined) params.size = size - if (fromSymbol !== undefined) params.fromSymbol = fromSymbol - if (toSymbol !== undefined) params.toSymbol = toSymbol - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = { type }; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (current !== undefined) params.current = current; + if (size !== undefined) params.size = size; + if (fromSymbol !== undefined) params.fromSymbol = fromSymbol; + if (toSymbol !== undefined) params.toSymbol = toSymbol; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.queryUserUniversalTransferHistory(params) - const data = await response.data() + const response = await walletClient.restAPI.queryUserUniversalTransferHistory(params); + const data = await response.data(); return { content: [ @@ -40,9 +40,9 @@ export function registerBinanceWalletQueryUserUniversalTransferHistory(server: M text: `Retrieved universal transfer history. Total: ${data.total || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -52,8 +52,8 @@ export function registerBinanceWalletQueryUserUniversalTransferHistory(server: M }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/asset-api/queryUserWalletBalance.ts b/src/modules/wallet/asset-api/queryUserWalletBalance.ts index bc5791bf..78ac08c1 100644 --- a/src/modules/wallet/asset-api/queryUserWalletBalance.ts +++ b/src/modules/wallet/asset-api/queryUserWalletBalance.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/asset-api/queryUserWalletBalance.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletQueryUserWalletBalance(server: McpServer) { server.tool( @@ -14,11 +14,11 @@ export function registerBinanceWalletQueryUserWalletBalance(server: McpServer) { }, async ({ recvWindow }) => { try { - const params: any = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.queryUserWalletBalance(params) - const data = await response.data() + const response = await walletClient.restAPI.queryUserWalletBalance(params); + const data = await response.data(); return { content: [ @@ -27,17 +27,17 @@ export function registerBinanceWalletQueryUserWalletBalance(server: McpServer) { text: `Retrieved user wallet balance. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve user wallet balance: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts b/src/modules/wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts index adfe18ed..7407c66e 100644 --- a/src/modules/wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts +++ b/src/modules/wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest(server: McpServer) { server.tool( @@ -16,14 +16,14 @@ export function registerBinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest(s }, async ({ spotBNBBurn, interestBNBBurn, recvWindow }) => { try { - const params: any = {} - if (spotBNBBurn !== undefined) params.spotBNBBurn = spotBNBBurn - if (interestBNBBurn !== undefined) params.interestBNBBurn = interestBNBBurn - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (spotBNBBurn !== undefined) params.spotBNBBurn = spotBNBBurn; + if (interestBNBBurn !== undefined) params.interestBNBBurn = interestBNBBurn; + if (recvWindow !== undefined) params.recvWindow = recvWindow; const response = - await walletClient.restAPI.toggleBnbBurnOnSpotTradeAndMarginInterest(params) - const data = await response.data() + await walletClient.restAPI.toggleBnbBurnOnSpotTradeAndMarginInterest(params); + const data = await response.data(); return { content: [ @@ -32,15 +32,15 @@ export function registerBinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest(s text: `BNB burn settings updated. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to update BNB burn settings: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/asset-api/tradeFee.ts b/src/modules/wallet/asset-api/tradeFee.ts index 026f68ec..7eae5189 100644 --- a/src/modules/wallet/asset-api/tradeFee.ts +++ b/src/modules/wallet/asset-api/tradeFee.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/asset-api/tradeFee.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletTradeFee(server: McpServer) { server.tool( @@ -15,12 +15,12 @@ export function registerBinanceWalletTradeFee(server: McpServer) { }, async ({ symbol, recvWindow }) => { try { - const params: any = {} - if (symbol !== undefined) params.symbol = symbol - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (symbol !== undefined) params.symbol = symbol; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.tradeFee(params) - const data = await response.data() + const response = await walletClient.restAPI.tradeFee(params); + const data = await response.data(); return { content: [ @@ -29,17 +29,17 @@ export function registerBinanceWalletTradeFee(server: McpServer) { text: `Retrieved trade fee information. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve trade fee information: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/asset-api/userAsset.ts b/src/modules/wallet/asset-api/userAsset.ts index 69f73322..8de08a7f 100644 --- a/src/modules/wallet/asset-api/userAsset.ts +++ b/src/modules/wallet/asset-api/userAsset.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/asset-api/userAsset.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletUserAsset(server: McpServer) { server.tool( @@ -15,12 +15,12 @@ export function registerBinanceWalletUserAsset(server: McpServer) { }, async ({ recvWindow, needBtcValuation }) => { try { - const params: any = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow - if (needBtcValuation !== undefined) params.needBtcValuation = needBtcValuation + const params: any = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; + if (needBtcValuation !== undefined) params.needBtcValuation = needBtcValuation; - const response = await walletClient.restAPI.userAsset(params) - const data = await response.data() + const response = await walletClient.restAPI.userAsset(params); + const data = await response.data(); return { content: [ @@ -29,15 +29,15 @@ export function registerBinanceWalletUserAsset(server: McpServer) { text: `Retrieved user assets. Number of assets: ${data.length || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve user assets: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/asset-api/userUniversalTransfer.ts b/src/modules/wallet/asset-api/userUniversalTransfer.ts index fc9def86..2edd3eb8 100644 --- a/src/modules/wallet/asset-api/userUniversalTransfer.ts +++ b/src/modules/wallet/asset-api/userUniversalTransfer.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/asset-api/userUniversalTransfer.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletUserUniversalTransfer(server: McpServer) { server.tool( @@ -23,13 +23,13 @@ export function registerBinanceWalletUserUniversalTransfer(server: McpServer) { type, asset, amount, - } - if (fromSymbol !== undefined) params.fromSymbol = fromSymbol - if (toSymbol !== undefined) params.toSymbol = toSymbol - if (recvWindow !== undefined) params.recvWindow = recvWindow + }; + if (fromSymbol !== undefined) params.fromSymbol = fromSymbol; + if (toSymbol !== undefined) params.toSymbol = toSymbol; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.userUniversalTransfer(params) - const data = await response.data() + const response = await walletClient.restAPI.userUniversalTransfer(params); + const data = await response.data(); return { content: [ @@ -38,17 +38,17 @@ export function registerBinanceWalletUserUniversalTransfer(server: McpServer) { text: `Universal transfer completed. Transfer ID: ${data.tranId}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to process universal transfer: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/capital-api/allCoinsInformation.ts b/src/modules/wallet/capital-api/allCoinsInformation.ts index af4fcb32..98915cd0 100644 --- a/src/modules/wallet/capital-api/allCoinsInformation.ts +++ b/src/modules/wallet/capital-api/allCoinsInformation.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/capital-api/allCoinsInformation.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletAllCoinsInformation(server: McpServer) { server.tool( @@ -14,11 +14,11 @@ export function registerBinanceWalletAllCoinsInformation(server: McpServer) { }, async ({ recvWindow }) => { try { - const params: any = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.allCoinsInformation(params) - const data = await response.data() + const response = await walletClient.restAPI.allCoinsInformation(params); + const data = await response.data(); return { content: [ @@ -27,15 +27,15 @@ export function registerBinanceWalletAllCoinsInformation(server: McpServer) { text: `Retrieved information for all coins. Total coins: ${data.length || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve coin information: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/capital-api/depositAddress.ts b/src/modules/wallet/capital-api/depositAddress.ts index 2899d1db..2ba1261c 100644 --- a/src/modules/wallet/capital-api/depositAddress.ts +++ b/src/modules/wallet/capital-api/depositAddress.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/capital-api/depositAddress.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletDepositAddress(server: McpServer) { server.tool( @@ -16,12 +16,12 @@ export function registerBinanceWalletDepositAddress(server: McpServer) { }, async ({ coin, network, recvWindow }) => { try { - const params: any = { coin } - if (network !== undefined) params.network = network - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = { coin }; + if (network !== undefined) params.network = network; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.depositAddress(params) - const data = await response.data() + const response = await walletClient.restAPI.depositAddress(params); + const data = await response.data(); return { content: [ @@ -30,15 +30,15 @@ export function registerBinanceWalletDepositAddress(server: McpServer) { text: `Retrieved deposit address for ${coin}. Address: ${data.address}${data.tag ? `, Tag: ${data.tag}` : ""}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve deposit address: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/capital-api/depositHistory.ts b/src/modules/wallet/capital-api/depositHistory.ts index c46eafe0..4d8d2a00 100644 --- a/src/modules/wallet/capital-api/depositHistory.ts +++ b/src/modules/wallet/capital-api/depositHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/capital-api/depositHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletDepositHistory(server: McpServer) { server.tool( @@ -20,17 +20,17 @@ export function registerBinanceWalletDepositHistory(server: McpServer) { }, async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { try { - const params: any = {} - if (coin !== undefined) params.coin = coin - if (status !== undefined) params.status = status - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (offset !== undefined) params.offset = offset - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (coin !== undefined) params.coin = coin; + if (status !== undefined) params.status = status; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (offset !== undefined) params.offset = offset; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.depositHistory(params) - const data = await response.data() + const response = await walletClient.restAPI.depositHistory(params); + const data = await response.data(); return { content: [ @@ -39,15 +39,15 @@ export function registerBinanceWalletDepositHistory(server: McpServer) { text: `Retrieved deposit history. Total deposits: ${data.length || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve deposit history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/capital-api/fetchDepositAddressListWithNetwork.ts b/src/modules/wallet/capital-api/fetchDepositAddressListWithNetwork.ts index e924cdbe..d3b67cd8 100644 --- a/src/modules/wallet/capital-api/fetchDepositAddressListWithNetwork.ts +++ b/src/modules/wallet/capital-api/fetchDepositAddressListWithNetwork.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/capital-api/fetchDepositAddressListWithNetwork.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletFetchDepositAddressListWithNetwork(server: McpServer) { server.tool( @@ -16,12 +16,12 @@ export function registerBinanceWalletFetchDepositAddressListWithNetwork(server: }, async ({ coin, network, recvWindow }) => { try { - const params: any = { coin } - if (network !== undefined) params.network = network - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = { coin }; + if (network !== undefined) params.network = network; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.fetchDepositAddressListWithNetwork(params) - const data = await response.data() + const response = await walletClient.restAPI.fetchDepositAddressListWithNetwork(params); + const data = await response.data(); return { content: [ @@ -30,17 +30,17 @@ export function registerBinanceWalletFetchDepositAddressListWithNetwork(server: text: `Retrieved deposit addresses for ${coin}. Total addresses: ${data.length || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve deposit addresses: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/capital-api/fetchWithdrawAddressList.ts b/src/modules/wallet/capital-api/fetchWithdrawAddressList.ts index ae2946c2..81b1e60b 100644 --- a/src/modules/wallet/capital-api/fetchWithdrawAddressList.ts +++ b/src/modules/wallet/capital-api/fetchWithdrawAddressList.ts @@ -1,7 +1,7 @@ // src/tools/binance-wallet/capital-api/fetchWithdrawAddressList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletFetchWithdrawAddressList(server: McpServer) { server.tool( @@ -10,8 +10,8 @@ export function registerBinanceWalletFetchWithdrawAddressList(server: McpServer) {}, async () => { try { - const response = await walletClient.restAPI.fetchWithdrawAddressList() - const data = await response.data() + const response = await walletClient.restAPI.fetchWithdrawAddressList(); + const data = await response.data(); return { content: [ @@ -20,17 +20,17 @@ export function registerBinanceWalletFetchWithdrawAddressList(server: McpServer) text: `Retrieved withdraw address list. Total addresses: ${data || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve withdraw address list: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/capital-api/index.ts b/src/modules/wallet/capital-api/index.ts index 694efb2d..f1086cd9 100644 --- a/src/modules/wallet/capital-api/index.ts +++ b/src/modules/wallet/capital-api/index.ts @@ -1,22 +1,22 @@ // src/tools/binance-wallet/capital-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceWalletAllCoinsInformation } from "./allCoinsInformation.js" -import { registerBinanceWalletDepositAddress } from "./depositAddress.js" -import { registerBinanceWalletDepositHistory } from "./depositHistory.js" -import { registerBinanceWalletFetchDepositAddressListWithNetwork } from "./fetchDepositAddressListWithNetwork.js" -import { registerBinanceWalletFetchWithdrawAddressList } from "./fetchWithdrawAddressList.js" -import { registerBinanceWalletOneClickArrivalDepositApply } from "./oneClickArrivalDepositApply.js" -import { registerBinanceWalletWithdraw } from "./withdraw.js" -import { registerBinanceWalletWithdrawHistory } from "./withdrawHistory.js" +import { registerBinanceWalletAllCoinsInformation } from "./allCoinsInformation.js"; +import { registerBinanceWalletDepositAddress } from "./depositAddress.js"; +import { registerBinanceWalletDepositHistory } from "./depositHistory.js"; +import { registerBinanceWalletFetchDepositAddressListWithNetwork } from "./fetchDepositAddressListWithNetwork.js"; +import { registerBinanceWalletFetchWithdrawAddressList } from "./fetchWithdrawAddressList.js"; +import { registerBinanceWalletOneClickArrivalDepositApply } from "./oneClickArrivalDepositApply.js"; +import { registerBinanceWalletWithdraw } from "./withdraw.js"; +import { registerBinanceWalletWithdrawHistory } from "./withdrawHistory.js"; export function registerBinanceWalletCapitalApiTools(server: McpServer) { - registerBinanceWalletAllCoinsInformation(server) - registerBinanceWalletDepositAddress(server) - registerBinanceWalletDepositHistory(server) - registerBinanceWalletWithdrawHistory(server) - registerBinanceWalletWithdraw(server) - registerBinanceWalletFetchDepositAddressListWithNetwork(server) - registerBinanceWalletFetchWithdrawAddressList(server) - registerBinanceWalletOneClickArrivalDepositApply(server) + registerBinanceWalletAllCoinsInformation(server); + registerBinanceWalletDepositAddress(server); + registerBinanceWalletDepositHistory(server); + registerBinanceWalletWithdrawHistory(server); + registerBinanceWalletWithdraw(server); + registerBinanceWalletFetchDepositAddressListWithNetwork(server); + registerBinanceWalletFetchWithdrawAddressList(server); + registerBinanceWalletOneClickArrivalDepositApply(server); } diff --git a/src/modules/wallet/capital-api/oneClickArrivalDepositApply.ts b/src/modules/wallet/capital-api/oneClickArrivalDepositApply.ts index 13e562ba..0d064983 100644 --- a/src/modules/wallet/capital-api/oneClickArrivalDepositApply.ts +++ b/src/modules/wallet/capital-api/oneClickArrivalDepositApply.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/capital-api/oneClickArrivalDepositApply.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletOneClickArrivalDepositApply(server: McpServer) { server.tool( @@ -15,12 +15,12 @@ export function registerBinanceWalletOneClickArrivalDepositApply(server: McpServ }, async ({ subAccountId, recvWindow }) => { try { - const params: any = {} - if (subAccountId !== undefined) params.subAccountId = subAccountId - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (subAccountId !== undefined) params.subAccountId = subAccountId; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.oneClickArrivalDepositApply(params) - const data = await response.data() + const response = await walletClient.restAPI.oneClickArrivalDepositApply(params); + const data = await response.data(); return { content: [ @@ -29,9 +29,9 @@ export function registerBinanceWalletOneClickArrivalDepositApply(server: McpServ text: `Applied for one-click arrival deposit. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -41,8 +41,8 @@ export function registerBinanceWalletOneClickArrivalDepositApply(server: McpServ }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/capital-api/withdraw.ts b/src/modules/wallet/capital-api/withdraw.ts index 3619a467..5e7570d7 100644 --- a/src/modules/wallet/capital-api/withdraw.ts +++ b/src/modules/wallet/capital-api/withdraw.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/capital-api/withdraw.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletWithdraw(server: McpServer) { server.tool( @@ -38,17 +38,17 @@ export function registerBinanceWalletWithdraw(server: McpServer) { coin, address, amount, - } - if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId - if (network !== undefined) params.network = network - if (addressTag !== undefined) params.addressTag = addressTag - if (name !== undefined) params.name = name - if (walletType !== undefined) params.walletType = walletType - if (transactionFeeFlag !== undefined) params.transactionFeeFlag = transactionFeeFlag - if (recvWindow !== undefined) params.recvWindow = recvWindow + }; + if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId; + if (network !== undefined) params.network = network; + if (addressTag !== undefined) params.addressTag = addressTag; + if (name !== undefined) params.name = name; + if (walletType !== undefined) params.walletType = walletType; + if (transactionFeeFlag !== undefined) params.transactionFeeFlag = transactionFeeFlag; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.withdraw(params) - const data = await response.data() + const response = await walletClient.restAPI.withdraw(params); + const data = await response.data(); return { content: [ @@ -57,15 +57,15 @@ export function registerBinanceWalletWithdraw(server: McpServer) { text: `Withdraw request submitted. Withdrawal ID: ${data.id}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to submit withdraw request: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/capital-api/withdrawHistory.ts b/src/modules/wallet/capital-api/withdrawHistory.ts index 63f0e692..98354666 100644 --- a/src/modules/wallet/capital-api/withdrawHistory.ts +++ b/src/modules/wallet/capital-api/withdrawHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/capital-api/withdrawHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletWithdrawHistory(server: McpServer) { server.tool( @@ -21,18 +21,18 @@ export function registerBinanceWalletWithdrawHistory(server: McpServer) { }, async ({ coin, withdrawOrderId, status, startTime, endTime, offset, limit, recvWindow }) => { try { - const params: any = {} - if (coin !== undefined) params.coin = coin - if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId - if (status !== undefined) params.status = status - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (offset !== undefined) params.offset = offset - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (coin !== undefined) params.coin = coin; + if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId; + if (status !== undefined) params.status = status; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (offset !== undefined) params.offset = offset; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.withdrawHistory(params) - const data = await response.data() + const response = await walletClient.restAPI.withdrawHistory(params); + const data = await response.data(); return { content: [ @@ -41,15 +41,15 @@ export function registerBinanceWalletWithdrawHistory(server: McpServer) { text: `Retrieved withdraw history. Total withdrawals: ${data.length || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve withdraw history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/index.ts b/src/modules/wallet/index.ts index 4b94fe4e..86747df4 100644 --- a/src/modules/wallet/index.ts +++ b/src/modules/wallet/index.ts @@ -1,28 +1,28 @@ // src/tools/binance-wallet/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceWalletAccountApiTools } from "./account-api/index.js" -import { registerBinanceWalletAssetApiTools } from "./asset-api/index.js" -import { registerBinanceWalletCapitalApiTools } from "./capital-api/index.js" -import { registerBinanceWalletOthersApiTools } from "./others-api/index.js" -import { registerBinanceWalletTravelRuleApiTools } from "./travel-rule-api/index.js" +import { registerBinanceWalletAccountApiTools } from "./account-api/index.js"; +import { registerBinanceWalletAssetApiTools } from "./asset-api/index.js"; +import { registerBinanceWalletCapitalApiTools } from "./capital-api/index.js"; +import { registerBinanceWalletOthersApiTools } from "./others-api/index.js"; +import { registerBinanceWalletTravelRuleApiTools } from "./travel-rule-api/index.js"; export function registerBinanceWalletTools(server: McpServer) { // Account API tools - registerBinanceWalletAccountApiTools(server) + registerBinanceWalletAccountApiTools(server); // Others API tools - registerBinanceWalletOthersApiTools(server) + registerBinanceWalletOthersApiTools(server); // Travel Rule API tools - registerBinanceWalletTravelRuleApiTools(server) + registerBinanceWalletTravelRuleApiTools(server); // Asset API tools - registerBinanceWalletAssetApiTools(server) + registerBinanceWalletAssetApiTools(server); // Capital API tools - registerBinanceWalletCapitalApiTools(server) + registerBinanceWalletCapitalApiTools(server); } // Alias for binance.ts compatibility -export { registerBinanceWalletTools as registerWallet } +export { registerBinanceWalletTools as registerWallet }; diff --git a/src/modules/wallet/others-api/getSymbolsDelistScheduleForSpot.ts b/src/modules/wallet/others-api/getSymbolsDelistScheduleForSpot.ts index 8ac0a258..f549aac9 100644 --- a/src/modules/wallet/others-api/getSymbolsDelistScheduleForSpot.ts +++ b/src/modules/wallet/others-api/getSymbolsDelistScheduleForSpot.ts @@ -1,7 +1,7 @@ // src/tools/binance-wallet/others-api/getSymbolsDelistScheduleForSpot.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletGetSymbolsDelistScheduleForSpot(server: McpServer) { server.tool( @@ -10,8 +10,8 @@ export function registerBinanceWalletGetSymbolsDelistScheduleForSpot(server: Mcp {}, async () => { try { - const response = await walletClient.restAPI.getSymbolsDelistScheduleForSpot() - const data = await response.data() + const response = await walletClient.restAPI.getSymbolsDelistScheduleForSpot(); + const data = await response.data(); return { content: [ @@ -20,15 +20,15 @@ export function registerBinanceWalletGetSymbolsDelistScheduleForSpot(server: Mcp text: `Retrieved delist schedule for spot symbols. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve delist schedule: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/others-api/index.ts b/src/modules/wallet/others-api/index.ts index 3b6520d6..e1f899e4 100644 --- a/src/modules/wallet/others-api/index.ts +++ b/src/modules/wallet/others-api/index.ts @@ -1,10 +1,10 @@ //src/tools/binance-wallet/others-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceWalletGetSymbolsDelistScheduleForSpot } from "./getSymbolsDelistScheduleForSpot.js" -import { registerBinanceWalletSystemStatus } from "./systemStatus.js" +import { registerBinanceWalletGetSymbolsDelistScheduleForSpot } from "./getSymbolsDelistScheduleForSpot.js"; +import { registerBinanceWalletSystemStatus } from "./systemStatus.js"; export function registerBinanceWalletOthersApiTools(server: McpServer) { - registerBinanceWalletSystemStatus(server) - registerBinanceWalletGetSymbolsDelistScheduleForSpot(server) + registerBinanceWalletSystemStatus(server); + registerBinanceWalletGetSymbolsDelistScheduleForSpot(server); } diff --git a/src/modules/wallet/others-api/systemStatus.ts b/src/modules/wallet/others-api/systemStatus.ts index f2bcc1b3..5121f4a9 100644 --- a/src/modules/wallet/others-api/systemStatus.ts +++ b/src/modules/wallet/others-api/systemStatus.ts @@ -1,13 +1,13 @@ // src/tools/binance-wallet/others-api/systemStatus.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletSystemStatus(server: McpServer) { server.tool("BinanceWalletSystemStatus", "Get Binance Wallet system status.", {}, async () => { try { - const response = await walletClient.restAPI.systemStatus() - const data = await response.data() + const response = await walletClient.restAPI.systemStatus(); + const data = await response.data(); return { content: [ @@ -16,14 +16,14 @@ export function registerBinanceWalletSystemStatus(server: McpServer) { text: `Retrieved system status. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve system status: ${errorMessage}` }], isError: true, - } + }; } - }) + }); } diff --git a/src/modules/wallet/travel-rule-api/brokerWithdraw.ts b/src/modules/wallet/travel-rule-api/brokerWithdraw.ts index f28f42ec..369ff418 100644 --- a/src/modules/wallet/travel-rule-api/brokerWithdraw.ts +++ b/src/modules/wallet/travel-rule-api/brokerWithdraw.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/travel-rule-api/brokerWithdraw.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletBrokerWithdraw(server: McpServer) { server.tool( @@ -47,14 +47,14 @@ export function registerBinanceWalletBrokerWithdraw(server: McpServer) { questionnaire, originatorPii, signature, - } - if (network !== undefined) params.network = network - if (addressTag !== undefined) params.addressTag = addressTag - if (name !== undefined) params.name = name - if (recvWindow !== undefined) params.recvWindow = recvWindow + }; + if (network !== undefined) params.network = network; + if (addressTag !== undefined) params.addressTag = addressTag; + if (name !== undefined) params.name = name; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.brokerWithdraw(params) - const data = await response.data() + const response = await walletClient.restAPI.brokerWithdraw(params); + const data = await response.data(); return { content: [ @@ -63,17 +63,17 @@ export function registerBinanceWalletBrokerWithdraw(server: McpServer) { text: `Broker withdraw request submitted. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to submit broker withdraw request: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/travel-rule-api/depositHistoryTravelRule.ts b/src/modules/wallet/travel-rule-api/depositHistoryTravelRule.ts index 9e1d7ef7..90060bfd 100644 --- a/src/modules/wallet/travel-rule-api/depositHistoryTravelRule.ts +++ b/src/modules/wallet/travel-rule-api/depositHistoryTravelRule.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/travel-rule-api/depositHistoryTravelRule.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletDepositHistoryTravelRule(server: McpServer) { server.tool( @@ -20,17 +20,17 @@ export function registerBinanceWalletDepositHistoryTravelRule(server: McpServer) }, async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { try { - const params: any = {} - if (coin !== undefined) params.coin = coin - if (status !== undefined) params.status = status - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (offset !== undefined) params.offset = offset - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (coin !== undefined) params.coin = coin; + if (status !== undefined) params.status = status; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (offset !== undefined) params.offset = offset; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.depositHistoryTravelRule(params) - const data = await response.data() + const response = await walletClient.restAPI.depositHistoryTravelRule(params); + const data = await response.data(); return { content: [ @@ -39,15 +39,15 @@ export function registerBinanceWalletDepositHistoryTravelRule(server: McpServer) text: `Retrieved deposit history for travel rule. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve deposit history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/travel-rule-api/index.ts b/src/modules/wallet/travel-rule-api/index.ts index 9e76b47d..f475165d 100644 --- a/src/modules/wallet/travel-rule-api/index.ts +++ b/src/modules/wallet/travel-rule-api/index.ts @@ -1,22 +1,22 @@ //src/tools/binance-wallet/travel-rule-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceWalletBrokerWithdraw } from "./brokerWithdraw.js" -import { registerBinanceWalletDepositHistoryTravelRule } from "./depositHistoryTravelRule.js" -import { registerBinanceWalletOnboardedVaspList } from "./onboardedVaspList.js" -import { registerBinanceWalletSubmitDepositQuestionnaire } from "./submitDepositQuestionnaire.js" -import { registerBinanceWalletSubmitDepositQuestionnaireTravelRule } from "./submitDepositQuestionnaireTravelRule.js" -import { registerBinanceWalletWithdrawHistoryV1 } from "./withdrawHistoryV1.js" -import { registerBinanceWalletWithdrawHistoryV2 } from "./withdrawHistoryV2.js" -import { registerBinanceWalletWithdrawTravelRule } from "./withdrawTravelRule.js" +import { registerBinanceWalletBrokerWithdraw } from "./brokerWithdraw.js"; +import { registerBinanceWalletDepositHistoryTravelRule } from "./depositHistoryTravelRule.js"; +import { registerBinanceWalletOnboardedVaspList } from "./onboardedVaspList.js"; +import { registerBinanceWalletSubmitDepositQuestionnaire } from "./submitDepositQuestionnaire.js"; +import { registerBinanceWalletSubmitDepositQuestionnaireTravelRule } from "./submitDepositQuestionnaireTravelRule.js"; +import { registerBinanceWalletWithdrawHistoryV1 } from "./withdrawHistoryV1.js"; +import { registerBinanceWalletWithdrawHistoryV2 } from "./withdrawHistoryV2.js"; +import { registerBinanceWalletWithdrawTravelRule } from "./withdrawTravelRule.js"; export function registerBinanceWalletTravelRuleApiTools(server: McpServer) { - registerBinanceWalletBrokerWithdraw(server) - registerBinanceWalletOnboardedVaspList(server) - registerBinanceWalletSubmitDepositQuestionnaire(server) - registerBinanceWalletWithdrawHistoryV1(server) - registerBinanceWalletDepositHistoryTravelRule(server) - registerBinanceWalletWithdrawHistoryV2(server) - registerBinanceWalletWithdrawTravelRule(server) - registerBinanceWalletSubmitDepositQuestionnaireTravelRule(server) + registerBinanceWalletBrokerWithdraw(server); + registerBinanceWalletOnboardedVaspList(server); + registerBinanceWalletSubmitDepositQuestionnaire(server); + registerBinanceWalletWithdrawHistoryV1(server); + registerBinanceWalletDepositHistoryTravelRule(server); + registerBinanceWalletWithdrawHistoryV2(server); + registerBinanceWalletWithdrawTravelRule(server); + registerBinanceWalletSubmitDepositQuestionnaireTravelRule(server); } diff --git a/src/modules/wallet/travel-rule-api/onboardedVaspList.ts b/src/modules/wallet/travel-rule-api/onboardedVaspList.ts index c6d74c32..a0f4e7b1 100644 --- a/src/modules/wallet/travel-rule-api/onboardedVaspList.ts +++ b/src/modules/wallet/travel-rule-api/onboardedVaspList.ts @@ -1,7 +1,7 @@ // src/tools/binance-wallet/travel-rule-api/onboardedVaspList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletOnboardedVaspList(server: McpServer) { server.tool( @@ -10,8 +10,8 @@ export function registerBinanceWalletOnboardedVaspList(server: McpServer) { {}, async () => { try { - const response = await walletClient.restAPI.onboardedVaspList() - const data = await response.data() + const response = await walletClient.restAPI.onboardedVaspList(); + const data = await response.data(); return { content: [ @@ -20,17 +20,17 @@ export function registerBinanceWalletOnboardedVaspList(server: McpServer) { text: `Retrieved onboarded VASP list. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve onboarded VASP list: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/travel-rule-api/submitDepositQuestionnaire.ts b/src/modules/wallet/travel-rule-api/submitDepositQuestionnaire.ts index 76a8e0ba..90fa2b14 100644 --- a/src/modules/wallet/travel-rule-api/submitDepositQuestionnaire.ts +++ b/src/modules/wallet/travel-rule-api/submitDepositQuestionnaire.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaire.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletSubmitDepositQuestionnaire(server: McpServer) { server.tool( @@ -25,11 +25,11 @@ export function registerBinanceWalletSubmitDepositQuestionnaire(server: McpServe questionnaire, beneficiaryPii, signature, - } - if (recvWindow !== undefined) params.recvWindow = recvWindow + }; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.submitDepositQuestionnaire(params) - const data = await response.data() + const response = await walletClient.restAPI.submitDepositQuestionnaire(params); + const data = await response.data(); return { content: [ @@ -38,17 +38,17 @@ export function registerBinanceWalletSubmitDepositQuestionnaire(server: McpServe text: `Submitted deposit questionnaire for broker deposit. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to submit deposit questionnaire: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts b/src/modules/wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts index 1160d5c9..10614549 100644 --- a/src/modules/wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts +++ b/src/modules/wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletSubmitDepositQuestionnaireTravelRule(server: McpServer) { server.tool( @@ -19,11 +19,11 @@ export function registerBinanceWalletSubmitDepositQuestionnaireTravelRule(server const params: any = { tranId, questionnaire, - } - if (recvWindow !== undefined) params.recvWindow = recvWindow + }; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.submitDepositQuestionnaireTravelRule(params) - const data = await response.data() + const response = await walletClient.restAPI.submitDepositQuestionnaireTravelRule(params); + const data = await response.data(); return { content: [ @@ -32,17 +32,17 @@ export function registerBinanceWalletSubmitDepositQuestionnaireTravelRule(server text: `Submitted deposit questionnaire for travel rule. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to submit deposit questionnaire: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/travel-rule-api/withdrawHistoryV1.ts b/src/modules/wallet/travel-rule-api/withdrawHistoryV1.ts index a1beb2c2..7787b949 100644 --- a/src/modules/wallet/travel-rule-api/withdrawHistoryV1.ts +++ b/src/modules/wallet/travel-rule-api/withdrawHistoryV1.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/travel-rule-api/withdrawHistoryV1.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletWithdrawHistoryV1(server: McpServer) { server.tool( @@ -20,17 +20,17 @@ export function registerBinanceWalletWithdrawHistoryV1(server: McpServer) { }, async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { try { - const params: any = {} - if (coin !== undefined) params.coin = coin - if (status !== undefined) params.status = status - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (offset !== undefined) params.offset = offset - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (coin !== undefined) params.coin = coin; + if (status !== undefined) params.status = status; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (offset !== undefined) params.offset = offset; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.withdrawHistoryV1(params) - const data = await response.data() + const response = await walletClient.restAPI.withdrawHistoryV1(params); + const data = await response.data(); return { content: [ @@ -39,15 +39,15 @@ export function registerBinanceWalletWithdrawHistoryV1(server: McpServer) { text: `Retrieved withdraw history v1. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve withdraw history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/travel-rule-api/withdrawHistoryV2.ts b/src/modules/wallet/travel-rule-api/withdrawHistoryV2.ts index fac53e5d..5370bb7d 100644 --- a/src/modules/wallet/travel-rule-api/withdrawHistoryV2.ts +++ b/src/modules/wallet/travel-rule-api/withdrawHistoryV2.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/travel-rule-api/withdrawHistoryV2.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletWithdrawHistoryV2(server: McpServer) { server.tool( @@ -20,17 +20,17 @@ export function registerBinanceWalletWithdrawHistoryV2(server: McpServer) { }, async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { try { - const params: any = {} - if (coin !== undefined) params.coin = coin - if (status !== undefined) params.status = status - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (offset !== undefined) params.offset = offset - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (coin !== undefined) params.coin = coin; + if (status !== undefined) params.status = status; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (offset !== undefined) params.offset = offset; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.withdrawHistoryV2(params) - const data = await response.data() + const response = await walletClient.restAPI.withdrawHistoryV2(params); + const data = await response.data(); return { content: [ @@ -39,15 +39,15 @@ export function registerBinanceWalletWithdrawHistoryV2(server: McpServer) { text: `Retrieved withdraw history v2. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve withdraw history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/modules/wallet/travel-rule-api/withdrawTravelRule.ts b/src/modules/wallet/travel-rule-api/withdrawTravelRule.ts index b9e385ec..3c13a06f 100644 --- a/src/modules/wallet/travel-rule-api/withdrawTravelRule.ts +++ b/src/modules/wallet/travel-rule-api/withdrawTravelRule.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/travel-rule-api/withdrawTravelRule.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletWithdrawTravelRule(server: McpServer) { server.tool( @@ -37,15 +37,15 @@ export function registerBinanceWalletWithdrawTravelRule(server: McpServer) { address, amount, questionnaire, - } - if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId - if (network !== undefined) params.network = network - if (addressTag !== undefined) params.addressTag = addressTag - if (name !== undefined) params.name = name - if (recvWindow !== undefined) params.recvWindow = recvWindow + }; + if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId; + if (network !== undefined) params.network = network; + if (addressTag !== undefined) params.addressTag = addressTag; + if (name !== undefined) params.name = name; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.withdrawTravelRule(params) - const data = await response.data() + const response = await walletClient.restAPI.withdrawTravelRule(params); + const data = await response.data(); return { content: [ @@ -54,9 +54,9 @@ export function registerBinanceWalletWithdrawTravelRule(server: McpServer) { text: `Withdraw travel rule request submitted. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -66,8 +66,8 @@ export function registerBinanceWalletWithdrawTravelRule(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/server/base.ts b/src/server/base.ts index 1fc00d25..11ad6a6b 100644 --- a/src/server/base.ts +++ b/src/server/base.ts @@ -1,28 +1,28 @@ // src/server/base.ts -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinance } from "../binance.js" -import { IS_TESTNET } from "../config/testnet.js" -import Logger from "../utils/logger.js" +import { registerBinance } from "../binance.js"; +import { IS_TESTNET } from "../config/testnet.js"; +import Logger from "../utils/logger.js"; export const startServer = () => { try { - const name = IS_TESTNET ? "binance-mcp (TESTNET)" : "binance-mcp" + const name = IS_TESTNET ? "binance-mcp (TESTNET)" : "binance-mcp"; const description = IS_TESTNET ? "MCP server for Binance Spot Test Network — only /api endpoints (spot trading & market data) are available" - : "MCP server for Binance exchange - spot trading, staking, wallet, NFT, pay, mining, and more" + : "MCP server for Binance exchange - spot trading, staking, wallet, NFT, pay, mining, and more"; const server = new McpServer({ name, version: "1.0.0", description, - }) + }); - registerBinance(server) + registerBinance(server); - return server + return server; } catch (error) { - Logger.error("Failed to initialize server:", error) - process.exit(1) + Logger.error("Failed to initialize server:", error); + process.exit(1); } -} +}; diff --git a/src/server/sse.ts b/src/server/sse.ts index cf0a0e66..db4a79b4 100644 --- a/src/server/sse.ts +++ b/src/server/sse.ts @@ -1,73 +1,73 @@ -import type { Server } from "http" +import type { Server } from "http"; -import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js" -import cors from "cors" -import express from "express" +import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js"; +import cors from "cors"; +import express from "express"; -import Logger from "../utils/logger.js" +import Logger from "../utils/logger.js"; -import { startServer } from "./base.js" +import { startServer } from "./base.js"; // src/server/sse.ts -import "dotenv/config" +import "dotenv/config"; -const PORT = process.env.PORT || 3002 +const PORT = process.env.PORT || 3002; // Start the server in SSE mode export const startSSEServer = async (): Promise => { try { - const app = express() - app.use(cors()) - app.use(express.json()) + const app = express(); + app.use(cors()); + app.use(express.json()); // Store active transports and their associated server instances - const transports = new Map() + const transports = new Map(); // SSE endpoint — each connection gets its own McpServer instance app.get("/sse", async (req, res) => { - const server = startServer() - const transport = new SSEServerTransport("/message", res) + const server = startServer(); + const transport = new SSEServerTransport("/message", res); - Logger.info(`New SSE connection: ${transport.sessionId}`) - transports.set(transport.sessionId, transport) + Logger.info(`New SSE connection: ${transport.sessionId}`); + transports.set(transport.sessionId, transport); res.on("close", async () => { - Logger.info(`SSE connection closed: ${transport.sessionId}`) - transports.delete(transport.sessionId) - await server.close() - }) + Logger.info(`SSE connection closed: ${transport.sessionId}`); + transports.delete(transport.sessionId); + await server.close(); + }); - await server.connect(transport) - }) + await server.connect(transport); + }); // Message endpoint app.post("/message", async (req, res) => { - const sessionId = req.query.sessionId as string - const transport = transports.get(sessionId) + const sessionId = req.query.sessionId as string; + const transport = transports.get(sessionId); if (!transport) { - res.status(404).json({ error: "Session not found" }) + res.status(404).json({ error: "Session not found" }); - return + return; } - await transport.handlePostMessage(req, res) - }) + await transport.handlePostMessage(req, res); + }); // Health check app.get("/health", (req, res) => { - res.json({ status: "ok", mode: "sse" }) - }) + res.json({ status: "ok", mode: "sse" }); + }); const httpServer = app.listen(PORT, () => { - Logger.info(`Binance MCP Server running on SSE mode at http://localhost:${PORT}`) - Logger.info(`SSE endpoint: http://localhost:${PORT}/sse`) - }) + Logger.info(`Binance MCP Server running on SSE mode at http://localhost:${PORT}`); + Logger.info(`SSE endpoint: http://localhost:${PORT}/sse`); + }); - return httpServer + return httpServer; } catch (error) { - Logger.error("Error starting Binance MCP SSE server:", error) + Logger.error("Error starting Binance MCP SSE server:", error); - return undefined + return undefined; } -} +}; diff --git a/src/server/stdio.ts b/src/server/stdio.ts index 2af2cbed..b3506f2f 100644 --- a/src/server/stdio.ts +++ b/src/server/stdio.ts @@ -1,34 +1,34 @@ -import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js" +import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; -import Logger from "../utils/logger.js" +import Logger from "../utils/logger.js"; -import { startServer } from "./base.js" +import { startServer } from "./base.js"; // src/server/stdio.ts -import "dotenv/config" +import "dotenv/config"; // Start the server in stdio mode export const startStdioServer = async () => { try { - const server = startServer() - const transport = new StdioServerTransport() + const server = startServer(); + const transport = new StdioServerTransport(); - Logger.info("Binance MCP Server running on stdio mode") + Logger.info("Binance MCP Server running on stdio mode"); transport.onmessage = (message) => { - Logger.debug("Received message:", message) - } + Logger.debug("Received message:", message); + }; transport.onclose = () => { - Logger.info("Stdio server closed") - } + Logger.info("Stdio server closed"); + }; transport.onerror = (error) => { - Logger.error("Stdio server error:", error) - } + Logger.error("Stdio server error:", error); + }; - await server.connect(transport) + await server.connect(transport); - return server + return server; } catch (error) { - Logger.error("Error starting Binance MCP Stdio server:", error) + Logger.error("Error starting Binance MCP Stdio server:", error); } -} +}; diff --git a/src/tools/account/index.ts b/src/tools/account/index.ts index 2c037adf..4806195d 100644 --- a/src/tools/account/index.ts +++ b/src/tools/account/index.ts @@ -1,9 +1,9 @@ // src/tools/account/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { makeSignedRequest } from "../../config/binanceUsClient.js" +import { makeSignedRequest } from "../../config/binanceUsClient.js"; /** * Register all Account-related tools for Binance.US @@ -31,17 +31,17 @@ export function registerAccountTools(server: McpServer) { }, async ({ recvWindow }) => { try { - const params: Record = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await makeSignedRequest("GET", "/api/v3/account", params) + const data = await makeSignedRequest("GET", "/api/v3/account", params); // Format balances for readability const nonZeroBalances = data.balances?.filter( (b: { free: string; locked: string }) => parseFloat(b.free) > 0 || parseFloat(b.locked) > 0, - ) || [] + ) || []; return { content: [ @@ -66,17 +66,17 @@ export function registerAccountTools(server: McpServer) { ), }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get account info: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================== // binance_us_my_trades @@ -99,15 +99,15 @@ export function registerAccountTools(server: McpServer) { }, async ({ symbol, orderId, startTime, endTime, fromId, limit, recvWindow }) => { try { - const params: Record = { symbol } - if (orderId !== undefined) params.orderId = orderId - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (fromId !== undefined) params.fromId = fromId - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = { symbol }; + if (orderId !== undefined) params.orderId = orderId; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (fromId !== undefined) params.fromId = fromId; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await makeSignedRequest("GET", "/api/v3/myTrades", params) + const data = await makeSignedRequest("GET", "/api/v3/myTrades", params); return { content: [ @@ -116,17 +116,17 @@ export function registerAccountTools(server: McpServer) { text: `Trade history for ${symbol}:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get trade history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================== // binance_us_rate_limits @@ -140,10 +140,10 @@ export function registerAccountTools(server: McpServer) { }, async ({ recvWindow }) => { try { - const params: Record = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await makeSignedRequest("GET", "/api/v3/rateLimit/order", params) + const data = await makeSignedRequest("GET", "/api/v3/rateLimit/order", params); return { content: [ @@ -152,17 +152,17 @@ export function registerAccountTools(server: McpServer) { text: `Order Rate Limits:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get rate limits: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================== // binance_us_trade_fee @@ -180,11 +180,11 @@ export function registerAccountTools(server: McpServer) { }, async ({ symbol, recvWindow }) => { try { - const params: Record = {} - if (symbol !== undefined) params.symbol = symbol - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = {}; + if (symbol !== undefined) params.symbol = symbol; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await makeSignedRequest("GET", "/sapi/v1/asset/query/trading-fee", params) + const data = await makeSignedRequest("GET", "/sapi/v1/asset/query/trading-fee", params); return { content: [ @@ -193,17 +193,17 @@ export function registerAccountTools(server: McpServer) { text: `Trading Fees:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get trading fees: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================== // binance_us_trade_volume @@ -217,10 +217,10 @@ export function registerAccountTools(server: McpServer) { }, async ({ recvWindow }) => { try { - const params: Record = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await makeSignedRequest("GET", "/sapi/v1/asset/query/trading-volume", params) + const data = await makeSignedRequest("GET", "/sapi/v1/asset/query/trading-volume", params); return { content: [ @@ -229,15 +229,15 @@ export function registerAccountTools(server: McpServer) { text: `Past 30 Days Trading Volume: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get trading volume: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-algo/future-algo/TwapNewTrade.ts b/src/tools/binance-algo/future-algo/TwapNewTrade.ts index 4be4e66d..cc8c2713 100644 --- a/src/tools/binance-algo/future-algo/TwapNewTrade.ts +++ b/src/tools/binance-algo/future-algo/TwapNewTrade.ts @@ -1,9 +1,9 @@ // src/tools/binance-algo/future-algo/TwapNewTrade.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { algoClient } from "../../../config/binanceClient.js" +import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceTwapNewTrade(server: McpServer) { server.tool( @@ -60,9 +60,9 @@ export function registerBinanceTwapNewTrade(server: McpServer) { ...(params.reduceOnly !== undefined && { reduceOnly: params.reduceOnly }), ...(params.limitPrice !== undefined && { limitPrice: params.limitPrice }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -73,9 +73,9 @@ export function registerBinanceTwapNewTrade(server: McpServer) { }. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -85,8 +85,8 @@ export function registerBinanceTwapNewTrade(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-algo/future-algo/VPNewTrade.ts b/src/tools/binance-algo/future-algo/VPNewTrade.ts index d9ab7294..007c0f01 100644 --- a/src/tools/binance-algo/future-algo/VPNewTrade.ts +++ b/src/tools/binance-algo/future-algo/VPNewTrade.ts @@ -1,9 +1,9 @@ // src/tools/binance-algo/future-algo/VPNewTrade.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { algoClient } from "../../../config/binanceClient.js" +import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceVPNewTrade(server: McpServer) { server.tool( @@ -55,9 +55,9 @@ export function registerBinanceVPNewTrade(server: McpServer) { ...(params.reduceOnly !== undefined && { reduceOnly: params.reduceOnly }), ...(params.limitPrice !== undefined && { limitPrice: params.limitPrice }), recvWindow: params.recvWindow, - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -68,9 +68,9 @@ export function registerBinanceVPNewTrade(server: McpServer) { }. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -80,8 +80,8 @@ export function registerBinanceVPNewTrade(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-algo/future-algo/cancelAlgoOrder.ts b/src/tools/binance-algo/future-algo/cancelAlgoOrder.ts index e068f8bb..d41e0867 100644 --- a/src/tools/binance-algo/future-algo/cancelAlgoOrder.ts +++ b/src/tools/binance-algo/future-algo/cancelAlgoOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-algo/future-algo/cancelAlgoOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { algoClient } from "../../../config/binanceClient.js" +import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceFutureCancelAlgoOrder(server: McpServer) { server.tool( @@ -18,9 +18,9 @@ export function registerBinanceFutureCancelAlgoOrder(server: McpServer) { const response = await algoClient.restAPI.cancelAlgoOrderFutureAlgo({ algoId: params.algoId, ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,9 +29,9 @@ export function registerBinanceFutureCancelAlgoOrder(server: McpServer) { text: `Algo order ${params.algoId} canceled successfully. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -41,8 +41,8 @@ export function registerBinanceFutureCancelAlgoOrder(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-algo/future-algo/currentAlgoOpenOrders.ts b/src/tools/binance-algo/future-algo/currentAlgoOpenOrders.ts index 39890130..1001a67b 100644 --- a/src/tools/binance-algo/future-algo/currentAlgoOpenOrders.ts +++ b/src/tools/binance-algo/future-algo/currentAlgoOpenOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-algo/future-algo/currentAlgoOpenOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { algoClient } from "../../../config/binanceClient.js" +import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceFutureCurrentAlgoOpenOrders(server: McpServer) { server.tool( @@ -16,9 +16,9 @@ export function registerBinanceFutureCurrentAlgoOpenOrders(server: McpServer) { try { const response = await algoClient.restAPI.queryCurrentAlgoOpenOrdersFutureAlgo({ ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -27,9 +27,9 @@ export function registerBinanceFutureCurrentAlgoOpenOrders(server: McpServer) { text: `Currently active algorithmic orders. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -39,8 +39,8 @@ export function registerBinanceFutureCurrentAlgoOpenOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-algo/future-algo/historicalAlgoOrder.ts b/src/tools/binance-algo/future-algo/historicalAlgoOrder.ts index 50583309..edafa7a9 100644 --- a/src/tools/binance-algo/future-algo/historicalAlgoOrder.ts +++ b/src/tools/binance-algo/future-algo/historicalAlgoOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-algo/future-algo/historicalAlgoOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { algoClient } from "../../../config/binanceClient.js" +import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceFutureHistoricalAlgoOrder(server: McpServer) { server.tool( @@ -43,9 +43,9 @@ export function registerBinanceFutureHistoricalAlgoOrder(server: McpServer) { ...(params.page !== undefined && { page: params.page }), ...(params.pageSize !== undefined && { pageSize: params.pageSize }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -54,9 +54,9 @@ export function registerBinanceFutureHistoricalAlgoOrder(server: McpServer) { text: `Historical Algo Orders retrieves successfully. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -66,8 +66,8 @@ export function registerBinanceFutureHistoricalAlgoOrder(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-algo/future-algo/index.ts b/src/tools/binance-algo/future-algo/index.ts index 4369d2aa..503ac247 100644 --- a/src/tools/binance-algo/future-algo/index.ts +++ b/src/tools/binance-algo/future-algo/index.ts @@ -1,29 +1,29 @@ // src/tools/binance-spot/market-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceFutureCancelAlgoOrder } from "./cancelAlgoOrder.js" -import { registerBinanceFutureCurrentAlgoOpenOrders } from "./currentAlgoOpenOrders.js" -import { registerBinanceFutureHistoricalAlgoOrder } from "./historicalAlgoOrder.js" -import { registerBinanceFutureSubOrders } from "./subOrders.js" -import { registerBinanceTwapNewTrade } from "./TwapNewTrade.js" -import { registerBinanceVPNewTrade } from "./VPNewTrade.js" +import { registerBinanceFutureCancelAlgoOrder } from "./cancelAlgoOrder.js"; +import { registerBinanceFutureCurrentAlgoOpenOrders } from "./currentAlgoOpenOrders.js"; +import { registerBinanceFutureHistoricalAlgoOrder } from "./historicalAlgoOrder.js"; +import { registerBinanceFutureSubOrders } from "./subOrders.js"; +import { registerBinanceTwapNewTrade } from "./TwapNewTrade.js"; +import { registerBinanceVPNewTrade } from "./VPNewTrade.js"; export function registerBinanceAlgoFutureApiTools(server: McpServer) { // Registers a new VP (Volume Participation) trade - registerBinanceVPNewTrade(server) + registerBinanceVPNewTrade(server); // Registers a new TWAP (Time-Weighted Average Price) trade - registerBinanceTwapNewTrade(server) + registerBinanceTwapNewTrade(server); // Registers functionality to cancel an algorithmic order - registerBinanceFutureCancelAlgoOrder(server) + registerBinanceFutureCancelAlgoOrder(server); // Registers API to query sub-orders of an algorithmic order - registerBinanceFutureSubOrders(server) + registerBinanceFutureSubOrders(server); // Registers API to retrieve currently open algorithmic orders - registerBinanceFutureCurrentAlgoOpenOrders(server) + registerBinanceFutureCurrentAlgoOpenOrders(server); // Registers API to fetch historical algorithmic orders - registerBinanceFutureHistoricalAlgoOrder(server) + registerBinanceFutureHistoricalAlgoOrder(server); } diff --git a/src/tools/binance-algo/future-algo/subOrders.ts b/src/tools/binance-algo/future-algo/subOrders.ts index 4a46a1d7..e0306890 100644 --- a/src/tools/binance-algo/future-algo/subOrders.ts +++ b/src/tools/binance-algo/future-algo/subOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-algo/future-algo/subOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { algoClient } from "../../../config/binanceClient.js" +import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceFutureSubOrders(server: McpServer) { server.tool( @@ -29,9 +29,9 @@ export function registerBinanceFutureSubOrders(server: McpServer) { page: params.page, pageSize: params.pageSize, ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -42,9 +42,9 @@ export function registerBinanceFutureSubOrders(server: McpServer) { }. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -54,8 +54,8 @@ export function registerBinanceFutureSubOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-algo/index.ts b/src/tools/binance-algo/index.ts index 8de0688e..32267f55 100644 --- a/src/tools/binance-algo/index.ts +++ b/src/tools/binance-algo/index.ts @@ -1,11 +1,11 @@ // src/tools/binance-spot/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceAlgoFutureApiTools } from "./future-algo/index.js" -import { registerBinanceAlgoSpotApiTools } from "./spot-algo/index.js" +import { registerBinanceAlgoFutureApiTools } from "./future-algo/index.js"; +import { registerBinanceAlgoSpotApiTools } from "./spot-algo/index.js"; export function registerBinanceAlgoTools(server: McpServer) { // Algo API tools - registerBinanceAlgoFutureApiTools(server) - registerBinanceAlgoSpotApiTools(server) + registerBinanceAlgoFutureApiTools(server); + registerBinanceAlgoSpotApiTools(server); } diff --git a/src/tools/binance-algo/spot-algo/cancelOpenTWAPOrder.ts b/src/tools/binance-algo/spot-algo/cancelOpenTWAPOrder.ts index 3517999e..3652e326 100644 --- a/src/tools/binance-algo/spot-algo/cancelOpenTWAPOrder.ts +++ b/src/tools/binance-algo/spot-algo/cancelOpenTWAPOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-algo/spot-algo/cancelOpenTWAPOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { algoClient } from "../../../config/binanceClient.js" +import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceSpotCancelOpenTWAPOrder(server: McpServer) { server.tool( @@ -18,9 +18,9 @@ export function registerBinanceSpotCancelOpenTWAPOrder(server: McpServer) { const response = await algoClient.restAPI.cancelAlgoOrderSpotAlgo({ algoId: params.algoId, ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,9 +29,9 @@ export function registerBinanceSpotCancelOpenTWAPOrder(server: McpServer) { text: `Algo order ${params.algoId} canceled successfully. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -41,8 +41,8 @@ export function registerBinanceSpotCancelOpenTWAPOrder(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-algo/spot-algo/currentAlgoOpenOrders.ts b/src/tools/binance-algo/spot-algo/currentAlgoOpenOrders.ts index 14b6d6cc..28bca403 100644 --- a/src/tools/binance-algo/spot-algo/currentAlgoOpenOrders.ts +++ b/src/tools/binance-algo/spot-algo/currentAlgoOpenOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-algo/spot-algo/currentAlgoOpenOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { algoClient } from "../../../config/binanceClient.js" +import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceSpotCurrentAlgoOpenOrders(server: McpServer) { server.tool( @@ -16,9 +16,9 @@ export function registerBinanceSpotCurrentAlgoOpenOrders(server: McpServer) { try { const response = await algoClient.restAPI.queryCurrentAlgoOpenOrdersSpotAlgo({ ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,9 +29,9 @@ export function registerBinanceSpotCurrentAlgoOpenOrders(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -41,8 +41,8 @@ export function registerBinanceSpotCurrentAlgoOpenOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-algo/spot-algo/historicalAlgoOrders.ts b/src/tools/binance-algo/spot-algo/historicalAlgoOrders.ts index 543a9c62..bcdba16c 100644 --- a/src/tools/binance-algo/spot-algo/historicalAlgoOrders.ts +++ b/src/tools/binance-algo/spot-algo/historicalAlgoOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-algo/spot-algo/historicalAlgoOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { algoClient } from "../../../config/binanceClient.js" +import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceSpotHistoricalAlgoOrders(server: McpServer) { server.tool( @@ -43,9 +43,9 @@ export function registerBinanceSpotHistoricalAlgoOrders(server: McpServer) { ...(params.page && { page: params.page }), ...(params.pageSize && { pageSize: params.pageSize }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -56,9 +56,9 @@ export function registerBinanceSpotHistoricalAlgoOrders(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -68,8 +68,8 @@ export function registerBinanceSpotHistoricalAlgoOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-algo/spot-algo/index.ts b/src/tools/binance-algo/spot-algo/index.ts index a8f1e420..366e4f7d 100644 --- a/src/tools/binance-algo/spot-algo/index.ts +++ b/src/tools/binance-algo/spot-algo/index.ts @@ -1,25 +1,25 @@ // src/tools/binance-spot/market-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceSpotCancelOpenTWAPOrder } from "./cancelOpenTWAPOrder.js" -import { registerBinanceSpotCurrentAlgoOpenOrders } from "./currentAlgoOpenOrders.js" -import { registerBinanceSpotHistoricalAlgoOrders } from "./historicalAlgoOrders.js" -import { registerBinanceSpotTwapNewTrade } from "./spotTWAPOrder.js" -import { registerBinanceSpotSubOrders } from "./subOrders.js" +import { registerBinanceSpotCancelOpenTWAPOrder } from "./cancelOpenTWAPOrder.js"; +import { registerBinanceSpotCurrentAlgoOpenOrders } from "./currentAlgoOpenOrders.js"; +import { registerBinanceSpotHistoricalAlgoOrders } from "./historicalAlgoOrders.js"; +import { registerBinanceSpotTwapNewTrade } from "./spotTWAPOrder.js"; +import { registerBinanceSpotSubOrders } from "./subOrders.js"; export function registerBinanceAlgoSpotApiTools(server: McpServer) { // Register the TWAP (Time-Weighted Average Price) tool for placing new spot algo orders - registerBinanceSpotTwapNewTrade(server) + registerBinanceSpotTwapNewTrade(server); // Register the tool for canceling open TWAP spot algo orders - registerBinanceSpotCancelOpenTWAPOrder(server) + registerBinanceSpotCancelOpenTWAPOrder(server); // Register the tool to handle sub-orders created under a parent algo order - registerBinanceSpotSubOrders(server) + registerBinanceSpotSubOrders(server); // Register the tool to fetch currently open algo orders for spot trading - registerBinanceSpotCurrentAlgoOpenOrders(server) + registerBinanceSpotCurrentAlgoOpenOrders(server); // Register the tool to fetch historical algo orders for spot trading - registerBinanceSpotHistoricalAlgoOrders(server) + registerBinanceSpotHistoricalAlgoOrders(server); } diff --git a/src/tools/binance-algo/spot-algo/spotTWAPOrder.ts b/src/tools/binance-algo/spot-algo/spotTWAPOrder.ts index 03510e6c..05f6b156 100644 --- a/src/tools/binance-algo/spot-algo/spotTWAPOrder.ts +++ b/src/tools/binance-algo/spot-algo/spotTWAPOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-algo/spot-algo/spotTwapNewTrade.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { algoClient } from "../../../config/binanceClient.js" +import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceSpotTwapNewTrade(server: McpServer) { server.tool( @@ -46,9 +46,9 @@ export function registerBinanceSpotTwapNewTrade(server: McpServer) { duration: params.duration, ...(params.clientAlgoId !== undefined && { clientAlgoId: params.clientAlgoId }), ...(params.limitPrice !== undefined && { limitPrice: params.limitPrice }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -59,9 +59,9 @@ export function registerBinanceSpotTwapNewTrade(server: McpServer) { }. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -71,8 +71,8 @@ export function registerBinanceSpotTwapNewTrade(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-algo/spot-algo/subOrders.ts b/src/tools/binance-algo/spot-algo/subOrders.ts index 2c7ac0c4..03bd51f7 100644 --- a/src/tools/binance-algo/spot-algo/subOrders.ts +++ b/src/tools/binance-algo/spot-algo/subOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-algo/spot-algo/subOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { algoClient } from "../../../config/binanceClient.js" +import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceSpotSubOrders(server: McpServer) { server.tool( @@ -29,9 +29,9 @@ export function registerBinanceSpotSubOrders(server: McpServer) { ...(params.page !== undefined && { page: params.page }), ...(params.pageSize !== undefined && { pageSize: params.pageSize }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -42,9 +42,9 @@ export function registerBinanceSpotSubOrders(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -54,8 +54,8 @@ export function registerBinanceSpotSubOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-auto-invest/changeIndexPlanStatus.ts b/src/tools/binance-auto-invest/changeIndexPlanStatus.ts index 39dfbfc5..d451c76c 100644 --- a/src/tools/binance-auto-invest/changeIndexPlanStatus.ts +++ b/src/tools/binance-auto-invest/changeIndexPlanStatus.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-auto-invest/changeIndexPlanStatus.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestChangeIndexPlanStatus(server: McpServer) { server.tool( @@ -26,8 +26,8 @@ export function registerBinanceAutoInvestChangeIndexPlanStatus(server: McpServer indexId: params.indexId, status: params.status, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -36,15 +36,15 @@ export function registerBinanceAutoInvestChangeIndexPlanStatus(server: McpServer text: `✅ Index plan status changed to ${params.status}\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to change index plan status: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-auto-invest/changePlanStatus.ts b/src/tools/binance-auto-invest/changePlanStatus.ts index aea225ba..db103e2b 100644 --- a/src/tools/binance-auto-invest/changePlanStatus.ts +++ b/src/tools/binance-auto-invest/changePlanStatus.ts @@ -1,9 +1,9 @@ // src/tools/binance-auto-invest/changePlanStatus.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestChangePlanStatus(server: McpServer) { server.tool( @@ -15,10 +15,10 @@ export function registerBinanceAutoInvestChangePlanStatus(server: McpServer) { }, async ({ planId, status }) => { try { - const params: any = { planId, status } + const params: any = { planId, status }; - const response = await autoInvestClient.restAPI.changePlanStatus(params) - const data = await response.data() + const response = await autoInvestClient.restAPI.changePlanStatus(params); + const data = await response.data(); return { content: [ @@ -27,15 +27,15 @@ export function registerBinanceAutoInvestChangePlanStatus(server: McpServer) { text: `Plan status changed successfully. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to change plan status: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-auto-invest/createPlan.ts b/src/tools/binance-auto-invest/createPlan.ts index abdffe20..07dcc186 100644 --- a/src/tools/binance-auto-invest/createPlan.ts +++ b/src/tools/binance-auto-invest/createPlan.ts @@ -1,9 +1,9 @@ // src/tools/binance-auto-invest/createPlan.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestCreatePlan(server: McpServer) { server.tool( @@ -45,11 +45,11 @@ export function registerBinanceAutoInvestCreatePlan(server: McpServer) { subscriptionStartTime, sourceAsset, details, - } - if (flexibleAllowedToUse !== undefined) params.flexibleAllowedToUse = flexibleAllowedToUse + }; + if (flexibleAllowedToUse !== undefined) params.flexibleAllowedToUse = flexibleAllowedToUse; - const response = await autoInvestClient.restAPI.investmentPlanCreation(params) - const data = await response.data() + const response = await autoInvestClient.restAPI.investmentPlanCreation(params); + const data = await response.data(); return { content: [ @@ -58,15 +58,15 @@ export function registerBinanceAutoInvestCreatePlan(server: McpServer) { text: `Investment plan created successfully. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to create plan: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-auto-invest/editPlan.ts b/src/tools/binance-auto-invest/editPlan.ts index 0f257fac..d0957529 100644 --- a/src/tools/binance-auto-invest/editPlan.ts +++ b/src/tools/binance-auto-invest/editPlan.ts @@ -1,9 +1,9 @@ // src/tools/binance-auto-invest/editPlan.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestEditPlan(server: McpServer) { server.tool( @@ -37,16 +37,16 @@ export function registerBinanceAutoInvestEditPlan(server: McpServer) { details, }) => { try { - const params: any = { planId } - if (subscriptionAmount !== undefined) params.subscriptionAmount = subscriptionAmount - if (subscriptionCycle) params.subscriptionCycle = subscriptionCycle - if (subscriptionStartTime) params.subscriptionStartTime = subscriptionStartTime - if (sourceAsset) params.sourceAsset = sourceAsset - if (flexibleAllowedToUse !== undefined) params.flexibleAllowedToUse = flexibleAllowedToUse - if (details) params.details = details + const params: any = { planId }; + if (subscriptionAmount !== undefined) params.subscriptionAmount = subscriptionAmount; + if (subscriptionCycle) params.subscriptionCycle = subscriptionCycle; + if (subscriptionStartTime) params.subscriptionStartTime = subscriptionStartTime; + if (sourceAsset) params.sourceAsset = sourceAsset; + if (flexibleAllowedToUse !== undefined) params.flexibleAllowedToUse = flexibleAllowedToUse; + if (details) params.details = details; - const response = await autoInvestClient.restAPI.investmentPlanAdjustment(params) - const data = await response.data() + const response = await autoInvestClient.restAPI.investmentPlanAdjustment(params); + const data = await response.data(); return { content: [ @@ -55,15 +55,15 @@ export function registerBinanceAutoInvestEditPlan(server: McpServer) { text: `Investment plan edited successfully. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to edit plan: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-auto-invest/getHistoryList.ts b/src/tools/binance-auto-invest/getHistoryList.ts index c6d90aef..ac7573ae 100644 --- a/src/tools/binance-auto-invest/getHistoryList.ts +++ b/src/tools/binance-auto-invest/getHistoryList.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-auto-invest/getHistoryList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestGetHistoryList(server: McpServer) { server.tool( @@ -39,9 +39,9 @@ export function registerBinanceAutoInvestGetHistoryList(server: McpServer) { ...(params.size && { size: params.size }), ...(params.current && { current: params.current }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -50,15 +50,15 @@ export function registerBinanceAutoInvestGetHistoryList(server: McpServer) { text: `Auto-invest history:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-auto-invest/getIndexInfo.ts b/src/tools/binance-auto-invest/getIndexInfo.ts index 37ac8966..2c3c8705 100644 --- a/src/tools/binance-auto-invest/getIndexInfo.ts +++ b/src/tools/binance-auto-invest/getIndexInfo.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-auto-invest/getIndexInfo.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestGetIndexInfo(server: McpServer) { server.tool( @@ -24,8 +24,8 @@ export function registerBinanceAutoInvestGetIndexInfo(server: McpServer) { const response = await autoInvestClient.restAPI.getIndexInfo({ ...(params.indexId && { indexId: params.indexId }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -34,15 +34,15 @@ export function registerBinanceAutoInvestGetIndexInfo(server: McpServer) { text: `Index portfolio info:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get index info: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-auto-invest/getIndexLinkedPlanPositionDetails.ts b/src/tools/binance-auto-invest/getIndexLinkedPlanPositionDetails.ts index 286f12d2..ed93bf1e 100644 --- a/src/tools/binance-auto-invest/getIndexLinkedPlanPositionDetails.ts +++ b/src/tools/binance-auto-invest/getIndexLinkedPlanPositionDetails.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-auto-invest/getIndexLinkedPlanPositionDetails.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestGetIndexLinkedPlanPositionDetails(server: McpServer) { server.tool( @@ -24,8 +24,8 @@ export function registerBinanceAutoInvestGetIndexLinkedPlanPositionDetails(serve const response = await autoInvestClient.restAPI.getIndexLinkedPlanPositionDetails({ indexId: params.indexId, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -34,15 +34,15 @@ export function registerBinanceAutoInvestGetIndexLinkedPlanPositionDetails(serve text: `Index-linked plan position details:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get position details: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-auto-invest/getIndexLinkedPlanPositionList.ts b/src/tools/binance-auto-invest/getIndexLinkedPlanPositionList.ts index dcc75de2..96dd765e 100644 --- a/src/tools/binance-auto-invest/getIndexLinkedPlanPositionList.ts +++ b/src/tools/binance-auto-invest/getIndexLinkedPlanPositionList.ts @@ -1,9 +1,9 @@ // src/tools/binance-auto-invest/getIndexLinkedPlanPositionList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestGetIndexLinkedPlanPositionList(server: McpServer) { server.tool( @@ -14,10 +14,10 @@ export function registerBinanceAutoInvestGetIndexLinkedPlanPositionList(server: }, async ({ indexId }) => { try { - const params: any = { indexId } + const params: any = { indexId }; - const response = await autoInvestClient.restAPI.queryIndexLinkedPlanPositionDetails(params) - const data = await response.data() + const response = await autoInvestClient.restAPI.queryIndexLinkedPlanPositionDetails(params); + const data = await response.data(); return { content: [ @@ -26,9 +26,9 @@ export function registerBinanceAutoInvestGetIndexLinkedPlanPositionList(server: text: `Index linked plan position list retrieved. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -38,8 +38,8 @@ export function registerBinanceAutoInvestGetIndexLinkedPlanPositionList(server: }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-auto-invest/getIndexLinkedPlanRebalanceHistory.ts b/src/tools/binance-auto-invest/getIndexLinkedPlanRebalanceHistory.ts index b928f34e..ec31435d 100644 --- a/src/tools/binance-auto-invest/getIndexLinkedPlanRebalanceHistory.ts +++ b/src/tools/binance-auto-invest/getIndexLinkedPlanRebalanceHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-auto-invest/getIndexLinkedPlanRebalanceHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestGetIndexLinkedPlanRebalanceHistory(server: McpServer) { server.tool( @@ -18,14 +18,14 @@ export function registerBinanceAutoInvestGetIndexLinkedPlanRebalanceHistory(serv }, async ({ indexId, startTime, endTime, current, size }) => { try { - const params: any = { indexId } - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (current !== undefined) params.current = current - if (size !== undefined) params.size = size + const params: any = { indexId }; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (current !== undefined) params.current = current; + if (size !== undefined) params.size = size; - const response = await autoInvestClient.restAPI.indexLinkedPlanRebalanceDetails(params) - const data = await response.data() + const response = await autoInvestClient.restAPI.indexLinkedPlanRebalanceDetails(params); + const data = await response.data(); return { content: [ @@ -34,9 +34,9 @@ export function registerBinanceAutoInvestGetIndexLinkedPlanRebalanceHistory(serv text: `Index linked plan rebalance history retrieved. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -46,8 +46,8 @@ export function registerBinanceAutoInvestGetIndexLinkedPlanRebalanceHistory(serv }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-auto-invest/getIndexUserSummary.ts b/src/tools/binance-auto-invest/getIndexUserSummary.ts index 4d56633d..d3576350 100644 --- a/src/tools/binance-auto-invest/getIndexUserSummary.ts +++ b/src/tools/binance-auto-invest/getIndexUserSummary.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-auto-invest/getIndexUserSummary.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestGetIndexUserSummary(server: McpServer) { server.tool( @@ -24,8 +24,8 @@ export function registerBinanceAutoInvestGetIndexUserSummary(server: McpServer) const response = await autoInvestClient.restAPI.getIndexUserSummary({ indexId: params.indexId, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -34,15 +34,15 @@ export function registerBinanceAutoInvestGetIndexUserSummary(server: McpServer) text: `Index user summary for index ${params.indexId}:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get index user summary: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-auto-invest/getOneTimePlans.ts b/src/tools/binance-auto-invest/getOneTimePlans.ts index 08530602..48bbfda2 100644 --- a/src/tools/binance-auto-invest/getOneTimePlans.ts +++ b/src/tools/binance-auto-invest/getOneTimePlans.ts @@ -1,9 +1,9 @@ // src/tools/binance-auto-invest/getOneTimePlans.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestGetOneTimePlans(server: McpServer) { server.tool( @@ -15,11 +15,11 @@ export function registerBinanceAutoInvestGetOneTimePlans(server: McpServer) { }, async ({ planId, requestId }) => { try { - const params: any = { planId } - if (requestId) params.requestId = requestId + const params: any = { planId }; + if (requestId) params.requestId = requestId; - const response = await autoInvestClient.restAPI.queryOneTimeTransactionStatus(params) - const data = await response.data() + const response = await autoInvestClient.restAPI.queryOneTimeTransactionStatus(params); + const data = await response.data(); return { content: [ @@ -28,15 +28,15 @@ export function registerBinanceAutoInvestGetOneTimePlans(server: McpServer) { text: `Plan details retrieved. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get plan details: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-auto-invest/getPlanList.ts b/src/tools/binance-auto-invest/getPlanList.ts index 157fdc2b..f42ac288 100644 --- a/src/tools/binance-auto-invest/getPlanList.ts +++ b/src/tools/binance-auto-invest/getPlanList.ts @@ -1,9 +1,9 @@ // src/tools/binance-auto-invest/getPlanList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestGetPlanList(server: McpServer) { server.tool( @@ -14,11 +14,11 @@ export function registerBinanceAutoInvestGetPlanList(server: McpServer) { }, async ({ planType }) => { try { - const params: any = {} - if (planType) params.planType = planType + const params: any = {}; + if (planType) params.planType = planType; - const response = await autoInvestClient.restAPI.getListOfPlans(params) - const data = await response.data() + const response = await autoInvestClient.restAPI.getListOfPlans(params); + const data = await response.data(); return { content: [ @@ -27,15 +27,15 @@ export function registerBinanceAutoInvestGetPlanList(server: McpServer) { text: `Plan list retrieved. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get plan list: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-auto-invest/getSourceAssetList.ts b/src/tools/binance-auto-invest/getSourceAssetList.ts index 9e919d2d..2bd3adcf 100644 --- a/src/tools/binance-auto-invest/getSourceAssetList.ts +++ b/src/tools/binance-auto-invest/getSourceAssetList.ts @@ -1,9 +1,9 @@ // src/tools/binance-auto-invest/getSourceAssetList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestGetSourceAssetList(server: McpServer) { server.tool( @@ -20,14 +20,14 @@ export function registerBinanceAutoInvestGetSourceAssetList(server: McpServer) { }, async ({ usageType, targetAsset, indexId, flexibleAllowedToUse }) => { try { - const params: any = {} - if (usageType) params.usageType = usageType - if (targetAsset) params.targetAsset = targetAsset - if (indexId !== undefined) params.indexId = indexId - if (flexibleAllowedToUse !== undefined) params.flexibleAllowedToUse = flexibleAllowedToUse + const params: any = {}; + if (usageType) params.usageType = usageType; + if (targetAsset) params.targetAsset = targetAsset; + if (indexId !== undefined) params.indexId = indexId; + if (flexibleAllowedToUse !== undefined) params.flexibleAllowedToUse = flexibleAllowedToUse; - const response = await autoInvestClient.restAPI.querySourceAssetList(params) - const data = await response.data() + const response = await autoInvestClient.restAPI.querySourceAssetList(params); + const data = await response.data(); return { content: [ @@ -36,15 +36,15 @@ export function registerBinanceAutoInvestGetSourceAssetList(server: McpServer) { text: `Source asset list retrieved. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get source asset list: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-auto-invest/getSubscriptionHistory.ts b/src/tools/binance-auto-invest/getSubscriptionHistory.ts index 4e01c9aa..382c322b 100644 --- a/src/tools/binance-auto-invest/getSubscriptionHistory.ts +++ b/src/tools/binance-auto-invest/getSubscriptionHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-auto-invest/getSubscriptionHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestGetSubscriptionHistory(server: McpServer) { server.tool( @@ -20,17 +20,17 @@ export function registerBinanceAutoInvestGetSubscriptionHistory(server: McpServe }, async ({ planId, startTime, endTime, targetAsset, planType, current, size }) => { try { - const params: any = {} - if (planId !== undefined) params.planId = planId - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (targetAsset) params.targetAsset = targetAsset - if (planType) params.planType = planType - if (current !== undefined) params.current = current - if (size !== undefined) params.size = size + const params: any = {}; + if (planId !== undefined) params.planId = planId; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (targetAsset) params.targetAsset = targetAsset; + if (planType) params.planType = planType; + if (current !== undefined) params.current = current; + if (size !== undefined) params.size = size; - const response = await autoInvestClient.restAPI.querySubscriptionTransactionHistory(params) - const data = await response.data() + const response = await autoInvestClient.restAPI.querySubscriptionTransactionHistory(params); + const data = await response.data(); return { content: [ @@ -39,15 +39,15 @@ export function registerBinanceAutoInvestGetSubscriptionHistory(server: McpServe text: `Subscription history retrieved. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get subscription history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-auto-invest/getTargetAssetList.ts b/src/tools/binance-auto-invest/getTargetAssetList.ts index 69389726..7459cd0d 100644 --- a/src/tools/binance-auto-invest/getTargetAssetList.ts +++ b/src/tools/binance-auto-invest/getTargetAssetList.ts @@ -1,9 +1,9 @@ // src/tools/binance-auto-invest/getTargetAssetList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestGetTargetAssetList(server: McpServer) { server.tool( @@ -16,13 +16,13 @@ export function registerBinanceAutoInvestGetTargetAssetList(server: McpServer) { }, async ({ targetAsset, size, current }) => { try { - const params: any = {} - if (targetAsset) params.targetAsset = targetAsset - if (size !== undefined) params.size = size - if (current !== undefined) params.current = current + const params: any = {}; + if (targetAsset) params.targetAsset = targetAsset; + if (size !== undefined) params.size = size; + if (current !== undefined) params.current = current; - const response = await autoInvestClient.restAPI.getTargetAssetList(params) - const data = await response.data() + const response = await autoInvestClient.restAPI.getTargetAssetList(params); + const data = await response.data(); return { content: [ @@ -31,15 +31,15 @@ export function registerBinanceAutoInvestGetTargetAssetList(server: McpServer) { text: `Target asset list retrieved. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get target asset list: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-auto-invest/getTargetAssetROI.ts b/src/tools/binance-auto-invest/getTargetAssetROI.ts index 439de6b4..1b7a6db8 100644 --- a/src/tools/binance-auto-invest/getTargetAssetROI.ts +++ b/src/tools/binance-auto-invest/getTargetAssetROI.ts @@ -1,9 +1,9 @@ // src/tools/binance-auto-invest/getTargetAssetROI.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestGetTargetAssetROI(server: McpServer) { server.tool( @@ -17,10 +17,10 @@ export function registerBinanceAutoInvestGetTargetAssetROI(server: McpServer) { }, async ({ targetAsset, hisRoiType }) => { try { - const params: any = { targetAsset, hisRoiType } + const params: any = { targetAsset, hisRoiType }; - const response = await autoInvestClient.restAPI.getTargetAssetRoiData(params) - const data = await response.data() + const response = await autoInvestClient.restAPI.getTargetAssetRoiData(params); + const data = await response.data(); return { content: [ @@ -29,15 +29,15 @@ export function registerBinanceAutoInvestGetTargetAssetROI(server: McpServer) { text: `Target asset ROI data retrieved. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get target asset ROI: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-auto-invest/getTargetAssetRoiData.ts b/src/tools/binance-auto-invest/getTargetAssetRoiData.ts index 8d5490d3..e9a2e54b 100644 --- a/src/tools/binance-auto-invest/getTargetAssetRoiData.ts +++ b/src/tools/binance-auto-invest/getTargetAssetRoiData.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-auto-invest/getTargetAssetRoiData.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestGetTargetAssetRoiData(server: McpServer) { server.tool( @@ -28,8 +28,8 @@ export function registerBinanceAutoInvestGetTargetAssetRoiData(server: McpServer targetAsset: params.targetAsset, hisRoiType: params.hisRoiType, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -38,15 +38,15 @@ export function registerBinanceAutoInvestGetTargetAssetRoiData(server: McpServer text: `ROI data for ${params.targetAsset} (${params.hisRoiType}):\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get ROI data: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-auto-invest/index.ts b/src/tools/binance-auto-invest/index.ts index e820a14d..e88465ac 100644 --- a/src/tools/binance-auto-invest/index.ts +++ b/src/tools/binance-auto-invest/index.ts @@ -1,30 +1,30 @@ // src/tools/binance-auto-invest/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceAutoInvestChangePlanStatus } from "./changePlanStatus.js" -import { registerBinanceAutoInvestCreatePlan } from "./createPlan.js" -import { registerBinanceAutoInvestEditPlan } from "./editPlan.js" -import { registerBinanceAutoInvestGetIndexLinkedPlanPositionList } from "./getIndexLinkedPlanPositionList.js" -import { registerBinanceAutoInvestGetIndexLinkedPlanRebalanceHistory } from "./getIndexLinkedPlanRebalanceHistory.js" -import { registerBinanceAutoInvestGetOneTimePlans } from "./getOneTimePlans.js" -import { registerBinanceAutoInvestGetPlanList } from "./getPlanList.js" -import { registerBinanceAutoInvestGetSourceAssetList } from "./getSourceAssetList.js" -import { registerBinanceAutoInvestGetSubscriptionHistory } from "./getSubscriptionHistory.js" -import { registerBinanceAutoInvestGetTargetAssetList } from "./getTargetAssetList.js" -import { registerBinanceAutoInvestGetTargetAssetROI } from "./getTargetAssetROI.js" -import { registerBinanceAutoInvestRedeemIndexLinkedPlan } from "./redeemIndexLinkedPlan.js" +import { registerBinanceAutoInvestChangePlanStatus } from "./changePlanStatus.js"; +import { registerBinanceAutoInvestCreatePlan } from "./createPlan.js"; +import { registerBinanceAutoInvestEditPlan } from "./editPlan.js"; +import { registerBinanceAutoInvestGetIndexLinkedPlanPositionList } from "./getIndexLinkedPlanPositionList.js"; +import { registerBinanceAutoInvestGetIndexLinkedPlanRebalanceHistory } from "./getIndexLinkedPlanRebalanceHistory.js"; +import { registerBinanceAutoInvestGetOneTimePlans } from "./getOneTimePlans.js"; +import { registerBinanceAutoInvestGetPlanList } from "./getPlanList.js"; +import { registerBinanceAutoInvestGetSourceAssetList } from "./getSourceAssetList.js"; +import { registerBinanceAutoInvestGetSubscriptionHistory } from "./getSubscriptionHistory.js"; +import { registerBinanceAutoInvestGetTargetAssetList } from "./getTargetAssetList.js"; +import { registerBinanceAutoInvestGetTargetAssetROI } from "./getTargetAssetROI.js"; +import { registerBinanceAutoInvestRedeemIndexLinkedPlan } from "./redeemIndexLinkedPlan.js"; export function registerBinanceAutoInvestTools(server: McpServer) { - registerBinanceAutoInvestGetTargetAssetList(server) - registerBinanceAutoInvestGetSourceAssetList(server) - registerBinanceAutoInvestGetTargetAssetROI(server) - registerBinanceAutoInvestGetPlanList(server) - registerBinanceAutoInvestGetOneTimePlans(server) - registerBinanceAutoInvestCreatePlan(server) - registerBinanceAutoInvestEditPlan(server) - registerBinanceAutoInvestChangePlanStatus(server) - registerBinanceAutoInvestGetIndexLinkedPlanPositionList(server) - registerBinanceAutoInvestGetIndexLinkedPlanRebalanceHistory(server) - registerBinanceAutoInvestGetSubscriptionHistory(server) - registerBinanceAutoInvestRedeemIndexLinkedPlan(server) + registerBinanceAutoInvestGetTargetAssetList(server); + registerBinanceAutoInvestGetSourceAssetList(server); + registerBinanceAutoInvestGetTargetAssetROI(server); + registerBinanceAutoInvestGetPlanList(server); + registerBinanceAutoInvestGetOneTimePlans(server); + registerBinanceAutoInvestCreatePlan(server); + registerBinanceAutoInvestEditPlan(server); + registerBinanceAutoInvestChangePlanStatus(server); + registerBinanceAutoInvestGetIndexLinkedPlanPositionList(server); + registerBinanceAutoInvestGetIndexLinkedPlanRebalanceHistory(server); + registerBinanceAutoInvestGetSubscriptionHistory(server); + registerBinanceAutoInvestRedeemIndexLinkedPlan(server); } diff --git a/src/tools/binance-auto-invest/oneTimeTransaction.ts b/src/tools/binance-auto-invest/oneTimeTransaction.ts index cdcf7388..fa8de2d0 100644 --- a/src/tools/binance-auto-invest/oneTimeTransaction.ts +++ b/src/tools/binance-auto-invest/oneTimeTransaction.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-auto-invest/oneTimeTransaction.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestOneTimeTransaction(server: McpServer) { server.tool( @@ -46,9 +46,9 @@ export function registerBinanceAutoInvestOneTimeTransaction(server: McpServer) { ...(params.indexId && { indexId: params.indexId }), ...(params.details && { details: JSON.stringify(params.details) }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -57,9 +57,9 @@ export function registerBinanceAutoInvestOneTimeTransaction(server: McpServer) { text: `✅ One-time investment executed!\n\nTransaction ID: ${data.transactionId || "N/A"}\nAmount: ${params.subscriptionAmount} ${params.sourceAsset}\n\nDetails:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -69,8 +69,8 @@ export function registerBinanceAutoInvestOneTimeTransaction(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-auto-invest/rebalanceHistory.ts b/src/tools/binance-auto-invest/rebalanceHistory.ts index 4ff104c5..12998d76 100644 --- a/src/tools/binance-auto-invest/rebalanceHistory.ts +++ b/src/tools/binance-auto-invest/rebalanceHistory.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-auto-invest/rebalanceHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestRebalanceHistory(server: McpServer) { server.tool( @@ -30,9 +30,9 @@ export function registerBinanceAutoInvestRebalanceHistory(server: McpServer) { ...(params.size && { size: params.size }), ...(params.current && { current: params.current }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -41,15 +41,15 @@ export function registerBinanceAutoInvestRebalanceHistory(server: McpServer) { text: `Rebalance history:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get rebalance history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-auto-invest/redeemIndexLinkedPlan.ts b/src/tools/binance-auto-invest/redeemIndexLinkedPlan.ts index 3b666c27..76a09618 100644 --- a/src/tools/binance-auto-invest/redeemIndexLinkedPlan.ts +++ b/src/tools/binance-auto-invest/redeemIndexLinkedPlan.ts @@ -1,9 +1,9 @@ // src/tools/binance-auto-invest/redeemIndexLinkedPlan.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestRedeemIndexLinkedPlan(server: McpServer) { server.tool( @@ -16,11 +16,11 @@ export function registerBinanceAutoInvestRedeemIndexLinkedPlan(server: McpServer }, async ({ indexId, redemptionPercentage, requestId }) => { try { - const params: any = { indexId, redemptionPercentage } - if (requestId) params.requestId = requestId + const params: any = { indexId, redemptionPercentage }; + if (requestId) params.requestId = requestId; - const response = await autoInvestClient.restAPI.indexLinkedPlanRedemption(params) - const data = await response.data() + const response = await autoInvestClient.restAPI.indexLinkedPlanRedemption(params); + const data = await response.data(); return { content: [ @@ -29,15 +29,15 @@ export function registerBinanceAutoInvestRedeemIndexLinkedPlan(server: McpServer text: `Index linked plan redeemed successfully. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to redeem index linked plan: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-auto-invest/redemption.ts b/src/tools/binance-auto-invest/redemption.ts index 90cf0ac4..c85ad277 100644 --- a/src/tools/binance-auto-invest/redemption.ts +++ b/src/tools/binance-auto-invest/redemption.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-auto-invest/redemption.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { autoInvestClient } from "../../config/binanceClient.js" +import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestRedemption(server: McpServer) { server.tool( @@ -30,9 +30,9 @@ export function registerBinanceAutoInvestRedemption(server: McpServer) { indexId: params.indexId, redemptionPercentage: params.redemptionPercentage, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -41,9 +41,9 @@ export function registerBinanceAutoInvestRedemption(server: McpServer) { text: `✅ Redemption executed!\n\nRedeemed ${params.redemptionPercentage}% from index ${params.indexId}\n\nDetails:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -53,8 +53,8 @@ export function registerBinanceAutoInvestRedemption(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-c2c/C2C/getC2CTradeHistory.ts b/src/tools/binance-c2c/C2C/getC2CTradeHistory.ts index d3fac5ea..1049e84a 100644 --- a/src/tools/binance-c2c/C2C/getC2CTradeHistory.ts +++ b/src/tools/binance-c2c/C2C/getC2CTradeHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-c2c/getC2CTradeHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { c2cClient } from "../../../config/binanceClient.js" +import { c2cClient } from "../../../config/binanceClient.js"; export function registerBinanceGetC2CTradeHistory(server: McpServer) { server.tool( @@ -22,8 +22,8 @@ export function registerBinanceGetC2CTradeHistory(server: McpServer) { ...(params.endTime !== undefined && { endTime: params.endTime }), ...(params.page !== undefined && { page: params.page }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -32,9 +32,9 @@ export function registerBinanceGetC2CTradeHistory(server: McpServer) { text: `Successfully retrieved the past C2C trades. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -44,8 +44,8 @@ export function registerBinanceGetC2CTradeHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-c2c/index.ts b/src/tools/binance-c2c/index.ts index 40576490..1f0b1aeb 100644 --- a/src/tools/binance-c2c/index.ts +++ b/src/tools/binance-c2c/index.ts @@ -1,8 +1,8 @@ // src/tools/binance-c2c/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetC2CTradeHistory } from "./C2C/getC2CTradeHistory.js" +import { registerBinanceGetC2CTradeHistory } from "./C2C/getC2CTradeHistory.js"; export function registerBinanceC2CTradeHistoryTools(server: McpServer) { - registerBinanceGetC2CTradeHistory(server) + registerBinanceGetC2CTradeHistory(server); } diff --git a/src/tools/binance-convert/index.ts b/src/tools/binance-convert/index.ts index df48a488..73e8df32 100644 --- a/src/tools/binance-convert/index.ts +++ b/src/tools/binance-convert/index.ts @@ -1,13 +1,13 @@ // src/tools/binance-convert/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceConvertMarketDataTools } from "./market-data-api/index.js" -import { registerBinanceConvertTradeTools } from "./trade-api/index.js" +import { registerBinanceConvertMarketDataTools } from "./market-data-api/index.js"; +import { registerBinanceConvertTradeTools } from "./trade-api/index.js"; export function registerBinanceConvertTools(server: McpServer) { // Register tools for accessing market data from Binance Convert - registerBinanceConvertMarketDataTools(server) + registerBinanceConvertMarketDataTools(server); // Register tools for performing trades on Binance Convert - registerBinanceConvertTradeTools(server) + registerBinanceConvertTradeTools(server); } diff --git a/src/tools/binance-convert/market-data-api/index.ts b/src/tools/binance-convert/market-data-api/index.ts index c9bcf504..325cb54b 100644 --- a/src/tools/binance-convert/market-data-api/index.ts +++ b/src/tools/binance-convert/market-data-api/index.ts @@ -1,13 +1,13 @@ // src/tools/binance-convert/market-data-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceConvertGetListAllConvertPairs } from "./listAllConvertPairs.js" -import { registerBinanceConvertQueryOrderQuantityPrecisionPerAsset } from "./queryOrderQuantityPrecisionPerAsset.js" +import { registerBinanceConvertGetListAllConvertPairs } from "./listAllConvertPairs.js"; +import { registerBinanceConvertQueryOrderQuantityPrecisionPerAsset } from "./queryOrderQuantityPrecisionPerAsset.js"; export function registerBinanceConvertMarketDataTools(server: McpServer) { // Register the route to get a list of all supported convert trading pairs - registerBinanceConvertGetListAllConvertPairs(server) + registerBinanceConvertGetListAllConvertPairs(server); // Register the route to get quantity precision details for each asset - registerBinanceConvertQueryOrderQuantityPrecisionPerAsset(server) + registerBinanceConvertQueryOrderQuantityPrecisionPerAsset(server); } diff --git a/src/tools/binance-convert/market-data-api/listAllConvertPairs.ts b/src/tools/binance-convert/market-data-api/listAllConvertPairs.ts index 845a72b6..25de6bef 100644 --- a/src/tools/binance-convert/market-data-api/listAllConvertPairs.ts +++ b/src/tools/binance-convert/market-data-api/listAllConvertPairs.ts @@ -1,9 +1,9 @@ // src/tools/binance-convert/market-data-api/listAllConvertPairs.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { convertClient } from "../../../config/binanceClient.js" +import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertGetListAllConvertPairs(server: McpServer) { server.tool( @@ -18,9 +18,9 @@ export function registerBinanceConvertGetListAllConvertPairs(server: McpServer) const response = await convertClient.restAPI.listAllConvertPairs({ ...(params.fromAsset && { fromAsset: params.fromAsset }), ...(params.toAsset && { toAsset: params.toAsset }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,9 +29,9 @@ export function registerBinanceConvertGetListAllConvertPairs(server: McpServer) text: `Successfully queried available conversion pairs. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -41,8 +41,8 @@ export function registerBinanceConvertGetListAllConvertPairs(server: McpServer) }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-convert/market-data-api/queryOrderQuantityPrecisionPerAsset.ts b/src/tools/binance-convert/market-data-api/queryOrderQuantityPrecisionPerAsset.ts index dc097eb2..21ac758a 100644 --- a/src/tools/binance-convert/market-data-api/queryOrderQuantityPrecisionPerAsset.ts +++ b/src/tools/binance-convert/market-data-api/queryOrderQuantityPrecisionPerAsset.ts @@ -1,9 +1,9 @@ // src/tools/binance-convert/market-data-api/queryOrderQuantityPrecisionPerAsset.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { convertClient } from "../../../config/binanceClient.js" +import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertQueryOrderQuantityPrecisionPerAsset(server: McpServer) { server.tool( @@ -21,9 +21,9 @@ export function registerBinanceConvertQueryOrderQuantityPrecisionPerAsset(server try { const response = await convertClient.restAPI.queryOrderQuantityPrecisionPerAsset({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -34,9 +34,9 @@ export function registerBinanceConvertQueryOrderQuantityPrecisionPerAsset(server )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -46,8 +46,8 @@ export function registerBinanceConvertQueryOrderQuantityPrecisionPerAsset(server }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-convert/trade-api/acceptQuote.ts b/src/tools/binance-convert/trade-api/acceptQuote.ts index b7ff1b5a..23deb653 100644 --- a/src/tools/binance-convert/trade-api/acceptQuote.ts +++ b/src/tools/binance-convert/trade-api/acceptQuote.ts @@ -1,9 +1,9 @@ // src/tools/binance-convert/trade-api/acceptQuote.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { convertClient } from "../../../config/binanceClient.js" +import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertAcceptQuote(server: McpServer) { server.tool( @@ -23,8 +23,8 @@ export function registerBinanceConvertAcceptQuote(server: McpServer) { const response = await convertClient.restAPI.acceptQuote({ quoteId: params.quoteId, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -33,9 +33,9 @@ export function registerBinanceConvertAcceptQuote(server: McpServer) { text: `Successfully executed the token conversion. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -45,8 +45,8 @@ export function registerBinanceConvertAcceptQuote(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-convert/trade-api/cancelLimitOrder.ts b/src/tools/binance-convert/trade-api/cancelLimitOrder.ts index 1a097a79..7982e671 100644 --- a/src/tools/binance-convert/trade-api/cancelLimitOrder.ts +++ b/src/tools/binance-convert/trade-api/cancelLimitOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-convert/trade-api/cancelLimitOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { convertClient } from "../../../config/binanceClient.js" +import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertCancelLimitOrder(server: McpServer) { server.tool( @@ -23,8 +23,8 @@ export function registerBinanceConvertCancelLimitOrder(server: McpServer) { const response = await convertClient.restAPI.cancelLimitOrder({ orderId: params.orderId, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -33,9 +33,9 @@ export function registerBinanceConvertCancelLimitOrder(server: McpServer) { text: `Canceled the placed limit order. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -45,8 +45,8 @@ export function registerBinanceConvertCancelLimitOrder(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-convert/trade-api/getConvertTradeHistory.ts b/src/tools/binance-convert/trade-api/getConvertTradeHistory.ts index 458bba40..5eafcf10 100644 --- a/src/tools/binance-convert/trade-api/getConvertTradeHistory.ts +++ b/src/tools/binance-convert/trade-api/getConvertTradeHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-convert/trade-api/getConvertTradeHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { convertClient } from "../../../config/binanceClient.js" +import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceGetConvertTradeHistory(server: McpServer) { server.tool( @@ -27,9 +27,9 @@ export function registerBinanceGetConvertTradeHistory(server: McpServer) { endTime: params.endTime, ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -40,9 +40,9 @@ export function registerBinanceGetConvertTradeHistory(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -52,8 +52,8 @@ export function registerBinanceGetConvertTradeHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-convert/trade-api/index.ts b/src/tools/binance-convert/trade-api/index.ts index 3b5e9db9..86128d99 100644 --- a/src/tools/binance-convert/trade-api/index.ts +++ b/src/tools/binance-convert/trade-api/index.ts @@ -1,33 +1,33 @@ // src/tools/binance-convert/trade-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceConvertAcceptQuote } from "./acceptQuote.js" -import { registerBinanceConvertCancelLimitOrder } from "./cancelLimitOrder.js" -import { registerBinanceGetConvertTradeHistory } from "./getConvertTradeHistory.js" -import { registerBinanceConvertOrderStatus } from "./orderStatus.js" -import { registerBinanceConvertPlaceLimitOrder } from "./placeLimitOrder.js" -import { registerBinanceConvertQueryLimitOpenOrders } from "./queryLimitOpenOrders.js" -import { registerBinanceConvertSendQuoteRequest } from "./sendQuoteRequest.js" +import { registerBinanceConvertAcceptQuote } from "./acceptQuote.js"; +import { registerBinanceConvertCancelLimitOrder } from "./cancelLimitOrder.js"; +import { registerBinanceGetConvertTradeHistory } from "./getConvertTradeHistory.js"; +import { registerBinanceConvertOrderStatus } from "./orderStatus.js"; +import { registerBinanceConvertPlaceLimitOrder } from "./placeLimitOrder.js"; +import { registerBinanceConvertQueryLimitOpenOrders } from "./queryLimitOpenOrders.js"; +import { registerBinanceConvertSendQuoteRequest } from "./sendQuoteRequest.js"; export function registerBinanceConvertTradeTools(server: McpServer) { // Register the route to accept a quote for a convert trade - registerBinanceConvertAcceptQuote(server) + registerBinanceConvertAcceptQuote(server); // Register the route to cancel an existing convert limit order - registerBinanceConvertCancelLimitOrder(server) + registerBinanceConvertCancelLimitOrder(server); // Register the route to get the convert trade history - registerBinanceGetConvertTradeHistory(server) + registerBinanceGetConvertTradeHistory(server); // Register the route to check the status of a convert order - registerBinanceConvertOrderStatus(server) + registerBinanceConvertOrderStatus(server); // Register the route to place a new convert limit order - registerBinanceConvertPlaceLimitOrder(server) + registerBinanceConvertPlaceLimitOrder(server); // Register the route to query currently open convert limit orders - registerBinanceConvertQueryLimitOpenOrders(server) + registerBinanceConvertQueryLimitOpenOrders(server); // Register the route to send a quote request for a convert trade - registerBinanceConvertSendQuoteRequest(server) + registerBinanceConvertSendQuoteRequest(server); } diff --git a/src/tools/binance-convert/trade-api/orderStatus.ts b/src/tools/binance-convert/trade-api/orderStatus.ts index 2a6521a6..2f0db587 100644 --- a/src/tools/binance-convert/trade-api/orderStatus.ts +++ b/src/tools/binance-convert/trade-api/orderStatus.ts @@ -1,9 +1,9 @@ // src/tools/binance-convert/trade-api/orderStatus.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { convertClient } from "../../../config/binanceClient.js" +import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertOrderStatus(server: McpServer) { server.tool( @@ -18,9 +18,9 @@ export function registerBinanceConvertOrderStatus(server: McpServer) { const response = await convertClient.restAPI.orderStatus({ ...(params.orderId && { orderId: params.orderId }), ...(params.quoteId && { quoteId: params.quoteId }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -31,9 +31,9 @@ export function registerBinanceConvertOrderStatus(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -43,8 +43,8 @@ export function registerBinanceConvertOrderStatus(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-convert/trade-api/placeLimitOrder.ts b/src/tools/binance-convert/trade-api/placeLimitOrder.ts index 775c1b66..54896a32 100644 --- a/src/tools/binance-convert/trade-api/placeLimitOrder.ts +++ b/src/tools/binance-convert/trade-api/placeLimitOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-convert/trade-api/placeLimitOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { convertClient } from "../../../config/binanceClient.js" +import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertPlaceLimitOrder(server: McpServer) { server.tool( @@ -53,9 +53,9 @@ export function registerBinanceConvertPlaceLimitOrder(server: McpServer) { ...(params.quoteAmount !== undefined && { quoteAmount: params.quoteAmount }), ...(params.walletType && { walletType: params.walletType }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -64,9 +64,9 @@ export function registerBinanceConvertPlaceLimitOrder(server: McpServer) { text: `Successfully placed the limit order. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -76,8 +76,8 @@ export function registerBinanceConvertPlaceLimitOrder(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-convert/trade-api/queryLimitOpenOrders.ts b/src/tools/binance-convert/trade-api/queryLimitOpenOrders.ts index 84e405af..a55f4f73 100644 --- a/src/tools/binance-convert/trade-api/queryLimitOpenOrders.ts +++ b/src/tools/binance-convert/trade-api/queryLimitOpenOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-convert/trade-api/queryLimitOpenOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { convertClient } from "../../../config/binanceClient.js" +import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertQueryLimitOpenOrders(server: McpServer) { server.tool( @@ -21,9 +21,9 @@ export function registerBinanceConvertQueryLimitOpenOrders(server: McpServer) { try { const response = await convertClient.restAPI.queryLimitOpenOrders({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -34,9 +34,9 @@ export function registerBinanceConvertQueryLimitOpenOrders(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -46,8 +46,8 @@ export function registerBinanceConvertQueryLimitOpenOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-convert/trade-api/sendQuoteRequest.ts b/src/tools/binance-convert/trade-api/sendQuoteRequest.ts index 8b7c40c7..e7ae7a91 100644 --- a/src/tools/binance-convert/trade-api/sendQuoteRequest.ts +++ b/src/tools/binance-convert/trade-api/sendQuoteRequest.ts @@ -1,9 +1,9 @@ // src/tools/binance-convert/trade-api/sendQuoteRequest.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { convertClient } from "../../../config/binanceClient.js" +import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertSendQuoteRequest(server: McpServer) { server.tool( @@ -43,9 +43,9 @@ export function registerBinanceConvertSendQuoteRequest(server: McpServer) { ...(params.walletType && { walletType: params.walletType }), ...(params.validTime && { validTime: params.validTime }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -56,9 +56,9 @@ export function registerBinanceConvertSendQuoteRequest(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -68,8 +68,8 @@ export function registerBinanceConvertSendQuoteRequest(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/followTrader.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/followTrader.ts index 87894903..1b09a1a3 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/followTrader.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/followTrader.ts @@ -1,9 +1,9 @@ // src/tools/binance-copy-trading/FutureCopyTrading-api/followTrader.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { copyTradingClient } from "../../../config/binanceClient.js" +import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceCopyTradingFollow(server: McpServer) { server.tool( @@ -40,9 +40,9 @@ export function registerBinanceCopyTradingFollow(server: McpServer) { ...(params.takeProfitRatio && { takeProfitRatio: params.takeProfitRatio }), ...(params.fixedAmount && { fixedAmount: params.fixedAmount }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -51,15 +51,15 @@ export function registerBinanceCopyTradingFollow(server: McpServer) { text: `✅ Now following trader ${params.portfolioId}!\n\nCopy Ratio: ${params.copyRatio || 1}x\nStop Loss: ${params.stopLossRatio ? params.stopLossRatio * 100 + "%" : "Not set"}\nTake Profit: ${params.takeProfitRatio ? params.takeProfitRatio * 100 + "%" : "Not set"}\n\n⚠️ Monitor your positions regularly.\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to follow trader: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyOrders.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyOrders.ts index 6a833546..40a8d3aa 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyOrders.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { copyTradingClient } from "../../../config/binanceClient.js" +import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceCopyTradingGetOrders(server: McpServer) { server.tool( @@ -28,9 +28,9 @@ export function registerBinanceCopyTradingGetOrders(server: McpServer) { ...(params.pageNumber && { pageNumber: params.pageNumber }), ...(params.pageSize && { pageSize: params.pageSize }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -39,15 +39,15 @@ export function registerBinanceCopyTradingGetOrders(server: McpServer) { text: `Copy Trading Orders:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get copy orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyPositions.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyPositions.ts index afed5f1f..763a245a 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyPositions.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyPositions.ts @@ -1,9 +1,9 @@ // src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyPositions.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { copyTradingClient } from "../../../config/binanceClient.js" +import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceCopyTradingGetPositions(server: McpServer) { server.tool( @@ -20,9 +20,9 @@ export function registerBinanceCopyTradingGetPositions(server: McpServer) { ...(params.portfolioId && { portfolioId: params.portfolioId }), ...(params.symbol && { symbol: params.symbol }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -31,15 +31,15 @@ export function registerBinanceCopyTradingGetPositions(server: McpServer) { text: `Copy Trading Positions:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get copy positions: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/getFollowingTraders.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/getFollowingTraders.ts index 710d4226..1df3bcb9 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/getFollowingTraders.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/getFollowingTraders.ts @@ -1,9 +1,9 @@ // src/tools/binance-copy-trading/FutureCopyTrading-api/getFollowingTraders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { copyTradingClient } from "../../../config/binanceClient.js" +import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceCopyTradingGetFollowing(server: McpServer) { server.tool( @@ -16,9 +16,9 @@ export function registerBinanceCopyTradingGetFollowing(server: McpServer) { try { const response = await copyTradingClient.restAPI.getFollowingTraders({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -27,15 +27,15 @@ export function registerBinanceCopyTradingGetFollowing(server: McpServer) { text: `Traders You're Following:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get following traders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts index 57786147..d824f411 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts @@ -1,9 +1,9 @@ // src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { copyTradingClient } from "../../../config/binanceClient.js" +import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetFuturesLeadTraderStatus(server: McpServer) { server.tool( @@ -16,9 +16,9 @@ export function registerBinanceGetFuturesLeadTraderStatus(server: McpServer) { try { const response = await copyTradingClient.restAPI.getFuturesLeadTraderStatus({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,9 +29,9 @@ export function registerBinanceGetFuturesLeadTraderStatus(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -41,8 +41,8 @@ export function registerBinanceGetFuturesLeadTraderStatus(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts index 925b449f..5efe5667 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts @@ -1,9 +1,9 @@ // src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { copyTradingClient } from "../../../config/binanceClient.js" +import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetFuturesLeadTradingSymbolWhitelist(server: McpServer) { server.tool( @@ -16,9 +16,9 @@ export function registerBinanceGetFuturesLeadTradingSymbolWhitelist(server: McpS try { const response = await copyTradingClient.restAPI.getFuturesLeadTradingSymbolWhitelist({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -27,9 +27,9 @@ export function registerBinanceGetFuturesLeadTradingSymbolWhitelist(server: McpS text: `Successfully retrieved trading pairs. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -39,8 +39,8 @@ export function registerBinanceGetFuturesLeadTradingSymbolWhitelist(server: McpS }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/getLeadTraders.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/getLeadTraders.ts index a6c96d1d..b058e89a 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/getLeadTraders.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/getLeadTraders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-copy-trading/FutureCopyTrading-api/getLeadTraders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { copyTradingClient } from "../../../config/binanceClient.js" +import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceCopyTradingGetLeaders(server: McpServer) { server.tool( @@ -26,9 +26,9 @@ export function registerBinanceCopyTradingGetLeaders(server: McpServer) { ...(params.pageNumber && { pageNumber: params.pageNumber }), ...(params.pageSize && { pageSize: params.pageSize }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -37,15 +37,15 @@ export function registerBinanceCopyTradingGetLeaders(server: McpServer) { text: `Lead Traders:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get lead traders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/getTraderPerformance.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/getTraderPerformance.ts index 6e3aa340..e206e5c0 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/getTraderPerformance.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/getTraderPerformance.ts @@ -1,9 +1,9 @@ // src/tools/binance-copy-trading/FutureCopyTrading-api/getTraderPerformance.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { copyTradingClient } from "../../../config/binanceClient.js" +import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceCopyTradingGetPerformance(server: McpServer) { server.tool( @@ -18,9 +18,9 @@ export function registerBinanceCopyTradingGetPerformance(server: McpServer) { const response = await copyTradingClient.restAPI.getLeadTraderPerformance({ portfolioId: params.portfolioId, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,15 +29,15 @@ export function registerBinanceCopyTradingGetPerformance(server: McpServer) { text: `Trader Performance for ${params.portfolioId}:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get trader performance: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/index.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/index.ts index c7be5c17..27f03171 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/index.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/index.ts @@ -1,14 +1,14 @@ // src/tools/binance-copy-trading/FutureCopyTrading-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetFuturesLeadTraderStatus } from "./getFuturesLeadTraderStatus.js" -import { registerBinanceGetFuturesLeadTradingSymbolWhitelist } from "./getFuturesLeadTradingSymbolWhitelist.js" +import { registerBinanceGetFuturesLeadTraderStatus } from "./getFuturesLeadTraderStatus.js"; +import { registerBinanceGetFuturesLeadTradingSymbolWhitelist } from "./getFuturesLeadTradingSymbolWhitelist.js"; // Registers Binance Futures Copy Trading API tools with the MCP server. export function registerBinanceFutureCopyTradingApiTools(server: McpServer) { // Registers an endpoint to get the status of a lead trader in futures copy trading - registerBinanceGetFuturesLeadTraderStatus(server) + registerBinanceGetFuturesLeadTraderStatus(server); // Registers an endpoint to get the whitelist of symbols available for futures copy trading - registerBinanceGetFuturesLeadTradingSymbolWhitelist(server) + registerBinanceGetFuturesLeadTradingSymbolWhitelist(server); } diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/unfollowTrader.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/unfollowTrader.ts index 778e9f58..57775242 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/unfollowTrader.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/unfollowTrader.ts @@ -1,9 +1,9 @@ // src/tools/binance-copy-trading/FutureCopyTrading-api/unfollowTrader.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { copyTradingClient } from "../../../config/binanceClient.js" +import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceCopyTradingUnfollow(server: McpServer) { server.tool( @@ -18,9 +18,9 @@ export function registerBinanceCopyTradingUnfollow(server: McpServer) { const response = await copyTradingClient.restAPI.unfollowLeadTrader({ portfolioId: params.portfolioId, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,15 +29,15 @@ export function registerBinanceCopyTradingUnfollow(server: McpServer) { text: `✅ Stopped following trader ${params.portfolioId}\n\n📝 Note: Existing copied positions remain open. Close them manually if needed.\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to unfollow trader: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-copy-trading/index.ts b/src/tools/binance-copy-trading/index.ts index 5dc0e672..4dabc39b 100644 --- a/src/tools/binance-copy-trading/index.ts +++ b/src/tools/binance-copy-trading/index.ts @@ -1,10 +1,10 @@ // src/tools/binance-copy-trading/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceFutureCopyTradingApiTools } from "./FutureCopyTrading-api/index.js" +import { registerBinanceFutureCopyTradingApiTools } from "./FutureCopyTrading-api/index.js"; // Registers all Binance Copy Trading related tools with the MCP server. export function registerBinanceCopyTradingTools(server: McpServer) { // Register the Binance Futures Copy Trading API tools with the given server. - registerBinanceFutureCopyTradingApiTools(server) + registerBinanceFutureCopyTradingApiTools(server); } diff --git a/src/tools/binance-crypto-loans/fixed-api/adjustLTV.ts b/src/tools/binance-crypto-loans/fixed-api/adjustLTV.ts index a9199c4a..8a9d613d 100644 --- a/src/tools/binance-crypto-loans/fixed-api/adjustLTV.ts +++ b/src/tools/binance-crypto-loans/fixed-api/adjustLTV.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/fixed-api/adjustLTV.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../../config/binanceClient.js" +import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFixedAdjustLTV(server: McpServer) { server.tool( @@ -30,11 +30,11 @@ export function registerBinanceCryptoLoansFixedAdjustLTV(server: McpServer) { amount: params.amount, direction: params.direction, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - const action = params.direction === "ADDITIONAL" ? "added" : "removed" + const action = params.direction === "ADDITIONAL" ? "added" : "removed"; return { content: [ @@ -43,15 +43,15 @@ export function registerBinanceCryptoLoansFixedAdjustLTV(server: McpServer) { text: `✅ LTV Adjusted!\n\nOrder ID: ${params.orderId}\nCollateral ${action}: ${params.amount}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to adjust LTV: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/fixed-api/borrow.ts b/src/tools/binance-crypto-loans/fixed-api/borrow.ts index 155ffea5..246a33b5 100644 --- a/src/tools/binance-crypto-loans/fixed-api/borrow.ts +++ b/src/tools/binance-crypto-loans/fixed-api/borrow.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/fixed-api/borrow.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../../config/binanceClient.js" +import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFixedBorrow(server: McpServer) { server.tool( @@ -37,7 +37,7 @@ export function registerBinanceCryptoLoansFixedBorrow(server: McpServer) { { type: "text", text: "❌ Either loanAmount or collateralAmount must be provided" }, ], isError: true, - } + }; } const response = await cryptoLoanClient.restAPI.cryptoLoanBorrow({ @@ -47,9 +47,9 @@ export function registerBinanceCryptoLoansFixedBorrow(server: McpServer) { ...(params.loanAmount && { loanAmount: params.loanAmount }), ...(params.collateralAmount && { collateralAmount: params.collateralAmount }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -58,15 +58,15 @@ export function registerBinanceCryptoLoansFixedBorrow(server: McpServer) { text: `✅ Fixed-Term Loan Created!\n\nLoan Coin: ${params.loanCoin}\nCollateral: ${params.collateralCoin}\nTerm: ${params.loanTerm} days\n\n⚠️ Remember to repay before the term ends to avoid liquidation.\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to borrow: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/fixed-api/checkCollateralRate.ts b/src/tools/binance-crypto-loans/fixed-api/checkCollateralRate.ts index c6fe8dfe..6edca8e9 100644 --- a/src/tools/binance-crypto-loans/fixed-api/checkCollateralRate.ts +++ b/src/tools/binance-crypto-loans/fixed-api/checkCollateralRate.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/fixed-api/checkCollateralRate.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../../config/binanceClient.js" +import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFixedCollateralRate(server: McpServer) { server.tool( @@ -28,9 +28,9 @@ export function registerBinanceCryptoLoansFixedCollateralRate(server: McpServer) collateralCoin: params.collateralCoin, repayAmount: params.repayAmount, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -39,15 +39,15 @@ export function registerBinanceCryptoLoansFixedCollateralRate(server: McpServer) text: `Collateral Repay Rate:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to check collateral rate: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/fixed-api/customizeMarginCall.ts b/src/tools/binance-crypto-loans/fixed-api/customizeMarginCall.ts index 12deda63..de1420c3 100644 --- a/src/tools/binance-crypto-loans/fixed-api/customizeMarginCall.ts +++ b/src/tools/binance-crypto-loans/fixed-api/customizeMarginCall.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/fixed-api/customizeMarginCall.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../../config/binanceClient.js" +import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFixedMarginCall(server: McpServer) { server.tool( @@ -26,9 +26,9 @@ export function registerBinanceCryptoLoansFixedMarginCall(server: McpServer) { orderId: params.orderId, marginCall: params.marginCall, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -37,15 +37,15 @@ export function registerBinanceCryptoLoansFixedMarginCall(server: McpServer) { text: `✅ Margin call threshold updated!\n\nOrder ID: ${params.orderId}\nNew Threshold: ${params.marginCall * 100}%\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to customize margin call: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/fixed-api/getBorrowHistory.ts b/src/tools/binance-crypto-loans/fixed-api/getBorrowHistory.ts index 2dec742f..d9476f36 100644 --- a/src/tools/binance-crypto-loans/fixed-api/getBorrowHistory.ts +++ b/src/tools/binance-crypto-loans/fixed-api/getBorrowHistory.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/fixed-api/getBorrowHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../../config/binanceClient.js" +import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFixedBorrowHistory(server: McpServer) { server.tool( @@ -36,9 +36,9 @@ export function registerBinanceCryptoLoansFixedBorrowHistory(server: McpServer) ...(params.current && { current: params.current }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -47,15 +47,15 @@ export function registerBinanceCryptoLoansFixedBorrowHistory(server: McpServer) text: `Fixed Loan Borrow History:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get borrow history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/fixed-api/getFixedCollateralData.ts b/src/tools/binance-crypto-loans/fixed-api/getFixedCollateralData.ts index 897f2f93..a214f3da 100644 --- a/src/tools/binance-crypto-loans/fixed-api/getFixedCollateralData.ts +++ b/src/tools/binance-crypto-loans/fixed-api/getFixedCollateralData.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/fixed-api/getFixedCollateralData.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../../config/binanceClient.js" +import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFixedCollateral(server: McpServer) { server.tool( @@ -26,9 +26,9 @@ export function registerBinanceCryptoLoansFixedCollateral(server: McpServer) { ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), ...(params.vipLevel !== undefined && { vipLevel: params.vipLevel }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -37,15 +37,15 @@ export function registerBinanceCryptoLoansFixedCollateral(server: McpServer) { text: `Fixed Loan Collateral Assets:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get collateral data: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/fixed-api/getFixedLoanData.ts b/src/tools/binance-crypto-loans/fixed-api/getFixedLoanData.ts index a908e6fa..fb58d306 100644 --- a/src/tools/binance-crypto-loans/fixed-api/getFixedLoanData.ts +++ b/src/tools/binance-crypto-loans/fixed-api/getFixedLoanData.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/fixed-api/getFixedLoanData.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../../config/binanceClient.js" +import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFixedAssets(server: McpServer) { server.tool( @@ -32,9 +32,9 @@ export function registerBinanceCryptoLoansFixedAssets(server: McpServer) { ...(params.loanCoin && { loanCoin: params.loanCoin }), ...(params.vipLevel !== undefined && { vipLevel: params.vipLevel }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -43,15 +43,15 @@ export function registerBinanceCryptoLoansFixedAssets(server: McpServer) { text: `Fixed Loan Assets:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get fixed loan assets: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/fixed-api/getOngoingOrders.ts b/src/tools/binance-crypto-loans/fixed-api/getOngoingOrders.ts index 8a76066c..7038e592 100644 --- a/src/tools/binance-crypto-loans/fixed-api/getOngoingOrders.ts +++ b/src/tools/binance-crypto-loans/fixed-api/getOngoingOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/fixed-api/getOngoingOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../../config/binanceClient.js" +import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFixedOngoing(server: McpServer) { server.tool( @@ -32,9 +32,9 @@ export function registerBinanceCryptoLoansFixedOngoing(server: McpServer) { ...(params.current && { current: params.current }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -43,15 +43,15 @@ export function registerBinanceCryptoLoansFixedOngoing(server: McpServer) { text: `Ongoing Fixed Loans:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get ongoing orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/fixed-api/getRepayHistory.ts b/src/tools/binance-crypto-loans/fixed-api/getRepayHistory.ts index 2f10f889..c4945403 100644 --- a/src/tools/binance-crypto-loans/fixed-api/getRepayHistory.ts +++ b/src/tools/binance-crypto-loans/fixed-api/getRepayHistory.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/fixed-api/getRepayHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../../config/binanceClient.js" +import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFixedRepayHistory(server: McpServer) { server.tool( @@ -36,9 +36,9 @@ export function registerBinanceCryptoLoansFixedRepayHistory(server: McpServer) { ...(params.current && { current: params.current }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -47,15 +47,15 @@ export function registerBinanceCryptoLoansFixedRepayHistory(server: McpServer) { text: `Fixed Loan Repay History:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get repay history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/fixed-api/index.ts b/src/tools/binance-crypto-loans/fixed-api/index.ts index 5f5ae38a..f8a542f6 100644 --- a/src/tools/binance-crypto-loans/fixed-api/index.ts +++ b/src/tools/binance-crypto-loans/fixed-api/index.ts @@ -5,28 +5,28 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/fixed-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceCryptoLoansFixedAdjustLTV } from "./adjustLTV.js" -import { registerBinanceCryptoLoansFixedBorrow } from "./borrow.js" -import { registerBinanceCryptoLoansFixedCollateralRate } from "./checkCollateralRate.js" -import { registerBinanceCryptoLoansFixedMarginCall } from "./customizeMarginCall.js" -import { registerBinanceCryptoLoansFixedBorrowHistory } from "./getBorrowHistory.js" -import { registerBinanceCryptoLoansFixedCollateral } from "./getFixedCollateralData.js" -import { registerBinanceCryptoLoansFixedAssets } from "./getFixedLoanData.js" -import { registerBinanceCryptoLoansFixedOngoing } from "./getOngoingOrders.js" -import { registerBinanceCryptoLoansFixedRepayHistory } from "./getRepayHistory.js" -import { registerBinanceCryptoLoansFixedRepay } from "./repay.js" +import { registerBinanceCryptoLoansFixedAdjustLTV } from "./adjustLTV.js"; +import { registerBinanceCryptoLoansFixedBorrow } from "./borrow.js"; +import { registerBinanceCryptoLoansFixedCollateralRate } from "./checkCollateralRate.js"; +import { registerBinanceCryptoLoansFixedMarginCall } from "./customizeMarginCall.js"; +import { registerBinanceCryptoLoansFixedBorrowHistory } from "./getBorrowHistory.js"; +import { registerBinanceCryptoLoansFixedCollateral } from "./getFixedCollateralData.js"; +import { registerBinanceCryptoLoansFixedAssets } from "./getFixedLoanData.js"; +import { registerBinanceCryptoLoansFixedOngoing } from "./getOngoingOrders.js"; +import { registerBinanceCryptoLoansFixedRepayHistory } from "./getRepayHistory.js"; +import { registerBinanceCryptoLoansFixedRepay } from "./repay.js"; export function registerBinanceCryptoLoansFixedTools(server: McpServer) { - registerBinanceCryptoLoansFixedAssets(server) - registerBinanceCryptoLoansFixedCollateral(server) - registerBinanceCryptoLoansFixedCollateralRate(server) - registerBinanceCryptoLoansFixedMarginCall(server) - registerBinanceCryptoLoansFixedBorrow(server) - registerBinanceCryptoLoansFixedRepay(server) - registerBinanceCryptoLoansFixedAdjustLTV(server) - registerBinanceCryptoLoansFixedOngoing(server) - registerBinanceCryptoLoansFixedBorrowHistory(server) - registerBinanceCryptoLoansFixedRepayHistory(server) + registerBinanceCryptoLoansFixedAssets(server); + registerBinanceCryptoLoansFixedCollateral(server); + registerBinanceCryptoLoansFixedCollateralRate(server); + registerBinanceCryptoLoansFixedMarginCall(server); + registerBinanceCryptoLoansFixedBorrow(server); + registerBinanceCryptoLoansFixedRepay(server); + registerBinanceCryptoLoansFixedAdjustLTV(server); + registerBinanceCryptoLoansFixedOngoing(server); + registerBinanceCryptoLoansFixedBorrowHistory(server); + registerBinanceCryptoLoansFixedRepayHistory(server); } diff --git a/src/tools/binance-crypto-loans/fixed-api/repay.ts b/src/tools/binance-crypto-loans/fixed-api/repay.ts index 7d73773a..29783976 100644 --- a/src/tools/binance-crypto-loans/fixed-api/repay.ts +++ b/src/tools/binance-crypto-loans/fixed-api/repay.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/fixed-api/repay.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../../config/binanceClient.js" +import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFixedRepay(server: McpServer) { server.tool( @@ -38,9 +38,9 @@ export function registerBinanceCryptoLoansFixedRepay(server: McpServer) { collateralReturn: params.collateralReturn, }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -49,15 +49,15 @@ export function registerBinanceCryptoLoansFixedRepay(server: McpServer) { text: `✅ Loan Repayment Successful!\n\nOrder ID: ${params.orderId}\nAmount Repaid: ${params.amount}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to repay loan: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/flexible-api/adjustLTV.ts b/src/tools/binance-crypto-loans/flexible-api/adjustLTV.ts index 8479854e..7e661c3d 100644 --- a/src/tools/binance-crypto-loans/flexible-api/adjustLTV.ts +++ b/src/tools/binance-crypto-loans/flexible-api/adjustLTV.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/flexible-api/adjustLTV.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../../config/binanceClient.js" +import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFlexibleAdjustLTV(server: McpServer) { server.tool( @@ -34,11 +34,11 @@ export function registerBinanceCryptoLoansFlexibleAdjustLTV(server: McpServer) { adjustmentAmount: params.adjustmentAmount, direction: params.direction, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - const action = params.direction === "ADDITIONAL" ? "added" : "removed" + const action = params.direction === "ADDITIONAL" ? "added" : "removed"; return { content: [ @@ -47,15 +47,15 @@ export function registerBinanceCryptoLoansFlexibleAdjustLTV(server: McpServer) { text: `✅ LTV Adjusted!\n\nCollateral ${action}: ${params.adjustmentAmount} ${params.collateralCoin}\n\n${params.direction === "ADDITIONAL" ? "Your liquidation risk is now lower." : "⚠️ Your liquidation risk may have increased."}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to adjust LTV: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/flexible-api/borrow.ts b/src/tools/binance-crypto-loans/flexible-api/borrow.ts index 69be92f0..7f08a77f 100644 --- a/src/tools/binance-crypto-loans/flexible-api/borrow.ts +++ b/src/tools/binance-crypto-loans/flexible-api/borrow.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/flexible-api/borrow.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../../config/binanceClient.js" +import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFlexibleBorrow(server: McpServer) { server.tool( @@ -37,7 +37,7 @@ export function registerBinanceCryptoLoansFlexibleBorrow(server: McpServer) { { type: "text", text: "❌ Either loanAmount or collateralAmount must be provided" }, ], isError: true, - } + }; } const response = await cryptoLoanClient.restAPI.flexibleLoanBorrow({ @@ -46,9 +46,9 @@ export function registerBinanceCryptoLoansFlexibleBorrow(server: McpServer) { ...(params.loanAmount && { loanAmount: params.loanAmount }), ...(params.collateralAmount && { collateralAmount: params.collateralAmount }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -57,15 +57,15 @@ export function registerBinanceCryptoLoansFlexibleBorrow(server: McpServer) { text: `✅ Flexible Loan Borrowed!\n\nLoan Coin: ${params.loanCoin}\nCollateral: ${params.collateralCoin}\n\n⚠️ Monitor your LTV ratio regularly to avoid liquidation.\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to borrow: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/flexible-api/getBorrowHistory.ts b/src/tools/binance-crypto-loans/flexible-api/getBorrowHistory.ts index 645e003a..4da463be 100644 --- a/src/tools/binance-crypto-loans/flexible-api/getBorrowHistory.ts +++ b/src/tools/binance-crypto-loans/flexible-api/getBorrowHistory.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/flexible-api/getBorrowHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../../config/binanceClient.js" +import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFlexibleBorrowHistory(server: McpServer) { server.tool( @@ -34,9 +34,9 @@ export function registerBinanceCryptoLoansFlexibleBorrowHistory(server: McpServe ...(params.current && { current: params.current }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -45,15 +45,15 @@ export function registerBinanceCryptoLoansFlexibleBorrowHistory(server: McpServe text: `Flexible Loan Borrow History:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get borrow history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/flexible-api/getFlexibleCollateralAssets.ts b/src/tools/binance-crypto-loans/flexible-api/getFlexibleCollateralAssets.ts index d1a1d190..74b2656f 100644 --- a/src/tools/binance-crypto-loans/flexible-api/getFlexibleCollateralAssets.ts +++ b/src/tools/binance-crypto-loans/flexible-api/getFlexibleCollateralAssets.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/flexible-api/getFlexibleCollateralAssets.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../../config/binanceClient.js" +import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFlexibleCollateral(server: McpServer) { server.tool( @@ -27,9 +27,9 @@ export function registerBinanceCryptoLoansFlexibleCollateral(server: McpServer) const response = await cryptoLoanClient.restAPI.getFlexibleLoanCollateralAssetsData({ ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -38,15 +38,15 @@ export function registerBinanceCryptoLoansFlexibleCollateral(server: McpServer) text: `Flexible Loan Collateral Assets:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get collateral assets: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/flexible-api/getFlexibleLoanAssets.ts b/src/tools/binance-crypto-loans/flexible-api/getFlexibleLoanAssets.ts index 8d443bce..0c481fec 100644 --- a/src/tools/binance-crypto-loans/flexible-api/getFlexibleLoanAssets.ts +++ b/src/tools/binance-crypto-loans/flexible-api/getFlexibleLoanAssets.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/flexible-api/getFlexibleLoanAssets.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../../config/binanceClient.js" +import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFlexibleAssets(server: McpServer) { server.tool( @@ -27,9 +27,9 @@ export function registerBinanceCryptoLoansFlexibleAssets(server: McpServer) { const response = await cryptoLoanClient.restAPI.getFlexibleLoanAssetsData({ ...(params.loanCoin && { loanCoin: params.loanCoin }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -38,15 +38,15 @@ export function registerBinanceCryptoLoansFlexibleAssets(server: McpServer) { text: `Flexible Loan Assets:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get loan assets: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/flexible-api/getOngoingOrders.ts b/src/tools/binance-crypto-loans/flexible-api/getOngoingOrders.ts index 93c5b1ea..ed2ff6d0 100644 --- a/src/tools/binance-crypto-loans/flexible-api/getOngoingOrders.ts +++ b/src/tools/binance-crypto-loans/flexible-api/getOngoingOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/flexible-api/getOngoingOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../../config/binanceClient.js" +import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFlexibleOngoing(server: McpServer) { server.tool( @@ -30,9 +30,9 @@ export function registerBinanceCryptoLoansFlexibleOngoing(server: McpServer) { ...(params.current && { current: params.current }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -41,15 +41,15 @@ export function registerBinanceCryptoLoansFlexibleOngoing(server: McpServer) { text: `Ongoing Flexible Loans:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get ongoing orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/flexible-api/getRepayHistory.ts b/src/tools/binance-crypto-loans/flexible-api/getRepayHistory.ts index 5d024f67..2eb02dca 100644 --- a/src/tools/binance-crypto-loans/flexible-api/getRepayHistory.ts +++ b/src/tools/binance-crypto-loans/flexible-api/getRepayHistory.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/flexible-api/getRepayHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../../config/binanceClient.js" +import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFlexibleRepayHistory(server: McpServer) { server.tool( @@ -34,9 +34,9 @@ export function registerBinanceCryptoLoansFlexibleRepayHistory(server: McpServer ...(params.current && { current: params.current }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -45,15 +45,15 @@ export function registerBinanceCryptoLoansFlexibleRepayHistory(server: McpServer text: `Flexible Loan Repay History:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get repay history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/flexible-api/index.ts b/src/tools/binance-crypto-loans/flexible-api/index.ts index c6e86e31..624a4bf2 100644 --- a/src/tools/binance-crypto-loans/flexible-api/index.ts +++ b/src/tools/binance-crypto-loans/flexible-api/index.ts @@ -5,24 +5,24 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/flexible-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceCryptoLoansFlexibleAdjustLTV } from "./adjustLTV.js" -import { registerBinanceCryptoLoansFlexibleBorrow } from "./borrow.js" -import { registerBinanceCryptoLoansFlexibleBorrowHistory } from "./getBorrowHistory.js" -import { registerBinanceCryptoLoansFlexibleCollateral } from "./getFlexibleCollateralAssets.js" -import { registerBinanceCryptoLoansFlexibleAssets } from "./getFlexibleLoanAssets.js" -import { registerBinanceCryptoLoansFlexibleOngoing } from "./getOngoingOrders.js" -import { registerBinanceCryptoLoansFlexibleRepayHistory } from "./getRepayHistory.js" -import { registerBinanceCryptoLoansFlexibleRepay } from "./repay.js" +import { registerBinanceCryptoLoansFlexibleAdjustLTV } from "./adjustLTV.js"; +import { registerBinanceCryptoLoansFlexibleBorrow } from "./borrow.js"; +import { registerBinanceCryptoLoansFlexibleBorrowHistory } from "./getBorrowHistory.js"; +import { registerBinanceCryptoLoansFlexibleCollateral } from "./getFlexibleCollateralAssets.js"; +import { registerBinanceCryptoLoansFlexibleAssets } from "./getFlexibleLoanAssets.js"; +import { registerBinanceCryptoLoansFlexibleOngoing } from "./getOngoingOrders.js"; +import { registerBinanceCryptoLoansFlexibleRepayHistory } from "./getRepayHistory.js"; +import { registerBinanceCryptoLoansFlexibleRepay } from "./repay.js"; export function registerBinanceCryptoLoansFlexibleTools(server: McpServer) { - registerBinanceCryptoLoansFlexibleAssets(server) - registerBinanceCryptoLoansFlexibleCollateral(server) - registerBinanceCryptoLoansFlexibleBorrow(server) - registerBinanceCryptoLoansFlexibleRepay(server) - registerBinanceCryptoLoansFlexibleAdjustLTV(server) - registerBinanceCryptoLoansFlexibleOngoing(server) - registerBinanceCryptoLoansFlexibleBorrowHistory(server) - registerBinanceCryptoLoansFlexibleRepayHistory(server) + registerBinanceCryptoLoansFlexibleAssets(server); + registerBinanceCryptoLoansFlexibleCollateral(server); + registerBinanceCryptoLoansFlexibleBorrow(server); + registerBinanceCryptoLoansFlexibleRepay(server); + registerBinanceCryptoLoansFlexibleAdjustLTV(server); + registerBinanceCryptoLoansFlexibleOngoing(server); + registerBinanceCryptoLoansFlexibleBorrowHistory(server); + registerBinanceCryptoLoansFlexibleRepayHistory(server); } diff --git a/src/tools/binance-crypto-loans/flexible-api/repay.ts b/src/tools/binance-crypto-loans/flexible-api/repay.ts index 50fab9be..0e92e3ee 100644 --- a/src/tools/binance-crypto-loans/flexible-api/repay.ts +++ b/src/tools/binance-crypto-loans/flexible-api/repay.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-crypto-loans/flexible-api/repay.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../../config/binanceClient.js" +import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFlexibleRepay(server: McpServer) { server.tool( @@ -37,9 +37,9 @@ export function registerBinanceCryptoLoansFlexibleRepay(server: McpServer) { }), ...(params.fullRepayment !== undefined && { fullRepayment: params.fullRepayment }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -48,15 +48,15 @@ export function registerBinanceCryptoLoansFlexibleRepay(server: McpServer) { text: `✅ Loan Repayment Successful!\n\nRepaid: ${params.repayAmount} ${params.loanCoin}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to repay loan: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/flexibleLoanAdjustLTV.ts b/src/tools/binance-crypto-loans/flexibleLoanAdjustLTV.ts index b56bdf52..8c1dbb36 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanAdjustLTV.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanAdjustLTV.ts @@ -1,9 +1,9 @@ // src/tools/binance-crypto-loans/flexibleLoanAdjustLTV.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../config/binanceClient.js" +import { cryptoLoanClient } from "../../config/binanceClient.js"; export function registerBinanceCryptoLoanFlexibleLoanAdjustLTV(server: McpServer) { server.tool( @@ -19,10 +19,10 @@ export function registerBinanceCryptoLoanFlexibleLoanAdjustLTV(server: McpServer }, async ({ loanCoin, collateralCoin, adjustmentAmount, direction }) => { try { - const params: any = { loanCoin, collateralCoin, adjustmentAmount, direction } + const params: any = { loanCoin, collateralCoin, adjustmentAmount, direction }; - const response = await cryptoLoanClient.restAPI.flexibleLoanAdjustLtv(params) - const data = await response.data() + const response = await cryptoLoanClient.restAPI.flexibleLoanAdjustLtv(params); + const data = await response.data(); return { content: [ @@ -31,15 +31,15 @@ export function registerBinanceCryptoLoanFlexibleLoanAdjustLTV(server: McpServer text: `Flexible loan LTV adjusted successfully. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to adjust flexible loan LTV: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/flexibleLoanBorrow.ts b/src/tools/binance-crypto-loans/flexibleLoanBorrow.ts index 092ab391..e021b0ca 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanBorrow.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanBorrow.ts @@ -1,9 +1,9 @@ // src/tools/binance-crypto-loans/flexibleLoanBorrow.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../config/binanceClient.js" +import { cryptoLoanClient } from "../../config/binanceClient.js"; export function registerBinanceCryptoLoanFlexibleLoanBorrow(server: McpServer) { server.tool( @@ -17,12 +17,12 @@ export function registerBinanceCryptoLoanFlexibleLoanBorrow(server: McpServer) { }, async ({ loanCoin, collateralCoin, loanAmount, collateralAmount }) => { try { - const params: any = { loanCoin, collateralCoin } - if (loanAmount !== undefined) params.loanAmount = loanAmount - if (collateralAmount !== undefined) params.collateralAmount = collateralAmount + const params: any = { loanCoin, collateralCoin }; + if (loanAmount !== undefined) params.loanAmount = loanAmount; + if (collateralAmount !== undefined) params.collateralAmount = collateralAmount; - const response = await cryptoLoanClient.restAPI.flexibleLoanBorrow(params) - const data = await response.data() + const response = await cryptoLoanClient.restAPI.flexibleLoanBorrow(params); + const data = await response.data(); return { content: [ @@ -31,15 +31,15 @@ export function registerBinanceCryptoLoanFlexibleLoanBorrow(server: McpServer) { text: `Flexible loan borrowed successfully. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to borrow flexible loan: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/flexibleLoanBorrowHistory.ts b/src/tools/binance-crypto-loans/flexibleLoanBorrowHistory.ts index 2e931072..3ad7d3b2 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanBorrowHistory.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanBorrowHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-crypto-loans/flexibleLoanBorrowHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../config/binanceClient.js" +import { cryptoLoanClient } from "../../config/binanceClient.js"; export function registerBinanceCryptoLoanFlexibleLoanBorrowHistory(server: McpServer) { server.tool( @@ -19,16 +19,16 @@ export function registerBinanceCryptoLoanFlexibleLoanBorrowHistory(server: McpSe }, async ({ loanCoin, collateralCoin, startTime, endTime, current, limit }) => { try { - const params: any = {} - if (loanCoin) params.loanCoin = loanCoin - if (collateralCoin) params.collateralCoin = collateralCoin - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (current !== undefined) params.current = current - if (limit !== undefined) params.limit = limit + const params: any = {}; + if (loanCoin) params.loanCoin = loanCoin; + if (collateralCoin) params.collateralCoin = collateralCoin; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (current !== undefined) params.current = current; + if (limit !== undefined) params.limit = limit; - const response = await cryptoLoanClient.restAPI.flexibleLoanBorrowHistory(params) - const data = await response.data() + const response = await cryptoLoanClient.restAPI.flexibleLoanBorrowHistory(params); + const data = await response.data(); return { content: [ @@ -37,17 +37,17 @@ export function registerBinanceCryptoLoanFlexibleLoanBorrowHistory(server: McpSe text: `Flexible loan borrow history retrieved. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to get flexible loan borrow history: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/flexibleLoanCollateralAssets.ts b/src/tools/binance-crypto-loans/flexibleLoanCollateralAssets.ts index d737df5a..30b88153 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanCollateralAssets.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanCollateralAssets.ts @@ -1,9 +1,9 @@ // src/tools/binance-crypto-loans/flexibleLoanCollateralAssets.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../config/binanceClient.js" +import { cryptoLoanClient } from "../../config/binanceClient.js"; export function registerBinanceCryptoLoanFlexibleLoanCollateralAssets(server: McpServer) { server.tool( @@ -14,11 +14,11 @@ export function registerBinanceCryptoLoanFlexibleLoanCollateralAssets(server: Mc }, async ({ collateralCoin }) => { try { - const params: any = {} - if (collateralCoin) params.collateralCoin = collateralCoin + const params: any = {}; + if (collateralCoin) params.collateralCoin = collateralCoin; - const response = await cryptoLoanClient.restAPI.getFlexibleLoanCollateralAssetsData(params) - const data = await response.data() + const response = await cryptoLoanClient.restAPI.getFlexibleLoanCollateralAssetsData(params); + const data = await response.data(); return { content: [ @@ -27,9 +27,9 @@ export function registerBinanceCryptoLoanFlexibleLoanCollateralAssets(server: Mc text: `Flexible loan collateral assets retrieved. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -39,8 +39,8 @@ export function registerBinanceCryptoLoanFlexibleLoanCollateralAssets(server: Mc }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/flexibleLoanLTVAdjustmentHistory.ts b/src/tools/binance-crypto-loans/flexibleLoanLTVAdjustmentHistory.ts index caee4efb..0e3a78b5 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanLTVAdjustmentHistory.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanLTVAdjustmentHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-crypto-loans/flexibleLoanLTVAdjustmentHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../config/binanceClient.js" +import { cryptoLoanClient } from "../../config/binanceClient.js"; export function registerBinanceCryptoLoanFlexibleLoanLTVAdjustmentHistory(server: McpServer) { server.tool( @@ -19,16 +19,16 @@ export function registerBinanceCryptoLoanFlexibleLoanLTVAdjustmentHistory(server }, async ({ loanCoin, collateralCoin, startTime, endTime, current, limit }) => { try { - const params: any = {} - if (loanCoin) params.loanCoin = loanCoin - if (collateralCoin) params.collateralCoin = collateralCoin - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (current !== undefined) params.current = current - if (limit !== undefined) params.limit = limit + const params: any = {}; + if (loanCoin) params.loanCoin = loanCoin; + if (collateralCoin) params.collateralCoin = collateralCoin; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (current !== undefined) params.current = current; + if (limit !== undefined) params.limit = limit; - const response = await cryptoLoanClient.restAPI.getFlexibleLoanLtvAdjustmentHistory(params) - const data = await response.data() + const response = await cryptoLoanClient.restAPI.getFlexibleLoanLtvAdjustmentHistory(params); + const data = await response.data(); return { content: [ @@ -37,9 +37,9 @@ export function registerBinanceCryptoLoanFlexibleLoanLTVAdjustmentHistory(server text: `Flexible loan LTV adjustment history retrieved. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -49,8 +49,8 @@ export function registerBinanceCryptoLoanFlexibleLoanLTVAdjustmentHistory(server }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/flexibleLoanLoanableAssets.ts b/src/tools/binance-crypto-loans/flexibleLoanLoanableAssets.ts index 1c2d6268..28f6e0fe 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanLoanableAssets.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanLoanableAssets.ts @@ -1,9 +1,9 @@ // src/tools/binance-crypto-loans/flexibleLoanLoanableAssets.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../config/binanceClient.js" +import { cryptoLoanClient } from "../../config/binanceClient.js"; export function registerBinanceCryptoLoanFlexibleLoanableAssets(server: McpServer) { server.tool( @@ -18,24 +18,24 @@ export function registerBinanceCryptoLoanFlexibleLoanableAssets(server: McpServe const response = await cryptoLoanClient.restAPI.getFlexibleLoanAssets({ ...(params.loanCoin && { loanCoin: params.loanCoin }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ { type: "text", text: `Flexible loan loanable assets: ${JSON.stringify(data)}` }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to get flexible loan loanable assets: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/flexibleLoanOngoingOrders.ts b/src/tools/binance-crypto-loans/flexibleLoanOngoingOrders.ts index 4916268e..3ea1c402 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanOngoingOrders.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanOngoingOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-crypto-loans/flexibleLoanOngoingOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../config/binanceClient.js" +import { cryptoLoanClient } from "../../config/binanceClient.js"; export function registerBinanceCryptoLoanFlexibleLoanOngoingOrders(server: McpServer) { server.tool( @@ -17,14 +17,14 @@ export function registerBinanceCryptoLoanFlexibleLoanOngoingOrders(server: McpSe }, async ({ loanCoin, collateralCoin, current, limit }) => { try { - const params: any = {} - if (loanCoin) params.loanCoin = loanCoin - if (collateralCoin) params.collateralCoin = collateralCoin - if (current !== undefined) params.current = current - if (limit !== undefined) params.limit = limit + const params: any = {}; + if (loanCoin) params.loanCoin = loanCoin; + if (collateralCoin) params.collateralCoin = collateralCoin; + if (current !== undefined) params.current = current; + if (limit !== undefined) params.limit = limit; - const response = await cryptoLoanClient.restAPI.flexibleLoanOngoingOrders(params) - const data = await response.data() + const response = await cryptoLoanClient.restAPI.flexibleLoanOngoingOrders(params); + const data = await response.data(); return { content: [ @@ -33,17 +33,17 @@ export function registerBinanceCryptoLoanFlexibleLoanOngoingOrders(server: McpSe text: `Flexible loan ongoing orders retrieved. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to get flexible loan ongoing orders: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/flexibleLoanRepay.ts b/src/tools/binance-crypto-loans/flexibleLoanRepay.ts index e854bfa9..b5f9311e 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanRepay.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanRepay.ts @@ -1,9 +1,9 @@ // src/tools/binance-crypto-loans/flexibleLoanRepay.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../config/binanceClient.js" +import { cryptoLoanClient } from "../../config/binanceClient.js"; export function registerBinanceCryptoLoanFlexibleLoanRepay(server: McpServer) { server.tool( @@ -18,12 +18,12 @@ export function registerBinanceCryptoLoanFlexibleLoanRepay(server: McpServer) { }, async ({ loanCoin, collateralCoin, repayAmount, collateralReturn, fullRepayment }) => { try { - const params: any = { loanCoin, collateralCoin, repayAmount } - if (collateralReturn !== undefined) params.collateralReturn = collateralReturn - if (fullRepayment !== undefined) params.fullRepayment = fullRepayment + const params: any = { loanCoin, collateralCoin, repayAmount }; + if (collateralReturn !== undefined) params.collateralReturn = collateralReturn; + if (fullRepayment !== undefined) params.fullRepayment = fullRepayment; - const response = await cryptoLoanClient.restAPI.flexibleLoanRepay(params) - const data = await response.data() + const response = await cryptoLoanClient.restAPI.flexibleLoanRepay(params); + const data = await response.data(); return { content: [ @@ -32,15 +32,15 @@ export function registerBinanceCryptoLoanFlexibleLoanRepay(server: McpServer) { text: `Flexible loan repaid successfully. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to repay flexible loan: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/flexibleLoanRepayHistory.ts b/src/tools/binance-crypto-loans/flexibleLoanRepayHistory.ts index 92f1a8cd..838e96c3 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanRepayHistory.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanRepayHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-crypto-loans/flexibleLoanRepayHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../config/binanceClient.js" +import { cryptoLoanClient } from "../../config/binanceClient.js"; export function registerBinanceCryptoLoanFlexibleLoanRepayHistory(server: McpServer) { server.tool( @@ -19,16 +19,16 @@ export function registerBinanceCryptoLoanFlexibleLoanRepayHistory(server: McpSer }, async ({ loanCoin, collateralCoin, startTime, endTime, current, limit }) => { try { - const params: any = {} - if (loanCoin) params.loanCoin = loanCoin - if (collateralCoin) params.collateralCoin = collateralCoin - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (current !== undefined) params.current = current - if (limit !== undefined) params.limit = limit + const params: any = {}; + if (loanCoin) params.loanCoin = loanCoin; + if (collateralCoin) params.collateralCoin = collateralCoin; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (current !== undefined) params.current = current; + if (limit !== undefined) params.limit = limit; - const response = await cryptoLoanClient.restAPI.flexibleLoanRepaymentHistory(params) - const data = await response.data() + const response = await cryptoLoanClient.restAPI.flexibleLoanRepaymentHistory(params); + const data = await response.data(); return { content: [ @@ -37,17 +37,17 @@ export function registerBinanceCryptoLoanFlexibleLoanRepayHistory(server: McpSer text: `Flexible loan repay history retrieved. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to get flexible loan repay history: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/getCollateralAssetsData.ts b/src/tools/binance-crypto-loans/getCollateralAssetsData.ts index a386428e..7f7706fe 100644 --- a/src/tools/binance-crypto-loans/getCollateralAssetsData.ts +++ b/src/tools/binance-crypto-loans/getCollateralAssetsData.ts @@ -1,9 +1,9 @@ // src/tools/binance-crypto-loans/getCollateralAssetsData.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../config/binanceClient.js" +import { cryptoLoanClient } from "../../config/binanceClient.js"; export function registerBinanceCryptoLoanGetCollateralAssetsDataV2(server: McpServer) { server.tool( @@ -15,12 +15,12 @@ export function registerBinanceCryptoLoanGetCollateralAssetsDataV2(server: McpSe }, async ({ collateralCoin, vipLevel }) => { try { - const params: any = {} - if (collateralCoin) params.collateralCoin = collateralCoin - if (vipLevel !== undefined) params.vipLevel = vipLevel + const params: any = {}; + if (collateralCoin) params.collateralCoin = collateralCoin; + if (vipLevel !== undefined) params.vipLevel = vipLevel; - const response = await cryptoLoanClient.restAPI.getFlexibleLoanCollateralAssetsData(params) - const data = await response.data() + const response = await cryptoLoanClient.restAPI.getFlexibleLoanCollateralAssetsData(params); + const data = await response.data(); return { content: [ @@ -29,17 +29,17 @@ export function registerBinanceCryptoLoanGetCollateralAssetsDataV2(server: McpSe text: `Collateral assets data V2 retrieved. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to get collateral assets data V2: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/getCollateralRepayRate.ts b/src/tools/binance-crypto-loans/getCollateralRepayRate.ts index 6fdbbf37..cc06d5b0 100644 --- a/src/tools/binance-crypto-loans/getCollateralRepayRate.ts +++ b/src/tools/binance-crypto-loans/getCollateralRepayRate.ts @@ -1,9 +1,9 @@ // src/tools/binance-crypto-loans/getCollateralRepayRate.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../config/binanceClient.js" +import { cryptoLoanClient } from "../../config/binanceClient.js"; export function registerBinanceCryptoLoanGetCollateralRepayRate(server: McpServer) { server.tool( @@ -16,10 +16,10 @@ export function registerBinanceCryptoLoanGetCollateralRepayRate(server: McpServe }, async ({ loanCoin, collateralCoin, repayAmount }) => { try { - const params: any = { loanCoin, collateralCoin, repayAmount } + const params: any = { loanCoin, collateralCoin, repayAmount }; - const response = await cryptoLoanClient.restAPI.checkCollateralRepayRate(params) - const data = await response.data() + const response = await cryptoLoanClient.restAPI.checkCollateralRepayRate(params); + const data = await response.data(); return { content: [ @@ -28,15 +28,15 @@ export function registerBinanceCryptoLoanGetCollateralRepayRate(server: McpServe text: `Collateral repay rate retrieved. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get collateral repay rate: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/getLoanableAssetsData.ts b/src/tools/binance-crypto-loans/getLoanableAssetsData.ts index 3e0939f7..94f0b89f 100644 --- a/src/tools/binance-crypto-loans/getLoanableAssetsData.ts +++ b/src/tools/binance-crypto-loans/getLoanableAssetsData.ts @@ -1,9 +1,9 @@ // src/tools/binance-crypto-loans/getLoanableAssetsData.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { cryptoLoanClient } from "../../config/binanceClient.js" +import { cryptoLoanClient } from "../../config/binanceClient.js"; export function registerBinanceCryptoLoanGetLoanableAssetsDataV2(server: McpServer) { server.tool( @@ -15,12 +15,12 @@ export function registerBinanceCryptoLoanGetLoanableAssetsDataV2(server: McpServ }, async ({ loanCoin, vipLevel }) => { try { - const params: any = {} - if (loanCoin) params.loanCoin = loanCoin - if (vipLevel !== undefined) params.vipLevel = vipLevel + const params: any = {}; + if (loanCoin) params.loanCoin = loanCoin; + if (vipLevel !== undefined) params.vipLevel = vipLevel; - const response = await cryptoLoanClient.restAPI.getFlexibleLoanAssetsData(params) - const data = await response.data() + const response = await cryptoLoanClient.restAPI.getFlexibleLoanAssetsData(params); + const data = await response.data(); return { content: [ @@ -29,17 +29,17 @@ export function registerBinanceCryptoLoanGetLoanableAssetsDataV2(server: McpServ text: `Loanable assets data V2 retrieved. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to get loanable assets data V2: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-crypto-loans/index.ts b/src/tools/binance-crypto-loans/index.ts index 708155b9..b7ebbc02 100644 --- a/src/tools/binance-crypto-loans/index.ts +++ b/src/tools/binance-crypto-loans/index.ts @@ -1,38 +1,38 @@ // src/tools/binance-crypto-loans/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceCryptoLoanFlexibleLoanAdjustLTV } from "./flexibleLoanAdjustLTV.js" +import { registerBinanceCryptoLoanFlexibleLoanAdjustLTV } from "./flexibleLoanAdjustLTV.js"; // Crypto Loans - Trading -import { registerBinanceCryptoLoanFlexibleLoanBorrow } from "./flexibleLoanBorrow.js" -import { registerBinanceCryptoLoanFlexibleLoanBorrowHistory } from "./flexibleLoanBorrowHistory.js" -import { registerBinanceCryptoLoanFlexibleLoanCollateralAssets } from "./flexibleLoanCollateralAssets.js" -import { registerBinanceCryptoLoanFlexibleLoanableAssets } from "./flexibleLoanLoanableAssets.js" -import { registerBinanceCryptoLoanFlexibleLoanLTVAdjustmentHistory } from "./flexibleLoanLTVAdjustmentHistory.js" +import { registerBinanceCryptoLoanFlexibleLoanBorrow } from "./flexibleLoanBorrow.js"; +import { registerBinanceCryptoLoanFlexibleLoanBorrowHistory } from "./flexibleLoanBorrowHistory.js"; +import { registerBinanceCryptoLoanFlexibleLoanCollateralAssets } from "./flexibleLoanCollateralAssets.js"; +import { registerBinanceCryptoLoanFlexibleLoanableAssets } from "./flexibleLoanLoanableAssets.js"; +import { registerBinanceCryptoLoanFlexibleLoanLTVAdjustmentHistory } from "./flexibleLoanLTVAdjustmentHistory.js"; // Crypto Loans - History -import { registerBinanceCryptoLoanFlexibleLoanOngoingOrders } from "./flexibleLoanOngoingOrders.js" -import { registerBinanceCryptoLoanFlexibleLoanRepay } from "./flexibleLoanRepay.js" -import { registerBinanceCryptoLoanFlexibleLoanRepayHistory } from "./flexibleLoanRepayHistory.js" -import { registerBinanceCryptoLoanGetCollateralAssetsDataV2 } from "./getCollateralAssetsData.js" +import { registerBinanceCryptoLoanFlexibleLoanOngoingOrders } from "./flexibleLoanOngoingOrders.js"; +import { registerBinanceCryptoLoanFlexibleLoanRepay } from "./flexibleLoanRepay.js"; +import { registerBinanceCryptoLoanFlexibleLoanRepayHistory } from "./flexibleLoanRepayHistory.js"; +import { registerBinanceCryptoLoanGetCollateralAssetsDataV2 } from "./getCollateralAssetsData.js"; // Crypto Loans - Info -import { registerBinanceCryptoLoanGetCollateralRepayRate } from "./getCollateralRepayRate.js" -import { registerBinanceCryptoLoanGetLoanableAssetsDataV2 } from "./getLoanableAssetsData.js" +import { registerBinanceCryptoLoanGetCollateralRepayRate } from "./getCollateralRepayRate.js"; +import { registerBinanceCryptoLoanGetLoanableAssetsDataV2 } from "./getLoanableAssetsData.js"; export function registerBinanceCryptoLoansTools(server: McpServer) { // Crypto Loans - Info - registerBinanceCryptoLoanGetCollateralRepayRate(server) - registerBinanceCryptoLoanGetLoanableAssetsDataV2(server) - registerBinanceCryptoLoanGetCollateralAssetsDataV2(server) - registerBinanceCryptoLoanFlexibleLoanCollateralAssets(server) - registerBinanceCryptoLoanFlexibleLoanableAssets(server) + registerBinanceCryptoLoanGetCollateralRepayRate(server); + registerBinanceCryptoLoanGetLoanableAssetsDataV2(server); + registerBinanceCryptoLoanGetCollateralAssetsDataV2(server); + registerBinanceCryptoLoanFlexibleLoanCollateralAssets(server); + registerBinanceCryptoLoanFlexibleLoanableAssets(server); // Crypto Loans - Trading - registerBinanceCryptoLoanFlexibleLoanBorrow(server) - registerBinanceCryptoLoanFlexibleLoanRepay(server) - registerBinanceCryptoLoanFlexibleLoanAdjustLTV(server) + registerBinanceCryptoLoanFlexibleLoanBorrow(server); + registerBinanceCryptoLoanFlexibleLoanRepay(server); + registerBinanceCryptoLoanFlexibleLoanAdjustLTV(server); // Crypto Loans - History - registerBinanceCryptoLoanFlexibleLoanOngoingOrders(server) - registerBinanceCryptoLoanFlexibleLoanBorrowHistory(server) - registerBinanceCryptoLoanFlexibleLoanRepayHistory(server) - registerBinanceCryptoLoanFlexibleLoanLTVAdjustmentHistory(server) + registerBinanceCryptoLoanFlexibleLoanOngoingOrders(server); + registerBinanceCryptoLoanFlexibleLoanBorrowHistory(server); + registerBinanceCryptoLoanFlexibleLoanRepayHistory(server); + registerBinanceCryptoLoanFlexibleLoanLTVAdjustmentHistory(server); } diff --git a/src/tools/binance-dual-investment/index.ts b/src/tools/binance-dual-investment/index.ts index 94c1369c..7a94024e 100644 --- a/src/tools/binance-dual-investment/index.ts +++ b/src/tools/binance-dual-investment/index.ts @@ -1,10 +1,10 @@ // src/tools/binance-dual-investment/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceDualInvestmentMarketApiTools } from "./market-api/index.js" -import { registerBinanceDualInvestmentTradeApiTools } from "./trade-api/index.js" +import { registerBinanceDualInvestmentMarketApiTools } from "./market-api/index.js"; +import { registerBinanceDualInvestmentTradeApiTools } from "./trade-api/index.js"; export function registerBinanceDualInvestmentTools(server: McpServer) { - registerBinanceDualInvestmentTradeApiTools(server) - registerBinanceDualInvestmentMarketApiTools(server) + registerBinanceDualInvestmentTradeApiTools(server); + registerBinanceDualInvestmentMarketApiTools(server); } diff --git a/src/tools/binance-dual-investment/market-api/getDualInvestmentProductList.ts b/src/tools/binance-dual-investment/market-api/getDualInvestmentProductList.ts index b9d20a31..0af64c24 100644 --- a/src/tools/binance-dual-investment/market-api/getDualInvestmentProductList.ts +++ b/src/tools/binance-dual-investment/market-api/getDualInvestmentProductList.ts @@ -1,9 +1,9 @@ // src/tools/binance-dual-investment/market-api/getDualInvestmentProductList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { dualInvestmentClient } from "../../../config/binanceClient.js" +import { dualInvestmentClient } from "../../../config/binanceClient.js"; export function registerBinanceGetDualInvestmentProductList(server: McpServer) { server.tool( @@ -37,9 +37,9 @@ export function registerBinanceGetDualInvestmentProductList(server: McpServer) { ...(params.pageSize && { pageSize: params.pageSize }), ...(params.pageIndex && { pageIndex: params.pageIndex }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -50,9 +50,9 @@ export function registerBinanceGetDualInvestmentProductList(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -62,8 +62,8 @@ export function registerBinanceGetDualInvestmentProductList(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-dual-investment/market-api/index.ts b/src/tools/binance-dual-investment/market-api/index.ts index b2d90200..f5465f8a 100644 --- a/src/tools/binance-dual-investment/market-api/index.ts +++ b/src/tools/binance-dual-investment/market-api/index.ts @@ -1,8 +1,8 @@ // src/tools/binance-dual-investment/market-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetDualInvestmentProductList } from "./getDualInvestmentProductList.js" +import { registerBinanceGetDualInvestmentProductList } from "./getDualInvestmentProductList.js"; export function registerBinanceDualInvestmentMarketApiTools(server: McpServer) { - registerBinanceGetDualInvestmentProductList(server) + registerBinanceGetDualInvestmentProductList(server); } diff --git a/src/tools/binance-dual-investment/trade-api/changeAutoCompoundStatus.ts b/src/tools/binance-dual-investment/trade-api/changeAutoCompoundStatus.ts index b47051eb..97749554 100644 --- a/src/tools/binance-dual-investment/trade-api/changeAutoCompoundStatus.ts +++ b/src/tools/binance-dual-investment/trade-api/changeAutoCompoundStatus.ts @@ -1,9 +1,9 @@ // src/tools/binance-dual-investment/trade-api/changeAutoCompoundStatus.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { dualInvestmentClient } from "../../../config/binanceClient.js" +import { dualInvestmentClient } from "../../../config/binanceClient.js"; export function registerBinanceChangeAutoCompoundStatus(server: McpServer) { server.tool( @@ -28,9 +28,9 @@ export function registerBinanceChangeAutoCompoundStatus(server: McpServer) { positionId: params.positionId, autoCompoundPlan: params.autoCompoundPlan, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -41,9 +41,9 @@ export function registerBinanceChangeAutoCompoundStatus(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -53,8 +53,8 @@ export function registerBinanceChangeAutoCompoundStatus(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-dual-investment/trade-api/checkDualInvestmentAccounts.ts b/src/tools/binance-dual-investment/trade-api/checkDualInvestmentAccounts.ts index a37c71f5..4fa4e18b 100644 --- a/src/tools/binance-dual-investment/trade-api/checkDualInvestmentAccounts.ts +++ b/src/tools/binance-dual-investment/trade-api/checkDualInvestmentAccounts.ts @@ -1,9 +1,9 @@ // src/tools/binance-dual-investment/trade-api/checkDualInvestmentAccounts.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { dualInvestmentClient } from "../../../config/binanceClient.js" +import { dualInvestmentClient } from "../../../config/binanceClient.js"; export function registerBinanceCheckDualInvestmentAccounts(server: McpServer) { server.tool( @@ -21,9 +21,9 @@ export function registerBinanceCheckDualInvestmentAccounts(server: McpServer) { try { const response = await dualInvestmentClient.restAPI.checkDualInvestmentAccounts({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -34,9 +34,9 @@ export function registerBinanceCheckDualInvestmentAccounts(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -46,8 +46,8 @@ export function registerBinanceCheckDualInvestmentAccounts(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-dual-investment/trade-api/getDualInvestmentPositions.ts b/src/tools/binance-dual-investment/trade-api/getDualInvestmentPositions.ts index 8a24b7b8..f7138155 100644 --- a/src/tools/binance-dual-investment/trade-api/getDualInvestmentPositions.ts +++ b/src/tools/binance-dual-investment/trade-api/getDualInvestmentPositions.ts @@ -1,9 +1,9 @@ // src/tools/binance-dual-investment/trade-api/getDualInvestmentPositions.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { dualInvestmentClient } from "../../../config/binanceClient.js" +import { dualInvestmentClient } from "../../../config/binanceClient.js"; export function registerBinanceGetDualInvestmentPositions(server: McpServer) { server.tool( @@ -46,9 +46,9 @@ export function registerBinanceGetDualInvestmentPositions(server: McpServer) { ...(params.pageSize && { pageSize: params.pageSize }), ...(params.pageIndex && { pageIndex: params.pageIndex }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -59,9 +59,9 @@ export function registerBinanceGetDualInvestmentPositions(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -71,8 +71,8 @@ export function registerBinanceGetDualInvestmentPositions(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-dual-investment/trade-api/index.ts b/src/tools/binance-dual-investment/trade-api/index.ts index 157890bc..97d55f6c 100644 --- a/src/tools/binance-dual-investment/trade-api/index.ts +++ b/src/tools/binance-dual-investment/trade-api/index.ts @@ -1,14 +1,14 @@ // src/tools/binance-dual-investment/trade-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceChangeAutoCompoundStatus } from "./changeAutoCompoundStatus.js" -import { registerBinanceCheckDualInvestmentAccounts } from "./checkDualInvestmentAccounts.js" -import { registerBinanceGetDualInvestmentPositions } from "./getDualInvestmentPositions.js" -import { registerBinanceSubscribeDualInvestmentProducts } from "./subscribeDualInvestmentProducts.js" +import { registerBinanceChangeAutoCompoundStatus } from "./changeAutoCompoundStatus.js"; +import { registerBinanceCheckDualInvestmentAccounts } from "./checkDualInvestmentAccounts.js"; +import { registerBinanceGetDualInvestmentPositions } from "./getDualInvestmentPositions.js"; +import { registerBinanceSubscribeDualInvestmentProducts } from "./subscribeDualInvestmentProducts.js"; export function registerBinanceDualInvestmentTradeApiTools(server: McpServer) { - registerBinanceSubscribeDualInvestmentProducts(server) - registerBinanceCheckDualInvestmentAccounts(server) - registerBinanceGetDualInvestmentPositions(server) - registerBinanceChangeAutoCompoundStatus(server) + registerBinanceSubscribeDualInvestmentProducts(server); + registerBinanceCheckDualInvestmentAccounts(server); + registerBinanceGetDualInvestmentPositions(server); + registerBinanceChangeAutoCompoundStatus(server); } diff --git a/src/tools/binance-dual-investment/trade-api/subscribeDualInvestmentProducts.ts b/src/tools/binance-dual-investment/trade-api/subscribeDualInvestmentProducts.ts index 41221ba1..b9b179fc 100644 --- a/src/tools/binance-dual-investment/trade-api/subscribeDualInvestmentProducts.ts +++ b/src/tools/binance-dual-investment/trade-api/subscribeDualInvestmentProducts.ts @@ -1,9 +1,9 @@ // src/tools/binance-dual-investment/trade-api/subscribeDualInvestmentProducts.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { dualInvestmentClient } from "../../../config/binanceClient.js" +import { dualInvestmentClient } from "../../../config/binanceClient.js"; export function registerBinanceSubscribeDualInvestmentProducts(server: McpServer) { server.tool( @@ -31,9 +31,9 @@ export function registerBinanceSubscribeDualInvestmentProducts(server: McpServer depositAmount: params.depositAmount, autoCompoundPlan: params.autoCompoundPlan, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -44,9 +44,9 @@ export function registerBinanceSubscribeDualInvestmentProducts(server: McpServer )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -56,8 +56,8 @@ export function registerBinanceSubscribeDualInvestmentProducts(server: McpServer }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-fiat/fiat-api/getFiatDepositWithdrawHistory.ts b/src/tools/binance-fiat/fiat-api/getFiatDepositWithdrawHistory.ts index bb1dd8d2..df6445a1 100644 --- a/src/tools/binance-fiat/fiat-api/getFiatDepositWithdrawHistory.ts +++ b/src/tools/binance-fiat/fiat-api/getFiatDepositWithdrawHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-fiat/fiat-api/getFiatDepositWithdrawHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { fiatClient } from "../../../config/binanceClient.js" +import { fiatClient } from "../../../config/binanceClient.js"; export function registerBinanceGetFiatDepositWithdrawHistory(server: McpServer) { server.tool( @@ -33,9 +33,9 @@ export function registerBinanceGetFiatDepositWithdrawHistory(server: McpServer) ...(params.page && { page: params.page }), ...(params.rows && { rows: params.rows }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -46,9 +46,9 @@ export function registerBinanceGetFiatDepositWithdrawHistory(server: McpServer) )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -58,8 +58,8 @@ export function registerBinanceGetFiatDepositWithdrawHistory(server: McpServer) }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-fiat/fiat-api/getFiatPaymentsHistory.ts b/src/tools/binance-fiat/fiat-api/getFiatPaymentsHistory.ts index 952e542f..0629c1c4 100644 --- a/src/tools/binance-fiat/fiat-api/getFiatPaymentsHistory.ts +++ b/src/tools/binance-fiat/fiat-api/getFiatPaymentsHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-fiat/fiat-api/getFiatPaymentsHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { fiatClient } from "../../../config/binanceClient.js" +import { fiatClient } from "../../../config/binanceClient.js"; export function registerBinanceGetFiatPaymentsHistory(server: McpServer) { server.tool( @@ -31,9 +31,9 @@ export function registerBinanceGetFiatPaymentsHistory(server: McpServer) { ...(params.page && { page: params.page }), ...(params.rows && { rows: params.rows }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -44,9 +44,9 @@ export function registerBinanceGetFiatPaymentsHistory(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -56,8 +56,8 @@ export function registerBinanceGetFiatPaymentsHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-fiat/index.ts b/src/tools/binance-fiat/index.ts index 8681309f..fbd6ba57 100644 --- a/src/tools/binance-fiat/index.ts +++ b/src/tools/binance-fiat/index.ts @@ -1,10 +1,10 @@ // src/tools/binance-fiat/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetFiatDepositWithdrawHistory } from "./fiat-api/getFiatDepositWithdrawHistory.js" -import { registerBinanceGetFiatPaymentsHistory } from "./fiat-api/getFiatPaymentsHistory.js" +import { registerBinanceGetFiatDepositWithdrawHistory } from "./fiat-api/getFiatDepositWithdrawHistory.js"; +import { registerBinanceGetFiatPaymentsHistory } from "./fiat-api/getFiatPaymentsHistory.js"; export function registerBinanceFiatDepositWithdrawHistoryTools(server: McpServer) { - registerBinanceGetFiatDepositWithdrawHistory(server) - registerBinanceGetFiatPaymentsHistory(server) + registerBinanceGetFiatDepositWithdrawHistory(server); + registerBinanceGetFiatPaymentsHistory(server); } diff --git a/src/tools/binance-futures-coinm/account-api/account.ts b/src/tools/binance-futures-coinm/account-api/account.ts index 1ce4205f..a8933ef9 100644 --- a/src/tools/binance-futures-coinm/account-api/account.ts +++ b/src/tools/binance-futures-coinm/account-api/account.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/account-api/account.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryAccount(server: McpServer) { server.tool( @@ -22,9 +22,9 @@ export function registerBinanceDeliveryAccount(server: McpServer) { try { const response = await deliveryClient.restAPI.account({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -33,15 +33,15 @@ export function registerBinanceDeliveryAccount(server: McpServer) { text: `📊 COIN-M Futures Account Information\n\nCan Trade: ${data.canTrade}\nCan Deposit: ${data.canDeposit}\nCan Withdraw: ${data.canWithdraw}\nUpdate Time: ${new Date(data.updateTime).toISOString()}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get account info: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/account-api/adlQuantile.ts b/src/tools/binance-futures-coinm/account-api/adlQuantile.ts index 09058f09..83bde3af 100644 --- a/src/tools/binance-futures-coinm/account-api/adlQuantile.ts +++ b/src/tools/binance-futures-coinm/account-api/adlQuantile.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/account-api/adlQuantile.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryAdlQuantile(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerBinanceDeliveryAdlQuantile(server: McpServer) { const response = await deliveryClient.restAPI.adlQuantile({ ...(params.symbol && { symbol: params.symbol }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,15 +35,15 @@ export function registerBinanceDeliveryAdlQuantile(server: McpServer) { text: `⚠️ COIN-M ADL Quantile${params.symbol ? ` for ${params.symbol}` : ""}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get ADL quantile: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/account-api/balance.ts b/src/tools/binance-futures-coinm/account-api/balance.ts index 9059400f..b7ddeca3 100644 --- a/src/tools/binance-futures-coinm/account-api/balance.ts +++ b/src/tools/binance-futures-coinm/account-api/balance.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/account-api/balance.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryBalance(server: McpServer) { server.tool( @@ -22,9 +22,9 @@ export function registerBinanceDeliveryBalance(server: McpServer) { try { const response = await deliveryClient.restAPI.balance({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -33,15 +33,15 @@ export function registerBinanceDeliveryBalance(server: McpServer) { text: `💰 COIN-M Futures Balance\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get balance: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/account-api/commissionRate.ts b/src/tools/binance-futures-coinm/account-api/commissionRate.ts index 4e6c435a..1b79d54e 100644 --- a/src/tools/binance-futures-coinm/account-api/commissionRate.ts +++ b/src/tools/binance-futures-coinm/account-api/commissionRate.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/account-api/commissionRate.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryCommissionRate(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerBinanceDeliveryCommissionRate(server: McpServer) { const response = await deliveryClient.restAPI.commissionRate({ symbol: params.symbol, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,15 +35,15 @@ export function registerBinanceDeliveryCommissionRate(server: McpServer) { text: `💰 COIN-M Commission Rate for ${params.symbol}\n\nMaker: ${data.makerCommissionRate}\nTaker: ${data.takerCommissionRate}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get commission rate: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/account-api/forceOrders.ts b/src/tools/binance-futures-coinm/account-api/forceOrders.ts index e9f96fc1..c9f3e7ff 100644 --- a/src/tools/binance-futures-coinm/account-api/forceOrders.ts +++ b/src/tools/binance-futures-coinm/account-api/forceOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/account-api/forceOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryForceOrders(server: McpServer) { server.tool( @@ -32,9 +32,9 @@ export function registerBinanceDeliveryForceOrders(server: McpServer) { ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -43,15 +43,15 @@ export function registerBinanceDeliveryForceOrders(server: McpServer) { text: `⚠️ COIN-M Force Orders (Liquidations)\n\nOrders: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get force orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/account-api/income.ts b/src/tools/binance-futures-coinm/account-api/income.ts index 10b603c8..d1ca0038 100644 --- a/src/tools/binance-futures-coinm/account-api/income.ts +++ b/src/tools/binance-futures-coinm/account-api/income.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/account-api/income.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryIncome(server: McpServer) { server.tool( @@ -47,9 +47,9 @@ export function registerBinanceDeliveryIncome(server: McpServer) { ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -58,15 +58,15 @@ export function registerBinanceDeliveryIncome(server: McpServer) { text: `💵 COIN-M Income History\n\nRecords: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get income history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/account-api/index.ts b/src/tools/binance-futures-coinm/account-api/index.ts index 4de5622e..7faba764 100644 --- a/src/tools/binance-futures-coinm/account-api/index.ts +++ b/src/tools/binance-futures-coinm/account-api/index.ts @@ -5,35 +5,35 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/account-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceDeliveryAccount } from "./account.js" -import { registerBinanceDeliveryAdlQuantile } from "./adlQuantile.js" -import { registerBinanceDeliveryBalance } from "./balance.js" -import { registerBinanceDeliveryCommissionRate } from "./commissionRate.js" -import { registerBinanceDeliveryForceOrders } from "./forceOrders.js" -import { registerBinanceDeliveryIncome } from "./income.js" -import { registerBinanceDeliveryLeverageBracket } from "./leverageBracket.js" -import { registerBinanceDeliveryPositionMode } from "./positionMode.js" -import { registerBinanceDeliveryPositionRisk } from "./positionRisk.js" -import { registerBinanceDeliveryUserTrades } from "./userTrades.js" +import { registerBinanceDeliveryAccount } from "./account.js"; +import { registerBinanceDeliveryAdlQuantile } from "./adlQuantile.js"; +import { registerBinanceDeliveryBalance } from "./balance.js"; +import { registerBinanceDeliveryCommissionRate } from "./commissionRate.js"; +import { registerBinanceDeliveryForceOrders } from "./forceOrders.js"; +import { registerBinanceDeliveryIncome } from "./income.js"; +import { registerBinanceDeliveryLeverageBracket } from "./leverageBracket.js"; +import { registerBinanceDeliveryPositionMode } from "./positionMode.js"; +import { registerBinanceDeliveryPositionRisk } from "./positionRisk.js"; +import { registerBinanceDeliveryUserTrades } from "./userTrades.js"; export function registerBinanceDeliveryAccountApiTools(server: McpServer) { // Account Information - registerBinanceDeliveryAccount(server) - registerBinanceDeliveryBalance(server) - registerBinanceDeliveryPositionRisk(server) + registerBinanceDeliveryAccount(server); + registerBinanceDeliveryBalance(server); + registerBinanceDeliveryPositionRisk(server); // Trade History - registerBinanceDeliveryUserTrades(server) - registerBinanceDeliveryIncome(server) + registerBinanceDeliveryUserTrades(server); + registerBinanceDeliveryIncome(server); // Leverage & Risk - registerBinanceDeliveryLeverageBracket(server) - registerBinanceDeliveryAdlQuantile(server) - registerBinanceDeliveryForceOrders(server) + registerBinanceDeliveryLeverageBracket(server); + registerBinanceDeliveryAdlQuantile(server); + registerBinanceDeliveryForceOrders(server); // Account Settings - registerBinanceDeliveryCommissionRate(server) - registerBinanceDeliveryPositionMode(server) + registerBinanceDeliveryCommissionRate(server); + registerBinanceDeliveryPositionMode(server); } diff --git a/src/tools/binance-futures-coinm/account-api/leverageBracket.ts b/src/tools/binance-futures-coinm/account-api/leverageBracket.ts index 5a8550ac..b1962b19 100644 --- a/src/tools/binance-futures-coinm/account-api/leverageBracket.ts +++ b/src/tools/binance-futures-coinm/account-api/leverageBracket.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/account-api/leverageBracket.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryLeverageBracket(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerBinanceDeliveryLeverageBracket(server: McpServer) { const response = await deliveryClient.restAPI.leverageBracket({ ...(params.pair && { pair: params.pair }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,15 +35,15 @@ export function registerBinanceDeliveryLeverageBracket(server: McpServer) { text: `📊 COIN-M Leverage Brackets${params.pair ? ` for ${params.pair}` : ""}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get leverage brackets: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/account-api/positionMode.ts b/src/tools/binance-futures-coinm/account-api/positionMode.ts index 8d0bebfe..fac0cabc 100644 --- a/src/tools/binance-futures-coinm/account-api/positionMode.ts +++ b/src/tools/binance-futures-coinm/account-api/positionMode.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/account-api/positionMode.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryPositionMode(server: McpServer) { server.tool( @@ -22,10 +22,10 @@ export function registerBinanceDeliveryPositionMode(server: McpServer) { try { const response = await deliveryClient.restAPI.getPositionMode({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() - const mode = data.dualSidePosition ? "Hedge Mode (LONG/SHORT)" : "One-way Mode (BOTH)" + const data = await response.data(); + const mode = data.dualSidePosition ? "Hedge Mode (LONG/SHORT)" : "One-way Mode (BOTH)"; return { content: [ @@ -34,15 +34,15 @@ export function registerBinanceDeliveryPositionMode(server: McpServer) { text: `⚙️ COIN-M Position Mode\n\nCurrent Mode: ${mode}\ndualSidePosition: ${data.dualSidePosition}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get position mode: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/account-api/positionRisk.ts b/src/tools/binance-futures-coinm/account-api/positionRisk.ts index e15bdeb6..7e705ed1 100644 --- a/src/tools/binance-futures-coinm/account-api/positionRisk.ts +++ b/src/tools/binance-futures-coinm/account-api/positionRisk.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/account-api/positionRisk.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryPositionRisk(server: McpServer) { server.tool( @@ -26,9 +26,9 @@ export function registerBinanceDeliveryPositionRisk(server: McpServer) { ...(params.marginAsset && { marginAsset: params.marginAsset }), ...(params.pair && { pair: params.pair }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -37,15 +37,15 @@ export function registerBinanceDeliveryPositionRisk(server: McpServer) { text: `📊 COIN-M Position Risk\n\nPositions: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get position risk: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/account-api/userTrades.ts b/src/tools/binance-futures-coinm/account-api/userTrades.ts index 37055924..5c0a64b7 100644 --- a/src/tools/binance-futures-coinm/account-api/userTrades.ts +++ b/src/tools/binance-futures-coinm/account-api/userTrades.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/account-api/userTrades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryUserTrades(server: McpServer) { server.tool( @@ -34,9 +34,9 @@ export function registerBinanceDeliveryUserTrades(server: McpServer) { ...(params.fromId && { fromId: params.fromId }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -45,15 +45,15 @@ export function registerBinanceDeliveryUserTrades(server: McpServer) { text: `📈 COIN-M Trade History\n\nTrades: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get user trades: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/account.ts b/src/tools/binance-futures-coinm/account.ts index 52167185..c00edf69 100644 --- a/src/tools/binance-futures-coinm/account.ts +++ b/src/tools/binance-futures-coinm/account.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/account.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMAccount(server: McpServer) { server.tool( @@ -16,19 +16,19 @@ export function registerBinanceFuturesCOINMAccount(server: McpServer) { try { const data = await deliveryClient.getAccount({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [{ type: "text", text: `COIN-M account info: ${JSON.stringify(data)}` }], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get COIN-M account: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/adlQuantile.ts b/src/tools/binance-futures-coinm/adlQuantile.ts index 9f085658..44c4f3e0 100644 --- a/src/tools/binance-futures-coinm/adlQuantile.ts +++ b/src/tools/binance-futures-coinm/adlQuantile.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/adlQuantile.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMADLQuantile(server: McpServer) { server.tool( @@ -19,10 +19,10 @@ export function registerBinanceFuturesCOINMADLQuantile(server: McpServer) { }, async ({ symbol }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol + const params: any = {}; + if (symbol) params.symbol = symbol; - const data = await deliveryClient.adlQuantile(params) + const data = await deliveryClient.adlQuantile(params); return { content: [ @@ -31,9 +31,9 @@ export function registerBinanceFuturesCOINMADLQuantile(server: McpServer) { text: `Retrieved COIN-M Futures ADL quantile${symbol ? ` for ${symbol}` : " for all positions"}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -43,8 +43,8 @@ export function registerBinanceFuturesCOINMADLQuantile(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/aggTrades.ts b/src/tools/binance-futures-coinm/aggTrades.ts index 2a68b793..6d7bb54f 100644 --- a/src/tools/binance-futures-coinm/aggTrades.ts +++ b/src/tools/binance-futures-coinm/aggTrades.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/aggTrades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMAggTrades(server: McpServer) { server.tool( @@ -24,13 +24,13 @@ export function registerBinanceFuturesCOINMAggTrades(server: McpServer) { }, async ({ symbol, fromId, startTime, endTime, limit }) => { try { - const params: any = { symbol } - if (fromId !== undefined) params.fromId = fromId - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + const params: any = { symbol }; + if (fromId !== undefined) params.fromId = fromId; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const data = await deliveryClient.aggTrades(params) + const data = await deliveryClient.aggTrades(params); return { content: [ @@ -39,9 +39,9 @@ export function registerBinanceFuturesCOINMAggTrades(server: McpServer) { text: `Retrieved ${data.length || 0} aggregated trades for COIN-M Futures ${symbol}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -51,8 +51,8 @@ export function registerBinanceFuturesCOINMAggTrades(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/allOrders.ts b/src/tools/binance-futures-coinm/allOrders.ts index 00d17859..d2b37912 100644 --- a/src/tools/binance-futures-coinm/allOrders.ts +++ b/src/tools/binance-futures-coinm/allOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/allOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMAllOrders(server: McpServer) { server.tool( @@ -19,15 +19,15 @@ export function registerBinanceFuturesCOINMAllOrders(server: McpServer) { }, async ({ symbol, pair, orderId, startTime, endTime, limit }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol - if (pair) params.pair = pair - if (orderId !== undefined) params.orderId = orderId - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + const params: any = {}; + if (symbol) params.symbol = symbol; + if (pair) params.pair = pair; + if (orderId !== undefined) params.orderId = orderId; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const data = await deliveryClient.allOrders(params) + const data = await deliveryClient.allOrders(params); return { content: [ @@ -36,17 +36,17 @@ export function registerBinanceFuturesCOINMAllOrders(server: McpServer) { text: `Retrieved ${data.length || 0} COIN-M Futures orders. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve COIN-M Futures all orders: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/balance.ts b/src/tools/binance-futures-coinm/balance.ts index dfe02747..a833070a 100644 --- a/src/tools/binance-futures-coinm/balance.ts +++ b/src/tools/binance-futures-coinm/balance.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/balance.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMBalance(server: McpServer) { server.tool( @@ -16,19 +16,19 @@ export function registerBinanceFuturesCOINMBalance(server: McpServer) { try { const data = await deliveryClient.getBalance({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [{ type: "text", text: `COIN-M balance: ${JSON.stringify(data)}` }], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get COIN-M balance: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/batchOrders.ts b/src/tools/binance-futures-coinm/batchOrders.ts index c34a9c1d..35d6bfc4 100644 --- a/src/tools/binance-futures-coinm/batchOrders.ts +++ b/src/tools/binance-futures-coinm/batchOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/batchOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMBatchOrders(server: McpServer) { server.tool( @@ -18,7 +18,7 @@ export function registerBinanceFuturesCOINMBatchOrders(server: McpServer) { }, async ({ batchOrders }) => { try { - const data = await deliveryClient.batchOrders({ batchOrders }) + const data = await deliveryClient.batchOrders({ batchOrders }); return { content: [ @@ -27,17 +27,17 @@ export function registerBinanceFuturesCOINMBatchOrders(server: McpServer) { text: `COIN-M Futures batch orders created. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to create COIN-M Futures batch orders: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/bookTicker.ts b/src/tools/binance-futures-coinm/bookTicker.ts index 2ccbb0df..ebfa9ea4 100644 --- a/src/tools/binance-futures-coinm/bookTicker.ts +++ b/src/tools/binance-futures-coinm/bookTicker.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/bookTicker.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMBookTicker(server: McpServer) { server.tool( @@ -20,11 +20,11 @@ export function registerBinanceFuturesCOINMBookTicker(server: McpServer) { }, async ({ symbol, pair }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol - if (pair) params.pair = pair + const params: any = {}; + if (symbol) params.symbol = symbol; + if (pair) params.pair = pair; - const data = await deliveryClient.tickerBookTicker(params) + const data = await deliveryClient.tickerBookTicker(params); return { content: [ @@ -33,9 +33,9 @@ export function registerBinanceFuturesCOINMBookTicker(server: McpServer) { text: `Retrieved COIN-M Futures book ticker${symbol ? ` for ${symbol}` : pair ? ` for pair ${pair}` : " for all symbols"}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -45,8 +45,8 @@ export function registerBinanceFuturesCOINMBookTicker(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/cancelAllOrders.ts b/src/tools/binance-futures-coinm/cancelAllOrders.ts index f439f06a..f73df3b1 100644 --- a/src/tools/binance-futures-coinm/cancelAllOrders.ts +++ b/src/tools/binance-futures-coinm/cancelAllOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/cancelAllOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMCancelAllOrders(server: McpServer) { server.tool( @@ -18,19 +18,19 @@ export function registerBinanceFuturesCOINMCancelAllOrders(server: McpServer) { const data = await deliveryClient.cancelAllOpenOrders({ symbol: params.symbol, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [{ type: "text", text: `All COIN-M orders cancelled: ${JSON.stringify(data)}` }], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to cancel all COIN-M orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/cancelBatchOrders.ts b/src/tools/binance-futures-coinm/cancelBatchOrders.ts index ed49bf15..2e21f9dc 100644 --- a/src/tools/binance-futures-coinm/cancelBatchOrders.ts +++ b/src/tools/binance-futures-coinm/cancelBatchOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/cancelBatchOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMCancelBatchOrders(server: McpServer) { server.tool( @@ -19,11 +19,11 @@ export function registerBinanceFuturesCOINMCancelBatchOrders(server: McpServer) }, async ({ symbol, orderIdList, origClientOrderIdList }) => { try { - const params: any = { symbol } - if (orderIdList) params.orderIdList = orderIdList - if (origClientOrderIdList) params.origClientOrderIdList = origClientOrderIdList + const params: any = { symbol }; + if (orderIdList) params.orderIdList = orderIdList; + if (origClientOrderIdList) params.origClientOrderIdList = origClientOrderIdList; - const data = await deliveryClient.cancelBatchOrders(params) + const data = await deliveryClient.cancelBatchOrders(params); return { content: [ @@ -32,17 +32,17 @@ export function registerBinanceFuturesCOINMCancelBatchOrders(server: McpServer) text: `COIN-M Futures batch orders cancelled. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to cancel COIN-M Futures batch orders: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/cancelOrder.ts b/src/tools/binance-futures-coinm/cancelOrder.ts index 56062e77..e19d369d 100644 --- a/src/tools/binance-futures-coinm/cancelOrder.ts +++ b/src/tools/binance-futures-coinm/cancelOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/cancelOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMCancelOrder(server: McpServer) { server.tool( @@ -22,19 +22,19 @@ export function registerBinanceFuturesCOINMCancelOrder(server: McpServer) { ...(params.orderId && { orderId: params.orderId }), ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [{ type: "text", text: `COIN-M order cancelled: ${JSON.stringify(data)}` }], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to cancel COIN-M order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/commissionRate.ts b/src/tools/binance-futures-coinm/commissionRate.ts index 248f5f69..b24060ab 100644 --- a/src/tools/binance-futures-coinm/commissionRate.ts +++ b/src/tools/binance-futures-coinm/commissionRate.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/commissionRate.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMCommissionRate(server: McpServer) { server.tool( @@ -14,7 +14,7 @@ export function registerBinanceFuturesCOINMCommissionRate(server: McpServer) { }, async ({ symbol }) => { try { - const data = await deliveryClient.commissionRate({ symbol }) + const data = await deliveryClient.commissionRate({ symbol }); return { content: [ @@ -23,9 +23,9 @@ export function registerBinanceFuturesCOINMCommissionRate(server: McpServer) { text: `Retrieved COIN-M Futures commission rate for ${symbol}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -35,8 +35,8 @@ export function registerBinanceFuturesCOINMCommissionRate(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/continuousKlines.ts b/src/tools/binance-futures-coinm/continuousKlines.ts index f225841e..d4db7fbc 100644 --- a/src/tools/binance-futures-coinm/continuousKlines.ts +++ b/src/tools/binance-futures-coinm/continuousKlines.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/continuousKlines.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMContinuousKlines(server: McpServer) { server.tool( @@ -39,12 +39,12 @@ export function registerBinanceFuturesCOINMContinuousKlines(server: McpServer) { }, async ({ pair, contractType, interval, startTime, endTime, limit }) => { try { - const params: any = { pair, contractType, interval } - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + const params: any = { pair, contractType, interval }; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const data = await deliveryClient.continuousKlines(params) + const data = await deliveryClient.continuousKlines(params); return { content: [ @@ -53,9 +53,9 @@ export function registerBinanceFuturesCOINMContinuousKlines(server: McpServer) { text: `Retrieved ${data.length || 0} continuous klines for COIN-M Futures ${pair} ${contractType} with ${interval} interval. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -65,8 +65,8 @@ export function registerBinanceFuturesCOINMContinuousKlines(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/depth.ts b/src/tools/binance-futures-coinm/depth.ts index d0ade0a9..badc7b41 100644 --- a/src/tools/binance-futures-coinm/depth.ts +++ b/src/tools/binance-futures-coinm/depth.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/depth.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMDepth(server: McpServer) { server.tool( @@ -20,10 +20,10 @@ export function registerBinanceFuturesCOINMDepth(server: McpServer) { }, async ({ symbol, limit }) => { try { - const params: any = { symbol } - if (limit !== undefined) params.limit = limit + const params: any = { symbol }; + if (limit !== undefined) params.limit = limit; - const data = await deliveryClient.depth(params) + const data = await deliveryClient.depth(params); return { content: [ @@ -32,9 +32,9 @@ export function registerBinanceFuturesCOINMDepth(server: McpServer) { text: `Retrieved COIN-M Futures order book depth for ${symbol}. Bids: ${data.bids?.length || 0}, Asks: ${data.asks?.length || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -44,8 +44,8 @@ export function registerBinanceFuturesCOINMDepth(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/exchangeInfo.ts b/src/tools/binance-futures-coinm/exchangeInfo.ts index 80ab2029..b7fa79e2 100644 --- a/src/tools/binance-futures-coinm/exchangeInfo.ts +++ b/src/tools/binance-futures-coinm/exchangeInfo.ts @@ -1,7 +1,7 @@ // src/tools/binance-futures-coinm/exchangeInfo.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMExchangeInfo(server: McpServer) { server.tool( @@ -10,7 +10,7 @@ export function registerBinanceFuturesCOINMExchangeInfo(server: McpServer) { {}, async () => { try { - const data = await deliveryClient.exchangeInfo() + const data = await deliveryClient.exchangeInfo(); return { content: [ @@ -19,17 +19,17 @@ export function registerBinanceFuturesCOINMExchangeInfo(server: McpServer) { text: `COIN-M Futures exchange info retrieved. Symbols count: ${data.symbols?.length || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to get COIN-M Futures exchange info: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/forceOrders.ts b/src/tools/binance-futures-coinm/forceOrders.ts index 8cdff2b8..15d9bcde 100644 --- a/src/tools/binance-futures-coinm/forceOrders.ts +++ b/src/tools/binance-futures-coinm/forceOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/forceOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMForceOrders(server: McpServer) { server.tool( @@ -21,14 +21,14 @@ export function registerBinanceFuturesCOINMForceOrders(server: McpServer) { }, async ({ symbol, autoCloseType, startTime, endTime, limit }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol - if (autoCloseType) params.autoCloseType = autoCloseType - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + const params: any = {}; + if (symbol) params.symbol = symbol; + if (autoCloseType) params.autoCloseType = autoCloseType; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const data = await deliveryClient.forceOrders(params) + const data = await deliveryClient.forceOrders(params); return { content: [ @@ -37,9 +37,9 @@ export function registerBinanceFuturesCOINMForceOrders(server: McpServer) { text: `Retrieved ${data.length || 0} COIN-M Futures force orders. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -49,8 +49,8 @@ export function registerBinanceFuturesCOINMForceOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/fundingRate.ts b/src/tools/binance-futures-coinm/fundingRate.ts index 9ac3ba08..d7da615a 100644 --- a/src/tools/binance-futures-coinm/fundingRate.ts +++ b/src/tools/binance-futures-coinm/fundingRate.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/fundingRate.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMFundingRate(server: McpServer) { server.tool( @@ -17,13 +17,13 @@ export function registerBinanceFuturesCOINMFundingRate(server: McpServer) { }, async ({ symbol, startTime, endTime, limit }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + const params: any = {}; + if (symbol) params.symbol = symbol; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const data = await deliveryClient.fundingRate(params) + const data = await deliveryClient.fundingRate(params); return { content: [ @@ -32,9 +32,9 @@ export function registerBinanceFuturesCOINMFundingRate(server: McpServer) { text: `Retrieved ${data.length || 0} funding rate records for COIN-M Futures${symbol ? ` ${symbol}` : ""}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -44,8 +44,8 @@ export function registerBinanceFuturesCOINMFundingRate(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/getOrder.ts b/src/tools/binance-futures-coinm/getOrder.ts index 47d95ebb..545d1e92 100644 --- a/src/tools/binance-futures-coinm/getOrder.ts +++ b/src/tools/binance-futures-coinm/getOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/getOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMGetOrder(server: McpServer) { server.tool( @@ -22,19 +22,19 @@ export function registerBinanceFuturesCOINMGetOrder(server: McpServer) { ...(params.orderId && { orderId: params.orderId }), ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [{ type: "text", text: `COIN-M order: ${JSON.stringify(data)}` }], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get COIN-M order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/historicalTrades.ts b/src/tools/binance-futures-coinm/historicalTrades.ts index cdd42e6e..fbc1bd29 100644 --- a/src/tools/binance-futures-coinm/historicalTrades.ts +++ b/src/tools/binance-futures-coinm/historicalTrades.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/historicalTrades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMHistoricalTrades(server: McpServer) { server.tool( @@ -19,11 +19,11 @@ export function registerBinanceFuturesCOINMHistoricalTrades(server: McpServer) { }, async ({ symbol, limit, fromId }) => { try { - const params: any = { symbol } - if (limit !== undefined) params.limit = limit - if (fromId !== undefined) params.fromId = fromId + const params: any = { symbol }; + if (limit !== undefined) params.limit = limit; + if (fromId !== undefined) params.fromId = fromId; - const data = await deliveryClient.historicalTrades(params) + const data = await deliveryClient.historicalTrades(params); return { content: [ @@ -32,9 +32,9 @@ export function registerBinanceFuturesCOINMHistoricalTrades(server: McpServer) { text: `Retrieved ${data.length || 0} historical trades for COIN-M Futures ${symbol}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -44,8 +44,8 @@ export function registerBinanceFuturesCOINMHistoricalTrades(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/income.ts b/src/tools/binance-futures-coinm/income.ts index 3f136937..6559b393 100644 --- a/src/tools/binance-futures-coinm/income.ts +++ b/src/tools/binance-futures-coinm/income.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/income.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMIncome(server: McpServer) { server.tool( @@ -33,14 +33,14 @@ export function registerBinanceFuturesCOINMIncome(server: McpServer) { }, async ({ symbol, incomeType, startTime, endTime, limit }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol - if (incomeType) params.incomeType = incomeType - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + const params: any = {}; + if (symbol) params.symbol = symbol; + if (incomeType) params.incomeType = incomeType; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const data = await deliveryClient.income(params) + const data = await deliveryClient.income(params); return { content: [ @@ -49,17 +49,17 @@ export function registerBinanceFuturesCOINMIncome(server: McpServer) { text: `Retrieved ${data.length || 0} COIN-M Futures income records. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve COIN-M Futures income: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/index.ts b/src/tools/binance-futures-coinm/index.ts index cf79cbdf..04f66887 100644 --- a/src/tools/binance-futures-coinm/index.ts +++ b/src/tools/binance-futures-coinm/index.ts @@ -1,96 +1,96 @@ // src/tools/binance-futures-coinm/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; // Account & Trading -import { registerBinanceFuturesCOINMAccount } from "./account.js" -import { registerBinanceFuturesCOINMADLQuantile } from "./adlQuantile.js" -import { registerBinanceFuturesCOINMAggTrades } from "./aggTrades.js" -import { registerBinanceFuturesCOINMAllOrders } from "./allOrders.js" -import { registerBinanceFuturesCOINMBalance } from "./balance.js" -import { registerBinanceFuturesCOINMBatchOrders } from "./batchOrders.js" -import { registerBinanceFuturesCOINMBookTicker } from "./bookTicker.js" -import { registerBinanceFuturesCOINMCancelAllOrders } from "./cancelAllOrders.js" -import { registerBinanceFuturesCOINMCancelBatchOrders } from "./cancelBatchOrders.js" -import { registerBinanceFuturesCOINMCancelOrder } from "./cancelOrder.js" -import { registerBinanceFuturesCOINMCommissionRate } from "./commissionRate.js" -import { registerBinanceFuturesCOINMContinuousKlines } from "./continuousKlines.js" -import { registerBinanceFuturesCOINMDepth } from "./depth.js" -import { registerBinanceFuturesCOINMExchangeInfo } from "./exchangeInfo.js" -import { registerBinanceFuturesCOINMForceOrders } from "./forceOrders.js" -import { registerBinanceFuturesCOINMFundingRate } from "./fundingRate.js" -import { registerBinanceFuturesCOINMGetOrder } from "./getOrder.js" -import { registerBinanceFuturesCOINMHistoricalTrades } from "./historicalTrades.js" -import { registerBinanceFuturesCOINMIncome } from "./income.js" -import { registerBinanceFuturesCOINMIndexPriceKlines } from "./indexPriceKlines.js" -import { registerBinanceFuturesCOINMKlines } from "./klines.js" -import { registerBinanceFuturesCOINMLeverage } from "./leverage.js" +import { registerBinanceFuturesCOINMAccount } from "./account.js"; +import { registerBinanceFuturesCOINMADLQuantile } from "./adlQuantile.js"; +import { registerBinanceFuturesCOINMAggTrades } from "./aggTrades.js"; +import { registerBinanceFuturesCOINMAllOrders } from "./allOrders.js"; +import { registerBinanceFuturesCOINMBalance } from "./balance.js"; +import { registerBinanceFuturesCOINMBatchOrders } from "./batchOrders.js"; +import { registerBinanceFuturesCOINMBookTicker } from "./bookTicker.js"; +import { registerBinanceFuturesCOINMCancelAllOrders } from "./cancelAllOrders.js"; +import { registerBinanceFuturesCOINMCancelBatchOrders } from "./cancelBatchOrders.js"; +import { registerBinanceFuturesCOINMCancelOrder } from "./cancelOrder.js"; +import { registerBinanceFuturesCOINMCommissionRate } from "./commissionRate.js"; +import { registerBinanceFuturesCOINMContinuousKlines } from "./continuousKlines.js"; +import { registerBinanceFuturesCOINMDepth } from "./depth.js"; +import { registerBinanceFuturesCOINMExchangeInfo } from "./exchangeInfo.js"; +import { registerBinanceFuturesCOINMForceOrders } from "./forceOrders.js"; +import { registerBinanceFuturesCOINMFundingRate } from "./fundingRate.js"; +import { registerBinanceFuturesCOINMGetOrder } from "./getOrder.js"; +import { registerBinanceFuturesCOINMHistoricalTrades } from "./historicalTrades.js"; +import { registerBinanceFuturesCOINMIncome } from "./income.js"; +import { registerBinanceFuturesCOINMIndexPriceKlines } from "./indexPriceKlines.js"; +import { registerBinanceFuturesCOINMKlines } from "./klines.js"; +import { registerBinanceFuturesCOINMLeverage } from "./leverage.js"; // User Data Stream import { registerBinanceFuturesCOINMListenKeyClose, registerBinanceFuturesCOINMListenKeyCreate, registerBinanceFuturesCOINMListenKeyRenew, -} from "./listenKey.js" -import { registerBinanceFuturesCOINMMarginType } from "./marginType.js" -import { registerBinanceFuturesCOINMMarkPriceKlines } from "./markPriceKlines.js" -import { registerBinanceFuturesCOINMNewOrder } from "./newOrder.js" -import { registerBinanceFuturesCOINMOpenInterest } from "./openInterest.js" -import { registerBinanceFuturesCOINMOpenOrders } from "./openOrders.js" +} from "./listenKey.js"; +import { registerBinanceFuturesCOINMMarginType } from "./marginType.js"; +import { registerBinanceFuturesCOINMMarkPriceKlines } from "./markPriceKlines.js"; +import { registerBinanceFuturesCOINMNewOrder } from "./newOrder.js"; +import { registerBinanceFuturesCOINMOpenInterest } from "./openInterest.js"; +import { registerBinanceFuturesCOINMOpenOrders } from "./openOrders.js"; // Market Data -import { registerBinanceFuturesCOINMPing } from "./ping.js" -import { registerBinanceFuturesCOINMPositionMargin } from "./positionMargin.js" -import { registerBinanceFuturesCOINMPositionMode } from "./positionMode.js" -import { registerBinanceFuturesCOINMPositionRisk } from "./positionRisk.js" -import { registerBinanceFuturesCOINMPremiumIndex } from "./premiumIndex.js" -import { registerBinanceFuturesCOINMTicker24hr } from "./ticker24hr.js" -import { registerBinanceFuturesCOINMTickerPrice } from "./tickerPrice.js" -import { registerBinanceFuturesCOINMTime } from "./time.js" -import { registerBinanceFuturesCOINMTrades } from "./trades.js" -import { registerBinanceFuturesCOINMUserTrades } from "./userTrades.js" +import { registerBinanceFuturesCOINMPing } from "./ping.js"; +import { registerBinanceFuturesCOINMPositionMargin } from "./positionMargin.js"; +import { registerBinanceFuturesCOINMPositionMode } from "./positionMode.js"; +import { registerBinanceFuturesCOINMPositionRisk } from "./positionRisk.js"; +import { registerBinanceFuturesCOINMPremiumIndex } from "./premiumIndex.js"; +import { registerBinanceFuturesCOINMTicker24hr } from "./ticker24hr.js"; +import { registerBinanceFuturesCOINMTickerPrice } from "./tickerPrice.js"; +import { registerBinanceFuturesCOINMTime } from "./time.js"; +import { registerBinanceFuturesCOINMTrades } from "./trades.js"; +import { registerBinanceFuturesCOINMUserTrades } from "./userTrades.js"; export function registerBinanceFuturesCOINMTools(server: McpServer) { // Market Data - registerBinanceFuturesCOINMPing(server) - registerBinanceFuturesCOINMTime(server) - registerBinanceFuturesCOINMExchangeInfo(server) - registerBinanceFuturesCOINMDepth(server) - registerBinanceFuturesCOINMTrades(server) - registerBinanceFuturesCOINMHistoricalTrades(server) - registerBinanceFuturesCOINMAggTrades(server) - registerBinanceFuturesCOINMKlines(server) - registerBinanceFuturesCOINMContinuousKlines(server) - registerBinanceFuturesCOINMIndexPriceKlines(server) - registerBinanceFuturesCOINMMarkPriceKlines(server) - registerBinanceFuturesCOINMPremiumIndex(server) - registerBinanceFuturesCOINMFundingRate(server) - registerBinanceFuturesCOINMTicker24hr(server) - registerBinanceFuturesCOINMTickerPrice(server) - registerBinanceFuturesCOINMBookTicker(server) - registerBinanceFuturesCOINMOpenInterest(server) + registerBinanceFuturesCOINMPing(server); + registerBinanceFuturesCOINMTime(server); + registerBinanceFuturesCOINMExchangeInfo(server); + registerBinanceFuturesCOINMDepth(server); + registerBinanceFuturesCOINMTrades(server); + registerBinanceFuturesCOINMHistoricalTrades(server); + registerBinanceFuturesCOINMAggTrades(server); + registerBinanceFuturesCOINMKlines(server); + registerBinanceFuturesCOINMContinuousKlines(server); + registerBinanceFuturesCOINMIndexPriceKlines(server); + registerBinanceFuturesCOINMMarkPriceKlines(server); + registerBinanceFuturesCOINMPremiumIndex(server); + registerBinanceFuturesCOINMFundingRate(server); + registerBinanceFuturesCOINMTicker24hr(server); + registerBinanceFuturesCOINMTickerPrice(server); + registerBinanceFuturesCOINMBookTicker(server); + registerBinanceFuturesCOINMOpenInterest(server); // Account & Trading - registerBinanceFuturesCOINMAccount(server) - registerBinanceFuturesCOINMBalance(server) - registerBinanceFuturesCOINMPositionRisk(server) - registerBinanceFuturesCOINMNewOrder(server) - registerBinanceFuturesCOINMBatchOrders(server) - registerBinanceFuturesCOINMGetOrder(server) - registerBinanceFuturesCOINMCancelOrder(server) - registerBinanceFuturesCOINMCancelAllOrders(server) - registerBinanceFuturesCOINMCancelBatchOrders(server) - registerBinanceFuturesCOINMOpenOrders(server) - registerBinanceFuturesCOINMAllOrders(server) - registerBinanceFuturesCOINMUserTrades(server) - registerBinanceFuturesCOINMIncome(server) - registerBinanceFuturesCOINMLeverage(server) - registerBinanceFuturesCOINMMarginType(server) - registerBinanceFuturesCOINMPositionMargin(server) - registerBinanceFuturesCOINMPositionMode(server) - registerBinanceFuturesCOINMCommissionRate(server) - registerBinanceFuturesCOINMForceOrders(server) - registerBinanceFuturesCOINMADLQuantile(server) + registerBinanceFuturesCOINMAccount(server); + registerBinanceFuturesCOINMBalance(server); + registerBinanceFuturesCOINMPositionRisk(server); + registerBinanceFuturesCOINMNewOrder(server); + registerBinanceFuturesCOINMBatchOrders(server); + registerBinanceFuturesCOINMGetOrder(server); + registerBinanceFuturesCOINMCancelOrder(server); + registerBinanceFuturesCOINMCancelAllOrders(server); + registerBinanceFuturesCOINMCancelBatchOrders(server); + registerBinanceFuturesCOINMOpenOrders(server); + registerBinanceFuturesCOINMAllOrders(server); + registerBinanceFuturesCOINMUserTrades(server); + registerBinanceFuturesCOINMIncome(server); + registerBinanceFuturesCOINMLeverage(server); + registerBinanceFuturesCOINMMarginType(server); + registerBinanceFuturesCOINMPositionMargin(server); + registerBinanceFuturesCOINMPositionMode(server); + registerBinanceFuturesCOINMCommissionRate(server); + registerBinanceFuturesCOINMForceOrders(server); + registerBinanceFuturesCOINMADLQuantile(server); // User Data Stream - registerBinanceFuturesCOINMListenKeyCreate(server) - registerBinanceFuturesCOINMListenKeyRenew(server) - registerBinanceFuturesCOINMListenKeyClose(server) + registerBinanceFuturesCOINMListenKeyCreate(server); + registerBinanceFuturesCOINMListenKeyRenew(server); + registerBinanceFuturesCOINMListenKeyClose(server); } diff --git a/src/tools/binance-futures-coinm/indexPriceKlines.ts b/src/tools/binance-futures-coinm/indexPriceKlines.ts index 497a663c..c6702409 100644 --- a/src/tools/binance-futures-coinm/indexPriceKlines.ts +++ b/src/tools/binance-futures-coinm/indexPriceKlines.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/indexPriceKlines.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMIndexPriceKlines(server: McpServer) { server.tool( @@ -36,12 +36,12 @@ export function registerBinanceFuturesCOINMIndexPriceKlines(server: McpServer) { }, async ({ pair, interval, startTime, endTime, limit }) => { try { - const params: any = { pair, interval } - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + const params: any = { pair, interval }; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const data = await deliveryClient.indexPriceKlines(params) + const data = await deliveryClient.indexPriceKlines(params); return { content: [ @@ -50,9 +50,9 @@ export function registerBinanceFuturesCOINMIndexPriceKlines(server: McpServer) { text: `Retrieved ${data.length || 0} index price klines for COIN-M Futures ${pair} with ${interval} interval. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -62,8 +62,8 @@ export function registerBinanceFuturesCOINMIndexPriceKlines(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/klines.ts b/src/tools/binance-futures-coinm/klines.ts index 27e3e605..79045839 100644 --- a/src/tools/binance-futures-coinm/klines.ts +++ b/src/tools/binance-futures-coinm/klines.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/klines.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMKlines(server: McpServer) { server.tool( @@ -36,12 +36,12 @@ export function registerBinanceFuturesCOINMKlines(server: McpServer) { }, async ({ symbol, interval, startTime, endTime, limit }) => { try { - const params: any = { symbol, interval } - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + const params: any = { symbol, interval }; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const data = await deliveryClient.klines(params) + const data = await deliveryClient.klines(params); return { content: [ @@ -50,17 +50,17 @@ export function registerBinanceFuturesCOINMKlines(server: McpServer) { text: `Retrieved ${data.length || 0} klines for COIN-M Futures ${symbol} with ${interval} interval. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve COIN-M Futures klines: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/leverage.ts b/src/tools/binance-futures-coinm/leverage.ts index 7f20581d..c240f986 100644 --- a/src/tools/binance-futures-coinm/leverage.ts +++ b/src/tools/binance-futures-coinm/leverage.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/leverage.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMLeverage(server: McpServer) { server.tool( @@ -20,19 +20,19 @@ export function registerBinanceFuturesCOINMLeverage(server: McpServer) { symbol: params.symbol, leverage: params.leverage, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [{ type: "text", text: `COIN-M leverage changed: ${JSON.stringify(data)}` }], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to change COIN-M leverage: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/listenKey.ts b/src/tools/binance-futures-coinm/listenKey.ts index 2e3f878d..91ea97e1 100644 --- a/src/tools/binance-futures-coinm/listenKey.ts +++ b/src/tools/binance-futures-coinm/listenKey.ts @@ -1,7 +1,7 @@ // src/tools/binance-futures-coinm/listenKey.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMListenKeyCreate(server: McpServer) { server.tool( @@ -10,7 +10,7 @@ export function registerBinanceFuturesCOINMListenKeyCreate(server: McpServer) { {}, async () => { try { - const data = await deliveryClient.createListenKey() + const data = await deliveryClient.createListenKey(); return { content: [ @@ -19,19 +19,19 @@ export function registerBinanceFuturesCOINMListenKeyCreate(server: McpServer) { text: `COIN-M Futures listen key created. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to create COIN-M Futures listen key: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } export function registerBinanceFuturesCOINMListenKeyRenew(server: McpServer) { @@ -41,7 +41,7 @@ export function registerBinanceFuturesCOINMListenKeyRenew(server: McpServer) { {}, async () => { try { - const data = await deliveryClient.keepAliveListenKey() + const data = await deliveryClient.keepAliveListenKey(); return { content: [ @@ -50,19 +50,19 @@ export function registerBinanceFuturesCOINMListenKeyRenew(server: McpServer) { text: `COIN-M Futures listen key renewed. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to renew COIN-M Futures listen key: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } export function registerBinanceFuturesCOINMListenKeyClose(server: McpServer) { @@ -72,7 +72,7 @@ export function registerBinanceFuturesCOINMListenKeyClose(server: McpServer) { {}, async () => { try { - const data = await deliveryClient.closeListenKey() + const data = await deliveryClient.closeListenKey(); return { content: [ @@ -81,17 +81,17 @@ export function registerBinanceFuturesCOINMListenKeyClose(server: McpServer) { text: `COIN-M Futures listen key closed. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to close COIN-M Futures listen key: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/marginType.ts b/src/tools/binance-futures-coinm/marginType.ts index 363e035d..c6482677 100644 --- a/src/tools/binance-futures-coinm/marginType.ts +++ b/src/tools/binance-futures-coinm/marginType.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/marginType.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMMarginType(server: McpServer) { server.tool( @@ -15,7 +15,7 @@ export function registerBinanceFuturesCOINMMarginType(server: McpServer) { }, async ({ symbol, marginType }) => { try { - const data = await deliveryClient.marginType({ symbol, marginType }) + const data = await deliveryClient.marginType({ symbol, marginType }); return { content: [ @@ -24,17 +24,17 @@ export function registerBinanceFuturesCOINMMarginType(server: McpServer) { text: `COIN-M Futures margin type changed to ${marginType} for ${symbol}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to change COIN-M Futures margin type: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/markPriceKlines.ts b/src/tools/binance-futures-coinm/markPriceKlines.ts index 5fbda9c4..bd11c57d 100644 --- a/src/tools/binance-futures-coinm/markPriceKlines.ts +++ b/src/tools/binance-futures-coinm/markPriceKlines.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/markPriceKlines.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMMarkPriceKlines(server: McpServer) { server.tool( @@ -36,12 +36,12 @@ export function registerBinanceFuturesCOINMMarkPriceKlines(server: McpServer) { }, async ({ symbol, interval, startTime, endTime, limit }) => { try { - const params: any = { symbol, interval } - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + const params: any = { symbol, interval }; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const data = await deliveryClient.markPriceKlines(params) + const data = await deliveryClient.markPriceKlines(params); return { content: [ @@ -50,9 +50,9 @@ export function registerBinanceFuturesCOINMMarkPriceKlines(server: McpServer) { text: `Retrieved ${data.length || 0} mark price klines for COIN-M Futures ${symbol} with ${interval} interval. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -62,8 +62,8 @@ export function registerBinanceFuturesCOINMMarkPriceKlines(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/market-api/aggTrades.ts b/src/tools/binance-futures-coinm/market-api/aggTrades.ts index 5a7e9ead..2f9aef26 100644 --- a/src/tools/binance-futures-coinm/market-api/aggTrades.ts +++ b/src/tools/binance-futures-coinm/market-api/aggTrades.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/aggTrades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryAggTrades(server: McpServer) { server.tool( @@ -30,9 +30,9 @@ export function registerBinanceDeliveryAggTrades(server: McpServer) { ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -41,15 +41,15 @@ export function registerBinanceDeliveryAggTrades(server: McpServer) { text: `📊 Aggregate Trades for ${params.symbol}\n\nTrades: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get aggregate trades: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/market-api/bookTicker.ts b/src/tools/binance-futures-coinm/market-api/bookTicker.ts index 2d606de7..9b989efa 100644 --- a/src/tools/binance-futures-coinm/market-api/bookTicker.ts +++ b/src/tools/binance-futures-coinm/market-api/bookTicker.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/bookTicker.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryTickerBookTicker(server: McpServer) { server.tool( @@ -27,9 +27,9 @@ export function registerBinanceDeliveryTickerBookTicker(server: McpServer) { const response = await deliveryClient.restAPI.tickerBookTicker({ ...(params.symbol && { symbol: params.symbol }), ...(params.pair && { pair: params.pair }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -38,15 +38,15 @@ export function registerBinanceDeliveryTickerBookTicker(server: McpServer) { text: `📖 Book Ticker${params.symbol ? ` for ${params.symbol}` : ""}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get book ticker: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/market-api/continuousKlines.ts b/src/tools/binance-futures-coinm/market-api/continuousKlines.ts index 120f00d3..b398e4fd 100644 --- a/src/tools/binance-futures-coinm/market-api/continuousKlines.ts +++ b/src/tools/binance-futures-coinm/market-api/continuousKlines.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/continuousKlines.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryContinuousKlines(server: McpServer) { server.tool( @@ -52,9 +52,9 @@ export function registerBinanceDeliveryContinuousKlines(server: McpServer) { ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -63,15 +63,15 @@ export function registerBinanceDeliveryContinuousKlines(server: McpServer) { text: `🕯️ Continuous Klines for ${params.pair} ${params.contractType} (${params.interval})\n\nCandles: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get continuous klines: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/market-api/depth.ts b/src/tools/binance-futures-coinm/market-api/depth.ts index 5c9dcf8f..2cf2936e 100644 --- a/src/tools/binance-futures-coinm/market-api/depth.ts +++ b/src/tools/binance-futures-coinm/market-api/depth.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/depth.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryDepth(server: McpServer) { server.tool( @@ -28,9 +28,9 @@ export function registerBinanceDeliveryDepth(server: McpServer) { const response = await deliveryClient.restAPI.depth({ symbol: params.symbol, ...(params.limit && { limit: params.limit }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -39,15 +39,15 @@ export function registerBinanceDeliveryDepth(server: McpServer) { text: `📚 Order Book for ${params.symbol}\n\nLast Update ID: ${data.lastUpdateId}\nBids: ${data.bids?.length || 0}\nAsks: ${data.asks?.length || 0}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get order book: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/market-api/exchangeInfo.ts b/src/tools/binance-futures-coinm/market-api/exchangeInfo.ts index 48b5b9c3..630a8a12 100644 --- a/src/tools/binance-futures-coinm/market-api/exchangeInfo.ts +++ b/src/tools/binance-futures-coinm/market-api/exchangeInfo.ts @@ -5,9 +5,9 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/exchangeInfo.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryExchangeInfo(server: McpServer) { server.tool( @@ -16,10 +16,10 @@ export function registerBinanceDeliveryExchangeInfo(server: McpServer) { {}, async () => { try { - const response = await deliveryClient.restAPI.exchangeInfo() - const data = await response.data() + const response = await deliveryClient.restAPI.exchangeInfo(); + const data = await response.data(); - const symbolCount = data.symbols?.length || 0 + const symbolCount = data.symbols?.length || 0; return { content: [ @@ -28,15 +28,15 @@ export function registerBinanceDeliveryExchangeInfo(server: McpServer) { text: `📊 COIN-M Futures Exchange Info\n\nTimezone: ${data.timezone}\nServer Time: ${new Date(data.serverTime).toISOString()}\nTotal Symbols: ${symbolCount}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get exchange info: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/market-api/fundingRate.ts b/src/tools/binance-futures-coinm/market-api/fundingRate.ts index 6f3d66a0..03e8f488 100644 --- a/src/tools/binance-futures-coinm/market-api/fundingRate.ts +++ b/src/tools/binance-futures-coinm/market-api/fundingRate.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/fundingRate.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryFundingRate(server: McpServer) { server.tool( @@ -28,9 +28,9 @@ export function registerBinanceDeliveryFundingRate(server: McpServer) { ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -39,15 +39,15 @@ export function registerBinanceDeliveryFundingRate(server: McpServer) { text: `📊 Funding Rate History for ${params.symbol}\n\nRecords: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get funding rate: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/market-api/historicalTrades.ts b/src/tools/binance-futures-coinm/market-api/historicalTrades.ts index 17d2dd84..5816c6b0 100644 --- a/src/tools/binance-futures-coinm/market-api/historicalTrades.ts +++ b/src/tools/binance-futures-coinm/market-api/historicalTrades.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/historicalTrades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryHistoricalTrades(server: McpServer) { server.tool( @@ -26,9 +26,9 @@ export function registerBinanceDeliveryHistoricalTrades(server: McpServer) { symbol: params.symbol, ...(params.limit && { limit: params.limit }), ...(params.fromId && { fromId: params.fromId }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -37,15 +37,15 @@ export function registerBinanceDeliveryHistoricalTrades(server: McpServer) { text: `📜 Historical Trades for ${params.symbol}\n\nTrades: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get historical trades: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/market-api/index.ts b/src/tools/binance-futures-coinm/market-api/index.ts index 52f41911..0bd4212c 100644 --- a/src/tools/binance-futures-coinm/market-api/index.ts +++ b/src/tools/binance-futures-coinm/market-api/index.ts @@ -5,55 +5,55 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceDeliveryAggTrades } from "./aggTrades.js" -import { registerBinanceDeliveryTickerBookTicker } from "./bookTicker.js" -import { registerBinanceDeliveryContinuousKlines } from "./continuousKlines.js" -import { registerBinanceDeliveryDepth } from "./depth.js" -import { registerBinanceDeliveryExchangeInfo } from "./exchangeInfo.js" -import { registerBinanceDeliveryFundingRate } from "./fundingRate.js" -import { registerBinanceDeliveryHistoricalTrades } from "./historicalTrades.js" -import { registerBinanceDeliveryIndexPriceKlines } from "./indexPriceKlines.js" -import { registerBinanceDeliveryKlines } from "./klines.js" -import { registerBinanceDeliveryMarkPriceKlines } from "./markPriceKlines.js" -import { registerBinanceDeliveryOpenInterest } from "./openInterest.js" -import { registerBinanceDeliveryOpenInterestHist } from "./openInterestHist.js" -import { registerBinanceDeliveryPing } from "./ping.js" -import { registerBinanceDeliveryPremiumIndex } from "./premiumIndex.js" -import { registerBinanceDelivery24hrTicker } from "./ticker24hr.js" -import { registerBinanceDeliveryTickerPrice } from "./tickerPrice.js" -import { registerBinanceDeliveryTime } from "./time.js" -import { registerBinanceDeliveryTrades } from "./trades.js" +import { registerBinanceDeliveryAggTrades } from "./aggTrades.js"; +import { registerBinanceDeliveryTickerBookTicker } from "./bookTicker.js"; +import { registerBinanceDeliveryContinuousKlines } from "./continuousKlines.js"; +import { registerBinanceDeliveryDepth } from "./depth.js"; +import { registerBinanceDeliveryExchangeInfo } from "./exchangeInfo.js"; +import { registerBinanceDeliveryFundingRate } from "./fundingRate.js"; +import { registerBinanceDeliveryHistoricalTrades } from "./historicalTrades.js"; +import { registerBinanceDeliveryIndexPriceKlines } from "./indexPriceKlines.js"; +import { registerBinanceDeliveryKlines } from "./klines.js"; +import { registerBinanceDeliveryMarkPriceKlines } from "./markPriceKlines.js"; +import { registerBinanceDeliveryOpenInterest } from "./openInterest.js"; +import { registerBinanceDeliveryOpenInterestHist } from "./openInterestHist.js"; +import { registerBinanceDeliveryPing } from "./ping.js"; +import { registerBinanceDeliveryPremiumIndex } from "./premiumIndex.js"; +import { registerBinanceDelivery24hrTicker } from "./ticker24hr.js"; +import { registerBinanceDeliveryTickerPrice } from "./tickerPrice.js"; +import { registerBinanceDeliveryTime } from "./time.js"; +import { registerBinanceDeliveryTrades } from "./trades.js"; export function registerBinanceDeliveryMarketApiTools(server: McpServer) { // System Status - registerBinanceDeliveryPing(server) - registerBinanceDeliveryTime(server) - registerBinanceDeliveryExchangeInfo(server) + registerBinanceDeliveryPing(server); + registerBinanceDeliveryTime(server); + registerBinanceDeliveryExchangeInfo(server); // Order Book & Trades - registerBinanceDeliveryDepth(server) - registerBinanceDeliveryTrades(server) - registerBinanceDeliveryHistoricalTrades(server) - registerBinanceDeliveryAggTrades(server) + registerBinanceDeliveryDepth(server); + registerBinanceDeliveryTrades(server); + registerBinanceDeliveryHistoricalTrades(server); + registerBinanceDeliveryAggTrades(server); // Klines/Candlesticks - registerBinanceDeliveryKlines(server) - registerBinanceDeliveryContinuousKlines(server) - registerBinanceDeliveryIndexPriceKlines(server) - registerBinanceDeliveryMarkPriceKlines(server) + registerBinanceDeliveryKlines(server); + registerBinanceDeliveryContinuousKlines(server); + registerBinanceDeliveryIndexPriceKlines(server); + registerBinanceDeliveryMarkPriceKlines(server); // Pricing & Funding - registerBinanceDeliveryPremiumIndex(server) - registerBinanceDeliveryFundingRate(server) + registerBinanceDeliveryPremiumIndex(server); + registerBinanceDeliveryFundingRate(server); // Tickers - registerBinanceDelivery24hrTicker(server) - registerBinanceDeliveryTickerPrice(server) - registerBinanceDeliveryTickerBookTicker(server) + registerBinanceDelivery24hrTicker(server); + registerBinanceDeliveryTickerPrice(server); + registerBinanceDeliveryTickerBookTicker(server); // Open Interest - registerBinanceDeliveryOpenInterest(server) - registerBinanceDeliveryOpenInterestHist(server) + registerBinanceDeliveryOpenInterest(server); + registerBinanceDeliveryOpenInterestHist(server); } diff --git a/src/tools/binance-futures-coinm/market-api/indexPriceKlines.ts b/src/tools/binance-futures-coinm/market-api/indexPriceKlines.ts index c30a4096..3f41d979 100644 --- a/src/tools/binance-futures-coinm/market-api/indexPriceKlines.ts +++ b/src/tools/binance-futures-coinm/market-api/indexPriceKlines.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/indexPriceKlines.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryIndexPriceKlines(server: McpServer) { server.tool( @@ -48,9 +48,9 @@ export function registerBinanceDeliveryIndexPriceKlines(server: McpServer) { ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -59,15 +59,15 @@ export function registerBinanceDeliveryIndexPriceKlines(server: McpServer) { text: `📈 Index Price Klines for ${params.pair} (${params.interval})\n\nCandles: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get index price klines: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/market-api/klines.ts b/src/tools/binance-futures-coinm/market-api/klines.ts index 9697cf30..bbb624fb 100644 --- a/src/tools/binance-futures-coinm/market-api/klines.ts +++ b/src/tools/binance-futures-coinm/market-api/klines.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/klines.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryKlines(server: McpServer) { server.tool( @@ -48,9 +48,9 @@ export function registerBinanceDeliveryKlines(server: McpServer) { ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -59,15 +59,15 @@ export function registerBinanceDeliveryKlines(server: McpServer) { text: `🕯️ Klines for ${params.symbol} (${params.interval})\n\nCandles: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get klines: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/market-api/markPriceKlines.ts b/src/tools/binance-futures-coinm/market-api/markPriceKlines.ts index 96051698..99b460dc 100644 --- a/src/tools/binance-futures-coinm/market-api/markPriceKlines.ts +++ b/src/tools/binance-futures-coinm/market-api/markPriceKlines.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/markPriceKlines.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryMarkPriceKlines(server: McpServer) { server.tool( @@ -48,9 +48,9 @@ export function registerBinanceDeliveryMarkPriceKlines(server: McpServer) { ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -59,15 +59,15 @@ export function registerBinanceDeliveryMarkPriceKlines(server: McpServer) { text: `📊 Mark Price Klines for ${params.symbol} (${params.interval})\n\nCandles: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get mark price klines: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/market-api/openInterest.ts b/src/tools/binance-futures-coinm/market-api/openInterest.ts index 1e93ca2f..290e0ff5 100644 --- a/src/tools/binance-futures-coinm/market-api/openInterest.ts +++ b/src/tools/binance-futures-coinm/market-api/openInterest.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/openInterest.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryOpenInterest(server: McpServer) { server.tool( @@ -22,9 +22,9 @@ export function registerBinanceDeliveryOpenInterest(server: McpServer) { try { const response = await deliveryClient.restAPI.openInterest({ symbol: params.symbol, - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -33,15 +33,15 @@ export function registerBinanceDeliveryOpenInterest(server: McpServer) { text: `📊 Open Interest for ${params.symbol}\n\nOpen Interest: ${data.openInterest}\nSymbol: ${data.symbol}\nPair: ${data.pair}\nContract Type: ${data.contractType}\nTime: ${new Date(data.time).toISOString()}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get open interest: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/market-api/openInterestHist.ts b/src/tools/binance-futures-coinm/market-api/openInterestHist.ts index c990fa0a..943250f9 100644 --- a/src/tools/binance-futures-coinm/market-api/openInterestHist.ts +++ b/src/tools/binance-futures-coinm/market-api/openInterestHist.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/openInterestHist.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryOpenInterestHist(server: McpServer) { server.tool( @@ -36,9 +36,9 @@ export function registerBinanceDeliveryOpenInterestHist(server: McpServer) { ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -47,17 +47,17 @@ export function registerBinanceDeliveryOpenInterestHist(server: McpServer) { text: `📈 Historical Open Interest for ${params.pair} ${params.contractType}\n\nPeriod: ${params.period}\nRecords: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `❌ Failed to get open interest history: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/market-api/ping.ts b/src/tools/binance-futures-coinm/market-api/ping.ts index 9c9c0271..5bbc1956 100644 --- a/src/tools/binance-futures-coinm/market-api/ping.ts +++ b/src/tools/binance-futures-coinm/market-api/ping.ts @@ -5,9 +5,9 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/ping.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryPing(server: McpServer) { server.tool( @@ -16,8 +16,8 @@ export function registerBinanceDeliveryPing(server: McpServer) { {}, async () => { try { - const response = await deliveryClient.restAPI.ping() - const data = await response.data() + const response = await deliveryClient.restAPI.ping(); + const data = await response.data(); return { content: [ @@ -26,15 +26,15 @@ export function registerBinanceDeliveryPing(server: McpServer) { text: `✅ COIN-M Futures API is reachable\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ COIN-M Futures API ping failed: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/market-api/premiumIndex.ts b/src/tools/binance-futures-coinm/market-api/premiumIndex.ts index 4c42b9ee..cce3c788 100644 --- a/src/tools/binance-futures-coinm/market-api/premiumIndex.ts +++ b/src/tools/binance-futures-coinm/market-api/premiumIndex.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/premiumIndex.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryPremiumIndex(server: McpServer) { server.tool( @@ -25,9 +25,9 @@ export function registerBinanceDeliveryPremiumIndex(server: McpServer) { try { const response = await deliveryClient.restAPI.premiumIndex({ ...(params.symbol && { symbol: params.symbol }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -36,15 +36,15 @@ export function registerBinanceDeliveryPremiumIndex(server: McpServer) { text: `💰 Premium Index${params.symbol ? ` for ${params.symbol}` : ""}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get premium index: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/market-api/ticker24hr.ts b/src/tools/binance-futures-coinm/market-api/ticker24hr.ts index a1b1d705..7fe99e89 100644 --- a/src/tools/binance-futures-coinm/market-api/ticker24hr.ts +++ b/src/tools/binance-futures-coinm/market-api/ticker24hr.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/ticker24hr.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDelivery24hrTicker(server: McpServer) { server.tool( @@ -27,9 +27,9 @@ export function registerBinanceDelivery24hrTicker(server: McpServer) { const response = await deliveryClient.restAPI.ticker24hr({ ...(params.symbol && { symbol: params.symbol }), ...(params.pair && { pair: params.pair }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -38,15 +38,15 @@ export function registerBinanceDelivery24hrTicker(server: McpServer) { text: `📊 24hr Ticker${params.symbol ? ` for ${params.symbol}` : ""}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get 24hr ticker: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/market-api/tickerPrice.ts b/src/tools/binance-futures-coinm/market-api/tickerPrice.ts index 26531c32..3b24c079 100644 --- a/src/tools/binance-futures-coinm/market-api/tickerPrice.ts +++ b/src/tools/binance-futures-coinm/market-api/tickerPrice.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/tickerPrice.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryTickerPrice(server: McpServer) { server.tool( @@ -27,9 +27,9 @@ export function registerBinanceDeliveryTickerPrice(server: McpServer) { const response = await deliveryClient.restAPI.tickerPrice({ ...(params.symbol && { symbol: params.symbol }), ...(params.pair && { pair: params.pair }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -38,15 +38,15 @@ export function registerBinanceDeliveryTickerPrice(server: McpServer) { text: `💰 Symbol Price${params.symbol ? ` for ${params.symbol}` : ""}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get ticker price: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/market-api/time.ts b/src/tools/binance-futures-coinm/market-api/time.ts index 343bb9b1..92630a21 100644 --- a/src/tools/binance-futures-coinm/market-api/time.ts +++ b/src/tools/binance-futures-coinm/market-api/time.ts @@ -5,9 +5,9 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/time.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryTime(server: McpServer) { server.tool( @@ -16,8 +16,8 @@ export function registerBinanceDeliveryTime(server: McpServer) { {}, async () => { try { - const response = await deliveryClient.restAPI.time() - const data = await response.data() + const response = await deliveryClient.restAPI.time(); + const data = await response.data(); return { content: [ @@ -26,15 +26,15 @@ export function registerBinanceDeliveryTime(server: McpServer) { text: `🕐 COIN-M Futures Server Time\n\nTimestamp: ${data.serverTime}\nDate: ${new Date(data.serverTime).toISOString()}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get server time: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/market-api/trades.ts b/src/tools/binance-futures-coinm/market-api/trades.ts index c0920643..16749900 100644 --- a/src/tools/binance-futures-coinm/market-api/trades.ts +++ b/src/tools/binance-futures-coinm/market-api/trades.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/market-api/trades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryTrades(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerBinanceDeliveryTrades(server: McpServer) { const response = await deliveryClient.restAPI.trades({ symbol: params.symbol, ...(params.limit && { limit: params.limit }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,15 +35,15 @@ export function registerBinanceDeliveryTrades(server: McpServer) { text: `📈 Recent Trades for ${params.symbol}\n\nTrades: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get trades: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/newOrder.ts b/src/tools/binance-futures-coinm/newOrder.ts index b3072263..0a5a6003 100644 --- a/src/tools/binance-futures-coinm/newOrder.ts +++ b/src/tools/binance-futures-coinm/newOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/newOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMNewOrder(server: McpServer) { server.tool( @@ -49,19 +49,19 @@ export function registerBinanceFuturesCOINMNewOrder(server: McpServer) { ...(params.reduceOnly !== undefined && { reduceOnly: params.reduceOnly }), ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [{ type: "text", text: `COIN-M order placed: ${JSON.stringify(data)}` }], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to place COIN-M order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/openInterest.ts b/src/tools/binance-futures-coinm/openInterest.ts index 8b48a784..f45a384a 100644 --- a/src/tools/binance-futures-coinm/openInterest.ts +++ b/src/tools/binance-futures-coinm/openInterest.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/openInterest.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMOpenInterest(server: McpServer) { server.tool( @@ -14,7 +14,7 @@ export function registerBinanceFuturesCOINMOpenInterest(server: McpServer) { }, async ({ symbol }) => { try { - const data = await deliveryClient.openInterest({ symbol }) + const data = await deliveryClient.openInterest({ symbol }); return { content: [ @@ -23,9 +23,9 @@ export function registerBinanceFuturesCOINMOpenInterest(server: McpServer) { text: `Retrieved COIN-M Futures open interest for ${symbol}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -35,8 +35,8 @@ export function registerBinanceFuturesCOINMOpenInterest(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/openOrders.ts b/src/tools/binance-futures-coinm/openOrders.ts index 63ca65bd..c6b39009 100644 --- a/src/tools/binance-futures-coinm/openOrders.ts +++ b/src/tools/binance-futures-coinm/openOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/openOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMOpenOrders(server: McpServer) { server.tool( @@ -20,19 +20,19 @@ export function registerBinanceFuturesCOINMOpenOrders(server: McpServer) { ...(params.symbol && { symbol: params.symbol }), ...(params.pair && { pair: params.pair }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [{ type: "text", text: `COIN-M open orders: ${JSON.stringify(data)}` }], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get COIN-M open orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/ping.ts b/src/tools/binance-futures-coinm/ping.ts index 6addb900..3b09dedc 100644 --- a/src/tools/binance-futures-coinm/ping.ts +++ b/src/tools/binance-futures-coinm/ping.ts @@ -1,7 +1,7 @@ // src/tools/binance-futures-coinm/ping.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMPing(server: McpServer) { server.tool( @@ -10,7 +10,7 @@ export function registerBinanceFuturesCOINMPing(server: McpServer) { {}, async () => { try { - const data = await deliveryClient.ping() + const data = await deliveryClient.ping(); return { content: [ @@ -19,15 +19,15 @@ export function registerBinanceFuturesCOINMPing(server: McpServer) { text: `COIN-M Futures API connectivity test successful. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to ping COIN-M Futures API: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/positionMargin.ts b/src/tools/binance-futures-coinm/positionMargin.ts index e7207502..1c65b698 100644 --- a/src/tools/binance-futures-coinm/positionMargin.ts +++ b/src/tools/binance-futures-coinm/positionMargin.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/positionMargin.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMPositionMargin(server: McpServer) { server.tool( @@ -20,10 +20,10 @@ export function registerBinanceFuturesCOINMPositionMargin(server: McpServer) { }, async ({ symbol, positionSide, amount, type }) => { try { - const params: any = { symbol, amount, type } - if (positionSide) params.positionSide = positionSide + const params: any = { symbol, amount, type }; + if (positionSide) params.positionSide = positionSide; - const data = await deliveryClient.positionMargin(params) + const data = await deliveryClient.positionMargin(params); return { content: [ @@ -32,9 +32,9 @@ export function registerBinanceFuturesCOINMPositionMargin(server: McpServer) { text: `COIN-M Futures position margin modified for ${symbol}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -44,8 +44,8 @@ export function registerBinanceFuturesCOINMPositionMargin(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/positionMode.ts b/src/tools/binance-futures-coinm/positionMode.ts index 8b0c5d12..3c0eaa1d 100644 --- a/src/tools/binance-futures-coinm/positionMode.ts +++ b/src/tools/binance-futures-coinm/positionMode.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/positionMode.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMPositionMode(server: McpServer) { server.tool( @@ -16,7 +16,7 @@ export function registerBinanceFuturesCOINMPositionMode(server: McpServer) { try { const data = await deliveryClient.positionSideDual({ dualSidePosition: dualSidePosition ? "true" : "false", - }) + }); return { content: [ @@ -25,9 +25,9 @@ export function registerBinanceFuturesCOINMPositionMode(server: McpServer) { text: `COIN-M Futures position mode changed to ${dualSidePosition ? "Hedge Mode" : "One-way Mode"}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -37,8 +37,8 @@ export function registerBinanceFuturesCOINMPositionMode(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/positionRisk.ts b/src/tools/binance-futures-coinm/positionRisk.ts index bc262749..7184eddd 100644 --- a/src/tools/binance-futures-coinm/positionRisk.ts +++ b/src/tools/binance-futures-coinm/positionRisk.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/positionRisk.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMPositionRisk(server: McpServer) { server.tool( @@ -20,19 +20,19 @@ export function registerBinanceFuturesCOINMPositionRisk(server: McpServer) { ...(params.marginAsset && { marginAsset: params.marginAsset }), ...(params.pair && { pair: params.pair }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [{ type: "text", text: `COIN-M position risk: ${JSON.stringify(data)}` }], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get COIN-M position risk: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/premiumIndex.ts b/src/tools/binance-futures-coinm/premiumIndex.ts index 5f364ec1..1060f03b 100644 --- a/src/tools/binance-futures-coinm/premiumIndex.ts +++ b/src/tools/binance-futures-coinm/premiumIndex.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/premiumIndex.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMPremiumIndex(server: McpServer) { server.tool( @@ -19,10 +19,10 @@ export function registerBinanceFuturesCOINMPremiumIndex(server: McpServer) { }, async ({ symbol }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol + const params: any = {}; + if (symbol) params.symbol = symbol; - const data = await deliveryClient.premiumIndex(params) + const data = await deliveryClient.premiumIndex(params); return { content: [ @@ -31,9 +31,9 @@ export function registerBinanceFuturesCOINMPremiumIndex(server: McpServer) { text: `Retrieved COIN-M Futures premium index${symbol ? ` for ${symbol}` : " for all symbols"}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -43,8 +43,8 @@ export function registerBinanceFuturesCOINMPremiumIndex(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/ticker24hr.ts b/src/tools/binance-futures-coinm/ticker24hr.ts index d830e387..8a7cd21d 100644 --- a/src/tools/binance-futures-coinm/ticker24hr.ts +++ b/src/tools/binance-futures-coinm/ticker24hr.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/ticker24hr.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMTicker24hr(server: McpServer) { server.tool( @@ -20,11 +20,11 @@ export function registerBinanceFuturesCOINMTicker24hr(server: McpServer) { }, async ({ symbol, pair }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol - if (pair) params.pair = pair + const params: any = {}; + if (symbol) params.symbol = symbol; + if (pair) params.pair = pair; - const data = await deliveryClient.ticker24hr(params) + const data = await deliveryClient.ticker24hr(params); return { content: [ @@ -33,9 +33,9 @@ export function registerBinanceFuturesCOINMTicker24hr(server: McpServer) { text: `Retrieved COIN-M Futures 24hr ticker${symbol ? ` for ${symbol}` : pair ? ` for pair ${pair}` : " for all symbols"}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -45,8 +45,8 @@ export function registerBinanceFuturesCOINMTicker24hr(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/tickerPrice.ts b/src/tools/binance-futures-coinm/tickerPrice.ts index 03c01a1c..c1b2ebd3 100644 --- a/src/tools/binance-futures-coinm/tickerPrice.ts +++ b/src/tools/binance-futures-coinm/tickerPrice.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/tickerPrice.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMTickerPrice(server: McpServer) { server.tool( @@ -20,11 +20,11 @@ export function registerBinanceFuturesCOINMTickerPrice(server: McpServer) { }, async ({ symbol, pair }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol - if (pair) params.pair = pair + const params: any = {}; + if (symbol) params.symbol = symbol; + if (pair) params.pair = pair; - const data = await deliveryClient.tickerPrice(params) + const data = await deliveryClient.tickerPrice(params); return { content: [ @@ -33,9 +33,9 @@ export function registerBinanceFuturesCOINMTickerPrice(server: McpServer) { text: `Retrieved COIN-M Futures ticker price${symbol ? ` for ${symbol}` : pair ? ` for pair ${pair}` : " for all symbols"}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -45,8 +45,8 @@ export function registerBinanceFuturesCOINMTickerPrice(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/time.ts b/src/tools/binance-futures-coinm/time.ts index 8d1c16b2..81d2473a 100644 --- a/src/tools/binance-futures-coinm/time.ts +++ b/src/tools/binance-futures-coinm/time.ts @@ -1,7 +1,7 @@ // src/tools/binance-futures-coinm/time.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMTime(server: McpServer) { server.tool( @@ -10,7 +10,7 @@ export function registerBinanceFuturesCOINMTime(server: McpServer) { {}, async () => { try { - const data = await deliveryClient.time() + const data = await deliveryClient.time(); return { content: [ @@ -19,17 +19,17 @@ export function registerBinanceFuturesCOINMTime(server: McpServer) { text: `COIN-M Futures server time: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to get COIN-M Futures server time: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/trade-api/allOrders.ts b/src/tools/binance-futures-coinm/trade-api/allOrders.ts index 90d45eb8..a259db70 100644 --- a/src/tools/binance-futures-coinm/trade-api/allOrders.ts +++ b/src/tools/binance-futures-coinm/trade-api/allOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/allOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryAllOrders(server: McpServer) { server.tool( @@ -34,9 +34,9 @@ export function registerBinanceDeliveryAllOrders(server: McpServer) { ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -45,15 +45,15 @@ export function registerBinanceDeliveryAllOrders(server: McpServer) { text: `📋 All Orders\n\nCount: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get all orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/trade-api/batchOrders.ts b/src/tools/binance-futures-coinm/trade-api/batchOrders.ts index 5624e0b5..3fb6dc04 100644 --- a/src/tools/binance-futures-coinm/trade-api/batchOrders.ts +++ b/src/tools/binance-futures-coinm/trade-api/batchOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/batchOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryBatchOrders(server: McpServer) { server.tool( @@ -22,17 +22,17 @@ export function registerBinanceDeliveryBatchOrders(server: McpServer) { }, async (params) => { try { - const orders = JSON.parse(params.batchOrders) + const orders = JSON.parse(params.batchOrders); if (!Array.isArray(orders) || orders.length === 0 || orders.length > 5) { return { content: [{ type: "text", text: "Error: batchOrders must be an array of 1-5 orders" }], isError: true, - } + }; } - const response = await deliveryClient.restAPI.placeMultipleOrders({ batchOrders: orders }) - const data = await response.data() + const response = await deliveryClient.restAPI.placeMultipleOrders({ batchOrders: orders }); + const data = await response.data(); return { content: [ @@ -41,15 +41,15 @@ export function registerBinanceDeliveryBatchOrders(server: McpServer) { text: `✅ Batch orders placed!\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to place batch orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/trade-api/cancelAllOrders.ts b/src/tools/binance-futures-coinm/trade-api/cancelAllOrders.ts index 0a88ca52..b14a3436 100644 --- a/src/tools/binance-futures-coinm/trade-api/cancelAllOrders.ts +++ b/src/tools/binance-futures-coinm/trade-api/cancelAllOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/cancelAllOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryCancelAllOrders(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerBinanceDeliveryCancelAllOrders(server: McpServer) { const response = await deliveryClient.restAPI.cancelAllOpenOrders({ symbol: params.symbol, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,15 +35,15 @@ export function registerBinanceDeliveryCancelAllOrders(server: McpServer) { text: `✅ All orders cancelled for ${params.symbol}!\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to cancel all orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/trade-api/cancelBatchOrders.ts b/src/tools/binance-futures-coinm/trade-api/cancelBatchOrders.ts index 45a3f521..53051595 100644 --- a/src/tools/binance-futures-coinm/trade-api/cancelBatchOrders.ts +++ b/src/tools/binance-futures-coinm/trade-api/cancelBatchOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/cancelBatchOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryCancelBatchOrders(server: McpServer) { server.tool( @@ -32,7 +32,7 @@ export function registerBinanceDeliveryCancelBatchOrders(server: McpServer) { }, ], isError: true, - } + }; } const response = await deliveryClient.restAPI.cancelMultipleOrders({ @@ -42,9 +42,9 @@ export function registerBinanceDeliveryCancelBatchOrders(server: McpServer) { origClientOrderIdList: JSON.parse(params.origClientOrderIdList), }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -53,15 +53,15 @@ export function registerBinanceDeliveryCancelBatchOrders(server: McpServer) { text: `✅ Batch orders cancelled!\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to cancel batch orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/trade-api/cancelOrder.ts b/src/tools/binance-futures-coinm/trade-api/cancelOrder.ts index 2afba823..9a272fa1 100644 --- a/src/tools/binance-futures-coinm/trade-api/cancelOrder.ts +++ b/src/tools/binance-futures-coinm/trade-api/cancelOrder.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/cancelOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryCancelOrder(server: McpServer) { server.tool( @@ -29,7 +29,7 @@ export function registerBinanceDeliveryCancelOrder(server: McpServer) { { type: "text", text: "Error: Either orderId or origClientOrderId must be provided" }, ], isError: true, - } + }; } const response = await deliveryClient.restAPI.cancelOrder({ @@ -37,9 +37,9 @@ export function registerBinanceDeliveryCancelOrder(server: McpServer) { ...(params.orderId && { orderId: params.orderId }), ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -48,15 +48,15 @@ export function registerBinanceDeliveryCancelOrder(server: McpServer) { text: `✅ Order cancelled!\n\nSymbol: ${data.symbol}\nOrder ID: ${data.orderId}\nStatus: ${data.status}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to cancel order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/trade-api/changeLeverage.ts b/src/tools/binance-futures-coinm/trade-api/changeLeverage.ts index e8bd17c3..1886851c 100644 --- a/src/tools/binance-futures-coinm/trade-api/changeLeverage.ts +++ b/src/tools/binance-futures-coinm/trade-api/changeLeverage.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/changeLeverage.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryChangeLeverage(server: McpServer) { server.tool( @@ -26,9 +26,9 @@ export function registerBinanceDeliveryChangeLeverage(server: McpServer) { symbol: params.symbol, leverage: params.leverage, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -37,15 +37,15 @@ export function registerBinanceDeliveryChangeLeverage(server: McpServer) { text: `✅ Leverage changed!\n\nSymbol: ${data.symbol}\nNew Leverage: ${data.leverage}x\nMax Notional: ${data.maxQty}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to change leverage: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/trade-api/changeMarginType.ts b/src/tools/binance-futures-coinm/trade-api/changeMarginType.ts index b79152ed..e29dda85 100644 --- a/src/tools/binance-futures-coinm/trade-api/changeMarginType.ts +++ b/src/tools/binance-futures-coinm/trade-api/changeMarginType.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/changeMarginType.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryChangeMarginType(server: McpServer) { server.tool( @@ -26,9 +26,9 @@ export function registerBinanceDeliveryChangeMarginType(server: McpServer) { symbol: params.symbol, marginType: params.marginType, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -37,15 +37,15 @@ export function registerBinanceDeliveryChangeMarginType(server: McpServer) { text: `✅ Margin type changed to ${params.marginType}!\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to change margin type: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/trade-api/changePositionMode.ts b/src/tools/binance-futures-coinm/trade-api/changePositionMode.ts index 815f88fe..fb6e6bb0 100644 --- a/src/tools/binance-futures-coinm/trade-api/changePositionMode.ts +++ b/src/tools/binance-futures-coinm/trade-api/changePositionMode.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/changePositionMode.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryChangePositionMode(server: McpServer) { server.tool( @@ -24,10 +24,10 @@ export function registerBinanceDeliveryChangePositionMode(server: McpServer) { const response = await deliveryClient.restAPI.changePositionMode({ dualSidePosition: params.dualSidePosition, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() - const mode = params.dualSidePosition ? "Hedge Mode" : "One-way Mode" + const data = await response.data(); + const mode = params.dualSidePosition ? "Hedge Mode" : "One-way Mode"; return { content: [ @@ -36,15 +36,15 @@ export function registerBinanceDeliveryChangePositionMode(server: McpServer) { text: `✅ Position mode changed to ${mode}!\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to change position mode: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/trade-api/countdownCancelAll.ts b/src/tools/binance-futures-coinm/trade-api/countdownCancelAll.ts index 2e395230..e28d29c9 100644 --- a/src/tools/binance-futures-coinm/trade-api/countdownCancelAll.ts +++ b/src/tools/binance-futures-coinm/trade-api/countdownCancelAll.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/countdownCancelAll.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryCountdownCancelAll(server: McpServer) { server.tool( @@ -26,9 +26,9 @@ export function registerBinanceDeliveryCountdownCancelAll(server: McpServer) { symbol: params.symbol, countdownTime: params.countdownTime, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -40,15 +40,15 @@ export function registerBinanceDeliveryCountdownCancelAll(server: McpServer) { : `⏱️ Countdown set! Orders will cancel in ${params.countdownTime / 1000}s\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to set countdown: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/trade-api/getAllOrders.ts b/src/tools/binance-futures-coinm/trade-api/getAllOrders.ts index 4e58c48f..f215e351 100644 --- a/src/tools/binance-futures-coinm/trade-api/getAllOrders.ts +++ b/src/tools/binance-futures-coinm/trade-api/getAllOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/getAllOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryGetAllOrders(server: McpServer) { server.tool( @@ -34,10 +34,10 @@ export function registerBinanceDeliveryGetAllOrders(server: McpServer) { ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() - const orders = Array.isArray(data) ? data : [data] + const data = await response.data(); + const orders = Array.isArray(data) ? data : [data]; const summary = orders .slice(0, 10) @@ -45,7 +45,7 @@ export function registerBinanceDeliveryGetAllOrders(server: McpServer) { (o: any) => `${o.symbol}: ${o.side} ${o.type} ${o.origQty} @ ${o.price || "MARKET"} - ${o.status}`, ) - .join("\n") + .join("\n"); return { content: [ @@ -54,15 +54,15 @@ export function registerBinanceDeliveryGetAllOrders(server: McpServer) { text: `📋 All Orders for ${params.symbol} (${orders.length} total)\n\n${summary}\n\nFull data: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get all orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/trade-api/getOrder.ts b/src/tools/binance-futures-coinm/trade-api/getOrder.ts index 6f57e367..545835b3 100644 --- a/src/tools/binance-futures-coinm/trade-api/getOrder.ts +++ b/src/tools/binance-futures-coinm/trade-api/getOrder.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/getOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryGetOrder(server: McpServer) { server.tool( @@ -29,7 +29,7 @@ export function registerBinanceDeliveryGetOrder(server: McpServer) { { type: "text", text: "Error: Either orderId or origClientOrderId must be provided" }, ], isError: true, - } + }; } const response = await deliveryClient.restAPI.queryOrder({ @@ -37,9 +37,9 @@ export function registerBinanceDeliveryGetOrder(server: McpServer) { ...(params.orderId && { orderId: params.orderId }), ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -48,15 +48,15 @@ export function registerBinanceDeliveryGetOrder(server: McpServer) { text: `📋 Order Details\n\nSymbol: ${data.symbol}\nOrder ID: ${data.orderId}\nStatus: ${data.status}\nSide: ${data.side}\nType: ${data.type}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/trade-api/index.ts b/src/tools/binance-futures-coinm/trade-api/index.ts index 773fe2e2..64d4ac47 100644 --- a/src/tools/binance-futures-coinm/trade-api/index.ts +++ b/src/tools/binance-futures-coinm/trade-api/index.ts @@ -5,45 +5,45 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceDeliveryAllOrders } from "./allOrders.js" -import { registerBinanceDeliveryBatchOrders } from "./batchOrders.js" -import { registerBinanceDeliveryCancelAllOrders } from "./cancelAllOrders.js" -import { registerBinanceDeliveryCancelBatchOrders } from "./cancelBatchOrders.js" -import { registerBinanceDeliveryCancelOrder } from "./cancelOrder.js" -import { registerBinanceDeliveryChangeLeverage } from "./changeLeverage.js" -import { registerBinanceDeliveryChangeMarginType } from "./changeMarginType.js" -import { registerBinanceDeliveryChangePositionMode } from "./changePositionMode.js" -import { registerBinanceDeliveryCountdownCancelAll } from "./countdownCancelAll.js" -import { registerBinanceDeliveryGetOrder } from "./getOrder.js" -import { registerBinanceDeliveryModifyIsolatedPositionMargin } from "./modifyIsolatedPositionMargin.js" -import { registerBinanceDeliveryNewOrder } from "./newOrder.js" -import { registerBinanceDeliveryOpenOrder } from "./openOrder.js" -import { registerBinanceDeliveryOpenOrders } from "./openOrders.js" +import { registerBinanceDeliveryAllOrders } from "./allOrders.js"; +import { registerBinanceDeliveryBatchOrders } from "./batchOrders.js"; +import { registerBinanceDeliveryCancelAllOrders } from "./cancelAllOrders.js"; +import { registerBinanceDeliveryCancelBatchOrders } from "./cancelBatchOrders.js"; +import { registerBinanceDeliveryCancelOrder } from "./cancelOrder.js"; +import { registerBinanceDeliveryChangeLeverage } from "./changeLeverage.js"; +import { registerBinanceDeliveryChangeMarginType } from "./changeMarginType.js"; +import { registerBinanceDeliveryChangePositionMode } from "./changePositionMode.js"; +import { registerBinanceDeliveryCountdownCancelAll } from "./countdownCancelAll.js"; +import { registerBinanceDeliveryGetOrder } from "./getOrder.js"; +import { registerBinanceDeliveryModifyIsolatedPositionMargin } from "./modifyIsolatedPositionMargin.js"; +import { registerBinanceDeliveryNewOrder } from "./newOrder.js"; +import { registerBinanceDeliveryOpenOrder } from "./openOrder.js"; +import { registerBinanceDeliveryOpenOrders } from "./openOrders.js"; export function registerBinanceDeliveryTradeApiTools(server: McpServer) { // Order Placement - registerBinanceDeliveryNewOrder(server) - registerBinanceDeliveryBatchOrders(server) + registerBinanceDeliveryNewOrder(server); + registerBinanceDeliveryBatchOrders(server); // Order Query - registerBinanceDeliveryGetOrder(server) - registerBinanceDeliveryOpenOrder(server) - registerBinanceDeliveryOpenOrders(server) - registerBinanceDeliveryAllOrders(server) + registerBinanceDeliveryGetOrder(server); + registerBinanceDeliveryOpenOrder(server); + registerBinanceDeliveryOpenOrders(server); + registerBinanceDeliveryAllOrders(server); // Order Cancellation - registerBinanceDeliveryCancelOrder(server) - registerBinanceDeliveryCancelAllOrders(server) - registerBinanceDeliveryCancelBatchOrders(server) - registerBinanceDeliveryCountdownCancelAll(server) + registerBinanceDeliveryCancelOrder(server); + registerBinanceDeliveryCancelAllOrders(server); + registerBinanceDeliveryCancelBatchOrders(server); + registerBinanceDeliveryCountdownCancelAll(server); // Leverage & Margin - registerBinanceDeliveryChangeLeverage(server) - registerBinanceDeliveryChangeMarginType(server) - registerBinanceDeliveryModifyIsolatedPositionMargin(server) + registerBinanceDeliveryChangeLeverage(server); + registerBinanceDeliveryChangeMarginType(server); + registerBinanceDeliveryModifyIsolatedPositionMargin(server); // Position Mode - registerBinanceDeliveryChangePositionMode(server) + registerBinanceDeliveryChangePositionMode(server); } diff --git a/src/tools/binance-futures-coinm/trade-api/modifyIsolatedPositionMargin.ts b/src/tools/binance-futures-coinm/trade-api/modifyIsolatedPositionMargin.ts index ecb4aa7c..24c263cf 100644 --- a/src/tools/binance-futures-coinm/trade-api/modifyIsolatedPositionMargin.ts +++ b/src/tools/binance-futures-coinm/trade-api/modifyIsolatedPositionMargin.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/modifyIsolatedPositionMargin.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryModifyIsolatedPositionMargin(server: McpServer) { server.tool( @@ -33,10 +33,10 @@ export function registerBinanceDeliveryModifyIsolatedPositionMargin(server: McpS type: parseInt(params.type) as 1 | 2, ...(params.positionSide && { positionSide: params.positionSide }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() - const action = params.type === "1" ? "added to" : "reduced from" + const data = await response.data(); + const action = params.type === "1" ? "added to" : "reduced from"; return { content: [ @@ -45,15 +45,15 @@ export function registerBinanceDeliveryModifyIsolatedPositionMargin(server: McpS text: `✅ Margin ${action} position!\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to modify position margin: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/trade-api/newOrder.ts b/src/tools/binance-futures-coinm/trade-api/newOrder.ts index 3198b378..90281ec8 100644 --- a/src/tools/binance-futures-coinm/trade-api/newOrder.ts +++ b/src/tools/binance-futures-coinm/trade-api/newOrder.ts @@ -1,8 +1,8 @@ -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryNewOrder(server: McpServer) { server.tool( @@ -66,9 +66,9 @@ export function registerBinanceDeliveryNewOrder(server: McpServer) { ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), ...(params.newOrderRespType && { newOrderRespType: params.newOrderRespType }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -77,9 +77,9 @@ export function registerBinanceDeliveryNewOrder(server: McpServer) { text: `✅ COIN-M Futures order placed!\n\nOrder ID: ${data.orderId}\nSymbol: ${data.symbol}\nSide: ${data.side}\nType: ${data.type}\nQuantity: ${data.origQty}\nPrice: ${data.price || "MARKET"}\nStatus: ${data.status}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -89,8 +89,8 @@ export function registerBinanceDeliveryNewOrder(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/trade-api/openOrder.ts b/src/tools/binance-futures-coinm/trade-api/openOrder.ts index a72d5849..61ac2dc9 100644 --- a/src/tools/binance-futures-coinm/trade-api/openOrder.ts +++ b/src/tools/binance-futures-coinm/trade-api/openOrder.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/openOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryOpenOrder(server: McpServer) { server.tool( @@ -29,7 +29,7 @@ export function registerBinanceDeliveryOpenOrder(server: McpServer) { { type: "text", text: "Error: Either orderId or origClientOrderId must be provided" }, ], isError: true, - } + }; } const response = await deliveryClient.restAPI.currentOpenOrder({ @@ -37,9 +37,9 @@ export function registerBinanceDeliveryOpenOrder(server: McpServer) { ...(params.orderId && { orderId: params.orderId }), ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -48,15 +48,15 @@ export function registerBinanceDeliveryOpenOrder(server: McpServer) { text: `📋 Open Order\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get open order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/trade-api/openOrders.ts b/src/tools/binance-futures-coinm/trade-api/openOrders.ts index aee96bf9..41f07da1 100644 --- a/src/tools/binance-futures-coinm/trade-api/openOrders.ts +++ b/src/tools/binance-futures-coinm/trade-api/openOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/trade-api/openOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryOpenOrders(server: McpServer) { server.tool( @@ -26,9 +26,9 @@ export function registerBinanceDeliveryOpenOrders(server: McpServer) { ...(params.symbol && { symbol: params.symbol }), ...(params.pair && { pair: params.pair }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -37,15 +37,15 @@ export function registerBinanceDeliveryOpenOrders(server: McpServer) { text: `📋 Open Orders\n\nCount: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get open orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/trades.ts b/src/tools/binance-futures-coinm/trades.ts index d7ec8f4e..250a4408 100644 --- a/src/tools/binance-futures-coinm/trades.ts +++ b/src/tools/binance-futures-coinm/trades.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/trades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMTrades(server: McpServer) { server.tool( @@ -15,10 +15,10 @@ export function registerBinanceFuturesCOINMTrades(server: McpServer) { }, async ({ symbol, limit }) => { try { - const params: any = { symbol } - if (limit !== undefined) params.limit = limit + const params: any = { symbol }; + if (limit !== undefined) params.limit = limit; - const data = await deliveryClient.trades(params) + const data = await deliveryClient.trades(params); return { content: [ @@ -27,9 +27,9 @@ export function registerBinanceFuturesCOINMTrades(server: McpServer) { text: `Retrieved ${data.length || 0} recent trades for COIN-M Futures ${symbol}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -39,8 +39,8 @@ export function registerBinanceFuturesCOINMTrades(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/userTrades.ts b/src/tools/binance-futures-coinm/userTrades.ts index 2d4919a9..9f958e9b 100644 --- a/src/tools/binance-futures-coinm/userTrades.ts +++ b/src/tools/binance-futures-coinm/userTrades.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-coinm/userTrades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../config/binanceClient.js" +import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMUserTrades(server: McpServer) { server.tool( @@ -20,16 +20,16 @@ export function registerBinanceFuturesCOINMUserTrades(server: McpServer) { }, async ({ symbol, pair, orderId, startTime, endTime, fromId, limit }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol - if (pair) params.pair = pair - if (orderId !== undefined) params.orderId = orderId - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (fromId !== undefined) params.fromId = fromId - if (limit !== undefined) params.limit = limit + const params: any = {}; + if (symbol) params.symbol = symbol; + if (pair) params.pair = pair; + if (orderId !== undefined) params.orderId = orderId; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (fromId !== undefined) params.fromId = fromId; + if (limit !== undefined) params.limit = limit; - const data = await deliveryClient.userTrades(params) + const data = await deliveryClient.userTrades(params); return { content: [ @@ -38,9 +38,9 @@ export function registerBinanceFuturesCOINMUserTrades(server: McpServer) { text: `Retrieved ${data.length || 0} COIN-M Futures trades. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -50,8 +50,8 @@ export function registerBinanceFuturesCOINMUserTrades(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/userdatastream-api/closeListenKey.ts b/src/tools/binance-futures-coinm/userdatastream-api/closeListenKey.ts index dc7483be..4ef25abb 100644 --- a/src/tools/binance-futures-coinm/userdatastream-api/closeListenKey.ts +++ b/src/tools/binance-futures-coinm/userdatastream-api/closeListenKey.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/userdatastream-api/closeListenKey.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryCloseListenKey(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerBinanceDeliveryCloseListenKey(server: McpServer) { const response = await deliveryClient.restAPI.closeListenKey({ ...(params.listenKey && { listenKey: params.listenKey }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,15 +35,15 @@ export function registerBinanceDeliveryCloseListenKey(server: McpServer) { text: `✅ Listen Key Closed!\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to close listen key: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/userdatastream-api/createListenKey.ts b/src/tools/binance-futures-coinm/userdatastream-api/createListenKey.ts index a15efd9a..4bc1fb90 100644 --- a/src/tools/binance-futures-coinm/userdatastream-api/createListenKey.ts +++ b/src/tools/binance-futures-coinm/userdatastream-api/createListenKey.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/userdatastream-api/createListenKey.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryCreateListenKey(server: McpServer) { server.tool( @@ -22,9 +22,9 @@ export function registerBinanceDeliveryCreateListenKey(server: McpServer) { try { const response = await deliveryClient.restAPI.createListenKey({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -33,15 +33,15 @@ export function registerBinanceDeliveryCreateListenKey(server: McpServer) { text: `✅ COIN-M Listen Key Created!\n\nListen Key: ${data.listenKey}\n\n⚠️ Important:\n- Valid for 60 minutes\n- Use keepAlive endpoint to extend validity\n\nWebSocket URL: wss://dstream.binance.com/ws/${data.listenKey}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to create listen key: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-coinm/userdatastream-api/index.ts b/src/tools/binance-futures-coinm/userdatastream-api/index.ts index 87388739..64281a93 100644 --- a/src/tools/binance-futures-coinm/userdatastream-api/index.ts +++ b/src/tools/binance-futures-coinm/userdatastream-api/index.ts @@ -5,15 +5,15 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/userdatastream-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceDeliveryCloseListenKey } from "./closeListenKey.js" -import { registerBinanceDeliveryCreateListenKey } from "./createListenKey.js" -import { registerBinanceDeliveryKeepAliveListenKey } from "./keepAliveListenKey.js" +import { registerBinanceDeliveryCloseListenKey } from "./closeListenKey.js"; +import { registerBinanceDeliveryCreateListenKey } from "./createListenKey.js"; +import { registerBinanceDeliveryKeepAliveListenKey } from "./keepAliveListenKey.js"; export function registerBinanceDeliveryUserDataStreamApiTools(server: McpServer) { // User Data Stream (Listen Key) Management - registerBinanceDeliveryCreateListenKey(server) - registerBinanceDeliveryKeepAliveListenKey(server) - registerBinanceDeliveryCloseListenKey(server) + registerBinanceDeliveryCreateListenKey(server); + registerBinanceDeliveryKeepAliveListenKey(server); + registerBinanceDeliveryCloseListenKey(server); } diff --git a/src/tools/binance-futures-coinm/userdatastream-api/keepAliveListenKey.ts b/src/tools/binance-futures-coinm/userdatastream-api/keepAliveListenKey.ts index 871b58a4..4aae924c 100644 --- a/src/tools/binance-futures-coinm/userdatastream-api/keepAliveListenKey.ts +++ b/src/tools/binance-futures-coinm/userdatastream-api/keepAliveListenKey.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-coinm/userdatastream-api/keepAliveListenKey.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { deliveryClient } from "../../../config/binanceClient.js" +import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryKeepAliveListenKey(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerBinanceDeliveryKeepAliveListenKey(server: McpServer) { const response = await deliveryClient.restAPI.renewListenKey({ ...(params.listenKey && { listenKey: params.listenKey }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - await response.data() + await response.data(); return { content: [ @@ -35,15 +35,15 @@ export function registerBinanceDeliveryKeepAliveListenKey(server: McpServer) { text: `✅ Listen Key Extended!\n\nYour COIN-M Futures listen key has been renewed for another 60 minutes.`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to extend listen key: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/account-api/account.ts b/src/tools/binance-futures-usdm/account-api/account.ts index 5159a403..95fee00c 100644 --- a/src/tools/binance-futures-usdm/account-api/account.ts +++ b/src/tools/binance-futures-usdm/account-api/account.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/account.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesAccount(server: McpServer) { server.tool( @@ -22,8 +22,8 @@ export function registerBinanceFuturesAccount(server: McpServer) { try { const response = await futuresClient.restAPI.account({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -32,15 +32,15 @@ export function registerBinanceFuturesAccount(server: McpServer) { text: `Futures Account: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get account info: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/account-api/adlQuantile.ts b/src/tools/binance-futures-usdm/account-api/adlQuantile.ts index 4f1452ea..4aadf214 100644 --- a/src/tools/binance-futures-usdm/account-api/adlQuantile.ts +++ b/src/tools/binance-futures-usdm/account-api/adlQuantile.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/adlQuantile.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesADLQuantile(server: McpServer) { server.tool( @@ -24,8 +24,8 @@ export function registerBinanceFuturesADLQuantile(server: McpServer) { const response = await futuresClient.restAPI.adlQuantile({ ...(params.symbol && { symbol: params.symbol }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -34,15 +34,15 @@ export function registerBinanceFuturesADLQuantile(server: McpServer) { text: `ADL Quantile: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get ADL quantile: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/account-api/apiTradingStatus.ts b/src/tools/binance-futures-usdm/account-api/apiTradingStatus.ts index c82bca27..7895e944 100644 --- a/src/tools/binance-futures-usdm/account-api/apiTradingStatus.ts +++ b/src/tools/binance-futures-usdm/account-api/apiTradingStatus.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/apiTradingStatus.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesApiTradingStatus(server: McpServer) { server.tool( @@ -24,8 +24,8 @@ export function registerBinanceFuturesApiTradingStatus(server: McpServer) { const response = await futuresClient.restAPI.apiTradingStatus({ ...(params.symbol && { symbol: params.symbol }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -34,15 +34,15 @@ export function registerBinanceFuturesApiTradingStatus(server: McpServer) { text: `API Trading Status: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get API trading status: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/account-api/balance.ts b/src/tools/binance-futures-usdm/account-api/balance.ts index c8292673..f786ecb6 100644 --- a/src/tools/binance-futures-usdm/account-api/balance.ts +++ b/src/tools/binance-futures-usdm/account-api/balance.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/balance.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesBalance(server: McpServer) { server.tool( @@ -22,8 +22,8 @@ export function registerBinanceFuturesBalance(server: McpServer) { try { const response = await futuresClient.restAPI.balance({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -32,15 +32,15 @@ export function registerBinanceFuturesBalance(server: McpServer) { text: `Futures Balance: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get balance: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/account-api/commissionRate.ts b/src/tools/binance-futures-usdm/account-api/commissionRate.ts index 7773d8ce..d8efc193 100644 --- a/src/tools/binance-futures-usdm/account-api/commissionRate.ts +++ b/src/tools/binance-futures-usdm/account-api/commissionRate.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/commissionRate.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesCommissionRate(server: McpServer) { server.tool( @@ -24,8 +24,8 @@ export function registerBinanceFuturesCommissionRate(server: McpServer) { const response = await futuresClient.restAPI.commissionRate({ symbol: params.symbol, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -34,15 +34,15 @@ export function registerBinanceFuturesCommissionRate(server: McpServer) { text: `Commission Rate for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get commission rate: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/account-api/downloadId.ts b/src/tools/binance-futures-usdm/account-api/downloadId.ts index 6ddedcae..c9b882a4 100644 --- a/src/tools/binance-futures-usdm/account-api/downloadId.ts +++ b/src/tools/binance-futures-usdm/account-api/downloadId.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/downloadId.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesDownloadIdForFuturesTransactionHistory(server: McpServer) { server.tool( @@ -26,8 +26,8 @@ export function registerBinanceFuturesDownloadIdForFuturesTransactionHistory(ser startTime: params.startTime, endTime: params.endTime, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -36,15 +36,15 @@ export function registerBinanceFuturesDownloadIdForFuturesTransactionHistory(ser text: `Download ID: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get download ID: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/account-api/forceOrders.ts b/src/tools/binance-futures-usdm/account-api/forceOrders.ts index c0efc1d6..1e91df37 100644 --- a/src/tools/binance-futures-usdm/account-api/forceOrders.ts +++ b/src/tools/binance-futures-usdm/account-api/forceOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/forceOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesForceOrders(server: McpServer) { server.tool( @@ -32,8 +32,8 @@ export function registerBinanceFuturesForceOrders(server: McpServer) { ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -42,15 +42,15 @@ export function registerBinanceFuturesForceOrders(server: McpServer) { text: `Force Orders: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get force orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/account-api/income.ts b/src/tools/binance-futures-usdm/account-api/income.ts index fe309e94..468e2ea7 100644 --- a/src/tools/binance-futures-usdm/account-api/income.ts +++ b/src/tools/binance-futures-usdm/account-api/income.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/income.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesIncome(server: McpServer) { server.tool( @@ -55,8 +55,8 @@ export function registerBinanceFuturesIncome(server: McpServer) { ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -65,15 +65,15 @@ export function registerBinanceFuturesIncome(server: McpServer) { text: `Income History: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get income history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/account-api/index.ts b/src/tools/binance-futures-usdm/account-api/index.ts index 55001e5a..3a63c68b 100644 --- a/src/tools/binance-futures-usdm/account-api/index.ts +++ b/src/tools/binance-futures-usdm/account-api/index.ts @@ -5,49 +5,49 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceFuturesAccount } from "./account.js" -import { registerBinanceFuturesADLQuantile } from "./adlQuantile.js" -import { registerBinanceFuturesApiTradingStatus } from "./apiTradingStatus.js" -import { registerBinanceFuturesBalance } from "./balance.js" -import { registerBinanceFuturesCommissionRate } from "./commissionRate.js" -import { registerBinanceFuturesDownloadIdForFuturesTransactionHistory } from "./downloadId.js" -import { registerBinanceFuturesForceOrders } from "./forceOrders.js" -import { registerBinanceFuturesIncome } from "./income.js" -import { registerBinanceFuturesLeverage } from "./leverage.js" -import { registerBinanceFuturesLeverageBracket } from "./leverageBracket.js" -import { registerBinanceFuturesMarginType } from "./marginType.js" -import { registerBinanceFuturesMultiAssetsMode } from "./multiAssetsMode.js" -import { registerBinanceFuturesPositionMargin } from "./positionMargin.js" -import { registerBinanceFuturesPositionMode } from "./positionMode.js" -import { registerBinanceFuturesPositionRisk } from "./positionRisk.js" -import { registerBinanceFuturesUserTrades } from "./userTrades.js" +import { registerBinanceFuturesAccount } from "./account.js"; +import { registerBinanceFuturesADLQuantile } from "./adlQuantile.js"; +import { registerBinanceFuturesApiTradingStatus } from "./apiTradingStatus.js"; +import { registerBinanceFuturesBalance } from "./balance.js"; +import { registerBinanceFuturesCommissionRate } from "./commissionRate.js"; +import { registerBinanceFuturesDownloadIdForFuturesTransactionHistory } from "./downloadId.js"; +import { registerBinanceFuturesForceOrders } from "./forceOrders.js"; +import { registerBinanceFuturesIncome } from "./income.js"; +import { registerBinanceFuturesLeverage } from "./leverage.js"; +import { registerBinanceFuturesLeverageBracket } from "./leverageBracket.js"; +import { registerBinanceFuturesMarginType } from "./marginType.js"; +import { registerBinanceFuturesMultiAssetsMode } from "./multiAssetsMode.js"; +import { registerBinanceFuturesPositionMargin } from "./positionMargin.js"; +import { registerBinanceFuturesPositionMode } from "./positionMode.js"; +import { registerBinanceFuturesPositionRisk } from "./positionRisk.js"; +import { registerBinanceFuturesUserTrades } from "./userTrades.js"; export function registerBinanceFuturesAccountApiTools(server: McpServer) { // Account Info - registerBinanceFuturesAccount(server) - registerBinanceFuturesBalance(server) - registerBinanceFuturesPositionRisk(server) - registerBinanceFuturesPositionMode(server) - registerBinanceFuturesMultiAssetsMode(server) + registerBinanceFuturesAccount(server); + registerBinanceFuturesBalance(server); + registerBinanceFuturesPositionRisk(server); + registerBinanceFuturesPositionMode(server); + registerBinanceFuturesMultiAssetsMode(server); // Leverage & Margin - registerBinanceFuturesLeverage(server) - registerBinanceFuturesMarginType(server) - registerBinanceFuturesPositionMargin(server) + registerBinanceFuturesLeverage(server); + registerBinanceFuturesMarginType(server); + registerBinanceFuturesPositionMargin(server); // Trades & History - registerBinanceFuturesUserTrades(server) - registerBinanceFuturesIncome(server) - registerBinanceFuturesForceOrders(server) - registerBinanceFuturesDownloadIdForFuturesTransactionHistory(server) + registerBinanceFuturesUserTrades(server); + registerBinanceFuturesIncome(server); + registerBinanceFuturesForceOrders(server); + registerBinanceFuturesDownloadIdForFuturesTransactionHistory(server); // Risk & Limits - registerBinanceFuturesLeverageBracket(server) - registerBinanceFuturesADLQuantile(server) + registerBinanceFuturesLeverageBracket(server); + registerBinanceFuturesADLQuantile(server); // Status & Commission - registerBinanceFuturesApiTradingStatus(server) - registerBinanceFuturesCommissionRate(server) + registerBinanceFuturesApiTradingStatus(server); + registerBinanceFuturesCommissionRate(server); } diff --git a/src/tools/binance-futures-usdm/account-api/leverage.ts b/src/tools/binance-futures-usdm/account-api/leverage.ts index a1006435..a8ac0902 100644 --- a/src/tools/binance-futures-usdm/account-api/leverage.ts +++ b/src/tools/binance-futures-usdm/account-api/leverage.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/leverage.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesLeverage(server: McpServer) { server.tool( @@ -31,8 +31,8 @@ export function registerBinanceFuturesLeverage(server: McpServer) { symbol: params.symbol, leverage: params.leverage, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -41,15 +41,15 @@ export function registerBinanceFuturesLeverage(server: McpServer) { text: `✅ Leverage changed for ${params.symbol}\nNew Leverage: ${data.leverage}x\nMax Notional Value: ${data.maxNotionalValue}\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to change leverage: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/account-api/leverageBracket.ts b/src/tools/binance-futures-usdm/account-api/leverageBracket.ts index a674d369..6c264900 100644 --- a/src/tools/binance-futures-usdm/account-api/leverageBracket.ts +++ b/src/tools/binance-futures-usdm/account-api/leverageBracket.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/leverageBracket.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesLeverageBracket(server: McpServer) { server.tool( @@ -24,8 +24,8 @@ export function registerBinanceFuturesLeverageBracket(server: McpServer) { const response = await futuresClient.restAPI.leverageBracket({ ...(params.symbol && { symbol: params.symbol }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -34,15 +34,15 @@ export function registerBinanceFuturesLeverageBracket(server: McpServer) { text: `Leverage Brackets: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get leverage brackets: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/account-api/marginType.ts b/src/tools/binance-futures-usdm/account-api/marginType.ts index 86c071d7..405ee18e 100644 --- a/src/tools/binance-futures-usdm/account-api/marginType.ts +++ b/src/tools/binance-futures-usdm/account-api/marginType.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/marginType.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesMarginType(server: McpServer) { server.tool( @@ -26,8 +26,8 @@ export function registerBinanceFuturesMarginType(server: McpServer) { symbol: params.symbol, marginType: params.marginType, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -36,15 +36,15 @@ export function registerBinanceFuturesMarginType(server: McpServer) { text: `✅ Margin type changed for ${params.symbol} to ${params.marginType}\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to change margin type: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/account-api/multiAssetsMode.ts b/src/tools/binance-futures-usdm/account-api/multiAssetsMode.ts index 2207604b..3878d1d5 100644 --- a/src/tools/binance-futures-usdm/account-api/multiAssetsMode.ts +++ b/src/tools/binance-futures-usdm/account-api/multiAssetsMode.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/multiAssetsMode.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesMultiAssetsMode(server: McpServer) { server.tool( @@ -22,8 +22,8 @@ export function registerBinanceFuturesMultiAssetsMode(server: McpServer) { try { const response = await futuresClient.restAPI.getMultiAssetsMode({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -32,15 +32,15 @@ export function registerBinanceFuturesMultiAssetsMode(server: McpServer) { text: `Multi-Assets Mode: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get multi-assets mode: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/account-api/positionMargin.ts b/src/tools/binance-futures-usdm/account-api/positionMargin.ts index fff6108c..8264690d 100644 --- a/src/tools/binance-futures-usdm/account-api/positionMargin.ts +++ b/src/tools/binance-futures-usdm/account-api/positionMargin.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/positionMargin.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesPositionMargin(server: McpServer) { // Modify Isolated Position Margin @@ -34,8 +34,8 @@ export function registerBinanceFuturesPositionMargin(server: McpServer) { type: parseInt(params.type), ...(params.positionSide && { positionSide: params.positionSide }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -44,17 +44,17 @@ export function registerBinanceFuturesPositionMargin(server: McpServer) { text: `✅ Position margin modified for ${params.symbol}\nAmount: ${params.amount}\nType: ${params.type === "1" ? "Added" : "Reduced"}\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to modify position margin: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // Get Position Margin Change History server.tool( @@ -77,8 +77,8 @@ export function registerBinanceFuturesPositionMargin(server: McpServer) { ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -87,17 +87,17 @@ export function registerBinanceFuturesPositionMargin(server: McpServer) { text: `Position margin history for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to get position margin history: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/account-api/positionMode.ts b/src/tools/binance-futures-usdm/account-api/positionMode.ts index 639dab0d..f3424d9e 100644 --- a/src/tools/binance-futures-usdm/account-api/positionMode.ts +++ b/src/tools/binance-futures-usdm/account-api/positionMode.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/positionMode.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesPositionMode(server: McpServer) { server.tool( @@ -22,8 +22,8 @@ export function registerBinanceFuturesPositionMode(server: McpServer) { try { const response = await futuresClient.restAPI.getPositionMode({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -32,15 +32,15 @@ export function registerBinanceFuturesPositionMode(server: McpServer) { text: `Position Mode: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get position mode: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/account-api/positionRisk.ts b/src/tools/binance-futures-usdm/account-api/positionRisk.ts index 58ebb738..46a76327 100644 --- a/src/tools/binance-futures-usdm/account-api/positionRisk.ts +++ b/src/tools/binance-futures-usdm/account-api/positionRisk.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/positionRisk.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesPositionRisk(server: McpServer) { server.tool( @@ -24,8 +24,8 @@ export function registerBinanceFuturesPositionRisk(server: McpServer) { const response = await futuresClient.restAPI.positionRisk({ ...(params.symbol && { symbol: params.symbol }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -34,15 +34,15 @@ export function registerBinanceFuturesPositionRisk(server: McpServer) { text: `Position Risk: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get position risk: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/account-api/userTrades.ts b/src/tools/binance-futures-usdm/account-api/userTrades.ts index cea21a55..b767f698 100644 --- a/src/tools/binance-futures-usdm/account-api/userTrades.ts +++ b/src/tools/binance-futures-usdm/account-api/userTrades.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/account-api/userTrades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesUserTrades(server: McpServer) { server.tool( @@ -34,8 +34,8 @@ export function registerBinanceFuturesUserTrades(server: McpServer) { ...(params.fromId !== undefined && { fromId: params.fromId }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -44,15 +44,15 @@ export function registerBinanceFuturesUserTrades(server: McpServer) { text: `User Trades for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get user trades: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/account.ts b/src/tools/binance-futures-usdm/account.ts index f274a602..7709cf36 100644 --- a/src/tools/binance-futures-usdm/account.ts +++ b/src/tools/binance-futures-usdm/account.ts @@ -1,7 +1,7 @@ // src/tools/binance-futures-usdm/account.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMAccount(server: McpServer) { server.tool( @@ -10,7 +10,7 @@ export function registerBinanceFuturesUSDMAccount(server: McpServer) { {}, async () => { try { - const data = await futuresClient.account() + const data = await futuresClient.account(); return { content: [ @@ -19,17 +19,17 @@ export function registerBinanceFuturesUSDMAccount(server: McpServer) { text: `Retrieved USD-M Futures account information. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve USD-M Futures account: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/adlQuantile.ts b/src/tools/binance-futures-usdm/adlQuantile.ts index dceea8e5..32950a3b 100644 --- a/src/tools/binance-futures-usdm/adlQuantile.ts +++ b/src/tools/binance-futures-usdm/adlQuantile.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/adlQuantile.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMADLQuantile(server: McpServer) { server.tool( @@ -19,10 +19,10 @@ export function registerBinanceFuturesUSDMADLQuantile(server: McpServer) { }, async ({ symbol }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol + const params: any = {}; + if (symbol) params.symbol = symbol; - const data = await futuresClient.adlQuantile(params) + const data = await futuresClient.adlQuantile(params); return { content: [ @@ -31,9 +31,9 @@ export function registerBinanceFuturesUSDMADLQuantile(server: McpServer) { text: `Retrieved USD-M Futures ADL quantile${symbol ? ` for ${symbol}` : " for all positions"}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -43,8 +43,8 @@ export function registerBinanceFuturesUSDMADLQuantile(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/aggTrades.ts b/src/tools/binance-futures-usdm/aggTrades.ts index a9346e37..3950a8b6 100644 --- a/src/tools/binance-futures-usdm/aggTrades.ts +++ b/src/tools/binance-futures-usdm/aggTrades.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/aggTrades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMAggTrades(server: McpServer) { server.tool( @@ -24,13 +24,13 @@ export function registerBinanceFuturesUSDMAggTrades(server: McpServer) { }, async ({ symbol, fromId, startTime, endTime, limit }) => { try { - const params: any = { symbol } - if (fromId !== undefined) params.fromId = fromId - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + const params: any = { symbol }; + if (fromId !== undefined) params.fromId = fromId; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const data = await futuresClient.aggTrades(params) + const data = await futuresClient.aggTrades(params); return { content: [ @@ -39,9 +39,9 @@ export function registerBinanceFuturesUSDMAggTrades(server: McpServer) { text: `Retrieved ${data.length || 0} aggregated trades for USD-M Futures ${symbol}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -51,8 +51,8 @@ export function registerBinanceFuturesUSDMAggTrades(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/allOrders.ts b/src/tools/binance-futures-usdm/allOrders.ts index 97e4aa86..377fe845 100644 --- a/src/tools/binance-futures-usdm/allOrders.ts +++ b/src/tools/binance-futures-usdm/allOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/allOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMAllOrders(server: McpServer) { server.tool( @@ -18,13 +18,13 @@ export function registerBinanceFuturesUSDMAllOrders(server: McpServer) { }, async ({ symbol, orderId, startTime, endTime, limit }) => { try { - const params: any = { symbol } - if (orderId !== undefined) params.orderId = orderId - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + const params: any = { symbol }; + if (orderId !== undefined) params.orderId = orderId; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const data = await futuresClient.allOrders(params) + const data = await futuresClient.allOrders(params); return { content: [ @@ -33,17 +33,17 @@ export function registerBinanceFuturesUSDMAllOrders(server: McpServer) { text: `Retrieved ${data.length || 0} USD-M Futures orders for ${symbol}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve USD-M Futures all orders: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/balance.ts b/src/tools/binance-futures-usdm/balance.ts index 3f2b4bed..be180aa0 100644 --- a/src/tools/binance-futures-usdm/balance.ts +++ b/src/tools/binance-futures-usdm/balance.ts @@ -1,7 +1,7 @@ // src/tools/binance-futures-usdm/balance.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMBalance(server: McpServer) { server.tool( @@ -10,7 +10,7 @@ export function registerBinanceFuturesUSDMBalance(server: McpServer) { {}, async () => { try { - const data = await futuresClient.balance() + const data = await futuresClient.balance(); return { content: [ @@ -19,17 +19,17 @@ export function registerBinanceFuturesUSDMBalance(server: McpServer) { text: `Retrieved USD-M Futures account balance. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve USD-M Futures balance: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/batchOrders.ts b/src/tools/binance-futures-usdm/batchOrders.ts index f1a90fa6..0c607127 100644 --- a/src/tools/binance-futures-usdm/batchOrders.ts +++ b/src/tools/binance-futures-usdm/batchOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/batchOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMBatchOrders(server: McpServer) { server.tool( @@ -18,7 +18,7 @@ export function registerBinanceFuturesUSDMBatchOrders(server: McpServer) { }, async ({ batchOrders }) => { try { - const data = await futuresClient.batchOrders({ batchOrders }) + const data = await futuresClient.batchOrders({ batchOrders }); return { content: [ @@ -27,17 +27,17 @@ export function registerBinanceFuturesUSDMBatchOrders(server: McpServer) { text: `USD-M Futures batch orders created. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to create USD-M Futures batch orders: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/bookTicker.ts b/src/tools/binance-futures-usdm/bookTicker.ts index 262c8f68..ae6f6ff7 100644 --- a/src/tools/binance-futures-usdm/bookTicker.ts +++ b/src/tools/binance-futures-usdm/bookTicker.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/bookTicker.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMBookTicker(server: McpServer) { server.tool( @@ -19,10 +19,10 @@ export function registerBinanceFuturesUSDMBookTicker(server: McpServer) { }, async ({ symbol }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol + const params: any = {}; + if (symbol) params.symbol = symbol; - const data = await futuresClient.bookTicker(params) + const data = await futuresClient.bookTicker(params); return { content: [ @@ -31,17 +31,17 @@ export function registerBinanceFuturesUSDMBookTicker(server: McpServer) { text: `Retrieved USD-M Futures book ticker${symbol ? ` for ${symbol}` : " for all symbols"}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve USD-M Futures book ticker: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/cancelAllOrders.ts b/src/tools/binance-futures-usdm/cancelAllOrders.ts index 083c67dd..f5353a73 100644 --- a/src/tools/binance-futures-usdm/cancelAllOrders.ts +++ b/src/tools/binance-futures-usdm/cancelAllOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/cancelAllOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMCancelAllOrders(server: McpServer) { server.tool( @@ -14,7 +14,7 @@ export function registerBinanceFuturesUSDMCancelAllOrders(server: McpServer) { }, async ({ symbol }) => { try { - const data = await futuresClient.cancelAllOpenOrders({ symbol }) + const data = await futuresClient.cancelAllOpenOrders({ symbol }); return { content: [ @@ -23,17 +23,17 @@ export function registerBinanceFuturesUSDMCancelAllOrders(server: McpServer) { text: `All USD-M Futures open orders cancelled for ${symbol}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to cancel USD-M Futures open orders: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/cancelBatchOrders.ts b/src/tools/binance-futures-usdm/cancelBatchOrders.ts index 510fa94c..8d81ea14 100644 --- a/src/tools/binance-futures-usdm/cancelBatchOrders.ts +++ b/src/tools/binance-futures-usdm/cancelBatchOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/cancelBatchOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMCancelBatchOrders(server: McpServer) { server.tool( @@ -19,11 +19,11 @@ export function registerBinanceFuturesUSDMCancelBatchOrders(server: McpServer) { }, async ({ symbol, orderIdList, origClientOrderIdList }) => { try { - const params: any = { symbol } - if (orderIdList) params.orderIdList = orderIdList - if (origClientOrderIdList) params.origClientOrderIdList = origClientOrderIdList + const params: any = { symbol }; + if (orderIdList) params.orderIdList = orderIdList; + if (origClientOrderIdList) params.origClientOrderIdList = origClientOrderIdList; - const data = await futuresClient.cancelBatchOrders(params) + const data = await futuresClient.cancelBatchOrders(params); return { content: [ @@ -32,17 +32,17 @@ export function registerBinanceFuturesUSDMCancelBatchOrders(server: McpServer) { text: `USD-M Futures batch orders cancelled. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to cancel USD-M Futures batch orders: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/cancelOrder.ts b/src/tools/binance-futures-usdm/cancelOrder.ts index 56e0f578..719bc2ec 100644 --- a/src/tools/binance-futures-usdm/cancelOrder.ts +++ b/src/tools/binance-futures-usdm/cancelOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/cancelOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMCancelOrder(server: McpServer) { server.tool( @@ -16,11 +16,11 @@ export function registerBinanceFuturesUSDMCancelOrder(server: McpServer) { }, async ({ symbol, orderId, origClientOrderId }) => { try { - const params: any = { symbol } - if (orderId !== undefined) params.orderId = orderId - if (origClientOrderId) params.origClientOrderId = origClientOrderId + const params: any = { symbol }; + if (orderId !== undefined) params.orderId = orderId; + if (origClientOrderId) params.origClientOrderId = origClientOrderId; - const data = await futuresClient.cancelOrder(params) + const data = await futuresClient.cancelOrder(params); return { content: [ @@ -29,17 +29,17 @@ export function registerBinanceFuturesUSDMCancelOrder(server: McpServer) { text: `USD-M Futures order cancelled successfully. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to cancel USD-M Futures order: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/commissionRate.ts b/src/tools/binance-futures-usdm/commissionRate.ts index d30f8292..48c76fb8 100644 --- a/src/tools/binance-futures-usdm/commissionRate.ts +++ b/src/tools/binance-futures-usdm/commissionRate.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/commissionRate.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMCommissionRate(server: McpServer) { server.tool( @@ -14,7 +14,7 @@ export function registerBinanceFuturesUSDMCommissionRate(server: McpServer) { }, async ({ symbol }) => { try { - const data = await futuresClient.commissionRate({ symbol }) + const data = await futuresClient.commissionRate({ symbol }); return { content: [ @@ -23,9 +23,9 @@ export function registerBinanceFuturesUSDMCommissionRate(server: McpServer) { text: `Retrieved USD-M Futures commission rate for ${symbol}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -35,8 +35,8 @@ export function registerBinanceFuturesUSDMCommissionRate(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/continuousKlines.ts b/src/tools/binance-futures-usdm/continuousKlines.ts index ed9310c1..0492d329 100644 --- a/src/tools/binance-futures-usdm/continuousKlines.ts +++ b/src/tools/binance-futures-usdm/continuousKlines.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/continuousKlines.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMContinuousKlines(server: McpServer) { server.tool( @@ -39,12 +39,12 @@ export function registerBinanceFuturesUSDMContinuousKlines(server: McpServer) { }, async ({ pair, contractType, interval, startTime, endTime, limit }) => { try { - const params: any = { pair, contractType, interval } - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + const params: any = { pair, contractType, interval }; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const data = await futuresClient.continuousKlines(params) + const data = await futuresClient.continuousKlines(params); return { content: [ @@ -53,9 +53,9 @@ export function registerBinanceFuturesUSDMContinuousKlines(server: McpServer) { text: `Retrieved ${data.length || 0} continuous klines for USD-M Futures ${pair} ${contractType} with ${interval} interval. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -65,8 +65,8 @@ export function registerBinanceFuturesUSDMContinuousKlines(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/depth.ts b/src/tools/binance-futures-usdm/depth.ts index 39a0ceec..092723c3 100644 --- a/src/tools/binance-futures-usdm/depth.ts +++ b/src/tools/binance-futures-usdm/depth.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/depth.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMDepth(server: McpServer) { server.tool( @@ -20,10 +20,10 @@ export function registerBinanceFuturesUSDMDepth(server: McpServer) { }, async ({ symbol, limit }) => { try { - const params: any = { symbol } - if (limit !== undefined) params.limit = limit + const params: any = { symbol }; + if (limit !== undefined) params.limit = limit; - const data = await futuresClient.depth(params) + const data = await futuresClient.depth(params); return { content: [ @@ -32,9 +32,9 @@ export function registerBinanceFuturesUSDMDepth(server: McpServer) { text: `Retrieved USD-M Futures order book depth for ${symbol}. Bids: ${data.bids?.length || 0}, Asks: ${data.asks?.length || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -44,8 +44,8 @@ export function registerBinanceFuturesUSDMDepth(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/exchangeInfo.ts b/src/tools/binance-futures-usdm/exchangeInfo.ts index a925a081..d17251aa 100644 --- a/src/tools/binance-futures-usdm/exchangeInfo.ts +++ b/src/tools/binance-futures-usdm/exchangeInfo.ts @@ -1,7 +1,7 @@ // src/tools/binance-futures-usdm/exchangeInfo.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMExchangeInfo(server: McpServer) { server.tool( @@ -10,7 +10,7 @@ export function registerBinanceFuturesUSDMExchangeInfo(server: McpServer) { {}, async () => { try { - const data = await futuresClient.exchangeInfo() + const data = await futuresClient.exchangeInfo(); return { content: [ @@ -19,17 +19,17 @@ export function registerBinanceFuturesUSDMExchangeInfo(server: McpServer) { text: `USD-M Futures exchange info retrieved. Symbols count: ${data.symbols?.length || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to get USD-M Futures exchange info: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/forceOrders.ts b/src/tools/binance-futures-usdm/forceOrders.ts index e7713cd5..d6a9befb 100644 --- a/src/tools/binance-futures-usdm/forceOrders.ts +++ b/src/tools/binance-futures-usdm/forceOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/forceOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMForceOrders(server: McpServer) { server.tool( @@ -21,14 +21,14 @@ export function registerBinanceFuturesUSDMForceOrders(server: McpServer) { }, async ({ symbol, autoCloseType, startTime, endTime, limit }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol - if (autoCloseType) params.autoCloseType = autoCloseType - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + const params: any = {}; + if (symbol) params.symbol = symbol; + if (autoCloseType) params.autoCloseType = autoCloseType; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const data = await futuresClient.forceOrders(params) + const data = await futuresClient.forceOrders(params); return { content: [ @@ -37,9 +37,9 @@ export function registerBinanceFuturesUSDMForceOrders(server: McpServer) { text: `Retrieved ${data.length || 0} USD-M Futures force orders. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -49,8 +49,8 @@ export function registerBinanceFuturesUSDMForceOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/fundingRate.ts b/src/tools/binance-futures-usdm/fundingRate.ts index 8084e9d3..a6204028 100644 --- a/src/tools/binance-futures-usdm/fundingRate.ts +++ b/src/tools/binance-futures-usdm/fundingRate.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/fundingRate.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMFundingRate(server: McpServer) { server.tool( @@ -17,13 +17,13 @@ export function registerBinanceFuturesUSDMFundingRate(server: McpServer) { }, async ({ symbol, startTime, endTime, limit }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + const params: any = {}; + if (symbol) params.symbol = symbol; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const data = await futuresClient.fundingRate(params) + const data = await futuresClient.fundingRate(params); return { content: [ @@ -32,9 +32,9 @@ export function registerBinanceFuturesUSDMFundingRate(server: McpServer) { text: `Retrieved ${data.length || 0} funding rate records for USD-M Futures${symbol ? ` ${symbol}` : ""}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -44,8 +44,8 @@ export function registerBinanceFuturesUSDMFundingRate(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/getOrder.ts b/src/tools/binance-futures-usdm/getOrder.ts index 136f0864..cd572708 100644 --- a/src/tools/binance-futures-usdm/getOrder.ts +++ b/src/tools/binance-futures-usdm/getOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/getOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMGetOrder(server: McpServer) { server.tool( @@ -16,11 +16,11 @@ export function registerBinanceFuturesUSDMGetOrder(server: McpServer) { }, async ({ symbol, orderId, origClientOrderId }) => { try { - const params: any = { symbol } - if (orderId !== undefined) params.orderId = orderId - if (origClientOrderId) params.origClientOrderId = origClientOrderId + const params: any = { symbol }; + if (orderId !== undefined) params.orderId = orderId; + if (origClientOrderId) params.origClientOrderId = origClientOrderId; - const data = await futuresClient.getOrder(params) + const data = await futuresClient.getOrder(params); return { content: [ @@ -29,17 +29,17 @@ export function registerBinanceFuturesUSDMGetOrder(server: McpServer) { text: `Retrieved USD-M Futures order. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve USD-M Futures order: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/historicalTrades.ts b/src/tools/binance-futures-usdm/historicalTrades.ts index b64b66ed..202fb103 100644 --- a/src/tools/binance-futures-usdm/historicalTrades.ts +++ b/src/tools/binance-futures-usdm/historicalTrades.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/historicalTrades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMHistoricalTrades(server: McpServer) { server.tool( @@ -19,11 +19,11 @@ export function registerBinanceFuturesUSDMHistoricalTrades(server: McpServer) { }, async ({ symbol, limit, fromId }) => { try { - const params: any = { symbol } - if (limit !== undefined) params.limit = limit - if (fromId !== undefined) params.fromId = fromId + const params: any = { symbol }; + if (limit !== undefined) params.limit = limit; + if (fromId !== undefined) params.fromId = fromId; - const data = await futuresClient.historicalTrades(params) + const data = await futuresClient.historicalTrades(params); return { content: [ @@ -32,9 +32,9 @@ export function registerBinanceFuturesUSDMHistoricalTrades(server: McpServer) { text: `Retrieved ${data.length || 0} historical trades for USD-M Futures ${symbol}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -44,8 +44,8 @@ export function registerBinanceFuturesUSDMHistoricalTrades(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/income.ts b/src/tools/binance-futures-usdm/income.ts index 01c23c02..076f0dc0 100644 --- a/src/tools/binance-futures-usdm/income.ts +++ b/src/tools/binance-futures-usdm/income.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/income.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMIncome(server: McpServer) { server.tool( @@ -41,14 +41,14 @@ export function registerBinanceFuturesUSDMIncome(server: McpServer) { }, async ({ symbol, incomeType, startTime, endTime, limit }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol - if (incomeType) params.incomeType = incomeType - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + const params: any = {}; + if (symbol) params.symbol = symbol; + if (incomeType) params.incomeType = incomeType; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const data = await futuresClient.income(params) + const data = await futuresClient.income(params); return { content: [ @@ -57,17 +57,17 @@ export function registerBinanceFuturesUSDMIncome(server: McpServer) { text: `Retrieved ${data.length || 0} USD-M Futures income records. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve USD-M Futures income: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/index.ts b/src/tools/binance-futures-usdm/index.ts index 66bd3ef4..555d9a71 100644 --- a/src/tools/binance-futures-usdm/index.ts +++ b/src/tools/binance-futures-usdm/index.ts @@ -1,98 +1,98 @@ // src/tools/binance-futures-usdm/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; // Account & Trading -import { registerBinanceFuturesUSDMAccount } from "./account.js" -import { registerBinanceFuturesUSDMADLQuantile } from "./adlQuantile.js" -import { registerBinanceFuturesUSDMAggTrades } from "./aggTrades.js" -import { registerBinanceFuturesUSDMAllOrders } from "./allOrders.js" -import { registerBinanceFuturesUSDMBalance } from "./balance.js" -import { registerBinanceFuturesUSDMBatchOrders } from "./batchOrders.js" -import { registerBinanceFuturesUSDMBookTicker } from "./bookTicker.js" -import { registerBinanceFuturesUSDMCancelAllOrders } from "./cancelAllOrders.js" -import { registerBinanceFuturesUSDMCancelBatchOrders } from "./cancelBatchOrders.js" -import { registerBinanceFuturesUSDMCancelOrder } from "./cancelOrder.js" -import { registerBinanceFuturesUSDMCommissionRate } from "./commissionRate.js" -import { registerBinanceFuturesUSDMContinuousKlines } from "./continuousKlines.js" -import { registerBinanceFuturesUSDMDepth } from "./depth.js" -import { registerBinanceFuturesUSDMExchangeInfo } from "./exchangeInfo.js" -import { registerBinanceFuturesUSDMForceOrders } from "./forceOrders.js" -import { registerBinanceFuturesUSDMFundingRate } from "./fundingRate.js" -import { registerBinanceFuturesUSDMGetOrder } from "./getOrder.js" -import { registerBinanceFuturesUSDMHistoricalTrades } from "./historicalTrades.js" -import { registerBinanceFuturesUSDMIncome } from "./income.js" -import { registerBinanceFuturesUSDMIndexPriceKlines } from "./indexPriceKlines.js" -import { registerBinanceFuturesUSDMKlines } from "./klines.js" -import { registerBinanceFuturesUSDMLeverage } from "./leverage.js" +import { registerBinanceFuturesUSDMAccount } from "./account.js"; +import { registerBinanceFuturesUSDMADLQuantile } from "./adlQuantile.js"; +import { registerBinanceFuturesUSDMAggTrades } from "./aggTrades.js"; +import { registerBinanceFuturesUSDMAllOrders } from "./allOrders.js"; +import { registerBinanceFuturesUSDMBalance } from "./balance.js"; +import { registerBinanceFuturesUSDMBatchOrders } from "./batchOrders.js"; +import { registerBinanceFuturesUSDMBookTicker } from "./bookTicker.js"; +import { registerBinanceFuturesUSDMCancelAllOrders } from "./cancelAllOrders.js"; +import { registerBinanceFuturesUSDMCancelBatchOrders } from "./cancelBatchOrders.js"; +import { registerBinanceFuturesUSDMCancelOrder } from "./cancelOrder.js"; +import { registerBinanceFuturesUSDMCommissionRate } from "./commissionRate.js"; +import { registerBinanceFuturesUSDMContinuousKlines } from "./continuousKlines.js"; +import { registerBinanceFuturesUSDMDepth } from "./depth.js"; +import { registerBinanceFuturesUSDMExchangeInfo } from "./exchangeInfo.js"; +import { registerBinanceFuturesUSDMForceOrders } from "./forceOrders.js"; +import { registerBinanceFuturesUSDMFundingRate } from "./fundingRate.js"; +import { registerBinanceFuturesUSDMGetOrder } from "./getOrder.js"; +import { registerBinanceFuturesUSDMHistoricalTrades } from "./historicalTrades.js"; +import { registerBinanceFuturesUSDMIncome } from "./income.js"; +import { registerBinanceFuturesUSDMIndexPriceKlines } from "./indexPriceKlines.js"; +import { registerBinanceFuturesUSDMKlines } from "./klines.js"; +import { registerBinanceFuturesUSDMLeverage } from "./leverage.js"; // User Data Stream import { registerBinanceFuturesUSDMListenKeyClose, registerBinanceFuturesUSDMListenKeyCreate, registerBinanceFuturesUSDMListenKeyRenew, -} from "./listenKey.js" -import { registerBinanceFuturesUSDMMarginType } from "./marginType.js" -import { registerBinanceFuturesUSDMMarkPriceKlines } from "./markPriceKlines.js" -import { registerBinanceFuturesUSDMMultiAssetsMode } from "./multiAssetsMode.js" -import { registerBinanceFuturesUSDMNewOrder } from "./newOrder.js" -import { registerBinanceFuturesUSDMOpenInterest } from "./openInterest.js" -import { registerBinanceFuturesUSDMOpenOrders } from "./openOrders.js" +} from "./listenKey.js"; +import { registerBinanceFuturesUSDMMarginType } from "./marginType.js"; +import { registerBinanceFuturesUSDMMarkPriceKlines } from "./markPriceKlines.js"; +import { registerBinanceFuturesUSDMMultiAssetsMode } from "./multiAssetsMode.js"; +import { registerBinanceFuturesUSDMNewOrder } from "./newOrder.js"; +import { registerBinanceFuturesUSDMOpenInterest } from "./openInterest.js"; +import { registerBinanceFuturesUSDMOpenOrders } from "./openOrders.js"; // Market Data -import { registerBinanceFuturesUSDMPing } from "./ping.js" -import { registerBinanceFuturesUSDMPositionMargin } from "./positionMargin.js" -import { registerBinanceFuturesUSDMPositionMode } from "./positionMode.js" -import { registerBinanceFuturesUSDMPositionRisk } from "./positionRisk.js" -import { registerBinanceFuturesUSDMPremiumIndex } from "./premiumIndex.js" -import { registerBinanceFuturesUSDMTicker24hr } from "./ticker24hr.js" -import { registerBinanceFuturesUSDMTickerPrice } from "./tickerPrice.js" -import { registerBinanceFuturesUSDMTime } from "./time.js" -import { registerBinanceFuturesUSDMTrades } from "./trades.js" -import { registerBinanceFuturesUSDMUserTrades } from "./userTrades.js" +import { registerBinanceFuturesUSDMPing } from "./ping.js"; +import { registerBinanceFuturesUSDMPositionMargin } from "./positionMargin.js"; +import { registerBinanceFuturesUSDMPositionMode } from "./positionMode.js"; +import { registerBinanceFuturesUSDMPositionRisk } from "./positionRisk.js"; +import { registerBinanceFuturesUSDMPremiumIndex } from "./premiumIndex.js"; +import { registerBinanceFuturesUSDMTicker24hr } from "./ticker24hr.js"; +import { registerBinanceFuturesUSDMTickerPrice } from "./tickerPrice.js"; +import { registerBinanceFuturesUSDMTime } from "./time.js"; +import { registerBinanceFuturesUSDMTrades } from "./trades.js"; +import { registerBinanceFuturesUSDMUserTrades } from "./userTrades.js"; export function registerBinanceFuturesUSDMTools(server: McpServer) { // Market Data - registerBinanceFuturesUSDMPing(server) - registerBinanceFuturesUSDMTime(server) - registerBinanceFuturesUSDMExchangeInfo(server) - registerBinanceFuturesUSDMDepth(server) - registerBinanceFuturesUSDMTrades(server) - registerBinanceFuturesUSDMHistoricalTrades(server) - registerBinanceFuturesUSDMAggTrades(server) - registerBinanceFuturesUSDMKlines(server) - registerBinanceFuturesUSDMContinuousKlines(server) - registerBinanceFuturesUSDMIndexPriceKlines(server) - registerBinanceFuturesUSDMMarkPriceKlines(server) - registerBinanceFuturesUSDMPremiumIndex(server) - registerBinanceFuturesUSDMFundingRate(server) - registerBinanceFuturesUSDMTicker24hr(server) - registerBinanceFuturesUSDMTickerPrice(server) - registerBinanceFuturesUSDMBookTicker(server) - registerBinanceFuturesUSDMOpenInterest(server) + registerBinanceFuturesUSDMPing(server); + registerBinanceFuturesUSDMTime(server); + registerBinanceFuturesUSDMExchangeInfo(server); + registerBinanceFuturesUSDMDepth(server); + registerBinanceFuturesUSDMTrades(server); + registerBinanceFuturesUSDMHistoricalTrades(server); + registerBinanceFuturesUSDMAggTrades(server); + registerBinanceFuturesUSDMKlines(server); + registerBinanceFuturesUSDMContinuousKlines(server); + registerBinanceFuturesUSDMIndexPriceKlines(server); + registerBinanceFuturesUSDMMarkPriceKlines(server); + registerBinanceFuturesUSDMPremiumIndex(server); + registerBinanceFuturesUSDMFundingRate(server); + registerBinanceFuturesUSDMTicker24hr(server); + registerBinanceFuturesUSDMTickerPrice(server); + registerBinanceFuturesUSDMBookTicker(server); + registerBinanceFuturesUSDMOpenInterest(server); // Account & Trading - registerBinanceFuturesUSDMAccount(server) - registerBinanceFuturesUSDMBalance(server) - registerBinanceFuturesUSDMPositionRisk(server) - registerBinanceFuturesUSDMNewOrder(server) - registerBinanceFuturesUSDMBatchOrders(server) - registerBinanceFuturesUSDMGetOrder(server) - registerBinanceFuturesUSDMCancelOrder(server) - registerBinanceFuturesUSDMCancelAllOrders(server) - registerBinanceFuturesUSDMCancelBatchOrders(server) - registerBinanceFuturesUSDMOpenOrders(server) - registerBinanceFuturesUSDMAllOrders(server) - registerBinanceFuturesUSDMUserTrades(server) - registerBinanceFuturesUSDMIncome(server) - registerBinanceFuturesUSDMLeverage(server) - registerBinanceFuturesUSDMMarginType(server) - registerBinanceFuturesUSDMPositionMargin(server) - registerBinanceFuturesUSDMPositionMode(server) - registerBinanceFuturesUSDMMultiAssetsMode(server) - registerBinanceFuturesUSDMCommissionRate(server) - registerBinanceFuturesUSDMForceOrders(server) - registerBinanceFuturesUSDMADLQuantile(server) + registerBinanceFuturesUSDMAccount(server); + registerBinanceFuturesUSDMBalance(server); + registerBinanceFuturesUSDMPositionRisk(server); + registerBinanceFuturesUSDMNewOrder(server); + registerBinanceFuturesUSDMBatchOrders(server); + registerBinanceFuturesUSDMGetOrder(server); + registerBinanceFuturesUSDMCancelOrder(server); + registerBinanceFuturesUSDMCancelAllOrders(server); + registerBinanceFuturesUSDMCancelBatchOrders(server); + registerBinanceFuturesUSDMOpenOrders(server); + registerBinanceFuturesUSDMAllOrders(server); + registerBinanceFuturesUSDMUserTrades(server); + registerBinanceFuturesUSDMIncome(server); + registerBinanceFuturesUSDMLeverage(server); + registerBinanceFuturesUSDMMarginType(server); + registerBinanceFuturesUSDMPositionMargin(server); + registerBinanceFuturesUSDMPositionMode(server); + registerBinanceFuturesUSDMMultiAssetsMode(server); + registerBinanceFuturesUSDMCommissionRate(server); + registerBinanceFuturesUSDMForceOrders(server); + registerBinanceFuturesUSDMADLQuantile(server); // User Data Stream - registerBinanceFuturesUSDMListenKeyCreate(server) - registerBinanceFuturesUSDMListenKeyRenew(server) - registerBinanceFuturesUSDMListenKeyClose(server) + registerBinanceFuturesUSDMListenKeyCreate(server); + registerBinanceFuturesUSDMListenKeyRenew(server); + registerBinanceFuturesUSDMListenKeyClose(server); } diff --git a/src/tools/binance-futures-usdm/indexPriceKlines.ts b/src/tools/binance-futures-usdm/indexPriceKlines.ts index 52c9661e..5f935bc2 100644 --- a/src/tools/binance-futures-usdm/indexPriceKlines.ts +++ b/src/tools/binance-futures-usdm/indexPriceKlines.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/indexPriceKlines.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMIndexPriceKlines(server: McpServer) { server.tool( @@ -36,12 +36,12 @@ export function registerBinanceFuturesUSDMIndexPriceKlines(server: McpServer) { }, async ({ pair, interval, startTime, endTime, limit }) => { try { - const params: any = { pair, interval } - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + const params: any = { pair, interval }; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const data = await futuresClient.indexPriceKlines(params) + const data = await futuresClient.indexPriceKlines(params); return { content: [ @@ -50,9 +50,9 @@ export function registerBinanceFuturesUSDMIndexPriceKlines(server: McpServer) { text: `Retrieved ${data.length || 0} index price klines for USD-M Futures ${pair} with ${interval} interval. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -62,8 +62,8 @@ export function registerBinanceFuturesUSDMIndexPriceKlines(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/klines.ts b/src/tools/binance-futures-usdm/klines.ts index 5ee6bc96..11077e2f 100644 --- a/src/tools/binance-futures-usdm/klines.ts +++ b/src/tools/binance-futures-usdm/klines.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/klines.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMKlines(server: McpServer) { server.tool( @@ -36,12 +36,12 @@ export function registerBinanceFuturesUSDMKlines(server: McpServer) { }, async ({ symbol, interval, startTime, endTime, limit }) => { try { - const params: any = { symbol, interval } - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + const params: any = { symbol, interval }; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const data = await futuresClient.klines(params) + const data = await futuresClient.klines(params); return { content: [ @@ -50,17 +50,17 @@ export function registerBinanceFuturesUSDMKlines(server: McpServer) { text: `Retrieved ${data.length || 0} klines for USD-M Futures ${symbol} with ${interval} interval. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve USD-M Futures klines: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/leverage.ts b/src/tools/binance-futures-usdm/leverage.ts index 899a6cb8..a99949bd 100644 --- a/src/tools/binance-futures-usdm/leverage.ts +++ b/src/tools/binance-futures-usdm/leverage.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/leverage.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMLeverage(server: McpServer) { server.tool( @@ -15,7 +15,7 @@ export function registerBinanceFuturesUSDMLeverage(server: McpServer) { }, async ({ symbol, leverage }) => { try { - const data = await futuresClient.leverage({ symbol, leverage }) + const data = await futuresClient.leverage({ symbol, leverage }); return { content: [ @@ -24,17 +24,17 @@ export function registerBinanceFuturesUSDMLeverage(server: McpServer) { text: `USD-M Futures leverage changed to ${leverage}x for ${symbol}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to change USD-M Futures leverage: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/listenKey.ts b/src/tools/binance-futures-usdm/listenKey.ts index 7787295e..2fa7a6e2 100644 --- a/src/tools/binance-futures-usdm/listenKey.ts +++ b/src/tools/binance-futures-usdm/listenKey.ts @@ -1,7 +1,7 @@ // src/tools/binance-futures-usdm/listenKey.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMListenKeyCreate(server: McpServer) { server.tool( @@ -10,7 +10,7 @@ export function registerBinanceFuturesUSDMListenKeyCreate(server: McpServer) { {}, async () => { try { - const data = await futuresClient.createListenKey() + const data = await futuresClient.createListenKey(); return { content: [ @@ -19,19 +19,19 @@ export function registerBinanceFuturesUSDMListenKeyCreate(server: McpServer) { text: `USD-M Futures listen key created. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to create USD-M Futures listen key: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } export function registerBinanceFuturesUSDMListenKeyRenew(server: McpServer) { @@ -41,7 +41,7 @@ export function registerBinanceFuturesUSDMListenKeyRenew(server: McpServer) { {}, async () => { try { - const data = await futuresClient.keepAliveListenKey() + const data = await futuresClient.keepAliveListenKey(); return { content: [ @@ -50,19 +50,19 @@ export function registerBinanceFuturesUSDMListenKeyRenew(server: McpServer) { text: `USD-M Futures listen key renewed. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to renew USD-M Futures listen key: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } export function registerBinanceFuturesUSDMListenKeyClose(server: McpServer) { @@ -72,7 +72,7 @@ export function registerBinanceFuturesUSDMListenKeyClose(server: McpServer) { {}, async () => { try { - const data = await futuresClient.closeListenKey() + const data = await futuresClient.closeListenKey(); return { content: [ @@ -81,17 +81,17 @@ export function registerBinanceFuturesUSDMListenKeyClose(server: McpServer) { text: `USD-M Futures listen key closed. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to close USD-M Futures listen key: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/marginType.ts b/src/tools/binance-futures-usdm/marginType.ts index b9ca93c8..4bc93724 100644 --- a/src/tools/binance-futures-usdm/marginType.ts +++ b/src/tools/binance-futures-usdm/marginType.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/marginType.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMMarginType(server: McpServer) { server.tool( @@ -15,7 +15,7 @@ export function registerBinanceFuturesUSDMMarginType(server: McpServer) { }, async ({ symbol, marginType }) => { try { - const data = await futuresClient.marginType({ symbol, marginType }) + const data = await futuresClient.marginType({ symbol, marginType }); return { content: [ @@ -24,17 +24,17 @@ export function registerBinanceFuturesUSDMMarginType(server: McpServer) { text: `USD-M Futures margin type changed to ${marginType} for ${symbol}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to change USD-M Futures margin type: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/markPriceKlines.ts b/src/tools/binance-futures-usdm/markPriceKlines.ts index 2c4e22c5..29314874 100644 --- a/src/tools/binance-futures-usdm/markPriceKlines.ts +++ b/src/tools/binance-futures-usdm/markPriceKlines.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/markPriceKlines.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMMarkPriceKlines(server: McpServer) { server.tool( @@ -36,12 +36,12 @@ export function registerBinanceFuturesUSDMMarkPriceKlines(server: McpServer) { }, async ({ symbol, interval, startTime, endTime, limit }) => { try { - const params: any = { symbol, interval } - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + const params: any = { symbol, interval }; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const data = await futuresClient.markPriceKlines(params) + const data = await futuresClient.markPriceKlines(params); return { content: [ @@ -50,9 +50,9 @@ export function registerBinanceFuturesUSDMMarkPriceKlines(server: McpServer) { text: `Retrieved ${data.length || 0} mark price klines for USD-M Futures ${symbol} with ${interval} interval. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -62,8 +62,8 @@ export function registerBinanceFuturesUSDMMarkPriceKlines(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/market-api/aggTrades.ts b/src/tools/binance-futures-usdm/market-api/aggTrades.ts index 04de252a..148d3a6f 100644 --- a/src/tools/binance-futures-usdm/market-api/aggTrades.ts +++ b/src/tools/binance-futures-usdm/market-api/aggTrades.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/aggTrades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesAggTrades(server: McpServer) { server.tool( @@ -30,8 +30,8 @@ export function registerBinanceFuturesAggTrades(server: McpServer) { ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -40,15 +40,15 @@ export function registerBinanceFuturesAggTrades(server: McpServer) { text: `Aggregate Trades for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get aggregate trades: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/market-api/assetIndex.ts b/src/tools/binance-futures-usdm/market-api/assetIndex.ts index e19a5ed3..7d4438d4 100644 --- a/src/tools/binance-futures-usdm/market-api/assetIndex.ts +++ b/src/tools/binance-futures-usdm/market-api/assetIndex.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/assetIndex.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesAssetIndex(server: McpServer) { server.tool( @@ -22,8 +22,8 @@ export function registerBinanceFuturesAssetIndex(server: McpServer) { try { const response = await futuresClient.restAPI.assetIndex({ ...(params.symbol && { symbol: params.symbol }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -32,15 +32,15 @@ export function registerBinanceFuturesAssetIndex(server: McpServer) { text: `Asset index${params.symbol ? ` for ${params.symbol}` : ""}: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get asset index: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/market-api/continuousKlines.ts b/src/tools/binance-futures-usdm/market-api/continuousKlines.ts index 9f5d5c28..94ba88b9 100644 --- a/src/tools/binance-futures-usdm/market-api/continuousKlines.ts +++ b/src/tools/binance-futures-usdm/market-api/continuousKlines.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/continuousKlines.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesContinuousKlines(server: McpServer) { server.tool( @@ -52,8 +52,8 @@ export function registerBinanceFuturesContinuousKlines(server: McpServer) { ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -62,15 +62,15 @@ export function registerBinanceFuturesContinuousKlines(server: McpServer) { text: `Continuous Klines for ${params.pair} ${params.contractType}: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get continuous klines: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/market-api/depth.ts b/src/tools/binance-futures-usdm/market-api/depth.ts index 5b31944c..111d78ea 100644 --- a/src/tools/binance-futures-usdm/market-api/depth.ts +++ b/src/tools/binance-futures-usdm/market-api/depth.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/depth.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesDepth(server: McpServer) { server.tool( @@ -28,8 +28,8 @@ export function registerBinanceFuturesDepth(server: McpServer) { const response = await futuresClient.restAPI.depth({ symbol: params.symbol, ...(params.limit && { limit: params.limit }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -38,15 +38,15 @@ export function registerBinanceFuturesDepth(server: McpServer) { text: `Futures Order Book for ${params.symbol}: Bids: ${data.bids?.length || 0}, Asks: ${data.asks?.length || 0}. ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get depth: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/market-api/exchangeInfo.ts b/src/tools/binance-futures-usdm/market-api/exchangeInfo.ts index 1b5bfe31..62d13f08 100644 --- a/src/tools/binance-futures-usdm/market-api/exchangeInfo.ts +++ b/src/tools/binance-futures-usdm/market-api/exchangeInfo.ts @@ -5,9 +5,9 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/exchangeInfo.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesExchangeInfo(server: McpServer) { server.tool( @@ -16,8 +16,8 @@ export function registerBinanceFuturesExchangeInfo(server: McpServer) { {}, async () => { try { - const response = await futuresClient.restAPI.exchangeInfo() - const data = await response.data() + const response = await futuresClient.restAPI.exchangeInfo(); + const data = await response.data(); return { content: [ @@ -26,15 +26,15 @@ export function registerBinanceFuturesExchangeInfo(server: McpServer) { text: `Futures Exchange Info: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get exchange info: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/market-api/fundingInfo.ts b/src/tools/binance-futures-usdm/market-api/fundingInfo.ts index 63a99417..9fe2fd3a 100644 --- a/src/tools/binance-futures-usdm/market-api/fundingInfo.ts +++ b/src/tools/binance-futures-usdm/market-api/fundingInfo.ts @@ -5,9 +5,9 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/fundingInfo.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesFundingInfo(server: McpServer) { server.tool( @@ -16,8 +16,8 @@ export function registerBinanceFuturesFundingInfo(server: McpServer) { {}, async () => { try { - const response = await futuresClient.restAPI.fundingInfo() - const data = await response.data() + const response = await futuresClient.restAPI.fundingInfo(); + const data = await response.data(); return { content: [ @@ -26,15 +26,15 @@ export function registerBinanceFuturesFundingInfo(server: McpServer) { text: `Funding Info: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get funding info: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/market-api/fundingRate.ts b/src/tools/binance-futures-usdm/market-api/fundingRate.ts index 4c6080ff..3d2b4896 100644 --- a/src/tools/binance-futures-usdm/market-api/fundingRate.ts +++ b/src/tools/binance-futures-usdm/market-api/fundingRate.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/fundingRate.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesFundingRate(server: McpServer) { server.tool( @@ -28,8 +28,8 @@ export function registerBinanceFuturesFundingRate(server: McpServer) { ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -38,15 +38,15 @@ export function registerBinanceFuturesFundingRate(server: McpServer) { text: `Funding Rate History for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get funding rate: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/market-api/globalLongShortAccountRatio.ts b/src/tools/binance-futures-usdm/market-api/globalLongShortAccountRatio.ts index dbbd4c25..3ec1b594 100644 --- a/src/tools/binance-futures-usdm/market-api/globalLongShortAccountRatio.ts +++ b/src/tools/binance-futures-usdm/market-api/globalLongShortAccountRatio.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/globalLongShortAccountRatio.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesGlobalLongShortAccountRatio(server: McpServer) { server.tool( @@ -37,8 +37,8 @@ export function registerBinanceFuturesGlobalLongShortAccountRatio(server: McpSer ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -47,9 +47,9 @@ export function registerBinanceFuturesGlobalLongShortAccountRatio(server: McpSer text: `Global long/short account ratio for ${params.symbol} (${params.period}): ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -59,8 +59,8 @@ export function registerBinanceFuturesGlobalLongShortAccountRatio(server: McpSer }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/market-api/historicalTrades.ts b/src/tools/binance-futures-usdm/market-api/historicalTrades.ts index 30a46efa..ecb1689e 100644 --- a/src/tools/binance-futures-usdm/market-api/historicalTrades.ts +++ b/src/tools/binance-futures-usdm/market-api/historicalTrades.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/historicalTrades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesHistoricalTrades(server: McpServer) { server.tool( @@ -26,8 +26,8 @@ export function registerBinanceFuturesHistoricalTrades(server: McpServer) { symbol: params.symbol, ...(params.limit && { limit: params.limit }), ...(params.fromId !== undefined && { fromId: params.fromId }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -36,15 +36,15 @@ export function registerBinanceFuturesHistoricalTrades(server: McpServer) { text: `Historical Futures Trades for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get historical trades: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/market-api/index.ts b/src/tools/binance-futures-usdm/market-api/index.ts index efd2f2e7..00e8ed46 100644 --- a/src/tools/binance-futures-usdm/market-api/index.ts +++ b/src/tools/binance-futures-usdm/market-api/index.ts @@ -5,73 +5,73 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceFuturesAggTrades } from "./aggTrades.js" -import { registerBinanceFuturesAssetIndex } from "./assetIndex.js" -import { registerBinanceFuturesContinuousKlines } from "./continuousKlines.js" -import { registerBinanceFuturesDepth } from "./depth.js" -import { registerBinanceFuturesExchangeInfo } from "./exchangeInfo.js" -import { registerBinanceFuturesFundingInfo } from "./fundingInfo.js" -import { registerBinanceFuturesFundingRate } from "./fundingRate.js" -import { registerBinanceFuturesGlobalLongShortAccountRatio } from "./globalLongShortAccountRatio.js" -import { registerBinanceFuturesHistoricalTrades } from "./historicalTrades.js" -import { registerBinanceFuturesIndexInfo } from "./indexInfo.js" -import { registerBinanceFuturesIndexPriceKlines } from "./indexPriceKlines.js" -import { registerBinanceFuturesKlines } from "./klines.js" -import { registerBinanceFuturesLvtKlines } from "./lvtKlines.js" -import { registerBinanceFuturesMarkPriceKlines } from "./markPriceKlines.js" -import { registerBinanceFuturesOpenInterest } from "./openInterest.js" -import { registerBinanceFuturesOpenInterestHist } from "./openInterestHist.js" -import { registerBinanceFuturesPing } from "./ping.js" -import { registerBinanceFuturesPremiumIndex } from "./premiumIndex.js" -import { registerBinanceFuturesTakerLongShortRatio } from "./takerLongShortRatio.js" -import { registerBinanceFuturesTicker24hr } from "./ticker24hr.js" -import { registerBinanceFuturesTickerBookTicker } from "./tickerBookTicker.js" -import { registerBinanceFuturesTickerPrice } from "./tickerPrice.js" -import { registerBinanceFuturesTime } from "./time.js" -import { registerBinanceFuturesTopLongShortAccountRatio } from "./topLongShortAccountRatio.js" -import { registerBinanceFuturesTopLongShortPositionRatio } from "./topLongShortPositionRatio.js" -import { registerBinanceFuturesTrades } from "./trades.js" +import { registerBinanceFuturesAggTrades } from "./aggTrades.js"; +import { registerBinanceFuturesAssetIndex } from "./assetIndex.js"; +import { registerBinanceFuturesContinuousKlines } from "./continuousKlines.js"; +import { registerBinanceFuturesDepth } from "./depth.js"; +import { registerBinanceFuturesExchangeInfo } from "./exchangeInfo.js"; +import { registerBinanceFuturesFundingInfo } from "./fundingInfo.js"; +import { registerBinanceFuturesFundingRate } from "./fundingRate.js"; +import { registerBinanceFuturesGlobalLongShortAccountRatio } from "./globalLongShortAccountRatio.js"; +import { registerBinanceFuturesHistoricalTrades } from "./historicalTrades.js"; +import { registerBinanceFuturesIndexInfo } from "./indexInfo.js"; +import { registerBinanceFuturesIndexPriceKlines } from "./indexPriceKlines.js"; +import { registerBinanceFuturesKlines } from "./klines.js"; +import { registerBinanceFuturesLvtKlines } from "./lvtKlines.js"; +import { registerBinanceFuturesMarkPriceKlines } from "./markPriceKlines.js"; +import { registerBinanceFuturesOpenInterest } from "./openInterest.js"; +import { registerBinanceFuturesOpenInterestHist } from "./openInterestHist.js"; +import { registerBinanceFuturesPing } from "./ping.js"; +import { registerBinanceFuturesPremiumIndex } from "./premiumIndex.js"; +import { registerBinanceFuturesTakerLongShortRatio } from "./takerLongShortRatio.js"; +import { registerBinanceFuturesTicker24hr } from "./ticker24hr.js"; +import { registerBinanceFuturesTickerBookTicker } from "./tickerBookTicker.js"; +import { registerBinanceFuturesTickerPrice } from "./tickerPrice.js"; +import { registerBinanceFuturesTime } from "./time.js"; +import { registerBinanceFuturesTopLongShortAccountRatio } from "./topLongShortAccountRatio.js"; +import { registerBinanceFuturesTopLongShortPositionRatio } from "./topLongShortPositionRatio.js"; +import { registerBinanceFuturesTrades } from "./trades.js"; export function registerBinanceFuturesMarketApiTools(server: McpServer) { // General - registerBinanceFuturesPing(server) - registerBinanceFuturesTime(server) - registerBinanceFuturesExchangeInfo(server) + registerBinanceFuturesPing(server); + registerBinanceFuturesTime(server); + registerBinanceFuturesExchangeInfo(server); // Market Data - registerBinanceFuturesDepth(server) - registerBinanceFuturesTrades(server) - registerBinanceFuturesHistoricalTrades(server) - registerBinanceFuturesAggTrades(server) + registerBinanceFuturesDepth(server); + registerBinanceFuturesTrades(server); + registerBinanceFuturesHistoricalTrades(server); + registerBinanceFuturesAggTrades(server); // Klines - registerBinanceFuturesKlines(server) - registerBinanceFuturesContinuousKlines(server) - registerBinanceFuturesIndexPriceKlines(server) - registerBinanceFuturesMarkPriceKlines(server) + registerBinanceFuturesKlines(server); + registerBinanceFuturesContinuousKlines(server); + registerBinanceFuturesIndexPriceKlines(server); + registerBinanceFuturesMarkPriceKlines(server); // Funding & Premium - registerBinanceFuturesPremiumIndex(server) - registerBinanceFuturesFundingRate(server) - registerBinanceFuturesFundingInfo(server) + registerBinanceFuturesPremiumIndex(server); + registerBinanceFuturesFundingRate(server); + registerBinanceFuturesFundingInfo(server); // Ticker - registerBinanceFuturesTicker24hr(server) - registerBinanceFuturesTickerPrice(server) - registerBinanceFuturesTickerBookTicker(server) + registerBinanceFuturesTicker24hr(server); + registerBinanceFuturesTickerPrice(server); + registerBinanceFuturesTickerBookTicker(server); // Open Interest & Analytics - registerBinanceFuturesOpenInterest(server) - registerBinanceFuturesOpenInterestHist(server) - registerBinanceFuturesTopLongShortAccountRatio(server) - registerBinanceFuturesTopLongShortPositionRatio(server) - registerBinanceFuturesGlobalLongShortAccountRatio(server) - registerBinanceFuturesTakerLongShortRatio(server) + registerBinanceFuturesOpenInterest(server); + registerBinanceFuturesOpenInterestHist(server); + registerBinanceFuturesTopLongShortAccountRatio(server); + registerBinanceFuturesTopLongShortPositionRatio(server); + registerBinanceFuturesGlobalLongShortAccountRatio(server); + registerBinanceFuturesTakerLongShortRatio(server); // Index - registerBinanceFuturesLvtKlines(server) - registerBinanceFuturesIndexInfo(server) - registerBinanceFuturesAssetIndex(server) + registerBinanceFuturesLvtKlines(server); + registerBinanceFuturesIndexInfo(server); + registerBinanceFuturesAssetIndex(server); } diff --git a/src/tools/binance-futures-usdm/market-api/indexInfo.ts b/src/tools/binance-futures-usdm/market-api/indexInfo.ts index 525de1d8..99fdd727 100644 --- a/src/tools/binance-futures-usdm/market-api/indexInfo.ts +++ b/src/tools/binance-futures-usdm/market-api/indexInfo.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/indexInfo.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesIndexInfo(server: McpServer) { server.tool( @@ -22,8 +22,8 @@ export function registerBinanceFuturesIndexInfo(server: McpServer) { try { const response = await futuresClient.restAPI.indexInfo({ ...(params.symbol && { symbol: params.symbol }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -32,15 +32,15 @@ export function registerBinanceFuturesIndexInfo(server: McpServer) { text: `Index info${params.symbol ? ` for ${params.symbol}` : ""}: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get index info: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/market-api/indexPriceKlines.ts b/src/tools/binance-futures-usdm/market-api/indexPriceKlines.ts index cb8db583..d5ef2692 100644 --- a/src/tools/binance-futures-usdm/market-api/indexPriceKlines.ts +++ b/src/tools/binance-futures-usdm/market-api/indexPriceKlines.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/indexPriceKlines.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesIndexPriceKlines(server: McpServer) { server.tool( @@ -48,8 +48,8 @@ export function registerBinanceFuturesIndexPriceKlines(server: McpServer) { ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -58,15 +58,15 @@ export function registerBinanceFuturesIndexPriceKlines(server: McpServer) { text: `Index Price Klines for ${params.pair}: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get index price klines: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/market-api/klines.ts b/src/tools/binance-futures-usdm/market-api/klines.ts index d5360b4f..aa44ba0d 100644 --- a/src/tools/binance-futures-usdm/market-api/klines.ts +++ b/src/tools/binance-futures-usdm/market-api/klines.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/klines.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesKlines(server: McpServer) { server.tool( @@ -48,8 +48,8 @@ export function registerBinanceFuturesKlines(server: McpServer) { ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -58,15 +58,15 @@ export function registerBinanceFuturesKlines(server: McpServer) { text: `Klines for ${params.symbol} (${params.interval}): ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get klines: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/market-api/lvtKlines.ts b/src/tools/binance-futures-usdm/market-api/lvtKlines.ts index 3c17df75..21b8d2cc 100644 --- a/src/tools/binance-futures-usdm/market-api/lvtKlines.ts +++ b/src/tools/binance-futures-usdm/market-api/lvtKlines.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/lvtKlines.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesLvtKlines(server: McpServer) { server.tool( @@ -53,8 +53,8 @@ export function registerBinanceFuturesLvtKlines(server: McpServer) { ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -63,15 +63,15 @@ export function registerBinanceFuturesLvtKlines(server: McpServer) { text: `LVT klines for ${params.symbol} (${params.interval}): ${Array.isArray(data) ? data.length : 0} candles. ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get LVT klines: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/market-api/markPriceKlines.ts b/src/tools/binance-futures-usdm/market-api/markPriceKlines.ts index 3c73a3ed..4cfbab5c 100644 --- a/src/tools/binance-futures-usdm/market-api/markPriceKlines.ts +++ b/src/tools/binance-futures-usdm/market-api/markPriceKlines.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/markPriceKlines.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesMarkPriceKlines(server: McpServer) { server.tool( @@ -48,8 +48,8 @@ export function registerBinanceFuturesMarkPriceKlines(server: McpServer) { ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -58,15 +58,15 @@ export function registerBinanceFuturesMarkPriceKlines(server: McpServer) { text: `Mark Price Klines for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get mark price klines: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/market-api/openInterest.ts b/src/tools/binance-futures-usdm/market-api/openInterest.ts index 0cfcb290..3371a0ca 100644 --- a/src/tools/binance-futures-usdm/market-api/openInterest.ts +++ b/src/tools/binance-futures-usdm/market-api/openInterest.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/openInterest.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesOpenInterest(server: McpServer) { server.tool( @@ -22,8 +22,8 @@ export function registerBinanceFuturesOpenInterest(server: McpServer) { try { const response = await futuresClient.restAPI.openInterest({ symbol: params.symbol, - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -32,15 +32,15 @@ export function registerBinanceFuturesOpenInterest(server: McpServer) { text: `Open interest for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get open interest: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/market-api/openInterestHist.ts b/src/tools/binance-futures-usdm/market-api/openInterestHist.ts index 060e1494..8a5378a6 100644 --- a/src/tools/binance-futures-usdm/market-api/openInterestHist.ts +++ b/src/tools/binance-futures-usdm/market-api/openInterestHist.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/openInterestHist.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesOpenInterestHist(server: McpServer) { server.tool( @@ -37,8 +37,8 @@ export function registerBinanceFuturesOpenInterestHist(server: McpServer) { ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -47,15 +47,15 @@ export function registerBinanceFuturesOpenInterestHist(server: McpServer) { text: `Historical open interest for ${params.symbol} (${params.period}): ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get open interest history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/market-api/ping.ts b/src/tools/binance-futures-usdm/market-api/ping.ts index 8f38b054..ae407443 100644 --- a/src/tools/binance-futures-usdm/market-api/ping.ts +++ b/src/tools/binance-futures-usdm/market-api/ping.ts @@ -5,9 +5,9 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/ping.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesPing(server: McpServer) { server.tool( @@ -16,8 +16,8 @@ export function registerBinanceFuturesPing(server: McpServer) { {}, async () => { try { - const response = await futuresClient.restAPI.ping() - const data = await response.data() + const response = await futuresClient.restAPI.ping(); + const data = await response.data(); return { content: [ @@ -26,15 +26,15 @@ export function registerBinanceFuturesPing(server: McpServer) { text: `Futures API connection successful: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Futures ping failed: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/market-api/premiumIndex.ts b/src/tools/binance-futures-usdm/market-api/premiumIndex.ts index ac98aa99..cd0bb2a0 100644 --- a/src/tools/binance-futures-usdm/market-api/premiumIndex.ts +++ b/src/tools/binance-futures-usdm/market-api/premiumIndex.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/premiumIndex.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesPremiumIndex(server: McpServer) { server.tool( @@ -25,8 +25,8 @@ export function registerBinanceFuturesPremiumIndex(server: McpServer) { try { const response = await futuresClient.restAPI.premiumIndex({ ...(params.symbol && { symbol: params.symbol }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -35,15 +35,15 @@ export function registerBinanceFuturesPremiumIndex(server: McpServer) { text: `Premium Index: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get premium index: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/market-api/takerLongShortRatio.ts b/src/tools/binance-futures-usdm/market-api/takerLongShortRatio.ts index c14f0b0f..fd421ee2 100644 --- a/src/tools/binance-futures-usdm/market-api/takerLongShortRatio.ts +++ b/src/tools/binance-futures-usdm/market-api/takerLongShortRatio.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/takerLongShortRatio.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesTakerLongShortRatio(server: McpServer) { server.tool( @@ -37,8 +37,8 @@ export function registerBinanceFuturesTakerLongShortRatio(server: McpServer) { ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -47,17 +47,17 @@ export function registerBinanceFuturesTakerLongShortRatio(server: McpServer) { text: `Taker long/short ratio for ${params.symbol} (${params.period}): ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to get taker long/short ratio: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/market-api/ticker24hr.ts b/src/tools/binance-futures-usdm/market-api/ticker24hr.ts index 0b7e6e30..59b30d9a 100644 --- a/src/tools/binance-futures-usdm/market-api/ticker24hr.ts +++ b/src/tools/binance-futures-usdm/market-api/ticker24hr.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/ticker24hr.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesTicker24hr(server: McpServer) { server.tool( @@ -22,8 +22,8 @@ export function registerBinanceFuturesTicker24hr(server: McpServer) { try { const response = await futuresClient.restAPI.ticker24hr({ ...(params.symbol && { symbol: params.symbol }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -32,15 +32,15 @@ export function registerBinanceFuturesTicker24hr(server: McpServer) { text: `24hr Ticker: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get 24hr ticker: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/market-api/tickerBookTicker.ts b/src/tools/binance-futures-usdm/market-api/tickerBookTicker.ts index 1be45af7..8da1b53d 100644 --- a/src/tools/binance-futures-usdm/market-api/tickerBookTicker.ts +++ b/src/tools/binance-futures-usdm/market-api/tickerBookTicker.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/tickerBookTicker.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesTickerBookTicker(server: McpServer) { server.tool( @@ -25,8 +25,8 @@ export function registerBinanceFuturesTickerBookTicker(server: McpServer) { try { const response = await futuresClient.restAPI.tickerBookTicker({ ...(params.symbol && { symbol: params.symbol }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -35,15 +35,15 @@ export function registerBinanceFuturesTickerBookTicker(server: McpServer) { text: `Book ticker${params.symbol ? ` for ${params.symbol}` : ""}: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get book ticker: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/market-api/tickerPrice.ts b/src/tools/binance-futures-usdm/market-api/tickerPrice.ts index 0ef5ec6e..3a2accaa 100644 --- a/src/tools/binance-futures-usdm/market-api/tickerPrice.ts +++ b/src/tools/binance-futures-usdm/market-api/tickerPrice.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/tickerPrice.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesTickerPrice(server: McpServer) { server.tool( @@ -22,8 +22,8 @@ export function registerBinanceFuturesTickerPrice(server: McpServer) { try { const response = await futuresClient.restAPI.tickerPrice({ ...(params.symbol && { symbol: params.symbol }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -32,15 +32,15 @@ export function registerBinanceFuturesTickerPrice(server: McpServer) { text: `Price Ticker: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get price ticker: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/market-api/time.ts b/src/tools/binance-futures-usdm/market-api/time.ts index 76b37ab6..59d450de 100644 --- a/src/tools/binance-futures-usdm/market-api/time.ts +++ b/src/tools/binance-futures-usdm/market-api/time.ts @@ -5,15 +5,15 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/time.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesTime(server: McpServer) { server.tool("BinanceFuturesTime", "Get current USD-M Futures server time.", {}, async () => { try { - const response = await futuresClient.restAPI.time() - const data = await response.data() + const response = await futuresClient.restAPI.time(); + const data = await response.data(); return { content: [ @@ -22,14 +22,14 @@ export function registerBinanceFuturesTime(server: McpServer) { text: `Futures server time: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get server time: ${errorMessage}` }], isError: true, - } + }; } - }) + }); } diff --git a/src/tools/binance-futures-usdm/market-api/topLongShortAccountRatio.ts b/src/tools/binance-futures-usdm/market-api/topLongShortAccountRatio.ts index 85c5b53c..e74d5201 100644 --- a/src/tools/binance-futures-usdm/market-api/topLongShortAccountRatio.ts +++ b/src/tools/binance-futures-usdm/market-api/topLongShortAccountRatio.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/topLongShortAccountRatio.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesTopLongShortAccountRatio(server: McpServer) { server.tool( @@ -37,8 +37,8 @@ export function registerBinanceFuturesTopLongShortAccountRatio(server: McpServer ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -47,17 +47,17 @@ export function registerBinanceFuturesTopLongShortAccountRatio(server: McpServer text: `Top traders long/short account ratio for ${params.symbol} (${params.period}): ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to get top long/short account ratio: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/market-api/topLongShortPositionRatio.ts b/src/tools/binance-futures-usdm/market-api/topLongShortPositionRatio.ts index 1d3a2839..53201415 100644 --- a/src/tools/binance-futures-usdm/market-api/topLongShortPositionRatio.ts +++ b/src/tools/binance-futures-usdm/market-api/topLongShortPositionRatio.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/topLongShortPositionRatio.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesTopLongShortPositionRatio(server: McpServer) { server.tool( @@ -37,8 +37,8 @@ export function registerBinanceFuturesTopLongShortPositionRatio(server: McpServe ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -47,17 +47,17 @@ export function registerBinanceFuturesTopLongShortPositionRatio(server: McpServe text: `Top traders long/short position ratio for ${params.symbol} (${params.period}): ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to get top long/short position ratio: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/market-api/trades.ts b/src/tools/binance-futures-usdm/market-api/trades.ts index c83993e7..e510f479 100644 --- a/src/tools/binance-futures-usdm/market-api/trades.ts +++ b/src/tools/binance-futures-usdm/market-api/trades.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/market-api/trades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesTrades(server: McpServer) { server.tool( @@ -28,8 +28,8 @@ export function registerBinanceFuturesTrades(server: McpServer) { const response = await futuresClient.restAPI.trades({ symbol: params.symbol, ...(params.limit && { limit: params.limit }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -38,15 +38,15 @@ export function registerBinanceFuturesTrades(server: McpServer) { text: `Recent Futures Trades for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get trades: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/multiAssetsMode.ts b/src/tools/binance-futures-usdm/multiAssetsMode.ts index 6efd42e8..910ea7b2 100644 --- a/src/tools/binance-futures-usdm/multiAssetsMode.ts +++ b/src/tools/binance-futures-usdm/multiAssetsMode.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/multiAssetsMode.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMMultiAssetsMode(server: McpServer) { server.tool( @@ -18,7 +18,7 @@ export function registerBinanceFuturesUSDMMultiAssetsMode(server: McpServer) { try { const data = await futuresClient.multiAssetsMargin({ multiAssetsMargin: multiAssetsMargin ? "true" : "false", - }) + }); return { content: [ @@ -27,9 +27,9 @@ export function registerBinanceFuturesUSDMMultiAssetsMode(server: McpServer) { text: `USD-M Futures multi-assets mode ${multiAssetsMargin ? "enabled" : "disabled"}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -39,8 +39,8 @@ export function registerBinanceFuturesUSDMMultiAssetsMode(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/newOrder.ts b/src/tools/binance-futures-usdm/newOrder.ts index 3ea2ab15..9d96435a 100644 --- a/src/tools/binance-futures-usdm/newOrder.ts +++ b/src/tools/binance-futures-usdm/newOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/newOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMNewOrder(server: McpServer) { server.tool( @@ -58,24 +58,24 @@ export function registerBinanceFuturesUSDMNewOrder(server: McpServer) { symbol: params.symbol, side: params.side, type: params.type, - } + }; - if (params.positionSide) requestParams.positionSide = params.positionSide - if (params.timeInForce) requestParams.timeInForce = params.timeInForce - if (params.quantity !== undefined) requestParams.quantity = params.quantity - if (params.reduceOnly !== undefined) requestParams.reduceOnly = params.reduceOnly - if (params.price !== undefined) requestParams.price = params.price - if (params.newClientOrderId) requestParams.newClientOrderId = params.newClientOrderId - if (params.stopPrice !== undefined) requestParams.stopPrice = params.stopPrice - if (params.closePosition !== undefined) requestParams.closePosition = params.closePosition + if (params.positionSide) requestParams.positionSide = params.positionSide; + if (params.timeInForce) requestParams.timeInForce = params.timeInForce; + if (params.quantity !== undefined) requestParams.quantity = params.quantity; + if (params.reduceOnly !== undefined) requestParams.reduceOnly = params.reduceOnly; + if (params.price !== undefined) requestParams.price = params.price; + if (params.newClientOrderId) requestParams.newClientOrderId = params.newClientOrderId; + if (params.stopPrice !== undefined) requestParams.stopPrice = params.stopPrice; + if (params.closePosition !== undefined) requestParams.closePosition = params.closePosition; if (params.activationPrice !== undefined) - requestParams.activationPrice = params.activationPrice - if (params.callbackRate !== undefined) requestParams.callbackRate = params.callbackRate - if (params.workingType) requestParams.workingType = params.workingType - if (params.priceProtect !== undefined) requestParams.priceProtect = params.priceProtect - if (params.newOrderRespType) requestParams.newOrderRespType = params.newOrderRespType + requestParams.activationPrice = params.activationPrice; + if (params.callbackRate !== undefined) requestParams.callbackRate = params.callbackRate; + if (params.workingType) requestParams.workingType = params.workingType; + if (params.priceProtect !== undefined) requestParams.priceProtect = params.priceProtect; + if (params.newOrderRespType) requestParams.newOrderRespType = params.newOrderRespType; - const data = await futuresClient.newOrder(requestParams) + const data = await futuresClient.newOrder(requestParams); return { content: [ @@ -84,17 +84,17 @@ export function registerBinanceFuturesUSDMNewOrder(server: McpServer) { text: `USD-M Futures order created successfully. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to create USD-M Futures order: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/openInterest.ts b/src/tools/binance-futures-usdm/openInterest.ts index 52281b3c..9fb53914 100644 --- a/src/tools/binance-futures-usdm/openInterest.ts +++ b/src/tools/binance-futures-usdm/openInterest.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/openInterest.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMOpenInterest(server: McpServer) { server.tool( @@ -14,7 +14,7 @@ export function registerBinanceFuturesUSDMOpenInterest(server: McpServer) { }, async ({ symbol }) => { try { - const data = await futuresClient.openInterest({ symbol }) + const data = await futuresClient.openInterest({ symbol }); return { content: [ @@ -23,9 +23,9 @@ export function registerBinanceFuturesUSDMOpenInterest(server: McpServer) { text: `Retrieved USD-M Futures open interest for ${symbol}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -35,8 +35,8 @@ export function registerBinanceFuturesUSDMOpenInterest(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/openOrders.ts b/src/tools/binance-futures-usdm/openOrders.ts index 746d70eb..1355f0b6 100644 --- a/src/tools/binance-futures-usdm/openOrders.ts +++ b/src/tools/binance-futures-usdm/openOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/openOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMOpenOrders(server: McpServer) { server.tool( @@ -19,10 +19,10 @@ export function registerBinanceFuturesUSDMOpenOrders(server: McpServer) { }, async ({ symbol }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol + const params: any = {}; + if (symbol) params.symbol = symbol; - const data = await futuresClient.openOrders(params) + const data = await futuresClient.openOrders(params); return { content: [ @@ -31,17 +31,17 @@ export function registerBinanceFuturesUSDMOpenOrders(server: McpServer) { text: `Retrieved USD-M Futures open orders${symbol ? ` for ${symbol}` : ""}. Count: ${data.length || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve USD-M Futures open orders: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/ping.ts b/src/tools/binance-futures-usdm/ping.ts index c41b23a0..2280f15f 100644 --- a/src/tools/binance-futures-usdm/ping.ts +++ b/src/tools/binance-futures-usdm/ping.ts @@ -1,7 +1,7 @@ // src/tools/binance-futures-usdm/ping.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMPing(server: McpServer) { server.tool( @@ -10,7 +10,7 @@ export function registerBinanceFuturesUSDMPing(server: McpServer) { {}, async () => { try { - const data = await futuresClient.ping() + const data = await futuresClient.ping(); return { content: [ @@ -19,15 +19,15 @@ export function registerBinanceFuturesUSDMPing(server: McpServer) { text: `USD-M Futures API connectivity test successful. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to ping USD-M Futures API: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/positionMargin.ts b/src/tools/binance-futures-usdm/positionMargin.ts index dd880fab..4cca6c71 100644 --- a/src/tools/binance-futures-usdm/positionMargin.ts +++ b/src/tools/binance-futures-usdm/positionMargin.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/positionMargin.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMPositionMargin(server: McpServer) { server.tool( @@ -20,10 +20,10 @@ export function registerBinanceFuturesUSDMPositionMargin(server: McpServer) { }, async ({ symbol, positionSide, amount, type }) => { try { - const params: any = { symbol, amount, type } - if (positionSide) params.positionSide = positionSide + const params: any = { symbol, amount, type }; + if (positionSide) params.positionSide = positionSide; - const data = await futuresClient.positionMargin(params) + const data = await futuresClient.positionMargin(params); return { content: [ @@ -32,9 +32,9 @@ export function registerBinanceFuturesUSDMPositionMargin(server: McpServer) { text: `USD-M Futures position margin modified for ${symbol}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -44,8 +44,8 @@ export function registerBinanceFuturesUSDMPositionMargin(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/positionMode.ts b/src/tools/binance-futures-usdm/positionMode.ts index 2f87e446..2514b1b9 100644 --- a/src/tools/binance-futures-usdm/positionMode.ts +++ b/src/tools/binance-futures-usdm/positionMode.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/positionMode.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMPositionMode(server: McpServer) { server.tool( @@ -16,7 +16,7 @@ export function registerBinanceFuturesUSDMPositionMode(server: McpServer) { try { const data = await futuresClient.changePositionMode({ dualSidePosition: dualSidePosition ? "true" : "false", - }) + }); return { content: [ @@ -25,17 +25,17 @@ export function registerBinanceFuturesUSDMPositionMode(server: McpServer) { text: `USD-M Futures position mode changed to ${dualSidePosition ? "Hedge Mode" : "One-way Mode"}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to change USD-M Futures position mode: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/positionRisk.ts b/src/tools/binance-futures-usdm/positionRisk.ts index ee6883a3..22d6a912 100644 --- a/src/tools/binance-futures-usdm/positionRisk.ts +++ b/src/tools/binance-futures-usdm/positionRisk.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/positionRisk.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMPositionRisk(server: McpServer) { server.tool( @@ -19,10 +19,10 @@ export function registerBinanceFuturesUSDMPositionRisk(server: McpServer) { }, async ({ symbol }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol + const params: any = {}; + if (symbol) params.symbol = symbol; - const data = await futuresClient.positionRisk(params) + const data = await futuresClient.positionRisk(params); return { content: [ @@ -31,9 +31,9 @@ export function registerBinanceFuturesUSDMPositionRisk(server: McpServer) { text: `Retrieved USD-M Futures position risk${symbol ? ` for ${symbol}` : " for all positions"}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -43,8 +43,8 @@ export function registerBinanceFuturesUSDMPositionRisk(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/premiumIndex.ts b/src/tools/binance-futures-usdm/premiumIndex.ts index 004051f4..a5fd5cc0 100644 --- a/src/tools/binance-futures-usdm/premiumIndex.ts +++ b/src/tools/binance-futures-usdm/premiumIndex.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/premiumIndex.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMPremiumIndex(server: McpServer) { server.tool( @@ -19,10 +19,10 @@ export function registerBinanceFuturesUSDMPremiumIndex(server: McpServer) { }, async ({ symbol }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol + const params: any = {}; + if (symbol) params.symbol = symbol; - const data = await futuresClient.premiumIndex(params) + const data = await futuresClient.premiumIndex(params); return { content: [ @@ -31,9 +31,9 @@ export function registerBinanceFuturesUSDMPremiumIndex(server: McpServer) { text: `Retrieved USD-M Futures premium index${symbol ? ` for ${symbol}` : " for all symbols"}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -43,8 +43,8 @@ export function registerBinanceFuturesUSDMPremiumIndex(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/ticker24hr.ts b/src/tools/binance-futures-usdm/ticker24hr.ts index a25a6b2b..72685c0f 100644 --- a/src/tools/binance-futures-usdm/ticker24hr.ts +++ b/src/tools/binance-futures-usdm/ticker24hr.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/ticker24hr.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMTicker24hr(server: McpServer) { server.tool( @@ -19,10 +19,10 @@ export function registerBinanceFuturesUSDMTicker24hr(server: McpServer) { }, async ({ symbol }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol + const params: any = {}; + if (symbol) params.symbol = symbol; - const data = await futuresClient.ticker24hr(params) + const data = await futuresClient.ticker24hr(params); return { content: [ @@ -31,17 +31,17 @@ export function registerBinanceFuturesUSDMTicker24hr(server: McpServer) { text: `Retrieved USD-M Futures 24hr ticker${symbol ? ` for ${symbol}` : " for all symbols"}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve USD-M Futures 24hr ticker: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/tickerPrice.ts b/src/tools/binance-futures-usdm/tickerPrice.ts index 898c990a..f77bd50d 100644 --- a/src/tools/binance-futures-usdm/tickerPrice.ts +++ b/src/tools/binance-futures-usdm/tickerPrice.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/tickerPrice.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMTickerPrice(server: McpServer) { server.tool( @@ -19,10 +19,10 @@ export function registerBinanceFuturesUSDMTickerPrice(server: McpServer) { }, async ({ symbol }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol + const params: any = {}; + if (symbol) params.symbol = symbol; - const data = await futuresClient.tickerPrice(params) + const data = await futuresClient.tickerPrice(params); return { content: [ @@ -31,9 +31,9 @@ export function registerBinanceFuturesUSDMTickerPrice(server: McpServer) { text: `Retrieved USD-M Futures ticker price${symbol ? ` for ${symbol}` : " for all symbols"}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -43,8 +43,8 @@ export function registerBinanceFuturesUSDMTickerPrice(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/time.ts b/src/tools/binance-futures-usdm/time.ts index c6c78781..a93084a7 100644 --- a/src/tools/binance-futures-usdm/time.ts +++ b/src/tools/binance-futures-usdm/time.ts @@ -1,7 +1,7 @@ // src/tools/binance-futures-usdm/time.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMTime(server: McpServer) { server.tool( @@ -10,7 +10,7 @@ export function registerBinanceFuturesUSDMTime(server: McpServer) { {}, async () => { try { - const data = await futuresClient.time() + const data = await futuresClient.time(); return { content: [ @@ -19,17 +19,17 @@ export function registerBinanceFuturesUSDMTime(server: McpServer) { text: `USD-M Futures server time: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to get USD-M Futures server time: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/trade-api/allOrders.ts b/src/tools/binance-futures-usdm/trade-api/allOrders.ts index fdac8a29..5b0f8af5 100644 --- a/src/tools/binance-futures-usdm/trade-api/allOrders.ts +++ b/src/tools/binance-futures-usdm/trade-api/allOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/allOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesAllOrders(server: McpServer) { server.tool( @@ -29,7 +29,7 @@ export function registerBinanceFuturesAllOrders(server: McpServer) { startTime: params.startTime, endTime: params.endTime, limit: params.limit, - }) + }); return { content: [ @@ -38,9 +38,9 @@ export function registerBinanceFuturesAllOrders(server: McpServer) { text: JSON.stringify(response.data, null, 2), }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : "Unknown error occurred" + const errorMessage = error instanceof Error ? error.message : "Unknown error occurred"; return { content: [ @@ -50,8 +50,8 @@ export function registerBinanceFuturesAllOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/trade-api/batchOrders.ts b/src/tools/binance-futures-usdm/trade-api/batchOrders.ts index 301c73eb..5f5135b6 100644 --- a/src/tools/binance-futures-usdm/trade-api/batchOrders.ts +++ b/src/tools/binance-futures-usdm/trade-api/batchOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/batchOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; const orderSchema = z.object({ symbol: z.string(), @@ -32,7 +32,7 @@ const orderSchema = z.object({ workingType: z.enum(["MARK_PRICE", "CONTRACT_PRICE"]).optional(), priceProtect: z.boolean().optional(), newClientOrderId: z.string().optional(), -}) +}); export function registerBinanceFuturesBatchOrders(server: McpServer) { server.tool( @@ -52,21 +52,21 @@ export function registerBinanceFuturesBatchOrders(server: McpServer) { const response = await futuresClient.restAPI.placeMultipleOrders({ batchOrders: JSON.stringify(params.batchOrders), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); const results = Array.isArray(data) ? data .map((order: any, index: number) => { if (order.orderId) { - return `Order ${index + 1}: ✅ ${order.symbol} ${order.side} ${order.type} - ID: ${order.orderId}` + return `Order ${index + 1}: ✅ ${order.symbol} ${order.side} ${order.type} - ID: ${order.orderId}`; } else { - return `Order ${index + 1}: ❌ Failed - ${order.msg || "Unknown error"}` + return `Order ${index + 1}: ❌ Failed - ${order.msg || "Unknown error"}`; } }) .join("\n") - : "Unexpected response format" + : "Unexpected response format"; return { content: [ @@ -75,9 +75,9 @@ export function registerBinanceFuturesBatchOrders(server: McpServer) { text: `Batch Order Results:\n${results}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -87,8 +87,8 @@ export function registerBinanceFuturesBatchOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/trade-api/cancelAllOpenOrders.ts b/src/tools/binance-futures-usdm/trade-api/cancelAllOpenOrders.ts index 2d5c598e..3f684db8 100644 --- a/src/tools/binance-futures-usdm/trade-api/cancelAllOpenOrders.ts +++ b/src/tools/binance-futures-usdm/trade-api/cancelAllOpenOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/cancelAllOpenOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesCancelAllOpenOrders(server: McpServer) { server.tool( @@ -20,7 +20,7 @@ export function registerBinanceFuturesCancelAllOpenOrders(server: McpServer) { }, async (params) => { try { - const response = await futuresClient.restAPI.cancelAllOpenOrders(params.symbol) + const response = await futuresClient.restAPI.cancelAllOpenOrders(params.symbol); return { content: [ @@ -29,9 +29,9 @@ export function registerBinanceFuturesCancelAllOpenOrders(server: McpServer) { text: JSON.stringify(response.data, null, 2), }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : "Unknown error occurred" + const errorMessage = error instanceof Error ? error.message : "Unknown error occurred"; return { content: [ @@ -41,8 +41,8 @@ export function registerBinanceFuturesCancelAllOpenOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/trade-api/cancelAllOrders.ts b/src/tools/binance-futures-usdm/trade-api/cancelAllOrders.ts index 95fd1200..21949562 100644 --- a/src/tools/binance-futures-usdm/trade-api/cancelAllOrders.ts +++ b/src/tools/binance-futures-usdm/trade-api/cancelAllOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/cancelAllOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesCancelAllOrders(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerBinanceFuturesCancelAllOrders(server: McpServer) { const response = await futuresClient.restAPI.cancelAllOpenOrders({ symbol: params.symbol, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,15 +35,15 @@ export function registerBinanceFuturesCancelAllOrders(server: McpServer) { text: `✅ All open orders cancelled for ${params.symbol}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to cancel all orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/trade-api/cancelBatchOrders.ts b/src/tools/binance-futures-usdm/trade-api/cancelBatchOrders.ts index 4791c76e..c7cfa7dc 100644 --- a/src/tools/binance-futures-usdm/trade-api/cancelBatchOrders.ts +++ b/src/tools/binance-futures-usdm/trade-api/cancelBatchOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/cancelBatchOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesCancelBatchOrders(server: McpServer) { server.tool( @@ -40,7 +40,7 @@ export function registerBinanceFuturesCancelBatchOrders(server: McpServer) { }, ], isError: true, - } + }; } const response = await futuresClient.restAPI.cancelMultipleOrders({ @@ -50,23 +50,23 @@ export function registerBinanceFuturesCancelBatchOrders(server: McpServer) { origClientOrderIdList: JSON.stringify(params.origClientOrderIdList), }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); const results = Array.isArray(data) ? data .map((order: any, index: number) => { if (order.orderId && order.status === "CANCELED") { - return `Order ${index + 1}: ✅ Cancelled - ID: ${order.orderId}` + return `Order ${index + 1}: ✅ Cancelled - ID: ${order.orderId}`; } else if (order.code) { - return `Order ${index + 1}: ❌ Failed - ${order.msg || "Unknown error"}` + return `Order ${index + 1}: ❌ Failed - ${order.msg || "Unknown error"}`; } else { - return `Order ${index + 1}: ${order.status} - ID: ${order.orderId}` + return `Order ${index + 1}: ${order.status} - ID: ${order.orderId}`; } }) .join("\n") - : "Unexpected response format" + : "Unexpected response format"; return { content: [ @@ -75,15 +75,15 @@ export function registerBinanceFuturesCancelBatchOrders(server: McpServer) { text: `Batch Cancel Results:\n${results}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to cancel batch orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/trade-api/cancelOrder.ts b/src/tools/binance-futures-usdm/trade-api/cancelOrder.ts index 345f39ff..4ca3a64e 100644 --- a/src/tools/binance-futures-usdm/trade-api/cancelOrder.ts +++ b/src/tools/binance-futures-usdm/trade-api/cancelOrder.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/cancelOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesCancelOrder(server: McpServer) { server.tool( @@ -29,7 +29,7 @@ export function registerBinanceFuturesCancelOrder(server: McpServer) { { type: "text", text: "Either orderId or origClientOrderId must be provided" }, ], isError: true, - } + }; } const response = await futuresClient.restAPI.cancelOrder({ @@ -37,9 +37,9 @@ export function registerBinanceFuturesCancelOrder(server: McpServer) { ...(params.orderId && { orderId: params.orderId }), ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -48,15 +48,15 @@ export function registerBinanceFuturesCancelOrder(server: McpServer) { text: `✅ Order cancelled successfully!\n\nSymbol: ${data.symbol}\nOrder ID: ${data.orderId}\nClient Order ID: ${data.clientOrderId}\nStatus: ${data.status}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to cancel order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/trade-api/changeLeverage.ts b/src/tools/binance-futures-usdm/trade-api/changeLeverage.ts index b2a44e20..add264f6 100644 --- a/src/tools/binance-futures-usdm/trade-api/changeLeverage.ts +++ b/src/tools/binance-futures-usdm/trade-api/changeLeverage.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/changeLeverage.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesChangeLeverage(server: McpServer) { server.tool( @@ -31,9 +31,9 @@ export function registerBinanceFuturesChangeLeverage(server: McpServer) { symbol: params.symbol, leverage: params.leverage, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -42,15 +42,15 @@ export function registerBinanceFuturesChangeLeverage(server: McpServer) { text: `✅ Leverage changed successfully!\n\nSymbol: ${data.symbol}\nNew Leverage: ${data.leverage}x\nMax Notional Value: ${data.maxNotionalValue}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to change leverage: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/trade-api/changeMarginType.ts b/src/tools/binance-futures-usdm/trade-api/changeMarginType.ts index 6dce1e71..57630489 100644 --- a/src/tools/binance-futures-usdm/trade-api/changeMarginType.ts +++ b/src/tools/binance-futures-usdm/trade-api/changeMarginType.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/changeMarginType.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesChangeMarginType(server: McpServer) { server.tool( @@ -30,9 +30,9 @@ export function registerBinanceFuturesChangeMarginType(server: McpServer) { symbol: params.symbol, marginType: params.marginType, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -41,15 +41,15 @@ export function registerBinanceFuturesChangeMarginType(server: McpServer) { text: `✅ Margin type changed successfully!\n\nSymbol: ${params.symbol}\nNew Margin Type: ${params.marginType}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to change margin type: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/trade-api/changeMultiAssetsMode.ts b/src/tools/binance-futures-usdm/trade-api/changeMultiAssetsMode.ts index 63682e8b..c3f9b3af 100644 --- a/src/tools/binance-futures-usdm/trade-api/changeMultiAssetsMode.ts +++ b/src/tools/binance-futures-usdm/trade-api/changeMultiAssetsMode.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/changeMultiAssetsMode.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesChangeMultiAssetsMode(server: McpServer) { server.tool( @@ -24,10 +24,10 @@ export function registerBinanceFuturesChangeMultiAssetsMode(server: McpServer) { const response = await futuresClient.restAPI.changeMultiAssetsMode({ multiAssetsMargin: params.multiAssetsMargin, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() - const mode = params.multiAssetsMargin ? "Enabled" : "Disabled" + const data = await response.data(); + const mode = params.multiAssetsMargin ? "Enabled" : "Disabled"; return { content: [ @@ -36,17 +36,17 @@ export function registerBinanceFuturesChangeMultiAssetsMode(server: McpServer) { text: `✅ Multi-Assets Mode ${mode}!\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `❌ Failed to change multi-assets mode: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/trade-api/changePositionMode.ts b/src/tools/binance-futures-usdm/trade-api/changePositionMode.ts index 0b5216d2..01db6f39 100644 --- a/src/tools/binance-futures-usdm/trade-api/changePositionMode.ts +++ b/src/tools/binance-futures-usdm/trade-api/changePositionMode.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/changePositionMode.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesChangePositionMode(server: McpServer) { server.tool( @@ -26,10 +26,10 @@ export function registerBinanceFuturesChangePositionMode(server: McpServer) { const response = await futuresClient.restAPI.changePositionMode({ dualSidePosition: params.dualSidePosition, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() - const mode = params.dualSidePosition ? "Hedge Mode (LONG/SHORT)" : "One-way Mode (BOTH)" + const data = await response.data(); + const mode = params.dualSidePosition ? "Hedge Mode (LONG/SHORT)" : "One-way Mode (BOTH)"; return { content: [ @@ -38,15 +38,15 @@ export function registerBinanceFuturesChangePositionMode(server: McpServer) { text: `✅ Position mode changed successfully!\n\nNew Mode: ${mode}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to change position mode: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/trade-api/countdownCancelAll.ts b/src/tools/binance-futures-usdm/trade-api/countdownCancelAll.ts index 5c66378e..83236b23 100644 --- a/src/tools/binance-futures-usdm/trade-api/countdownCancelAll.ts +++ b/src/tools/binance-futures-usdm/trade-api/countdownCancelAll.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/countdownCancelAll.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesCountdownCancelAll(server: McpServer) { server.tool( @@ -29,14 +29,14 @@ export function registerBinanceFuturesCountdownCancelAll(server: McpServer) { symbol: params.symbol, countdownTime: params.countdownTime, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); const message = params.countdownTime === 0 ? `✅ Countdown cancelled for ${params.symbol}` - : `✅ Countdown set for ${params.symbol}\nOrders will be cancelled in ${params.countdownTime}ms if no heartbeat received` + : `✅ Countdown set for ${params.symbol}\nOrders will be cancelled in ${params.countdownTime}ms if no heartbeat received`; return { content: [ @@ -45,15 +45,15 @@ export function registerBinanceFuturesCountdownCancelAll(server: McpServer) { text: `${message}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to set countdown: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/trade-api/getAllOrders.ts b/src/tools/binance-futures-usdm/trade-api/getAllOrders.ts index c9b9cf73..27d431dd 100644 --- a/src/tools/binance-futures-usdm/trade-api/getAllOrders.ts +++ b/src/tools/binance-futures-usdm/trade-api/getAllOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/getAllOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesGetAllOrders(server: McpServer) { server.tool( @@ -37,11 +37,11 @@ export function registerBinanceFuturesGetAllOrders(server: McpServer) { ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - const orderCount = Array.isArray(data) ? data.length : 0 + const orderCount = Array.isArray(data) ? data.length : 0; return { content: [ @@ -50,15 +50,15 @@ export function registerBinanceFuturesGetAllOrders(server: McpServer) { text: `All Orders for ${params.symbol}: ${orderCount} orders\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get all orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/trade-api/getOpenOrder.ts b/src/tools/binance-futures-usdm/trade-api/getOpenOrder.ts index de88b467..5e47b858 100644 --- a/src/tools/binance-futures-usdm/trade-api/getOpenOrder.ts +++ b/src/tools/binance-futures-usdm/trade-api/getOpenOrder.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/getOpenOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesGetOpenOrder(server: McpServer) { server.tool( @@ -29,7 +29,7 @@ export function registerBinanceFuturesGetOpenOrder(server: McpServer) { { type: "text", text: "Either orderId or origClientOrderId must be provided" }, ], isError: true, - } + }; } const response = await futuresClient.restAPI.queryCurrentOpenOrder({ @@ -37,9 +37,9 @@ export function registerBinanceFuturesGetOpenOrder(server: McpServer) { ...(params.orderId && { orderId: params.orderId }), ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -48,15 +48,15 @@ export function registerBinanceFuturesGetOpenOrder(server: McpServer) { text: `Open Order Details:\n\nSymbol: ${data.symbol}\nOrder ID: ${data.orderId}\nClient Order ID: ${data.clientOrderId}\nSide: ${data.side}\nType: ${data.type}\nStatus: ${data.status}\nPrice: ${data.price}\nQty: ${data.origQty}\nExecuted Qty: ${data.executedQty}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to query open order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/trade-api/getOpenOrders.ts b/src/tools/binance-futures-usdm/trade-api/getOpenOrders.ts index 1058133a..a6a1d8ed 100644 --- a/src/tools/binance-futures-usdm/trade-api/getOpenOrders.ts +++ b/src/tools/binance-futures-usdm/trade-api/getOpenOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/getOpenOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesGetOpenOrders(server: McpServer) { server.tool( @@ -27,11 +27,11 @@ export function registerBinanceFuturesGetOpenOrders(server: McpServer) { const response = await futuresClient.restAPI.currentAllOpenOrders({ ...(params.symbol && { symbol: params.symbol }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - const orderCount = Array.isArray(data) ? data.length : 0 + const orderCount = Array.isArray(data) ? data.length : 0; const orderSummary = Array.isArray(data) && data.length > 0 ? data @@ -40,7 +40,7 @@ export function registerBinanceFuturesGetOpenOrders(server: McpServer) { `${order.symbol} ${order.side} ${order.type} ${order.origQty}@${order.price} (ID: ${order.orderId})`, ) .join("\n") - : "No open orders" + : "No open orders"; return { content: [ @@ -49,15 +49,15 @@ export function registerBinanceFuturesGetOpenOrders(server: McpServer) { text: `Open Orders${params.symbol ? ` for ${params.symbol}` : ""}: ${orderCount}\n\n${orderSummary}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get open orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/trade-api/getOrder.ts b/src/tools/binance-futures-usdm/trade-api/getOrder.ts index 012487b1..53734951 100644 --- a/src/tools/binance-futures-usdm/trade-api/getOrder.ts +++ b/src/tools/binance-futures-usdm/trade-api/getOrder.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/getOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesGetOrder(server: McpServer) { server.tool( @@ -29,7 +29,7 @@ export function registerBinanceFuturesGetOrder(server: McpServer) { { type: "text", text: "Either orderId or origClientOrderId must be provided" }, ], isError: true, - } + }; } const response = await futuresClient.restAPI.queryOrder({ @@ -37,9 +37,9 @@ export function registerBinanceFuturesGetOrder(server: McpServer) { ...(params.orderId && { orderId: params.orderId }), ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -48,15 +48,15 @@ export function registerBinanceFuturesGetOrder(server: McpServer) { text: `Order Details:\n\nSymbol: ${data.symbol}\nOrder ID: ${data.orderId}\nClient Order ID: ${data.clientOrderId}\nSide: ${data.side}\nType: ${data.type}\nStatus: ${data.status}\nPrice: ${data.price}\nQty: ${data.origQty}\nExecuted Qty: ${data.executedQty}\nAvg Price: ${data.avgPrice}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to query order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/trade-api/index.ts b/src/tools/binance-futures-usdm/trade-api/index.ts index 22095479..39522866 100644 --- a/src/tools/binance-futures-usdm/trade-api/index.ts +++ b/src/tools/binance-futures-usdm/trade-api/index.ts @@ -5,51 +5,51 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceFuturesBatchOrders } from "./batchOrders.js" -import { registerBinanceFuturesCancelAllOrders } from "./cancelAllOrders.js" -import { registerBinanceFuturesCancelBatchOrders } from "./cancelBatchOrders.js" -import { registerBinanceFuturesCancelOrder } from "./cancelOrder.js" -import { registerBinanceFuturesChangeLeverage } from "./changeLeverage.js" -import { registerBinanceFuturesChangeMarginType } from "./changeMarginType.js" -import { registerBinanceFuturesChangeMultiAssetsMode } from "./changeMultiAssetsMode.js" -import { registerBinanceFuturesChangePositionMode } from "./changePositionMode.js" -import { registerBinanceFuturesCountdownCancelAll } from "./countdownCancelAll.js" -import { registerBinanceFuturesGetAllOrders } from "./getAllOrders.js" -import { registerBinanceFuturesGetOpenOrder } from "./getOpenOrder.js" -import { registerBinanceFuturesGetOpenOrders } from "./getOpenOrders.js" -import { registerBinanceFuturesGetOrder } from "./getOrder.js" -import { registerBinanceFuturesModifyIsolatedPositionMargin } from "./modifyIsolatedPositionMargin.js" -import { registerBinanceFuturesModifyOrder } from "./modifyOrder.js" -import { registerBinanceFuturesNewOrder } from "./newOrder.js" -import { registerBinanceFuturesPositionMarginHistory } from "./positionMarginHistory.js" +import { registerBinanceFuturesBatchOrders } from "./batchOrders.js"; +import { registerBinanceFuturesCancelAllOrders } from "./cancelAllOrders.js"; +import { registerBinanceFuturesCancelBatchOrders } from "./cancelBatchOrders.js"; +import { registerBinanceFuturesCancelOrder } from "./cancelOrder.js"; +import { registerBinanceFuturesChangeLeverage } from "./changeLeverage.js"; +import { registerBinanceFuturesChangeMarginType } from "./changeMarginType.js"; +import { registerBinanceFuturesChangeMultiAssetsMode } from "./changeMultiAssetsMode.js"; +import { registerBinanceFuturesChangePositionMode } from "./changePositionMode.js"; +import { registerBinanceFuturesCountdownCancelAll } from "./countdownCancelAll.js"; +import { registerBinanceFuturesGetAllOrders } from "./getAllOrders.js"; +import { registerBinanceFuturesGetOpenOrder } from "./getOpenOrder.js"; +import { registerBinanceFuturesGetOpenOrders } from "./getOpenOrders.js"; +import { registerBinanceFuturesGetOrder } from "./getOrder.js"; +import { registerBinanceFuturesModifyIsolatedPositionMargin } from "./modifyIsolatedPositionMargin.js"; +import { registerBinanceFuturesModifyOrder } from "./modifyOrder.js"; +import { registerBinanceFuturesNewOrder } from "./newOrder.js"; +import { registerBinanceFuturesPositionMarginHistory } from "./positionMarginHistory.js"; export function registerBinanceFuturesTradeApiTools(server: McpServer) { // Order Placement - registerBinanceFuturesNewOrder(server) - registerBinanceFuturesBatchOrders(server) - registerBinanceFuturesModifyOrder(server) + registerBinanceFuturesNewOrder(server); + registerBinanceFuturesBatchOrders(server); + registerBinanceFuturesModifyOrder(server); // Order Query - registerBinanceFuturesGetOrder(server) - registerBinanceFuturesGetOpenOrder(server) - registerBinanceFuturesGetOpenOrders(server) - registerBinanceFuturesGetAllOrders(server) + registerBinanceFuturesGetOrder(server); + registerBinanceFuturesGetOpenOrder(server); + registerBinanceFuturesGetOpenOrders(server); + registerBinanceFuturesGetAllOrders(server); // Order Cancellation - registerBinanceFuturesCancelOrder(server) - registerBinanceFuturesCancelAllOrders(server) - registerBinanceFuturesCancelBatchOrders(server) - registerBinanceFuturesCountdownCancelAll(server) + registerBinanceFuturesCancelOrder(server); + registerBinanceFuturesCancelAllOrders(server); + registerBinanceFuturesCancelBatchOrders(server); + registerBinanceFuturesCountdownCancelAll(server); // Leverage & Margin - registerBinanceFuturesChangeLeverage(server) - registerBinanceFuturesChangeMarginType(server) - registerBinanceFuturesModifyIsolatedPositionMargin(server) - registerBinanceFuturesPositionMarginHistory(server) + registerBinanceFuturesChangeLeverage(server); + registerBinanceFuturesChangeMarginType(server); + registerBinanceFuturesModifyIsolatedPositionMargin(server); + registerBinanceFuturesPositionMarginHistory(server); // Position & Asset Modes - registerBinanceFuturesChangePositionMode(server) - registerBinanceFuturesChangeMultiAssetsMode(server) + registerBinanceFuturesChangePositionMode(server); + registerBinanceFuturesChangeMultiAssetsMode(server); } diff --git a/src/tools/binance-futures-usdm/trade-api/modifyIsolatedPositionMargin.ts b/src/tools/binance-futures-usdm/trade-api/modifyIsolatedPositionMargin.ts index f141525d..cae00b4d 100644 --- a/src/tools/binance-futures-usdm/trade-api/modifyIsolatedPositionMargin.ts +++ b/src/tools/binance-futures-usdm/trade-api/modifyIsolatedPositionMargin.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/modifyIsolatedPositionMargin.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesModifyIsolatedPositionMargin(server: McpServer) { server.tool( @@ -33,10 +33,10 @@ export function registerBinanceFuturesModifyIsolatedPositionMargin(server: McpSe type: parseInt(params.type) as 1 | 2, ...(params.positionSide && { positionSide: params.positionSide }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() - const action = params.type === "1" ? "added to" : "reduced from" + const data = await response.data(); + const action = params.type === "1" ? "added to" : "reduced from"; return { content: [ @@ -45,17 +45,17 @@ export function registerBinanceFuturesModifyIsolatedPositionMargin(server: McpSe text: `✅ Margin ${action} position successfully!\n\nSymbol: ${params.symbol}\nAmount: ${params.amount}\nAction: ${params.type === "1" ? "Add" : "Reduce"}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `❌ Failed to modify isolated position margin: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/trade-api/modifyOrder.ts b/src/tools/binance-futures-usdm/trade-api/modifyOrder.ts index 45df2768..5d2d5a0b 100644 --- a/src/tools/binance-futures-usdm/trade-api/modifyOrder.ts +++ b/src/tools/binance-futures-usdm/trade-api/modifyOrder.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/modifyOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesModifyOrder(server: McpServer) { server.tool( @@ -45,7 +45,7 @@ export function registerBinanceFuturesModifyOrder(server: McpServer) { { type: "text", text: "Either orderId or origClientOrderId must be provided" }, ], isError: true, - } + }; } const response = await futuresClient.restAPI.modifyOrder({ @@ -57,9 +57,9 @@ export function registerBinanceFuturesModifyOrder(server: McpServer) { ...(params.price && { price: params.price }), ...(params.priceMatch && { priceMatch: params.priceMatch }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -68,15 +68,15 @@ export function registerBinanceFuturesModifyOrder(server: McpServer) { text: `✅ Order modified successfully!\n\nSymbol: ${data.symbol}\nOrder ID: ${data.orderId}\nSide: ${data.side}\nNew Price: ${data.price}\nNew Qty: ${data.origQty}\nStatus: ${data.status}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to modify order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/trade-api/newOrder.ts b/src/tools/binance-futures-usdm/trade-api/newOrder.ts index 39410830..02105af7 100644 --- a/src/tools/binance-futures-usdm/trade-api/newOrder.ts +++ b/src/tools/binance-futures-usdm/trade-api/newOrder.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/newOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesNewOrder(server: McpServer) { server.tool( @@ -84,9 +84,9 @@ export function registerBinanceFuturesNewOrder(server: McpServer) { ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), ...(params.newOrderRespType && { newOrderRespType: params.newOrderRespType }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -95,9 +95,9 @@ export function registerBinanceFuturesNewOrder(server: McpServer) { text: `✅ Futures order placed successfully!\n\nOrder ID: ${data.orderId}\nClient Order ID: ${data.clientOrderId}\nSymbol: ${data.symbol}\nSide: ${data.side}\nPosition Side: ${data.positionSide || "BOTH"}\nType: ${data.type}\nQuantity: ${data.origQty}\nPrice: ${data.price || "MARKET"}\nStop Price: ${data.stopPrice || "N/A"}\nStatus: ${data.status}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -107,8 +107,8 @@ export function registerBinanceFuturesNewOrder(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/trade-api/openOrder.ts b/src/tools/binance-futures-usdm/trade-api/openOrder.ts index f4ed0a83..24d4a8f3 100644 --- a/src/tools/binance-futures-usdm/trade-api/openOrder.ts +++ b/src/tools/binance-futures-usdm/trade-api/openOrder.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/openOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesOpenOrder(server: McpServer) { server.tool( @@ -31,13 +31,13 @@ export function registerBinanceFuturesOpenOrder(server: McpServer) { }, ], isError: true, - } + }; } const response = await futuresClient.restAPI.currentOpenOrder(params.symbol, { orderId: params.orderId, origClientOrderId: params.origClientOrderId, - }) + }); return { content: [ @@ -46,9 +46,9 @@ export function registerBinanceFuturesOpenOrder(server: McpServer) { text: JSON.stringify(response.data, null, 2), }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : "Unknown error occurred" + const errorMessage = error instanceof Error ? error.message : "Unknown error occurred"; return { content: [ @@ -58,8 +58,8 @@ export function registerBinanceFuturesOpenOrder(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/trade-api/openOrders.ts b/src/tools/binance-futures-usdm/trade-api/openOrders.ts index 3427b869..77849fa3 100644 --- a/src/tools/binance-futures-usdm/trade-api/openOrders.ts +++ b/src/tools/binance-futures-usdm/trade-api/openOrders.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/openOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesOpenOrders(server: McpServer) { server.tool( @@ -25,7 +25,7 @@ export function registerBinanceFuturesOpenOrders(server: McpServer) { try { const response = await futuresClient.restAPI.currentAllOpenOrders({ symbol: params.symbol, - }) + }); return { content: [ @@ -34,9 +34,9 @@ export function registerBinanceFuturesOpenOrders(server: McpServer) { text: JSON.stringify(response.data, null, 2), }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : "Unknown error occurred" + const errorMessage = error instanceof Error ? error.message : "Unknown error occurred"; return { content: [ @@ -46,8 +46,8 @@ export function registerBinanceFuturesOpenOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/trade-api/positionMarginHistory.ts b/src/tools/binance-futures-usdm/trade-api/positionMarginHistory.ts index b9803249..0bbcf451 100644 --- a/src/tools/binance-futures-usdm/trade-api/positionMarginHistory.ts +++ b/src/tools/binance-futures-usdm/trade-api/positionMarginHistory.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/trade-api/positionMarginHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesPositionMarginHistory(server: McpServer) { server.tool( @@ -32,9 +32,9 @@ export function registerBinanceFuturesPositionMarginHistory(server: McpServer) { ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -43,17 +43,17 @@ export function registerBinanceFuturesPositionMarginHistory(server: McpServer) { text: `📊 Position Margin History for ${params.symbol}\n\nRecords: ${Array.isArray(data) ? data.length : 0}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `❌ Failed to get position margin history: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/trades.ts b/src/tools/binance-futures-usdm/trades.ts index e5af8469..d12b9ce8 100644 --- a/src/tools/binance-futures-usdm/trades.ts +++ b/src/tools/binance-futures-usdm/trades.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/trades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMTrades(server: McpServer) { server.tool( @@ -15,10 +15,10 @@ export function registerBinanceFuturesUSDMTrades(server: McpServer) { }, async ({ symbol, limit }) => { try { - const params: any = { symbol } - if (limit !== undefined) params.limit = limit + const params: any = { symbol }; + if (limit !== undefined) params.limit = limit; - const data = await futuresClient.trades(params) + const data = await futuresClient.trades(params); return { content: [ @@ -27,9 +27,9 @@ export function registerBinanceFuturesUSDMTrades(server: McpServer) { text: `Retrieved ${data.length || 0} recent trades for USD-M Futures ${symbol}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -39,8 +39,8 @@ export function registerBinanceFuturesUSDMTrades(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/userTrades.ts b/src/tools/binance-futures-usdm/userTrades.ts index 5ad85a7a..56a8a4a5 100644 --- a/src/tools/binance-futures-usdm/userTrades.ts +++ b/src/tools/binance-futures-usdm/userTrades.ts @@ -1,9 +1,9 @@ // src/tools/binance-futures-usdm/userTrades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../config/binanceClient.js" +import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMUserTrades(server: McpServer) { server.tool( @@ -19,14 +19,14 @@ export function registerBinanceFuturesUSDMUserTrades(server: McpServer) { }, async ({ symbol, orderId, startTime, endTime, fromId, limit }) => { try { - const params: any = { symbol } - if (orderId !== undefined) params.orderId = orderId - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (fromId !== undefined) params.fromId = fromId - if (limit !== undefined) params.limit = limit + const params: any = { symbol }; + if (orderId !== undefined) params.orderId = orderId; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (fromId !== undefined) params.fromId = fromId; + if (limit !== undefined) params.limit = limit; - const data = await futuresClient.userTrades(params) + const data = await futuresClient.userTrades(params); return { content: [ @@ -35,17 +35,17 @@ export function registerBinanceFuturesUSDMUserTrades(server: McpServer) { text: `Retrieved ${data.length || 0} USD-M Futures trades for ${symbol}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve USD-M Futures user trades: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/userdatastream-api/closeListenKey.ts b/src/tools/binance-futures-usdm/userdatastream-api/closeListenKey.ts index f8e44c50..f2a263e3 100644 --- a/src/tools/binance-futures-usdm/userdatastream-api/closeListenKey.ts +++ b/src/tools/binance-futures-usdm/userdatastream-api/closeListenKey.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/userdatastream-api/closeListenKey.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesCloseListenKey(server: McpServer) { server.tool( @@ -27,9 +27,9 @@ export function registerBinanceFuturesCloseListenKey(server: McpServer) { const response = await futuresClient.restAPI.closeListenKey({ ...(params.listenKey && { listenKey: params.listenKey }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -38,15 +38,15 @@ export function registerBinanceFuturesCloseListenKey(server: McpServer) { text: `✅ Listen Key Closed!\n\nThe listen key has been invalidated and the stream is closed.\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to close listen key: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/userdatastream-api/createListenKey.ts b/src/tools/binance-futures-usdm/userdatastream-api/createListenKey.ts index 063510ef..a99098b4 100644 --- a/src/tools/binance-futures-usdm/userdatastream-api/createListenKey.ts +++ b/src/tools/binance-futures-usdm/userdatastream-api/createListenKey.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/userdatastream-api/createListenKey.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesCreateListenKey(server: McpServer) { server.tool( @@ -22,9 +22,9 @@ export function registerBinanceFuturesCreateListenKey(server: McpServer) { try { const response = await futuresClient.restAPI.createListenKey({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -33,15 +33,15 @@ export function registerBinanceFuturesCreateListenKey(server: McpServer) { text: `✅ Listen Key Created Successfully!\n\nListen Key: ${data.listenKey}\n\n⚠️ Important:\n- Valid for 60 minutes\n- Use keepAlive endpoint to extend validity\n- Use this key to connect to futures websocket stream\n\nWebSocket URL: wss://fstream.binance.com/ws/${data.listenKey}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to create listen key: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-futures-usdm/userdatastream-api/index.ts b/src/tools/binance-futures-usdm/userdatastream-api/index.ts index e2e06a69..9174f5c0 100644 --- a/src/tools/binance-futures-usdm/userdatastream-api/index.ts +++ b/src/tools/binance-futures-usdm/userdatastream-api/index.ts @@ -5,15 +5,15 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/userdatastream-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceFuturesCloseListenKey } from "./closeListenKey.js" -import { registerBinanceFuturesCreateListenKey } from "./createListenKey.js" -import { registerBinanceFuturesKeepAliveListenKey } from "./keepAliveListenKey.js" +import { registerBinanceFuturesCloseListenKey } from "./closeListenKey.js"; +import { registerBinanceFuturesCreateListenKey } from "./createListenKey.js"; +import { registerBinanceFuturesKeepAliveListenKey } from "./keepAliveListenKey.js"; export function registerBinanceFuturesUserDataStreamApiTools(server: McpServer) { // User Data Stream (Listen Key) Management - registerBinanceFuturesCreateListenKey(server) - registerBinanceFuturesKeepAliveListenKey(server) - registerBinanceFuturesCloseListenKey(server) + registerBinanceFuturesCreateListenKey(server); + registerBinanceFuturesKeepAliveListenKey(server); + registerBinanceFuturesCloseListenKey(server); } diff --git a/src/tools/binance-futures-usdm/userdatastream-api/keepAliveListenKey.ts b/src/tools/binance-futures-usdm/userdatastream-api/keepAliveListenKey.ts index 02362b47..2320049b 100644 --- a/src/tools/binance-futures-usdm/userdatastream-api/keepAliveListenKey.ts +++ b/src/tools/binance-futures-usdm/userdatastream-api/keepAliveListenKey.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-futures-usdm/userdatastream-api/keepAliveListenKey.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { futuresClient } from "../../../config/binanceClient.js" +import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesKeepAliveListenKey(server: McpServer) { server.tool( @@ -27,9 +27,9 @@ export function registerBinanceFuturesKeepAliveListenKey(server: McpServer) { const response = await futuresClient.restAPI.renewListenKey({ ...(params.listenKey && { listenKey: params.listenKey }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -38,15 +38,15 @@ export function registerBinanceFuturesKeepAliveListenKey(server: McpServer) { text: `✅ Listen Key Extended!\n\nThe listen key validity has been extended by 60 minutes.\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to keepalive listen key: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-gift-card/buyCode.ts b/src/tools/binance-gift-card/buyCode.ts index 586deff3..c7f7d0eb 100644 --- a/src/tools/binance-gift-card/buyCode.ts +++ b/src/tools/binance-gift-card/buyCode.ts @@ -1,9 +1,9 @@ // src/tools/binance-gift-card/buyCode.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { giftCardClient } from "../../config/binanceClient.js" +import { giftCardClient } from "../../config/binanceClient.js"; export function registerBinanceGiftCardBuyCode(server: McpServer) { server.tool( @@ -17,10 +17,10 @@ export function registerBinanceGiftCardBuyCode(server: McpServer) { }, async ({ baseToken, faceToken, baseTokenAmount, recvWindow }) => { try { - const params: Record = { baseToken, faceToken, baseTokenAmount } - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = { baseToken, faceToken, baseTokenAmount }; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await giftCardClient.buyCode(params) + const data = await giftCardClient.buyCode(params); return { content: [ @@ -29,15 +29,15 @@ export function registerBinanceGiftCardBuyCode(server: McpServer) { text: `Gift card purchased: ${baseTokenAmount} ${baseToken} -> ${faceToken}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to buy gift card: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-gift-card/createCode.ts b/src/tools/binance-gift-card/createCode.ts index a67137fa..9c1a6e81 100644 --- a/src/tools/binance-gift-card/createCode.ts +++ b/src/tools/binance-gift-card/createCode.ts @@ -1,9 +1,9 @@ // src/tools/binance-gift-card/createCode.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { giftCardClient } from "../../config/binanceClient.js" +import { giftCardClient } from "../../config/binanceClient.js"; export function registerBinanceGiftCardCreateCode(server: McpServer) { server.tool( @@ -16,10 +16,10 @@ export function registerBinanceGiftCardCreateCode(server: McpServer) { }, async ({ token, amount, recvWindow }) => { try { - const params: Record = { token, amount } - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = { token, amount }; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await giftCardClient.createCode(params) + const data = await giftCardClient.createCode(params); return { content: [ @@ -28,15 +28,15 @@ export function registerBinanceGiftCardCreateCode(server: McpServer) { text: `Gift card code created successfully for ${amount} ${token}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to create gift card code: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-gift-card/createDualTokenCode.ts b/src/tools/binance-gift-card/createDualTokenCode.ts index 045cbb53..8d559177 100644 --- a/src/tools/binance-gift-card/createDualTokenCode.ts +++ b/src/tools/binance-gift-card/createDualTokenCode.ts @@ -1,9 +1,9 @@ // src/tools/binance-gift-card/createDualTokenCode.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { giftCardClient } from "../../config/binanceClient.js" +import { giftCardClient } from "../../config/binanceClient.js"; export function registerBinanceGiftCardCreateDualTokenCode(server: McpServer) { server.tool( @@ -20,11 +20,11 @@ export function registerBinanceGiftCardCreateDualTokenCode(server: McpServer) { }, async ({ baseToken, faceToken, baseTokenAmount, discount, recvWindow }) => { try { - const params: Record = { baseToken, faceToken, baseTokenAmount } - if (discount !== undefined) params.discount = discount - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = { baseToken, faceToken, baseTokenAmount }; + if (discount !== undefined) params.discount = discount; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await giftCardClient.createDualTokenCode(params) + const data = await giftCardClient.createDualTokenCode(params); return { content: [ @@ -33,17 +33,17 @@ export function registerBinanceGiftCardCreateDualTokenCode(server: McpServer) { text: `Dual-token gift card created: ${baseTokenAmount} ${baseToken} -> ${faceToken}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to create dual-token gift card: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-gift-card/createDualTokenGiftCard.ts b/src/tools/binance-gift-card/createDualTokenGiftCard.ts index 529354e1..bb9eb2ca 100644 --- a/src/tools/binance-gift-card/createDualTokenGiftCard.ts +++ b/src/tools/binance-gift-card/createDualTokenGiftCard.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-gift-card/createDualTokenGiftCard.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { giftCardClient } from "../../config/binanceClient.js" +import { giftCardClient } from "../../config/binanceClient.js"; export function registerBinanceGiftCardCreateDualToken(server: McpServer) { server.tool( @@ -30,9 +30,9 @@ export function registerBinanceGiftCardCreateDualToken(server: McpServer) { baseTokenAmount: params.baseTokenAmount, ...(params.discount !== undefined && { discount: params.discount }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -41,17 +41,17 @@ export function registerBinanceGiftCardCreateDualToken(server: McpServer) { text: `✅ Dual-Token Gift Card Created!\n\nReference No: ${data.referenceNo}\nCode: ${data.code}\nPaid: ${params.baseTokenAmount} ${params.baseToken}\nRecipient Gets: ${data.faceTokenAmount || "N/A"} ${params.faceToken}\n\n⚠️ Keep the code secure!`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `❌ Failed to create dual-token gift card: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-gift-card/createGiftCard.ts b/src/tools/binance-gift-card/createGiftCard.ts index bb2fa89f..83320ad6 100644 --- a/src/tools/binance-gift-card/createGiftCard.ts +++ b/src/tools/binance-gift-card/createGiftCard.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-gift-card/createGiftCard.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { giftCardClient } from "../../config/binanceClient.js" +import { giftCardClient } from "../../config/binanceClient.js"; export function registerBinanceGiftCardCreate(server: McpServer) { server.tool( @@ -26,9 +26,9 @@ export function registerBinanceGiftCardCreate(server: McpServer) { token: params.token, amount: params.amount, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -37,15 +37,15 @@ export function registerBinanceGiftCardCreate(server: McpServer) { text: `✅ Gift Card Created!\n\nReference No: ${data.referenceNo}\nCode: ${data.code}\nToken: ${params.token}\nAmount: ${params.amount}\n\n⚠️ Keep the code secure! Anyone with the code can redeem it.`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to create gift card: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-gift-card/getTokenLimit.ts b/src/tools/binance-gift-card/getTokenLimit.ts index 641044b3..d6519370 100644 --- a/src/tools/binance-gift-card/getTokenLimit.ts +++ b/src/tools/binance-gift-card/getTokenLimit.ts @@ -1,9 +1,9 @@ // src/tools/binance-gift-card/getTokenLimit.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { giftCardClient } from "../../config/binanceClient.js" +import { giftCardClient } from "../../config/binanceClient.js"; export function registerBinanceGiftCardGetTokenLimit(server: McpServer) { server.tool( @@ -15,10 +15,10 @@ export function registerBinanceGiftCardGetTokenLimit(server: McpServer) { }, async ({ baseToken, recvWindow }) => { try { - const params: Record = { baseToken } - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = { baseToken }; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await giftCardClient.getTokenLimit(params) + const data = await giftCardClient.getTokenLimit(params); return { content: [ @@ -27,15 +27,15 @@ export function registerBinanceGiftCardGetTokenLimit(server: McpServer) { text: `Token limit for ${baseToken}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to fetch token limit: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-gift-card/index.ts b/src/tools/binance-gift-card/index.ts index 3b835aa5..48f11655 100644 --- a/src/tools/binance-gift-card/index.ts +++ b/src/tools/binance-gift-card/index.ts @@ -1,25 +1,25 @@ // src/tools/binance-gift-card/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGiftCardBuyCode } from "./buyCode.js" -import { registerBinanceGiftCardCreateCode } from "./createCode.js" -import { registerBinanceGiftCardCreateDualTokenCode } from "./createDualTokenCode.js" -import { registerBinanceGiftCardGetTokenLimit } from "./getTokenLimit.js" -import { registerBinanceGiftCardRedeemCode } from "./redeemCode.js" -import { registerBinanceGiftCardRsaPublicKey } from "./rsaPublicKey.js" -import { registerBinanceGiftCardVerify } from "./verify.js" +import { registerBinanceGiftCardBuyCode } from "./buyCode.js"; +import { registerBinanceGiftCardCreateCode } from "./createCode.js"; +import { registerBinanceGiftCardCreateDualTokenCode } from "./createDualTokenCode.js"; +import { registerBinanceGiftCardGetTokenLimit } from "./getTokenLimit.js"; +import { registerBinanceGiftCardRedeemCode } from "./redeemCode.js"; +import { registerBinanceGiftCardRsaPublicKey } from "./rsaPublicKey.js"; +import { registerBinanceGiftCardVerify } from "./verify.js"; export function registerBinanceGiftCardTools(server: McpServer) { // Create Gift Cards - registerBinanceGiftCardCreateCode(server) - registerBinanceGiftCardCreateDualTokenCode(server) - registerBinanceGiftCardBuyCode(server) + registerBinanceGiftCardCreateCode(server); + registerBinanceGiftCardCreateDualTokenCode(server); + registerBinanceGiftCardBuyCode(server); // Redeem & Verify - registerBinanceGiftCardRedeemCode(server) - registerBinanceGiftCardVerify(server) + registerBinanceGiftCardRedeemCode(server); + registerBinanceGiftCardVerify(server); // Utilities - registerBinanceGiftCardRsaPublicKey(server) - registerBinanceGiftCardGetTokenLimit(server) + registerBinanceGiftCardRsaPublicKey(server); + registerBinanceGiftCardGetTokenLimit(server); } diff --git a/src/tools/binance-gift-card/redeemCode.ts b/src/tools/binance-gift-card/redeemCode.ts index aa7f012c..2ab59318 100644 --- a/src/tools/binance-gift-card/redeemCode.ts +++ b/src/tools/binance-gift-card/redeemCode.ts @@ -1,9 +1,9 @@ // src/tools/binance-gift-card/redeemCode.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { giftCardClient } from "../../config/binanceClient.js" +import { giftCardClient } from "../../config/binanceClient.js"; export function registerBinanceGiftCardRedeemCode(server: McpServer) { server.tool( @@ -16,11 +16,11 @@ export function registerBinanceGiftCardRedeemCode(server: McpServer) { }, async ({ code, externalUid, recvWindow }) => { try { - const params: Record = { code } - if (externalUid !== undefined) params.externalUid = externalUid - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = { code }; + if (externalUid !== undefined) params.externalUid = externalUid; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await giftCardClient.redeemCode(params) + const data = await giftCardClient.redeemCode(params); return { content: [ @@ -29,15 +29,15 @@ export function registerBinanceGiftCardRedeemCode(server: McpServer) { text: `Gift card redeemed successfully. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to redeem gift card: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-gift-card/redeemDualTokenGiftCard.ts b/src/tools/binance-gift-card/redeemDualTokenGiftCard.ts index 6450bb81..bf933dd4 100644 --- a/src/tools/binance-gift-card/redeemDualTokenGiftCard.ts +++ b/src/tools/binance-gift-card/redeemDualTokenGiftCard.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-gift-card/redeemDualTokenGiftCard.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { giftCardClient } from "../../config/binanceClient.js" +import { giftCardClient } from "../../config/binanceClient.js"; export function registerBinanceGiftCardRedeemDualToken(server: McpServer) { server.tool( @@ -26,9 +26,9 @@ export function registerBinanceGiftCardRedeemDualToken(server: McpServer) { code: params.code, ...(params.externalUid && { externalUid: params.externalUid }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -37,17 +37,17 @@ export function registerBinanceGiftCardRedeemDualToken(server: McpServer) { text: `✅ Dual-Token Gift Card Redeemed!\n\nReference No: ${data.referenceNo}\nToken Received: ${data.token}\nAmount: ${data.amount}\n\nTokens have been credited to your spot wallet.`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `❌ Failed to redeem dual-token gift card: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-gift-card/redeemGiftCard.ts b/src/tools/binance-gift-card/redeemGiftCard.ts index 82b48867..e5d20d1b 100644 --- a/src/tools/binance-gift-card/redeemGiftCard.ts +++ b/src/tools/binance-gift-card/redeemGiftCard.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-gift-card/redeemGiftCard.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { giftCardClient } from "../../config/binanceClient.js" +import { giftCardClient } from "../../config/binanceClient.js"; export function registerBinanceGiftCardRedeem(server: McpServer) { server.tool( @@ -26,9 +26,9 @@ export function registerBinanceGiftCardRedeem(server: McpServer) { code: params.code, ...(params.externalUid && { externalUid: params.externalUid }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -37,15 +37,15 @@ export function registerBinanceGiftCardRedeem(server: McpServer) { text: `✅ Gift Card Redeemed!\n\nReference No: ${data.referenceNo}\nToken: ${data.token}\nAmount: ${data.amount}\n\nTokens have been credited to your spot wallet.`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to redeem gift card: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-gift-card/rsaPublicKey.ts b/src/tools/binance-gift-card/rsaPublicKey.ts index 9e901198..c50d4c4e 100644 --- a/src/tools/binance-gift-card/rsaPublicKey.ts +++ b/src/tools/binance-gift-card/rsaPublicKey.ts @@ -1,9 +1,9 @@ // src/tools/binance-gift-card/rsaPublicKey.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { giftCardClient } from "../../config/binanceClient.js" +import { giftCardClient } from "../../config/binanceClient.js"; export function registerBinanceGiftCardRsaPublicKey(server: McpServer) { server.tool( @@ -14,10 +14,10 @@ export function registerBinanceGiftCardRsaPublicKey(server: McpServer) { }, async ({ recvWindow }) => { try { - const params: Record = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await giftCardClient.rsaPublicKey(params) + const data = await giftCardClient.rsaPublicKey(params); return { content: [ @@ -26,15 +26,15 @@ export function registerBinanceGiftCardRsaPublicKey(server: McpServer) { text: `Retrieved RSA public key. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to fetch RSA public key: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-gift-card/tokenLimit.ts b/src/tools/binance-gift-card/tokenLimit.ts index fa6be31a..d4203e46 100644 --- a/src/tools/binance-gift-card/tokenLimit.ts +++ b/src/tools/binance-gift-card/tokenLimit.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-gift-card/tokenLimit.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { giftCardClient } from "../../config/binanceClient.js" +import { giftCardClient } from "../../config/binanceClient.js"; export function registerBinanceGiftCardTokenLimit(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerBinanceGiftCardTokenLimit(server: McpServer) { const response = await giftCardClient.restAPI.tokenLimit({ baseToken: params.baseToken, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,15 +35,15 @@ export function registerBinanceGiftCardTokenLimit(server: McpServer) { text: `📊 Gift Card Token Limits for ${params.baseToken}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get token limits: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-gift-card/verify.ts b/src/tools/binance-gift-card/verify.ts index 11b041c4..f05b7322 100644 --- a/src/tools/binance-gift-card/verify.ts +++ b/src/tools/binance-gift-card/verify.ts @@ -1,9 +1,9 @@ // src/tools/binance-gift-card/verify.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { giftCardClient } from "../../config/binanceClient.js" +import { giftCardClient } from "../../config/binanceClient.js"; export function registerBinanceGiftCardVerify(server: McpServer) { server.tool( @@ -15,10 +15,10 @@ export function registerBinanceGiftCardVerify(server: McpServer) { }, async ({ referenceNo, recvWindow }) => { try { - const params: Record = { referenceNo } - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = { referenceNo }; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await giftCardClient.verify(params) + const data = await giftCardClient.verify(params); return { content: [ @@ -27,15 +27,15 @@ export function registerBinanceGiftCardVerify(server: McpServer) { text: `Gift card verification result. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to verify gift card: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-gift-card/verifyGiftCard.ts b/src/tools/binance-gift-card/verifyGiftCard.ts index aab3770d..e2790824 100644 --- a/src/tools/binance-gift-card/verifyGiftCard.ts +++ b/src/tools/binance-gift-card/verifyGiftCard.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-gift-card/verifyGiftCard.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { giftCardClient } from "../../config/binanceClient.js" +import { giftCardClient } from "../../config/binanceClient.js"; export function registerBinanceGiftCardVerify(server: McpServer) { server.tool( @@ -24,13 +24,13 @@ export function registerBinanceGiftCardVerify(server: McpServer) { const response = await giftCardClient.restAPI.verify({ referenceNo: params.referenceNo, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); - let statusText = "Unknown" - if (data.valid === true) statusText = "✅ Valid" - else if (data.valid === false) statusText = "❌ Invalid/Used" + let statusText = "Unknown"; + if (data.valid === true) statusText = "✅ Valid"; + else if (data.valid === false) statusText = "❌ Invalid/Used"; return { content: [ @@ -39,15 +39,15 @@ export function registerBinanceGiftCardVerify(server: McpServer) { text: `🎁 Gift Card Verification\n\nReference No: ${params.referenceNo}\nStatus: ${statusText}\nToken: ${data.token || "N/A"}\nAmount: ${data.amount || "N/A"}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to verify gift card: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginAccount.ts b/src/tools/binance-margin/cross-margin-api/crossMarginAccount.ts index df82acca..f4d2c6f1 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginAccount.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginAccount.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/cross-margin-api/crossMarginAccount.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginAccount(server: McpServer) { server.tool( @@ -16,7 +16,7 @@ export function registerBinanceCrossMarginAccount(server: McpServer) { try { const data = await marginClient.getAccount({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -25,15 +25,15 @@ export function registerBinanceCrossMarginAccount(server: McpServer) { text: `Cross Margin Account Details: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to query account: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginAllAssets.ts b/src/tools/binance-margin/cross-margin-api/crossMarginAllAssets.ts index a288d23b..b810b1d3 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginAllAssets.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginAllAssets.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-margin/cross-margin-api/crossMarginAllAssets.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginAllAssets(server: McpServer) { server.tool( @@ -28,16 +28,16 @@ export function registerBinanceCrossMarginAllAssets(server: McpServer) { try { const response = await marginClient.restAPI.getAllCrossMarginPairs({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); // If specific asset requested, filter results - let result = data + let result = data; if (params.asset && Array.isArray(data)) { result = data.filter( (item: any) => item.base === params.asset || item.quote === params.asset, - ) + ); } return { @@ -47,15 +47,15 @@ export function registerBinanceCrossMarginAllAssets(server: McpServer) { text: `Cross Margin Assets: ${JSON.stringify(result, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to query cross margin assets: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginAllOrders.ts b/src/tools/binance-margin/cross-margin-api/crossMarginAllOrders.ts index a0e29503..aa73d933 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginAllOrders.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginAllOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/cross-margin-api/crossMarginAllOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginAllOrders(server: McpServer) { server.tool( @@ -28,7 +28,7 @@ export function registerBinanceCrossMarginAllOrders(server: McpServer) { ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -37,15 +37,15 @@ export function registerBinanceCrossMarginAllOrders(server: McpServer) { text: `All Margin Orders for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to query all orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginAvailableInventory.ts b/src/tools/binance-margin/cross-margin-api/crossMarginAvailableInventory.ts index 0a600504..967d61a6 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginAvailableInventory.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginAvailableInventory.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/cross-margin-api/crossMarginAvailableInventory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginAvailableInventory(server: McpServer) { server.tool( @@ -20,7 +20,7 @@ export function registerBinanceCrossMarginAvailableInventory(server: McpServer) const data = await marginClient.getAvailableInventory({ type: params.type, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -29,15 +29,15 @@ export function registerBinanceCrossMarginAvailableInventory(server: McpServer) text: `Margin Available Inventory: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to query available inventory: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginBorrow.ts b/src/tools/binance-margin/cross-margin-api/crossMarginBorrow.ts index cfb6d67d..683ca1ef 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginBorrow.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginBorrow.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/cross-margin-api/crossMarginBorrow.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginBorrow(server: McpServer) { server.tool( @@ -27,7 +27,7 @@ export function registerBinanceCrossMarginBorrow(server: McpServer) { ...(params.isIsolated && { isIsolated: params.isIsolated }), ...(params.symbol && { symbol: params.symbol }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -36,15 +36,15 @@ export function registerBinanceCrossMarginBorrow(server: McpServer) { text: `Successfully borrowed ${params.amount} ${params.asset} in Cross Margin. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to borrow: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginCancelAllOrders.ts b/src/tools/binance-margin/cross-margin-api/crossMarginCancelAllOrders.ts index f2e1ac9d..875b8d43 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginCancelAllOrders.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginCancelAllOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/cross-margin-api/crossMarginCancelAllOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginCancelAllOrders(server: McpServer) { server.tool( @@ -18,7 +18,7 @@ export function registerBinanceCrossMarginCancelAllOrders(server: McpServer) { const data = await marginClient.cancelAllOpenOrders({ symbol: params.symbol, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -27,15 +27,15 @@ export function registerBinanceCrossMarginCancelAllOrders(server: McpServer) { text: `All open margin orders cancelled for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to cancel all orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginCancelOrder.ts b/src/tools/binance-margin/cross-margin-api/crossMarginCancelOrder.ts index a52c53cd..e49a57b8 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginCancelOrder.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginCancelOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/cross-margin-api/crossMarginCancelOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginCancelOrder(server: McpServer) { server.tool( @@ -27,7 +27,7 @@ export function registerBinanceCrossMarginCancelOrder(server: McpServer) { ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -36,15 +36,15 @@ export function registerBinanceCrossMarginCancelOrder(server: McpServer) { text: `Margin order cancelled successfully: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to cancel margin order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginCapitalFlow.ts b/src/tools/binance-margin/cross-margin-api/crossMarginCapitalFlow.ts index 22ecb1e5..270cdfca 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginCapitalFlow.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginCapitalFlow.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/cross-margin-api/crossMarginCapitalFlow.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginCapitalFlow(server: McpServer) { server.tool( @@ -45,7 +45,7 @@ export function registerBinanceCrossMarginCapitalFlow(server: McpServer) { ...(params.fromId && { fromId: params.fromId }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -54,15 +54,15 @@ export function registerBinanceCrossMarginCapitalFlow(server: McpServer) { text: `Cross Margin Capital Flow: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get capital flow: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginDelist.ts b/src/tools/binance-margin/cross-margin-api/crossMarginDelist.ts index 84589947..5f24729e 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginDelist.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginDelist.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/cross-margin-api/crossMarginDelist.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginDelist(server: McpServer) { server.tool( @@ -16,7 +16,7 @@ export function registerBinanceCrossMarginDelist(server: McpServer) { try { const data = await marginClient.getDelistSchedule({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -25,15 +25,15 @@ export function registerBinanceCrossMarginDelist(server: McpServer) { text: `Cross Margin Delist Schedule: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get delist schedule: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginDustLog.ts b/src/tools/binance-margin/cross-margin-api/crossMarginDustLog.ts index 47896dd2..f19927b6 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginDustLog.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginDustLog.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/cross-margin-api/crossMarginDustLog.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginDustLog(server: McpServer) { server.tool( @@ -20,7 +20,7 @@ export function registerBinanceCrossMarginDustLog(server: McpServer) { ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -29,15 +29,15 @@ export function registerBinanceCrossMarginDustLog(server: McpServer) { text: `Margin Dust Log: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to query dust log: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginFee.ts b/src/tools/binance-margin/cross-margin-api/crossMarginFee.ts index 2a60cd2a..2050471a 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginFee.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginFee.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/cross-margin-api/crossMarginFee.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginFee(server: McpServer) { server.tool( @@ -24,7 +24,7 @@ export function registerBinanceCrossMarginFee(server: McpServer) { ...(params.vipLevel !== undefined && { vipLevel: params.vipLevel }), ...(params.coin && { coin: params.coin }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -33,15 +33,15 @@ export function registerBinanceCrossMarginFee(server: McpServer) { text: `Cross Margin Fee Data: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to query cross margin fee: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginForceLiquidationRec.ts b/src/tools/binance-margin/cross-margin-api/crossMarginForceLiquidationRec.ts index 5f3ffc60..675ba4ed 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginForceLiquidationRec.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginForceLiquidationRec.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/cross-margin-api/crossMarginForceLiquidationRec.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginForceLiquidationRec(server: McpServer) { server.tool( @@ -26,7 +26,7 @@ export function registerBinanceCrossMarginForceLiquidationRec(server: McpServer) ...(params.current && { current: params.current }), ...(params.size && { size: params.size }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -35,15 +35,15 @@ export function registerBinanceCrossMarginForceLiquidationRec(server: McpServer) text: `Force Liquidation Records: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get liquidation records: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginInterestHistory.ts b/src/tools/binance-margin/cross-margin-api/crossMarginInterestHistory.ts index e7ae5531..00c24200 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginInterestHistory.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginInterestHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/cross-margin-api/crossMarginInterestHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginInterestHistory(server: McpServer) { server.tool( @@ -30,7 +30,7 @@ export function registerBinanceCrossMarginInterestHistory(server: McpServer) { ...(params.size && { size: params.size }), ...(params.archived !== undefined && { archived: params.archived }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -39,15 +39,15 @@ export function registerBinanceCrossMarginInterestHistory(server: McpServer) { text: `Interest History: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to query interest history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginInterestRateHistory.ts b/src/tools/binance-margin/cross-margin-api/crossMarginInterestRateHistory.ts index a5337da6..874a8ffa 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginInterestRateHistory.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginInterestRateHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/cross-margin-api/crossMarginInterestRateHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginInterestRateHistory(server: McpServer) { server.tool( @@ -28,7 +28,7 @@ export function registerBinanceCrossMarginInterestRateHistory(server: McpServer) ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -37,17 +37,17 @@ export function registerBinanceCrossMarginInterestRateHistory(server: McpServer) text: `Margin Interest Rate History for ${params.asset}: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to query interest rate history: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginLoanRecord.ts b/src/tools/binance-margin/cross-margin-api/crossMarginLoanRecord.ts index b331c912..51ce3d28 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginLoanRecord.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginLoanRecord.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/cross-margin-api/crossMarginLoanRecord.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginLoanRecord(server: McpServer) { server.tool( @@ -32,7 +32,7 @@ export function registerBinanceCrossMarginLoanRecord(server: McpServer) { ...(params.size && { size: params.size }), ...(params.archived !== undefined && { archived: params.archived }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -41,15 +41,15 @@ export function registerBinanceCrossMarginLoanRecord(server: McpServer) { text: `Loan Records: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to query loan records: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginMaxBorrowable.ts b/src/tools/binance-margin/cross-margin-api/crossMarginMaxBorrowable.ts index 8fd2534e..7d27407b 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginMaxBorrowable.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginMaxBorrowable.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/cross-margin-api/crossMarginMaxBorrowable.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginMaxBorrowable(server: McpServer) { server.tool( @@ -20,7 +20,7 @@ export function registerBinanceCrossMarginMaxBorrowable(server: McpServer) { asset: params.asset, ...(params.isolatedSymbol && { isolatedSymbol: params.isolatedSymbol }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -29,15 +29,15 @@ export function registerBinanceCrossMarginMaxBorrowable(server: McpServer) { text: `Max Borrowable for ${params.asset}: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to query max borrowable: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginMaxTransferable.ts b/src/tools/binance-margin/cross-margin-api/crossMarginMaxTransferable.ts index d2565e0f..e1e7690c 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginMaxTransferable.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginMaxTransferable.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/cross-margin-api/crossMarginMaxTransferable.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginMaxTransferable(server: McpServer) { server.tool( @@ -20,7 +20,7 @@ export function registerBinanceCrossMarginMaxTransferable(server: McpServer) { asset: params.asset, ...(params.isolatedSymbol && { isolatedSymbol: params.isolatedSymbol }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -29,15 +29,15 @@ export function registerBinanceCrossMarginMaxTransferable(server: McpServer) { text: `Max Transferable for ${params.asset}: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to query max transferable: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginMyTrades.ts b/src/tools/binance-margin/cross-margin-api/crossMarginMyTrades.ts index 4ef22ca7..b832a576 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginMyTrades.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginMyTrades.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/cross-margin-api/crossMarginMyTrades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginMyTrades(server: McpServer) { server.tool( @@ -30,7 +30,7 @@ export function registerBinanceCrossMarginMyTrades(server: McpServer) { ...(params.fromId && { fromId: params.fromId }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -39,15 +39,15 @@ export function registerBinanceCrossMarginMyTrades(server: McpServer) { text: `Margin Trades for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to query trades: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginNewOrder.ts b/src/tools/binance-margin/cross-margin-api/crossMarginNewOrder.ts index c51804e3..5fe112f7 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginNewOrder.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginNewOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/cross-margin-api/crossMarginNewOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginNewOrder(server: McpServer) { server.tool( @@ -67,7 +67,7 @@ export function registerBinanceCrossMarginNewOrder(server: McpServer) { autoRepayAtCancel: params.autoRepayAtCancel, }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -76,15 +76,15 @@ export function registerBinanceCrossMarginNewOrder(server: McpServer) { text: `Cross Margin order placed successfully: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to place margin order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginOpenOrders.ts b/src/tools/binance-margin/cross-margin-api/crossMarginOpenOrders.ts index 2d1e258c..ced9ca76 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginOpenOrders.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginOpenOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/cross-margin-api/crossMarginOpenOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginOpenOrders(server: McpServer) { server.tool( @@ -20,7 +20,7 @@ export function registerBinanceCrossMarginOpenOrders(server: McpServer) { ...(params.symbol && { symbol: params.symbol }), ...(params.isIsolated && { isIsolated: params.isIsolated }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -29,15 +29,15 @@ export function registerBinanceCrossMarginOpenOrders(server: McpServer) { text: `Open Margin Orders: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to query open orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginPairs.ts b/src/tools/binance-margin/cross-margin-api/crossMarginPairs.ts index dffea1c1..176cf8d6 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginPairs.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginPairs.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/cross-margin-api/crossMarginPairs.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginPairs(server: McpServer) { server.tool( @@ -16,7 +16,7 @@ export function registerBinanceCrossMarginPairs(server: McpServer) { try { const data = await marginClient.getAllPairs({ ...(params.symbol && { symbol: params.symbol }), - }) + }); return { content: [ @@ -25,15 +25,15 @@ export function registerBinanceCrossMarginPairs(server: McpServer) { text: `Cross Margin Pairs: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get cross margin pairs: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginPriceIndex.ts b/src/tools/binance-margin/cross-margin-api/crossMarginPriceIndex.ts index 8f7318e4..8a018fd6 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginPriceIndex.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginPriceIndex.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/cross-margin-api/crossMarginPriceIndex.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginPriceIndex(server: McpServer) { server.tool( @@ -16,7 +16,7 @@ export function registerBinanceCrossMarginPriceIndex(server: McpServer) { try { const data = await marginClient.getPriceIndex({ symbol: params.symbol, - }) + }); return { content: [ @@ -25,15 +25,15 @@ export function registerBinanceCrossMarginPriceIndex(server: McpServer) { text: `Margin Price Index for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to query price index: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginRepay.ts b/src/tools/binance-margin/cross-margin-api/crossMarginRepay.ts index f6775e39..d1a812d5 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginRepay.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginRepay.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/cross-margin-api/crossMarginRepay.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginRepay(server: McpServer) { server.tool( @@ -27,7 +27,7 @@ export function registerBinanceCrossMarginRepay(server: McpServer) { ...(params.isIsolated && { isIsolated: params.isIsolated }), ...(params.symbol && { symbol: params.symbol }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -36,15 +36,15 @@ export function registerBinanceCrossMarginRepay(server: McpServer) { text: `Successfully repaid ${params.amount} ${params.asset} in Cross Margin. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to repay: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginRepayRecord.ts b/src/tools/binance-margin/cross-margin-api/crossMarginRepayRecord.ts index da30984c..e436b400 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginRepayRecord.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginRepayRecord.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/cross-margin-api/crossMarginRepayRecord.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginRepayRecord(server: McpServer) { server.tool( @@ -32,7 +32,7 @@ export function registerBinanceCrossMarginRepayRecord(server: McpServer) { ...(params.size && { size: params.size }), ...(params.archived !== undefined && { archived: params.archived }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -41,15 +41,15 @@ export function registerBinanceCrossMarginRepayRecord(server: McpServer) { text: `Repay Records: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to query repay records: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginSmallLiabilityExchange.ts b/src/tools/binance-margin/cross-margin-api/crossMarginSmallLiabilityExchange.ts index dc53017d..bd660b2f 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginSmallLiabilityExchange.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginSmallLiabilityExchange.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/cross-margin-api/crossMarginSmallLiabilityExchange.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginSmallLiabilityExchange(server: McpServer) { server.tool( @@ -20,7 +20,7 @@ export function registerBinanceCrossMarginSmallLiabilityExchange(server: McpServ const data = await marginClient.smallLiabilityExchange({ assetNames: params.assetNames.join(","), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -29,15 +29,15 @@ export function registerBinanceCrossMarginSmallLiabilityExchange(server: McpServ text: `Small liability exchange completed: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to exchange small liability: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginSmallLiabilityExchangeHistory.ts b/src/tools/binance-margin/cross-margin-api/crossMarginSmallLiabilityExchangeHistory.ts index c773bea5..a36f7b0a 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginSmallLiabilityExchangeHistory.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginSmallLiabilityExchangeHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/cross-margin-api/crossMarginSmallLiabilityExchangeHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginSmallLiabilityExchangeHistory(server: McpServer) { server.tool( @@ -24,7 +24,7 @@ export function registerBinanceCrossMarginSmallLiabilityExchangeHistory(server: ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -33,15 +33,15 @@ export function registerBinanceCrossMarginSmallLiabilityExchangeHistory(server: text: `Small Liability Exchange History: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get exchange history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginTransfer.ts b/src/tools/binance-margin/cross-margin-api/crossMarginTransfer.ts index e1686f80..b63dc852 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginTransfer.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginTransfer.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/cross-margin-api/crossMarginTransfer.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginTransfer(server: McpServer) { server.tool( @@ -22,7 +22,7 @@ export function registerBinanceCrossMarginTransfer(server: McpServer) { amount: params.amount, type: parseInt(params.type), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -31,15 +31,15 @@ export function registerBinanceCrossMarginTransfer(server: McpServer) { text: `Successfully transferred ${params.amount} ${params.asset}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to transfer: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/cross-margin-api/index.ts b/src/tools/binance-margin/cross-margin-api/index.ts index 66bfeb26..f968dc63 100644 --- a/src/tools/binance-margin/cross-margin-api/index.ts +++ b/src/tools/binance-margin/cross-margin-api/index.ts @@ -1,69 +1,69 @@ // src/tools/binance-margin/cross-margin-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceCrossMarginAccount } from "./crossMarginAccount.js" -import { registerBinanceCrossMarginAllOrders } from "./crossMarginAllOrders.js" -import { registerBinanceCrossMarginAvailableInventory } from "./crossMarginAvailableInventory.js" -import { registerBinanceCrossMarginBorrow } from "./crossMarginBorrow.js" -import { registerBinanceCrossMarginCancelAllOrders } from "./crossMarginCancelAllOrders.js" -import { registerBinanceCrossMarginCancelOrder } from "./crossMarginCancelOrder.js" -import { registerBinanceCrossMarginCapitalFlow } from "./crossMarginCapitalFlow.js" -import { registerBinanceCrossMarginDelist } from "./crossMarginDelist.js" -import { registerBinanceCrossMarginDustLog } from "./crossMarginDustLog.js" -import { registerBinanceCrossMarginFee } from "./crossMarginFee.js" -import { registerBinanceCrossMarginForceLiquidationRec } from "./crossMarginForceLiquidationRec.js" -import { registerBinanceCrossMarginInterestHistory } from "./crossMarginInterestHistory.js" -import { registerBinanceCrossMarginInterestRateHistory } from "./crossMarginInterestRateHistory.js" -import { registerBinanceCrossMarginLoanRecord } from "./crossMarginLoanRecord.js" -import { registerBinanceCrossMarginMaxBorrowable } from "./crossMarginMaxBorrowable.js" -import { registerBinanceCrossMarginMaxTransferable } from "./crossMarginMaxTransferable.js" -import { registerBinanceCrossMarginMyTrades } from "./crossMarginMyTrades.js" -import { registerBinanceCrossMarginNewOrder } from "./crossMarginNewOrder.js" -import { registerBinanceCrossMarginOpenOrders } from "./crossMarginOpenOrders.js" -import { registerBinanceCrossMarginPairs } from "./crossMarginPairs.js" -import { registerBinanceCrossMarginPriceIndex } from "./crossMarginPriceIndex.js" -import { registerBinanceCrossMarginRepay } from "./crossMarginRepay.js" -import { registerBinanceCrossMarginRepayRecord } from "./crossMarginRepayRecord.js" -import { registerBinanceCrossMarginSmallLiabilityExchange } from "./crossMarginSmallLiabilityExchange.js" -import { registerBinanceCrossMarginSmallLiabilityExchangeHistory } from "./crossMarginSmallLiabilityExchangeHistory.js" -import { registerBinanceCrossMarginTransfer } from "./crossMarginTransfer.js" +import { registerBinanceCrossMarginAccount } from "./crossMarginAccount.js"; +import { registerBinanceCrossMarginAllOrders } from "./crossMarginAllOrders.js"; +import { registerBinanceCrossMarginAvailableInventory } from "./crossMarginAvailableInventory.js"; +import { registerBinanceCrossMarginBorrow } from "./crossMarginBorrow.js"; +import { registerBinanceCrossMarginCancelAllOrders } from "./crossMarginCancelAllOrders.js"; +import { registerBinanceCrossMarginCancelOrder } from "./crossMarginCancelOrder.js"; +import { registerBinanceCrossMarginCapitalFlow } from "./crossMarginCapitalFlow.js"; +import { registerBinanceCrossMarginDelist } from "./crossMarginDelist.js"; +import { registerBinanceCrossMarginDustLog } from "./crossMarginDustLog.js"; +import { registerBinanceCrossMarginFee } from "./crossMarginFee.js"; +import { registerBinanceCrossMarginForceLiquidationRec } from "./crossMarginForceLiquidationRec.js"; +import { registerBinanceCrossMarginInterestHistory } from "./crossMarginInterestHistory.js"; +import { registerBinanceCrossMarginInterestRateHistory } from "./crossMarginInterestRateHistory.js"; +import { registerBinanceCrossMarginLoanRecord } from "./crossMarginLoanRecord.js"; +import { registerBinanceCrossMarginMaxBorrowable } from "./crossMarginMaxBorrowable.js"; +import { registerBinanceCrossMarginMaxTransferable } from "./crossMarginMaxTransferable.js"; +import { registerBinanceCrossMarginMyTrades } from "./crossMarginMyTrades.js"; +import { registerBinanceCrossMarginNewOrder } from "./crossMarginNewOrder.js"; +import { registerBinanceCrossMarginOpenOrders } from "./crossMarginOpenOrders.js"; +import { registerBinanceCrossMarginPairs } from "./crossMarginPairs.js"; +import { registerBinanceCrossMarginPriceIndex } from "./crossMarginPriceIndex.js"; +import { registerBinanceCrossMarginRepay } from "./crossMarginRepay.js"; +import { registerBinanceCrossMarginRepayRecord } from "./crossMarginRepayRecord.js"; +import { registerBinanceCrossMarginSmallLiabilityExchange } from "./crossMarginSmallLiabilityExchange.js"; +import { registerBinanceCrossMarginSmallLiabilityExchangeHistory } from "./crossMarginSmallLiabilityExchangeHistory.js"; +import { registerBinanceCrossMarginTransfer } from "./crossMarginTransfer.js"; export function registerBinanceCrossMarginTools(server: McpServer) { // Borrow & Repay - registerBinanceCrossMarginBorrow(server) - registerBinanceCrossMarginRepay(server) + registerBinanceCrossMarginBorrow(server); + registerBinanceCrossMarginRepay(server); // Account & Transfer - registerBinanceCrossMarginAccount(server) - registerBinanceCrossMarginTransfer(server) - registerBinanceCrossMarginCapitalFlow(server) + registerBinanceCrossMarginAccount(server); + registerBinanceCrossMarginTransfer(server); + registerBinanceCrossMarginCapitalFlow(server); // Records & History - registerBinanceCrossMarginInterestHistory(server) - registerBinanceCrossMarginLoanRecord(server) - registerBinanceCrossMarginRepayRecord(server) - registerBinanceCrossMarginInterestRateHistory(server) - registerBinanceCrossMarginForceLiquidationRec(server) + registerBinanceCrossMarginInterestHistory(server); + registerBinanceCrossMarginLoanRecord(server); + registerBinanceCrossMarginRepayRecord(server); + registerBinanceCrossMarginInterestRateHistory(server); + registerBinanceCrossMarginForceLiquidationRec(server); // Limits & Info - registerBinanceCrossMarginMaxBorrowable(server) - registerBinanceCrossMarginMaxTransferable(server) - registerBinanceCrossMarginPairs(server) - registerBinanceCrossMarginPriceIndex(server) - registerBinanceCrossMarginFee(server) - registerBinanceCrossMarginAvailableInventory(server) - registerBinanceCrossMarginDelist(server) + registerBinanceCrossMarginMaxBorrowable(server); + registerBinanceCrossMarginMaxTransferable(server); + registerBinanceCrossMarginPairs(server); + registerBinanceCrossMarginPriceIndex(server); + registerBinanceCrossMarginFee(server); + registerBinanceCrossMarginAvailableInventory(server); + registerBinanceCrossMarginDelist(server); // Trading - registerBinanceCrossMarginNewOrder(server) - registerBinanceCrossMarginCancelOrder(server) - registerBinanceCrossMarginCancelAllOrders(server) - registerBinanceCrossMarginOpenOrders(server) - registerBinanceCrossMarginAllOrders(server) - registerBinanceCrossMarginMyTrades(server) + registerBinanceCrossMarginNewOrder(server); + registerBinanceCrossMarginCancelOrder(server); + registerBinanceCrossMarginCancelAllOrders(server); + registerBinanceCrossMarginOpenOrders(server); + registerBinanceCrossMarginAllOrders(server); + registerBinanceCrossMarginMyTrades(server); // Other - registerBinanceCrossMarginDustLog(server) - registerBinanceCrossMarginSmallLiabilityExchange(server) - registerBinanceCrossMarginSmallLiabilityExchangeHistory(server) + registerBinanceCrossMarginDustLog(server); + registerBinanceCrossMarginSmallLiabilityExchange(server); + registerBinanceCrossMarginSmallLiabilityExchangeHistory(server); } diff --git a/src/tools/binance-margin/index.ts b/src/tools/binance-margin/index.ts index 1783b0d2..462e8a61 100644 --- a/src/tools/binance-margin/index.ts +++ b/src/tools/binance-margin/index.ts @@ -1,13 +1,13 @@ // src/tools/binance-margin/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceCrossMarginTools } from "./cross-margin-api/index.js" -import { registerBinanceIsolatedMarginTools } from "./isolated-margin-api/index.js" +import { registerBinanceCrossMarginTools } from "./cross-margin-api/index.js"; +import { registerBinanceIsolatedMarginTools } from "./isolated-margin-api/index.js"; export function registerBinanceMarginTools(server: McpServer) { // Cross Margin API tools - registerBinanceCrossMarginTools(server) + registerBinanceCrossMarginTools(server); // Isolated Margin API tools - registerBinanceIsolatedMarginTools(server) + registerBinanceIsolatedMarginTools(server); } diff --git a/src/tools/binance-margin/isolated-margin-api/disableIsolatedMarginAccount.ts b/src/tools/binance-margin/isolated-margin-api/disableIsolatedMarginAccount.ts index 8db93201..5f24242a 100644 --- a/src/tools/binance-margin/isolated-margin-api/disableIsolatedMarginAccount.ts +++ b/src/tools/binance-margin/isolated-margin-api/disableIsolatedMarginAccount.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-margin/isolated-margin-api/disableIsolatedMarginAccount.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceDisableIsolatedMarginAccount(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerBinanceDisableIsolatedMarginAccount(server: McpServer) { const response = await marginClient.restAPI.disableIsolatedMarginAccount({ symbol: params.symbol, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,15 +35,15 @@ export function registerBinanceDisableIsolatedMarginAccount(server: McpServer) { text: `Isolated margin account disabled for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to disable isolated margin: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/isolated-margin-api/enableIsolatedMarginAccount.ts b/src/tools/binance-margin/isolated-margin-api/enableIsolatedMarginAccount.ts index 4d13aa7e..c0a231f0 100644 --- a/src/tools/binance-margin/isolated-margin-api/enableIsolatedMarginAccount.ts +++ b/src/tools/binance-margin/isolated-margin-api/enableIsolatedMarginAccount.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-margin/isolated-margin-api/enableIsolatedMarginAccount.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceEnableIsolatedMarginAccount(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerBinanceEnableIsolatedMarginAccount(server: McpServer) { const response = await marginClient.restAPI.enableIsolatedMarginAccount({ symbol: params.symbol, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,15 +35,15 @@ export function registerBinanceEnableIsolatedMarginAccount(server: McpServer) { text: `Isolated margin account enabled for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to enable isolated margin: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/isolated-margin-api/getBnbBurnStatus.ts b/src/tools/binance-margin/isolated-margin-api/getBnbBurnStatus.ts index 0cd8eaa3..ce195598 100644 --- a/src/tools/binance-margin/isolated-margin-api/getBnbBurnStatus.ts +++ b/src/tools/binance-margin/isolated-margin-api/getBnbBurnStatus.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/isolated-margin-api/getBnbBurnStatus.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceGetBnbBurnStatus(server: McpServer) { server.tool( @@ -16,7 +16,7 @@ export function registerBinanceGetBnbBurnStatus(server: McpServer) { try { const data = await marginClient.getAccount({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -25,15 +25,15 @@ export function registerBinanceGetBnbBurnStatus(server: McpServer) { text: `BNB Burn Status: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get BNB burn status: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/isolated-margin-api/index.ts b/src/tools/binance-margin/isolated-margin-api/index.ts index 87da9c92..ee2459b1 100644 --- a/src/tools/binance-margin/isolated-margin-api/index.ts +++ b/src/tools/binance-margin/isolated-margin-api/index.ts @@ -1,43 +1,43 @@ // src/tools/binance-margin/isolated-margin-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetBnbBurnStatus } from "./getBnbBurnStatus.js" -import { registerBinanceIsolatedMarginAccount } from "./isolatedMarginAccount.js" -import { registerBinanceIsolatedMarginAccountLimit } from "./isolatedMarginAccountLimit.js" -import { registerBinanceIsolatedMarginAllOrders } from "./isolatedMarginAllOrders.js" -import { registerBinanceIsolatedMarginAllPairs } from "./isolatedMarginAllPairs.js" -import { registerBinanceIsolatedMarginCancelOrder } from "./isolatedMarginCancelOrder.js" -import { registerBinanceIsolatedMarginFee } from "./isolatedMarginFee.js" -import { registerBinanceIsolatedMarginMyTrades } from "./isolatedMarginMyTrades.js" -import { registerBinanceIsolatedMarginNewOrder } from "./isolatedMarginNewOrder.js" -import { registerBinanceIsolatedMarginOpenOrders } from "./isolatedMarginOpenOrders.js" -import { registerBinanceIsolatedMarginPair } from "./isolatedMarginPair.js" -import { registerBinanceIsolatedMarginTierData } from "./isolatedMarginTierData.js" -import { registerBinanceIsolatedMarginTransfer } from "./isolatedMarginTransfer.js" -import { registerBinanceToggleBnbBurn } from "./toggleBnbBurn.js" +import { registerBinanceGetBnbBurnStatus } from "./getBnbBurnStatus.js"; +import { registerBinanceIsolatedMarginAccount } from "./isolatedMarginAccount.js"; +import { registerBinanceIsolatedMarginAccountLimit } from "./isolatedMarginAccountLimit.js"; +import { registerBinanceIsolatedMarginAllOrders } from "./isolatedMarginAllOrders.js"; +import { registerBinanceIsolatedMarginAllPairs } from "./isolatedMarginAllPairs.js"; +import { registerBinanceIsolatedMarginCancelOrder } from "./isolatedMarginCancelOrder.js"; +import { registerBinanceIsolatedMarginFee } from "./isolatedMarginFee.js"; +import { registerBinanceIsolatedMarginMyTrades } from "./isolatedMarginMyTrades.js"; +import { registerBinanceIsolatedMarginNewOrder } from "./isolatedMarginNewOrder.js"; +import { registerBinanceIsolatedMarginOpenOrders } from "./isolatedMarginOpenOrders.js"; +import { registerBinanceIsolatedMarginPair } from "./isolatedMarginPair.js"; +import { registerBinanceIsolatedMarginTierData } from "./isolatedMarginTierData.js"; +import { registerBinanceIsolatedMarginTransfer } from "./isolatedMarginTransfer.js"; +import { registerBinanceToggleBnbBurn } from "./toggleBnbBurn.js"; export function registerBinanceIsolatedMarginTools(server: McpServer) { // Transfer - registerBinanceIsolatedMarginTransfer(server) + registerBinanceIsolatedMarginTransfer(server); // Account Info - registerBinanceIsolatedMarginAccount(server) - registerBinanceIsolatedMarginAccountLimit(server) + registerBinanceIsolatedMarginAccount(server); + registerBinanceIsolatedMarginAccountLimit(server); // Pairs & Info - registerBinanceIsolatedMarginPair(server) - registerBinanceIsolatedMarginAllPairs(server) - registerBinanceIsolatedMarginTierData(server) - registerBinanceIsolatedMarginFee(server) + registerBinanceIsolatedMarginPair(server); + registerBinanceIsolatedMarginAllPairs(server); + registerBinanceIsolatedMarginTierData(server); + registerBinanceIsolatedMarginFee(server); // Trading - registerBinanceIsolatedMarginNewOrder(server) - registerBinanceIsolatedMarginCancelOrder(server) - registerBinanceIsolatedMarginOpenOrders(server) - registerBinanceIsolatedMarginAllOrders(server) - registerBinanceIsolatedMarginMyTrades(server) + registerBinanceIsolatedMarginNewOrder(server); + registerBinanceIsolatedMarginCancelOrder(server); + registerBinanceIsolatedMarginOpenOrders(server); + registerBinanceIsolatedMarginAllOrders(server); + registerBinanceIsolatedMarginMyTrades(server); // BNB Burn - registerBinanceToggleBnbBurn(server) - registerBinanceGetBnbBurnStatus(server) + registerBinanceToggleBnbBurn(server); + registerBinanceGetBnbBurnStatus(server); } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAccount.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAccount.ts index d4532aa2..ec440fa7 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAccount.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAccount.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/isolated-margin-api/isolatedMarginAccount.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginAccount(server: McpServer) { server.tool( @@ -21,7 +21,7 @@ export function registerBinanceIsolatedMarginAccount(server: McpServer) { const data = await marginClient.getIsolatedAccount({ ...(params.symbols && { symbols: params.symbols }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -30,15 +30,15 @@ export function registerBinanceIsolatedMarginAccount(server: McpServer) { text: `Isolated Margin Account Info: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to query account: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAccountLimit.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAccountLimit.ts index d38705f0..1a3a5c62 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAccountLimit.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAccountLimit.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/isolated-margin-api/isolatedMarginAccountLimit.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginAccountLimit(server: McpServer) { server.tool( @@ -16,7 +16,7 @@ export function registerBinanceIsolatedMarginAccountLimit(server: McpServer) { try { const data = await marginClient.getIsolatedAccount({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -25,15 +25,15 @@ export function registerBinanceIsolatedMarginAccountLimit(server: McpServer) { text: `Isolated Margin Account Limit: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to query account limit: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllOrders.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllOrders.ts index 84d74aeb..b7a185fc 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllOrders.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/isolated-margin-api/isolatedMarginAllOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginAllOrders(server: McpServer) { server.tool( @@ -27,7 +27,7 @@ export function registerBinanceIsolatedMarginAllOrders(server: McpServer) { ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -36,15 +36,15 @@ export function registerBinanceIsolatedMarginAllOrders(server: McpServer) { text: `All Isolated Margin Orders for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to query all orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllPairs.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllPairs.ts index 48d0097f..e50f4152 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllPairs.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllPairs.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/isolated-margin-api/isolatedMarginAllPairs.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginAllPairs(server: McpServer) { server.tool( @@ -16,7 +16,7 @@ export function registerBinanceIsolatedMarginAllPairs(server: McpServer) { try { const data = await marginClient.getIsolatedMarginPairs({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -25,15 +25,15 @@ export function registerBinanceIsolatedMarginAllPairs(server: McpServer) { text: `All Isolated Margin Pairs: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get isolated pairs: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllSymbols.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllSymbols.ts index c1d5ac11..93a6f84f 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllSymbols.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllSymbols.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-margin/isolated-margin-api/isolatedMarginAllSymbols.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginAllSymbols(server: McpServer) { server.tool( @@ -22,9 +22,9 @@ export function registerBinanceIsolatedMarginAllSymbols(server: McpServer) { try { const response = await marginClient.restAPI.getAllIsolatedMarginSymbol({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -33,15 +33,15 @@ export function registerBinanceIsolatedMarginAllSymbols(server: McpServer) { text: `All Isolated Margin Symbols: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to query all symbols: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginBorrow.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginBorrow.ts index 77f64dc0..86279f39 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginBorrow.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginBorrow.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-margin/isolated-margin-api/isolatedMarginBorrow.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginBorrow(server: McpServer) { server.tool( @@ -30,9 +30,9 @@ export function registerBinanceIsolatedMarginBorrow(server: McpServer) { amount: params.amount, type: "BORROW", ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -41,15 +41,15 @@ export function registerBinanceIsolatedMarginBorrow(server: McpServer) { text: `Borrowed ${params.amount} ${params.asset} for ${params.symbol}: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to borrow: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginCancelOrder.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginCancelOrder.ts index f52cc1ac..f0d1fb41 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginCancelOrder.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginCancelOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/isolated-margin-api/isolatedMarginCancelOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginCancelOrder(server: McpServer) { server.tool( @@ -28,7 +28,7 @@ export function registerBinanceIsolatedMarginCancelOrder(server: McpServer) { ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -37,17 +37,17 @@ export function registerBinanceIsolatedMarginCancelOrder(server: McpServer) { text: `Isolated margin order cancelled successfully: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to cancel isolated margin order: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginFee.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginFee.ts index ca47d14d..5ae0f011 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginFee.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginFee.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/isolated-margin-api/isolatedMarginFee.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginFee(server: McpServer) { server.tool( @@ -24,7 +24,7 @@ export function registerBinanceIsolatedMarginFee(server: McpServer) { ...(params.symbol && { symbol: params.symbol }), ...(params.vipLevel !== undefined && { vipLevel: params.vipLevel }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -33,15 +33,15 @@ export function registerBinanceIsolatedMarginFee(server: McpServer) { text: `Isolated Margin Fee Data: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to query fee data: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginMyTrades.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginMyTrades.ts index 2beab2fd..166b7d1a 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginMyTrades.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginMyTrades.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/isolated-margin-api/isolatedMarginMyTrades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginMyTrades(server: McpServer) { server.tool( @@ -29,7 +29,7 @@ export function registerBinanceIsolatedMarginMyTrades(server: McpServer) { ...(params.fromId && { fromId: params.fromId }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -38,15 +38,15 @@ export function registerBinanceIsolatedMarginMyTrades(server: McpServer) { text: `Isolated Margin Trades for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to query trades: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginNewOrder.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginNewOrder.ts index 4ffc89e9..328f3008 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginNewOrder.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginNewOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/isolated-margin-api/isolatedMarginNewOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginNewOrder(server: McpServer) { server.tool( @@ -68,7 +68,7 @@ export function registerBinanceIsolatedMarginNewOrder(server: McpServer) { autoRepayAtCancel: params.autoRepayAtCancel, }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -77,17 +77,17 @@ export function registerBinanceIsolatedMarginNewOrder(server: McpServer) { text: `Isolated margin order placed successfully: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to place isolated margin order: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginOpenOrders.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginOpenOrders.ts index 3ef79aca..4a02020f 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginOpenOrders.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginOpenOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/isolated-margin-api/isolatedMarginOpenOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginOpenOrders(server: McpServer) { server.tool( @@ -19,7 +19,7 @@ export function registerBinanceIsolatedMarginOpenOrders(server: McpServer) { symbol: params.symbol, isIsolated: "TRUE", ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -28,15 +28,15 @@ export function registerBinanceIsolatedMarginOpenOrders(server: McpServer) { text: `Isolated Margin Open Orders for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to query open orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginPair.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginPair.ts index 7f5f06c0..d4dca427 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginPair.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginPair.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/isolated-margin-api/isolatedMarginPair.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginPair(server: McpServer) { server.tool( @@ -18,7 +18,7 @@ export function registerBinanceIsolatedMarginPair(server: McpServer) { const data = await marginClient.getIsolatedMarginPairs({ symbol: params.symbol, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -27,15 +27,15 @@ export function registerBinanceIsolatedMarginPair(server: McpServer) { text: `Isolated Margin Pair Info for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to query pair info: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginRepay.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginRepay.ts index de753499..fb8ae43b 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginRepay.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginRepay.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-margin/isolated-margin-api/isolatedMarginRepay.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginRepay(server: McpServer) { server.tool( @@ -30,9 +30,9 @@ export function registerBinanceIsolatedMarginRepay(server: McpServer) { amount: params.amount, type: "REPAY", ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -41,15 +41,15 @@ export function registerBinanceIsolatedMarginRepay(server: McpServer) { text: `Repaid ${params.amount} ${params.asset} for ${params.symbol}: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to repay: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginSymbol.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginSymbol.ts index 11a424fb..72c73561 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginSymbol.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginSymbol.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-margin/isolated-margin-api/isolatedMarginSymbol.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginSymbol(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerBinanceIsolatedMarginSymbol(server: McpServer) { const response = await marginClient.restAPI.queryIsolatedMarginSymbol({ symbol: params.symbol, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,15 +35,15 @@ export function registerBinanceIsolatedMarginSymbol(server: McpServer) { text: `Isolated Margin Symbol Info for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to query symbol info: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginTierData.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginTierData.ts index 1caac253..3f0af2d2 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginTierData.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginTierData.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/isolated-margin-api/isolatedMarginTierData.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginTierData(server: McpServer) { server.tool( @@ -20,7 +20,7 @@ export function registerBinanceIsolatedMarginTierData(server: McpServer) { symbol: params.symbol, ...(params.tier !== undefined && { tier: params.tier }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -29,15 +29,15 @@ export function registerBinanceIsolatedMarginTierData(server: McpServer) { text: `Isolated Margin Tier Data for ${params.symbol}: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to query tier data: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginTransfer.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginTransfer.ts index dc37ab32..e692c931 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginTransfer.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginTransfer.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/isolated-margin-api/isolatedMarginTransfer.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginTransfer(server: McpServer) { server.tool( @@ -26,7 +26,7 @@ export function registerBinanceIsolatedMarginTransfer(server: McpServer) { transFrom: params.transFrom, transTo: params.transTo, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -35,15 +35,15 @@ export function registerBinanceIsolatedMarginTransfer(server: McpServer) { text: `Isolated margin transfer successful: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to transfer: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginTransferHistory.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginTransferHistory.ts index 9551402d..efd07c6f 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginTransferHistory.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginTransferHistory.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-margin/isolated-margin-api/isolatedMarginTransferHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginTransferHistory(server: McpServer) { server.tool( @@ -40,9 +40,9 @@ export function registerBinanceIsolatedMarginTransferHistory(server: McpServer) ...(params.size && { size: params.size }), ...(params.archived !== undefined && { archived: params.archived }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -51,15 +51,15 @@ export function registerBinanceIsolatedMarginTransferHistory(server: McpServer) text: `Isolated Margin Transfer History: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to query transfer history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/isolated-margin-api/toggleBnbBurn.ts b/src/tools/binance-margin/isolated-margin-api/toggleBnbBurn.ts index f6e43ee9..e9950793 100644 --- a/src/tools/binance-margin/isolated-margin-api/toggleBnbBurn.ts +++ b/src/tools/binance-margin/isolated-margin-api/toggleBnbBurn.ts @@ -1,9 +1,9 @@ // src/tools/binance-margin/isolated-margin-api/toggleBnbBurn.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceToggleBnbBurn(server: McpServer) { server.tool( @@ -26,7 +26,7 @@ export function registerBinanceToggleBnbBurn(server: McpServer) { ...(params.spotBNBBurn && { spotBNBBurn: params.spotBNBBurn }), ...(params.interestBNBBurn && { interestBNBBurn: params.interestBNBBurn }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); return { content: [ @@ -35,15 +35,15 @@ export function registerBinanceToggleBnbBurn(server: McpServer) { text: `BNB Burn settings updated: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to toggle BNB burn: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/margin-order-api/index.ts b/src/tools/binance-margin/margin-order-api/index.ts index 8e32682e..037e2be1 100644 --- a/src/tools/binance-margin/margin-order-api/index.ts +++ b/src/tools/binance-margin/margin-order-api/index.ts @@ -5,19 +5,19 @@ * @license Apache-2.0 */ // src/tools/binance-margin/margin-order-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceMarginCancelOco } from "./marginCancelOco.js" -import { registerBinanceMarginGetAllOco } from "./marginGetAllOco.js" -import { registerBinanceMarginGetOco } from "./marginGetOco.js" -import { registerBinanceMarginGetOpenOco } from "./marginGetOpenOco.js" -import { registerBinanceMarginNewOco } from "./marginNewOco.js" +import { registerBinanceMarginCancelOco } from "./marginCancelOco.js"; +import { registerBinanceMarginGetAllOco } from "./marginGetAllOco.js"; +import { registerBinanceMarginGetOco } from "./marginGetOco.js"; +import { registerBinanceMarginGetOpenOco } from "./marginGetOpenOco.js"; +import { registerBinanceMarginNewOco } from "./marginNewOco.js"; export function registerBinanceMarginOrderTools(server: McpServer) { // OCO Orders - registerBinanceMarginNewOco(server) - registerBinanceMarginCancelOco(server) - registerBinanceMarginGetOco(server) - registerBinanceMarginGetAllOco(server) - registerBinanceMarginGetOpenOco(server) + registerBinanceMarginNewOco(server); + registerBinanceMarginCancelOco(server); + registerBinanceMarginGetOco(server); + registerBinanceMarginGetAllOco(server); + registerBinanceMarginGetOpenOco(server); } diff --git a/src/tools/binance-margin/margin-order-api/marginCancelOco.ts b/src/tools/binance-margin/margin-order-api/marginCancelOco.ts index 77ca4f5f..87368408 100644 --- a/src/tools/binance-margin/margin-order-api/marginCancelOco.ts +++ b/src/tools/binance-margin/margin-order-api/marginCancelOco.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-margin/margin-order-api/marginCancelOco.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceMarginCancelOco(server: McpServer) { server.tool( @@ -38,7 +38,7 @@ export function registerBinanceMarginCancelOco(server: McpServer) { { type: "text", text: "Either orderListId or listClientOrderId must be provided" }, ], isError: true, - } + }; } const response = await marginClient.restAPI.marginAccountCancelOco({ @@ -48,9 +48,9 @@ export function registerBinanceMarginCancelOco(server: McpServer) { ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), ...(params.isIsolated && { isIsolated: params.isIsolated }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -59,15 +59,15 @@ export function registerBinanceMarginCancelOco(server: McpServer) { text: `Margin OCO order cancelled successfully: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to cancel margin OCO order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/margin-order-api/marginGetAllOco.ts b/src/tools/binance-margin/margin-order-api/marginGetAllOco.ts index 2dcbde78..67d5c833 100644 --- a/src/tools/binance-margin/margin-order-api/marginGetAllOco.ts +++ b/src/tools/binance-margin/margin-order-api/marginGetAllOco.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-margin/margin-order-api/marginGetAllOco.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceMarginGetAllOco(server: McpServer) { server.tool( @@ -40,9 +40,9 @@ export function registerBinanceMarginGetAllOco(server: McpServer) { ...(params.limit && { limit: params.limit }), ...(params.isIsolated && { isIsolated: params.isIsolated }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -51,17 +51,17 @@ export function registerBinanceMarginGetAllOco(server: McpServer) { text: `All Margin OCO orders: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to query all margin OCO orders: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/margin-order-api/marginGetOco.ts b/src/tools/binance-margin/margin-order-api/marginGetOco.ts index 03c85fe6..dc46d2e0 100644 --- a/src/tools/binance-margin/margin-order-api/marginGetOco.ts +++ b/src/tools/binance-margin/margin-order-api/marginGetOco.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-margin/margin-order-api/marginGetOco.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceMarginGetOco(server: McpServer) { server.tool( @@ -37,7 +37,7 @@ export function registerBinanceMarginGetOco(server: McpServer) { { type: "text", text: "Either orderListId or origClientOrderId must be provided" }, ], isError: true, - } + }; } const response = await marginClient.restAPI.queryMarginAccountsOco({ @@ -46,9 +46,9 @@ export function registerBinanceMarginGetOco(server: McpServer) { ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), ...(params.isIsolated && { isIsolated: params.isIsolated }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -57,15 +57,15 @@ export function registerBinanceMarginGetOco(server: McpServer) { text: `Margin OCO order details: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to query margin OCO order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/margin-order-api/marginGetOpenOco.ts b/src/tools/binance-margin/margin-order-api/marginGetOpenOco.ts index b511759d..cfa173d1 100644 --- a/src/tools/binance-margin/margin-order-api/marginGetOpenOco.ts +++ b/src/tools/binance-margin/margin-order-api/marginGetOpenOco.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-margin/margin-order-api/marginGetOpenOco.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceMarginGetOpenOco(server: McpServer) { server.tool( @@ -32,9 +32,9 @@ export function registerBinanceMarginGetOpenOco(server: McpServer) { ...(params.symbol && { symbol: params.symbol }), ...(params.isIsolated && { isIsolated: params.isIsolated }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -43,17 +43,17 @@ export function registerBinanceMarginGetOpenOco(server: McpServer) { text: `Open Margin OCO orders: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to query open margin OCO orders: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-margin/margin-order-api/marginNewOco.ts b/src/tools/binance-margin/margin-order-api/marginNewOco.ts index e40290c0..f6cd3795 100644 --- a/src/tools/binance-margin/margin-order-api/marginNewOco.ts +++ b/src/tools/binance-margin/margin-order-api/marginNewOco.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-margin/margin-order-api/marginNewOco.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { marginClient } from "../../../config/binanceClient.js" +import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceMarginNewOco(server: McpServer) { server.tool( @@ -75,9 +75,9 @@ export function registerBinanceMarginNewOco(server: McpServer) { autoRepayAtCancel: params.autoRepayAtCancel, }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -86,15 +86,15 @@ export function registerBinanceMarginNewOco(server: McpServer) { text: `Margin OCO order placed successfully: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to place margin OCO order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-mining/index.ts b/src/tools/binance-mining/index.ts index e990dca3..987b48ee 100644 --- a/src/tools/binance-mining/index.ts +++ b/src/tools/binance-mining/index.ts @@ -1,32 +1,32 @@ // src/tools/binance-mining/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceAccountList } from "./mining-api/accountList.js" -import { registerBinanceAcquiringAlgorithm } from "./mining-api/acquiringAlgorithm.js" -import { registerBinanceAcquiringCoinName } from "./mining-api/acquiringCoinname.js" -import { registerBinanceCancelHashRateResaleConfiguration } from "./mining-api/cancelHashrateResaleConfiguration.js" -import { registerBinanceEarningsList } from "./mining-api/earningsList.js" -import { registerBinanceExtraBonusList } from "./mining-api/extraBonusList.js" -import { registerBinanceHashRateResaleDetail } from "./mining-api/hashrateResaleDetail.js" -import { registerBinanceHashRateResaleList } from "./mining-api/hashrateResaleList.js" -import { registerBinanceHashRateResaleRequest } from "./mining-api/hashrateResaleRequest.js" -import { registerBinanceMiningAccountEarning } from "./mining-api/miningAccountEarning.js" -import { registerBinanceRequestForDetailMinerList } from "./mining-api/requestForDetailMinerList.js" -import { registerBinanceRequestForMinerList } from "./mining-api/requestForMinerList.js" -import { registerBinanceStatisticList } from "./mining-api/statisticList.js" +import { registerBinanceAccountList } from "./mining-api/accountList.js"; +import { registerBinanceAcquiringAlgorithm } from "./mining-api/acquiringAlgorithm.js"; +import { registerBinanceAcquiringCoinName } from "./mining-api/acquiringCoinname.js"; +import { registerBinanceCancelHashRateResaleConfiguration } from "./mining-api/cancelHashrateResaleConfiguration.js"; +import { registerBinanceEarningsList } from "./mining-api/earningsList.js"; +import { registerBinanceExtraBonusList } from "./mining-api/extraBonusList.js"; +import { registerBinanceHashRateResaleDetail } from "./mining-api/hashrateResaleDetail.js"; +import { registerBinanceHashRateResaleList } from "./mining-api/hashrateResaleList.js"; +import { registerBinanceHashRateResaleRequest } from "./mining-api/hashrateResaleRequest.js"; +import { registerBinanceMiningAccountEarning } from "./mining-api/miningAccountEarning.js"; +import { registerBinanceRequestForDetailMinerList } from "./mining-api/requestForDetailMinerList.js"; +import { registerBinanceRequestForMinerList } from "./mining-api/requestForMinerList.js"; +import { registerBinanceStatisticList } from "./mining-api/statisticList.js"; export function registerBinanceMiningTools(server: McpServer) { - registerBinanceAcquiringAlgorithm(server) - registerBinanceAcquiringCoinName(server) - registerBinanceHashRateResaleList(server) - registerBinanceRequestForMinerList(server) - registerBinanceRequestForDetailMinerList(server) - registerBinanceExtraBonusList(server) - registerBinanceEarningsList(server) - registerBinanceCancelHashRateResaleConfiguration(server) - registerBinanceHashRateResaleDetail(server) - registerBinanceMiningAccountEarning(server) - registerBinanceStatisticList(server) - registerBinanceHashRateResaleRequest(server) - registerBinanceAccountList(server) + registerBinanceAcquiringAlgorithm(server); + registerBinanceAcquiringCoinName(server); + registerBinanceHashRateResaleList(server); + registerBinanceRequestForMinerList(server); + registerBinanceRequestForDetailMinerList(server); + registerBinanceExtraBonusList(server); + registerBinanceEarningsList(server); + registerBinanceCancelHashRateResaleConfiguration(server); + registerBinanceHashRateResaleDetail(server); + registerBinanceMiningAccountEarning(server); + registerBinanceStatisticList(server); + registerBinanceHashRateResaleRequest(server); + registerBinanceAccountList(server); } diff --git a/src/tools/binance-mining/mining-api/accountList.ts b/src/tools/binance-mining/mining-api/accountList.ts index cb48f137..5d43881a 100644 --- a/src/tools/binance-mining/mining-api/accountList.ts +++ b/src/tools/binance-mining/mining-api/accountList.ts @@ -1,9 +1,9 @@ // src/tools/binance-mining/mining-api/accountList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { miningClient } from "../../../config/binanceClient.js" +import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceAccountList(server: McpServer) { server.tool( @@ -20,9 +20,9 @@ export function registerBinanceAccountList(server: McpServer) { algo: params.algo, userName: params.userName, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -33,9 +33,9 @@ export function registerBinanceAccountList(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -45,8 +45,8 @@ export function registerBinanceAccountList(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-mining/mining-api/acquiringAlgorithm.ts b/src/tools/binance-mining/mining-api/acquiringAlgorithm.ts index 4551274c..c02d7f3a 100644 --- a/src/tools/binance-mining/mining-api/acquiringAlgorithm.ts +++ b/src/tools/binance-mining/mining-api/acquiringAlgorithm.ts @@ -1,7 +1,7 @@ // src/tools/binance-mining/mining-api/acquiringAlgorithm.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js" +import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceAcquiringAlgorithm(server: McpServer) { server.tool( @@ -10,9 +10,9 @@ export function registerBinanceAcquiringAlgorithm(server: McpServer) { {}, async () => { try { - const response = await miningClient.restAPI.acquiringAlgorithm() + const response = await miningClient.restAPI.acquiringAlgorithm(); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -23,9 +23,9 @@ export function registerBinanceAcquiringAlgorithm(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -35,8 +35,8 @@ export function registerBinanceAcquiringAlgorithm(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-mining/mining-api/acquiringCoinname.ts b/src/tools/binance-mining/mining-api/acquiringCoinname.ts index aef4b04c..f5ff7b69 100644 --- a/src/tools/binance-mining/mining-api/acquiringCoinname.ts +++ b/src/tools/binance-mining/mining-api/acquiringCoinname.ts @@ -1,7 +1,7 @@ // src/tools/binance-mining/mining-api/acquiringCoinname.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { miningClient } from "../../../config/binanceClient.js" +import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceAcquiringCoinName(server: McpServer) { server.tool( @@ -10,9 +10,9 @@ export function registerBinanceAcquiringCoinName(server: McpServer) { {}, async () => { try { - const response = await miningClient.restAPI.acquiringCoinname() + const response = await miningClient.restAPI.acquiringCoinname(); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -21,9 +21,9 @@ export function registerBinanceAcquiringCoinName(server: McpServer) { text: `Successfully fetched supported mining coins. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -33,8 +33,8 @@ export function registerBinanceAcquiringCoinName(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-mining/mining-api/cancelHashrateResaleConfiguration.ts b/src/tools/binance-mining/mining-api/cancelHashrateResaleConfiguration.ts index 5dd7d120..7ec167a4 100644 --- a/src/tools/binance-mining/mining-api/cancelHashrateResaleConfiguration.ts +++ b/src/tools/binance-mining/mining-api/cancelHashrateResaleConfiguration.ts @@ -1,9 +1,9 @@ // src/tools/binance-mining/mining-api/cancelHashrateResaleConfiguration.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { miningClient } from "../../../config/binanceClient.js" +import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceCancelHashRateResaleConfiguration(server: McpServer) { server.tool( @@ -20,9 +20,9 @@ export function registerBinanceCancelHashRateResaleConfiguration(server: McpServ configId: params.configId, userName: params.userName, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -33,9 +33,9 @@ export function registerBinanceCancelHashRateResaleConfiguration(server: McpServ )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -45,8 +45,8 @@ export function registerBinanceCancelHashRateResaleConfiguration(server: McpServ }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-mining/mining-api/earningsList.ts b/src/tools/binance-mining/mining-api/earningsList.ts index 3afee161..2e768d70 100644 --- a/src/tools/binance-mining/mining-api/earningsList.ts +++ b/src/tools/binance-mining/mining-api/earningsList.ts @@ -1,9 +1,9 @@ // src/tools/binance-mining/mining-api/earningsList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { miningClient } from "../../../config/binanceClient.js" +import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceEarningsList(server: McpServer) { server.tool( @@ -44,9 +44,9 @@ export function registerBinanceEarningsList(server: McpServer) { ...(params.pageIndex && { pageIndex: params.pageIndex }), ...(params.pageSize && { pageSize: params.pageSize }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -57,9 +57,9 @@ export function registerBinanceEarningsList(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -69,8 +69,8 @@ export function registerBinanceEarningsList(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-mining/mining-api/extraBonusList.ts b/src/tools/binance-mining/mining-api/extraBonusList.ts index a49e7c0d..a8a2c38c 100644 --- a/src/tools/binance-mining/mining-api/extraBonusList.ts +++ b/src/tools/binance-mining/mining-api/extraBonusList.ts @@ -1,9 +1,9 @@ // src/tools/binance-mining/mining-api/extraBonusList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { miningClient } from "../../../config/binanceClient.js" +import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceExtraBonusList(server: McpServer) { server.tool( @@ -39,8 +39,8 @@ export function registerBinanceExtraBonusList(server: McpServer) { ...(params.pageIndex && { pageIndex: params.pageIndex }), ...(params.pageSize && { pageSize: params.pageSize }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -51,9 +51,9 @@ export function registerBinanceExtraBonusList(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -63,8 +63,8 @@ export function registerBinanceExtraBonusList(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-mining/mining-api/hashrateResaleDetail.ts b/src/tools/binance-mining/mining-api/hashrateResaleDetail.ts index 770d81c9..b5b37a68 100644 --- a/src/tools/binance-mining/mining-api/hashrateResaleDetail.ts +++ b/src/tools/binance-mining/mining-api/hashrateResaleDetail.ts @@ -1,9 +1,9 @@ // src/tools/binance-mining/mining-api/hashrateResaleDetail.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { miningClient } from "../../../config/binanceClient.js" +import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceHashRateResaleDetail(server: McpServer) { server.tool( @@ -35,9 +35,9 @@ export function registerBinanceHashRateResaleDetail(server: McpServer) { ...(params.pageIndex && { pageIndex: params.pageIndex }), ...(params.pageSize && { pageSize: params.pageSize }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -48,9 +48,9 @@ export function registerBinanceHashRateResaleDetail(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -60,8 +60,8 @@ export function registerBinanceHashRateResaleDetail(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-mining/mining-api/hashrateResaleList.ts b/src/tools/binance-mining/mining-api/hashrateResaleList.ts index b5b6ab27..7c91d0bc 100644 --- a/src/tools/binance-mining/mining-api/hashrateResaleList.ts +++ b/src/tools/binance-mining/mining-api/hashrateResaleList.ts @@ -1,9 +1,9 @@ // src/tools/binance-mining/mining-api/hashrateResaleList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { miningClient } from "../../../config/binanceClient.js" +import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceHashRateResaleList(server: McpServer) { server.tool( @@ -31,9 +31,9 @@ export function registerBinanceHashRateResaleList(server: McpServer) { ...(params.pageIndex && { pageIndex: params.pageIndex }), ...(params.pageSize && { pageSize: params.pageSize }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -44,9 +44,9 @@ export function registerBinanceHashRateResaleList(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -56,8 +56,8 @@ export function registerBinanceHashRateResaleList(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-mining/mining-api/hashrateResaleRequest.ts b/src/tools/binance-mining/mining-api/hashrateResaleRequest.ts index 73c3b099..e8029938 100644 --- a/src/tools/binance-mining/mining-api/hashrateResaleRequest.ts +++ b/src/tools/binance-mining/mining-api/hashrateResaleRequest.ts @@ -1,9 +1,9 @@ // src/tools/binance-mining/mining-api/hashrateResaleRequest.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { miningClient } from "../../../config/binanceClient.js" +import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceHashRateResaleRequest(server: McpServer) { server.tool( @@ -35,9 +35,9 @@ export function registerBinanceHashRateResaleRequest(server: McpServer) { toPoolUser: params.toPoolUser, hashRate: params.hashRate, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -48,9 +48,9 @@ export function registerBinanceHashRateResaleRequest(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -60,8 +60,8 @@ export function registerBinanceHashRateResaleRequest(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-mining/mining-api/miningAccountEarning.ts b/src/tools/binance-mining/mining-api/miningAccountEarning.ts index 17f4e9ac..5b1d4e86 100644 --- a/src/tools/binance-mining/mining-api/miningAccountEarning.ts +++ b/src/tools/binance-mining/mining-api/miningAccountEarning.ts @@ -1,9 +1,9 @@ // src/tools/binance-mining/mining-api/miningAccountEarning.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { miningClient } from "../../../config/binanceClient.js" +import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceMiningAccountEarning(server: McpServer) { server.tool( @@ -32,9 +32,9 @@ export function registerBinanceMiningAccountEarning(server: McpServer) { ...(params.pageIndex && { pageIndex: params.pageIndex }), ...(params.pageSize && { pageSize: params.pageSize }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -45,9 +45,9 @@ export function registerBinanceMiningAccountEarning(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -57,8 +57,8 @@ export function registerBinanceMiningAccountEarning(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-mining/mining-api/requestForDetailMinerList.ts b/src/tools/binance-mining/mining-api/requestForDetailMinerList.ts index a45268a5..5302c9aa 100644 --- a/src/tools/binance-mining/mining-api/requestForDetailMinerList.ts +++ b/src/tools/binance-mining/mining-api/requestForDetailMinerList.ts @@ -1,9 +1,9 @@ // src/tools/binance-mining/mining-api/requestForDetailMinerList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { miningClient } from "../../../config/binanceClient.js" +import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceRequestForDetailMinerList(server: McpServer) { server.tool( @@ -22,9 +22,9 @@ export function registerBinanceRequestForDetailMinerList(server: McpServer) { userName: params.userName, workerName: params.workerName, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,9 +35,9 @@ export function registerBinanceRequestForDetailMinerList(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -47,8 +47,8 @@ export function registerBinanceRequestForDetailMinerList(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-mining/mining-api/requestForMinerList.ts b/src/tools/binance-mining/mining-api/requestForMinerList.ts index f83cb473..b344712a 100644 --- a/src/tools/binance-mining/mining-api/requestForMinerList.ts +++ b/src/tools/binance-mining/mining-api/requestForMinerList.ts @@ -1,9 +1,9 @@ // src/tools/binance-mining/mining-api/requestForMinerList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { miningClient } from "../../../config/binanceClient.js" +import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceRequestForMinerList(server: McpServer) { server.tool( @@ -53,9 +53,9 @@ export function registerBinanceRequestForMinerList(server: McpServer) { ...(params.sortColumn && { sortColumn: params.sortColumn }), ...(params.workerStatus && { workerStatus: params.workerStatus }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -66,9 +66,9 @@ export function registerBinanceRequestForMinerList(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -78,8 +78,8 @@ export function registerBinanceRequestForMinerList(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-mining/mining-api/statisticList.ts b/src/tools/binance-mining/mining-api/statisticList.ts index 0b7e4631..6957833f 100644 --- a/src/tools/binance-mining/mining-api/statisticList.ts +++ b/src/tools/binance-mining/mining-api/statisticList.ts @@ -1,9 +1,9 @@ // src/tools/binance-mining/mining-api/statisticList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { miningClient } from "../../../config/binanceClient.js" +import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceStatisticList(server: McpServer) { server.tool( @@ -24,8 +24,8 @@ export function registerBinanceStatisticList(server: McpServer) { algo: params.algo, userName: params.userName, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -36,9 +36,9 @@ export function registerBinanceStatisticList(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -48,8 +48,8 @@ export function registerBinanceStatisticList(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-nft/index.ts b/src/tools/binance-nft/index.ts index da7e111f..da5e5703 100644 --- a/src/tools/binance-nft/index.ts +++ b/src/tools/binance-nft/index.ts @@ -1,14 +1,14 @@ // src/tools/binance-fiat/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetNFTAsset } from "./nft-api/getNFTAsset.js" -import { registerBinanceGetNFTDepositHistory } from "./nft-api/getNFTDepositHistory.js" -import { registerBinanceGetNFTTransactionHistory } from "./nft-api/getNFTTransactionHistory.js" -import { registerBinanceGetNFTWithdrawHistory } from "./nft-api/getNFTWithdrawHistory.js" +import { registerBinanceGetNFTAsset } from "./nft-api/getNFTAsset.js"; +import { registerBinanceGetNFTDepositHistory } from "./nft-api/getNFTDepositHistory.js"; +import { registerBinanceGetNFTTransactionHistory } from "./nft-api/getNFTTransactionHistory.js"; +import { registerBinanceGetNFTWithdrawHistory } from "./nft-api/getNFTWithdrawHistory.js"; export function registerBinanceNFTTools(server: McpServer) { - registerBinanceGetNFTDepositHistory(server) - registerBinanceGetNFTWithdrawHistory(server) - registerBinanceGetNFTTransactionHistory(server) - registerBinanceGetNFTAsset(server) + registerBinanceGetNFTDepositHistory(server); + registerBinanceGetNFTWithdrawHistory(server); + registerBinanceGetNFTTransactionHistory(server); + registerBinanceGetNFTAsset(server); } diff --git a/src/tools/binance-nft/nft-api/getNFTAsset.ts b/src/tools/binance-nft/nft-api/getNFTAsset.ts index dc5cc49c..335bc2c3 100644 --- a/src/tools/binance-nft/nft-api/getNFTAsset.ts +++ b/src/tools/binance-nft/nft-api/getNFTAsset.ts @@ -1,9 +1,9 @@ // src/tools/binance-nft/nft-api/getNFTAsset.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { nftClient } from "../../../config/binanceClient.js" +import { nftClient } from "../../../config/binanceClient.js"; export function registerBinanceGetNFTAsset(server: McpServer) { server.tool( @@ -25,9 +25,9 @@ export function registerBinanceGetNFTAsset(server: McpServer) { ...(params.limit && { limit: params.limit }), ...(params.page && { page: params.page }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -38,9 +38,9 @@ export function registerBinanceGetNFTAsset(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -50,8 +50,8 @@ export function registerBinanceGetNFTAsset(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-nft/nft-api/getNFTDepositHistory.ts b/src/tools/binance-nft/nft-api/getNFTDepositHistory.ts index a01bc6a2..57fec721 100644 --- a/src/tools/binance-nft/nft-api/getNFTDepositHistory.ts +++ b/src/tools/binance-nft/nft-api/getNFTDepositHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-nft/nft-api/getNFTDepositHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { nftClient } from "../../../config/binanceClient.js" +import { nftClient } from "../../../config/binanceClient.js"; export function registerBinanceGetNFTDepositHistory(server: McpServer) { server.tool( @@ -29,9 +29,9 @@ export function registerBinanceGetNFTDepositHistory(server: McpServer) { ...(params.limit && { limit: params.limit }), ...(params.page && { page: params.page }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -42,9 +42,9 @@ export function registerBinanceGetNFTDepositHistory(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -54,8 +54,8 @@ export function registerBinanceGetNFTDepositHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-nft/nft-api/getNFTTransactionHistory.ts b/src/tools/binance-nft/nft-api/getNFTTransactionHistory.ts index 8c755bc9..0320072f 100644 --- a/src/tools/binance-nft/nft-api/getNFTTransactionHistory.ts +++ b/src/tools/binance-nft/nft-api/getNFTTransactionHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-nft/nft-api/getNFTTransactionHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { nftClient } from "../../../config/binanceClient.js" +import { nftClient } from "../../../config/binanceClient.js"; export function registerBinanceGetNFTTransactionHistory(server: McpServer) { server.tool( @@ -35,9 +35,9 @@ export function registerBinanceGetNFTTransactionHistory(server: McpServer) { ...(params.limit && { limit: params.limit }), ...(params.page && { page: params.page }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -46,9 +46,9 @@ export function registerBinanceGetNFTTransactionHistory(server: McpServer) { text: `Successfully retrieved NFT transaction history. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -58,8 +58,8 @@ export function registerBinanceGetNFTTransactionHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-nft/nft-api/getNFTWithdrawHistory.ts b/src/tools/binance-nft/nft-api/getNFTWithdrawHistory.ts index 6cf2bdb7..b14b3cd9 100644 --- a/src/tools/binance-nft/nft-api/getNFTWithdrawHistory.ts +++ b/src/tools/binance-nft/nft-api/getNFTWithdrawHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-nft/nft-api/getNFTWithdrawHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { nftClient } from "../../../config/binanceClient.js" +import { nftClient } from "../../../config/binanceClient.js"; export function registerBinanceGetNFTWithdrawHistory(server: McpServer) { server.tool( @@ -29,9 +29,9 @@ export function registerBinanceGetNFTWithdrawHistory(server: McpServer) { ...(params.limit && { limit: params.limit }), ...(params.page && { page: params.page }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -42,9 +42,9 @@ export function registerBinanceGetNFTWithdrawHistory(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -54,8 +54,8 @@ export function registerBinanceGetNFTWithdrawHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-options/account.ts b/src/tools/binance-options/account.ts index f068d751..71786369 100644 --- a/src/tools/binance-options/account.ts +++ b/src/tools/binance-options/account.ts @@ -1,12 +1,12 @@ // src/tools/binance-options/account.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../config/binanceClient.js" +import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsAccount(server: McpServer) { server.tool("BinanceOptionsAccount", "Get current options account information.", {}, async () => { try { - const data = await optionsClient.account() + const data = await optionsClient.account(); return { content: [ @@ -15,14 +15,14 @@ export function registerBinanceOptionsAccount(server: McpServer) { text: `Options account information retrieved. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get account info: ${errorMessage}` }], isError: true, - } + }; } - }) + }); } diff --git a/src/tools/binance-options/batchOrders.ts b/src/tools/binance-options/batchOrders.ts index 409f67f1..748e67e3 100644 --- a/src/tools/binance-options/batchOrders.ts +++ b/src/tools/binance-options/batchOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-options/batchOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js" +import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsBatchOrders(server: McpServer) { server.tool( @@ -18,9 +18,9 @@ export function registerBinanceOptionsBatchOrders(server: McpServer) { }, async ({ orders }) => { try { - const params: any = { orders } + const params: any = { orders }; - const data = await optionsClient.batchOrders(params) + const data = await optionsClient.batchOrders(params); return { content: [ @@ -29,15 +29,15 @@ export function registerBinanceOptionsBatchOrders(server: McpServer) { text: `Batch orders placed successfully. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to place batch orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-options/bill.ts b/src/tools/binance-options/bill.ts index b18a8ddb..47fd6417 100644 --- a/src/tools/binance-options/bill.ts +++ b/src/tools/binance-options/bill.ts @@ -1,9 +1,9 @@ // src/tools/binance-options/bill.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js" +import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsBill(server: McpServer) { server.tool( @@ -18,14 +18,14 @@ export function registerBinanceOptionsBill(server: McpServer) { }, async ({ currency, recordId, startTime, endTime, limit }) => { try { - const params: any = {} - if (currency) params.currency = currency - if (recordId !== undefined) params.recordId = recordId - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + const params: any = {}; + if (currency) params.currency = currency; + if (recordId !== undefined) params.recordId = recordId; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const data = await optionsClient.bill(params) + const data = await optionsClient.bill(params); return { content: [ @@ -34,15 +34,15 @@ export function registerBinanceOptionsBill(server: McpServer) { text: `Bill history retrieved. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get bill history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-options/cancelAllOrders.ts b/src/tools/binance-options/cancelAllOrders.ts index bd78d7d1..8ea9617b 100644 --- a/src/tools/binance-options/cancelAllOrders.ts +++ b/src/tools/binance-options/cancelAllOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-options/cancelAllOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js" +import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsCancelAllOrders(server: McpServer) { server.tool( @@ -14,9 +14,9 @@ export function registerBinanceOptionsCancelAllOrders(server: McpServer) { }, async ({ symbol }) => { try { - const params: any = { symbol } + const params: any = { symbol }; - const data = await optionsClient.cancelAllOrders(params) + const data = await optionsClient.cancelAllOrders(params); return { content: [ @@ -25,15 +25,15 @@ export function registerBinanceOptionsCancelAllOrders(server: McpServer) { text: `All orders cancelled successfully. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to cancel all orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-options/cancelBatchOrders.ts b/src/tools/binance-options/cancelBatchOrders.ts index 2f3a2774..187a47ed 100644 --- a/src/tools/binance-options/cancelBatchOrders.ts +++ b/src/tools/binance-options/cancelBatchOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-options/cancelBatchOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js" +import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsCancelBatchOrders(server: McpServer) { server.tool( @@ -19,11 +19,11 @@ export function registerBinanceOptionsCancelBatchOrders(server: McpServer) { }, async ({ symbol, orderIds, clientOrderIds }) => { try { - const params: any = { symbol } - if (orderIds) params.orderIds = orderIds - if (clientOrderIds) params.clientOrderIds = clientOrderIds + const params: any = { symbol }; + if (orderIds) params.orderIds = orderIds; + if (clientOrderIds) params.clientOrderIds = clientOrderIds; - const data = await optionsClient.cancelBatchOrders(params) + const data = await optionsClient.cancelBatchOrders(params); return { content: [ @@ -32,15 +32,15 @@ export function registerBinanceOptionsCancelBatchOrders(server: McpServer) { text: `Batch orders cancelled successfully. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to cancel batch orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-options/cancelOrder.ts b/src/tools/binance-options/cancelOrder.ts index dd514344..8cddd46d 100644 --- a/src/tools/binance-options/cancelOrder.ts +++ b/src/tools/binance-options/cancelOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-options/cancelOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js" +import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsCancelOrder(server: McpServer) { server.tool( @@ -16,11 +16,11 @@ export function registerBinanceOptionsCancelOrder(server: McpServer) { }, async ({ symbol, orderId, clientOrderId }) => { try { - const params: any = { symbol } - if (orderId !== undefined) params.orderId = orderId - if (clientOrderId) params.clientOrderId = clientOrderId + const params: any = { symbol }; + if (orderId !== undefined) params.orderId = orderId; + if (clientOrderId) params.clientOrderId = clientOrderId; - const data = await optionsClient.cancelOrder(params) + const data = await optionsClient.cancelOrder(params); return { content: [ @@ -29,15 +29,15 @@ export function registerBinanceOptionsCancelOrder(server: McpServer) { text: `Order cancelled successfully. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to cancel order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-options/depth.ts b/src/tools/binance-options/depth.ts index 9e11f628..2bc7a310 100644 --- a/src/tools/binance-options/depth.ts +++ b/src/tools/binance-options/depth.ts @@ -1,9 +1,9 @@ // src/tools/binance-options/depth.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js" +import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsDepth(server: McpServer) { server.tool( @@ -15,10 +15,10 @@ export function registerBinanceOptionsDepth(server: McpServer) { }, async ({ symbol, limit }) => { try { - const params: any = { symbol } - if (limit !== undefined) params.limit = limit + const params: any = { symbol }; + if (limit !== undefined) params.limit = limit; - const data = await optionsClient.depth(params) + const data = await optionsClient.depth(params); return { content: [ @@ -27,15 +27,15 @@ export function registerBinanceOptionsDepth(server: McpServer) { text: `Order book depth for ${symbol}. Bids: ${data.bids?.length || 0}, Asks: ${data.asks?.length || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get order book depth: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-options/exchangeInfo.ts b/src/tools/binance-options/exchangeInfo.ts index 51e3b8e2..0d4bc262 100644 --- a/src/tools/binance-options/exchangeInfo.ts +++ b/src/tools/binance-options/exchangeInfo.ts @@ -1,9 +1,9 @@ // src/tools/binance-options/exchangeInfo.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js" +import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsExchangeInfo(server: McpServer) { server.tool( @@ -14,10 +14,10 @@ export function registerBinanceOptionsExchangeInfo(server: McpServer) { }, async ({ symbol }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol + const params: any = {}; + if (symbol) params.symbol = symbol; - const data = await optionsClient.exchangeInfo(params) + const data = await optionsClient.exchangeInfo(params); return { content: [ @@ -26,15 +26,15 @@ export function registerBinanceOptionsExchangeInfo(server: McpServer) { text: `Exchange info retrieved successfully. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get exchange info: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-options/exerciseHistory.ts b/src/tools/binance-options/exerciseHistory.ts index 93d9634b..1b59edc5 100644 --- a/src/tools/binance-options/exerciseHistory.ts +++ b/src/tools/binance-options/exerciseHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-options/exerciseHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js" +import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsExerciseHistory(server: McpServer) { server.tool( @@ -17,13 +17,13 @@ export function registerBinanceOptionsExerciseHistory(server: McpServer) { }, async ({ underlying, startTime, endTime, limit }) => { try { - const params: any = {} - if (underlying) params.underlying = underlying - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + const params: any = {}; + if (underlying) params.underlying = underlying; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const data = await optionsClient.exerciseHistory(params) + const data = await optionsClient.exerciseHistory(params); return { content: [ @@ -32,15 +32,15 @@ export function registerBinanceOptionsExerciseHistory(server: McpServer) { text: `Exercise history retrieved. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get exercise history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-options/exerciseRecord.ts b/src/tools/binance-options/exerciseRecord.ts index f52184c4..f8edc4d8 100644 --- a/src/tools/binance-options/exerciseRecord.ts +++ b/src/tools/binance-options/exerciseRecord.ts @@ -1,9 +1,9 @@ // src/tools/binance-options/exerciseRecord.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js" +import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsExerciseRecord(server: McpServer) { server.tool( @@ -17,13 +17,13 @@ export function registerBinanceOptionsExerciseRecord(server: McpServer) { }, async ({ symbol, startTime, endTime, limit }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + const params: any = {}; + if (symbol) params.symbol = symbol; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const data = await optionsClient.exerciseRecord(params) + const data = await optionsClient.exerciseRecord(params); return { content: [ @@ -32,15 +32,15 @@ export function registerBinanceOptionsExerciseRecord(server: McpServer) { text: `Exercise records retrieved. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get exercise records: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-options/getOrder.ts b/src/tools/binance-options/getOrder.ts index e0a7ac8e..80dbdcd0 100644 --- a/src/tools/binance-options/getOrder.ts +++ b/src/tools/binance-options/getOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-options/getOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js" +import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsGetOrder(server: McpServer) { server.tool( @@ -16,11 +16,11 @@ export function registerBinanceOptionsGetOrder(server: McpServer) { }, async ({ symbol, orderId, clientOrderId }) => { try { - const params: any = { symbol } - if (orderId !== undefined) params.orderId = orderId - if (clientOrderId) params.clientOrderId = clientOrderId + const params: any = { symbol }; + if (orderId !== undefined) params.orderId = orderId; + if (clientOrderId) params.clientOrderId = clientOrderId; - const data = await optionsClient.getOrder(params) + const data = await optionsClient.getOrder(params); return { content: [ @@ -29,15 +29,15 @@ export function registerBinanceOptionsGetOrder(server: McpServer) { text: `Order details retrieved. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-options/historicalTrades.ts b/src/tools/binance-options/historicalTrades.ts index b1d36c30..78b2fe14 100644 --- a/src/tools/binance-options/historicalTrades.ts +++ b/src/tools/binance-options/historicalTrades.ts @@ -1,9 +1,9 @@ // src/tools/binance-options/historicalTrades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js" +import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsHistoricalTrades(server: McpServer) { server.tool( @@ -16,11 +16,11 @@ export function registerBinanceOptionsHistoricalTrades(server: McpServer) { }, async ({ symbol, fromId, limit }) => { try { - const params: any = { symbol } - if (fromId !== undefined) params.fromId = fromId - if (limit !== undefined) params.limit = limit + const params: any = { symbol }; + if (fromId !== undefined) params.fromId = fromId; + if (limit !== undefined) params.limit = limit; - const data = await optionsClient.historicalTrades(params) + const data = await optionsClient.historicalTrades(params); return { content: [ @@ -29,15 +29,15 @@ export function registerBinanceOptionsHistoricalTrades(server: McpServer) { text: `Historical trades for ${symbol}. Count: ${Array.isArray(data) ? data.length : 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get historical trades: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-options/historyOrders.ts b/src/tools/binance-options/historyOrders.ts index c07196a4..37fff98b 100644 --- a/src/tools/binance-options/historyOrders.ts +++ b/src/tools/binance-options/historyOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-options/historyOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js" +import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsHistoryOrders(server: McpServer) { server.tool( @@ -18,13 +18,13 @@ export function registerBinanceOptionsHistoryOrders(server: McpServer) { }, async ({ symbol, orderId, startTime, endTime, limit }) => { try { - const params: any = { symbol } - if (orderId !== undefined) params.orderId = orderId - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + const params: any = { symbol }; + if (orderId !== undefined) params.orderId = orderId; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const data = await optionsClient.historyOrders(params) + const data = await optionsClient.historyOrders(params); return { content: [ @@ -33,15 +33,15 @@ export function registerBinanceOptionsHistoryOrders(server: McpServer) { text: `Historical orders retrieved. Count: ${Array.isArray(data) ? data.length : 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get history orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-options/index.ts b/src/tools/binance-options/index.ts index d79773ff..f86d2d21 100644 --- a/src/tools/binance-options/index.ts +++ b/src/tools/binance-options/index.ts @@ -1,72 +1,72 @@ // src/tools/binance-options/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; // Account & Trading -import { registerBinanceOptionsAccount } from "./account.js" -import { registerBinanceOptionsBatchOrders } from "./batchOrders.js" -import { registerBinanceOptionsBill } from "./bill.js" -import { registerBinanceOptionsCancelAllOrders } from "./cancelAllOrders.js" -import { registerBinanceOptionsCancelBatchOrders } from "./cancelBatchOrders.js" -import { registerBinanceOptionsCancelOrder } from "./cancelOrder.js" -import { registerBinanceOptionsDepth } from "./depth.js" -import { registerBinanceOptionsExchangeInfo } from "./exchangeInfo.js" -import { registerBinanceOptionsExerciseHistory } from "./exerciseHistory.js" -import { registerBinanceOptionsExerciseRecord } from "./exerciseRecord.js" -import { registerBinanceOptionsGetOrder } from "./getOrder.js" -import { registerBinanceOptionsHistoricalTrades } from "./historicalTrades.js" -import { registerBinanceOptionsHistoryOrders } from "./historyOrders.js" -import { registerBinanceOptionsIndexPrice } from "./indexPrice.js" -import { registerBinanceOptionsKlines } from "./klines.js" +import { registerBinanceOptionsAccount } from "./account.js"; +import { registerBinanceOptionsBatchOrders } from "./batchOrders.js"; +import { registerBinanceOptionsBill } from "./bill.js"; +import { registerBinanceOptionsCancelAllOrders } from "./cancelAllOrders.js"; +import { registerBinanceOptionsCancelBatchOrders } from "./cancelBatchOrders.js"; +import { registerBinanceOptionsCancelOrder } from "./cancelOrder.js"; +import { registerBinanceOptionsDepth } from "./depth.js"; +import { registerBinanceOptionsExchangeInfo } from "./exchangeInfo.js"; +import { registerBinanceOptionsExerciseHistory } from "./exerciseHistory.js"; +import { registerBinanceOptionsExerciseRecord } from "./exerciseRecord.js"; +import { registerBinanceOptionsGetOrder } from "./getOrder.js"; +import { registerBinanceOptionsHistoricalTrades } from "./historicalTrades.js"; +import { registerBinanceOptionsHistoryOrders } from "./historyOrders.js"; +import { registerBinanceOptionsIndexPrice } from "./indexPrice.js"; +import { registerBinanceOptionsKlines } from "./klines.js"; // User Data Stream import { registerBinanceOptionsCreateListenKey, registerBinanceOptionsDeleteListenKey, registerBinanceOptionsKeepAliveListenKey, -} from "./listenKey.js" -import { registerBinanceOptionsMark } from "./mark.js" -import { registerBinanceOptionsNewOrder } from "./newOrder.js" -import { registerBinanceOptionsOpenInterest } from "./openInterest.js" -import { registerBinanceOptionsOpenOrders } from "./openOrders.js" +} from "./listenKey.js"; +import { registerBinanceOptionsMark } from "./mark.js"; +import { registerBinanceOptionsNewOrder } from "./newOrder.js"; +import { registerBinanceOptionsOpenInterest } from "./openInterest.js"; +import { registerBinanceOptionsOpenOrders } from "./openOrders.js"; // Market Data -import { registerBinanceOptionsPing } from "./ping.js" -import { registerBinanceOptionsPosition } from "./position.js" -import { registerBinanceOptionsTicker } from "./ticker.js" -import { registerBinanceOptionsTime } from "./time.js" -import { registerBinanceOptionsTrades } from "./trades.js" -import { registerBinanceOptionsUserTrades } from "./userTrades.js" +import { registerBinanceOptionsPing } from "./ping.js"; +import { registerBinanceOptionsPosition } from "./position.js"; +import { registerBinanceOptionsTicker } from "./ticker.js"; +import { registerBinanceOptionsTime } from "./time.js"; +import { registerBinanceOptionsTrades } from "./trades.js"; +import { registerBinanceOptionsUserTrades } from "./userTrades.js"; export function registerBinanceOptionsTools(server: McpServer) { // Market Data - registerBinanceOptionsPing(server) - registerBinanceOptionsTime(server) - registerBinanceOptionsExchangeInfo(server) - registerBinanceOptionsDepth(server) - registerBinanceOptionsTrades(server) - registerBinanceOptionsHistoricalTrades(server) - registerBinanceOptionsKlines(server) - registerBinanceOptionsMark(server) - registerBinanceOptionsTicker(server) - registerBinanceOptionsIndexPrice(server) - registerBinanceOptionsExerciseHistory(server) - registerBinanceOptionsOpenInterest(server) + registerBinanceOptionsPing(server); + registerBinanceOptionsTime(server); + registerBinanceOptionsExchangeInfo(server); + registerBinanceOptionsDepth(server); + registerBinanceOptionsTrades(server); + registerBinanceOptionsHistoricalTrades(server); + registerBinanceOptionsKlines(server); + registerBinanceOptionsMark(server); + registerBinanceOptionsTicker(server); + registerBinanceOptionsIndexPrice(server); + registerBinanceOptionsExerciseHistory(server); + registerBinanceOptionsOpenInterest(server); // Account & Trading - registerBinanceOptionsAccount(server) - registerBinanceOptionsNewOrder(server) - registerBinanceOptionsBatchOrders(server) - registerBinanceOptionsCancelOrder(server) - registerBinanceOptionsCancelAllOrders(server) - registerBinanceOptionsCancelBatchOrders(server) - registerBinanceOptionsGetOrder(server) - registerBinanceOptionsOpenOrders(server) - registerBinanceOptionsHistoryOrders(server) - registerBinanceOptionsPosition(server) - registerBinanceOptionsUserTrades(server) - registerBinanceOptionsExerciseRecord(server) - registerBinanceOptionsBill(server) + registerBinanceOptionsAccount(server); + registerBinanceOptionsNewOrder(server); + registerBinanceOptionsBatchOrders(server); + registerBinanceOptionsCancelOrder(server); + registerBinanceOptionsCancelAllOrders(server); + registerBinanceOptionsCancelBatchOrders(server); + registerBinanceOptionsGetOrder(server); + registerBinanceOptionsOpenOrders(server); + registerBinanceOptionsHistoryOrders(server); + registerBinanceOptionsPosition(server); + registerBinanceOptionsUserTrades(server); + registerBinanceOptionsExerciseRecord(server); + registerBinanceOptionsBill(server); // User Data Stream - registerBinanceOptionsCreateListenKey(server) - registerBinanceOptionsKeepAliveListenKey(server) - registerBinanceOptionsDeleteListenKey(server) + registerBinanceOptionsCreateListenKey(server); + registerBinanceOptionsKeepAliveListenKey(server); + registerBinanceOptionsDeleteListenKey(server); } diff --git a/src/tools/binance-options/indexPrice.ts b/src/tools/binance-options/indexPrice.ts index 97bc2ed2..56c0f18e 100644 --- a/src/tools/binance-options/indexPrice.ts +++ b/src/tools/binance-options/indexPrice.ts @@ -1,9 +1,9 @@ // src/tools/binance-options/indexPrice.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js" +import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsIndexPrice(server: McpServer) { server.tool( @@ -14,9 +14,9 @@ export function registerBinanceOptionsIndexPrice(server: McpServer) { }, async ({ underlying }) => { try { - const params: any = { underlying } + const params: any = { underlying }; - const data = await optionsClient.index(params) + const data = await optionsClient.index(params); return { content: [ @@ -25,15 +25,15 @@ export function registerBinanceOptionsIndexPrice(server: McpServer) { text: `Index price for ${underlying} retrieved. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get index price: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-options/klines.ts b/src/tools/binance-options/klines.ts index b36fc207..2aba9cee 100644 --- a/src/tools/binance-options/klines.ts +++ b/src/tools/binance-options/klines.ts @@ -1,9 +1,9 @@ // src/tools/binance-options/klines.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js" +import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsKlines(server: McpServer) { server.tool( @@ -20,12 +20,12 @@ export function registerBinanceOptionsKlines(server: McpServer) { }, async ({ symbol, interval, startTime, endTime, limit }) => { try { - const params: any = { symbol, interval } - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + const params: any = { symbol, interval }; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const data = await optionsClient.klines(params) + const data = await optionsClient.klines(params); return { content: [ @@ -34,15 +34,15 @@ export function registerBinanceOptionsKlines(server: McpServer) { text: `Klines for ${symbol}. Count: ${Array.isArray(data) ? data.length : 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get klines: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-options/listenKey.ts b/src/tools/binance-options/listenKey.ts index f4a78cfc..2c56bf30 100644 --- a/src/tools/binance-options/listenKey.ts +++ b/src/tools/binance-options/listenKey.ts @@ -1,9 +1,9 @@ // src/tools/binance-options/listenKey.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js" +import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsCreateListenKey(server: McpServer) { server.tool( @@ -12,7 +12,7 @@ export function registerBinanceOptionsCreateListenKey(server: McpServer) { {}, async () => { try { - const data = await optionsClient.createListenKey() + const data = await optionsClient.createListenKey(); return { content: [ @@ -21,17 +21,17 @@ export function registerBinanceOptionsCreateListenKey(server: McpServer) { text: `Listen key created successfully. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to create listen key: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } export function registerBinanceOptionsKeepAliveListenKey(server: McpServer) { @@ -43,7 +43,7 @@ export function registerBinanceOptionsKeepAliveListenKey(server: McpServer) { }, async ({ listenKey: _listenKey }) => { try { - const data = await optionsClient.keepAliveListenKey() + const data = await optionsClient.keepAliveListenKey(); return { content: [ @@ -52,17 +52,17 @@ export function registerBinanceOptionsKeepAliveListenKey(server: McpServer) { text: `Listen key renewed successfully. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to renew listen key: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } export function registerBinanceOptionsDeleteListenKey(server: McpServer) { @@ -74,7 +74,7 @@ export function registerBinanceOptionsDeleteListenKey(server: McpServer) { }, async ({ listenKey: _listenKey }) => { try { - const data = await optionsClient.closeListenKey() + const data = await optionsClient.closeListenKey(); return { content: [ @@ -83,15 +83,15 @@ export function registerBinanceOptionsDeleteListenKey(server: McpServer) { text: `Listen key deleted successfully. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to delete listen key: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-options/mark.ts b/src/tools/binance-options/mark.ts index 6144971a..370e673d 100644 --- a/src/tools/binance-options/mark.ts +++ b/src/tools/binance-options/mark.ts @@ -1,9 +1,9 @@ // src/tools/binance-options/mark.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js" +import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsMark(server: McpServer) { server.tool( @@ -14,10 +14,10 @@ export function registerBinanceOptionsMark(server: McpServer) { }, async ({ symbol }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol + const params: any = {}; + if (symbol) params.symbol = symbol; - const data = await optionsClient.mark(params) + const data = await optionsClient.mark(params); return { content: [ @@ -26,15 +26,15 @@ export function registerBinanceOptionsMark(server: McpServer) { text: `Option mark price retrieved. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get mark price: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-options/newOrder.ts b/src/tools/binance-options/newOrder.ts index 1aeba590..56f41118 100644 --- a/src/tools/binance-options/newOrder.ts +++ b/src/tools/binance-options/newOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-options/newOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js" +import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsNewOrder(server: McpServer) { server.tool( @@ -34,15 +34,15 @@ export function registerBinanceOptionsNewOrder(server: McpServer) { clientOrderId, }) => { try { - const params: any = { symbol, side, type, quantity } - if (price !== undefined) params.price = price - if (timeInForce) params.timeInForce = timeInForce - if (reduceOnly !== undefined) params.reduceOnly = reduceOnly - if (postOnly !== undefined) params.postOnly = postOnly - if (newOrderRespType) params.newOrderRespType = newOrderRespType - if (clientOrderId) params.clientOrderId = clientOrderId + const params: any = { symbol, side, type, quantity }; + if (price !== undefined) params.price = price; + if (timeInForce) params.timeInForce = timeInForce; + if (reduceOnly !== undefined) params.reduceOnly = reduceOnly; + if (postOnly !== undefined) params.postOnly = postOnly; + if (newOrderRespType) params.newOrderRespType = newOrderRespType; + if (clientOrderId) params.clientOrderId = clientOrderId; - const data = await optionsClient.newOrder(params) + const data = await optionsClient.newOrder(params); return { content: [ @@ -51,15 +51,15 @@ export function registerBinanceOptionsNewOrder(server: McpServer) { text: `Options order created successfully. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to create order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-options/openInterest.ts b/src/tools/binance-options/openInterest.ts index 7906638c..e63d9560 100644 --- a/src/tools/binance-options/openInterest.ts +++ b/src/tools/binance-options/openInterest.ts @@ -1,9 +1,9 @@ // src/tools/binance-options/openInterest.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js" +import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsOpenInterest(server: McpServer) { server.tool( @@ -15,9 +15,9 @@ export function registerBinanceOptionsOpenInterest(server: McpServer) { }, async ({ underlyingAsset, expiration }) => { try { - const params: any = { underlyingAsset, expiration } + const params: any = { underlyingAsset, expiration }; - const data = await optionsClient.openInterest(params) + const data = await optionsClient.openInterest(params); return { content: [ @@ -26,15 +26,15 @@ export function registerBinanceOptionsOpenInterest(server: McpServer) { text: `Open interest retrieved. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get open interest: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-options/openOrders.ts b/src/tools/binance-options/openOrders.ts index 0c9cb8b7..ed489a0d 100644 --- a/src/tools/binance-options/openOrders.ts +++ b/src/tools/binance-options/openOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-options/openOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js" +import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsOpenOrders(server: McpServer) { server.tool( @@ -14,10 +14,10 @@ export function registerBinanceOptionsOpenOrders(server: McpServer) { }, async ({ symbol }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol + const params: any = {}; + if (symbol) params.symbol = symbol; - const data = await optionsClient.openOrders(params) + const data = await optionsClient.openOrders(params); return { content: [ @@ -26,15 +26,15 @@ export function registerBinanceOptionsOpenOrders(server: McpServer) { text: `Open orders retrieved. Count: ${Array.isArray(data) ? data.length : 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get open orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-options/ping.ts b/src/tools/binance-options/ping.ts index d193ddc0..435a4f9f 100644 --- a/src/tools/binance-options/ping.ts +++ b/src/tools/binance-options/ping.ts @@ -1,7 +1,7 @@ // src/tools/binance-options/ping.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../config/binanceClient.js" +import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsPing(server: McpServer) { server.tool( @@ -10,7 +10,7 @@ export function registerBinanceOptionsPing(server: McpServer) { {}, async () => { try { - const data = await optionsClient.ping() + const data = await optionsClient.ping(); return { content: [ @@ -19,17 +19,17 @@ export function registerBinanceOptionsPing(server: McpServer) { text: `Options API connectivity test successful. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Options API connectivity test failed: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-options/position.ts b/src/tools/binance-options/position.ts index 20b89dd8..d4b68995 100644 --- a/src/tools/binance-options/position.ts +++ b/src/tools/binance-options/position.ts @@ -1,9 +1,9 @@ // src/tools/binance-options/position.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js" +import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsPosition(server: McpServer) { server.tool( @@ -14,10 +14,10 @@ export function registerBinanceOptionsPosition(server: McpServer) { }, async ({ symbol }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol + const params: any = {}; + if (symbol) params.symbol = symbol; - const data = await optionsClient.position(params) + const data = await optionsClient.position(params); return { content: [ @@ -26,15 +26,15 @@ export function registerBinanceOptionsPosition(server: McpServer) { text: `Position information retrieved. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get position: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-options/ticker.ts b/src/tools/binance-options/ticker.ts index 878bb0c2..29a2254a 100644 --- a/src/tools/binance-options/ticker.ts +++ b/src/tools/binance-options/ticker.ts @@ -1,9 +1,9 @@ // src/tools/binance-options/ticker.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js" +import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsTicker(server: McpServer) { server.tool( @@ -14,10 +14,10 @@ export function registerBinanceOptionsTicker(server: McpServer) { }, async ({ symbol }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol + const params: any = {}; + if (symbol) params.symbol = symbol; - const data = await optionsClient.ticker(params) + const data = await optionsClient.ticker(params); return { content: [ @@ -26,15 +26,15 @@ export function registerBinanceOptionsTicker(server: McpServer) { text: `24hr ticker statistics retrieved. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get ticker: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-options/time.ts b/src/tools/binance-options/time.ts index d7b6c876..5807400a 100644 --- a/src/tools/binance-options/time.ts +++ b/src/tools/binance-options/time.ts @@ -1,7 +1,7 @@ // src/tools/binance-options/time.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { optionsClient } from "../../config/binanceClient.js" +import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsTime(server: McpServer) { server.tool( @@ -10,7 +10,7 @@ export function registerBinanceOptionsTime(server: McpServer) { {}, async () => { try { - const data = await optionsClient.time() + const data = await optionsClient.time(); return { content: [ @@ -19,15 +19,15 @@ export function registerBinanceOptionsTime(server: McpServer) { text: `Server time retrieved successfully. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get server time: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-options/trades.ts b/src/tools/binance-options/trades.ts index 807d1f6f..f2cdead4 100644 --- a/src/tools/binance-options/trades.ts +++ b/src/tools/binance-options/trades.ts @@ -1,9 +1,9 @@ // src/tools/binance-options/trades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js" +import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsTrades(server: McpServer) { server.tool( @@ -15,10 +15,10 @@ export function registerBinanceOptionsTrades(server: McpServer) { }, async ({ symbol, limit }) => { try { - const params: any = { symbol } - if (limit !== undefined) params.limit = limit + const params: any = { symbol }; + if (limit !== undefined) params.limit = limit; - const data = await optionsClient.trades(params) + const data = await optionsClient.trades(params); return { content: [ @@ -27,15 +27,15 @@ export function registerBinanceOptionsTrades(server: McpServer) { text: `Recent trades for ${symbol}. Count: ${Array.isArray(data) ? data.length : 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get recent trades: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-options/userTrades.ts b/src/tools/binance-options/userTrades.ts index fee19f4b..6f93f4f9 100644 --- a/src/tools/binance-options/userTrades.ts +++ b/src/tools/binance-options/userTrades.ts @@ -1,9 +1,9 @@ // src/tools/binance-options/userTrades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { optionsClient } from "../../config/binanceClient.js" +import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsUserTrades(server: McpServer) { server.tool( @@ -18,14 +18,14 @@ export function registerBinanceOptionsUserTrades(server: McpServer) { }, async ({ symbol, fromId, startTime, endTime, limit }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol - if (fromId !== undefined) params.fromId = fromId - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + const params: any = {}; + if (symbol) params.symbol = symbol; + if (fromId !== undefined) params.fromId = fromId; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const data = await optionsClient.userTrades(params) + const data = await optionsClient.userTrades(params); return { content: [ @@ -34,15 +34,15 @@ export function registerBinanceOptionsUserTrades(server: McpServer) { text: `User trades retrieved. Count: ${Array.isArray(data) ? data.length : 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get user trades: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-pay/index.ts b/src/tools/binance-pay/index.ts index 77fe5ce6..5d04881a 100644 --- a/src/tools/binance-pay/index.ts +++ b/src/tools/binance-pay/index.ts @@ -1,8 +1,8 @@ // src/tools/binance-pay/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetPayTradeHistory } from "./pay-api/getPayTradeHistory.js" +import { registerBinanceGetPayTradeHistory } from "./pay-api/getPayTradeHistory.js"; export function registerBinancePayTools(server: McpServer) { - registerBinanceGetPayTradeHistory(server) + registerBinanceGetPayTradeHistory(server); } diff --git a/src/tools/binance-pay/pay-api/getPayTradeHistory.ts b/src/tools/binance-pay/pay-api/getPayTradeHistory.ts index e55a6c73..479cd14d 100644 --- a/src/tools/binance-pay/pay-api/getPayTradeHistory.ts +++ b/src/tools/binance-pay/pay-api/getPayTradeHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-pay/pay-api/getPayTradeHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { payClient } from "../../../config/binanceClient.js" +import { payClient } from "../../../config/binanceClient.js"; export function registerBinanceGetPayTradeHistory(server: McpServer) { server.tool( @@ -27,9 +27,9 @@ export function registerBinanceGetPayTradeHistory(server: McpServer) { ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -38,9 +38,9 @@ export function registerBinanceGetPayTradeHistory(server: McpServer) { text: `Successfully retrieved Binance Pay trade history. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -50,8 +50,8 @@ export function registerBinanceGetPayTradeHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-portfolio-margin/bnbTransfer.ts b/src/tools/binance-portfolio-margin/bnbTransfer.ts index 74f5aece..f7c950d5 100644 --- a/src/tools/binance-portfolio-margin/bnbTransfer.ts +++ b/src/tools/binance-portfolio-margin/bnbTransfer.ts @@ -1,9 +1,9 @@ // src/tools/binance-portfolio-margin/bnbTransfer.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../config/binanceClient.js" +import { portfolioMarginClient } from "../../config/binanceClient.js"; export function registerBinancePortfolioMarginBnbTransfer(server: McpServer) { server.tool( @@ -18,10 +18,10 @@ export function registerBinancePortfolioMarginBnbTransfer(server: McpServer) { }, async ({ amount, transferSide, recvWindow }) => { try { - const params: Record = { amount, transferSide } - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = { amount, transferSide }; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await portfolioMarginClient.bnbTransfer(params) + const data = await portfolioMarginClient.bnbTransfer(params); return { content: [ @@ -30,15 +30,15 @@ export function registerBinancePortfolioMarginBnbTransfer(server: McpServer) { text: `BNB transfer completed. Amount: ${amount}, Direction: ${transferSide}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to transfer BNB: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-portfolio-margin/changeAutoRepayFutures.ts b/src/tools/binance-portfolio-margin/changeAutoRepayFutures.ts index 3ddb450f..cf462c5a 100644 --- a/src/tools/binance-portfolio-margin/changeAutoRepayFutures.ts +++ b/src/tools/binance-portfolio-margin/changeAutoRepayFutures.ts @@ -1,9 +1,9 @@ // src/tools/binance-portfolio-margin/changeAutoRepayFutures.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../config/binanceClient.js" +import { portfolioMarginClient } from "../../config/binanceClient.js"; export function registerBinancePortfolioMarginChangeAutoRepayFutures(server: McpServer) { server.tool( @@ -15,10 +15,10 @@ export function registerBinancePortfolioMarginChangeAutoRepayFutures(server: Mcp }, async ({ autoRepay, recvWindow }) => { try { - const params: Record = { autoRepay } - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = { autoRepay }; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await portfolioMarginClient.changeAutoRepayFutures(params) + const data = await portfolioMarginClient.changeAutoRepayFutures(params); return { content: [ @@ -27,17 +27,17 @@ export function registerBinancePortfolioMarginChangeAutoRepayFutures(server: Mcp text: `Auto-repay-futures status changed to ${autoRepay}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to change auto-repay-futures status: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-portfolio-margin/fundAutoCollection.ts b/src/tools/binance-portfolio-margin/fundAutoCollection.ts index 72d6ce34..be602097 100644 --- a/src/tools/binance-portfolio-margin/fundAutoCollection.ts +++ b/src/tools/binance-portfolio-margin/fundAutoCollection.ts @@ -1,9 +1,9 @@ // src/tools/binance-portfolio-margin/fundAutoCollection.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../config/binanceClient.js" +import { portfolioMarginClient } from "../../config/binanceClient.js"; export function registerBinancePortfolioMarginFundAutoCollection(server: McpServer) { server.tool( @@ -14,10 +14,10 @@ export function registerBinancePortfolioMarginFundAutoCollection(server: McpServ }, async ({ recvWindow }) => { try { - const params: Record = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await portfolioMarginClient.fundAutoCollection(params) + const data = await portfolioMarginClient.fundAutoCollection(params); return { content: [ @@ -26,17 +26,17 @@ export function registerBinancePortfolioMarginFundAutoCollection(server: McpServ text: `Fund auto-collection configured. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to configure fund auto-collection: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-portfolio-margin/fundCollection.ts b/src/tools/binance-portfolio-margin/fundCollection.ts index f7a415ad..a28cfd85 100644 --- a/src/tools/binance-portfolio-margin/fundCollection.ts +++ b/src/tools/binance-portfolio-margin/fundCollection.ts @@ -1,9 +1,9 @@ // src/tools/binance-portfolio-margin/fundCollection.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../config/binanceClient.js" +import { portfolioMarginClient } from "../../config/binanceClient.js"; export function registerBinancePortfolioMarginFundCollection(server: McpServer) { server.tool( @@ -15,10 +15,10 @@ export function registerBinancePortfolioMarginFundCollection(server: McpServer) }, async ({ asset, recvWindow }) => { try { - const params: Record = { asset } - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = { asset }; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await portfolioMarginClient.fundCollection(params) + const data = await portfolioMarginClient.fundCollection(params); return { content: [ @@ -27,15 +27,15 @@ export function registerBinancePortfolioMarginFundCollection(server: McpServer) text: `Fund collection triggered for ${asset}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to trigger fund collection: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-portfolio-margin/getAccountBalance.ts b/src/tools/binance-portfolio-margin/getAccountBalance.ts index d170aacf..b29aa5b3 100644 --- a/src/tools/binance-portfolio-margin/getAccountBalance.ts +++ b/src/tools/binance-portfolio-margin/getAccountBalance.ts @@ -1,9 +1,9 @@ // src/tools/binance-portfolio-margin/getAccountBalance.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../config/binanceClient.js" +import { portfolioMarginClient } from "../../config/binanceClient.js"; export function registerBinancePortfolioMarginGetAccountBalance(server: McpServer) { server.tool( @@ -18,11 +18,11 @@ export function registerBinancePortfolioMarginGetAccountBalance(server: McpServe }, async ({ asset, recvWindow }) => { try { - const params: Record = {} - if (asset !== undefined) params.asset = asset - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = {}; + if (asset !== undefined) params.asset = asset; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await portfolioMarginClient.getBalance(params) + const data = await portfolioMarginClient.getBalance(params); return { content: [ @@ -31,15 +31,15 @@ export function registerBinancePortfolioMarginGetAccountBalance(server: McpServe text: `Retrieved account balance. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve account balance: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-portfolio-margin/getAutoRepayFuturesStatus.ts b/src/tools/binance-portfolio-margin/getAutoRepayFuturesStatus.ts index 0212151a..850c3022 100644 --- a/src/tools/binance-portfolio-margin/getAutoRepayFuturesStatus.ts +++ b/src/tools/binance-portfolio-margin/getAutoRepayFuturesStatus.ts @@ -1,9 +1,9 @@ // src/tools/binance-portfolio-margin/getAutoRepayFuturesStatus.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../config/binanceClient.js" +import { portfolioMarginClient } from "../../config/binanceClient.js"; export function registerBinancePortfolioMarginGetAutoRepayFuturesStatus(server: McpServer) { server.tool( @@ -14,10 +14,10 @@ export function registerBinancePortfolioMarginGetAutoRepayFuturesStatus(server: }, async ({ recvWindow }) => { try { - const params: Record = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await portfolioMarginClient.getAutoRepayFuturesStatus(params) + const data = await portfolioMarginClient.getAutoRepayFuturesStatus(params); return { content: [ @@ -26,17 +26,17 @@ export function registerBinancePortfolioMarginGetAutoRepayFuturesStatus(server: text: `Retrieved auto-repay-futures status. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve auto-repay-futures status: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-portfolio-margin/getCollateralRate.ts b/src/tools/binance-portfolio-margin/getCollateralRate.ts index 585968e2..fcb77511 100644 --- a/src/tools/binance-portfolio-margin/getCollateralRate.ts +++ b/src/tools/binance-portfolio-margin/getCollateralRate.ts @@ -1,9 +1,9 @@ // src/tools/binance-portfolio-margin/getCollateralRate.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../config/binanceClient.js" +import { portfolioMarginClient } from "../../config/binanceClient.js"; export function registerBinancePortfolioMarginGetCollateralRate(server: McpServer) { server.tool( @@ -14,10 +14,10 @@ export function registerBinancePortfolioMarginGetCollateralRate(server: McpServe }, async ({ recvWindow }) => { try { - const params: Record = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await portfolioMarginClient.getCollateralRate(params) + const data = await portfolioMarginClient.getCollateralRate(params); return { content: [ @@ -26,15 +26,15 @@ export function registerBinancePortfolioMarginGetCollateralRate(server: McpServe text: `Retrieved portfolio margin collateral rate. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve collateral rate: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-portfolio-margin/getPortfolioMarginAccount.ts b/src/tools/binance-portfolio-margin/getPortfolioMarginAccount.ts index 83277993..e1a4defa 100644 --- a/src/tools/binance-portfolio-margin/getPortfolioMarginAccount.ts +++ b/src/tools/binance-portfolio-margin/getPortfolioMarginAccount.ts @@ -1,9 +1,9 @@ // src/tools/binance-portfolio-margin/getPortfolioMarginAccount.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../config/binanceClient.js" +import { portfolioMarginClient } from "../../config/binanceClient.js"; export function registerBinancePortfolioMarginGetAccount(server: McpServer) { server.tool( @@ -14,10 +14,10 @@ export function registerBinancePortfolioMarginGetAccount(server: McpServer) { }, async ({ recvWindow }) => { try { - const params: Record = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await portfolioMarginClient.getAccount(params) + const data = await portfolioMarginClient.getAccount(params); return { content: [ @@ -26,17 +26,17 @@ export function registerBinancePortfolioMarginGetAccount(server: McpServer) { text: `Retrieved portfolio margin account info. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve portfolio margin account: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-portfolio-margin/getPortfolioMarginAssetIndexPrice.ts b/src/tools/binance-portfolio-margin/getPortfolioMarginAssetIndexPrice.ts index ed051564..74fbaca6 100644 --- a/src/tools/binance-portfolio-margin/getPortfolioMarginAssetIndexPrice.ts +++ b/src/tools/binance-portfolio-margin/getPortfolioMarginAssetIndexPrice.ts @@ -1,9 +1,9 @@ // src/tools/binance-portfolio-margin/getPortfolioMarginAssetIndexPrice.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../config/binanceClient.js" +import { portfolioMarginClient } from "../../config/binanceClient.js"; export function registerBinancePortfolioMarginGetAssetIndexPrice(server: McpServer) { server.tool( @@ -18,11 +18,11 @@ export function registerBinancePortfolioMarginGetAssetIndexPrice(server: McpServ }, async ({ asset, recvWindow }) => { try { - const params: Record = {} - if (asset !== undefined) params.asset = asset - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = {}; + if (asset !== undefined) params.asset = asset; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await portfolioMarginClient.getAssetIndexPrice(params) + const data = await portfolioMarginClient.getAssetIndexPrice(params); return { content: [ @@ -31,17 +31,17 @@ export function registerBinancePortfolioMarginGetAssetIndexPrice(server: McpServ text: `Retrieved asset index price. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve asset index price: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-portfolio-margin/getPortfolioMarginAssetLeverage.ts b/src/tools/binance-portfolio-margin/getPortfolioMarginAssetLeverage.ts index e08c1bb9..da53d339 100644 --- a/src/tools/binance-portfolio-margin/getPortfolioMarginAssetLeverage.ts +++ b/src/tools/binance-portfolio-margin/getPortfolioMarginAssetLeverage.ts @@ -1,9 +1,9 @@ // src/tools/binance-portfolio-margin/getPortfolioMarginAssetLeverage.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../config/binanceClient.js" +import { portfolioMarginClient } from "../../config/binanceClient.js"; export function registerBinancePortfolioMarginGetAssetLeverage(server: McpServer) { server.tool( @@ -14,10 +14,10 @@ export function registerBinancePortfolioMarginGetAssetLeverage(server: McpServer }, async ({ recvWindow }) => { try { - const params: Record = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await portfolioMarginClient.getAssetLeverage(params) + const data = await portfolioMarginClient.getAssetLeverage(params); return { content: [ @@ -26,15 +26,15 @@ export function registerBinancePortfolioMarginGetAssetLeverage(server: McpServer text: `Retrieved asset leverage information. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve asset leverage: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-portfolio-margin/getPortfolioMarginBankruptcyLoanAmount.ts b/src/tools/binance-portfolio-margin/getPortfolioMarginBankruptcyLoanAmount.ts index aa067e1f..90356a51 100644 --- a/src/tools/binance-portfolio-margin/getPortfolioMarginBankruptcyLoanAmount.ts +++ b/src/tools/binance-portfolio-margin/getPortfolioMarginBankruptcyLoanAmount.ts @@ -1,9 +1,9 @@ // src/tools/binance-portfolio-margin/getPortfolioMarginBankruptcyLoanAmount.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../config/binanceClient.js" +import { portfolioMarginClient } from "../../config/binanceClient.js"; export function registerBinancePortfolioMarginGetBankruptcyLoanAmount(server: McpServer) { server.tool( @@ -14,10 +14,10 @@ export function registerBinancePortfolioMarginGetBankruptcyLoanAmount(server: Mc }, async ({ recvWindow }) => { try { - const params: Record = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await portfolioMarginClient.getBankruptcyLoanAmount(params) + const data = await portfolioMarginClient.getBankruptcyLoanAmount(params); return { content: [ @@ -26,17 +26,17 @@ export function registerBinancePortfolioMarginGetBankruptcyLoanAmount(server: Mc text: `Retrieved bankruptcy loan amount. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve bankruptcy loan amount: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-portfolio-margin/getPortfolioMarginInterestHistory.ts b/src/tools/binance-portfolio-margin/getPortfolioMarginInterestHistory.ts index 3c9cdcc9..57d8c48b 100644 --- a/src/tools/binance-portfolio-margin/getPortfolioMarginInterestHistory.ts +++ b/src/tools/binance-portfolio-margin/getPortfolioMarginInterestHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-portfolio-margin/getPortfolioMarginInterestHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../config/binanceClient.js" +import { portfolioMarginClient } from "../../config/binanceClient.js"; export function registerBinancePortfolioMarginGetInterestHistory(server: McpServer) { server.tool( @@ -18,14 +18,14 @@ export function registerBinancePortfolioMarginGetInterestHistory(server: McpServ }, async ({ asset, startTime, endTime, size, recvWindow }) => { try { - const params: Record = {} - if (asset !== undefined) params.asset = asset - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (size !== undefined) params.size = size - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = {}; + if (asset !== undefined) params.asset = asset; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (size !== undefined) params.size = size; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await portfolioMarginClient.getInterestHistory(params) + const data = await portfolioMarginClient.getInterestHistory(params); return { content: [ @@ -34,15 +34,15 @@ export function registerBinancePortfolioMarginGetInterestHistory(server: McpServ text: `Retrieved interest history. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve interest history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-portfolio-margin/index.ts b/src/tools/binance-portfolio-margin/index.ts index ec08ff82..ff02d9aa 100644 --- a/src/tools/binance-portfolio-margin/index.ts +++ b/src/tools/binance-portfolio-margin/index.ts @@ -1,41 +1,41 @@ // src/tools/binance-portfolio-margin/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinancePortfolioMarginBnbTransfer } from "./bnbTransfer.js" -import { registerBinancePortfolioMarginChangeAutoRepayFutures } from "./changeAutoRepayFutures.js" -import { registerBinancePortfolioMarginFundAutoCollection } from "./fundAutoCollection.js" -import { registerBinancePortfolioMarginFundCollection } from "./fundCollection.js" -import { registerBinancePortfolioMarginGetAccountBalance } from "./getAccountBalance.js" -import { registerBinancePortfolioMarginGetAutoRepayFuturesStatus } from "./getAutoRepayFuturesStatus.js" -import { registerBinancePortfolioMarginGetCollateralRate } from "./getCollateralRate.js" -import { registerBinancePortfolioMarginGetAccount } from "./getPortfolioMarginAccount.js" -import { registerBinancePortfolioMarginGetAssetIndexPrice } from "./getPortfolioMarginAssetIndexPrice.js" -import { registerBinancePortfolioMarginGetAssetLeverage } from "./getPortfolioMarginAssetLeverage.js" -import { registerBinancePortfolioMarginGetBankruptcyLoanAmount } from "./getPortfolioMarginBankruptcyLoanAmount.js" -import { registerBinancePortfolioMarginGetInterestHistory } from "./getPortfolioMarginInterestHistory.js" -import { registerBinancePortfolioMarginRepayFuturesNegativeBalance } from "./repayFuturesNegativeBalance.js" -import { registerBinancePortfolioMarginRepayBankruptcyLoan } from "./repayPortfolioMarginBankruptcyLoan.js" +import { registerBinancePortfolioMarginBnbTransfer } from "./bnbTransfer.js"; +import { registerBinancePortfolioMarginChangeAutoRepayFutures } from "./changeAutoRepayFutures.js"; +import { registerBinancePortfolioMarginFundAutoCollection } from "./fundAutoCollection.js"; +import { registerBinancePortfolioMarginFundCollection } from "./fundCollection.js"; +import { registerBinancePortfolioMarginGetAccountBalance } from "./getAccountBalance.js"; +import { registerBinancePortfolioMarginGetAutoRepayFuturesStatus } from "./getAutoRepayFuturesStatus.js"; +import { registerBinancePortfolioMarginGetCollateralRate } from "./getCollateralRate.js"; +import { registerBinancePortfolioMarginGetAccount } from "./getPortfolioMarginAccount.js"; +import { registerBinancePortfolioMarginGetAssetIndexPrice } from "./getPortfolioMarginAssetIndexPrice.js"; +import { registerBinancePortfolioMarginGetAssetLeverage } from "./getPortfolioMarginAssetLeverage.js"; +import { registerBinancePortfolioMarginGetBankruptcyLoanAmount } from "./getPortfolioMarginBankruptcyLoanAmount.js"; +import { registerBinancePortfolioMarginGetInterestHistory } from "./getPortfolioMarginInterestHistory.js"; +import { registerBinancePortfolioMarginRepayFuturesNegativeBalance } from "./repayFuturesNegativeBalance.js"; +import { registerBinancePortfolioMarginRepayBankruptcyLoan } from "./repayPortfolioMarginBankruptcyLoan.js"; export function registerBinancePortfolioMarginTools(server: McpServer) { // Account Information - registerBinancePortfolioMarginGetAccount(server) - registerBinancePortfolioMarginGetAccountBalance(server) - registerBinancePortfolioMarginGetCollateralRate(server) - registerBinancePortfolioMarginGetAssetLeverage(server) - registerBinancePortfolioMarginGetAssetIndexPrice(server) + registerBinancePortfolioMarginGetAccount(server); + registerBinancePortfolioMarginGetAccountBalance(server); + registerBinancePortfolioMarginGetCollateralRate(server); + registerBinancePortfolioMarginGetAssetLeverage(server); + registerBinancePortfolioMarginGetAssetIndexPrice(server); // Interest & Loan Management - registerBinancePortfolioMarginGetInterestHistory(server) - registerBinancePortfolioMarginGetBankruptcyLoanAmount(server) - registerBinancePortfolioMarginRepayBankruptcyLoan(server) + registerBinancePortfolioMarginGetInterestHistory(server); + registerBinancePortfolioMarginGetBankruptcyLoanAmount(server); + registerBinancePortfolioMarginRepayBankruptcyLoan(server); // Fund Management - registerBinancePortfolioMarginFundAutoCollection(server) - registerBinancePortfolioMarginFundCollection(server) - registerBinancePortfolioMarginBnbTransfer(server) + registerBinancePortfolioMarginFundAutoCollection(server); + registerBinancePortfolioMarginFundCollection(server); + registerBinancePortfolioMarginBnbTransfer(server); // Futures Auto-Repay - registerBinancePortfolioMarginChangeAutoRepayFutures(server) - registerBinancePortfolioMarginGetAutoRepayFuturesStatus(server) - registerBinancePortfolioMarginRepayFuturesNegativeBalance(server) + registerBinancePortfolioMarginChangeAutoRepayFutures(server); + registerBinancePortfolioMarginGetAutoRepayFuturesStatus(server); + registerBinancePortfolioMarginRepayFuturesNegativeBalance(server); } diff --git a/src/tools/binance-portfolio-margin/repayFuturesNegativeBalance.ts b/src/tools/binance-portfolio-margin/repayFuturesNegativeBalance.ts index 0a0622d9..fbdc34e5 100644 --- a/src/tools/binance-portfolio-margin/repayFuturesNegativeBalance.ts +++ b/src/tools/binance-portfolio-margin/repayFuturesNegativeBalance.ts @@ -1,9 +1,9 @@ // src/tools/binance-portfolio-margin/repayFuturesNegativeBalance.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../config/binanceClient.js" +import { portfolioMarginClient } from "../../config/binanceClient.js"; export function registerBinancePortfolioMarginRepayFuturesNegativeBalance(server: McpServer) { server.tool( @@ -14,10 +14,10 @@ export function registerBinancePortfolioMarginRepayFuturesNegativeBalance(server }, async ({ recvWindow }) => { try { - const params: Record = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await portfolioMarginClient.repayFuturesNegativeBalance(params) + const data = await portfolioMarginClient.repayFuturesNegativeBalance(params); return { content: [ @@ -26,17 +26,17 @@ export function registerBinancePortfolioMarginRepayFuturesNegativeBalance(server text: `Futures negative balance repaid. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to repay futures negative balance: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-portfolio-margin/repayPortfolioMarginBankruptcyLoan.ts b/src/tools/binance-portfolio-margin/repayPortfolioMarginBankruptcyLoan.ts index 05982dc7..b06c3970 100644 --- a/src/tools/binance-portfolio-margin/repayPortfolioMarginBankruptcyLoan.ts +++ b/src/tools/binance-portfolio-margin/repayPortfolioMarginBankruptcyLoan.ts @@ -1,9 +1,9 @@ // src/tools/binance-portfolio-margin/repayPortfolioMarginBankruptcyLoan.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { portfolioMarginClient } from "../../config/binanceClient.js" +import { portfolioMarginClient } from "../../config/binanceClient.js"; export function registerBinancePortfolioMarginRepayBankruptcyLoan(server: McpServer) { server.tool( @@ -14,10 +14,10 @@ export function registerBinancePortfolioMarginRepayBankruptcyLoan(server: McpSer }, async ({ recvWindow }) => { try { - const params: Record = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await portfolioMarginClient.repayBankruptcyLoan(params) + const data = await portfolioMarginClient.repayBankruptcyLoan(params); return { content: [ @@ -26,15 +26,15 @@ export function registerBinancePortfolioMarginRepayBankruptcyLoan(server: McpSer text: `Successfully repaid bankruptcy loan. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to repay bankruptcy loan: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-rebate/index.ts b/src/tools/binance-rebate/index.ts index 7ffeab67..7a07677c 100644 --- a/src/tools/binance-rebate/index.ts +++ b/src/tools/binance-rebate/index.ts @@ -1,8 +1,8 @@ // src/tools/binance-rebate/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetSpotRebateHistoryRecords } from "./rebate-api/getSpotRebateHistoryRecords.js" +import { registerBinanceGetSpotRebateHistoryRecords } from "./rebate-api/getSpotRebateHistoryRecords.js"; export function registerBinanceRebateTools(server: McpServer) { - registerBinanceGetSpotRebateHistoryRecords(server) + registerBinanceGetSpotRebateHistoryRecords(server); } diff --git a/src/tools/binance-rebate/rebate-api/getSpotRebateHistoryRecords.ts b/src/tools/binance-rebate/rebate-api/getSpotRebateHistoryRecords.ts index 9a5e6b22..e0855594 100644 --- a/src/tools/binance-rebate/rebate-api/getSpotRebateHistoryRecords.ts +++ b/src/tools/binance-rebate/rebate-api/getSpotRebateHistoryRecords.ts @@ -1,9 +1,9 @@ // src/tools/binance-pay/rebate-api/getSpotRebateHistoryRecords.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { rebateClient } from "../../../config/binanceClient.js" +import { rebateClient } from "../../../config/binanceClient.js"; export function registerBinanceGetSpotRebateHistoryRecords(server: McpServer) { server.tool( @@ -22,9 +22,9 @@ export function registerBinanceGetSpotRebateHistoryRecords(server: McpServer) { ...(params.endTime && { endTime: params.endTime }), ...(params.page && { page: params.page }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,9 +35,9 @@ export function registerBinanceGetSpotRebateHistoryRecords(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -47,8 +47,8 @@ export function registerBinanceGetSpotRebateHistoryRecords(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-simple-earn/account-api/getFlexibleProductPosition.ts b/src/tools/binance-simple-earn/account-api/getFlexibleProductPosition.ts index 5f2208fc..3b657330 100644 --- a/src/tools/binance-simple-earn/account-api/getFlexibleProductPosition.ts +++ b/src/tools/binance-simple-earn/account-api/getFlexibleProductPosition.ts @@ -1,9 +1,9 @@ // src/tools/binance-simple-earn/account-api/getFlexibleProductPosition.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { simpleEarnClient } from "../../../config/binanceClient.js" +import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerBinanceGetFlexibleProductPosition(server: McpServer) { server.tool( @@ -37,9 +37,9 @@ export function registerBinanceGetFlexibleProductPosition(server: McpServer) { ...(params.current && { current: params.current }), ...(params.size && { size: params.size }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -50,9 +50,9 @@ export function registerBinanceGetFlexibleProductPosition(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -62,8 +62,8 @@ export function registerBinanceGetFlexibleProductPosition(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-simple-earn/account-api/index.ts b/src/tools/binance-simple-earn/account-api/index.ts index c3800c9b..ce694ad7 100644 --- a/src/tools/binance-simple-earn/account-api/index.ts +++ b/src/tools/binance-simple-earn/account-api/index.ts @@ -1,13 +1,13 @@ // src/tools/binance-simple-earn/account-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetFlexibleProductPosition } from "./getFlexibleProductPosition.js" -import { registerBinanceSimpleEarnFlexibleProductList } from "./simpleEarnFlexibleProductList.js" +import { registerBinanceGetFlexibleProductPosition } from "./getFlexibleProductPosition.js"; +import { registerBinanceSimpleEarnFlexibleProductList } from "./simpleEarnFlexibleProductList.js"; export function registerBinanceSimpleEarnAccountApiTools(server: McpServer) { // Registers a tool to get the list of flexible earning products - registerBinanceSimpleEarnFlexibleProductList(server) + registerBinanceSimpleEarnFlexibleProductList(server); // Registers a tool to get the user's position in flexible earning products - registerBinanceGetFlexibleProductPosition(server) + registerBinanceGetFlexibleProductPosition(server); } diff --git a/src/tools/binance-simple-earn/account-api/simpleEarnFlexibleProductList.ts b/src/tools/binance-simple-earn/account-api/simpleEarnFlexibleProductList.ts index a76d9793..0ad34c15 100644 --- a/src/tools/binance-simple-earn/account-api/simpleEarnFlexibleProductList.ts +++ b/src/tools/binance-simple-earn/account-api/simpleEarnFlexibleProductList.ts @@ -1,9 +1,9 @@ // src/tools/binance-simple-earn/account-api/simpleEarnFlexibleProductList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { simpleEarnClient } from "../../../config/binanceClient.js" +import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerBinanceSimpleEarnFlexibleProductList(server: McpServer) { server.tool( @@ -35,9 +35,9 @@ export function registerBinanceSimpleEarnFlexibleProductList(server: McpServer) ...(params.current && { current: params.current }), ...(params.size && { size: params.size }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -48,9 +48,9 @@ export function registerBinanceSimpleEarnFlexibleProductList(server: McpServer) )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -60,8 +60,8 @@ export function registerBinanceSimpleEarnFlexibleProductList(server: McpServer) }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-simple-earn/earn-api/index.ts b/src/tools/binance-simple-earn/earn-api/index.ts index 219084b7..3c1f18b4 100644 --- a/src/tools/binance-simple-earn/earn-api/index.ts +++ b/src/tools/binance-simple-earn/earn-api/index.ts @@ -1,13 +1,13 @@ // src/tools/binance-simple-earn/earn-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceRedeemFlexibleProduct } from "./redeemFlexibleProduct.js" -import { registerBinanceSubscribeFlexibleProduct } from "./subscribeFlexibleProduct.js" +import { registerBinanceRedeemFlexibleProduct } from "./redeemFlexibleProduct.js"; +import { registerBinanceSubscribeFlexibleProduct } from "./subscribeFlexibleProduct.js"; export function registerBinanceSimpleEarnApiTools(server: McpServer) { // Register the route for subscribing to a flexible earn product - registerBinanceSubscribeFlexibleProduct(server) + registerBinanceSubscribeFlexibleProduct(server); // Register the route for redeeming from a flexible earn product - registerBinanceRedeemFlexibleProduct(server) + registerBinanceRedeemFlexibleProduct(server); } diff --git a/src/tools/binance-simple-earn/earn-api/redeemFlexibleProduct.ts b/src/tools/binance-simple-earn/earn-api/redeemFlexibleProduct.ts index bdb4d1cc..0ffd3e25 100644 --- a/src/tools/binance-simple-earn/earn-api/redeemFlexibleProduct.ts +++ b/src/tools/binance-simple-earn/earn-api/redeemFlexibleProduct.ts @@ -1,9 +1,9 @@ // src/tools/binance-simple-earn/earn-api/redeemFlexibleProduct.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { simpleEarnClient } from "../../../config/binanceClient.js" +import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerBinanceRedeemFlexibleProduct(server: McpServer) { server.tool( @@ -25,7 +25,7 @@ export function registerBinanceRedeemFlexibleProduct(server: McpServer) { }, async (params) => { try { - const { productId, redeemAll = false, amount, destAccount, recvWindow } = params + const { productId, redeemAll = false, amount, destAccount, recvWindow } = params; // Defensive check if (!redeemAll && (amount === undefined || amount <= 0)) { @@ -37,7 +37,7 @@ export function registerBinanceRedeemFlexibleProduct(server: McpServer) { }, ], isError: true, - } + }; } const response = await simpleEarnClient.restAPI.redeemFlexibleProduct({ @@ -46,9 +46,9 @@ export function registerBinanceRedeemFlexibleProduct(server: McpServer) { ...(amount !== undefined && { amount }), ...(destAccount && { destAccount }), ...(recvWindow && { recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -59,9 +59,9 @@ export function registerBinanceRedeemFlexibleProduct(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -71,8 +71,8 @@ export function registerBinanceRedeemFlexibleProduct(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-simple-earn/earn-api/subscribeFlexibleProduct.ts b/src/tools/binance-simple-earn/earn-api/subscribeFlexibleProduct.ts index 3532c8eb..7d269ed4 100644 --- a/src/tools/binance-simple-earn/earn-api/subscribeFlexibleProduct.ts +++ b/src/tools/binance-simple-earn/earn-api/subscribeFlexibleProduct.ts @@ -1,9 +1,9 @@ // src/tools/binance-simple-earn/earn-api/subscribeFlexibleProduct.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { simpleEarnClient } from "../../../config/binanceClient.js" +import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerBinanceSubscribeFlexibleProduct(server: McpServer) { server.tool( @@ -27,9 +27,9 @@ export function registerBinanceSubscribeFlexibleProduct(server: McpServer) { ...(params.autoSubscribe !== undefined && { autoSubscribe: params.autoSubscribe }), ...(params.sourceAccount && { sourceAccount: params.sourceAccount }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -40,9 +40,9 @@ export function registerBinanceSubscribeFlexibleProduct(server: McpServer) { } and amount${params.amount}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -52,8 +52,8 @@ export function registerBinanceSubscribeFlexibleProduct(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-simple-earn/index.ts b/src/tools/binance-simple-earn/index.ts index 7f5ae8eb..948d3dbb 100644 --- a/src/tools/binance-simple-earn/index.ts +++ b/src/tools/binance-simple-earn/index.ts @@ -1,13 +1,13 @@ // src/tools/binance-simple-earn/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceSimpleEarnAccountApiTools } from "./account-api/index.js" -import { registerBinanceSimpleEarnApiTools } from "./earn-api/index.js" +import { registerBinanceSimpleEarnAccountApiTools } from "./account-api/index.js"; +import { registerBinanceSimpleEarnApiTools } from "./earn-api/index.js"; export function registerBinanceSimpleEarnTools(server: McpServer) { // Registers core API tools like subscribing to flexible products - registerBinanceSimpleEarnApiTools(server) + registerBinanceSimpleEarnApiTools(server); // Registers account-related tools like viewing product lists and positions - registerBinanceSimpleEarnAccountApiTools(server) + registerBinanceSimpleEarnAccountApiTools(server); } diff --git a/src/tools/binance-spot/account-api/accountCommission.ts b/src/tools/binance-spot/account-api/accountCommission.ts index f4a179c2..b0603a78 100644 --- a/src/tools/binance-spot/account-api/accountCommission.ts +++ b/src/tools/binance-spot/account-api/accountCommission.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/account-api/accountCommission.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceAccountCommission(server: McpServer) { server.tool( @@ -15,12 +15,12 @@ export function registerBinanceAccountCommission(server: McpServer) { }, async ({ symbol, recvWindow }) => { try { - const params: any = { symbol } - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = { symbol }; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await spotClient.restAPI.accountCommission(params) + const response = await spotClient.restAPI.accountCommission(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,17 +29,17 @@ export function registerBinanceAccountCommission(server: McpServer) { text: `Retrieved account commission rates for ${symbol}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve account commission rates: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-spot/account-api/getAccount.ts b/src/tools/binance-spot/account-api/getAccount.ts index 556a3e19..d0db5720 100644 --- a/src/tools/binance-spot/account-api/getAccount.ts +++ b/src/tools/binance-spot/account-api/getAccount.ts @@ -1,9 +1,10 @@ // src/tools/binance-spot/account-api/getAccount.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; +import { safeJsonStringify } from "../../../utils/json.js"; export function registerBinanceGetAccount(server: McpServer) { server.tool( @@ -14,31 +15,31 @@ export function registerBinanceGetAccount(server: McpServer) { }, async ({ recvWindow }) => { try { - const params: any = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await spotClient.restAPI.getAccount(params) + const response = await spotClient.restAPI.getAccount(params); - const data = await response.data() + const data = await response.data(); return { content: [ { type: "text", - text: `Retrieved account information. Account contains ${data.balances?.length || 0} balances. Response: ${JSON.stringify(data)}`, + text: `Retrieved account information. Account contains ${data.balances?.length || 0} balances. Response: ${safeJsonStringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve account information: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-spot/account-api/index.ts b/src/tools/binance-spot/account-api/index.ts index 2be3a54f..53d31c2c 100644 --- a/src/tools/binance-spot/account-api/index.ts +++ b/src/tools/binance-spot/account-api/index.ts @@ -1,18 +1,18 @@ // src/tools/binance-spot/account-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceAccountCommission } from "./accountCommission.js" -import { registerBinanceGetAccount } from "./getAccount.js" -import { registerBinanceMyAllocations } from "./myAllocations.js" -import { registerBinanceMyPreventedMatches } from "./myPreventedMatches.js" -import { registerBinanceMyTrades } from "./myTrades.js" -import { registerBinanceRateLimitOrder } from "./rateLimitOrder.js" +import { registerBinanceAccountCommission } from "./accountCommission.js"; +import { registerBinanceGetAccount } from "./getAccount.js"; +import { registerBinanceMyAllocations } from "./myAllocations.js"; +import { registerBinanceMyPreventedMatches } from "./myPreventedMatches.js"; +import { registerBinanceMyTrades } from "./myTrades.js"; +import { registerBinanceRateLimitOrder } from "./rateLimitOrder.js"; export function registerBinanceAccountApiTools(server: McpServer) { - registerBinanceMyPreventedMatches(server) - registerBinanceGetAccount(server) - registerBinanceMyAllocations(server) - registerBinanceRateLimitOrder(server) - registerBinanceAccountCommission(server) - registerBinanceMyTrades(server) + registerBinanceMyPreventedMatches(server); + registerBinanceGetAccount(server); + registerBinanceMyAllocations(server); + registerBinanceRateLimitOrder(server); + registerBinanceAccountCommission(server); + registerBinanceMyTrades(server); } diff --git a/src/tools/binance-spot/account-api/myAllocations.ts b/src/tools/binance-spot/account-api/myAllocations.ts index 81a00914..2d1668a3 100644 --- a/src/tools/binance-spot/account-api/myAllocations.ts +++ b/src/tools/binance-spot/account-api/myAllocations.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/account-api/myAllocations.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceMyAllocations(server: McpServer) { server.tool( @@ -19,17 +19,17 @@ export function registerBinanceMyAllocations(server: McpServer) { }, async ({ symbol, allocationId, orderId, fromAllocationId, limit, recvWindow }) => { try { - const params: any = { symbol } + const params: any = { symbol }; - if (allocationId !== undefined) params.allocationId = allocationId - if (orderId !== undefined) params.orderId = orderId - if (fromAllocationId !== undefined) params.fromAllocationId = fromAllocationId - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + if (allocationId !== undefined) params.allocationId = allocationId; + if (orderId !== undefined) params.orderId = orderId; + if (fromAllocationId !== undefined) params.fromAllocationId = fromAllocationId; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await spotClient.restAPI.myAllocations(params) + const response = await spotClient.restAPI.myAllocations(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -38,15 +38,15 @@ export function registerBinanceMyAllocations(server: McpServer) { text: `Retrieved SOR allocations for ${symbol}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve SOR allocations: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-spot/account-api/myPreventedMatches.ts b/src/tools/binance-spot/account-api/myPreventedMatches.ts index 61403e30..0181e33e 100644 --- a/src/tools/binance-spot/account-api/myPreventedMatches.ts +++ b/src/tools/binance-spot/account-api/myPreventedMatches.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/account-api/myPreventedMatches.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceMyPreventedMatches(server: McpServer) { server.tool( @@ -19,17 +19,17 @@ export function registerBinanceMyPreventedMatches(server: McpServer) { }, async ({ symbol, preventedMatchId, orderId, fromPreventedMatchId, limit, recvWindow }) => { try { - const params: any = { symbol } + const params: any = { symbol }; - if (preventedMatchId !== undefined) params.preventedMatchId = preventedMatchId - if (orderId !== undefined) params.orderId = orderId - if (fromPreventedMatchId !== undefined) params.fromPreventedMatchId = fromPreventedMatchId - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + if (preventedMatchId !== undefined) params.preventedMatchId = preventedMatchId; + if (orderId !== undefined) params.orderId = orderId; + if (fromPreventedMatchId !== undefined) params.fromPreventedMatchId = fromPreventedMatchId; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await spotClient.restAPI.myPreventedMatches(params) + const response = await spotClient.restAPI.myPreventedMatches(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -38,17 +38,17 @@ export function registerBinanceMyPreventedMatches(server: McpServer) { text: `Retrieved prevented matches for ${symbol}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve prevented matches: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-spot/account-api/myTrades.ts b/src/tools/binance-spot/account-api/myTrades.ts index bfe95f19..81e110b9 100644 --- a/src/tools/binance-spot/account-api/myTrades.ts +++ b/src/tools/binance-spot/account-api/myTrades.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/account-api/myTrades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceMyTrades(server: McpServer) { server.tool( @@ -20,18 +20,18 @@ export function registerBinanceMyTrades(server: McpServer) { }, async ({ symbol, orderId, startTime, endTime, fromId, limit, recvWindow }) => { try { - const params: any = { symbol } + const params: any = { symbol }; - if (orderId !== undefined) params.orderId = orderId - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (fromId !== undefined) params.fromId = fromId - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + if (orderId !== undefined) params.orderId = orderId; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (fromId !== undefined) params.fromId = fromId; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await spotClient.restAPI.myTrades(params) + const response = await spotClient.restAPI.myTrades(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -40,15 +40,15 @@ export function registerBinanceMyTrades(server: McpServer) { text: `Retrieved trades for ${symbol}. Total trades: ${data.length}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve account trades: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-spot/account-api/rateLimitOrder.ts b/src/tools/binance-spot/account-api/rateLimitOrder.ts index bd415e83..83fe3be2 100644 --- a/src/tools/binance-spot/account-api/rateLimitOrder.ts +++ b/src/tools/binance-spot/account-api/rateLimitOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/account-api/rateLimitOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceRateLimitOrder(server: McpServer) { server.tool( @@ -14,12 +14,12 @@ export function registerBinanceRateLimitOrder(server: McpServer) { }, async ({ recvWindow }) => { try { - const params: any = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await spotClient.restAPI.rateLimitOrder(params) + const response = await spotClient.restAPI.rateLimitOrder(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -28,17 +28,17 @@ export function registerBinanceRateLimitOrder(server: McpServer) { text: `Retrieved current order count usage. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve order count usage: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-spot/general-api/exchangeInfo.ts b/src/tools/binance-spot/general-api/exchangeInfo.ts index 9967eebe..33b2abcb 100644 --- a/src/tools/binance-spot/general-api/exchangeInfo.ts +++ b/src/tools/binance-spot/general-api/exchangeInfo.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/general-api/exchangeInfo.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceExchangeInfo(server: McpServer) { server.tool( @@ -16,18 +16,18 @@ export function registerBinanceExchangeInfo(server: McpServer) { }, async ({ symbol, symbols, permissions }) => { try { - const params: any = {} + const params: any = {}; - if (symbol) params.symbol = symbol - if (symbols) params.symbols = symbols - if (permissions) params.permissions = permissions + if (symbol) params.symbol = symbol; + if (symbols) params.symbols = symbols; + if (permissions) params.permissions = permissions; - const response = await spotClient.restAPI.exchangeInfo(params) + const response = await spotClient.restAPI.exchangeInfo(params); - const data = await response.data() + const data = await response.data(); - const symbolCount = data.symbols?.length || 0 - const exchangeFiltersCount = data.exchangeFilters?.length || 0 + const symbolCount = data.symbols?.length || 0; + const exchangeFiltersCount = data.exchangeFilters?.length || 0; return { content: [ @@ -36,17 +36,17 @@ export function registerBinanceExchangeInfo(server: McpServer) { text: `Retrieved exchange information. Total symbols: ${symbolCount}, Exchange filters: ${exchangeFiltersCount}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve exchange information: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-spot/general-api/index.ts b/src/tools/binance-spot/general-api/index.ts index 471676d4..3cecf4b7 100644 --- a/src/tools/binance-spot/general-api/index.ts +++ b/src/tools/binance-spot/general-api/index.ts @@ -1,12 +1,12 @@ // src/tools/binance-spot/general-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceExchangeInfo } from "./exchangeInfo.js" -import { registerBinancePing } from "./ping.js" -import { registerBinanceTime } from "./time.js" +import { registerBinanceExchangeInfo } from "./exchangeInfo.js"; +import { registerBinancePing } from "./ping.js"; +import { registerBinanceTime } from "./time.js"; export function registerBinanceGeneralApiTools(server: McpServer) { - registerBinancePing(server) - registerBinanceTime(server) - registerBinanceExchangeInfo(server) + registerBinancePing(server); + registerBinanceTime(server); + registerBinanceExchangeInfo(server); } diff --git a/src/tools/binance-spot/general-api/ping.ts b/src/tools/binance-spot/general-api/ping.ts index 1e0aa465..ebce997e 100644 --- a/src/tools/binance-spot/general-api/ping.ts +++ b/src/tools/binance-spot/general-api/ping.ts @@ -1,14 +1,14 @@ // src/tools/binance-spot/general-api/ping.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinancePing(server: McpServer) { server.tool("BinancePing", "Test connectivity to the Binance API.", {}, async () => { try { - const response = await spotClient.restAPI.ping() + const response = await spotClient.restAPI.ping(); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -17,14 +17,14 @@ export function registerBinancePing(server: McpServer) { text: `Successfully pinged Binance API. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to ping Binance API: ${errorMessage}` }], isError: true, - } + }; } - }) + }); } diff --git a/src/tools/binance-spot/general-api/time.ts b/src/tools/binance-spot/general-api/time.ts index 3c0aa903..01df870a 100644 --- a/src/tools/binance-spot/general-api/time.ts +++ b/src/tools/binance-spot/general-api/time.ts @@ -1,17 +1,17 @@ // src/tools/binance-spot/general-api/time.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceTime(server: McpServer) { server.tool("BinanceTime", "Get the current server time from Binance API.", {}, async () => { try { - const response = await spotClient.restAPI.time() + const response = await spotClient.restAPI.time(); - const data = await response.data() + const data = await response.data(); // @ts-expect-error - serverTime not in generated type definition - const serverTime = new Date(data.serverTime).toISOString() + const serverTime = new Date(data.serverTime).toISOString(); return { content: [ @@ -22,14 +22,14 @@ export function registerBinanceTime(server: McpServer) { }). Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve server time: ${errorMessage}` }], isError: true, - } + }; } - }) + }); } diff --git a/src/tools/binance-spot/index.ts b/src/tools/binance-spot/index.ts index 1c742dba..16f9345b 100644 --- a/src/tools/binance-spot/index.ts +++ b/src/tools/binance-spot/index.ts @@ -1,25 +1,25 @@ // src/tools/binance-spot/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceAccountApiTools } from "./account-api/index.js" -import { registerBinanceGeneralApiTools } from "./general-api/index.js" -import { registerBinanceMarketApiTools } from "./market-api/index.js" -import { registerBinanceTradeApiTools } from "./trade-api/index.js" -import { registerBinanceUserDataStreamApiTools } from "./userdatastream-api/index.js" +import { registerBinanceAccountApiTools } from "./account-api/index.js"; +import { registerBinanceGeneralApiTools } from "./general-api/index.js"; +import { registerBinanceMarketApiTools } from "./market-api/index.js"; +import { registerBinanceTradeApiTools } from "./trade-api/index.js"; +import { registerBinanceUserDataStreamApiTools } from "./userdatastream-api/index.js"; export function registerBinanceSpotTools(server: McpServer) { // Trade API tools - registerBinanceTradeApiTools(server) + registerBinanceTradeApiTools(server); // Market API tools - registerBinanceMarketApiTools(server) + registerBinanceMarketApiTools(server); // Account API tools - registerBinanceAccountApiTools(server) + registerBinanceAccountApiTools(server); // User Data Stream API tools - registerBinanceUserDataStreamApiTools(server) + registerBinanceUserDataStreamApiTools(server); // General API tools - registerBinanceGeneralApiTools(server) + registerBinanceGeneralApiTools(server); } diff --git a/src/tools/binance-spot/market-api/aggTrades.ts b/src/tools/binance-spot/market-api/aggTrades.ts index 3a1a49ef..378358ef 100644 --- a/src/tools/binance-spot/market-api/aggTrades.ts +++ b/src/tools/binance-spot/market-api/aggTrades.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/market-api/aggTrades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceAggTrades(server: McpServer) { server.tool( @@ -18,16 +18,16 @@ export function registerBinanceAggTrades(server: McpServer) { }, async ({ symbol, fromId, startTime, endTime, limit }) => { try { - const params: any = { symbol } + const params: any = { symbol }; - if (fromId !== undefined) params.fromId = fromId - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + if (fromId !== undefined) params.fromId = fromId; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const response = await spotClient.restAPI.aggTrades(params) + const response = await spotClient.restAPI.aggTrades(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -36,15 +36,15 @@ export function registerBinanceAggTrades(server: McpServer) { text: `Retrieved aggregate trades for ${symbol}. Total trades: ${data.length}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve aggregate trades: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-spot/market-api/avgPrice.ts b/src/tools/binance-spot/market-api/avgPrice.ts index 80ed5102..6603c81b 100644 --- a/src/tools/binance-spot/market-api/avgPrice.ts +++ b/src/tools/binance-spot/market-api/avgPrice.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/market-api/avgPrice.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceAvgPrice(server: McpServer) { server.tool( @@ -16,9 +16,9 @@ export function registerBinanceAvgPrice(server: McpServer) { try { const response = await spotClient.restAPI.avgPrice({ symbol: symbol, - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -27,15 +27,15 @@ export function registerBinanceAvgPrice(server: McpServer) { text: `Retrieved current average price for ${symbol}. Average price: ${data.price}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve average price: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-spot/market-api/depth.ts b/src/tools/binance-spot/market-api/depth.ts index 6df7e4b5..31b78959 100644 --- a/src/tools/binance-spot/market-api/depth.ts +++ b/src/tools/binance-spot/market-api/depth.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/market-api/depth.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceDepth(server: McpServer) { server.tool( @@ -15,12 +15,12 @@ export function registerBinanceDepth(server: McpServer) { }, async ({ symbol, limit }) => { try { - const params: any = { symbol } - if (limit !== undefined) params.limit = limit + const params: any = { symbol }; + if (limit !== undefined) params.limit = limit; - const response = await spotClient.restAPI.depth(params) + const response = await spotClient.restAPI.depth(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,15 +29,15 @@ export function registerBinanceDepth(server: McpServer) { text: `Retrieved order book depth for ${symbol}. Bids: ${data.bids?.length || 0}, Asks: ${data.asks?.length || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve order book depth: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-spot/market-api/getTrades.ts b/src/tools/binance-spot/market-api/getTrades.ts index 6f65b5e4..2e1ed4c1 100644 --- a/src/tools/binance-spot/market-api/getTrades.ts +++ b/src/tools/binance-spot/market-api/getTrades.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/market-api/getTrades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceGetTrades(server: McpServer) { server.tool( @@ -15,13 +15,13 @@ export function registerBinanceGetTrades(server: McpServer) { }, async ({ symbol, limit }) => { try { - const params: any = { symbol } + const params: any = { symbol }; - if (limit !== undefined) params.limit = limit + if (limit !== undefined) params.limit = limit; - const response = await spotClient.restAPI.getTrades(params) + const response = await spotClient.restAPI.getTrades(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -30,15 +30,15 @@ export function registerBinanceGetTrades(server: McpServer) { text: `Retrieved recent trades for ${symbol}. Total trades: ${data.length}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve recent trades: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-spot/market-api/historicalTrades.ts b/src/tools/binance-spot/market-api/historicalTrades.ts index ca14bb87..07a7b27d 100644 --- a/src/tools/binance-spot/market-api/historicalTrades.ts +++ b/src/tools/binance-spot/market-api/historicalTrades.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/market-api/historicalTrades.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceHistoricalTrades(server: McpServer) { server.tool( @@ -16,14 +16,14 @@ export function registerBinanceHistoricalTrades(server: McpServer) { }, async ({ symbol, limit, fromId }) => { try { - const params: any = { symbol } + const params: any = { symbol }; - if (limit !== undefined) params.limit = limit - if (fromId !== undefined) params.fromId = fromId + if (limit !== undefined) params.limit = limit; + if (fromId !== undefined) params.fromId = fromId; - const response = await spotClient.restAPI.historicalTrades(params) + const response = await spotClient.restAPI.historicalTrades(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -32,17 +32,17 @@ export function registerBinanceHistoricalTrades(server: McpServer) { text: `Retrieved historical trades for ${symbol}. Total trades: ${data.length}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve historical trades: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-spot/market-api/index.ts b/src/tools/binance-spot/market-api/index.ts index 4ccede7d..51efb908 100644 --- a/src/tools/binance-spot/market-api/index.ts +++ b/src/tools/binance-spot/market-api/index.ts @@ -1,30 +1,30 @@ // src/tools/binance-spot/market-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceAggTrades } from "./aggTrades.js" -import { registerBinanceAvgPrice } from "./avgPrice.js" -import { registerBinanceDepth } from "./depth.js" -import { registerBinanceGetTrades } from "./getTrades.js" -import { registerBinanceHistoricalTrades } from "./historicalTrades.js" -import { registerBinanceKlines } from "./klines.js" -import { registerBinanceTicker24hr } from "./ticker24hr.js" -import { registerBinanceTicker } from "./ticker.js" -import { registerBinanceTickerBookTicker } from "./tickerBookTicker.js" -import { registerBinanceTickerPrice } from "./tickerPrice.js" -import { registerBinanceTickerTradingDay } from "./tickerTradingDay.js" -import { registerBinanceUiKlines } from "./uiKlines.js" +import { registerBinanceAggTrades } from "./aggTrades.js"; +import { registerBinanceAvgPrice } from "./avgPrice.js"; +import { registerBinanceDepth } from "./depth.js"; +import { registerBinanceGetTrades } from "./getTrades.js"; +import { registerBinanceHistoricalTrades } from "./historicalTrades.js"; +import { registerBinanceKlines } from "./klines.js"; +import { registerBinanceTicker24hr } from "./ticker24hr.js"; +import { registerBinanceTicker } from "./ticker.js"; +import { registerBinanceTickerBookTicker } from "./tickerBookTicker.js"; +import { registerBinanceTickerPrice } from "./tickerPrice.js"; +import { registerBinanceTickerTradingDay } from "./tickerTradingDay.js"; +import { registerBinanceUiKlines } from "./uiKlines.js"; export function registerBinanceMarketApiTools(server: McpServer) { - registerBinanceKlines(server) - registerBinanceTicker24hr(server) - registerBinanceDepth(server) - registerBinanceAggTrades(server) - registerBinanceTickerTradingDay(server) - registerBinanceUiKlines(server) - registerBinanceTickerBookTicker(server) - registerBinanceAvgPrice(server) - registerBinanceTickerPrice(server) - registerBinanceTicker(server) - registerBinanceHistoricalTrades(server) - registerBinanceGetTrades(server) + registerBinanceKlines(server); + registerBinanceTicker24hr(server); + registerBinanceDepth(server); + registerBinanceAggTrades(server); + registerBinanceTickerTradingDay(server); + registerBinanceUiKlines(server); + registerBinanceTickerBookTicker(server); + registerBinanceAvgPrice(server); + registerBinanceTickerPrice(server); + registerBinanceTicker(server); + registerBinanceHistoricalTrades(server); + registerBinanceGetTrades(server); } diff --git a/src/tools/binance-spot/market-api/klines.ts b/src/tools/binance-spot/market-api/klines.ts index 1eb9eb49..8ab84f65 100644 --- a/src/tools/binance-spot/market-api/klines.ts +++ b/src/tools/binance-spot/market-api/klines.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/market-api/klines.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceKlines(server: McpServer) { server.tool( @@ -39,15 +39,15 @@ export function registerBinanceKlines(server: McpServer) { const params: any = { symbol, interval, - } + }; - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const response = await spotClient.restAPI.klines(params) + const response = await spotClient.restAPI.klines(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -56,15 +56,15 @@ export function registerBinanceKlines(server: McpServer) { text: `Retrieved klines for ${symbol} with ${interval} interval. Total candles: ${data.length}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve klines: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-spot/market-api/ticker.ts b/src/tools/binance-spot/market-api/ticker.ts index 05d15f05..fca26210 100644 --- a/src/tools/binance-spot/market-api/ticker.ts +++ b/src/tools/binance-spot/market-api/ticker.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/market-api/ticker.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceTicker(server: McpServer) { server.tool( @@ -18,18 +18,18 @@ export function registerBinanceTicker(server: McpServer) { }, async ({ symbol, windowSize }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol - if (windowSize) params.windowSize = windowSize + const params: any = {}; + if (symbol) params.symbol = symbol; + if (windowSize) params.windowSize = windowSize; - const response = await spotClient.restAPI.ticker(params) + const response = await spotClient.restAPI.ticker(params); - const data = await response.data() + const data = await response.data(); - const isArray = Array.isArray(data) + const isArray = Array.isArray(data); const responseText = isArray ? `Retrieved ticker statistics for all symbols${windowSize ? ` with window size ${windowSize}` : ""}. Total items: ${data.length}.` - : `Retrieved ticker statistics for ${symbol}${windowSize ? ` with window size ${windowSize}` : ""}.` + : `Retrieved ticker statistics for ${symbol}${windowSize ? ` with window size ${windowSize}` : ""}.`; return { content: [ @@ -38,17 +38,17 @@ export function registerBinanceTicker(server: McpServer) { text: `${responseText} Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve ticker statistics: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-spot/market-api/ticker24hr.ts b/src/tools/binance-spot/market-api/ticker24hr.ts index 58f1d5ed..bb9cf669 100644 --- a/src/tools/binance-spot/market-api/ticker24hr.ts +++ b/src/tools/binance-spot/market-api/ticker24hr.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/market-api/ticker24hr.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceTicker24hr(server: McpServer) { server.tool( @@ -14,17 +14,17 @@ export function registerBinanceTicker24hr(server: McpServer) { }, async ({ symbol }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol + const params: any = {}; + if (symbol) params.symbol = symbol; - const response = await spotClient.restAPI.ticker24hr(params) + const response = await spotClient.restAPI.ticker24hr(params); - const data = await response.data() + const data = await response.data(); - const isArray = Array.isArray(data) + const isArray = Array.isArray(data); const responseText = isArray ? `Retrieved 24hr statistics for all symbols. Total items: ${data.length}.` - : `Retrieved 24hr statistics for ${symbol}.` + : `Retrieved 24hr statistics for ${symbol}.`; return { content: [ @@ -33,15 +33,15 @@ export function registerBinanceTicker24hr(server: McpServer) { text: `${responseText} Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve 24hr ticker: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-spot/market-api/tickerBookTicker.ts b/src/tools/binance-spot/market-api/tickerBookTicker.ts index 9fede0b8..0c59dc80 100644 --- a/src/tools/binance-spot/market-api/tickerBookTicker.ts +++ b/src/tools/binance-spot/market-api/tickerBookTicker.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/market-api/tickerBookTicker.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceTickerBookTicker(server: McpServer) { server.tool( @@ -14,17 +14,17 @@ export function registerBinanceTickerBookTicker(server: McpServer) { }, async ({ symbol }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol + const params: any = {}; + if (symbol) params.symbol = symbol; - const response = await spotClient.restAPI.tickerBookTicker(params) + const response = await spotClient.restAPI.tickerBookTicker(params); - const data = await response.data() + const data = await response.data(); - const isArray = Array.isArray(data) + const isArray = Array.isArray(data); const responseText = isArray ? `Retrieved best price/quantity on the order book for all symbols. Total items: ${data.length}.` - : `Retrieved best price/quantity on the order book for ${symbol}.` + : `Retrieved best price/quantity on the order book for ${symbol}.`; return { content: [ @@ -33,15 +33,15 @@ export function registerBinanceTickerBookTicker(server: McpServer) { text: `${responseText} Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve book ticker: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-spot/market-api/tickerPrice.ts b/src/tools/binance-spot/market-api/tickerPrice.ts index d57a9323..1480cdcb 100644 --- a/src/tools/binance-spot/market-api/tickerPrice.ts +++ b/src/tools/binance-spot/market-api/tickerPrice.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/market-api/tickerPrice.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceTickerPrice(server: McpServer) { server.tool( @@ -14,17 +14,17 @@ export function registerBinanceTickerPrice(server: McpServer) { }, async ({ symbol }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol + const params: any = {}; + if (symbol) params.symbol = symbol; - const response = await spotClient.restAPI.tickerPrice(params) + const response = await spotClient.restAPI.tickerPrice(params); - const data = await response.data() + const data = await response.data(); - const isArray = Array.isArray(data) + const isArray = Array.isArray(data); const responseText = isArray ? `Retrieved latest prices for all symbols. Total items: ${data.length}.` - : `Retrieved latest price for ${symbol}: ${data.price}.` + : `Retrieved latest price for ${symbol}: ${data.price}.`; return { content: [ @@ -33,15 +33,15 @@ export function registerBinanceTickerPrice(server: McpServer) { text: `${responseText} Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve ticker price: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-spot/market-api/tickerTradingDay.ts b/src/tools/binance-spot/market-api/tickerTradingDay.ts index 9e21de6f..8ec97804 100644 --- a/src/tools/binance-spot/market-api/tickerTradingDay.ts +++ b/src/tools/binance-spot/market-api/tickerTradingDay.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/market-api/tickerTradingDay.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceTickerTradingDay(server: McpServer) { server.tool( @@ -14,17 +14,17 @@ export function registerBinanceTickerTradingDay(server: McpServer) { }, async ({ symbol }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol + const params: any = {}; + if (symbol) params.symbol = symbol; - const response = await spotClient.restAPI.tickerTradingDay(params) + const response = await spotClient.restAPI.tickerTradingDay(params); - const data = await response.data() + const data = await response.data(); - const isArray = Array.isArray(data) + const isArray = Array.isArray(data); const responseText = isArray ? `Retrieved trading day statistics for all symbols. Total items: ${data.length}.` - : `Retrieved trading day statistics for ${symbol}.` + : `Retrieved trading day statistics for ${symbol}.`; return { content: [ @@ -33,17 +33,17 @@ export function registerBinanceTickerTradingDay(server: McpServer) { text: `${responseText} Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve trading day statistics: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-spot/market-api/uiKlines.ts b/src/tools/binance-spot/market-api/uiKlines.ts index 886a3d75..10cc184e 100644 --- a/src/tools/binance-spot/market-api/uiKlines.ts +++ b/src/tools/binance-spot/market-api/uiKlines.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/market-api/uiKlines.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceUiKlines(server: McpServer) { server.tool( @@ -39,15 +39,15 @@ export function registerBinanceUiKlines(server: McpServer) { const params: any = { symbol, interval, - } + }; - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const response = await spotClient.restAPI.uiKlines(params) + const response = await spotClient.restAPI.uiKlines(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -56,15 +56,15 @@ export function registerBinanceUiKlines(server: McpServer) { text: `Retrieved UI klines for ${symbol} with ${interval} interval. Total candles: ${data.length}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve UI klines: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-spot/trade-api/allOrders.ts b/src/tools/binance-spot/trade-api/allOrders.ts index 1a4b3f19..939a32f8 100644 --- a/src/tools/binance-spot/trade-api/allOrders.ts +++ b/src/tools/binance-spot/trade-api/allOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/trade-api/allOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceAllOrders(server: McpServer) { server.tool( @@ -21,16 +21,16 @@ export function registerBinanceAllOrders(server: McpServer) { }, async ({ symbol, orderId, startTime, endTime, limit }) => { try { - const params: any = { symbol } + const params: any = { symbol }; - if (orderId !== undefined) params.orderId = orderId - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + if (orderId !== undefined) params.orderId = orderId; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const response = await spotClient.restAPI.allOrders(params) + const response = await spotClient.restAPI.allOrders(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -39,15 +39,15 @@ export function registerBinanceAllOrders(server: McpServer) { text: `Retrieved all orders for ${symbol}. Total orders: ${data.length}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve all orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-spot/trade-api/deleteOpenOrders.ts b/src/tools/binance-spot/trade-api/deleteOpenOrders.ts index 95920e81..1d37e077 100644 --- a/src/tools/binance-spot/trade-api/deleteOpenOrders.ts +++ b/src/tools/binance-spot/trade-api/deleteOpenOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/trade-api/deleteOpenOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceDeleteOpenOrders(server: McpServer) { server.tool( @@ -16,9 +16,9 @@ export function registerBinanceDeleteOpenOrders(server: McpServer) { try { const response = await spotClient.restAPI.deleteOpenOrders({ symbol: symbol, - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -27,15 +27,15 @@ export function registerBinanceDeleteOpenOrders(server: McpServer) { text: `Successfully canceled all open orders for ${symbol}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to cancel open orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-spot/trade-api/deleteOrder.ts b/src/tools/binance-spot/trade-api/deleteOrder.ts index cbf5490d..8bbe0e5f 100644 --- a/src/tools/binance-spot/trade-api/deleteOrder.ts +++ b/src/tools/binance-spot/trade-api/deleteOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/trade-api/deleteOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceDeleteOrder(server: McpServer) { server.tool( @@ -16,14 +16,14 @@ export function registerBinanceDeleteOrder(server: McpServer) { }, async ({ symbol, orderId, origClientOrderId }) => { try { - const params: any = { symbol } + const params: any = { symbol }; - if (orderId) params.orderId = orderId - if (origClientOrderId) params.origClientOrderId = origClientOrderId + if (orderId) params.orderId = orderId; + if (origClientOrderId) params.origClientOrderId = origClientOrderId; - const response = await spotClient.restAPI.deleteOrder(params) + const response = await spotClient.restAPI.deleteOrder(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -32,15 +32,15 @@ export function registerBinanceDeleteOrder(server: McpServer) { text: `Order successfully canceled. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to cancel order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-spot/trade-api/getOpenOrders.ts b/src/tools/binance-spot/trade-api/getOpenOrders.ts index 70e079a7..5d30259d 100644 --- a/src/tools/binance-spot/trade-api/getOpenOrders.ts +++ b/src/tools/binance-spot/trade-api/getOpenOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/trade-api/getOpenOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceGetOpenOrders(server: McpServer) { server.tool( @@ -14,12 +14,12 @@ export function registerBinanceGetOpenOrders(server: McpServer) { }, async ({ symbol }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol + const params: any = {}; + if (symbol) params.symbol = symbol; - const response = await spotClient.restAPI.getOpenOrders(params) + const response = await spotClient.restAPI.getOpenOrders(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -28,15 +28,15 @@ export function registerBinanceGetOpenOrders(server: McpServer) { text: `Retrieved open orders${symbol ? ` for ${symbol}` : ""}. Total open orders: ${data.length}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve open orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-spot/trade-api/getOrder.ts b/src/tools/binance-spot/trade-api/getOrder.ts index 1c83ac75..e76b7bf5 100644 --- a/src/tools/binance-spot/trade-api/getOrder.ts +++ b/src/tools/binance-spot/trade-api/getOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/trade-api/getOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceGetOrder(server: McpServer) { server.tool( @@ -16,14 +16,14 @@ export function registerBinanceGetOrder(server: McpServer) { }, async ({ symbol, orderId, origClientOrderId }) => { try { - const params: any = { symbol } + const params: any = { symbol }; - if (orderId) params.orderId = orderId - if (origClientOrderId) params.origClientOrderId = origClientOrderId + if (orderId) params.orderId = orderId; + if (origClientOrderId) params.origClientOrderId = origClientOrderId; - const response = await spotClient.restAPI.getOrder(params) + const response = await spotClient.restAPI.getOrder(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -32,17 +32,17 @@ export function registerBinanceGetOrder(server: McpServer) { text: `Order information retrieved successfully. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve order information: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-spot/trade-api/index.ts b/src/tools/binance-spot/trade-api/index.ts index d7dc679c..dac0fe57 100644 --- a/src/tools/binance-spot/trade-api/index.ts +++ b/src/tools/binance-spot/trade-api/index.ts @@ -1,22 +1,22 @@ // src/tools/binance-spot/trade-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceAllOrders } from "./allOrders.js" -import { registerBinanceDeleteOpenOrders } from "./deleteOpenOrders.js" -import { registerBinanceDeleteOrder } from "./deleteOrder.js" -import { registerBinanceGetOpenOrders } from "./getOpenOrders.js" -import { registerBinanceGetOrder } from "./getOrder.js" -import { registerBinanceNewOrder } from "./newOrder.js" -import { registerBinanceOpenOrderList } from "./openOrderList.js" -import { registerBinanceOrderOco } from "./orderOco.js" +import { registerBinanceAllOrders } from "./allOrders.js"; +import { registerBinanceDeleteOpenOrders } from "./deleteOpenOrders.js"; +import { registerBinanceDeleteOrder } from "./deleteOrder.js"; +import { registerBinanceGetOpenOrders } from "./getOpenOrders.js"; +import { registerBinanceGetOrder } from "./getOrder.js"; +import { registerBinanceNewOrder } from "./newOrder.js"; +import { registerBinanceOpenOrderList } from "./openOrderList.js"; +import { registerBinanceOrderOco } from "./orderOco.js"; export function registerBinanceTradeApiTools(server: McpServer) { - registerBinanceDeleteOrder(server) - registerBinanceAllOrders(server) - registerBinanceOpenOrderList(server) - registerBinanceNewOrder(server) - registerBinanceGetOrder(server) - registerBinanceGetOpenOrders(server) - registerBinanceDeleteOpenOrders(server) - registerBinanceOrderOco(server) + registerBinanceDeleteOrder(server); + registerBinanceAllOrders(server); + registerBinanceOpenOrderList(server); + registerBinanceNewOrder(server); + registerBinanceGetOrder(server); + registerBinanceGetOpenOrders(server); + registerBinanceDeleteOpenOrders(server); + registerBinanceOrderOco(server); } diff --git a/src/tools/binance-spot/trade-api/newOrder.ts b/src/tools/binance-spot/trade-api/newOrder.ts index 9080a015..c61a2350 100644 --- a/src/tools/binance-spot/trade-api/newOrder.ts +++ b/src/tools/binance-spot/trade-api/newOrder.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/trade-api/newOrder.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceNewOrder(server: McpServer) { server.tool( @@ -51,19 +51,19 @@ export function registerBinanceNewOrder(server: McpServer) { side, type, quantity, - } + }; - if (timeInForce) params.timeInForce = timeInForce - if (quoteOrderQty !== undefined) params.quoteOrderQty = quoteOrderQty - if (price !== undefined) params.price = price - if (newClientOrderId) params.newClientOrderId = newClientOrderId - if (stopPrice !== undefined) params.stopPrice = stopPrice - if (icebergQty !== undefined) params.icebergQty = icebergQty - if (newOrderRespType) params.newOrderRespType = newOrderRespType + if (timeInForce) params.timeInForce = timeInForce; + if (quoteOrderQty !== undefined) params.quoteOrderQty = quoteOrderQty; + if (price !== undefined) params.price = price; + if (newClientOrderId) params.newClientOrderId = newClientOrderId; + if (stopPrice !== undefined) params.stopPrice = stopPrice; + if (icebergQty !== undefined) params.icebergQty = icebergQty; + if (newOrderRespType) params.newOrderRespType = newOrderRespType; - const response = await spotClient.restAPI.newOrder(params) + const response = await spotClient.restAPI.newOrder(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -72,15 +72,15 @@ export function registerBinanceNewOrder(server: McpServer) { text: `New order successfully created. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to create new order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-spot/trade-api/openOrderList.ts b/src/tools/binance-spot/trade-api/openOrderList.ts index 1ba07a57..2a8c3ee9 100644 --- a/src/tools/binance-spot/trade-api/openOrderList.ts +++ b/src/tools/binance-spot/trade-api/openOrderList.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/trade-api/openOrderList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceOpenOrderList(server: McpServer) { server.tool( @@ -14,12 +14,12 @@ export function registerBinanceOpenOrderList(server: McpServer) { }, async ({ symbol }) => { try { - const params: any = {} - if (symbol) params.symbol = symbol + const params: any = {}; + if (symbol) params.symbol = symbol; - const response = await spotClient.restAPI.openOrderList(params) + const response = await spotClient.restAPI.openOrderList(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -28,15 +28,15 @@ export function registerBinanceOpenOrderList(server: McpServer) { text: `Retrieved open OCO orders${symbol ? ` for ${symbol}` : ""}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve open OCO orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-spot/trade-api/orderOco.ts b/src/tools/binance-spot/trade-api/orderOco.ts index bfca8250..42803c26 100644 --- a/src/tools/binance-spot/trade-api/orderOco.ts +++ b/src/tools/binance-spot/trade-api/orderOco.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/trade-api/orderOco.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceOrderOco(server: McpServer) { server.tool( @@ -45,18 +45,18 @@ export function registerBinanceOrderOco(server: McpServer) { quantity, price, stopPrice, - } + }; - if (stopLimitPrice !== undefined) params.stopLimitPrice = stopLimitPrice - if (stopLimitTimeInForce) params.stopLimitTimeInForce = stopLimitTimeInForce - if (newClientOrderId) params.newClientOrderId = newClientOrderId - if (stopClientOrderId) params.stopClientOrderId = stopClientOrderId - if (limitIcebergQty !== undefined) params.limitIcebergQty = limitIcebergQty - if (stopIcebergQty !== undefined) params.stopIcebergQty = stopIcebergQty + if (stopLimitPrice !== undefined) params.stopLimitPrice = stopLimitPrice; + if (stopLimitTimeInForce) params.stopLimitTimeInForce = stopLimitTimeInForce; + if (newClientOrderId) params.newClientOrderId = newClientOrderId; + if (stopClientOrderId) params.stopClientOrderId = stopClientOrderId; + if (limitIcebergQty !== undefined) params.limitIcebergQty = limitIcebergQty; + if (stopIcebergQty !== undefined) params.stopIcebergQty = stopIcebergQty; - const response = await spotClient.restAPI.orderOco(params) + const response = await spotClient.restAPI.orderOco(params); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -65,15 +65,15 @@ export function registerBinanceOrderOco(server: McpServer) { text: `OCO order successfully created. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to create OCO order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-spot/userdatastream-api/deleteUserDataStream.ts b/src/tools/binance-spot/userdatastream-api/deleteUserDataStream.ts index 45f9c877..823a10cd 100644 --- a/src/tools/binance-spot/userdatastream-api/deleteUserDataStream.ts +++ b/src/tools/binance-spot/userdatastream-api/deleteUserDataStream.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/userdatastream-api/deleteUserDataStream.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceDeleteUserDataStream(server: McpServer) { server.tool( @@ -16,9 +16,9 @@ export function registerBinanceDeleteUserDataStream(server: McpServer) { try { const response = await spotClient.restAPI.deleteUserDataStream({ listenKey: listenKey, - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -27,15 +27,15 @@ export function registerBinanceDeleteUserDataStream(server: McpServer) { text: `Successfully closed user data stream with listen key: ${listenKey}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to close user data stream: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-spot/userdatastream-api/index.ts b/src/tools/binance-spot/userdatastream-api/index.ts index a321fb5d..288eaa88 100644 --- a/src/tools/binance-spot/userdatastream-api/index.ts +++ b/src/tools/binance-spot/userdatastream-api/index.ts @@ -1,12 +1,12 @@ // src/tools/binance-spot/userdatastream-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceDeleteUserDataStream } from "./deleteUserDataStream.js" -import { registerBinanceNewUserDataStream } from "./newUserDataStream.js" -import { registerBinancePutUserDataStream } from "./putUserDataStream.js" +import { registerBinanceDeleteUserDataStream } from "./deleteUserDataStream.js"; +import { registerBinanceNewUserDataStream } from "./newUserDataStream.js"; +import { registerBinancePutUserDataStream } from "./putUserDataStream.js"; export function registerBinanceUserDataStreamApiTools(server: McpServer) { - registerBinanceNewUserDataStream(server) - registerBinanceDeleteUserDataStream(server) - registerBinancePutUserDataStream(server) + registerBinanceNewUserDataStream(server); + registerBinanceDeleteUserDataStream(server); + registerBinancePutUserDataStream(server); } diff --git a/src/tools/binance-spot/userdatastream-api/newUserDataStream.ts b/src/tools/binance-spot/userdatastream-api/newUserDataStream.ts index e01448e8..053ed45c 100644 --- a/src/tools/binance-spot/userdatastream-api/newUserDataStream.ts +++ b/src/tools/binance-spot/userdatastream-api/newUserDataStream.ts @@ -1,7 +1,7 @@ // src/tools/binance-spot/userdatastream-api/newUserDataStream.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceNewUserDataStream(server: McpServer) { server.tool( @@ -10,9 +10,9 @@ export function registerBinanceNewUserDataStream(server: McpServer) { {}, async () => { try { - const response = await spotClient.restAPI.newUserDataStream() + const response = await spotClient.restAPI.newUserDataStream(); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -21,15 +21,15 @@ export function registerBinanceNewUserDataStream(server: McpServer) { text: `Created new listen key for user data stream. Listen key: ${data.listenKey}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to create user data stream: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-spot/userdatastream-api/putUserDataStream.ts b/src/tools/binance-spot/userdatastream-api/putUserDataStream.ts index 4f054acd..3579e98d 100644 --- a/src/tools/binance-spot/userdatastream-api/putUserDataStream.ts +++ b/src/tools/binance-spot/userdatastream-api/putUserDataStream.ts @@ -1,9 +1,9 @@ // src/tools/binance-spot/userdatastream-api/putUserDataStream.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinancePutUserDataStream(server: McpServer) { server.tool( @@ -16,9 +16,9 @@ export function registerBinancePutUserDataStream(server: McpServer) { try { const response = await spotClient.restAPI.putUserDataStream({ listenKey: listenKey, - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -27,17 +27,17 @@ export function registerBinancePutUserDataStream(server: McpServer) { text: `Successfully extended validity of listen key: ${listenKey}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to extend listen key validity: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-staking/ETH-staking-api/ethStakingAccount.ts b/src/tools/binance-staking/ETH-staking-api/ethStakingAccount.ts index f2c6820f..b6b73263 100644 --- a/src/tools/binance-staking/ETH-staking-api/ethStakingAccount.ts +++ b/src/tools/binance-staking/ETH-staking-api/ethStakingAccount.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/ETH-staking-api/ethStakingAccount.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceEthStakingAccount(server: McpServer) { server.tool( @@ -16,9 +16,9 @@ export function registerBinanceEthStakingAccount(server: McpServer) { try { const response = await stakingClient.restAPI.ethStakingAccount({ ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,9 +29,9 @@ export function registerBinanceEthStakingAccount(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -41,8 +41,8 @@ export function registerBinanceEthStakingAccount(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-staking/ETH-staking-api/getCurrentEthStakingQuota.ts b/src/tools/binance-staking/ETH-staking-api/getCurrentEthStakingQuota.ts index f64b1532..cb23363b 100644 --- a/src/tools/binance-staking/ETH-staking-api/getCurrentEthStakingQuota.ts +++ b/src/tools/binance-staking/ETH-staking-api/getCurrentEthStakingQuota.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/ETH-staking-api/getCurrentEthStakingQuota.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetCurrentEthStakingQuota(server: McpServer) { server.tool( @@ -16,9 +16,9 @@ export function registerBinanceGetCurrentEthStakingQuota(server: McpServer) { try { const response = await stakingClient.restAPI.getCurrentEthStakingQuota({ ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,9 +29,9 @@ export function registerBinanceGetCurrentEthStakingQuota(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -41,8 +41,8 @@ export function registerBinanceGetCurrentEthStakingQuota(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-staking/ETH-staking-api/getEthRedemptionHistory.ts b/src/tools/binance-staking/ETH-staking-api/getEthRedemptionHistory.ts index 4e47b3ee..4ca27d3d 100644 --- a/src/tools/binance-staking/ETH-staking-api/getEthRedemptionHistory.ts +++ b/src/tools/binance-staking/ETH-staking-api/getEthRedemptionHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/ETH-staking-api/getEthRedemptionHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetEthRedemptionHistory(server: McpServer) { server.tool( @@ -45,9 +45,9 @@ export function registerBinanceGetEthRedemptionHistory(server: McpServer) { ...(params.endTime !== undefined && { endTime: params.endTime }), ...(params.current !== undefined && { current: params.current }), ...(params.size !== undefined && { size: params.size }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -58,9 +58,9 @@ export function registerBinanceGetEthRedemptionHistory(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -70,8 +70,8 @@ export function registerBinanceGetEthRedemptionHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-staking/ETH-staking-api/getEthStakingHistory.ts b/src/tools/binance-staking/ETH-staking-api/getEthStakingHistory.ts index 80d93ebb..6f2405f4 100644 --- a/src/tools/binance-staking/ETH-staking-api/getEthStakingHistory.ts +++ b/src/tools/binance-staking/ETH-staking-api/getEthStakingHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/ETH-staking-api/getEthStakingHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetEthStakingHistory(server: McpServer) { server.tool( @@ -45,9 +45,9 @@ export function registerBinanceGetEthStakingHistory(server: McpServer) { ...(params.endTime !== undefined && { endTime: params.endTime }), ...(params.current !== undefined && { current: params.current }), ...(params.size !== undefined && { size: params.size }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -58,9 +58,9 @@ export function registerBinanceGetEthStakingHistory(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -70,8 +70,8 @@ export function registerBinanceGetEthStakingHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-staking/ETH-staking-api/getWbethRateHistory.ts b/src/tools/binance-staking/ETH-staking-api/getWbethRateHistory.ts index a9c69bef..4f354623 100644 --- a/src/tools/binance-staking/ETH-staking-api/getWbethRateHistory.ts +++ b/src/tools/binance-staking/ETH-staking-api/getWbethRateHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/ETH-staking-api/getWbethRateHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetWbethRateHistory(server: McpServer) { server.tool( @@ -42,9 +42,9 @@ export function registerBinanceGetWbethRateHistory(server: McpServer) { ...(params.endTime !== undefined && { endTime: params.endTime }), ...(params.current !== undefined && { current: params.current }), ...(params.size !== undefined && { size: params.size }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -55,9 +55,9 @@ export function registerBinanceGetWbethRateHistory(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -67,8 +67,8 @@ export function registerBinanceGetWbethRateHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-staking/ETH-staking-api/getWbethRewardsHistory.ts b/src/tools/binance-staking/ETH-staking-api/getWbethRewardsHistory.ts index 79a83b5a..697014e7 100644 --- a/src/tools/binance-staking/ETH-staking-api/getWbethRewardsHistory.ts +++ b/src/tools/binance-staking/ETH-staking-api/getWbethRewardsHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/ETH-staking-api/getWbethRewardsHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetWbethRewardsHistory(server: McpServer) { server.tool( @@ -45,9 +45,9 @@ export function registerBinanceGetWbethRewardsHistory(server: McpServer) { ...(params.endTime !== undefined && { endTime: params.endTime }), ...(params.current !== undefined && { current: params.current }), ...(params.size !== undefined && { size: params.size }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -58,9 +58,9 @@ export function registerBinanceGetWbethRewardsHistory(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -70,8 +70,8 @@ export function registerBinanceGetWbethRewardsHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-staking/ETH-staking-api/getWbethUnwrapHistory.ts b/src/tools/binance-staking/ETH-staking-api/getWbethUnwrapHistory.ts index 7bdf1f01..d36db1e5 100644 --- a/src/tools/binance-staking/ETH-staking-api/getWbethUnwrapHistory.ts +++ b/src/tools/binance-staking/ETH-staking-api/getWbethUnwrapHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/ETH-staking-api/getWbethUnwrapHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetWbethUnwrapHistory(server: McpServer) { server.tool( @@ -41,9 +41,9 @@ export function registerBinanceGetWbethUnwrapHistory(server: McpServer) { ...(params.current !== undefined && { current: params.current }), ...(params.size !== undefined && { size: params.size }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -54,9 +54,9 @@ export function registerBinanceGetWbethUnwrapHistory(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -66,8 +66,8 @@ export function registerBinanceGetWbethUnwrapHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-staking/ETH-staking-api/getWbethWrapHistory.ts b/src/tools/binance-staking/ETH-staking-api/getWbethWrapHistory.ts index 0901f741..29d4e678 100644 --- a/src/tools/binance-staking/ETH-staking-api/getWbethWrapHistory.ts +++ b/src/tools/binance-staking/ETH-staking-api/getWbethWrapHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/ETH-staking-api/getWbethWrapHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetWbethWrapHistory(server: McpServer) { server.tool( @@ -37,9 +37,9 @@ export function registerBinanceGetWbethWrapHistory(server: McpServer) { ...(params.current !== undefined && { current: params.current }), ...(params.size !== undefined && { size: params.size }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -50,9 +50,9 @@ export function registerBinanceGetWbethWrapHistory(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -62,8 +62,8 @@ export function registerBinanceGetWbethWrapHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-staking/ETH-staking-api/index.ts b/src/tools/binance-staking/ETH-staking-api/index.ts index ce933182..9430f1f2 100644 --- a/src/tools/binance-staking/ETH-staking-api/index.ts +++ b/src/tools/binance-staking/ETH-staking-api/index.ts @@ -1,28 +1,28 @@ // src/tools/binance-staking/ETH-staking-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceEthStakingAccount } from "./ethStakingAccount.js" -import { registerBinanceGetCurrentEthStakingQuota } from "./getCurrentEthStakingQuota.js" -import { registerBinanceGetEthRedemptionHistory } from "./getEthRedemptionHistory.js" -import { registerBinanceGetEthStakingHistory } from "./getEthStakingHistory.js" -import { registerBinanceGetWbethRateHistory } from "./getWbethRateHistory.js" -import { registerBinanceGetWbethRewardsHistory } from "./getWbethRewardsHistory.js" -import { registerBinanceGetWbethUnwrapHistory } from "./getWbethUnwrapHistory.js" -import { registerBinanceGetWbethWrapHistory } from "./getWbethWrapHistory.js" -import { registerBinanceRedeemEth } from "./redeemEth.js" -import { registerBinanceSubscribeEthStaking } from "./subscribeEthStaking.js" -import { registerBinanceWrapBeth } from "./wrapBeth.js" +import { registerBinanceEthStakingAccount } from "./ethStakingAccount.js"; +import { registerBinanceGetCurrentEthStakingQuota } from "./getCurrentEthStakingQuota.js"; +import { registerBinanceGetEthRedemptionHistory } from "./getEthRedemptionHistory.js"; +import { registerBinanceGetEthStakingHistory } from "./getEthStakingHistory.js"; +import { registerBinanceGetWbethRateHistory } from "./getWbethRateHistory.js"; +import { registerBinanceGetWbethRewardsHistory } from "./getWbethRewardsHistory.js"; +import { registerBinanceGetWbethUnwrapHistory } from "./getWbethUnwrapHistory.js"; +import { registerBinanceGetWbethWrapHistory } from "./getWbethWrapHistory.js"; +import { registerBinanceRedeemEth } from "./redeemEth.js"; +import { registerBinanceSubscribeEthStaking } from "./subscribeEthStaking.js"; +import { registerBinanceWrapBeth } from "./wrapBeth.js"; export function registerBinanceETHStakingApiTools(server: McpServer) { - registerBinanceEthStakingAccount(server) - registerBinanceGetCurrentEthStakingQuota(server) - registerBinanceGetEthRedemptionHistory(server) - registerBinanceGetEthStakingHistory(server) - registerBinanceGetWbethRateHistory(server) - registerBinanceGetWbethRewardsHistory(server) - registerBinanceGetWbethUnwrapHistory(server) - registerBinanceGetWbethWrapHistory(server) - registerBinanceRedeemEth(server) - registerBinanceSubscribeEthStaking(server) - registerBinanceWrapBeth(server) + registerBinanceEthStakingAccount(server); + registerBinanceGetCurrentEthStakingQuota(server); + registerBinanceGetEthRedemptionHistory(server); + registerBinanceGetEthStakingHistory(server); + registerBinanceGetWbethRateHistory(server); + registerBinanceGetWbethRewardsHistory(server); + registerBinanceGetWbethUnwrapHistory(server); + registerBinanceGetWbethWrapHistory(server); + registerBinanceRedeemEth(server); + registerBinanceSubscribeEthStaking(server); + registerBinanceWrapBeth(server); } diff --git a/src/tools/binance-staking/ETH-staking-api/redeemEth.ts b/src/tools/binance-staking/ETH-staking-api/redeemEth.ts index 33fc2e31..53d22e97 100644 --- a/src/tools/binance-staking/ETH-staking-api/redeemEth.ts +++ b/src/tools/binance-staking/ETH-staking-api/redeemEth.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/ETH-staking-api/redeemEth.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceRedeemEth(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerBinanceRedeemEth(server: McpServer) { amount: params.amount, asset: params.asset, ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,9 +35,9 @@ export function registerBinanceRedeemEth(server: McpServer) { text: `Successfully redeemed WBETH or BETH for ETH. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -47,8 +47,8 @@ export function registerBinanceRedeemEth(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-staking/ETH-staking-api/subscribeEthStaking.ts b/src/tools/binance-staking/ETH-staking-api/subscribeEthStaking.ts index f288528d..b9c9272d 100644 --- a/src/tools/binance-staking/ETH-staking-api/subscribeEthStaking.ts +++ b/src/tools/binance-staking/ETH-staking-api/subscribeEthStaking.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/ETH-staking-api/subscribeEthStaking.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceSubscribeEthStaking(server: McpServer) { server.tool( @@ -18,9 +18,9 @@ export function registerBinanceSubscribeEthStaking(server: McpServer) { const response = await stakingClient.restAPI.subscribeEthStaking({ amount: params.amount, ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,9 +29,9 @@ export function registerBinanceSubscribeEthStaking(server: McpServer) { text: `Successfully staked ETH and receive WBETH. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -41,8 +41,8 @@ export function registerBinanceSubscribeEthStaking(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-staking/ETH-staking-api/wrapBeth.ts b/src/tools/binance-staking/ETH-staking-api/wrapBeth.ts index 01845a0c..596c5486 100644 --- a/src/tools/binance-staking/ETH-staking-api/wrapBeth.ts +++ b/src/tools/binance-staking/ETH-staking-api/wrapBeth.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/ETHStaking-api/wrapBeth.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceWrapBeth(server: McpServer) { server.tool( @@ -18,9 +18,9 @@ export function registerBinanceWrapBeth(server: McpServer) { const response = await stakingClient.restAPI.wrapBeth({ amount: params.amount, ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,9 +29,9 @@ export function registerBinanceWrapBeth(server: McpServer) { text: `Successfully convert BETH into WBETH. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -41,8 +41,8 @@ export function registerBinanceWrapBeth(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-staking/SOL-staking-api/claimBoostRewards.ts b/src/tools/binance-staking/SOL-staking-api/claimBoostRewards.ts index 2cb0f0d9..f79e096c 100644 --- a/src/tools/binance-staking/SOL-staking-api/claimBoostRewards.ts +++ b/src/tools/binance-staking/SOL-staking-api/claimBoostRewards.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/SOL-staking-api/claimBoostRewards.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceClaimBoostRewards(server: McpServer) { server.tool( @@ -16,9 +16,9 @@ export function registerBinanceClaimBoostRewards(server: McpServer) { try { const response = await stakingClient.restAPI.claimBoostRewards({ ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,9 +29,9 @@ export function registerBinanceClaimBoostRewards(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -41,8 +41,8 @@ export function registerBinanceClaimBoostRewards(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-staking/SOL-staking-api/getBnsolRateHistory.ts b/src/tools/binance-staking/SOL-staking-api/getBnsolRateHistory.ts index 7ee8fbc6..12381dac 100644 --- a/src/tools/binance-staking/SOL-staking-api/getBnsolRateHistory.ts +++ b/src/tools/binance-staking/SOL-staking-api/getBnsolRateHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/SOL-staking-api/getBnsolRateHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetBnsolRateHistory(server: McpServer) { server.tool( @@ -37,9 +37,9 @@ export function registerBinanceGetBnsolRateHistory(server: McpServer) { ...(params.current !== undefined && { current: params.current }), ...(params.size !== undefined && { size: params.size }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -50,9 +50,9 @@ export function registerBinanceGetBnsolRateHistory(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -62,8 +62,8 @@ export function registerBinanceGetBnsolRateHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-staking/SOL-staking-api/getBnsolRewardsHistory.ts b/src/tools/binance-staking/SOL-staking-api/getBnsolRewardsHistory.ts index 277f7189..a11cfcab 100644 --- a/src/tools/binance-staking/SOL-staking-api/getBnsolRewardsHistory.ts +++ b/src/tools/binance-staking/SOL-staking-api/getBnsolRewardsHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/SOL-staking-api/getBnsolRewardsHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetBnsolRewardsHistory(server: McpServer) { server.tool( @@ -42,9 +42,9 @@ export function registerBinanceGetBnsolRewardsHistory(server: McpServer) { ...(params.size !== undefined && { size: params.size }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), ...(params.type && { type: params.type }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -55,9 +55,9 @@ export function registerBinanceGetBnsolRewardsHistory(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -67,8 +67,8 @@ export function registerBinanceGetBnsolRewardsHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-staking/SOL-staking-api/getBoostRewardsHistory.ts b/src/tools/binance-staking/SOL-staking-api/getBoostRewardsHistory.ts index b4659629..674bcca5 100644 --- a/src/tools/binance-staking/SOL-staking-api/getBoostRewardsHistory.ts +++ b/src/tools/binance-staking/SOL-staking-api/getBoostRewardsHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/SOL-staking-api/getBoostRewardsHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetBoostRewardsHistory(server: McpServer) { server.tool( @@ -42,8 +42,8 @@ export function registerBinanceGetBoostRewardsHistory(server: McpServer) { ...(params.current !== undefined && { current: params.current }), ...(params.size !== undefined && { size: params.size }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -54,9 +54,9 @@ export function registerBinanceGetBoostRewardsHistory(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -66,8 +66,8 @@ export function registerBinanceGetBoostRewardsHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-staking/SOL-staking-api/getSolRedemptionHistory.ts b/src/tools/binance-staking/SOL-staking-api/getSolRedemptionHistory.ts index 03e91757..de4997af 100644 --- a/src/tools/binance-staking/SOL-staking-api/getSolRedemptionHistory.ts +++ b/src/tools/binance-staking/SOL-staking-api/getSolRedemptionHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/SOL-staking-api/getSolRedemptionHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetSolRedemptionHistory(server: McpServer) { server.tool( @@ -37,9 +37,9 @@ export function registerBinanceGetSolRedemptionHistory(server: McpServer) { ...(params.current !== undefined && { current: params.current }), ...(params.size !== undefined && { size: params.size }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -48,9 +48,9 @@ export function registerBinanceGetSolRedemptionHistory(server: McpServer) { text: `Successfully retrieved SOL redemption history. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -60,8 +60,8 @@ export function registerBinanceGetSolRedemptionHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-staking/SOL-staking-api/getSolStakingHistory.ts b/src/tools/binance-staking/SOL-staking-api/getSolStakingHistory.ts index e20e2c7c..4ebfba7b 100644 --- a/src/tools/binance-staking/SOL-staking-api/getSolStakingHistory.ts +++ b/src/tools/binance-staking/SOL-staking-api/getSolStakingHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/SOL-staking-api/getSolStakingHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetSolStakingHistory(server: McpServer) { server.tool( @@ -37,9 +37,9 @@ export function registerBinanceGetSolStakingHistory(server: McpServer) { ...(params.current !== undefined && { current: params.current }), ...(params.size !== undefined && { size: params.size }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -48,9 +48,9 @@ export function registerBinanceGetSolStakingHistory(server: McpServer) { text: `Successfully retrieved SOL staking history. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -60,8 +60,8 @@ export function registerBinanceGetSolStakingHistory(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-staking/SOL-staking-api/getSolStakingQuotaDetails.ts b/src/tools/binance-staking/SOL-staking-api/getSolStakingQuotaDetails.ts index 84ed7ce3..d2757f96 100644 --- a/src/tools/binance-staking/SOL-staking-api/getSolStakingQuotaDetails.ts +++ b/src/tools/binance-staking/SOL-staking-api/getSolStakingQuotaDetails.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/SOL-staking-api/getSolStakingQuotaDetails.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetSolStakingQuotaDetails(server: McpServer) { server.tool( @@ -16,9 +16,9 @@ export function registerBinanceGetSolStakingQuotaDetails(server: McpServer) { try { const response = await stakingClient.restAPI.getSolStakingQuotaDetails({ ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -27,9 +27,9 @@ export function registerBinanceGetSolStakingQuotaDetails(server: McpServer) { text: `Successfully retrieved current SOL staking quota. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -39,8 +39,8 @@ export function registerBinanceGetSolStakingQuotaDetails(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-staking/SOL-staking-api/getUnclaimedRewards.ts b/src/tools/binance-staking/SOL-staking-api/getUnclaimedRewards.ts index 93687ff9..8d022775 100644 --- a/src/tools/binance-staking/SOL-staking-api/getUnclaimedRewards.ts +++ b/src/tools/binance-staking/SOL-staking-api/getUnclaimedRewards.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/SOL-staking-api/getUnclaimedRewards.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetUnclaimedRewards(server: McpServer) { server.tool( @@ -16,9 +16,9 @@ export function registerBinanceGetUnclaimedRewards(server: McpServer) { try { const response = await stakingClient.restAPI.getUnclaimedRewards({ ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,9 +29,9 @@ export function registerBinanceGetUnclaimedRewards(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -41,8 +41,8 @@ export function registerBinanceGetUnclaimedRewards(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-staking/SOL-staking-api/index.ts b/src/tools/binance-staking/SOL-staking-api/index.ts index 117dd8e1..1485119d 100644 --- a/src/tools/binance-staking/SOL-staking-api/index.ts +++ b/src/tools/binance-staking/SOL-staking-api/index.ts @@ -1,28 +1,28 @@ // src/tools/binance-staking/SOL-staking-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceClaimBoostRewards } from "./claimBoostRewards.js" -import { registerBinanceGetBnsolRateHistory } from "./getBnsolRateHistory.js" -import { registerBinanceGetBnsolRewardsHistory } from "./getBnsolRewardsHistory.js" -import { registerBinanceGetBoostRewardsHistory } from "./getBoostRewardsHistory.js" -import { registerBinanceGetSolRedemptionHistory } from "./getSolRedemptionHistory.js" -import { registerBinanceGetSolStakingHistory } from "./getSolStakingHistory.js" -import { registerBinanceGetSolStakingQuotaDetails } from "./getSolStakingQuotaDetails.js" -import { registerBinanceGetUnclaimedRewards } from "./getUnclaimedRewards.js" -import { registerBinanceRedeemSol } from "./redeemSol.js" -import { registerBinanceSolStakingAccount } from "./solStakingAccount.js" -import { registerBinanceSubscribeSolStaking } from "./subscribeSolStaking.js" +import { registerBinanceClaimBoostRewards } from "./claimBoostRewards.js"; +import { registerBinanceGetBnsolRateHistory } from "./getBnsolRateHistory.js"; +import { registerBinanceGetBnsolRewardsHistory } from "./getBnsolRewardsHistory.js"; +import { registerBinanceGetBoostRewardsHistory } from "./getBoostRewardsHistory.js"; +import { registerBinanceGetSolRedemptionHistory } from "./getSolRedemptionHistory.js"; +import { registerBinanceGetSolStakingHistory } from "./getSolStakingHistory.js"; +import { registerBinanceGetSolStakingQuotaDetails } from "./getSolStakingQuotaDetails.js"; +import { registerBinanceGetUnclaimedRewards } from "./getUnclaimedRewards.js"; +import { registerBinanceRedeemSol } from "./redeemSol.js"; +import { registerBinanceSolStakingAccount } from "./solStakingAccount.js"; +import { registerBinanceSubscribeSolStaking } from "./subscribeSolStaking.js"; export function registerBinanceSOLStakingApiTools(server: McpServer) { - registerBinanceClaimBoostRewards(server) - registerBinanceGetBnsolRateHistory(server) - registerBinanceGetBnsolRewardsHistory(server) - registerBinanceGetBoostRewardsHistory(server) - registerBinanceGetSolRedemptionHistory(server) - registerBinanceGetSolStakingHistory(server) - registerBinanceGetSolStakingQuotaDetails(server) - registerBinanceGetUnclaimedRewards(server) - registerBinanceRedeemSol(server) - registerBinanceSolStakingAccount(server) - registerBinanceSubscribeSolStaking(server) + registerBinanceClaimBoostRewards(server); + registerBinanceGetBnsolRateHistory(server); + registerBinanceGetBnsolRewardsHistory(server); + registerBinanceGetBoostRewardsHistory(server); + registerBinanceGetSolRedemptionHistory(server); + registerBinanceGetSolStakingHistory(server); + registerBinanceGetSolStakingQuotaDetails(server); + registerBinanceGetUnclaimedRewards(server); + registerBinanceRedeemSol(server); + registerBinanceSolStakingAccount(server); + registerBinanceSubscribeSolStaking(server); } diff --git a/src/tools/binance-staking/SOL-staking-api/redeemSol.ts b/src/tools/binance-staking/SOL-staking-api/redeemSol.ts index ef2d7608..9121ac3c 100644 --- a/src/tools/binance-staking/SOL-staking-api/redeemSol.ts +++ b/src/tools/binance-staking/SOL-staking-api/redeemSol.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/SOL-staking-api/getUnclaimedRewards.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceRedeemSol(server: McpServer) { server.tool( @@ -22,9 +22,9 @@ export function registerBinanceRedeemSol(server: McpServer) { const response = await stakingClient.restAPI.redeemSol({ amount: params.amount, ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,9 +35,9 @@ export function registerBinanceRedeemSol(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -47,8 +47,8 @@ export function registerBinanceRedeemSol(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-staking/SOL-staking-api/solStakingAccount.ts b/src/tools/binance-staking/SOL-staking-api/solStakingAccount.ts index 9674b5e3..65e2d89b 100644 --- a/src/tools/binance-staking/SOL-staking-api/solStakingAccount.ts +++ b/src/tools/binance-staking/SOL-staking-api/solStakingAccount.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/SOL-staking-api/solStakingAccount.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceSolStakingAccount(server: McpServer) { server.tool( @@ -16,9 +16,9 @@ export function registerBinanceSolStakingAccount(server: McpServer) { try { const response = await stakingClient.restAPI.solStakingAccount({ ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -27,9 +27,9 @@ export function registerBinanceSolStakingAccount(server: McpServer) { text: `Successfully retrieve SOL staking account details: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -39,8 +39,8 @@ export function registerBinanceSolStakingAccount(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-staking/SOL-staking-api/subscribeSolStaking.ts b/src/tools/binance-staking/SOL-staking-api/subscribeSolStaking.ts index 81b31bf7..6ac11d78 100644 --- a/src/tools/binance-staking/SOL-staking-api/subscribeSolStaking.ts +++ b/src/tools/binance-staking/SOL-staking-api/subscribeSolStaking.ts @@ -1,9 +1,9 @@ // src/tools/binance-staking/SOL-staking-api/subscribeSolStaking.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { stakingClient } from "../../../config/binanceClient.js" +import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceSubscribeSolStaking(server: McpServer) { server.tool( @@ -18,9 +18,9 @@ export function registerBinanceSubscribeSolStaking(server: McpServer) { const response = await stakingClient.restAPI.subscribeSolStaking({ amount: params.amount, ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -29,9 +29,9 @@ export function registerBinanceSubscribeSolStaking(server: McpServer) { text: `Successfully stake SOL and receive BNSOL in return: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -41,8 +41,8 @@ export function registerBinanceSubscribeSolStaking(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-staking/index.ts b/src/tools/binance-staking/index.ts index 3ba3de44..b96f673e 100644 --- a/src/tools/binance-staking/index.ts +++ b/src/tools/binance-staking/index.ts @@ -1,10 +1,10 @@ // src/tools/binance-staking/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceETHStakingApiTools } from "./ETH-staking-api/index.js" -import { registerBinanceSOLStakingApiTools } from "./SOL-staking-api/index.js" +import { registerBinanceETHStakingApiTools } from "./ETH-staking-api/index.js"; +import { registerBinanceSOLStakingApiTools } from "./SOL-staking-api/index.js"; export function registerBinanceStakingTools(server: McpServer) { - registerBinanceETHStakingApiTools(server) - registerBinanceSOLStakingApiTools(server) + registerBinanceETHStakingApiTools(server); + registerBinanceSOLStakingApiTools(server); } diff --git a/src/tools/binance-sub-account/assets-api/getFuturesAssetsSummary.ts b/src/tools/binance-sub-account/assets-api/getFuturesAssetsSummary.ts index d3609a42..a65be43e 100644 --- a/src/tools/binance-sub-account/assets-api/getFuturesAssetsSummary.ts +++ b/src/tools/binance-sub-account/assets-api/getFuturesAssetsSummary.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/assets-api/getFuturesAssetsSummary.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountFuturesSummary(server: McpServer) { server.tool( @@ -27,9 +27,9 @@ export function registerBinanceSubAccountFuturesSummary(server: McpServer) { const response = await spotClient.restAPI.getSubAccountFuturesAccountSummaryV2({ ...(params.futuresType && { futuresType: params.futuresType }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -38,15 +38,15 @@ export function registerBinanceSubAccountFuturesSummary(server: McpServer) { text: `Sub-Account Futures Summary:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get futures summary: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/assets-api/getFuturesPositionRisk.ts b/src/tools/binance-sub-account/assets-api/getFuturesPositionRisk.ts index 498d079a..10eab6ad 100644 --- a/src/tools/binance-sub-account/assets-api/getFuturesPositionRisk.ts +++ b/src/tools/binance-sub-account/assets-api/getFuturesPositionRisk.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/assets-api/getFuturesPositionRisk.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountFuturesPositionRisk(server: McpServer) { server.tool( @@ -29,9 +29,9 @@ export function registerBinanceSubAccountFuturesPositionRisk(server: McpServer) email: params.email, ...(params.futuresType && { futuresType: params.futuresType }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -40,15 +40,15 @@ export function registerBinanceSubAccountFuturesPositionRisk(server: McpServer) text: `Sub-Account Futures Position Risk for ${params.email}:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get position risk: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/assets-api/getMarginAssetsSummary.ts b/src/tools/binance-sub-account/assets-api/getMarginAssetsSummary.ts index 8bde0597..ea36cc95 100644 --- a/src/tools/binance-sub-account/assets-api/getMarginAssetsSummary.ts +++ b/src/tools/binance-sub-account/assets-api/getMarginAssetsSummary.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/assets-api/getMarginAssetsSummary.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountMarginSummary(server: McpServer) { server.tool( @@ -22,9 +22,9 @@ export function registerBinanceSubAccountMarginSummary(server: McpServer) { try { const response = await spotClient.restAPI.getSubAccountMarginAccountSummary({ ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -33,15 +33,15 @@ export function registerBinanceSubAccountMarginSummary(server: McpServer) { text: `Sub-Account Margin Summary:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get margin summary: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/assets-api/getSpotAssetsSummary.ts b/src/tools/binance-sub-account/assets-api/getSpotAssetsSummary.ts index c6857004..10bd64e7 100644 --- a/src/tools/binance-sub-account/assets-api/getSpotAssetsSummary.ts +++ b/src/tools/binance-sub-account/assets-api/getSpotAssetsSummary.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/assets-api/getSpotAssetsSummary.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountSpotSummary(server: McpServer) { server.tool( @@ -34,9 +34,9 @@ export function registerBinanceSubAccountSpotSummary(server: McpServer) { ...(params.page && { page: params.page }), ...(params.size && { size: params.size }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -45,15 +45,15 @@ export function registerBinanceSubAccountSpotSummary(server: McpServer) { text: `Sub-Account Spot Assets Summary:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get spot summary: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/assets-api/getSubAccountAssets.ts b/src/tools/binance-sub-account/assets-api/getSubAccountAssets.ts index 6d974aeb..c4e3a561 100644 --- a/src/tools/binance-sub-account/assets-api/getSubAccountAssets.ts +++ b/src/tools/binance-sub-account/assets-api/getSubAccountAssets.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/assets-api/getSubAccountAssets.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountAssets(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerBinanceSubAccountAssets(server: McpServer) { const response = await spotClient.restAPI.querySubAccountAssetsV4({ email: params.email, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,15 +35,15 @@ export function registerBinanceSubAccountAssets(server: McpServer) { text: `Sub-Account Assets for ${params.email}:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get sub-account assets: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/assets-api/index.ts b/src/tools/binance-sub-account/assets-api/index.ts index e085ec42..31ccd8e5 100644 --- a/src/tools/binance-sub-account/assets-api/index.ts +++ b/src/tools/binance-sub-account/assets-api/index.ts @@ -5,18 +5,18 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/assets-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceSubAccountFuturesSummary } from "./getFuturesAssetsSummary.js" -import { registerBinanceSubAccountFuturesPositionRisk } from "./getFuturesPositionRisk.js" -import { registerBinanceSubAccountMarginSummary } from "./getMarginAssetsSummary.js" -import { registerBinanceSubAccountSpotSummary } from "./getSpotAssetsSummary.js" -import { registerBinanceSubAccountAssets } from "./getSubAccountAssets.js" +import { registerBinanceSubAccountFuturesSummary } from "./getFuturesAssetsSummary.js"; +import { registerBinanceSubAccountFuturesPositionRisk } from "./getFuturesPositionRisk.js"; +import { registerBinanceSubAccountMarginSummary } from "./getMarginAssetsSummary.js"; +import { registerBinanceSubAccountSpotSummary } from "./getSpotAssetsSummary.js"; +import { registerBinanceSubAccountAssets } from "./getSubAccountAssets.js"; export function registerBinanceSubAccountAssetsTools(server: McpServer) { - registerBinanceSubAccountAssets(server) - registerBinanceSubAccountSpotSummary(server) - registerBinanceSubAccountMarginSummary(server) - registerBinanceSubAccountFuturesSummary(server) - registerBinanceSubAccountFuturesPositionRisk(server) + registerBinanceSubAccountAssets(server); + registerBinanceSubAccountSpotSummary(server); + registerBinanceSubAccountMarginSummary(server); + registerBinanceSubAccountFuturesSummary(server); + registerBinanceSubAccountFuturesPositionRisk(server); } diff --git a/src/tools/binance-sub-account/createApiKey.ts b/src/tools/binance-sub-account/createApiKey.ts index 531f4ed6..d658a8a6 100644 --- a/src/tools/binance-sub-account/createApiKey.ts +++ b/src/tools/binance-sub-account/createApiKey.ts @@ -1,9 +1,9 @@ // src/tools/binance-sub-account/createApiKey.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js" +import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountCreateApiKey(server: McpServer) { server.tool( @@ -18,12 +18,12 @@ export function registerBinanceSubAccountCreateApiKey(server: McpServer) { }, async ({ subAccountId, canTrade, marginTrade, futuresTrade, recvWindow }) => { try { - const params: any = { subAccountId, canTrade } - if (marginTrade !== undefined) params.marginTrade = marginTrade - if (futuresTrade !== undefined) params.futuresTrade = futuresTrade - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = { subAccountId, canTrade }; + if (marginTrade !== undefined) params.marginTrade = marginTrade; + if (futuresTrade !== undefined) params.futuresTrade = futuresTrade; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await subAccountApiClient.createSubAccountApiKey(params) + const data = await subAccountApiClient.createSubAccountApiKey(params); return { content: [ @@ -32,17 +32,17 @@ export function registerBinanceSubAccountCreateApiKey(server: McpServer) { text: `API key created for sub-account. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to create sub-account API key: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/createVirtualSubAccount.ts b/src/tools/binance-sub-account/createVirtualSubAccount.ts index 1769b68b..252c33df 100644 --- a/src/tools/binance-sub-account/createVirtualSubAccount.ts +++ b/src/tools/binance-sub-account/createVirtualSubAccount.ts @@ -1,9 +1,9 @@ // src/tools/binance-sub-account/createVirtualSubAccount.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js" +import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountCreateVirtual(server: McpServer) { server.tool( @@ -15,10 +15,10 @@ export function registerBinanceSubAccountCreateVirtual(server: McpServer) { }, async ({ subAccountString, recvWindow }) => { try { - const params: any = { subAccountString } - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = { subAccountString }; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await subAccountApiClient.createVirtualSubAccount(params) + const data = await subAccountApiClient.createVirtualSubAccount(params); return { content: [ @@ -27,17 +27,17 @@ export function registerBinanceSubAccountCreateVirtual(server: McpServer) { text: `Virtual sub-account created: ${subAccountString}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to create virtual sub-account: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/deleteApiKey.ts b/src/tools/binance-sub-account/deleteApiKey.ts index ae2f84de..be04c9f9 100644 --- a/src/tools/binance-sub-account/deleteApiKey.ts +++ b/src/tools/binance-sub-account/deleteApiKey.ts @@ -1,9 +1,9 @@ // src/tools/binance-sub-account/deleteApiKey.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js" +import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountDeleteApiKey(server: McpServer) { server.tool( @@ -16,10 +16,10 @@ export function registerBinanceSubAccountDeleteApiKey(server: McpServer) { }, async ({ subAccountId, subAccountApiKey, recvWindow }) => { try { - const params: any = { subAccountId, subAccountApiKey } - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = { subAccountId, subAccountApiKey }; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await subAccountApiClient.deleteSubAccountApiKey(params) + const data = await subAccountApiClient.deleteSubAccountApiKey(params); return { content: [ @@ -28,17 +28,17 @@ export function registerBinanceSubAccountDeleteApiKey(server: McpServer) { text: `API key deleted for sub-account. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to delete sub-account API key: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/deposit-api/getDepositAddress.ts b/src/tools/binance-sub-account/deposit-api/getDepositAddress.ts index 186cac5a..9be5dde0 100644 --- a/src/tools/binance-sub-account/deposit-api/getDepositAddress.ts +++ b/src/tools/binance-sub-account/deposit-api/getDepositAddress.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/deposit-api/getDepositAddress.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountDepositAddress(server: McpServer) { server.tool( @@ -28,9 +28,9 @@ export function registerBinanceSubAccountDepositAddress(server: McpServer) { coin: params.coin, ...(params.network && { network: params.network }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -39,15 +39,15 @@ export function registerBinanceSubAccountDepositAddress(server: McpServer) { text: `Deposit Address for ${params.email}:\n\nCoin: ${params.coin}\nNetwork: ${params.network || "Default"}\nAddress: ${data.address}\n${data.tag ? `Tag/Memo: ${data.tag}` : ""}\n\n⚠️ Always verify the address before sending funds!`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get deposit address: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/deposit-api/getDepositHistory.ts b/src/tools/binance-sub-account/deposit-api/getDepositHistory.ts index 19b4921f..4c8f02a4 100644 --- a/src/tools/binance-sub-account/deposit-api/getDepositHistory.ts +++ b/src/tools/binance-sub-account/deposit-api/getDepositHistory.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/deposit-api/getDepositHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountDepositHistory(server: McpServer) { server.tool( @@ -39,9 +39,9 @@ export function registerBinanceSubAccountDepositHistory(server: McpServer) { ...(params.limit && { limit: params.limit }), ...(params.offset && { offset: params.offset }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -50,15 +50,15 @@ export function registerBinanceSubAccountDepositHistory(server: McpServer) { text: `Sub-Account Deposit History for ${params.email}:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get deposit history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/deposit-api/index.ts b/src/tools/binance-sub-account/deposit-api/index.ts index bea59881..88924663 100644 --- a/src/tools/binance-sub-account/deposit-api/index.ts +++ b/src/tools/binance-sub-account/deposit-api/index.ts @@ -5,12 +5,12 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/deposit-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceSubAccountDepositAddress } from "./getDepositAddress.js" -import { registerBinanceSubAccountDepositHistory } from "./getDepositHistory.js" +import { registerBinanceSubAccountDepositAddress } from "./getDepositAddress.js"; +import { registerBinanceSubAccountDepositHistory } from "./getDepositHistory.js"; export function registerBinanceSubAccountDepositTools(server: McpServer) { - registerBinanceSubAccountDepositAddress(server) - registerBinanceSubAccountDepositHistory(server) + registerBinanceSubAccountDepositAddress(server); + registerBinanceSubAccountDepositHistory(server); } diff --git a/src/tools/binance-sub-account/enableFutures.ts b/src/tools/binance-sub-account/enableFutures.ts index 8242eaed..978ce66e 100644 --- a/src/tools/binance-sub-account/enableFutures.ts +++ b/src/tools/binance-sub-account/enableFutures.ts @@ -1,9 +1,9 @@ // src/tools/binance-sub-account/enableFutures.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js" +import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountEnableFutures(server: McpServer) { server.tool( @@ -15,10 +15,10 @@ export function registerBinanceSubAccountEnableFutures(server: McpServer) { }, async ({ email, recvWindow }) => { try { - const params: any = { email } - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = { email }; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await subAccountApiClient.enableFuturesForSubAccount(params) + const data = await subAccountApiClient.enableFuturesForSubAccount(params); return { content: [ @@ -27,17 +27,17 @@ export function registerBinanceSubAccountEnableFutures(server: McpServer) { text: `Futures enabled for sub-account ${email}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to enable futures for sub-account: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/enableMargin.ts b/src/tools/binance-sub-account/enableMargin.ts index 0fa97800..124fc4bb 100644 --- a/src/tools/binance-sub-account/enableMargin.ts +++ b/src/tools/binance-sub-account/enableMargin.ts @@ -1,9 +1,9 @@ // src/tools/binance-sub-account/enableMargin.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js" +import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountEnableMargin(server: McpServer) { server.tool( @@ -15,10 +15,10 @@ export function registerBinanceSubAccountEnableMargin(server: McpServer) { }, async ({ email, recvWindow }) => { try { - const params: any = { email } - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = { email }; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await subAccountApiClient.enableMarginForSubAccount(params) + const data = await subAccountApiClient.enableMarginForSubAccount(params); return { content: [ @@ -27,17 +27,17 @@ export function registerBinanceSubAccountEnableMargin(server: McpServer) { text: `Margin enabled for sub-account ${email}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to enable margin for sub-account: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/getApiKeyIpRestriction.ts b/src/tools/binance-sub-account/getApiKeyIpRestriction.ts index aa378c95..c082df43 100644 --- a/src/tools/binance-sub-account/getApiKeyIpRestriction.ts +++ b/src/tools/binance-sub-account/getApiKeyIpRestriction.ts @@ -1,9 +1,9 @@ // src/tools/binance-sub-account/getApiKeyIpRestriction.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js" +import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountGetApiKeyIpRestriction(server: McpServer) { server.tool( @@ -16,10 +16,10 @@ export function registerBinanceSubAccountGetApiKeyIpRestriction(server: McpServe }, async ({ subAccountId, subAccountApiKey, recvWindow }) => { try { - const params: any = { subAccountId, subAccountApiKey } - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = { subAccountId, subAccountApiKey }; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await subAccountApiClient.getSubAccountApiKeyIpRestriction(params) + const data = await subAccountApiClient.getSubAccountApiKeyIpRestriction(params); return { content: [ @@ -28,15 +28,15 @@ export function registerBinanceSubAccountGetApiKeyIpRestriction(server: McpServe text: `Retrieved IP restriction for sub-account API key. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get IP restriction: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/getSubAccountAssets.ts b/src/tools/binance-sub-account/getSubAccountAssets.ts index 5fcef84b..91cb988a 100644 --- a/src/tools/binance-sub-account/getSubAccountAssets.ts +++ b/src/tools/binance-sub-account/getSubAccountAssets.ts @@ -1,9 +1,9 @@ // src/tools/binance-sub-account/getSubAccountAssets.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js" +import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountGetAssets(server: McpServer) { server.tool( @@ -15,10 +15,10 @@ export function registerBinanceSubAccountGetAssets(server: McpServer) { }, async ({ email, recvWindow }) => { try { - const params: any = { email } - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = { email }; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await subAccountApiClient.getSubAccountAssets(params) + const data = await subAccountApiClient.getSubAccountAssets(params); return { content: [ @@ -27,15 +27,15 @@ export function registerBinanceSubAccountGetAssets(server: McpServer) { text: `Retrieved assets for sub-account ${email}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get sub-account assets: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/getSubAccountDepositAddress.ts b/src/tools/binance-sub-account/getSubAccountDepositAddress.ts index 104b89c3..2c90f5d5 100644 --- a/src/tools/binance-sub-account/getSubAccountDepositAddress.ts +++ b/src/tools/binance-sub-account/getSubAccountDepositAddress.ts @@ -1,9 +1,9 @@ // src/tools/binance-sub-account/getSubAccountDepositAddress.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js" +import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountGetDepositAddress(server: McpServer) { server.tool( @@ -17,11 +17,11 @@ export function registerBinanceSubAccountGetDepositAddress(server: McpServer) { }, async ({ email, coin, network, recvWindow }) => { try { - const params: any = { email, coin } - if (network !== undefined) params.network = network - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = { email, coin }; + if (network !== undefined) params.network = network; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await subAccountApiClient.getSubAccountDepositAddress(params) + const data = await subAccountApiClient.getSubAccountDepositAddress(params); return { content: [ @@ -30,17 +30,17 @@ export function registerBinanceSubAccountGetDepositAddress(server: McpServer) { text: `Retrieved deposit address for ${coin} on ${email}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to get sub-account deposit address: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/getSubAccountDepositHistory.ts b/src/tools/binance-sub-account/getSubAccountDepositHistory.ts index 81ff3250..250653f5 100644 --- a/src/tools/binance-sub-account/getSubAccountDepositHistory.ts +++ b/src/tools/binance-sub-account/getSubAccountDepositHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-sub-account/getSubAccountDepositHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js" +import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountGetDepositHistory(server: McpServer) { server.tool( @@ -24,16 +24,16 @@ export function registerBinanceSubAccountGetDepositHistory(server: McpServer) { }, async ({ email, coin, status, startTime, endTime, limit, offset, recvWindow }) => { try { - const params: any = { email } - if (coin !== undefined) params.coin = coin - if (status !== undefined) params.status = status - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit - if (offset !== undefined) params.offset = offset - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = { email }; + if (coin !== undefined) params.coin = coin; + if (status !== undefined) params.status = status; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; + if (offset !== undefined) params.offset = offset; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await subAccountApiClient.getSubAccountDepositHistory(params) + const data = await subAccountApiClient.getSubAccountDepositHistory(params); return { content: [ @@ -42,17 +42,17 @@ export function registerBinanceSubAccountGetDepositHistory(server: McpServer) { text: `Retrieved deposit history for ${email}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to get sub-account deposit history: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/getSubAccountFuturesPositionRisk.ts b/src/tools/binance-sub-account/getSubAccountFuturesPositionRisk.ts index 9c04bc93..126807e3 100644 --- a/src/tools/binance-sub-account/getSubAccountFuturesPositionRisk.ts +++ b/src/tools/binance-sub-account/getSubAccountFuturesPositionRisk.ts @@ -1,9 +1,9 @@ // src/tools/binance-sub-account/getSubAccountFuturesPositionRisk.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js" +import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountGetFuturesPositionRisk(server: McpServer) { server.tool( @@ -19,11 +19,11 @@ export function registerBinanceSubAccountGetFuturesPositionRisk(server: McpServe }, async ({ email, futuresType, recvWindow }) => { try { - const params: any = { email } - if (futuresType !== undefined) params.futuresType = futuresType - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = { email }; + if (futuresType !== undefined) params.futuresType = futuresType; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await subAccountApiClient.getSubAccountFuturesPositionRisk(params) + const data = await subAccountApiClient.getSubAccountFuturesPositionRisk(params); return { content: [ @@ -32,9 +32,9 @@ export function registerBinanceSubAccountGetFuturesPositionRisk(server: McpServe text: `Retrieved futures position risk for ${email}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -44,8 +44,8 @@ export function registerBinanceSubAccountGetFuturesPositionRisk(server: McpServe }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/getSubAccountFuturesSummary.ts b/src/tools/binance-sub-account/getSubAccountFuturesSummary.ts index 73299a95..e10638b4 100644 --- a/src/tools/binance-sub-account/getSubAccountFuturesSummary.ts +++ b/src/tools/binance-sub-account/getSubAccountFuturesSummary.ts @@ -1,9 +1,9 @@ // src/tools/binance-sub-account/getSubAccountFuturesSummary.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js" +import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountGetFuturesSummary(server: McpServer) { server.tool( @@ -15,11 +15,11 @@ export function registerBinanceSubAccountGetFuturesSummary(server: McpServer) { }, async ({ email, recvWindow }) => { try { - const params: any = {} - if (email !== undefined) params.email = email - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (email !== undefined) params.email = email; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await subAccountApiClient.getSubAccountFuturesSummary(params) + const data = await subAccountApiClient.getSubAccountFuturesSummary(params); return { content: [ @@ -28,17 +28,17 @@ export function registerBinanceSubAccountGetFuturesSummary(server: McpServer) { text: `Retrieved sub-account futures summary. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to get sub-account futures summary: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/getSubAccountList.ts b/src/tools/binance-sub-account/getSubAccountList.ts index 5ac5b8ad..aa55a038 100644 --- a/src/tools/binance-sub-account/getSubAccountList.ts +++ b/src/tools/binance-sub-account/getSubAccountList.ts @@ -1,9 +1,9 @@ // src/tools/binance-sub-account/getSubAccountList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js" +import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountGetList(server: McpServer) { server.tool( @@ -18,14 +18,14 @@ export function registerBinanceSubAccountGetList(server: McpServer) { }, async ({ email, isFreeze, page, limit, recvWindow }) => { try { - const params: any = {} - if (email !== undefined) params.email = email - if (isFreeze !== undefined) params.isFreeze = isFreeze - if (page !== undefined) params.page = page - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (email !== undefined) params.email = email; + if (isFreeze !== undefined) params.isFreeze = isFreeze; + if (page !== undefined) params.page = page; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await subAccountApiClient.getSubAccountList(params) + const data = await subAccountApiClient.getSubAccountList(params); return { content: [ @@ -34,15 +34,15 @@ export function registerBinanceSubAccountGetList(server: McpServer) { text: `Retrieved sub-account list. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get sub-account list: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/getSubAccountMarginSummary.ts b/src/tools/binance-sub-account/getSubAccountMarginSummary.ts index 9f2f9e9f..f3e303ce 100644 --- a/src/tools/binance-sub-account/getSubAccountMarginSummary.ts +++ b/src/tools/binance-sub-account/getSubAccountMarginSummary.ts @@ -1,9 +1,9 @@ // src/tools/binance-sub-account/getSubAccountMarginSummary.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js" +import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountGetMarginSummary(server: McpServer) { server.tool( @@ -15,11 +15,11 @@ export function registerBinanceSubAccountGetMarginSummary(server: McpServer) { }, async ({ email, recvWindow }) => { try { - const params: any = {} - if (email !== undefined) params.email = email - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (email !== undefined) params.email = email; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await subAccountApiClient.getSubAccountMarginSummary(params) + const data = await subAccountApiClient.getSubAccountMarginSummary(params); return { content: [ @@ -28,17 +28,17 @@ export function registerBinanceSubAccountGetMarginSummary(server: McpServer) { text: `Retrieved sub-account margin summary. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to get sub-account margin summary: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/getSubAccountSpotSummary.ts b/src/tools/binance-sub-account/getSubAccountSpotSummary.ts index 0df399e7..e99e97e8 100644 --- a/src/tools/binance-sub-account/getSubAccountSpotSummary.ts +++ b/src/tools/binance-sub-account/getSubAccountSpotSummary.ts @@ -1,9 +1,9 @@ // src/tools/binance-sub-account/getSubAccountSpotSummary.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js" +import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountGetSpotSummary(server: McpServer) { server.tool( @@ -20,13 +20,13 @@ export function registerBinanceSubAccountGetSpotSummary(server: McpServer) { }, async ({ email, page, size, recvWindow }) => { try { - const params: any = {} - if (email !== undefined) params.email = email - if (page !== undefined) params.page = page - if (size !== undefined) params.size = size - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (email !== undefined) params.email = email; + if (page !== undefined) params.page = page; + if (size !== undefined) params.size = size; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await subAccountApiClient.getSubAccountSpotSummary(params) + const data = await subAccountApiClient.getSubAccountSpotSummary(params); return { content: [ @@ -35,17 +35,17 @@ export function registerBinanceSubAccountGetSpotSummary(server: McpServer) { text: `Retrieved sub-account spot summary. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to get sub-account spot summary: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/getSubAccountStatus.ts b/src/tools/binance-sub-account/getSubAccountStatus.ts index dd493ce1..bd04800d 100644 --- a/src/tools/binance-sub-account/getSubAccountStatus.ts +++ b/src/tools/binance-sub-account/getSubAccountStatus.ts @@ -1,9 +1,9 @@ // src/tools/binance-sub-account/getSubAccountStatus.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js" +import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountGetStatus(server: McpServer) { server.tool( @@ -15,11 +15,11 @@ export function registerBinanceSubAccountGetStatus(server: McpServer) { }, async ({ email, recvWindow }) => { try { - const params: any = {} - if (email !== undefined) params.email = email - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (email !== undefined) params.email = email; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await subAccountApiClient.getSubAccountStatus(params) + const data = await subAccountApiClient.getSubAccountStatus(params); return { content: [ @@ -28,15 +28,15 @@ export function registerBinanceSubAccountGetStatus(server: McpServer) { text: `Retrieved sub-account status. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get sub-account status: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/getSubAccountTransferHistory.ts b/src/tools/binance-sub-account/getSubAccountTransferHistory.ts index c4b81bdd..186934a2 100644 --- a/src/tools/binance-sub-account/getSubAccountTransferHistory.ts +++ b/src/tools/binance-sub-account/getSubAccountTransferHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-sub-account/getSubAccountTransferHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js" +import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountGetTransferHistory(server: McpServer) { server.tool( @@ -19,15 +19,15 @@ export function registerBinanceSubAccountGetTransferHistory(server: McpServer) { }, async ({ asset, type, startTime, endTime, limit, recvWindow }) => { try { - const params: any = {} - if (asset !== undefined) params.asset = asset - if (type !== undefined) params.type = type - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (asset !== undefined) params.asset = asset; + if (type !== undefined) params.type = type; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await subAccountApiClient.getSubAccountTransferHistory(params) + const data = await subAccountApiClient.getSubAccountTransferHistory(params); return { content: [ @@ -36,17 +36,17 @@ export function registerBinanceSubAccountGetTransferHistory(server: McpServer) { text: `Retrieved sub-account transfer history. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to get sub-account transfer history: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/getUniversalTransferHistory.ts b/src/tools/binance-sub-account/getUniversalTransferHistory.ts index 7cff1cf3..b9200bc3 100644 --- a/src/tools/binance-sub-account/getUniversalTransferHistory.ts +++ b/src/tools/binance-sub-account/getUniversalTransferHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-sub-account/getUniversalTransferHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js" +import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountGetUniversalTransferHistory(server: McpServer) { server.tool( @@ -20,16 +20,16 @@ export function registerBinanceSubAccountGetUniversalTransferHistory(server: Mcp }, async ({ fromEmail, toEmail, startTime, endTime, page, limit, recvWindow }) => { try { - const params: any = {} - if (fromEmail !== undefined) params.fromEmail = fromEmail - if (toEmail !== undefined) params.toEmail = toEmail - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (page !== undefined) params.page = page - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (fromEmail !== undefined) params.fromEmail = fromEmail; + if (toEmail !== undefined) params.toEmail = toEmail; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (page !== undefined) params.page = page; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await subAccountApiClient.getSubAccountUniversalTransferHistory(params) + const data = await subAccountApiClient.getSubAccountUniversalTransferHistory(params); return { content: [ @@ -38,17 +38,17 @@ export function registerBinanceSubAccountGetUniversalTransferHistory(server: Mcp text: `Retrieved universal transfer history. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to get universal transfer history: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/index.ts b/src/tools/binance-sub-account/index.ts index 658a89bd..22fbbb05 100644 --- a/src/tools/binance-sub-account/index.ts +++ b/src/tools/binance-sub-account/index.ts @@ -1,59 +1,59 @@ // src/tools/binance-sub-account/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceSubAccountCreateApiKey } from "./createApiKey.js" -import { registerBinanceSubAccountCreateVirtual } from "./createVirtualSubAccount.js" -import { registerBinanceSubAccountDeleteApiKey } from "./deleteApiKey.js" -import { registerBinanceSubAccountEnableFutures } from "./enableFutures.js" -import { registerBinanceSubAccountEnableMargin } from "./enableMargin.js" -import { registerBinanceSubAccountGetApiKeyIpRestriction } from "./getApiKeyIpRestriction.js" -import { registerBinanceSubAccountGetAssets } from "./getSubAccountAssets.js" -import { registerBinanceSubAccountGetDepositAddress } from "./getSubAccountDepositAddress.js" -import { registerBinanceSubAccountGetDepositHistory } from "./getSubAccountDepositHistory.js" -import { registerBinanceSubAccountGetFuturesPositionRisk } from "./getSubAccountFuturesPositionRisk.js" -import { registerBinanceSubAccountGetFuturesSummary } from "./getSubAccountFuturesSummary.js" -import { registerBinanceSubAccountGetList } from "./getSubAccountList.js" -import { registerBinanceSubAccountGetMarginSummary } from "./getSubAccountMarginSummary.js" -import { registerBinanceSubAccountGetSpotSummary } from "./getSubAccountSpotSummary.js" -import { registerBinanceSubAccountGetStatus } from "./getSubAccountStatus.js" -import { registerBinanceSubAccountGetTransferHistory } from "./getSubAccountTransferHistory.js" -import { registerBinanceSubAccountGetUniversalTransferHistory } from "./getUniversalTransferHistory.js" -import { registerBinanceSubAccountTransferToMaster } from "./transferToMaster.js" -import { registerBinanceSubAccountTransferToSub } from "./transferToSubAccount.js" -import { registerBinanceSubAccountUniversalTransfer } from "./universalTransfer.js" -import { registerBinanceSubAccountUpdateIpRestriction } from "./updateIpRestriction.js" +import { registerBinanceSubAccountCreateApiKey } from "./createApiKey.js"; +import { registerBinanceSubAccountCreateVirtual } from "./createVirtualSubAccount.js"; +import { registerBinanceSubAccountDeleteApiKey } from "./deleteApiKey.js"; +import { registerBinanceSubAccountEnableFutures } from "./enableFutures.js"; +import { registerBinanceSubAccountEnableMargin } from "./enableMargin.js"; +import { registerBinanceSubAccountGetApiKeyIpRestriction } from "./getApiKeyIpRestriction.js"; +import { registerBinanceSubAccountGetAssets } from "./getSubAccountAssets.js"; +import { registerBinanceSubAccountGetDepositAddress } from "./getSubAccountDepositAddress.js"; +import { registerBinanceSubAccountGetDepositHistory } from "./getSubAccountDepositHistory.js"; +import { registerBinanceSubAccountGetFuturesPositionRisk } from "./getSubAccountFuturesPositionRisk.js"; +import { registerBinanceSubAccountGetFuturesSummary } from "./getSubAccountFuturesSummary.js"; +import { registerBinanceSubAccountGetList } from "./getSubAccountList.js"; +import { registerBinanceSubAccountGetMarginSummary } from "./getSubAccountMarginSummary.js"; +import { registerBinanceSubAccountGetSpotSummary } from "./getSubAccountSpotSummary.js"; +import { registerBinanceSubAccountGetStatus } from "./getSubAccountStatus.js"; +import { registerBinanceSubAccountGetTransferHistory } from "./getSubAccountTransferHistory.js"; +import { registerBinanceSubAccountGetUniversalTransferHistory } from "./getUniversalTransferHistory.js"; +import { registerBinanceSubAccountTransferToMaster } from "./transferToMaster.js"; +import { registerBinanceSubAccountTransferToSub } from "./transferToSubAccount.js"; +import { registerBinanceSubAccountUniversalTransfer } from "./universalTransfer.js"; +import { registerBinanceSubAccountUpdateIpRestriction } from "./updateIpRestriction.js"; export function registerBinanceSubAccountTools(server: McpServer) { // Sub-account Management - registerBinanceSubAccountCreateVirtual(server) - registerBinanceSubAccountGetList(server) - registerBinanceSubAccountGetAssets(server) - registerBinanceSubAccountGetSpotSummary(server) - registerBinanceSubAccountGetStatus(server) + registerBinanceSubAccountCreateVirtual(server); + registerBinanceSubAccountGetList(server); + registerBinanceSubAccountGetAssets(server); + registerBinanceSubAccountGetSpotSummary(server); + registerBinanceSubAccountGetStatus(server); // Margin Management - registerBinanceSubAccountEnableMargin(server) - registerBinanceSubAccountGetMarginSummary(server) + registerBinanceSubAccountEnableMargin(server); + registerBinanceSubAccountGetMarginSummary(server); // Futures Management - registerBinanceSubAccountEnableFutures(server) - registerBinanceSubAccountGetFuturesSummary(server) - registerBinanceSubAccountGetFuturesPositionRisk(server) + registerBinanceSubAccountEnableFutures(server); + registerBinanceSubAccountGetFuturesSummary(server); + registerBinanceSubAccountGetFuturesPositionRisk(server); // Transfers - registerBinanceSubAccountTransferToSub(server) - registerBinanceSubAccountTransferToMaster(server) - registerBinanceSubAccountGetTransferHistory(server) - registerBinanceSubAccountUniversalTransfer(server) - registerBinanceSubAccountGetUniversalTransferHistory(server) + registerBinanceSubAccountTransferToSub(server); + registerBinanceSubAccountTransferToMaster(server); + registerBinanceSubAccountGetTransferHistory(server); + registerBinanceSubAccountUniversalTransfer(server); + registerBinanceSubAccountGetUniversalTransferHistory(server); // Deposit - registerBinanceSubAccountGetDepositAddress(server) - registerBinanceSubAccountGetDepositHistory(server) + registerBinanceSubAccountGetDepositAddress(server); + registerBinanceSubAccountGetDepositHistory(server); // API Key Management - registerBinanceSubAccountCreateApiKey(server) - registerBinanceSubAccountDeleteApiKey(server) - registerBinanceSubAccountUpdateIpRestriction(server) - registerBinanceSubAccountGetApiKeyIpRestriction(server) + registerBinanceSubAccountCreateApiKey(server); + registerBinanceSubAccountDeleteApiKey(server); + registerBinanceSubAccountUpdateIpRestriction(server); + registerBinanceSubAccountGetApiKeyIpRestriction(server); } diff --git a/src/tools/binance-sub-account/management-api/createSubAccount.ts b/src/tools/binance-sub-account/management-api/createSubAccount.ts index 9cd4ac9a..f29b6dd3 100644 --- a/src/tools/binance-sub-account/management-api/createSubAccount.ts +++ b/src/tools/binance-sub-account/management-api/createSubAccount.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/management-api/createSubAccount.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountCreate(server: McpServer) { server.tool( @@ -28,9 +28,9 @@ export function registerBinanceSubAccountCreate(server: McpServer) { const response = await spotClient.restAPI.createVirtualSubAccount({ subAccountString: params.subAccountString, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -39,15 +39,15 @@ export function registerBinanceSubAccountCreate(server: McpServer) { text: `✅ Sub-account created successfully!\n\nEmail: ${data.email}\n\n📝 Note: The sub-account email is auto-generated. Use it for API operations and transfers.`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to create sub-account: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/management-api/enableFutures.ts b/src/tools/binance-sub-account/management-api/enableFutures.ts index f84d9aaf..439c2ae4 100644 --- a/src/tools/binance-sub-account/management-api/enableFutures.ts +++ b/src/tools/binance-sub-account/management-api/enableFutures.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/management-api/enableFutures.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountEnableFutures(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerBinanceSubAccountEnableFutures(server: McpServer) { const response = await spotClient.restAPI.enableFuturesForSubAccount({ email: params.email, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,15 +35,15 @@ export function registerBinanceSubAccountEnableFutures(server: McpServer) { text: `✅ Futures trading enabled for sub-account: ${params.email}\n\nResponse: ${JSON.stringify(data, null, 2)}\n\n⚠️ Reminder: Futures trading carries significant risk of total loss.`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to enable futures: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/management-api/enableMargin.ts b/src/tools/binance-sub-account/management-api/enableMargin.ts index 59ae5cee..b4acc9a0 100644 --- a/src/tools/binance-sub-account/management-api/enableMargin.ts +++ b/src/tools/binance-sub-account/management-api/enableMargin.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/management-api/enableMargin.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountEnableMargin(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerBinanceSubAccountEnableMargin(server: McpServer) { const response = await spotClient.restAPI.enableMarginForSubAccount({ email: params.email, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,15 +35,15 @@ export function registerBinanceSubAccountEnableMargin(server: McpServer) { text: `✅ Margin trading enabled for sub-account: ${params.email}\n\nResponse: ${JSON.stringify(data, null, 2)}\n\n⚠️ Reminder: Margin trading carries significant risk.`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to enable margin: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/management-api/getSubAccountApiPermission.ts b/src/tools/binance-sub-account/management-api/getSubAccountApiPermission.ts index f9843bba..a0445829 100644 --- a/src/tools/binance-sub-account/management-api/getSubAccountApiPermission.ts +++ b/src/tools/binance-sub-account/management-api/getSubAccountApiPermission.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/management-api/getSubAccountApiPermission.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountApiPermission(server: McpServer) { server.tool( @@ -26,9 +26,9 @@ export function registerBinanceSubAccountApiPermission(server: McpServer) { email: params.email, subAccountApiKey: params.subAccountApiKey, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -37,15 +37,15 @@ export function registerBinanceSubAccountApiPermission(server: McpServer) { text: `Sub-Account API Permissions:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get API permissions: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/management-api/getSubAccountList.ts b/src/tools/binance-sub-account/management-api/getSubAccountList.ts index 444d3bb9..bf73bbb6 100644 --- a/src/tools/binance-sub-account/management-api/getSubAccountList.ts +++ b/src/tools/binance-sub-account/management-api/getSubAccountList.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/management-api/getSubAccountList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountList(server: McpServer) { server.tool( @@ -36,9 +36,9 @@ export function registerBinanceSubAccountList(server: McpServer) { ...(params.page && { page: params.page }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -47,15 +47,15 @@ export function registerBinanceSubAccountList(server: McpServer) { text: `Sub-Account List:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get sub-account list: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/management-api/getSubAccountStatus.ts b/src/tools/binance-sub-account/management-api/getSubAccountStatus.ts index 455b60ee..c8bf7663 100644 --- a/src/tools/binance-sub-account/management-api/getSubAccountStatus.ts +++ b/src/tools/binance-sub-account/management-api/getSubAccountStatus.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/management-api/getSubAccountStatus.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountStatus(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerBinanceSubAccountStatus(server: McpServer) { const response = await spotClient.restAPI.getSubAccountStatus({ ...(params.email && { email: params.email }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,15 +35,15 @@ export function registerBinanceSubAccountStatus(server: McpServer) { text: `Sub-Account Status:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get sub-account status: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/management-api/index.ts b/src/tools/binance-sub-account/management-api/index.ts index 71a66075..3f9c70d6 100644 --- a/src/tools/binance-sub-account/management-api/index.ts +++ b/src/tools/binance-sub-account/management-api/index.ts @@ -5,20 +5,20 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/management-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceSubAccountCreate } from "./createSubAccount.js" -import { registerBinanceSubAccountEnableFutures } from "./enableFutures.js" -import { registerBinanceSubAccountEnableMargin } from "./enableMargin.js" -import { registerBinanceSubAccountApiPermission } from "./getSubAccountApiPermission.js" -import { registerBinanceSubAccountList } from "./getSubAccountList.js" -import { registerBinanceSubAccountStatus } from "./getSubAccountStatus.js" +import { registerBinanceSubAccountCreate } from "./createSubAccount.js"; +import { registerBinanceSubAccountEnableFutures } from "./enableFutures.js"; +import { registerBinanceSubAccountEnableMargin } from "./enableMargin.js"; +import { registerBinanceSubAccountApiPermission } from "./getSubAccountApiPermission.js"; +import { registerBinanceSubAccountList } from "./getSubAccountList.js"; +import { registerBinanceSubAccountStatus } from "./getSubAccountStatus.js"; export function registerBinanceSubAccountManagementTools(server: McpServer) { - registerBinanceSubAccountCreate(server) - registerBinanceSubAccountList(server) - registerBinanceSubAccountStatus(server) - registerBinanceSubAccountEnableMargin(server) - registerBinanceSubAccountEnableFutures(server) - registerBinanceSubAccountApiPermission(server) + registerBinanceSubAccountCreate(server); + registerBinanceSubAccountList(server); + registerBinanceSubAccountStatus(server); + registerBinanceSubAccountEnableMargin(server); + registerBinanceSubAccountEnableFutures(server); + registerBinanceSubAccountApiPermission(server); } diff --git a/src/tools/binance-sub-account/transfer-api/futuresTransfer.ts b/src/tools/binance-sub-account/transfer-api/futuresTransfer.ts index 350e094f..d10a66bf 100644 --- a/src/tools/binance-sub-account/transfer-api/futuresTransfer.ts +++ b/src/tools/binance-sub-account/transfer-api/futuresTransfer.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/transfer-api/futuresTransfer.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountFuturesTransfer(server: McpServer) { server.tool( @@ -32,9 +32,9 @@ export function registerBinanceSubAccountFuturesTransfer(server: McpServer) { asset: params.asset, amount: params.amount, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -43,15 +43,15 @@ export function registerBinanceSubAccountFuturesTransfer(server: McpServer) { text: `✅ Futures internal transfer successful!\n\nFrom: ${params.fromEmail}\nTo: ${params.toEmail}\nFutures Type: ${params.futuresType === "1" ? "USD-M" : "COIN-M"}\nAsset: ${params.asset}\nAmount: ${params.amount}\n\nTransaction: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to transfer: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/transfer-api/getTransferHistory.ts b/src/tools/binance-sub-account/transfer-api/getTransferHistory.ts index 578a0e3f..fdfb6df8 100644 --- a/src/tools/binance-sub-account/transfer-api/getTransferHistory.ts +++ b/src/tools/binance-sub-account/transfer-api/getTransferHistory.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/transfer-api/getTransferHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountTransferHistory(server: McpServer) { server.tool( @@ -35,9 +35,9 @@ export function registerBinanceSubAccountTransferHistory(server: McpServer) { ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -46,15 +46,15 @@ export function registerBinanceSubAccountTransferHistory(server: McpServer) { text: `Sub-Account Transfer History:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to get transfer history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/transfer-api/index.ts b/src/tools/binance-sub-account/transfer-api/index.ts index a023779d..031ffa48 100644 --- a/src/tools/binance-sub-account/transfer-api/index.ts +++ b/src/tools/binance-sub-account/transfer-api/index.ts @@ -5,18 +5,18 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/transfer-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceSubAccountFuturesTransfer } from "./futuresTransfer.js" -import { registerBinanceSubAccountTransferHistory } from "./getTransferHistory.js" -import { registerBinanceSubAccountTransferToMaster } from "./transferToMaster.js" -import { registerBinanceSubAccountTransferToSub } from "./transferToSubAccount.js" -import { registerBinanceSubAccountUniversalTransfer } from "./universalTransfer.js" +import { registerBinanceSubAccountFuturesTransfer } from "./futuresTransfer.js"; +import { registerBinanceSubAccountTransferHistory } from "./getTransferHistory.js"; +import { registerBinanceSubAccountTransferToMaster } from "./transferToMaster.js"; +import { registerBinanceSubAccountTransferToSub } from "./transferToSubAccount.js"; +import { registerBinanceSubAccountUniversalTransfer } from "./universalTransfer.js"; export function registerBinanceSubAccountTransferTools(server: McpServer) { - registerBinanceSubAccountTransferToSub(server) - registerBinanceSubAccountTransferToMaster(server) - registerBinanceSubAccountUniversalTransfer(server) - registerBinanceSubAccountTransferHistory(server) - registerBinanceSubAccountFuturesTransfer(server) + registerBinanceSubAccountTransferToSub(server); + registerBinanceSubAccountTransferToMaster(server); + registerBinanceSubAccountUniversalTransfer(server); + registerBinanceSubAccountTransferHistory(server); + registerBinanceSubAccountFuturesTransfer(server); } diff --git a/src/tools/binance-sub-account/transfer-api/transferToMaster.ts b/src/tools/binance-sub-account/transfer-api/transferToMaster.ts index 210551d3..543c4cc0 100644 --- a/src/tools/binance-sub-account/transfer-api/transferToMaster.ts +++ b/src/tools/binance-sub-account/transfer-api/transferToMaster.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/transfer-api/transferToMaster.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountTransferToMaster(server: McpServer) { server.tool( @@ -26,9 +26,9 @@ export function registerBinanceSubAccountTransferToMaster(server: McpServer) { asset: params.asset, amount: params.amount, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -37,15 +37,15 @@ export function registerBinanceSubAccountTransferToMaster(server: McpServer) { text: `✅ Transfer to master successful!\n\nAsset: ${params.asset}\nAmount: ${params.amount}\n\nTransaction: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to transfer to master: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/transfer-api/transferToSubAccount.ts b/src/tools/binance-sub-account/transfer-api/transferToSubAccount.ts index e0c8b87f..6e2791ac 100644 --- a/src/tools/binance-sub-account/transfer-api/transferToSubAccount.ts +++ b/src/tools/binance-sub-account/transfer-api/transferToSubAccount.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/transfer-api/transferToSubAccount.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountTransferToSub(server: McpServer) { server.tool( @@ -28,9 +28,9 @@ export function registerBinanceSubAccountTransferToSub(server: McpServer) { asset: params.asset, amount: params.amount, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -39,15 +39,15 @@ export function registerBinanceSubAccountTransferToSub(server: McpServer) { text: `✅ Transfer successful!\n\nTo: ${params.toEmail}\nAsset: ${params.asset}\nAmount: ${params.amount}\n\nTransaction: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to transfer: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/transfer-api/universalTransfer.ts b/src/tools/binance-sub-account/transfer-api/universalTransfer.ts index c2647e57..acb3e719 100644 --- a/src/tools/binance-sub-account/transfer-api/universalTransfer.ts +++ b/src/tools/binance-sub-account/transfer-api/universalTransfer.ts @@ -5,11 +5,11 @@ * @license Apache-2.0 */ // src/tools/binance-sub-account/transfer-api/universalTransfer.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../../../config/binanceClient.js" +import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountUniversalTransfer(server: McpServer) { server.tool( @@ -50,9 +50,9 @@ export function registerBinanceSubAccountUniversalTransfer(server: McpServer) { ...(params.clientTranId && { clientTranId: params.clientTranId }), ...(params.symbol && { symbol: params.symbol }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -61,15 +61,15 @@ export function registerBinanceSubAccountUniversalTransfer(server: McpServer) { text: `✅ Universal transfer successful!\n\nFrom: ${params.fromEmail || "Master"} (${params.fromAccountType})\nTo: ${params.toEmail || "Master"} (${params.toAccountType})\nAsset: ${params.asset}\nAmount: ${params.amount}\n\nTransaction: ${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `❌ Failed to transfer: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/transferToMaster.ts b/src/tools/binance-sub-account/transferToMaster.ts index dce01406..71c48e31 100644 --- a/src/tools/binance-sub-account/transferToMaster.ts +++ b/src/tools/binance-sub-account/transferToMaster.ts @@ -1,9 +1,9 @@ // src/tools/binance-sub-account/transferToMaster.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js" +import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountTransferToMaster(server: McpServer) { server.tool( @@ -16,10 +16,10 @@ export function registerBinanceSubAccountTransferToMaster(server: McpServer) { }, async ({ asset, amount, recvWindow }) => { try { - const params: any = { asset, amount } - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = { asset, amount }; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await subAccountApiClient.transferToMaster(params) + const data = await subAccountApiClient.transferToMaster(params); return { content: [ @@ -28,17 +28,17 @@ export function registerBinanceSubAccountTransferToMaster(server: McpServer) { text: `Transferred ${amount} ${asset} to master account. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to transfer to master account: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/transferToSubAccount.ts b/src/tools/binance-sub-account/transferToSubAccount.ts index 4e22c825..92becfec 100644 --- a/src/tools/binance-sub-account/transferToSubAccount.ts +++ b/src/tools/binance-sub-account/transferToSubAccount.ts @@ -1,9 +1,9 @@ // src/tools/binance-sub-account/transferToSubAccount.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js" +import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountTransferToSub(server: McpServer) { server.tool( @@ -17,10 +17,10 @@ export function registerBinanceSubAccountTransferToSub(server: McpServer) { }, async ({ toEmail, asset, amount, recvWindow }) => { try { - const params: any = { toEmail, asset, amount } - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = { toEmail, asset, amount }; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await subAccountApiClient.transferToSubAccount(params) + const data = await subAccountApiClient.transferToSubAccount(params); return { content: [ @@ -29,15 +29,15 @@ export function registerBinanceSubAccountTransferToSub(server: McpServer) { text: `Transferred ${amount} ${asset} to ${toEmail}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to transfer to sub-account: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/universalTransfer.ts b/src/tools/binance-sub-account/universalTransfer.ts index b167ac89..9ef25a44 100644 --- a/src/tools/binance-sub-account/universalTransfer.ts +++ b/src/tools/binance-sub-account/universalTransfer.ts @@ -1,9 +1,9 @@ // src/tools/binance-sub-account/universalTransfer.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js" +import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountUniversalTransfer(server: McpServer) { server.tool( @@ -39,13 +39,13 @@ export function registerBinanceSubAccountUniversalTransfer(server: McpServer) { recvWindow, }) => { try { - const params: any = { fromAccountType, toAccountType, asset, amount } - if (fromEmail !== undefined) params.fromEmail = fromEmail - if (toEmail !== undefined) params.toEmail = toEmail - if (symbol !== undefined) params.symbol = symbol - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = { fromAccountType, toAccountType, asset, amount }; + if (fromEmail !== undefined) params.fromEmail = fromEmail; + if (toEmail !== undefined) params.toEmail = toEmail; + if (symbol !== undefined) params.symbol = symbol; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await subAccountApiClient.subAccountUniversalTransfer(params) + const data = await subAccountApiClient.subAccountUniversalTransfer(params); return { content: [ @@ -54,17 +54,17 @@ export function registerBinanceSubAccountUniversalTransfer(server: McpServer) { text: `Universal transfer completed: ${amount} ${asset}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to execute universal transfer: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-sub-account/updateIpRestriction.ts b/src/tools/binance-sub-account/updateIpRestriction.ts index c98e520c..a2226bc5 100644 --- a/src/tools/binance-sub-account/updateIpRestriction.ts +++ b/src/tools/binance-sub-account/updateIpRestriction.ts @@ -1,9 +1,9 @@ // src/tools/binance-sub-account/updateIpRestriction.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { subAccountApiClient } from "../../config/binanceClient.js" +import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountUpdateIpRestriction(server: McpServer) { server.tool( @@ -18,11 +18,11 @@ export function registerBinanceSubAccountUpdateIpRestriction(server: McpServer) }, async ({ subAccountId, subAccountApiKey, status, ipAddress, recvWindow }) => { try { - const params: any = { subAccountId, subAccountApiKey, status } - if (ipAddress !== undefined) params.ipAddress = ipAddress - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = { subAccountId, subAccountApiKey, status }; + if (ipAddress !== undefined) params.ipAddress = ipAddress; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await subAccountApiClient.updateSubAccountApiKeyIpRestriction(params) + const data = await subAccountApiClient.updateSubAccountApiKeyIpRestriction(params); return { content: [ @@ -31,15 +31,15 @@ export function registerBinanceSubAccountUpdateIpRestriction(server: McpServer) text: `IP restriction updated for sub-account API key. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to update IP restriction: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-vip-loan/index.ts b/src/tools/binance-vip-loan/index.ts index 71d157fb..8afb223a 100644 --- a/src/tools/binance-vip-loan/index.ts +++ b/src/tools/binance-vip-loan/index.ts @@ -1,12 +1,12 @@ // src/tools/binance-vip-loan/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceVipLoanMarketApiTools } from "./market-api/index.js" -import { registerBinanceVipLoanTradeApiTools } from "./trade-api/index.js" -import { registerBinanceVipLoanUserInformationApiTools } from "./userInformation-api/index.js" +import { registerBinanceVipLoanMarketApiTools } from "./market-api/index.js"; +import { registerBinanceVipLoanTradeApiTools } from "./trade-api/index.js"; +import { registerBinanceVipLoanUserInformationApiTools } from "./userInformation-api/index.js"; export function registerBinanceVipLoanTools(server: McpServer) { - registerBinanceVipLoanMarketApiTools(server) - registerBinanceVipLoanTradeApiTools(server) - registerBinanceVipLoanUserInformationApiTools(server) + registerBinanceVipLoanMarketApiTools(server); + registerBinanceVipLoanTradeApiTools(server); + registerBinanceVipLoanUserInformationApiTools(server); } diff --git a/src/tools/binance-vip-loan/market-api/getBorrowInterestRate.ts b/src/tools/binance-vip-loan/market-api/getBorrowInterestRate.ts index bececb1b..d4c0a1c7 100644 --- a/src/tools/binance-vip-loan/market-api/getBorrowInterestRate.ts +++ b/src/tools/binance-vip-loan/market-api/getBorrowInterestRate.ts @@ -1,9 +1,9 @@ // src/tools/binance-vip-loan/market-api/getBorrowInterestRate.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { vipLoanClient } from "../../../config/binanceClient.js" +import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceGetBorrowInterestRate(server: McpServer) { server.tool( @@ -18,9 +18,9 @@ export function registerBinanceGetBorrowInterestRate(server: McpServer) { const response = await vipLoanClient.restAPI.getBorrowInterestRate({ loanCoin: params.loanCoin, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -31,9 +31,9 @@ export function registerBinanceGetBorrowInterestRate(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -43,8 +43,8 @@ export function registerBinanceGetBorrowInterestRate(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-vip-loan/market-api/getCollateralAssetData.ts b/src/tools/binance-vip-loan/market-api/getCollateralAssetData.ts index b3ac53ff..012f657a 100644 --- a/src/tools/binance-vip-loan/market-api/getCollateralAssetData.ts +++ b/src/tools/binance-vip-loan/market-api/getCollateralAssetData.ts @@ -1,9 +1,9 @@ // src/tools/binance-vip-loan/market-api/getCollateralAssetData.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { vipLoanClient } from "../../../config/binanceClient.js" +import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceGetCollateralAssetData(server: McpServer) { server.tool( @@ -18,9 +18,9 @@ export function registerBinanceGetCollateralAssetData(server: McpServer) { const response = await vipLoanClient.restAPI.getCollateralAssetData({ ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -31,9 +31,9 @@ export function registerBinanceGetCollateralAssetData(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -43,8 +43,8 @@ export function registerBinanceGetCollateralAssetData(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-vip-loan/market-api/getLoanableAssetsData.ts b/src/tools/binance-vip-loan/market-api/getLoanableAssetsData.ts index 69acff8d..f5a7c1c5 100644 --- a/src/tools/binance-vip-loan/market-api/getLoanableAssetsData.ts +++ b/src/tools/binance-vip-loan/market-api/getLoanableAssetsData.ts @@ -1,9 +1,9 @@ // src/tools/binance-vip-loan/market-api/getLoanableAssetsData.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { vipLoanClient } from "../../../config/binanceClient.js" +import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceGetLoanableAssetsData(server: McpServer) { server.tool( @@ -24,9 +24,9 @@ export function registerBinanceGetLoanableAssetsData(server: McpServer) { ...(params.loanCoin && { loanCoin: params.loanCoin }), ...(params.vipLevel && { vipLevel: params.vipLevel }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -37,9 +37,9 @@ export function registerBinanceGetLoanableAssetsData(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -49,8 +49,8 @@ export function registerBinanceGetLoanableAssetsData(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-vip-loan/market-api/index.ts b/src/tools/binance-vip-loan/market-api/index.ts index ffc74390..5ee3c97f 100644 --- a/src/tools/binance-vip-loan/market-api/index.ts +++ b/src/tools/binance-vip-loan/market-api/index.ts @@ -1,12 +1,12 @@ // src/tools/binance-vip-loan/market-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceGetBorrowInterestRate } from "./getBorrowInterestRate.js" -import { registerBinanceGetCollateralAssetData } from "./getCollateralAssetData.js" -import { registerBinanceGetLoanableAssetsData } from "./getLoanableAssetsData.js" +import { registerBinanceGetBorrowInterestRate } from "./getBorrowInterestRate.js"; +import { registerBinanceGetCollateralAssetData } from "./getCollateralAssetData.js"; +import { registerBinanceGetLoanableAssetsData } from "./getLoanableAssetsData.js"; export function registerBinanceVipLoanMarketApiTools(server: McpServer) { - registerBinanceGetBorrowInterestRate(server) - registerBinanceGetCollateralAssetData(server) - registerBinanceGetLoanableAssetsData(server) + registerBinanceGetBorrowInterestRate(server); + registerBinanceGetCollateralAssetData(server); + registerBinanceGetLoanableAssetsData(server); } diff --git a/src/tools/binance-vip-loan/trade-api/index.ts b/src/tools/binance-vip-loan/trade-api/index.ts index 85a97036..95c9cb6c 100644 --- a/src/tools/binance-vip-loan/trade-api/index.ts +++ b/src/tools/binance-vip-loan/trade-api/index.ts @@ -1,12 +1,12 @@ // src/tools/binance-vip-loan/trade-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceVipLoanBorrow } from "./vipLoanBorrow.js" -import { registerBinanceVipLoanRenew } from "./vipLoanRenew.js" -import { registerBinanceVipLoanRepay } from "./vipLoanRepay.js" +import { registerBinanceVipLoanBorrow } from "./vipLoanBorrow.js"; +import { registerBinanceVipLoanRenew } from "./vipLoanRenew.js"; +import { registerBinanceVipLoanRepay } from "./vipLoanRepay.js"; export function registerBinanceVipLoanTradeApiTools(server: McpServer) { - registerBinanceVipLoanRenew(server) - registerBinanceVipLoanRepay(server) - registerBinanceVipLoanBorrow(server) + registerBinanceVipLoanRenew(server); + registerBinanceVipLoanRepay(server); + registerBinanceVipLoanBorrow(server); } diff --git a/src/tools/binance-vip-loan/trade-api/vipLoanBorrow.ts b/src/tools/binance-vip-loan/trade-api/vipLoanBorrow.ts index 032e83c4..d47f03de 100644 --- a/src/tools/binance-vip-loan/trade-api/vipLoanBorrow.ts +++ b/src/tools/binance-vip-loan/trade-api/vipLoanBorrow.ts @@ -1,9 +1,9 @@ // src/tools/binance-vip-loan/trade-api/vipLoanBorrow.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { vipLoanClient } from "../../../config/binanceClient.js" +import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceVipLoanBorrow(server: McpServer) { server.tool( @@ -37,9 +37,9 @@ export function registerBinanceVipLoanBorrow(server: McpServer) { isFlexibleRate: params.isFlexibleRate, ...(params.loanTerm !== undefined && { loanTerm: params.loanTerm }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -50,9 +50,9 @@ export function registerBinanceVipLoanBorrow(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -62,8 +62,8 @@ export function registerBinanceVipLoanBorrow(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-vip-loan/trade-api/vipLoanRenew.ts b/src/tools/binance-vip-loan/trade-api/vipLoanRenew.ts index 2699fbb4..7ffcc0ad 100644 --- a/src/tools/binance-vip-loan/trade-api/vipLoanRenew.ts +++ b/src/tools/binance-vip-loan/trade-api/vipLoanRenew.ts @@ -1,9 +1,9 @@ // src/tools/binance-vip-loan/trade-api/vipLoanRenew.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { vipLoanClient } from "../../../config/binanceClient.js" +import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceVipLoanRenew(server: McpServer) { server.tool( @@ -26,8 +26,8 @@ export function registerBinanceVipLoanRenew(server: McpServer) { orderId: params.orderId, loanTerm: params.loanTerm, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) - const data = await response.data() + }); + const data = await response.data(); return { content: [ @@ -36,9 +36,9 @@ export function registerBinanceVipLoanRenew(server: McpServer) { text: `Successfully renew an existing VIP loan. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -48,8 +48,8 @@ export function registerBinanceVipLoanRenew(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-vip-loan/trade-api/vipLoanRepay.ts b/src/tools/binance-vip-loan/trade-api/vipLoanRepay.ts index 8f8d7041..11fa3f64 100644 --- a/src/tools/binance-vip-loan/trade-api/vipLoanRepay.ts +++ b/src/tools/binance-vip-loan/trade-api/vipLoanRepay.ts @@ -1,9 +1,9 @@ // src/tools/binance-vip-loan/trade-api/vipLoanRepay.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { vipLoanClient } from "../../../config/binanceClient.js" +import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceVipLoanRepay(server: McpServer) { server.tool( @@ -20,9 +20,9 @@ export function registerBinanceVipLoanRepay(server: McpServer) { orderId: params.orderId, amount: params.amount, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -31,9 +31,9 @@ export function registerBinanceVipLoanRepay(server: McpServer) { text: `Successfully repay the active loan. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -43,8 +43,8 @@ export function registerBinanceVipLoanRepay(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-vip-loan/userInformation-api/checkVIPLoanCollateralAccount.ts b/src/tools/binance-vip-loan/userInformation-api/checkVIPLoanCollateralAccount.ts index ca85b235..4d3b2b01 100644 --- a/src/tools/binance-vip-loan/userInformation-api/checkVIPLoanCollateralAccount.ts +++ b/src/tools/binance-vip-loan/userInformation-api/checkVIPLoanCollateralAccount.ts @@ -1,9 +1,9 @@ // src/tools/binance-vip-loan/userInformation-api/checkVIPLoanCollateralAccount.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { vipLoanClient } from "../../../config/binanceClient.js" +import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCheckVIPLoanCollateralAccount(server: McpServer) { server.tool( @@ -22,9 +22,9 @@ export function registerBinanceCheckVIPLoanCollateralAccount(server: McpServer) collateralAccountId: params.collateralAccountId, }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -35,9 +35,9 @@ export function registerBinanceCheckVIPLoanCollateralAccount(server: McpServer) )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -47,8 +47,8 @@ export function registerBinanceCheckVIPLoanCollateralAccount(server: McpServer) }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-vip-loan/userInformation-api/getVIPLoanOngoingOrders.ts b/src/tools/binance-vip-loan/userInformation-api/getVIPLoanOngoingOrders.ts index 4effee4e..6f984328 100644 --- a/src/tools/binance-vip-loan/userInformation-api/getVIPLoanOngoingOrders.ts +++ b/src/tools/binance-vip-loan/userInformation-api/getVIPLoanOngoingOrders.ts @@ -1,9 +1,9 @@ // src/tools/binance-vip-loan/userInformation-api/getVIPLoanOngoingOrders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { vipLoanClient } from "../../../config/binanceClient.js" +import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceGetVIPLoanOngoingOrders(server: McpServer) { server.tool( @@ -42,9 +42,9 @@ export function registerBinanceGetVIPLoanOngoingOrders(server: McpServer) { ...(params.current !== undefined && { current: params.current }), ...(params.limit !== undefined && { limit: params.limit }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -55,9 +55,9 @@ export function registerBinanceGetVIPLoanOngoingOrders(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -67,8 +67,8 @@ export function registerBinanceGetVIPLoanOngoingOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-vip-loan/userInformation-api/index.ts b/src/tools/binance-vip-loan/userInformation-api/index.ts index 82cd64ab..fcffe103 100644 --- a/src/tools/binance-vip-loan/userInformation-api/index.ts +++ b/src/tools/binance-vip-loan/userInformation-api/index.ts @@ -1,12 +1,12 @@ // src/tools/binance-vip-loan/userInformation-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceCheckVIPLoanCollateralAccount } from "./checkVIPLoanCollateralAccount.js" -import { registerBinanceGetVIPLoanOngoingOrders } from "./getVIPLoanOngoingOrders.js" -import { registerBinanceQueryApplicationStatus } from "./queryApplicationStatus.js" +import { registerBinanceCheckVIPLoanCollateralAccount } from "./checkVIPLoanCollateralAccount.js"; +import { registerBinanceGetVIPLoanOngoingOrders } from "./getVIPLoanOngoingOrders.js"; +import { registerBinanceQueryApplicationStatus } from "./queryApplicationStatus.js"; export function registerBinanceVipLoanUserInformationApiTools(server: McpServer) { - registerBinanceCheckVIPLoanCollateralAccount(server) - registerBinanceGetVIPLoanOngoingOrders(server) - registerBinanceQueryApplicationStatus(server) + registerBinanceCheckVIPLoanCollateralAccount(server); + registerBinanceGetVIPLoanOngoingOrders(server); + registerBinanceQueryApplicationStatus(server); } diff --git a/src/tools/binance-vip-loan/userInformation-api/queryApplicationStatus.ts b/src/tools/binance-vip-loan/userInformation-api/queryApplicationStatus.ts index aa8a6295..9288868f 100644 --- a/src/tools/binance-vip-loan/userInformation-api/queryApplicationStatus.ts +++ b/src/tools/binance-vip-loan/userInformation-api/queryApplicationStatus.ts @@ -1,9 +1,9 @@ // src/tools/binance-vip-loan/userInformation-api/queryApplicationStatus.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { vipLoanClient } from "../../../config/binanceClient.js" +import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceQueryApplicationStatus(server: McpServer) { server.tool( @@ -26,9 +26,9 @@ export function registerBinanceQueryApplicationStatus(server: McpServer) { ...(params.current !== undefined && { current: params.current }), ...(params.limit !== undefined && { limit: params.limit }), ...(params.recvWindow !== undefined && { recvWindow: params.recvWindow }), - }) + }); - const data = await response.data() + const data = await response.data(); return { content: [ @@ -39,9 +39,9 @@ export function registerBinanceQueryApplicationStatus(server: McpServer) { )}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -51,8 +51,8 @@ export function registerBinanceQueryApplicationStatus(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/account-api/accountApiTradingStatus.ts b/src/tools/binance-wallet/account-api/accountApiTradingStatus.ts index c24c0226..d677bf15 100644 --- a/src/tools/binance-wallet/account-api/accountApiTradingStatus.ts +++ b/src/tools/binance-wallet/account-api/accountApiTradingStatus.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/account-api/accountApiTradingStatus.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletAccountApiTradingStatus(server: McpServer) { server.tool( @@ -14,11 +14,11 @@ export function registerBinanceWalletAccountApiTradingStatus(server: McpServer) }, async ({ recvWindow }) => { try { - const params: any = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.accountApiTradingStatus(params) - const data = await response.data() + const response = await walletClient.restAPI.accountApiTradingStatus(params); + const data = await response.data(); return { content: [ @@ -27,9 +27,9 @@ export function registerBinanceWalletAccountApiTradingStatus(server: McpServer) text: `Retrieved account API trading status. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -39,8 +39,8 @@ export function registerBinanceWalletAccountApiTradingStatus(server: McpServer) }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/account-api/accountInfo.ts b/src/tools/binance-wallet/account-api/accountInfo.ts index 39b964df..ce607633 100644 --- a/src/tools/binance-wallet/account-api/accountInfo.ts +++ b/src/tools/binance-wallet/account-api/accountInfo.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/account-api/accountInfo.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletAccountInfo(server: McpServer) { server.tool( @@ -14,11 +14,11 @@ export function registerBinanceWalletAccountInfo(server: McpServer) { }, async ({ recvWindow }) => { try { - const params: any = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.accountInfo(params) - const data = await response.data() + const response = await walletClient.restAPI.accountInfo(params); + const data = await response.data(); return { content: [ @@ -27,9 +27,9 @@ export function registerBinanceWalletAccountInfo(server: McpServer) { text: `Retrieved wallet account information. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -39,8 +39,8 @@ export function registerBinanceWalletAccountInfo(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/account-api/accountStatus.ts b/src/tools/binance-wallet/account-api/accountStatus.ts index 4cefe42b..fd202436 100644 --- a/src/tools/binance-wallet/account-api/accountStatus.ts +++ b/src/tools/binance-wallet/account-api/accountStatus.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/account-api/accountStatus.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletAccountStatus(server: McpServer) { server.tool( @@ -14,11 +14,11 @@ export function registerBinanceWalletAccountStatus(server: McpServer) { }, async ({ recvWindow }) => { try { - const params: any = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.accountStatus(params) - const data = await response.data() + const response = await walletClient.restAPI.accountStatus(params); + const data = await response.data(); return { content: [ @@ -27,17 +27,17 @@ export function registerBinanceWalletAccountStatus(server: McpServer) { text: `Retrieved wallet account status. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve wallet account status: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/account-api/dailyAccountSnapshot.ts b/src/tools/binance-wallet/account-api/dailyAccountSnapshot.ts index 145e3db8..39fe678f 100644 --- a/src/tools/binance-wallet/account-api/dailyAccountSnapshot.ts +++ b/src/tools/binance-wallet/account-api/dailyAccountSnapshot.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/account-api/dailyAccountSnapshot.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletDailyAccountSnapshot(server: McpServer) { server.tool( @@ -18,14 +18,14 @@ export function registerBinanceWalletDailyAccountSnapshot(server: McpServer) { }, async ({ type, startTime, endTime, limit, recvWindow }) => { try { - const params: any = { type } - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = { type }; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.dailyAccountSnapshot(params) - const data = await response.data() + const response = await walletClient.restAPI.dailyAccountSnapshot(params); + const data = await response.data(); return { content: [ @@ -34,17 +34,17 @@ export function registerBinanceWalletDailyAccountSnapshot(server: McpServer) { text: `Retrieved daily account snapshot for ${type}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve daily account snapshot: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/account-api/disableFastWithdrawSwitch.ts b/src/tools/binance-wallet/account-api/disableFastWithdrawSwitch.ts index f348aaa2..66915d9a 100644 --- a/src/tools/binance-wallet/account-api/disableFastWithdrawSwitch.ts +++ b/src/tools/binance-wallet/account-api/disableFastWithdrawSwitch.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/account-api/disableFastWithdrawSwitch.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletDisableFastWithdrawSwitch(server: McpServer) { server.tool( @@ -14,11 +14,11 @@ export function registerBinanceWalletDisableFastWithdrawSwitch(server: McpServer }, async ({ recvWindow }) => { try { - const params: any = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.disableFastWithdrawSwitch(params) - const data = await response.data() + const response = await walletClient.restAPI.disableFastWithdrawSwitch(params); + const data = await response.data(); return { content: [ @@ -27,17 +27,17 @@ export function registerBinanceWalletDisableFastWithdrawSwitch(server: McpServer text: `Disabled fast withdraw switch. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to disable fast withdraw switch: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/account-api/enableFastWithdrawSwitch.ts b/src/tools/binance-wallet/account-api/enableFastWithdrawSwitch.ts index 08b0430f..657cf9ee 100644 --- a/src/tools/binance-wallet/account-api/enableFastWithdrawSwitch.ts +++ b/src/tools/binance-wallet/account-api/enableFastWithdrawSwitch.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/account-api/enableFastWithdrawSwitch.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletEnableFastWithdrawSwitch(server: McpServer) { server.tool( @@ -14,11 +14,11 @@ export function registerBinanceWalletEnableFastWithdrawSwitch(server: McpServer) }, async ({ recvWindow }) => { try { - const params: any = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.enableFastWithdrawSwitch(params) - const data = await response.data() + const response = await walletClient.restAPI.enableFastWithdrawSwitch(params); + const data = await response.data(); return { content: [ @@ -27,17 +27,17 @@ export function registerBinanceWalletEnableFastWithdrawSwitch(server: McpServer) text: `Enabled fast withdraw switch. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to enable fast withdraw switch: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/account-api/getApiKeyPermission.ts b/src/tools/binance-wallet/account-api/getApiKeyPermission.ts index 782053fb..bda72cb5 100644 --- a/src/tools/binance-wallet/account-api/getApiKeyPermission.ts +++ b/src/tools/binance-wallet/account-api/getApiKeyPermission.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/account-api/getApiKeyPermission.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletGetApiKeyPermission(server: McpServer) { server.tool( @@ -14,11 +14,11 @@ export function registerBinanceWalletGetApiKeyPermission(server: McpServer) { }, async ({ recvWindow }) => { try { - const params: any = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.getApiKeyPermission(params) - const data = await response.data() + const response = await walletClient.restAPI.getApiKeyPermission(params); + const data = await response.data(); return { content: [ @@ -27,17 +27,17 @@ export function registerBinanceWalletGetApiKeyPermission(server: McpServer) { text: `Retrieved API key permission. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve API key permission: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/account-api/index.ts b/src/tools/binance-wallet/account-api/index.ts index c01341a4..d454e39c 100644 --- a/src/tools/binance-wallet/account-api/index.ts +++ b/src/tools/binance-wallet/account-api/index.ts @@ -1,20 +1,20 @@ // src/tools/binance-wallet/account-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceWalletAccountApiTradingStatus } from "./accountApiTradingStatus.js" -import { registerBinanceWalletAccountInfo } from "./accountInfo.js" -import { registerBinanceWalletAccountStatus } from "./accountStatus.js" -import { registerBinanceWalletDailyAccountSnapshot } from "./dailyAccountSnapshot.js" -import { registerBinanceWalletDisableFastWithdrawSwitch } from "./disableFastWithdrawSwitch.js" -import { registerBinanceWalletEnableFastWithdrawSwitch } from "./enableFastWithdrawSwitch.js" -import { registerBinanceWalletGetApiKeyPermission } from "./getApiKeyPermission.js" +import { registerBinanceWalletAccountApiTradingStatus } from "./accountApiTradingStatus.js"; +import { registerBinanceWalletAccountInfo } from "./accountInfo.js"; +import { registerBinanceWalletAccountStatus } from "./accountStatus.js"; +import { registerBinanceWalletDailyAccountSnapshot } from "./dailyAccountSnapshot.js"; +import { registerBinanceWalletDisableFastWithdrawSwitch } from "./disableFastWithdrawSwitch.js"; +import { registerBinanceWalletEnableFastWithdrawSwitch } from "./enableFastWithdrawSwitch.js"; +import { registerBinanceWalletGetApiKeyPermission } from "./getApiKeyPermission.js"; export function registerBinanceWalletAccountApiTools(server: McpServer) { - registerBinanceWalletDailyAccountSnapshot(server) - registerBinanceWalletGetApiKeyPermission(server) - registerBinanceWalletAccountInfo(server) - registerBinanceWalletAccountStatus(server) - registerBinanceWalletAccountApiTradingStatus(server) - registerBinanceWalletEnableFastWithdrawSwitch(server) - registerBinanceWalletDisableFastWithdrawSwitch(server) + registerBinanceWalletDailyAccountSnapshot(server); + registerBinanceWalletGetApiKeyPermission(server); + registerBinanceWalletAccountInfo(server); + registerBinanceWalletAccountStatus(server); + registerBinanceWalletAccountApiTradingStatus(server); + registerBinanceWalletEnableFastWithdrawSwitch(server); + registerBinanceWalletDisableFastWithdrawSwitch(server); } diff --git a/src/tools/binance-wallet/asset-api/assetDetail.ts b/src/tools/binance-wallet/asset-api/assetDetail.ts index 33f3dd6b..c49f28fa 100644 --- a/src/tools/binance-wallet/asset-api/assetDetail.ts +++ b/src/tools/binance-wallet/asset-api/assetDetail.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/asset-api/assetDetail.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletAssetDetail(server: McpServer) { server.tool( @@ -15,12 +15,12 @@ export function registerBinanceWalletAssetDetail(server: McpServer) { }, async ({ asset, recvWindow }) => { try { - const params: any = {} - if (asset !== undefined) params.asset = asset - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (asset !== undefined) params.asset = asset; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.assetDetail(params) - const data = await response.data() + const response = await walletClient.restAPI.assetDetail(params); + const data = await response.data(); return { content: [ @@ -29,15 +29,15 @@ export function registerBinanceWalletAssetDetail(server: McpServer) { text: `Retrieved asset details. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve asset details: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/asset-api/assetDividendRecord.ts b/src/tools/binance-wallet/asset-api/assetDividendRecord.ts index 038cf6aa..6944e01b 100644 --- a/src/tools/binance-wallet/asset-api/assetDividendRecord.ts +++ b/src/tools/binance-wallet/asset-api/assetDividendRecord.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/asset-api/assetDividendRecord.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletAssetDividendRecord(server: McpServer) { server.tool( @@ -18,15 +18,15 @@ export function registerBinanceWalletAssetDividendRecord(server: McpServer) { }, async ({ asset, startTime, endTime, limit, recvWindow }) => { try { - const params: any = {} - if (asset !== undefined) params.asset = asset - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (asset !== undefined) params.asset = asset; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.assetDividendRecord(params) - const data = await response.data() + const response = await walletClient.restAPI.assetDividendRecord(params); + const data = await response.data(); return { content: [ @@ -35,17 +35,17 @@ export function registerBinanceWalletAssetDividendRecord(server: McpServer) { text: `Retrieved asset dividend record. Total records: ${data.total || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve asset dividend record: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/asset-api/dustTransfer.ts b/src/tools/binance-wallet/asset-api/dustTransfer.ts index bc1ebf68..965f940e 100644 --- a/src/tools/binance-wallet/asset-api/dustTransfer.ts +++ b/src/tools/binance-wallet/asset-api/dustTransfer.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/asset-api/dustTransfer.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletDustTransfer(server: McpServer) { server.tool( @@ -15,11 +15,11 @@ export function registerBinanceWalletDustTransfer(server: McpServer) { }, async ({ asset, recvWindow }) => { try { - const params: any = { asset } - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = { asset }; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.dustTransfer(params) - const data = await response.data() + const response = await walletClient.restAPI.dustTransfer(params); + const data = await response.data(); return { content: [ @@ -28,15 +28,15 @@ export function registerBinanceWalletDustTransfer(server: McpServer) { text: `Dust transfer completed. Total BNB received: ${data.totalServiceCharge || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to process dust transfer: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/asset-api/dustlog.ts b/src/tools/binance-wallet/asset-api/dustlog.ts index f86dd243..62ede583 100644 --- a/src/tools/binance-wallet/asset-api/dustlog.ts +++ b/src/tools/binance-wallet/asset-api/dustlog.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/asset-api/dustlog.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletDustlog(server: McpServer) { server.tool( @@ -16,13 +16,13 @@ export function registerBinanceWalletDustlog(server: McpServer) { }, async ({ startTime, endTime, recvWindow }) => { try { - const params: any = {} - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.dustlog(params) - const data = await response.data() + const response = await walletClient.restAPI.dustlog(params); + const data = await response.data(); return { content: [ @@ -31,15 +31,15 @@ export function registerBinanceWalletDustlog(server: McpServer) { text: `Retrieved dust log. Total transfers: ${data.total || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve dust log: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/asset-api/fundingWallet.ts b/src/tools/binance-wallet/asset-api/fundingWallet.ts index 28ecfab4..0a11d347 100644 --- a/src/tools/binance-wallet/asset-api/fundingWallet.ts +++ b/src/tools/binance-wallet/asset-api/fundingWallet.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/asset-api/fundingWallet.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletFundingWallet(server: McpServer) { server.tool( @@ -16,13 +16,13 @@ export function registerBinanceWalletFundingWallet(server: McpServer) { }, async ({ asset, needBtcValuation, recvWindow }) => { try { - const params: any = {} - if (asset !== undefined) params.asset = asset - if (needBtcValuation !== undefined) params.needBtcValuation = needBtcValuation - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (asset !== undefined) params.asset = asset; + if (needBtcValuation !== undefined) params.needBtcValuation = needBtcValuation; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.fundingWallet(params) - const data = await response.data() + const response = await walletClient.restAPI.fundingWallet(params); + const data = await response.data(); return { content: [ @@ -31,17 +31,17 @@ export function registerBinanceWalletFundingWallet(server: McpServer) { text: `Retrieved funding wallet balance. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve funding wallet balance: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts b/src/tools/binance-wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts index aa233936..41a83029 100644 --- a/src/tools/binance-wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts +++ b/src/tools/binance-wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletGetAssetsThatCanBeConvertedIntoBnb(server: McpServer) { server.tool( @@ -14,11 +14,11 @@ export function registerBinanceWalletGetAssetsThatCanBeConvertedIntoBnb(server: }, async ({ recvWindow }) => { try { - const params: any = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.getAssetsThatCanBeConvertedIntoBnb(params) - const data = await response.data() + const response = await walletClient.restAPI.getAssetsThatCanBeConvertedIntoBnb(params); + const data = await response.data(); return { content: [ @@ -27,17 +27,17 @@ export function registerBinanceWalletGetAssetsThatCanBeConvertedIntoBnb(server: text: `Retrieved assets that can be converted to BNB. Total: ${data.details?.length || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve convertible assets: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts b/src/tools/binance-wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts index 52652ef4..90b98913 100644 --- a/src/tools/binance-wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts +++ b/src/tools/binance-wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletGetCloudMiningPaymentAndRefundHistory(server: McpServer) { server.tool( @@ -21,13 +21,13 @@ export function registerBinanceWalletGetCloudMiningPaymentAndRefundHistory(serve const params: any = { startTime, endTime, - } - if (page !== undefined) params.page = page - if (pageSize !== undefined) params.pageSize = pageSize - if (recvWindow !== undefined) params.recvWindow = recvWindow + }; + if (page !== undefined) params.page = page; + if (pageSize !== undefined) params.pageSize = pageSize; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.getCloudMiningPaymentAndRefundHistory(params) - const data = await response.data() + const response = await walletClient.restAPI.getCloudMiningPaymentAndRefundHistory(params); + const data = await response.data(); return { content: [ @@ -36,17 +36,17 @@ export function registerBinanceWalletGetCloudMiningPaymentAndRefundHistory(serve text: `Retrieved cloud mining payment and refund history. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve cloud mining history: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/asset-api/getOpenSymbolList.ts b/src/tools/binance-wallet/asset-api/getOpenSymbolList.ts index f79ebab2..0e112d72 100644 --- a/src/tools/binance-wallet/asset-api/getOpenSymbolList.ts +++ b/src/tools/binance-wallet/asset-api/getOpenSymbolList.ts @@ -1,13 +1,13 @@ // src/tools/binance-wallet/asset-api/getOpenSymbolList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletGetOpenSymbolList(server: McpServer) { server.tool("BinanceWalletGetOpenSymbolList", "Get open symbol list.", {}, async () => { try { - const response = await walletClient.restAPI.getOpenSymbolList() - const data = await response.data() + const response = await walletClient.restAPI.getOpenSymbolList(); + const data = await response.data(); return { content: [ @@ -16,14 +16,14 @@ export function registerBinanceWalletGetOpenSymbolList(server: McpServer) { text: `Retrieved open symbol list. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve open symbol list: ${errorMessage}` }], isError: true, - } + }; } - }) + }); } diff --git a/src/tools/binance-wallet/asset-api/index.ts b/src/tools/binance-wallet/asset-api/index.ts index e736e603..d06e8cd3 100644 --- a/src/tools/binance-wallet/asset-api/index.ts +++ b/src/tools/binance-wallet/asset-api/index.ts @@ -1,36 +1,36 @@ // src/tools/binance-wallet/asset-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceWalletAssetDetail } from "./assetDetail.js" -import { registerBinanceWalletAssetDividendRecord } from "./assetDividendRecord.js" -import { registerBinanceWalletDustlog } from "./dustlog.js" -import { registerBinanceWalletDustTransfer } from "./dustTransfer.js" -import { registerBinanceWalletFundingWallet } from "./fundingWallet.js" -import { registerBinanceWalletGetAssetsThatCanBeConvertedIntoBnb } from "./getAssetsThatCanBeConvertedIntoBnb.js" -import { registerBinanceWalletGetCloudMiningPaymentAndRefundHistory } from "./getCloudMiningPaymentAndRefundHistory.js" -import { registerBinanceWalletGetOpenSymbolList } from "./getOpenSymbolList.js" -import { registerBinanceWalletQueryUserDelegationHistory } from "./queryUserDelegationHistory.js" -import { registerBinanceWalletQueryUserUniversalTransferHistory } from "./queryUserUniversalTransferHistory.js" -import { registerBinanceWalletQueryUserWalletBalance } from "./queryUserWalletBalance.js" -import { registerBinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest } from "./toggleBnbBurnOnSpotTradeAndMarginInterest.js" -import { registerBinanceWalletTradeFee } from "./tradeFee.js" -import { registerBinanceWalletUserAsset } from "./userAsset.js" -import { registerBinanceWalletUserUniversalTransfer } from "./userUniversalTransfer.js" +import { registerBinanceWalletAssetDetail } from "./assetDetail.js"; +import { registerBinanceWalletAssetDividendRecord } from "./assetDividendRecord.js"; +import { registerBinanceWalletDustlog } from "./dustlog.js"; +import { registerBinanceWalletDustTransfer } from "./dustTransfer.js"; +import { registerBinanceWalletFundingWallet } from "./fundingWallet.js"; +import { registerBinanceWalletGetAssetsThatCanBeConvertedIntoBnb } from "./getAssetsThatCanBeConvertedIntoBnb.js"; +import { registerBinanceWalletGetCloudMiningPaymentAndRefundHistory } from "./getCloudMiningPaymentAndRefundHistory.js"; +import { registerBinanceWalletGetOpenSymbolList } from "./getOpenSymbolList.js"; +import { registerBinanceWalletQueryUserDelegationHistory } from "./queryUserDelegationHistory.js"; +import { registerBinanceWalletQueryUserUniversalTransferHistory } from "./queryUserUniversalTransferHistory.js"; +import { registerBinanceWalletQueryUserWalletBalance } from "./queryUserWalletBalance.js"; +import { registerBinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest } from "./toggleBnbBurnOnSpotTradeAndMarginInterest.js"; +import { registerBinanceWalletTradeFee } from "./tradeFee.js"; +import { registerBinanceWalletUserAsset } from "./userAsset.js"; +import { registerBinanceWalletUserUniversalTransfer } from "./userUniversalTransfer.js"; export function registerBinanceWalletAssetApiTools(server: McpServer) { - registerBinanceWalletUserAsset(server) - registerBinanceWalletFundingWallet(server) - registerBinanceWalletAssetDetail(server) - registerBinanceWalletTradeFee(server) - registerBinanceWalletUserUniversalTransfer(server) - registerBinanceWalletQueryUserUniversalTransferHistory(server) - registerBinanceWalletDustTransfer(server) - registerBinanceWalletDustlog(server) - registerBinanceWalletAssetDividendRecord(server) - registerBinanceWalletGetAssetsThatCanBeConvertedIntoBnb(server) - registerBinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest(server) - registerBinanceWalletGetCloudMiningPaymentAndRefundHistory(server) - registerBinanceWalletQueryUserDelegationHistory(server) - registerBinanceWalletGetOpenSymbolList(server) - registerBinanceWalletQueryUserWalletBalance(server) + registerBinanceWalletUserAsset(server); + registerBinanceWalletFundingWallet(server); + registerBinanceWalletAssetDetail(server); + registerBinanceWalletTradeFee(server); + registerBinanceWalletUserUniversalTransfer(server); + registerBinanceWalletQueryUserUniversalTransferHistory(server); + registerBinanceWalletDustTransfer(server); + registerBinanceWalletDustlog(server); + registerBinanceWalletAssetDividendRecord(server); + registerBinanceWalletGetAssetsThatCanBeConvertedIntoBnb(server); + registerBinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest(server); + registerBinanceWalletGetCloudMiningPaymentAndRefundHistory(server); + registerBinanceWalletQueryUserDelegationHistory(server); + registerBinanceWalletGetOpenSymbolList(server); + registerBinanceWalletQueryUserWalletBalance(server); } diff --git a/src/tools/binance-wallet/asset-api/queryUserDelegationHistory.ts b/src/tools/binance-wallet/asset-api/queryUserDelegationHistory.ts index 733e68ec..58d0767d 100644 --- a/src/tools/binance-wallet/asset-api/queryUserDelegationHistory.ts +++ b/src/tools/binance-wallet/asset-api/queryUserDelegationHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/asset-api/queryUserDelegationHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletQueryUserDelegationHistory(server: McpServer) { server.tool( @@ -23,13 +23,13 @@ export function registerBinanceWalletQueryUserDelegationHistory(server: McpServe email, startTime, endTime, - } - if (page !== undefined) params.page = page - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + }; + if (page !== undefined) params.page = page; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.queryUserDelegationHistory(params) - const data = await response.data() + const response = await walletClient.restAPI.queryUserDelegationHistory(params); + const data = await response.data(); return { content: [ @@ -38,17 +38,17 @@ export function registerBinanceWalletQueryUserDelegationHistory(server: McpServe text: `Retrieved user delegation history. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve user delegation history: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/asset-api/queryUserUniversalTransferHistory.ts b/src/tools/binance-wallet/asset-api/queryUserUniversalTransferHistory.ts index f8c0bb20..f5c23c09 100644 --- a/src/tools/binance-wallet/asset-api/queryUserUniversalTransferHistory.ts +++ b/src/tools/binance-wallet/asset-api/queryUserUniversalTransferHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/asset-api/queryUserUniversalTransferHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletQueryUserUniversalTransferHistory(server: McpServer) { server.tool( @@ -21,17 +21,17 @@ export function registerBinanceWalletQueryUserUniversalTransferHistory(server: M }, async ({ type, startTime, endTime, current, size, fromSymbol, toSymbol, recvWindow }) => { try { - const params: any = { type } - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (current !== undefined) params.current = current - if (size !== undefined) params.size = size - if (fromSymbol !== undefined) params.fromSymbol = fromSymbol - if (toSymbol !== undefined) params.toSymbol = toSymbol - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = { type }; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (current !== undefined) params.current = current; + if (size !== undefined) params.size = size; + if (fromSymbol !== undefined) params.fromSymbol = fromSymbol; + if (toSymbol !== undefined) params.toSymbol = toSymbol; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.queryUserUniversalTransferHistory(params) - const data = await response.data() + const response = await walletClient.restAPI.queryUserUniversalTransferHistory(params); + const data = await response.data(); return { content: [ @@ -40,9 +40,9 @@ export function registerBinanceWalletQueryUserUniversalTransferHistory(server: M text: `Retrieved universal transfer history. Total: ${data.total || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -52,8 +52,8 @@ export function registerBinanceWalletQueryUserUniversalTransferHistory(server: M }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/asset-api/queryUserWalletBalance.ts b/src/tools/binance-wallet/asset-api/queryUserWalletBalance.ts index bc5791bf..78ac08c1 100644 --- a/src/tools/binance-wallet/asset-api/queryUserWalletBalance.ts +++ b/src/tools/binance-wallet/asset-api/queryUserWalletBalance.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/asset-api/queryUserWalletBalance.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletQueryUserWalletBalance(server: McpServer) { server.tool( @@ -14,11 +14,11 @@ export function registerBinanceWalletQueryUserWalletBalance(server: McpServer) { }, async ({ recvWindow }) => { try { - const params: any = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.queryUserWalletBalance(params) - const data = await response.data() + const response = await walletClient.restAPI.queryUserWalletBalance(params); + const data = await response.data(); return { content: [ @@ -27,17 +27,17 @@ export function registerBinanceWalletQueryUserWalletBalance(server: McpServer) { text: `Retrieved user wallet balance. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve user wallet balance: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts b/src/tools/binance-wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts index adfe18ed..7407c66e 100644 --- a/src/tools/binance-wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts +++ b/src/tools/binance-wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest(server: McpServer) { server.tool( @@ -16,14 +16,14 @@ export function registerBinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest(s }, async ({ spotBNBBurn, interestBNBBurn, recvWindow }) => { try { - const params: any = {} - if (spotBNBBurn !== undefined) params.spotBNBBurn = spotBNBBurn - if (interestBNBBurn !== undefined) params.interestBNBBurn = interestBNBBurn - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (spotBNBBurn !== undefined) params.spotBNBBurn = spotBNBBurn; + if (interestBNBBurn !== undefined) params.interestBNBBurn = interestBNBBurn; + if (recvWindow !== undefined) params.recvWindow = recvWindow; const response = - await walletClient.restAPI.toggleBnbBurnOnSpotTradeAndMarginInterest(params) - const data = await response.data() + await walletClient.restAPI.toggleBnbBurnOnSpotTradeAndMarginInterest(params); + const data = await response.data(); return { content: [ @@ -32,15 +32,15 @@ export function registerBinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest(s text: `BNB burn settings updated. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to update BNB burn settings: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/asset-api/tradeFee.ts b/src/tools/binance-wallet/asset-api/tradeFee.ts index 026f68ec..7eae5189 100644 --- a/src/tools/binance-wallet/asset-api/tradeFee.ts +++ b/src/tools/binance-wallet/asset-api/tradeFee.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/asset-api/tradeFee.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletTradeFee(server: McpServer) { server.tool( @@ -15,12 +15,12 @@ export function registerBinanceWalletTradeFee(server: McpServer) { }, async ({ symbol, recvWindow }) => { try { - const params: any = {} - if (symbol !== undefined) params.symbol = symbol - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (symbol !== undefined) params.symbol = symbol; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.tradeFee(params) - const data = await response.data() + const response = await walletClient.restAPI.tradeFee(params); + const data = await response.data(); return { content: [ @@ -29,17 +29,17 @@ export function registerBinanceWalletTradeFee(server: McpServer) { text: `Retrieved trade fee information. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve trade fee information: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/asset-api/userAsset.ts b/src/tools/binance-wallet/asset-api/userAsset.ts index 69f73322..8de08a7f 100644 --- a/src/tools/binance-wallet/asset-api/userAsset.ts +++ b/src/tools/binance-wallet/asset-api/userAsset.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/asset-api/userAsset.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletUserAsset(server: McpServer) { server.tool( @@ -15,12 +15,12 @@ export function registerBinanceWalletUserAsset(server: McpServer) { }, async ({ recvWindow, needBtcValuation }) => { try { - const params: any = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow - if (needBtcValuation !== undefined) params.needBtcValuation = needBtcValuation + const params: any = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; + if (needBtcValuation !== undefined) params.needBtcValuation = needBtcValuation; - const response = await walletClient.restAPI.userAsset(params) - const data = await response.data() + const response = await walletClient.restAPI.userAsset(params); + const data = await response.data(); return { content: [ @@ -29,15 +29,15 @@ export function registerBinanceWalletUserAsset(server: McpServer) { text: `Retrieved user assets. Number of assets: ${data.length || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve user assets: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/asset-api/userUniversalTransfer.ts b/src/tools/binance-wallet/asset-api/userUniversalTransfer.ts index fc9def86..2edd3eb8 100644 --- a/src/tools/binance-wallet/asset-api/userUniversalTransfer.ts +++ b/src/tools/binance-wallet/asset-api/userUniversalTransfer.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/asset-api/userUniversalTransfer.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletUserUniversalTransfer(server: McpServer) { server.tool( @@ -23,13 +23,13 @@ export function registerBinanceWalletUserUniversalTransfer(server: McpServer) { type, asset, amount, - } - if (fromSymbol !== undefined) params.fromSymbol = fromSymbol - if (toSymbol !== undefined) params.toSymbol = toSymbol - if (recvWindow !== undefined) params.recvWindow = recvWindow + }; + if (fromSymbol !== undefined) params.fromSymbol = fromSymbol; + if (toSymbol !== undefined) params.toSymbol = toSymbol; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.userUniversalTransfer(params) - const data = await response.data() + const response = await walletClient.restAPI.userUniversalTransfer(params); + const data = await response.data(); return { content: [ @@ -38,17 +38,17 @@ export function registerBinanceWalletUserUniversalTransfer(server: McpServer) { text: `Universal transfer completed. Transfer ID: ${data.tranId}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to process universal transfer: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/capital-api/allCoinsInformation.ts b/src/tools/binance-wallet/capital-api/allCoinsInformation.ts index af4fcb32..98915cd0 100644 --- a/src/tools/binance-wallet/capital-api/allCoinsInformation.ts +++ b/src/tools/binance-wallet/capital-api/allCoinsInformation.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/capital-api/allCoinsInformation.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletAllCoinsInformation(server: McpServer) { server.tool( @@ -14,11 +14,11 @@ export function registerBinanceWalletAllCoinsInformation(server: McpServer) { }, async ({ recvWindow }) => { try { - const params: any = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.allCoinsInformation(params) - const data = await response.data() + const response = await walletClient.restAPI.allCoinsInformation(params); + const data = await response.data(); return { content: [ @@ -27,15 +27,15 @@ export function registerBinanceWalletAllCoinsInformation(server: McpServer) { text: `Retrieved information for all coins. Total coins: ${data.length || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve coin information: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/capital-api/depositAddress.ts b/src/tools/binance-wallet/capital-api/depositAddress.ts index 2899d1db..2ba1261c 100644 --- a/src/tools/binance-wallet/capital-api/depositAddress.ts +++ b/src/tools/binance-wallet/capital-api/depositAddress.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/capital-api/depositAddress.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletDepositAddress(server: McpServer) { server.tool( @@ -16,12 +16,12 @@ export function registerBinanceWalletDepositAddress(server: McpServer) { }, async ({ coin, network, recvWindow }) => { try { - const params: any = { coin } - if (network !== undefined) params.network = network - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = { coin }; + if (network !== undefined) params.network = network; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.depositAddress(params) - const data = await response.data() + const response = await walletClient.restAPI.depositAddress(params); + const data = await response.data(); return { content: [ @@ -30,15 +30,15 @@ export function registerBinanceWalletDepositAddress(server: McpServer) { text: `Retrieved deposit address for ${coin}. Address: ${data.address}${data.tag ? `, Tag: ${data.tag}` : ""}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve deposit address: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/capital-api/depositHistory.ts b/src/tools/binance-wallet/capital-api/depositHistory.ts index c46eafe0..4d8d2a00 100644 --- a/src/tools/binance-wallet/capital-api/depositHistory.ts +++ b/src/tools/binance-wallet/capital-api/depositHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/capital-api/depositHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletDepositHistory(server: McpServer) { server.tool( @@ -20,17 +20,17 @@ export function registerBinanceWalletDepositHistory(server: McpServer) { }, async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { try { - const params: any = {} - if (coin !== undefined) params.coin = coin - if (status !== undefined) params.status = status - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (offset !== undefined) params.offset = offset - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (coin !== undefined) params.coin = coin; + if (status !== undefined) params.status = status; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (offset !== undefined) params.offset = offset; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.depositHistory(params) - const data = await response.data() + const response = await walletClient.restAPI.depositHistory(params); + const data = await response.data(); return { content: [ @@ -39,15 +39,15 @@ export function registerBinanceWalletDepositHistory(server: McpServer) { text: `Retrieved deposit history. Total deposits: ${data.length || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve deposit history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/capital-api/fetchDepositAddressListWithNetwork.ts b/src/tools/binance-wallet/capital-api/fetchDepositAddressListWithNetwork.ts index e924cdbe..d3b67cd8 100644 --- a/src/tools/binance-wallet/capital-api/fetchDepositAddressListWithNetwork.ts +++ b/src/tools/binance-wallet/capital-api/fetchDepositAddressListWithNetwork.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/capital-api/fetchDepositAddressListWithNetwork.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletFetchDepositAddressListWithNetwork(server: McpServer) { server.tool( @@ -16,12 +16,12 @@ export function registerBinanceWalletFetchDepositAddressListWithNetwork(server: }, async ({ coin, network, recvWindow }) => { try { - const params: any = { coin } - if (network !== undefined) params.network = network - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = { coin }; + if (network !== undefined) params.network = network; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.fetchDepositAddressListWithNetwork(params) - const data = await response.data() + const response = await walletClient.restAPI.fetchDepositAddressListWithNetwork(params); + const data = await response.data(); return { content: [ @@ -30,17 +30,17 @@ export function registerBinanceWalletFetchDepositAddressListWithNetwork(server: text: `Retrieved deposit addresses for ${coin}. Total addresses: ${data.length || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve deposit addresses: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/capital-api/fetchWithdrawAddressList.ts b/src/tools/binance-wallet/capital-api/fetchWithdrawAddressList.ts index ae2946c2..81b1e60b 100644 --- a/src/tools/binance-wallet/capital-api/fetchWithdrawAddressList.ts +++ b/src/tools/binance-wallet/capital-api/fetchWithdrawAddressList.ts @@ -1,7 +1,7 @@ // src/tools/binance-wallet/capital-api/fetchWithdrawAddressList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletFetchWithdrawAddressList(server: McpServer) { server.tool( @@ -10,8 +10,8 @@ export function registerBinanceWalletFetchWithdrawAddressList(server: McpServer) {}, async () => { try { - const response = await walletClient.restAPI.fetchWithdrawAddressList() - const data = await response.data() + const response = await walletClient.restAPI.fetchWithdrawAddressList(); + const data = await response.data(); return { content: [ @@ -20,17 +20,17 @@ export function registerBinanceWalletFetchWithdrawAddressList(server: McpServer) text: `Retrieved withdraw address list. Total addresses: ${data || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve withdraw address list: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/capital-api/index.ts b/src/tools/binance-wallet/capital-api/index.ts index 694efb2d..f1086cd9 100644 --- a/src/tools/binance-wallet/capital-api/index.ts +++ b/src/tools/binance-wallet/capital-api/index.ts @@ -1,22 +1,22 @@ // src/tools/binance-wallet/capital-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceWalletAllCoinsInformation } from "./allCoinsInformation.js" -import { registerBinanceWalletDepositAddress } from "./depositAddress.js" -import { registerBinanceWalletDepositHistory } from "./depositHistory.js" -import { registerBinanceWalletFetchDepositAddressListWithNetwork } from "./fetchDepositAddressListWithNetwork.js" -import { registerBinanceWalletFetchWithdrawAddressList } from "./fetchWithdrawAddressList.js" -import { registerBinanceWalletOneClickArrivalDepositApply } from "./oneClickArrivalDepositApply.js" -import { registerBinanceWalletWithdraw } from "./withdraw.js" -import { registerBinanceWalletWithdrawHistory } from "./withdrawHistory.js" +import { registerBinanceWalletAllCoinsInformation } from "./allCoinsInformation.js"; +import { registerBinanceWalletDepositAddress } from "./depositAddress.js"; +import { registerBinanceWalletDepositHistory } from "./depositHistory.js"; +import { registerBinanceWalletFetchDepositAddressListWithNetwork } from "./fetchDepositAddressListWithNetwork.js"; +import { registerBinanceWalletFetchWithdrawAddressList } from "./fetchWithdrawAddressList.js"; +import { registerBinanceWalletOneClickArrivalDepositApply } from "./oneClickArrivalDepositApply.js"; +import { registerBinanceWalletWithdraw } from "./withdraw.js"; +import { registerBinanceWalletWithdrawHistory } from "./withdrawHistory.js"; export function registerBinanceWalletCapitalApiTools(server: McpServer) { - registerBinanceWalletAllCoinsInformation(server) - registerBinanceWalletDepositAddress(server) - registerBinanceWalletDepositHistory(server) - registerBinanceWalletWithdrawHistory(server) - registerBinanceWalletWithdraw(server) - registerBinanceWalletFetchDepositAddressListWithNetwork(server) - registerBinanceWalletFetchWithdrawAddressList(server) - registerBinanceWalletOneClickArrivalDepositApply(server) + registerBinanceWalletAllCoinsInformation(server); + registerBinanceWalletDepositAddress(server); + registerBinanceWalletDepositHistory(server); + registerBinanceWalletWithdrawHistory(server); + registerBinanceWalletWithdraw(server); + registerBinanceWalletFetchDepositAddressListWithNetwork(server); + registerBinanceWalletFetchWithdrawAddressList(server); + registerBinanceWalletOneClickArrivalDepositApply(server); } diff --git a/src/tools/binance-wallet/capital-api/oneClickArrivalDepositApply.ts b/src/tools/binance-wallet/capital-api/oneClickArrivalDepositApply.ts index 13e562ba..0d064983 100644 --- a/src/tools/binance-wallet/capital-api/oneClickArrivalDepositApply.ts +++ b/src/tools/binance-wallet/capital-api/oneClickArrivalDepositApply.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/capital-api/oneClickArrivalDepositApply.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletOneClickArrivalDepositApply(server: McpServer) { server.tool( @@ -15,12 +15,12 @@ export function registerBinanceWalletOneClickArrivalDepositApply(server: McpServ }, async ({ subAccountId, recvWindow }) => { try { - const params: any = {} - if (subAccountId !== undefined) params.subAccountId = subAccountId - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (subAccountId !== undefined) params.subAccountId = subAccountId; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.oneClickArrivalDepositApply(params) - const data = await response.data() + const response = await walletClient.restAPI.oneClickArrivalDepositApply(params); + const data = await response.data(); return { content: [ @@ -29,9 +29,9 @@ export function registerBinanceWalletOneClickArrivalDepositApply(server: McpServ text: `Applied for one-click arrival deposit. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -41,8 +41,8 @@ export function registerBinanceWalletOneClickArrivalDepositApply(server: McpServ }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/capital-api/withdraw.ts b/src/tools/binance-wallet/capital-api/withdraw.ts index 3619a467..5e7570d7 100644 --- a/src/tools/binance-wallet/capital-api/withdraw.ts +++ b/src/tools/binance-wallet/capital-api/withdraw.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/capital-api/withdraw.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletWithdraw(server: McpServer) { server.tool( @@ -38,17 +38,17 @@ export function registerBinanceWalletWithdraw(server: McpServer) { coin, address, amount, - } - if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId - if (network !== undefined) params.network = network - if (addressTag !== undefined) params.addressTag = addressTag - if (name !== undefined) params.name = name - if (walletType !== undefined) params.walletType = walletType - if (transactionFeeFlag !== undefined) params.transactionFeeFlag = transactionFeeFlag - if (recvWindow !== undefined) params.recvWindow = recvWindow + }; + if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId; + if (network !== undefined) params.network = network; + if (addressTag !== undefined) params.addressTag = addressTag; + if (name !== undefined) params.name = name; + if (walletType !== undefined) params.walletType = walletType; + if (transactionFeeFlag !== undefined) params.transactionFeeFlag = transactionFeeFlag; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.withdraw(params) - const data = await response.data() + const response = await walletClient.restAPI.withdraw(params); + const data = await response.data(); return { content: [ @@ -57,15 +57,15 @@ export function registerBinanceWalletWithdraw(server: McpServer) { text: `Withdraw request submitted. Withdrawal ID: ${data.id}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to submit withdraw request: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/capital-api/withdrawHistory.ts b/src/tools/binance-wallet/capital-api/withdrawHistory.ts index 63f0e692..98354666 100644 --- a/src/tools/binance-wallet/capital-api/withdrawHistory.ts +++ b/src/tools/binance-wallet/capital-api/withdrawHistory.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/capital-api/withdrawHistory.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletWithdrawHistory(server: McpServer) { server.tool( @@ -21,18 +21,18 @@ export function registerBinanceWalletWithdrawHistory(server: McpServer) { }, async ({ coin, withdrawOrderId, status, startTime, endTime, offset, limit, recvWindow }) => { try { - const params: any = {} - if (coin !== undefined) params.coin = coin - if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId - if (status !== undefined) params.status = status - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (offset !== undefined) params.offset = offset - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (coin !== undefined) params.coin = coin; + if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId; + if (status !== undefined) params.status = status; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (offset !== undefined) params.offset = offset; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.withdrawHistory(params) - const data = await response.data() + const response = await walletClient.restAPI.withdrawHistory(params); + const data = await response.data(); return { content: [ @@ -41,15 +41,15 @@ export function registerBinanceWalletWithdrawHistory(server: McpServer) { text: `Retrieved withdraw history. Total withdrawals: ${data.length || 0}. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve withdraw history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/index.ts b/src/tools/binance-wallet/index.ts index 7b1665ce..89694cce 100644 --- a/src/tools/binance-wallet/index.ts +++ b/src/tools/binance-wallet/index.ts @@ -1,25 +1,25 @@ // src/tools/binance-wallet/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceWalletAccountApiTools } from "./account-api/index.js" -import { registerBinanceWalletAssetApiTools } from "./asset-api/index.js" -import { registerBinanceWalletCapitalApiTools } from "./capital-api/index.js" -import { registerBinanceWalletOthersApiTools } from "./others-api/index.js" -import { registerBinanceWalletTravelRuleApiTools } from "./travel-rule-api/index.js" +import { registerBinanceWalletAccountApiTools } from "./account-api/index.js"; +import { registerBinanceWalletAssetApiTools } from "./asset-api/index.js"; +import { registerBinanceWalletCapitalApiTools } from "./capital-api/index.js"; +import { registerBinanceWalletOthersApiTools } from "./others-api/index.js"; +import { registerBinanceWalletTravelRuleApiTools } from "./travel-rule-api/index.js"; export function registerBinanceWalletTools(server: McpServer) { // Account API tools - registerBinanceWalletAccountApiTools(server) + registerBinanceWalletAccountApiTools(server); // Others API tools - registerBinanceWalletOthersApiTools(server) + registerBinanceWalletOthersApiTools(server); // Travel Rule API tools - registerBinanceWalletTravelRuleApiTools(server) + registerBinanceWalletTravelRuleApiTools(server); // Asset API tools - registerBinanceWalletAssetApiTools(server) + registerBinanceWalletAssetApiTools(server); // Capital API tools - registerBinanceWalletCapitalApiTools(server) + registerBinanceWalletCapitalApiTools(server); } diff --git a/src/tools/binance-wallet/others-api/getSymbolsDelistScheduleForSpot.ts b/src/tools/binance-wallet/others-api/getSymbolsDelistScheduleForSpot.ts index 8ac0a258..f549aac9 100644 --- a/src/tools/binance-wallet/others-api/getSymbolsDelistScheduleForSpot.ts +++ b/src/tools/binance-wallet/others-api/getSymbolsDelistScheduleForSpot.ts @@ -1,7 +1,7 @@ // src/tools/binance-wallet/others-api/getSymbolsDelistScheduleForSpot.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletGetSymbolsDelistScheduleForSpot(server: McpServer) { server.tool( @@ -10,8 +10,8 @@ export function registerBinanceWalletGetSymbolsDelistScheduleForSpot(server: Mcp {}, async () => { try { - const response = await walletClient.restAPI.getSymbolsDelistScheduleForSpot() - const data = await response.data() + const response = await walletClient.restAPI.getSymbolsDelistScheduleForSpot(); + const data = await response.data(); return { content: [ @@ -20,15 +20,15 @@ export function registerBinanceWalletGetSymbolsDelistScheduleForSpot(server: Mcp text: `Retrieved delist schedule for spot symbols. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve delist schedule: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/others-api/index.ts b/src/tools/binance-wallet/others-api/index.ts index 3b6520d6..e1f899e4 100644 --- a/src/tools/binance-wallet/others-api/index.ts +++ b/src/tools/binance-wallet/others-api/index.ts @@ -1,10 +1,10 @@ //src/tools/binance-wallet/others-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceWalletGetSymbolsDelistScheduleForSpot } from "./getSymbolsDelistScheduleForSpot.js" -import { registerBinanceWalletSystemStatus } from "./systemStatus.js" +import { registerBinanceWalletGetSymbolsDelistScheduleForSpot } from "./getSymbolsDelistScheduleForSpot.js"; +import { registerBinanceWalletSystemStatus } from "./systemStatus.js"; export function registerBinanceWalletOthersApiTools(server: McpServer) { - registerBinanceWalletSystemStatus(server) - registerBinanceWalletGetSymbolsDelistScheduleForSpot(server) + registerBinanceWalletSystemStatus(server); + registerBinanceWalletGetSymbolsDelistScheduleForSpot(server); } diff --git a/src/tools/binance-wallet/others-api/systemStatus.ts b/src/tools/binance-wallet/others-api/systemStatus.ts index f2bcc1b3..5121f4a9 100644 --- a/src/tools/binance-wallet/others-api/systemStatus.ts +++ b/src/tools/binance-wallet/others-api/systemStatus.ts @@ -1,13 +1,13 @@ // src/tools/binance-wallet/others-api/systemStatus.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletSystemStatus(server: McpServer) { server.tool("BinanceWalletSystemStatus", "Get Binance Wallet system status.", {}, async () => { try { - const response = await walletClient.restAPI.systemStatus() - const data = await response.data() + const response = await walletClient.restAPI.systemStatus(); + const data = await response.data(); return { content: [ @@ -16,14 +16,14 @@ export function registerBinanceWalletSystemStatus(server: McpServer) { text: `Retrieved system status. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve system status: ${errorMessage}` }], isError: true, - } + }; } - }) + }); } diff --git a/src/tools/binance-wallet/travel-rule-api/brokerWithdraw.ts b/src/tools/binance-wallet/travel-rule-api/brokerWithdraw.ts index f28f42ec..369ff418 100644 --- a/src/tools/binance-wallet/travel-rule-api/brokerWithdraw.ts +++ b/src/tools/binance-wallet/travel-rule-api/brokerWithdraw.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/travel-rule-api/brokerWithdraw.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletBrokerWithdraw(server: McpServer) { server.tool( @@ -47,14 +47,14 @@ export function registerBinanceWalletBrokerWithdraw(server: McpServer) { questionnaire, originatorPii, signature, - } - if (network !== undefined) params.network = network - if (addressTag !== undefined) params.addressTag = addressTag - if (name !== undefined) params.name = name - if (recvWindow !== undefined) params.recvWindow = recvWindow + }; + if (network !== undefined) params.network = network; + if (addressTag !== undefined) params.addressTag = addressTag; + if (name !== undefined) params.name = name; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.brokerWithdraw(params) - const data = await response.data() + const response = await walletClient.restAPI.brokerWithdraw(params); + const data = await response.data(); return { content: [ @@ -63,17 +63,17 @@ export function registerBinanceWalletBrokerWithdraw(server: McpServer) { text: `Broker withdraw request submitted. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to submit broker withdraw request: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/travel-rule-api/depositHistoryTravelRule.ts b/src/tools/binance-wallet/travel-rule-api/depositHistoryTravelRule.ts index 9e1d7ef7..90060bfd 100644 --- a/src/tools/binance-wallet/travel-rule-api/depositHistoryTravelRule.ts +++ b/src/tools/binance-wallet/travel-rule-api/depositHistoryTravelRule.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/travel-rule-api/depositHistoryTravelRule.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletDepositHistoryTravelRule(server: McpServer) { server.tool( @@ -20,17 +20,17 @@ export function registerBinanceWalletDepositHistoryTravelRule(server: McpServer) }, async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { try { - const params: any = {} - if (coin !== undefined) params.coin = coin - if (status !== undefined) params.status = status - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (offset !== undefined) params.offset = offset - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (coin !== undefined) params.coin = coin; + if (status !== undefined) params.status = status; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (offset !== undefined) params.offset = offset; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.depositHistoryTravelRule(params) - const data = await response.data() + const response = await walletClient.restAPI.depositHistoryTravelRule(params); + const data = await response.data(); return { content: [ @@ -39,15 +39,15 @@ export function registerBinanceWalletDepositHistoryTravelRule(server: McpServer) text: `Retrieved deposit history for travel rule. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve deposit history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/travel-rule-api/index.ts b/src/tools/binance-wallet/travel-rule-api/index.ts index 9e76b47d..f475165d 100644 --- a/src/tools/binance-wallet/travel-rule-api/index.ts +++ b/src/tools/binance-wallet/travel-rule-api/index.ts @@ -1,22 +1,22 @@ //src/tools/binance-wallet/travel-rule-api/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceWalletBrokerWithdraw } from "./brokerWithdraw.js" -import { registerBinanceWalletDepositHistoryTravelRule } from "./depositHistoryTravelRule.js" -import { registerBinanceWalletOnboardedVaspList } from "./onboardedVaspList.js" -import { registerBinanceWalletSubmitDepositQuestionnaire } from "./submitDepositQuestionnaire.js" -import { registerBinanceWalletSubmitDepositQuestionnaireTravelRule } from "./submitDepositQuestionnaireTravelRule.js" -import { registerBinanceWalletWithdrawHistoryV1 } from "./withdrawHistoryV1.js" -import { registerBinanceWalletWithdrawHistoryV2 } from "./withdrawHistoryV2.js" -import { registerBinanceWalletWithdrawTravelRule } from "./withdrawTravelRule.js" +import { registerBinanceWalletBrokerWithdraw } from "./brokerWithdraw.js"; +import { registerBinanceWalletDepositHistoryTravelRule } from "./depositHistoryTravelRule.js"; +import { registerBinanceWalletOnboardedVaspList } from "./onboardedVaspList.js"; +import { registerBinanceWalletSubmitDepositQuestionnaire } from "./submitDepositQuestionnaire.js"; +import { registerBinanceWalletSubmitDepositQuestionnaireTravelRule } from "./submitDepositQuestionnaireTravelRule.js"; +import { registerBinanceWalletWithdrawHistoryV1 } from "./withdrawHistoryV1.js"; +import { registerBinanceWalletWithdrawHistoryV2 } from "./withdrawHistoryV2.js"; +import { registerBinanceWalletWithdrawTravelRule } from "./withdrawTravelRule.js"; export function registerBinanceWalletTravelRuleApiTools(server: McpServer) { - registerBinanceWalletBrokerWithdraw(server) - registerBinanceWalletOnboardedVaspList(server) - registerBinanceWalletSubmitDepositQuestionnaire(server) - registerBinanceWalletWithdrawHistoryV1(server) - registerBinanceWalletDepositHistoryTravelRule(server) - registerBinanceWalletWithdrawHistoryV2(server) - registerBinanceWalletWithdrawTravelRule(server) - registerBinanceWalletSubmitDepositQuestionnaireTravelRule(server) + registerBinanceWalletBrokerWithdraw(server); + registerBinanceWalletOnboardedVaspList(server); + registerBinanceWalletSubmitDepositQuestionnaire(server); + registerBinanceWalletWithdrawHistoryV1(server); + registerBinanceWalletDepositHistoryTravelRule(server); + registerBinanceWalletWithdrawHistoryV2(server); + registerBinanceWalletWithdrawTravelRule(server); + registerBinanceWalletSubmitDepositQuestionnaireTravelRule(server); } diff --git a/src/tools/binance-wallet/travel-rule-api/onboardedVaspList.ts b/src/tools/binance-wallet/travel-rule-api/onboardedVaspList.ts index c6d74c32..a0f4e7b1 100644 --- a/src/tools/binance-wallet/travel-rule-api/onboardedVaspList.ts +++ b/src/tools/binance-wallet/travel-rule-api/onboardedVaspList.ts @@ -1,7 +1,7 @@ // src/tools/binance-wallet/travel-rule-api/onboardedVaspList.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletOnboardedVaspList(server: McpServer) { server.tool( @@ -10,8 +10,8 @@ export function registerBinanceWalletOnboardedVaspList(server: McpServer) { {}, async () => { try { - const response = await walletClient.restAPI.onboardedVaspList() - const data = await response.data() + const response = await walletClient.restAPI.onboardedVaspList(); + const data = await response.data(); return { content: [ @@ -20,17 +20,17 @@ export function registerBinanceWalletOnboardedVaspList(server: McpServer) { text: `Retrieved onboarded VASP list. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve onboarded VASP list: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaire.ts b/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaire.ts index 76a8e0ba..90fa2b14 100644 --- a/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaire.ts +++ b/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaire.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaire.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletSubmitDepositQuestionnaire(server: McpServer) { server.tool( @@ -25,11 +25,11 @@ export function registerBinanceWalletSubmitDepositQuestionnaire(server: McpServe questionnaire, beneficiaryPii, signature, - } - if (recvWindow !== undefined) params.recvWindow = recvWindow + }; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.submitDepositQuestionnaire(params) - const data = await response.data() + const response = await walletClient.restAPI.submitDepositQuestionnaire(params); + const data = await response.data(); return { content: [ @@ -38,17 +38,17 @@ export function registerBinanceWalletSubmitDepositQuestionnaire(server: McpServe text: `Submitted deposit questionnaire for broker deposit. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to submit deposit questionnaire: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts b/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts index 1160d5c9..10614549 100644 --- a/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts +++ b/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletSubmitDepositQuestionnaireTravelRule(server: McpServer) { server.tool( @@ -19,11 +19,11 @@ export function registerBinanceWalletSubmitDepositQuestionnaireTravelRule(server const params: any = { tranId, questionnaire, - } - if (recvWindow !== undefined) params.recvWindow = recvWindow + }; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.submitDepositQuestionnaireTravelRule(params) - const data = await response.data() + const response = await walletClient.restAPI.submitDepositQuestionnaireTravelRule(params); + const data = await response.data(); return { content: [ @@ -32,17 +32,17 @@ export function registerBinanceWalletSubmitDepositQuestionnaireTravelRule(server text: `Submitted deposit questionnaire for travel rule. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to submit deposit questionnaire: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV1.ts b/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV1.ts index a1beb2c2..7787b949 100644 --- a/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV1.ts +++ b/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV1.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/travel-rule-api/withdrawHistoryV1.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletWithdrawHistoryV1(server: McpServer) { server.tool( @@ -20,17 +20,17 @@ export function registerBinanceWalletWithdrawHistoryV1(server: McpServer) { }, async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { try { - const params: any = {} - if (coin !== undefined) params.coin = coin - if (status !== undefined) params.status = status - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (offset !== undefined) params.offset = offset - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (coin !== undefined) params.coin = coin; + if (status !== undefined) params.status = status; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (offset !== undefined) params.offset = offset; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.withdrawHistoryV1(params) - const data = await response.data() + const response = await walletClient.restAPI.withdrawHistoryV1(params); + const data = await response.data(); return { content: [ @@ -39,15 +39,15 @@ export function registerBinanceWalletWithdrawHistoryV1(server: McpServer) { text: `Retrieved withdraw history v1. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve withdraw history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV2.ts b/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV2.ts index fac53e5d..5370bb7d 100644 --- a/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV2.ts +++ b/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV2.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/travel-rule-api/withdrawHistoryV2.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletWithdrawHistoryV2(server: McpServer) { server.tool( @@ -20,17 +20,17 @@ export function registerBinanceWalletWithdrawHistoryV2(server: McpServer) { }, async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { try { - const params: any = {} - if (coin !== undefined) params.coin = coin - if (status !== undefined) params.status = status - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (offset !== undefined) params.offset = offset - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: any = {}; + if (coin !== undefined) params.coin = coin; + if (status !== undefined) params.status = status; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (offset !== undefined) params.offset = offset; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.withdrawHistoryV2(params) - const data = await response.data() + const response = await walletClient.restAPI.withdrawHistoryV2(params); + const data = await response.data(); return { content: [ @@ -39,15 +39,15 @@ export function registerBinanceWalletWithdrawHistoryV2(server: McpServer) { text: `Retrieved withdraw history v2. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to retrieve withdraw history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binance-wallet/travel-rule-api/withdrawTravelRule.ts b/src/tools/binance-wallet/travel-rule-api/withdrawTravelRule.ts index b9e385ec..3c13a06f 100644 --- a/src/tools/binance-wallet/travel-rule-api/withdrawTravelRule.ts +++ b/src/tools/binance-wallet/travel-rule-api/withdrawTravelRule.ts @@ -1,9 +1,9 @@ // src/tools/binance-wallet/travel-rule-api/withdrawTravelRule.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { walletClient } from "../../../config/binanceClient.js" +import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletWithdrawTravelRule(server: McpServer) { server.tool( @@ -37,15 +37,15 @@ export function registerBinanceWalletWithdrawTravelRule(server: McpServer) { address, amount, questionnaire, - } - if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId - if (network !== undefined) params.network = network - if (addressTag !== undefined) params.addressTag = addressTag - if (name !== undefined) params.name = name - if (recvWindow !== undefined) params.recvWindow = recvWindow + }; + if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId; + if (network !== undefined) params.network = network; + if (addressTag !== undefined) params.addressTag = addressTag; + if (name !== undefined) params.name = name; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.withdrawTravelRule(params) - const data = await response.data() + const response = await walletClient.restAPI.withdrawTravelRule(params); + const data = await response.data(); return { content: [ @@ -54,9 +54,9 @@ export function registerBinanceWalletWithdrawTravelRule(server: McpServer) { text: `Withdraw travel rule request submitted. Response: ${JSON.stringify(data)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ @@ -66,8 +66,8 @@ export function registerBinanceWalletWithdrawTravelRule(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binanceAccountInfo.ts b/src/tools/binanceAccountInfo.ts index 66323600..0bd86526 100644 --- a/src/tools/binanceAccountInfo.ts +++ b/src/tools/binanceAccountInfo.ts @@ -1,28 +1,28 @@ -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { AccountSnapshotType } from "@binance/connector-typescript" +import { AccountSnapshotType } from "@binance/connector-typescript"; -import { spotClient } from "../config/client.js" +import { spotClient } from "../config/client.js"; export function registerBinanceAccountInfo(server: McpServer) { server.tool("binanceAccountInfo", "check binance account info", {}, async (_params) => { try { - const accountInfo = await spotClient.accountInformation() + const accountInfo = await spotClient.accountInformation(); const accountSnapshot = await spotClient.dailyAccountSnapshot(AccountSnapshotType.SPOT, { limit: 7, - }) + }); const userAsset = await spotClient.userAsset({ needBtcValuation: true, - }) + }); if (userAsset) { const balances = userAsset.map((item) => ({ asset: item.asset, free: item.free, locked: item.locked, - })) + })); const totalAssetOfBtc = userAsset .reduce((sum, item) => sum + parseFloat(item.btcValuation || "0"), 0) .toFixed(20) - .replace(/\.?0+$/, "") + .replace(/\.?0+$/, ""); accountSnapshot.snapshotVos.push({ type: "spot", updateTime: Date.now(), @@ -30,11 +30,11 @@ export function registerBinanceAccountInfo(server: McpServer) { totalAssetOfBtc, balances, }, - }) + }); } const btcPrice = await spotClient.symbolPriceTicker({ symbol: "BTCUSDT", - }) + }); return { content: [ @@ -51,14 +51,14 @@ export function registerBinanceAccountInfo(server: McpServer) { text: `Get BTC price successfully. data: ${JSON.stringify(btcPrice)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Server failed: ${errorMessage}` }], isError: true, - } + }; } - }) + }); } diff --git a/src/tools/binanceOrderBook.ts b/src/tools/binanceOrderBook.ts index c018a0f7..6472a243 100644 --- a/src/tools/binanceOrderBook.ts +++ b/src/tools/binanceOrderBook.ts @@ -1,8 +1,8 @@ -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { spotClient } from "../config/client.js" +import { spotClient } from "../config/client.js"; export function registerBinanceOrderBook(server: McpServer) { server.tool( @@ -13,7 +13,7 @@ export function registerBinanceOrderBook(server: McpServer) { }, async ({ symbol }) => { try { - const orderBook = await spotClient.orderBook(symbol, { limit: 50 }) + const orderBook = await spotClient.orderBook(symbol, { limit: 50 }); return { content: [ @@ -22,15 +22,15 @@ export function registerBinanceOrderBook(server: McpServer) { text: `Get binance order book successfully. data: ${JSON.stringify(orderBook)}}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Server failed: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binanceSpotPlaceOrder.ts b/src/tools/binanceSpotPlaceOrder.ts index a80c62a4..4fd896e5 100644 --- a/src/tools/binanceSpotPlaceOrder.ts +++ b/src/tools/binanceSpotPlaceOrder.ts @@ -1,10 +1,10 @@ -import type { Side } from "@binance/connector-typescript" -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { Side } from "@binance/connector-typescript"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { OrderType } from "@binance/connector-typescript" -import { z } from "zod" +import { OrderType } from "@binance/connector-typescript"; +import { z } from "zod"; -import { spotClient } from "../config/client.js" +import { spotClient } from "../config/client.js"; export function registerBinanceSpotPlaceOrder(server: McpServer) { server.tool( @@ -29,7 +29,7 @@ export function registerBinanceSpotPlaceOrder(server: McpServer) { const result = await spotClient.newOrder(symbol, side as Side, OrderType.MARKET, { quantity, quoteOrderQty, - }) + }); return { content: [ @@ -38,15 +38,15 @@ export function registerBinanceSpotPlaceOrder(server: McpServer) { text: `Place a new spot TWAP order with Algo service successfully. result: ${JSON.stringify(result)}}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Server failed: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/binanceTimeWeightedAveragePriceFutureAlgo.ts b/src/tools/binanceTimeWeightedAveragePriceFutureAlgo.ts index 4424b746..776bd5a9 100644 --- a/src/tools/binanceTimeWeightedAveragePriceFutureAlgo.ts +++ b/src/tools/binanceTimeWeightedAveragePriceFutureAlgo.ts @@ -1,8 +1,8 @@ -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { algoClient } from "../config/client.js" +import { algoClient } from "../config/client.js"; export function registerBinanceTimeWeightedAveragePriceFutureAlgo(server: McpServer) { server.tool( @@ -20,14 +20,14 @@ export function registerBinanceTimeWeightedAveragePriceFutureAlgo(server: McpSer }, async ({ symbol, side, quantity, duration }) => { try { - console.log({ symbol, side, quantity, duration }) + console.log({ symbol, side, quantity, duration }); const result = await algoClient.restAPI.timeWeightedAveragePriceSpotAlgo({ symbol, side, quantity, duration, - }) + }); return { content: [ @@ -36,15 +36,15 @@ export function registerBinanceTimeWeightedAveragePriceFutureAlgo(server: McpSer text: `Place a new spot TWAP order with Algo service successfully. result: ${JSON.stringify(result)}}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Server failed: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/credit-line/index.ts b/src/tools/credit-line/index.ts index 712872d7..1c6950b0 100644 --- a/src/tools/credit-line/index.ts +++ b/src/tools/credit-line/index.ts @@ -2,11 +2,11 @@ // Binance.US Credit Line Tools // For institutional clients with credit line agreements -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { makeSignedRequest } from "../../config/binanceUsClient.js" +import { makeSignedRequest } from "../../config/binanceUsClient.js"; /** * Register all Binance.US Credit Line tools @@ -52,10 +52,10 @@ Returns comprehensive account information including: }, async (params) => { try { - const requestParams: Record = {} - if (params.recvWindow) requestParams.recvWindow = params.recvWindow + const requestParams: Record = {}; + if (params.recvWindow) requestParams.recvWindow = params.recvWindow; - const response = await makeSignedRequest("GET", "/sapi/v2/cl/account", requestParams) + const response = await makeSignedRequest("GET", "/sapi/v2/cl/account", requestParams); // Format key metrics for easy reading const summary = `Credit Line Account Summary: @@ -84,7 +84,7 @@ Contract Period: End: ${new Date(response.contractEndTime).toISOString()} Required Deposit: ${response.requiredDepositAmount} -Available to Withdraw: ${response.availableAmountToTransferOut}` +Available to Withdraw: ${response.availableAmountToTransferOut}`; return { content: [ @@ -93,17 +93,17 @@ Available to Withdraw: ${response.availableAmountToTransferOut}` text: `${summary}\n\nFull Response:\n${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get credit line account: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // GET /sapi/v1/cl/alert/history - Get Alert History (Margin Calls/Liquidations) @@ -138,26 +138,26 @@ when margin calls or liquidation warnings have occurred.`, }, async (params) => { try { - const requestParams: Record = {} - if (params.alertType) requestParams.alertType = params.alertType - if (params.startTime) requestParams.startTime = params.startTime - if (params.endTime) requestParams.endTime = params.endTime - if (params.limit) requestParams.limit = params.limit - if (params.recvWindow) requestParams.recvWindow = params.recvWindow + const requestParams: Record = {}; + if (params.alertType) requestParams.alertType = params.alertType; + if (params.startTime) requestParams.startTime = params.startTime; + if (params.endTime) requestParams.endTime = params.endTime; + if (params.limit) requestParams.limit = params.limit; + if (params.recvWindow) requestParams.recvWindow = params.recvWindow; - const response = await makeSignedRequest("GET", "/sapi/v1/cl/alert/history", requestParams) + const response = await makeSignedRequest("GET", "/sapi/v1/cl/alert/history", requestParams); // Format alerts for readability - let alertSummary = "Credit Line Alert History:\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n" + let alertSummary = "Credit Line Alert History:\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n"; if (Array.isArray(response) && response.length > 0) { response.forEach((alert: any, index: number) => { - alertSummary += `\n[${index + 1}] ${alert.alertType}\n` - alertSummary += ` Time: ${new Date(alert.alertTime).toISOString()}\n` - alertSummary += ` Current LTV: ${(parseFloat(alert.currentLTV) * 100).toFixed(2)}%\n` - alertSummary += ` Total Balance: $${alert.totalBalance}\n` - }) + alertSummary += `\n[${index + 1}] ${alert.alertType}\n`; + alertSummary += ` Time: ${new Date(alert.alertTime).toISOString()}\n`; + alertSummary += ` Current LTV: ${(parseFloat(alert.currentLTV) * 100).toFixed(2)}%\n`; + alertSummary += ` Total Balance: $${alert.totalBalance}\n`; + }); } else { - alertSummary += "No alerts found.\n" + alertSummary += "No alerts found.\n"; } return { @@ -167,17 +167,17 @@ when margin calls or liquidation warnings have occurred.`, text: `${alertSummary}\nFull Response:\n${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get alert history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // GET /sapi/v1/cl/transferHistory - Get Transfer History @@ -211,32 +211,32 @@ Use this to track deposits and withdrawals from your credit line account.`, }, async (params) => { try { - const requestParams: Record = {} - if (params.transferType) requestParams.transferType = params.transferType - if (params.asset) requestParams.asset = params.asset.toUpperCase() - if (params.startTime) requestParams.startTime = params.startTime - if (params.endTime) requestParams.endTime = params.endTime - if (params.limit) requestParams.limit = params.limit - if (params.recvWindow) requestParams.recvWindow = params.recvWindow + const requestParams: Record = {}; + if (params.transferType) requestParams.transferType = params.transferType; + if (params.asset) requestParams.asset = params.asset.toUpperCase(); + if (params.startTime) requestParams.startTime = params.startTime; + if (params.endTime) requestParams.endTime = params.endTime; + if (params.limit) requestParams.limit = params.limit; + if (params.recvWindow) requestParams.recvWindow = params.recvWindow; const response = await makeSignedRequest( "GET", "/sapi/v1/cl/transferHistory", requestParams, - ) + ); // Format transfers for readability - let transferSummary = "Credit Line Transfer History:\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n" + let transferSummary = "Credit Line Transfer History:\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n"; if (Array.isArray(response) && response.length > 0) { response.forEach((transfer: any, index: number) => { - const direction = transfer.transferType === "TRANSFER_IN" ? "→ IN" : "← OUT" - transferSummary += `\n[${index + 1}] ${direction} ${transfer.amount} ${transfer.asset}\n` - transferSummary += ` ID: ${transfer.transferId}\n` - transferSummary += ` Status: ${transfer.status}\n` - transferSummary += ` Time: ${new Date(transfer.transferTime).toISOString()}\n` - }) + const direction = transfer.transferType === "TRANSFER_IN" ? "→ IN" : "← OUT"; + transferSummary += `\n[${index + 1}] ${direction} ${transfer.amount} ${transfer.asset}\n`; + transferSummary += ` ID: ${transfer.transferId}\n`; + transferSummary += ` Status: ${transfer.status}\n`; + transferSummary += ` Time: ${new Date(transfer.transferTime).toISOString()}\n`; + }); } else { - transferSummary += "No transfers found.\n" + transferSummary += "No transfers found.\n"; } return { @@ -246,17 +246,17 @@ Use this to track deposits and withdrawals from your credit line account.`, text: `${transferSummary}\nFull Response:\n${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get transfer history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // POST /sapi/v1/cl/transfer - Execute Transfer @@ -289,12 +289,12 @@ Check availableAmountToTransferOut in binance_us_cl_account first.`, transferType: params.transferType, transferAssetType: params.transferAssetType.toUpperCase(), quantity: params.quantity, - } - if (params.recvWindow) requestParams.recvWindow = params.recvWindow + }; + if (params.recvWindow) requestParams.recvWindow = params.recvWindow; - const response = await makeSignedRequest("POST", "/sapi/v1/cl/transfer", requestParams) + const response = await makeSignedRequest("POST", "/sapi/v1/cl/transfer", requestParams); - const direction = params.transferType === "TRANSFER_IN" ? "deposited to" : "withdrawn from" + const direction = params.transferType === "TRANSFER_IN" ? "deposited to" : "withdrawn from"; return { content: [ @@ -303,15 +303,15 @@ Check availableAmountToTransferOut in binance_us_cl_account first.`, text: `Transfer completed!\n\nTransfer ID: ${response.transferId}\nStatus: ${response.status}\n${params.quantity} ${params.transferAssetType.toUpperCase()} ${direction} credit line account.\n\nFull Response:\n${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to execute transfer: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/creditline/index.ts b/src/tools/creditline/index.ts index fb846b91..a8b32315 100644 --- a/src/tools/creditline/index.ts +++ b/src/tools/creditline/index.ts @@ -2,11 +2,11 @@ // Binance.US Credit Line Tools // For institutional credit line agreements -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { makeSignedRequest } from "../../config/binanceUsClient.js" +import { makeSignedRequest } from "../../config/binanceUsClient.js"; /** * Register all Binance.US Credit Line tools @@ -72,20 +72,20 @@ Balances: try { const response = await makeSignedRequest("GET", "/sapi/v2/cl/account", { ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); // Calculate risk level based on LTV - let riskLevel = "LOW" - const currentLTV = parseFloat(response.currentLTV) - const marginCallLTV = parseFloat(response.marginCallLTV) - const liquidationLTV = parseFloat(response.liquidationLTV) + let riskLevel = "LOW"; + const currentLTV = parseFloat(response.currentLTV); + const marginCallLTV = parseFloat(response.marginCallLTV); + const liquidationLTV = parseFloat(response.liquidationLTV); if (currentLTV >= liquidationLTV) { - riskLevel = "CRITICAL - LIQUIDATION IMMINENT" + riskLevel = "CRITICAL - LIQUIDATION IMMINENT"; } else if (currentLTV >= marginCallLTV) { - riskLevel = "HIGH - MARGIN CALL" + riskLevel = "HIGH - MARGIN CALL"; } else if (currentLTV >= marginCallLTV * 0.9) { - riskLevel = "MEDIUM" + riskLevel = "MEDIUM"; } return { @@ -103,17 +103,17 @@ Balances: Full Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get credit line account: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // GET /sapi/v1/cl/alert/history - Get Alert History (Margin Call & Liquidation) @@ -171,13 +171,13 @@ Use this to: ...(params.limit && { limit: params.limit }), ...(params.alertType && { alertType: params.alertType }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const alerts = Array.isArray(response) ? response : [] - const marginCalls = alerts.filter((a: any) => a.alertType === "MARGIN_CALL").length + const alerts = Array.isArray(response) ? response : []; + const marginCalls = alerts.filter((a: any) => a.alertType === "MARGIN_CALL").length; const liquidationCalls = alerts.filter( (a: any) => a.alertType === "LIQUIDATION_CALL", - ).length + ).length; return { content: [ @@ -192,17 +192,17 @@ Use this to: Full Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get alert history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // GET /sapi/v1/cl/transferHistory - Get Transfer History @@ -261,11 +261,11 @@ Use this to: ...(params.transferType && { transferType: params.transferType }), ...(params.asset && { asset: params.asset.toUpperCase() }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const transfers = Array.isArray(response) ? response : [] - const transfersIn = transfers.filter((t: any) => t.transferType === "TRANSFER_IN").length - const transfersOut = transfers.filter((t: any) => t.transferType === "TRANSFER_OUT").length + const transfers = Array.isArray(response) ? response : []; + const transfersIn = transfers.filter((t: any) => t.transferType === "TRANSFER_IN").length; + const transfersOut = transfers.filter((t: any) => t.transferType === "TRANSFER_OUT").length; return { content: [ @@ -280,17 +280,17 @@ Use this to: Full Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get transfer history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // POST /sapi/v1/cl/transfer - Execute Transfer @@ -337,10 +337,10 @@ Response includes: transferAssetType: params.transferAssetType.toUpperCase(), quantity: params.quantity, ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); const actionText = - params.transferType === "TRANSFER_IN" ? "deposited into" : "withdrawn from" + params.transferType === "TRANSFER_IN" ? "deposited into" : "withdrawn from"; return { content: [ @@ -357,17 +357,17 @@ ${params.transferType === "TRANSFER_OUT" ? "⚠️ Your LTV ratio has increased. Full Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to execute transfer: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // GET /sapi/v1/cl/liquidation/history - Get Liquidation History @@ -416,9 +416,9 @@ Use this to: ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }) + }); - const liquidations = Array.isArray(response) ? response : [] + const liquidations = Array.isArray(response) ? response : []; return { content: [ @@ -432,15 +432,15 @@ ${liquidations.length > 0 ? "⚠️ Review your risk management strategy." : " Full Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get liquidation history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/custodial-solution/index.ts b/src/tools/custodial-solution/index.ts index ceecde3e..4bd10f9b 100644 --- a/src/tools/custodial-solution/index.ts +++ b/src/tools/custodial-solution/index.ts @@ -3,11 +3,11 @@ // ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY - Not available to regular users // Only for users with a Custody Exchange Network agreement -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { makeSignedRequest } from "../../config/binanceUsClient.js" +import { makeSignedRequest } from "../../config/binanceUsClient.js"; /** * Register all Binance.US Custodial Solution tools @@ -50,7 +50,7 @@ Each balance includes: try { const response = await makeSignedRequest("GET", "/sapi/v1/custodian/balance", { rail: rail.toUpperCase(), - }) + }); return { content: [ @@ -59,17 +59,17 @@ Each balance includes: text: `Custodial Balance Information:\n${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get custodial balance: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // GET /sapi/v1/custodian/supportedAssetList - Get Supported Assets @@ -95,7 +95,7 @@ Each asset includes: try { const response = await makeSignedRequest("GET", "/sapi/v1/custodian/supportedAssetList", { rail: rail.toUpperCase(), - }) + }); return { content: [ @@ -104,17 +104,17 @@ Each asset includes: text: `Custodial Supported Assets:\n${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get supported assets: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // POST /sapi/v1/custodian/walletTransfer - Transfer From Exchange Wallet @@ -143,14 +143,14 @@ which can then be traded or settled to your custodial partner.`, rail: rail.toUpperCase(), asset: asset.toUpperCase(), amount, - } - if (clientOrderId) params.clientOrderId = clientOrderId + }; + if (clientOrderId) params.clientOrderId = clientOrderId; const response = await makeSignedRequest( "POST", "/sapi/v1/custodian/walletTransfer", params, - ) + ); return { content: [ @@ -159,17 +159,17 @@ which can then be traded or settled to your custodial partner.`, text: `Wallet Transfer Submitted!\n\nTransfer ID: ${response.transferId}\nAsset: ${response.asset}\nAmount: ${response.amount}\nStatus: ${response.status}\n\nFull Response:\n${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to execute wallet transfer: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // POST /sapi/v1/custodian/custodianTransfer - Transfer From Custodian @@ -198,14 +198,14 @@ The actual transfer is executed by the custody partner.`, rail: rail.toUpperCase(), asset: asset.toUpperCase(), amount, - } - if (clientOrderId) params.clientOrderId = clientOrderId + }; + if (clientOrderId) params.clientOrderId = clientOrderId; const response = await makeSignedRequest( "POST", "/sapi/v1/custodian/custodianTransfer", params, - ) + ); return { content: [ @@ -214,19 +214,19 @@ The actual transfer is executed by the custody partner.`, text: `Custodian Transfer Requested!\n\nTransfer ID: ${response.transferId}\nAsset: ${response.asset}\nAmount: ${response.amount}\nStatus: ${response.status}\n\nFull Response:\n${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to request custodian transfer: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); // ===================================================================== // POST /sapi/v1/custodian/undoTransfer - Undo Transfer @@ -248,7 +248,7 @@ This reverses a previous custodian transfer by its transfer ID.`, const response = await makeSignedRequest("POST", "/sapi/v1/custodian/undoTransfer", { rail: rail.toUpperCase(), originTransferId, - }) + }); return { content: [ @@ -257,17 +257,17 @@ This reverses a previous custodian transfer by its transfer ID.`, text: `Transfer Undone!\n\nUndo Transfer ID: ${response.transferId}\nAsset: ${response.asset}\nAmount: ${response.amount}\n\nFull Response:\n${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to undo transfer: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // GET /sapi/v1/custodian/walletTransferHistory - Wallet Transfer History @@ -294,20 +294,20 @@ Returns transfer history with status, amounts, and timestamps.`, }, async ({ rail, transferId, clientOrderId, asset, startTime, endTime, page, limit }) => { try { - const params: Record = { rail: rail.toUpperCase() } - if (transferId) params.transferId = transferId - if (clientOrderId) params.clientOrderId = clientOrderId - if (asset) params.asset = asset.toUpperCase() - if (startTime) params.startTime = startTime - if (endTime) params.endTime = endTime - if (page) params.page = page - if (limit) params.limit = limit + const params: Record = { rail: rail.toUpperCase() }; + if (transferId) params.transferId = transferId; + if (clientOrderId) params.clientOrderId = clientOrderId; + if (asset) params.asset = asset.toUpperCase(); + if (startTime) params.startTime = startTime; + if (endTime) params.endTime = endTime; + if (page) params.page = page; + if (limit) params.limit = limit; const response = await makeSignedRequest( "GET", "/sapi/v1/custodian/walletTransferHistory", params, - ) + ); return { content: [ @@ -316,19 +316,19 @@ Returns transfer history with status, amounts, and timestamps.`, text: `Wallet Transfer History:\n\nTotal: ${response.total}\n\n${JSON.stringify(response.data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to get wallet transfer history: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); // ===================================================================== // GET /sapi/v1/custodian/custodianTransferHistory - Custodian Transfer History @@ -366,21 +366,21 @@ Returns transfer history with status, amounts, and timestamps.`, limit, }) => { try { - const params: Record = { rail: rail.toUpperCase() } - if (transferId) params.transferId = transferId - if (clientOrderId) params.clientOrderId = clientOrderId - if (expressTradeTransfer !== undefined) params.expressTradeTransfer = expressTradeTransfer - if (asset) params.asset = asset.toUpperCase() - if (startTime) params.startTime = startTime - if (endTime) params.endTime = endTime - if (page) params.page = page - if (limit) params.limit = limit + const params: Record = { rail: rail.toUpperCase() }; + if (transferId) params.transferId = transferId; + if (clientOrderId) params.clientOrderId = clientOrderId; + if (expressTradeTransfer !== undefined) params.expressTradeTransfer = expressTradeTransfer; + if (asset) params.asset = asset.toUpperCase(); + if (startTime) params.startTime = startTime; + if (endTime) params.endTime = endTime; + if (page) params.page = page; + if (limit) params.limit = limit; const response = await makeSignedRequest( "GET", "/sapi/v1/custodian/custodianTransferHistory", params, - ) + ); return { content: [ @@ -389,19 +389,19 @@ Returns transfer history with status, amounts, and timestamps.`, text: `Custodian Transfer History:\n\nTotal: ${response.total}\n\n${JSON.stringify(response.data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to get custodian transfer history: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); // ===================================================================== // POST /sapi/v1/custodian/settlement - Request Settlement @@ -430,10 +430,10 @@ to your custody partner's vault.`, rail: rail.toUpperCase(), asset: asset.toUpperCase(), amount, - } - if (clientOrderId) params.clientOrderId = clientOrderId + }; + if (clientOrderId) params.clientOrderId = clientOrderId; - const response = await makeSignedRequest("POST", "/sapi/v1/custodian/settlement", params) + const response = await makeSignedRequest("POST", "/sapi/v1/custodian/settlement", params); return { content: [ @@ -442,17 +442,17 @@ to your custody partner's vault.`, text: `Settlement Requested!\n\nSettlement ID: ${response.settlementId}\nAsset: ${response.asset}\nAmount: ${response.amount}\nStatus: ${response.status}\n\nFull Response:\n${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to request settlement: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // GET /sapi/v1/custodian/settlementHistory - Settlement History @@ -476,20 +476,20 @@ Returns settlement history with status, amounts, and timestamps.`, }, async ({ rail, settlementId, clientOrderId, asset, startTime, endTime, page, limit }) => { try { - const params: Record = { rail: rail.toUpperCase() } - if (settlementId) params.settlementId = settlementId - if (clientOrderId) params.clientOrderId = clientOrderId - if (asset) params.asset = asset.toUpperCase() - if (startTime) params.startTime = startTime - if (endTime) params.endTime = endTime - if (page) params.page = page - if (limit) params.limit = limit + const params: Record = { rail: rail.toUpperCase() }; + if (settlementId) params.settlementId = settlementId; + if (clientOrderId) params.clientOrderId = clientOrderId; + if (asset) params.asset = asset.toUpperCase(); + if (startTime) params.startTime = startTime; + if (endTime) params.endTime = endTime; + if (page) params.page = page; + if (limit) params.limit = limit; const response = await makeSignedRequest( "GET", "/sapi/v1/custodian/settlementHistory", params, - ) + ); return { content: [ @@ -498,15 +498,15 @@ Returns settlement history with status, amounts, and timestamps.`, text: `Settlement History:\n\nTotal: ${response.total}\n\n${JSON.stringify(response.data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get settlement history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/custodial/index.ts b/src/tools/custodial/index.ts index 4b73cc75..7eec11fa 100644 --- a/src/tools/custodial/index.ts +++ b/src/tools/custodial/index.ts @@ -2,16 +2,16 @@ // Binance.US Custodial Solution Tools // For institutional custody partners (e.g., Anchorage, BitGo) -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { makeSignedRequest } from "../../config/binanceUsClient.js" +import { makeSignedRequest } from "../../config/binanceUsClient.js"; // Common schema for rail parameter (custodial partner) const railSchema = z .string() - .describe("Custodial partner name (e.g., ANCHORAGE, BITGO). Must be uppercase.") + .describe("Custodial partner name (e.g., ANCHORAGE, BITGO). Must be uppercase."); // Order type enum const orderTypeEnum = z.enum([ @@ -22,13 +22,13 @@ const orderTypeEnum = z.enum([ "TAKE_PROFIT", "TAKE_PROFIT_LIMIT", "LIMIT_MAKER", -]) +]); // Order side enum -const orderSideEnum = z.enum(["BUY", "SELL"]) +const orderSideEnum = z.enum(["BUY", "SELL"]); // Time in force enum -const timeInForceEnum = z.enum(["GTC", "IOC", "FOK"]) +const timeInForceEnum = z.enum(["GTC", "IOC", "FOK"]); /** * Register all Binance.US Custodial Solution tools @@ -69,7 +69,7 @@ Each balance entry contains: try { const response = await makeSignedRequest("GET", "/sapi/v1/custodian/balance", { rail: params.rail.toUpperCase(), - }) + }); return { content: [ @@ -78,17 +78,17 @@ Each balance entry contains: text: `Successfully retrieved custodial balance. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get custodial balance: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // GET /sapi/v1/custodian/supportedAssetList - Get Supported Assets @@ -114,7 +114,7 @@ Each asset entry contains: try { const response = await makeSignedRequest("GET", "/sapi/v1/custodian/supportedAssetList", { rail: params.rail.toUpperCase(), - }) + }); return { content: [ @@ -123,17 +123,17 @@ Each asset entry contains: text: `Successfully retrieved supported assets. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get supported assets: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // POST /sapi/v1/custodian/walletTransfer - Transfer from Exchange Wallet @@ -170,7 +170,7 @@ Response includes: asset: params.asset.toUpperCase(), amount: params.amount, ...(params.clientOrderId && { clientOrderId: params.clientOrderId }), - }) + }); return { content: [ @@ -179,17 +179,17 @@ Response includes: text: `Wallet transfer completed. Transfer ID: ${response.transferId}, Status: ${response.status}. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to execute wallet transfer: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // POST /sapi/v1/custodian/custodianTransfer - Transfer from Custodian @@ -226,7 +226,7 @@ Response includes: asset: params.asset.toUpperCase(), amount: params.amount, ...(params.clientOrderId && { clientOrderId: params.clientOrderId }), - }) + }); return { content: [ @@ -235,19 +235,19 @@ Response includes: text: `Custodian transfer initiated. Transfer ID: ${response.transferId}, Status: ${response.status}. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to execute custodian transfer: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); // ===================================================================== // POST /sapi/v1/custodian/undoTransfer - Undo Transfer @@ -273,7 +273,7 @@ Response includes: const response = await makeSignedRequest("POST", "/sapi/v1/custodian/undoTransfer", { rail: params.rail.toUpperCase(), originTransferId: params.originTransferId, - }) + }); return { content: [ @@ -282,17 +282,17 @@ Response includes: text: `Transfer undo completed. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to undo transfer: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // GET /sapi/v1/custodian/walletTransferHistory - Wallet Transfer History @@ -341,7 +341,7 @@ status, createTime, updateTime`, ...(params.page && { page: params.page }), ...(params.limit && { limit: params.limit }), }, - ) + ); return { content: [ @@ -350,19 +350,19 @@ status, createTime, updateTime`, text: `Retrieved ${response.total} wallet transfers. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to get wallet transfer history: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); // ===================================================================== // GET /sapi/v1/custodian/custodianTransferHistory - Custodian Transfer History @@ -421,7 +421,7 @@ expressTrade flag, createTime, updateTime`, ...(params.page && { page: params.page }), ...(params.limit && { limit: params.limit }), }, - ) + ); return { content: [ @@ -430,19 +430,19 @@ expressTrade flag, createTime, updateTime`, text: `Retrieved ${response.total} custodian transfers. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to get custodian transfer history: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); // ===================================================================== // GET /sapi/v1/custodian/availableBalance - Get Available Balance @@ -463,7 +463,7 @@ Returns the balance available for placing new orders.`, const response = await makeSignedRequest("GET", "/sapi/v1/custodian/availableBalance", { rail: params.rail.toUpperCase(), ...(params.asset && { asset: params.asset.toUpperCase() }), - }) + }); return { content: [ @@ -472,17 +472,17 @@ Returns the balance available for placing new orders.`, text: `Successfully retrieved available balance. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get available balance: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // POST /sapi/v1/custodian/order - Place Custodial Order @@ -549,7 +549,7 @@ executedQty, and expressTradeFlag`, ...(params.allowExpressTrade !== undefined && { allowExpressTrade: params.allowExpressTrade, }), - }) + }); return { content: [ @@ -558,17 +558,17 @@ executedQty, and expressTradeFlag`, text: `Custodial order placed. Order ID: ${response.orderId}, Status: ${response.status}. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to place custodial order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // POST /sapi/v1/custodian/ocoOrder - Place Custodial OCO Order @@ -626,7 +626,7 @@ Response includes orderListId, orders array, and orderReports with details.`, ...(params.allowExpressTrade !== undefined && { allowExpressTrade: params.allowExpressTrade, }), - }) + }); return { content: [ @@ -635,17 +635,17 @@ Response includes orderListId, orders array, and orderReports with details.`, text: `Custodial OCO order placed. Order List ID: ${response.orderListId}, Status: ${response.listOrderStatus}. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to place custodial OCO order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // GET /sapi/v1/custodian/openOrders - Get Open Orders @@ -673,7 +673,7 @@ expressTradeFlag`, const response = await makeSignedRequest("GET", "/sapi/v1/custodian/openOrders", { rail: params.rail.toUpperCase(), ...(params.symbol && { symbol: params.symbol.toUpperCase() }), - }) + }); return { content: [ @@ -682,17 +682,17 @@ expressTradeFlag`, text: `Retrieved ${Array.isArray(response) ? response.length : 0} open orders. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get open orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // GET /sapi/v1/custodian/order - Get Order @@ -717,7 +717,7 @@ icebergQty, time, updateTime, isWorking, expressTradeFlag`, rail: params.rail.toUpperCase(), symbol: params.symbol.toUpperCase(), orderId: params.orderId, - }) + }); return { content: [ @@ -726,17 +726,17 @@ icebergQty, time, updateTime, isWorking, expressTradeFlag`, text: `Order retrieved. Status: ${response.status}. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // GET /sapi/v1/custodian/orderHistory - Get Order History @@ -778,7 +778,7 @@ executedQty, and expressTradeFlag.`, ...(params.endTime && { endTime: params.endTime }), ...(params.fromId && { fromId: params.fromId }), ...(params.limit && { limit: params.limit }), - }) + }); return { content: [ @@ -787,17 +787,17 @@ executedQty, and expressTradeFlag.`, text: `Retrieved ${Array.isArray(response) ? response.length : 0} historical orders. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get order history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // GET /sapi/v1/custodian/tradeHistory - Get Trade History @@ -838,7 +838,7 @@ isBuyer, isMaker, isBestMatch, orderId, commission, commissionAsset`, ...(params.endTime && { endTime: params.endTime }), ...(params.fromId && { fromId: params.fromId }), ...(params.limit && { limit: params.limit }), - }) + }); return { content: [ @@ -847,17 +847,17 @@ isBuyer, isMaker, isBestMatch, orderId, commission, commissionAsset`, text: `Retrieved ${Array.isArray(response) ? response.length : 0} trades. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get trade history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // DELETE /sapi/v1/custodian/cancelOrder - Cancel Order @@ -884,7 +884,7 @@ Response includes the canceled order details with status: CANCELED`, async (params) => { try { if (!params.orderId && !params.origClientOrderId) { - throw new Error("Either orderId or origClientOrderId must be provided") + throw new Error("Either orderId or origClientOrderId must be provided"); } const response = await makeSignedRequest("DELETE", "/sapi/v1/custodian/cancelOrder", { @@ -893,7 +893,7 @@ Response includes the canceled order details with status: CANCELED`, ...(params.orderId && { orderId: params.orderId }), ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), - }) + }); return { content: [ @@ -902,17 +902,17 @@ Response includes the canceled order details with status: CANCELED`, text: `Order canceled. Order ID: ${response.orderId}, Status: ${response.status}. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to cancel order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // DELETE /sapi/v1/custodian/cancelOrdersBySymbol - Cancel All Orders for Symbol @@ -939,7 +939,7 @@ Response is an array of all canceled orders.`, rail: params.rail.toUpperCase(), symbol: params.symbol.toUpperCase(), }, - ) + ); return { content: [ @@ -948,17 +948,17 @@ Response is an array of all canceled orders.`, text: `All orders canceled for ${params.symbol}. Canceled ${Array.isArray(response) ? response.length : 0} orders. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to cancel orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // DELETE /sapi/v1/custodian/cancelOcoOrder - Cancel OCO Order @@ -988,7 +988,7 @@ canceled order details.`, orderListId: params.orderListId, ...(params.listClientOrderId && { listClientOrderId: params.listClientOrderId }), ...(params.newClientOrderId && { newClientOrderId: params.newClientOrderId }), - }) + }); return { content: [ @@ -997,17 +997,17 @@ canceled order details.`, text: `OCO order canceled. List ID: ${response.orderListId}, Status: ${response.listOrderStatus}. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to cancel OCO order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // GET /sapi/v1/custodian/settlementSetting - Get Settlement Settings @@ -1031,7 +1031,7 @@ Response includes: try { const response = await makeSignedRequest("GET", "/sapi/v1/custodian/settlementSetting", { rail: params.rail.toUpperCase(), - }) + }); return { content: [ @@ -1040,17 +1040,17 @@ Response includes: text: `Settlement settings retrieved. Active: ${response.settlementActive}, Next: ${new Date(response.nextTriggerTime).toISOString()}. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get settlement settings: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // GET /sapi/v1/custodian/settlementHistory - Get Settlement History @@ -1094,7 +1094,7 @@ Each record contains: ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), ...(params.page && { page: params.page }), - }) + }); return { content: [ @@ -1103,15 +1103,15 @@ Each record contains: text: `Retrieved ${response.total} settlement records. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get settlement history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/general/index.ts b/src/tools/general/index.ts index 2d8178b3..49d3bebd 100644 --- a/src/tools/general/index.ts +++ b/src/tools/general/index.ts @@ -1,9 +1,9 @@ // src/tools/general/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { binanceUsRequest } from "../../config/binanceUsClient.js" +import { binanceUsRequest } from "../../config/binanceUsClient.js"; export function registerGeneralTools(server: McpServer) { // binance_us_ping - Test connectivity to Binance.US @@ -13,7 +13,7 @@ export function registerGeneralTools(server: McpServer) { {}, async () => { try { - const result = await binanceUsRequest("GET", "/api/v3/ping", {}, false) + const result = await binanceUsRequest("GET", "/api/v3/ping", {}, false); return { content: [ @@ -22,17 +22,17 @@ export function registerGeneralTools(server: McpServer) { text: `Binance.US API connection successful. Response: ${JSON.stringify(result)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to ping Binance.US API: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // binance_us_server_time - Get server time server.tool( @@ -41,8 +41,8 @@ export function registerGeneralTools(server: McpServer) { {}, async () => { try { - const result = await binanceUsRequest("GET", "/api/v3/time", {}, false) - const serverTime = new Date(result.serverTime).toISOString() + const result = await binanceUsRequest("GET", "/api/v3/time", {}, false); + const serverTime = new Date(result.serverTime).toISOString(); return { content: [ @@ -51,17 +51,17 @@ export function registerGeneralTools(server: McpServer) { text: `Binance.US server time: ${serverTime} (${result.serverTime}). Response: ${JSON.stringify(result)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get server time: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // binance_us_system_status - Get system maintenance status (SIGNED) server.tool( @@ -70,8 +70,8 @@ export function registerGeneralTools(server: McpServer) { {}, async () => { try { - const result = await binanceUsRequest("GET", "/sapi/v1/system/status", {}, true) - const statusText = result.status === 0 ? "Normal" : "System Maintenance" + const result = await binanceUsRequest("GET", "/sapi/v1/system/status", {}, true); + const statusText = result.status === 0 ? "Normal" : "System Maintenance"; return { content: [ @@ -80,17 +80,17 @@ export function registerGeneralTools(server: McpServer) { text: `Binance.US system status: ${statusText} (${result.status}). Response: ${JSON.stringify(result)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get system status: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // binance_us_exchange_info - Get exchange information server.tool( @@ -116,7 +116,7 @@ export function registerGeneralTools(server: McpServer) { }, async ({ symbol, symbols, permissions }) => { try { - const params: Record = {} + const params: Record = {}; // symbol and symbols are mutually exclusive if (symbol && symbols) { @@ -128,22 +128,22 @@ export function registerGeneralTools(server: McpServer) { }, ], isError: true, - } + }; } if (symbol) { - params.symbol = symbol + params.symbol = symbol; } else if (symbols && symbols.length > 0) { - params.symbols = JSON.stringify(symbols) + params.symbols = JSON.stringify(symbols); } if (permissions && permissions.length > 0) { - params.permissions = permissions.join(",") + params.permissions = permissions.join(","); } - const result = await binanceUsRequest("GET", "/api/v3/exchangeInfo", params, false) + const result = await binanceUsRequest("GET", "/api/v3/exchangeInfo", params, false); - const symbolCount = result.symbols?.length || 0 + const symbolCount = result.symbols?.length || 0; return { content: [ @@ -152,15 +152,15 @@ export function registerGeneralTools(server: McpServer) { text: `Retrieved exchange info. Total symbols: ${symbolCount}. Server time: ${result.serverTime}. Timezone: ${result.timezone}. Response: ${JSON.stringify(result, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get exchange info: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/market/index.ts b/src/tools/market/index.ts index 97ed5122..6b9b0b7b 100644 --- a/src/tools/market/index.ts +++ b/src/tools/market/index.ts @@ -1,7 +1,7 @@ // src/tools/market/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; import { type AggTradeResponse, @@ -17,7 +17,7 @@ import { ORDER_BOOK_VALID_LIMITS, RateLimitError, ROLLING_WINDOW_SIZES, -} from "../../config/binanceUsClient.js" +} from "../../config/binanceUsClient.js"; /** * Format error response with helpful details @@ -32,7 +32,7 @@ function formatError(error: unknown): { content: { type: "text"; text: string }[ }, ], isError: true, - } + }; } if (error instanceof IpBanError) { return { @@ -43,7 +43,7 @@ function formatError(error: unknown): { content: { type: "text"; text: string }[ }, ], isError: true, - } + }; } if (error instanceof BinanceUsApiError) { return { @@ -54,14 +54,14 @@ function formatError(error: unknown): { content: { type: "text"; text: string }[ }, ], isError: true, - } + }; } - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: errorMessage }], isError: true, - } + }; } /** @@ -89,13 +89,13 @@ export function registerMarketTools(server: McpServer) { }, async ({ symbol, limit }) => { try { - const params: Record = { symbol } - if (limit !== undefined) params.limit = limit + const params: Record = { symbol }; + if (limit !== undefined) params.limit = limit; - const result = await binanceUsRequest("GET", "/api/v3/depth", params, false) + const result = await binanceUsRequest("GET", "/api/v3/depth", params, false); - const bestBid = result.bids?.[0] || ["N/A", "N/A"] - const bestAsk = result.asks?.[0] || ["N/A", "N/A"] + const bestBid = result.bids?.[0] || ["N/A", "N/A"]; + const bestAsk = result.asks?.[0] || ["N/A", "N/A"]; return { content: [ @@ -116,12 +116,12 @@ export function registerMarketTools(server: McpServer) { `Full Response:\n${JSON.stringify(result, null, 2)}`, }, ], - } + }; } catch (error) { - return formatError(error) + return formatError(error); } }, - ) + ); // binance_us_recent_trades - Get recent trades server.tool( @@ -139,13 +139,13 @@ export function registerMarketTools(server: McpServer) { }, async ({ symbol, limit }) => { try { - const params: Record = { symbol } - if (limit !== undefined) params.limit = limit + const params: Record = { symbol }; + if (limit !== undefined) params.limit = limit; - const result = await binanceUsRequest("GET", "/api/v3/trades", params, false) + const result = await binanceUsRequest("GET", "/api/v3/trades", params, false); - const latestTrade = result[result.length - 1] - const oldestTrade = result[0] + const latestTrade = result[result.length - 1]; + const oldestTrade = result[0]; return { content: [ @@ -160,12 +160,12 @@ export function registerMarketTools(server: McpServer) { `Full Response:\n${JSON.stringify(result, null, 2)}`, }, ], - } + }; } catch (error) { - return formatError(error) + return formatError(error); } }, - ) + ); // binance_us_historical_trades - Get older trades (MARKET_DATA) server.tool( @@ -189,9 +189,9 @@ export function registerMarketTools(server: McpServer) { }, async ({ symbol, limit, fromId }) => { try { - const params: Record = { symbol } - if (limit !== undefined) params.limit = limit - if (fromId !== undefined) params.fromId = fromId + const params: Record = { symbol }; + if (limit !== undefined) params.limit = limit; + if (fromId !== undefined) params.fromId = fromId; const result = await binanceUsRequest( "GET", @@ -199,10 +199,10 @@ export function registerMarketTools(server: McpServer) { params, false, true, - ) + ); - const latestTrade = result[result.length - 1] - const oldestTrade = result[0] + const latestTrade = result[result.length - 1]; + const oldestTrade = result[0]; return { content: [ @@ -217,12 +217,12 @@ export function registerMarketTools(server: McpServer) { `Full Response:\n${JSON.stringify(result, null, 2)}`, }, ], - } + }; } catch (error) { - return formatError(error) + return formatError(error); } }, - ) + ); // binance_us_agg_trades - Get aggregate trades server.tool( @@ -243,22 +243,22 @@ export function registerMarketTools(server: McpServer) { }, async ({ symbol, fromId, startTime, endTime, limit }) => { try { - const params: Record = { symbol } - if (fromId !== undefined) params.fromId = fromId - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + const params: Record = { symbol }; + if (fromId !== undefined) params.fromId = fromId; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; const result: AggTradeResponse[] = await binanceUsRequest( "GET", "/api/v3/aggTrades", params, false, - ) - const formattedTrades = result.map(formatAggTrade) + ); + const formattedTrades = result.map(formatAggTrade); - const firstTrade = result[0] - const lastTrade = result[result.length - 1] + const firstTrade = result[0]; + const lastTrade = result[result.length - 1]; const summary = firstTrade && lastTrade ? { @@ -267,7 +267,7 @@ export function registerMarketTools(server: McpServer) { timeRange: `${new Date(firstTrade.T).toISOString()} to ${new Date(lastTrade.T).toISOString()}`, latestPrice: lastTrade.p, } - : null + : null; return { content: [ @@ -286,12 +286,12 @@ export function registerMarketTools(server: McpServer) { `Raw Response:\n${JSON.stringify(result, null, 2)}`, }, ], - } + }; } catch (error) { - return formatError(error) + return formatError(error); } }, - ) + ); // binance_us_klines - Get candlestick data server.tool( @@ -312,28 +312,28 @@ export function registerMarketTools(server: McpServer) { }, async ({ symbol, interval, startTime, endTime, limit }) => { try { - const params: Record = { symbol, interval } - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (limit !== undefined) params.limit = limit + const params: Record = { symbol, interval }; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (limit !== undefined) params.limit = limit; - const result: KlineRaw[] = await binanceUsRequest("GET", "/api/v3/klines", params, false) - const formattedKlines = result.map(formatKline) + const result: KlineRaw[] = await binanceUsRequest("GET", "/api/v3/klines", params, false); + const formattedKlines = result.map(formatKline); - const firstKline = formattedKlines[0] - const latestKline = formattedKlines[formattedKlines.length - 1] + const firstKline = formattedKlines[0]; + const latestKline = formattedKlines[formattedKlines.length - 1]; - let summaryText = "" + let summaryText = ""; if (formattedKlines.length > 0 && firstKline && latestKline) { - const highs = formattedKlines.map((k) => parseFloat(k.high)) - const lows = formattedKlines.map((k) => parseFloat(k.low)) - const volumes = formattedKlines.map((k) => parseFloat(k.volume)) + const highs = formattedKlines.map((k) => parseFloat(k.high)); + const lows = formattedKlines.map((k) => parseFloat(k.low)); + const volumes = formattedKlines.map((k) => parseFloat(k.volume)); summaryText = `Period: ${firstKline.openTimeISO} to ${latestKline.closeTimeISO}\n` + `Latest: O:${latestKline.open} H:${latestKline.high} L:${latestKline.low} C:${latestKline.close}\n` + `Period High: ${Math.max(...highs)} | Period Low: ${Math.min(...lows)}\n` + - `Total Volume: ${volumes.reduce((a, b) => a + b, 0).toFixed(8)}\n` + `Total Volume: ${volumes.reduce((a, b) => a + b, 0).toFixed(8)}\n`; } return { @@ -350,12 +350,12 @@ export function registerMarketTools(server: McpServer) { `Full Response:\n${JSON.stringify(formattedKlines, null, 2)}`, }, ], - } + }; } catch (error) { - return formatError(error) + return formatError(error); } }, - ) + ); // binance_us_avg_price - Get average price server.tool( @@ -366,7 +366,7 @@ export function registerMarketTools(server: McpServer) { }, async ({ symbol }) => { try { - const result = await binanceUsRequest("GET", "/api/v3/avgPrice", { symbol }, false) + const result = await binanceUsRequest("GET", "/api/v3/avgPrice", { symbol }, false); return { content: [ @@ -380,12 +380,12 @@ export function registerMarketTools(server: McpServer) { `Response:\n${JSON.stringify(result, null, 2)}`, }, ], - } + }; } catch (error) { - return formatError(error) + return formatError(error); } }, - ) + ); // binance_us_ticker_24hr - Get 24hr statistics server.tool( @@ -409,32 +409,32 @@ export function registerMarketTools(server: McpServer) { return { content: [{ type: "text", text: "Error: Cannot specify both 'symbol' and 'symbols'." }], isError: true, - } + }; } - const params: Record = {} - if (symbol) params.symbol = symbol - if (symbols?.length) params.symbols = JSON.stringify(symbols.map((s) => s.toUpperCase())) - if (type) params.type = type + const params: Record = {}; + if (symbol) params.symbol = symbol; + if (symbols?.length) params.symbols = JSON.stringify(symbols.map((s) => s.toUpperCase())); + if (type) params.type = type; - const result = await binanceUsRequest("GET", "/api/v3/ticker/24hr", params, false) + const result = await binanceUsRequest("GET", "/api/v3/ticker/24hr", params, false); - const isArray = Array.isArray(result) - let summaryText: string + const isArray = Array.isArray(result); + let summaryText: string; if (isArray) { const sorted = [...result].sort( (a: any, b: any) => parseFloat(b.quoteVolume) - parseFloat(a.quoteVolume), - ) - const top5 = sorted.slice(0, 5) + ); + const top5 = sorted.slice(0, 5); summaryText = `Total symbols: ${result.length}\n` + - `Top 5 by volume:\n${top5.map((t: any) => ` ${t.symbol}: ${t.priceChangePercent}% | Vol: ${parseFloat(t.quoteVolume).toLocaleString()}`).join("\n")}` + `Top 5 by volume:\n${top5.map((t: any) => ` ${t.symbol}: ${t.priceChangePercent}% | Vol: ${parseFloat(t.quoteVolume).toLocaleString()}`).join("\n")}`; } else { summaryText = `${result.symbol}: ${result.lastPrice} (${parseFloat(result.priceChangePercent) >= 0 ? "+" : ""}${result.priceChangePercent}%)\n` + `High: ${result.highPrice} | Low: ${result.lowPrice}\n` + - `Volume: ${result.volume}` + `Volume: ${result.volume}`; } return { @@ -449,12 +449,12 @@ export function registerMarketTools(server: McpServer) { `Full Response:\n${JSON.stringify(result, null, 2)}`, }, ], - } + }; } catch (error) { - return formatError(error) + return formatError(error); } }, - ) + ); // binance_us_ticker_price - Get latest price server.tool( @@ -477,19 +477,19 @@ export function registerMarketTools(server: McpServer) { return { content: [{ type: "text", text: "Error: Cannot specify both 'symbol' and 'symbols'." }], isError: true, - } + }; } - const params: Record = {} - if (symbol) params.symbol = symbol - if (symbols?.length) params.symbols = JSON.stringify(symbols.map((s) => s.toUpperCase())) + const params: Record = {}; + if (symbol) params.symbol = symbol; + if (symbols?.length) params.symbols = JSON.stringify(symbols.map((s) => s.toUpperCase())); - const result = await binanceUsRequest("GET", "/api/v3/ticker/price", params, false) + const result = await binanceUsRequest("GET", "/api/v3/ticker/price", params, false); - const isArray = Array.isArray(result) + const isArray = Array.isArray(result); const responseText = isArray ? `Retrieved prices for ${result.length} symbols.` - : `${result.symbol}: ${result.price}` + : `${result.symbol}: ${result.price}`; return { content: [ @@ -502,12 +502,12 @@ export function registerMarketTools(server: McpServer) { `Response:\n${JSON.stringify(result, null, 2)}`, }, ], - } + }; } catch (error) { - return formatError(error) + return formatError(error); } }, - ) + ); // binance_us_ticker_book - Get book ticker server.tool( @@ -530,31 +530,31 @@ export function registerMarketTools(server: McpServer) { return { content: [{ type: "text", text: "Error: Cannot specify both 'symbol' and 'symbols'." }], isError: true, - } + }; } - const params: Record = {} - if (symbol) params.symbol = symbol - if (symbols?.length) params.symbols = JSON.stringify(symbols.map((s) => s.toUpperCase())) + const params: Record = {}; + if (symbol) params.symbol = symbol; + if (symbols?.length) params.symbols = JSON.stringify(symbols.map((s) => s.toUpperCase())); - const result = await binanceUsRequest("GET", "/api/v3/ticker/bookTicker", params, false) + const result = await binanceUsRequest("GET", "/api/v3/ticker/bookTicker", params, false); - const isArray = Array.isArray(result) - let summaryText: string + const isArray = Array.isArray(result); + let summaryText: string; if (isArray) { - summaryText = `Total symbols: ${result.length}` + summaryText = `Total symbols: ${result.length}`; } else { - const spread = (parseFloat(result.askPrice) - parseFloat(result.bidPrice)).toFixed(8) + const spread = (parseFloat(result.askPrice) - parseFloat(result.bidPrice)).toFixed(8); const midPrice = ( (parseFloat(result.askPrice) + parseFloat(result.bidPrice)) / 2 - ).toFixed(8) + ).toFixed(8); summaryText = `${result.symbol}\n` + `Bid: ${result.bidPrice} @ ${result.bidQty}\n` + `Ask: ${result.askPrice} @ ${result.askQty}\n` + - `Spread: ${spread} | Mid: ${midPrice}` + `Spread: ${spread} | Mid: ${midPrice}`; } return { @@ -568,12 +568,12 @@ export function registerMarketTools(server: McpServer) { `Response:\n${JSON.stringify(result, null, 2)}`, }, ], - } + }; } catch (error) { - return formatError(error) + return formatError(error); } }, - ) + ); // binance_us_rolling_window - Get rolling window stats server.tool( @@ -603,35 +603,35 @@ export function registerMarketTools(server: McpServer) { { type: "text", text: "Error: Either 'symbol' or 'symbols' must be provided." }, ], isError: true, - } + }; } if (symbol && symbols) { return { content: [{ type: "text", text: "Error: Cannot specify both 'symbol' and 'symbols'." }], isError: true, - } + }; } - const params: Record = {} - if (symbol) params.symbol = symbol - if (symbols?.length) params.symbols = JSON.stringify(symbols.map((s) => s.toUpperCase())) - if (windowSize) params.windowSize = windowSize - if (type) params.type = type + const params: Record = {}; + if (symbol) params.symbol = symbol; + if (symbols?.length) params.symbols = JSON.stringify(symbols.map((s) => s.toUpperCase())); + if (windowSize) params.windowSize = windowSize; + if (type) params.type = type; - const result = await binanceUsRequest("GET", "/api/v3/ticker", params, false) + const result = await binanceUsRequest("GET", "/api/v3/ticker", params, false); - const isArray = Array.isArray(result) - const windowText = windowSize || "1d" - let summaryText: string + const isArray = Array.isArray(result); + const windowText = windowSize || "1d"; + let summaryText: string; if (isArray) { - summaryText = `Window: ${windowText}\nTotal symbols: ${result.length}` + summaryText = `Window: ${windowText}\nTotal symbols: ${result.length}`; } else { summaryText = `${result.symbol} (${windowText})\n` + `Price: ${result.lastPrice} (${parseFloat(result.priceChangePercent) >= 0 ? "+" : ""}${result.priceChangePercent}%)\n` + `High: ${result.highPrice} | Low: ${result.lowPrice}\n` + - `Volume: ${result.volume} | Trades: ${result.count}` + `Volume: ${result.volume} | Trades: ${result.count}`; } return { @@ -645,10 +645,10 @@ export function registerMarketTools(server: McpServer) { `Response:\n${JSON.stringify(result, null, 2)}`, }, ], - } + }; } catch (error) { - return formatError(error) + return formatError(error); } }, - ) + ); } diff --git a/src/tools/otc/index.ts b/src/tools/otc/index.ts index 68d88ad5..583695de 100644 --- a/src/tools/otc/index.ts +++ b/src/tools/otc/index.ts @@ -2,11 +2,11 @@ // Binance.US OTC (Over-The-Counter) Trading Tools // Large block trades executed outside the regular order book -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { makeSignedRequest } from "../../config/binanceUsClient.js" +import { makeSignedRequest } from "../../config/binanceUsClient.js"; /** * Register all Binance.US OTC trading tools @@ -41,7 +41,7 @@ Example: Convert large amounts of BTC to USDT without affecting market price.`, const response = await makeSignedRequest("GET", "/sapi/v1/otc/coinPairs", { ...(params.fromCoin && { fromCoin: params.fromCoin.toUpperCase() }), ...(params.toCoin && { toCoin: params.toCoin.toUpperCase() }), - }) + }); return { content: [ @@ -50,17 +50,17 @@ Example: Convert large amounts of BTC to USDT without affecting market price.`, text: `Successfully retrieved OTC coin pairs. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get OTC coin pairs: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // POST /sapi/v1/otc/quotes - Request Quote for OTC Trade @@ -101,7 +101,7 @@ Response includes: toCoin: params.toCoin.toUpperCase(), requestCoin: params.requestCoin.toUpperCase(), requestAmount: params.requestAmount, - }) + }); return { content: [ @@ -110,17 +110,17 @@ Response includes: text: `OTC Quote received successfully. ⚠️ Quote expires at timestamp ${response.validTimestamp}. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get OTC quote: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // POST /sapi/v1/otc/orders - Place OTC Trade Order @@ -153,7 +153,7 @@ Response includes: try { const response = await makeSignedRequest("POST", "/sapi/v1/otc/orders", { quoteId: params.quoteId, - }) + }); return { content: [ @@ -162,17 +162,17 @@ Response includes: text: `OTC order placed successfully. Order ID: ${response.orderId}, Status: ${response.orderStatus}. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to place OTC order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // GET /sapi/v1/otc/orders/{orderId} - Get OTC Order Details @@ -196,7 +196,7 @@ Response includes: }, async (params) => { try { - const response = await makeSignedRequest("GET", `/sapi/v1/otc/orders/${params.orderId}`) + const response = await makeSignedRequest("GET", `/sapi/v1/otc/orders/${params.orderId}`); return { content: [ @@ -205,17 +205,17 @@ Response includes: text: `OTC order details retrieved. Status: ${response.orderStatus}. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get OTC order: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // GET /sapi/v1/otc/orders - Get All OTC Trade Orders @@ -257,7 +257,7 @@ toCoin, toAmount, ratio, inverseRatio, createTime`, ...(params.endTime && { endTime: params.endTime }), ...(params.page && { page: params.page }), ...(params.limit && { limit: params.limit }), - }) + }); return { content: [ @@ -266,17 +266,17 @@ toCoin, toAmount, ratio, inverseRatio, createTime`, text: `Retrieved ${response.total} OTC orders. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get OTC orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // GET /sapi/v1/ocbs/orders - Get All OCBS (Fiat) Orders @@ -320,7 +320,7 @@ Each order contains: ...(params.endTime && { endTime: params.endTime }), ...(params.page && { page: params.page }), ...(params.limit && { limit: params.limit }), - }) + }); return { content: [ @@ -329,15 +329,15 @@ Each order contains: text: `Retrieved ${response.total} OCBS orders. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get OCBS orders: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/staking/index.ts b/src/tools/staking/index.ts index 16eab1d2..e5268841 100644 --- a/src/tools/staking/index.ts +++ b/src/tools/staking/index.ts @@ -2,11 +2,11 @@ // Binance.US Staking Tools // Earn rewards by staking supported cryptocurrencies -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { makeSignedRequest } from "../../config/binanceUsClient.js" +import { makeSignedRequest } from "../../config/binanceUsClient.js"; /** * Register all Binance.US Staking tools @@ -45,7 +45,7 @@ If no asset is specified, returns information for all staking assets.`, try { const response = await makeSignedRequest("GET", "/sapi/v1/staking/asset", { ...(params.stakingAsset && { stakingAsset: params.stakingAsset.toUpperCase() }), - }) + }); return { content: [ @@ -54,17 +54,17 @@ If no asset is specified, returns information for all staking assets.`, text: `Successfully retrieved staking asset information. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get staking asset info: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // POST /sapi/v1/staking/stake - Stake Asset @@ -102,7 +102,7 @@ Response includes: stakingAsset: params.stakingAsset.toUpperCase(), amount: params.amount, autoRestake: params.autoRestake, - }) + }); return { content: [ @@ -111,17 +111,17 @@ Response includes: text: `Staking request submitted. Result: ${response.data?.result || response.result}. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to stake asset: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // POST /sapi/v1/staking/unstake - Unstake Asset @@ -150,7 +150,7 @@ Response includes: const response = await makeSignedRequest("POST", "/sapi/v1/staking/unstake", { stakingAsset: params.stakingAsset.toUpperCase(), amount: params.amount, - }) + }); return { content: [ @@ -159,17 +159,17 @@ Response includes: text: `Unstaking request submitted. Result: ${response.data?.result || response.result}. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to unstake asset: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // GET /sapi/v1/staking/stakingBalance - Get Staking Balance @@ -199,7 +199,7 @@ If no asset is specified, returns balances for all staked assets.`, try { const response = await makeSignedRequest("GET", "/sapi/v1/staking/stakingBalance", { ...(params.asset && { asset: params.asset.toUpperCase() }), - }) + }); return { content: [ @@ -208,17 +208,17 @@ If no asset is specified, returns balances for all staked assets.`, text: `Successfully retrieved staking balance. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get staking balance: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // GET /sapi/v1/staking/history - Get Staking History @@ -262,7 +262,7 @@ If no asset is specified, returns history for all assets.`, ...(params.endTime && { endTime: params.endTime }), ...(params.page && { page: params.page }), ...(params.limit && { limit: params.limit }), - }) + }); return { content: [ @@ -271,17 +271,17 @@ If no asset is specified, returns history for all assets.`, text: `Successfully retrieved staking history. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get staking history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // GET /sapi/v1/staking/stakingRewardsHistory - Get Staking Rewards History @@ -330,7 +330,7 @@ If no asset is specified, returns rewards for all staked assets.`, ...(params.endTime && { endTime: params.endTime }), ...(params.page && { page: params.page }), ...(params.limit && { limit: params.limit }), - }) + }); return { content: [ @@ -339,17 +339,17 @@ If no asset is specified, returns rewards for all staked assets.`, text: `Successfully retrieved staking rewards history. Total: ${response.total || "N/A"}. Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to get staking rewards history: ${errorMessage}` }, ], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/subaccount/index.ts b/src/tools/subaccount/index.ts index ef38ff14..3988a6d2 100644 --- a/src/tools/subaccount/index.ts +++ b/src/tools/subaccount/index.ts @@ -1,9 +1,9 @@ // src/tools/subaccount/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { makeSignedRequest } from "../../config/binanceUsClient.js" +import { makeSignedRequest } from "../../config/binanceUsClient.js"; /** * Register all Sub-account related tools for Binance.US @@ -33,14 +33,14 @@ export function registerSubaccountTools(server: McpServer) { }, async ({ email, status, page, limit, recvWindow }) => { try { - const params: Record = {} - if (email !== undefined) params.email = email - if (status !== undefined) params.status = status - if (page !== undefined) params.page = page - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = {}; + if (email !== undefined) params.email = email; + if (status !== undefined) params.status = status; + if (page !== undefined) params.page = page; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await makeSignedRequest("GET", "/sapi/v3/sub-account/list", params) + const data = await makeSignedRequest("GET", "/sapi/v3/sub-account/list", params); return { content: [ @@ -49,17 +49,17 @@ export function registerSubaccountTools(server: McpServer) { text: `Sub-accounts:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get sub-account list: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================== // binance_us_subaccount_transfer_history @@ -78,15 +78,19 @@ export function registerSubaccountTools(server: McpServer) { }, async ({ email, startTime, endTime, page, limit, recvWindow }) => { try { - const params: Record = {} - if (email !== undefined) params.email = email - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (page !== undefined) params.page = page - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = {}; + if (email !== undefined) params.email = email; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (page !== undefined) params.page = page; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await makeSignedRequest("GET", "/sapi/v3/sub-account/transfer/history", params) + const data = await makeSignedRequest( + "GET", + "/sapi/v3/sub-account/transfer/history", + params, + ); return { content: [ @@ -95,17 +99,17 @@ export function registerSubaccountTools(server: McpServer) { text: `Sub-account Transfer History:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get transfer history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================== // binance_us_subaccount_transfer @@ -128,10 +132,10 @@ export function registerSubaccountTools(server: McpServer) { toEmail, asset, amount, - } - if (recvWindow !== undefined) params.recvWindow = recvWindow + }; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await makeSignedRequest("POST", "/sapi/v3/sub-account/transfer", params) + const data = await makeSignedRequest("POST", "/sapi/v3/sub-account/transfer", params); return { content: [ @@ -140,17 +144,17 @@ export function registerSubaccountTools(server: McpServer) { text: `Transfer completed successfully!\nTransaction ID: ${data.txnId}\nFrom: ${fromEmail}\nTo: ${toEmail}\nAsset: ${asset}\nAmount: ${amount}\n\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to execute transfer: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================== // binance_us_subaccount_assets @@ -165,17 +169,17 @@ export function registerSubaccountTools(server: McpServer) { }, async ({ email, recvWindow }) => { try { - const params: Record = { email } - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = { email }; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await makeSignedRequest("GET", "/sapi/v3/sub-account/assets", params) + const data = await makeSignedRequest("GET", "/sapi/v3/sub-account/assets", params); // Filter to show only non-zero balances const nonZeroBalances = data.balances?.filter( (b: { free: string | number; locked: string | number }) => parseFloat(String(b.free)) > 0 || parseFloat(String(b.locked)) > 0, - ) || [] + ) || []; return { content: [ @@ -184,17 +188,17 @@ export function registerSubaccountTools(server: McpServer) { text: `Sub-account Assets for ${email}:\n\nNon-zero balances:\n${JSON.stringify(nonZeroBalances, null, 2)}\n\nFull response:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get sub-account assets: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================== // binance_us_subaccount_summary @@ -211,13 +215,13 @@ export function registerSubaccountTools(server: McpServer) { }, async ({ email, page, size, recvWindow }) => { try { - const params: Record = {} - if (email !== undefined) params.email = email - if (page !== undefined) params.page = page - if (size !== undefined) params.size = size - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = {}; + if (email !== undefined) params.email = email; + if (page !== undefined) params.page = page; + if (size !== undefined) params.size = size; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await makeSignedRequest("GET", "/sapi/v1/sub-account/spotSummary", params) + const data = await makeSignedRequest("GET", "/sapi/v1/sub-account/spotSummary", params); return { content: [ @@ -226,17 +230,17 @@ export function registerSubaccountTools(server: McpServer) { text: `Sub-account Summary:\nTotal Accounts: ${data.totalCount}\nMaster Account Total Asset (USD): ${data.masterAccountTotalAsset}\n\nSub-account Details:\n${JSON.stringify(data.spotSubUserAssetBtcVoList, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get sub-account summary: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================== // binance_us_subaccount_status @@ -251,11 +255,11 @@ export function registerSubaccountTools(server: McpServer) { }, async ({ email, recvWindow }) => { try { - const params: Record = {} - if (email !== undefined) params.email = email - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = {}; + if (email !== undefined) params.email = email; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await makeSignedRequest("GET", "/sapi/v1/sub-account/status", params) + const data = await makeSignedRequest("GET", "/sapi/v1/sub-account/status", params); return { content: [ @@ -264,15 +268,15 @@ export function registerSubaccountTools(server: McpServer) { text: `Sub-account Status:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get sub-account status: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/tools/trade/index.ts b/src/tools/trade/index.ts index 8e4f8268..1627c762 100644 --- a/src/tools/trade/index.ts +++ b/src/tools/trade/index.ts @@ -1,8 +1,8 @@ // src/tools/trade/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { registerBinanceUsOcoTools } from "./oco.js" -import { registerBinanceUsOrderTools } from "./orders.js" +import { registerBinanceUsOcoTools } from "./oco.js"; +import { registerBinanceUsOrderTools } from "./orders.js"; /** * Register all Binance.US trading tools @@ -25,13 +25,13 @@ import { registerBinanceUsOrderTools } from "./orders.js" * - binance_us_all_oco_orders: Get OCO order history */ export function registerBinanceUsTradeTools(server: McpServer) { - registerBinanceUsOrderTools(server) - registerBinanceUsOcoTools(server) + registerBinanceUsOrderTools(server); + registerBinanceUsOcoTools(server); } // Re-export individual registration functions for granular control -export { registerBinanceUsOrderTools } from "./orders.js" -export { registerBinanceUsOcoTools } from "./oco.js" +export { registerBinanceUsOrderTools } from "./orders.js"; +export { registerBinanceUsOcoTools } from "./oco.js"; // Re-export individual tool registration functions export { @@ -43,7 +43,7 @@ export { registerBinanceUsCancelAllOpenOrders, registerBinanceUsOpenOrders, registerBinanceUsAllOrders, -} from "./orders.js" +} from "./orders.js"; export { registerBinanceUsNewOco, @@ -51,4 +51,4 @@ export { registerBinanceUsCancelOco, registerBinanceUsOpenOco, registerBinanceUsAllOcoOrders, -} from "./oco.js" +} from "./oco.js"; diff --git a/src/tools/trade/oco.ts b/src/tools/trade/oco.ts index a8bc10de..280bb341 100644 --- a/src/tools/trade/oco.ts +++ b/src/tools/trade/oco.ts @@ -1,13 +1,13 @@ // src/tools/trade/oco.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; import { BINANCE_US_CONFIG, hasApiCredentials, makeSignedRequest, -} from "../../config/binanceUsClient.js" +} from "../../config/binanceUsClient.js"; // Common Binance error codes for better error messages const BINANCE_ERROR_CODES: Record = { @@ -26,13 +26,13 @@ const BINANCE_ERROR_CODES: Record = { [-2015]: "Rejected - invalid API key, IP, or permissions", [-2018]: "Balance is insufficient", [-2021]: "Order would immediately trigger stop price", -} +}; /** * Get human-readable error message for Binance error code */ function getBinanceErrorMessage(code: number): string { - return BINANCE_ERROR_CODES[code] || `Unknown error code: ${code}` + return BINANCE_ERROR_CODES[code] || `Unknown error code: ${code}`; } /** @@ -40,10 +40,10 @@ function getBinanceErrorMessage(code: number): string { */ function checkCredentials(): string | null { if (!hasApiCredentials()) { - return "❌ API credentials not configured. Please set BINANCE_US_API_KEY and BINANCE_US_API_SECRET environment variables." + return "❌ API credentials not configured. Please set BINANCE_US_API_KEY and BINANCE_US_API_SECRET environment variables."; } - return null + return null; } /** @@ -51,10 +51,10 @@ function checkCredentials(): string | null { */ function validateRecvWindow(recvWindow?: number): string | null { if (recvWindow !== undefined && recvWindow > BINANCE_US_CONFIG.MAX_RECV_WINDOW) { - return `❌ recvWindow cannot exceed ${BINANCE_US_CONFIG.MAX_RECV_WINDOW}ms (60 seconds).` + return `❌ recvWindow cannot exceed ${BINANCE_US_CONFIG.MAX_RECV_WINDOW}ms (60 seconds).`; } - return null + return null; } /** @@ -62,26 +62,26 @@ function validateRecvWindow(recvWindow?: number): string | null { */ function validateSymbol(symbol: string): string | null { if (!symbol || symbol.length < 2 || symbol.length > 20) { - return "❌ Invalid symbol format. Symbol should be 2-20 characters (e.g., BTCUSD, ETHUSD)." + return "❌ Invalid symbol format. Symbol should be 2-20 characters (e.g., BTCUSD, ETHUSD)."; } if (!/^[A-Z0-9]+$/.test(symbol.toUpperCase())) { - return "❌ Invalid symbol format. Symbol should contain only letters and numbers." + return "❌ Invalid symbol format. Symbol should contain only letters and numbers."; } - return null + return null; } // Order side enum -const OrderSide = z.enum(["BUY", "SELL"]) +const OrderSide = z.enum(["BUY", "SELL"]); // Time in force enum -const TimeInForce = z.enum(["GTC", "IOC", "FOK"]) +const TimeInForce = z.enum(["GTC", "IOC", "FOK"]); // Response type enum -const OrderRespType = z.enum(["ACK", "RESULT", "FULL"]) +const OrderRespType = z.enum(["ACK", "RESULT", "FULL"]); // Self trade prevention mode enum -const SelfTradePreventionMode = z.enum(["EXPIRE_TAKER", "EXPIRE_MAKER", "EXPIRE_BOTH", "NONE"]) +const SelfTradePreventionMode = z.enum(["EXPIRE_TAKER", "EXPIRE_MAKER", "EXPIRE_BOTH", "NONE"]); /** * Register new OCO order tool @@ -120,29 +120,29 @@ export function registerBinanceUsNewOco(server: McpServer) { async (params) => { try { // Check API credentials first - const credError = checkCredentials() - if (credError) return { content: [{ type: "text", text: credError }], isError: true } + const credError = checkCredentials(); + if (credError) return { content: [{ type: "text", text: credError }], isError: true }; // Validate symbol and recvWindow - const symbolError = validateSymbol(params.symbol) - if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true } - const recvWindowError = validateRecvWindow(params.recvWindow) + const symbolError = validateSymbol(params.symbol); + if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true }; + const recvWindowError = validateRecvWindow(params.recvWindow); if (recvWindowError) - return { content: [{ type: "text", text: recvWindowError }], isError: true } + return { content: [{ type: "text", text: recvWindowError }], isError: true }; // Validate OCO parameters - const validationError = validateOcoParams(params) + const validationError = validateOcoParams(params); if (validationError) { return { content: [{ type: "text", text: validationError }], isError: true, - } + }; } - const response = await makeSignedRequest("POST", "/api/v3/order/oco", params) + const response = await makeSignedRequest("POST", "/api/v3/order/oco", params); - const orders = response.orders || [] - const orderReports = response.orderReports || [] + const orders = response.orders || []; + const orderReports = response.orderReports || []; return { content: [ @@ -174,14 +174,14 @@ export function registerBinanceUsNewOco(server: McpServer) { `\n\nFull Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) - const codeMatch = errorMessage.match(/code:\s*(-?\d+)/) + const errorMessage = error instanceof Error ? error.message : String(error); + const codeMatch = errorMessage.match(/code:\s*(-?\d+)/); const additionalHelp = codeMatch && codeMatch[1] ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` - : "" + : ""; return { content: [ @@ -191,10 +191,10 @@ export function registerBinanceUsNewOco(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } /** @@ -212,11 +212,11 @@ export function registerBinanceUsGetOco(server: McpServer) { async (params) => { try { // Check API credentials first - const credError = checkCredentials() - if (credError) return { content: [{ type: "text", text: credError }], isError: true } - const recvWindowError = validateRecvWindow(params.recvWindow) + const credError = checkCredentials(); + if (credError) return { content: [{ type: "text", text: credError }], isError: true }; + const recvWindowError = validateRecvWindow(params.recvWindow); if (recvWindowError) - return { content: [{ type: "text", text: recvWindowError }], isError: true } + return { content: [{ type: "text", text: recvWindowError }], isError: true }; if (!params.orderListId && !params.origClientOrderId) { return { @@ -227,12 +227,12 @@ export function registerBinanceUsGetOco(server: McpServer) { }, ], isError: true, - } + }; } - const response = await makeSignedRequest("GET", "/api/v3/orderList", params) + const response = await makeSignedRequest("GET", "/api/v3/orderList", params); - const orders = response.orders || [] + const orders = response.orders || []; return { content: [ @@ -257,24 +257,24 @@ export function registerBinanceUsGetOco(server: McpServer) { `\n\nFull Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) - const codeMatch = errorMessage.match(/code:\s*(-?\d+)/) + const errorMessage = error instanceof Error ? error.message : String(error); + const codeMatch = errorMessage.match(/code:\s*(-?\d+)/); const additionalHelp = codeMatch && codeMatch[1] ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` - : "" + : ""; return { content: [ { type: "text", text: `❌ Failed to get OCO order: ${errorMessage}${additionalHelp}` }, ], isError: true, - } + }; } }, - ) + ); } /** @@ -297,13 +297,13 @@ export function registerBinanceUsCancelOco(server: McpServer) { async (params) => { try { // Check API credentials first - const credError = checkCredentials() - if (credError) return { content: [{ type: "text", text: credError }], isError: true } - const symbolError = validateSymbol(params.symbol) - if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true } - const recvWindowError = validateRecvWindow(params.recvWindow) + const credError = checkCredentials(); + if (credError) return { content: [{ type: "text", text: credError }], isError: true }; + const symbolError = validateSymbol(params.symbol); + if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true }; + const recvWindowError = validateRecvWindow(params.recvWindow); if (recvWindowError) - return { content: [{ type: "text", text: recvWindowError }], isError: true } + return { content: [{ type: "text", text: recvWindowError }], isError: true }; if (!params.orderListId && !params.listClientOrderId) { return { @@ -314,12 +314,12 @@ export function registerBinanceUsCancelOco(server: McpServer) { }, ], isError: true, - } + }; } - const response = await makeSignedRequest("DELETE", "/api/v3/orderList", params) + const response = await makeSignedRequest("DELETE", "/api/v3/orderList", params); - const orderReports = response.orderReports || [] + const orderReports = response.orderReports || []; return { content: [ @@ -343,14 +343,14 @@ export function registerBinanceUsCancelOco(server: McpServer) { `\n\nFull Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) - const codeMatch = errorMessage.match(/code:\s*(-?\d+)/) + const errorMessage = error instanceof Error ? error.message : String(error); + const codeMatch = errorMessage.match(/code:\s*(-?\d+)/); const additionalHelp = codeMatch && codeMatch[1] ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` - : "" + : ""; return { content: [ @@ -360,10 +360,10 @@ export function registerBinanceUsCancelOco(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } /** @@ -379,13 +379,13 @@ export function registerBinanceUsOpenOco(server: McpServer) { async (params) => { try { // Check API credentials first - const credError = checkCredentials() - if (credError) return { content: [{ type: "text", text: credError }], isError: true } - const recvWindowError = validateRecvWindow(params.recvWindow) + const credError = checkCredentials(); + if (credError) return { content: [{ type: "text", text: credError }], isError: true }; + const recvWindowError = validateRecvWindow(params.recvWindow); if (recvWindowError) - return { content: [{ type: "text", text: recvWindowError }], isError: true } + return { content: [{ type: "text", text: recvWindowError }], isError: true }; - const response = await makeSignedRequest("GET", "/api/v3/openOrderList", params) + const response = await makeSignedRequest("GET", "/api/v3/openOrderList", params); if (!response || response.length === 0) { return { @@ -395,12 +395,12 @@ export function registerBinanceUsOpenOco(server: McpServer) { text: `📋 No open OCO orders found`, }, ], - } + }; } const ocoList = response .map((oco: any) => { - const orders = oco.orders || [] + const orders = oco.orders || []; return ( `\n📦 Order List ID: ${oco.orderListId}\n` + @@ -414,9 +414,9 @@ export function registerBinanceUsOpenOco(server: McpServer) { ` • Order ID: ${order.orderId} | Client ID: ${order.clientOrderId}`, ) .join("\n") - ) + ); }) - .join("\n") + .join("\n"); return { content: [ @@ -429,14 +429,14 @@ export function registerBinanceUsOpenOco(server: McpServer) { `Full Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) - const codeMatch = errorMessage.match(/code:\s*(-?\d+)/) + const errorMessage = error instanceof Error ? error.message : String(error); + const codeMatch = errorMessage.match(/code:\s*(-?\d+)/); const additionalHelp = codeMatch && codeMatch[1] ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` - : "" + : ""; return { content: [ @@ -446,10 +446,10 @@ export function registerBinanceUsOpenOco(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } /** @@ -478,11 +478,11 @@ export function registerBinanceUsAllOcoOrders(server: McpServer) { async (params) => { try { // Check API credentials first - const credError = checkCredentials() - if (credError) return { content: [{ type: "text", text: credError }], isError: true } - const recvWindowError = validateRecvWindow(params.recvWindow) + const credError = checkCredentials(); + if (credError) return { content: [{ type: "text", text: credError }], isError: true }; + const recvWindowError = validateRecvWindow(params.recvWindow); if (recvWindowError) - return { content: [{ type: "text", text: recvWindowError }], isError: true } + return { content: [{ type: "text", text: recvWindowError }], isError: true }; // Validate mutually exclusive parameters if (params.fromId && (params.startTime || params.endTime)) { @@ -494,7 +494,7 @@ export function registerBinanceUsAllOcoOrders(server: McpServer) { }, ], isError: true, - } + }; } // Validate limit @@ -502,10 +502,10 @@ export function registerBinanceUsAllOcoOrders(server: McpServer) { return { content: [{ type: "text", text: "❌ limit must be between 1 and 1000." }], isError: true, - } + }; } - const response = await makeSignedRequest("GET", "/api/v3/allOrderList", params) + const response = await makeSignedRequest("GET", "/api/v3/allOrderList", params); if (!response || response.length === 0) { return { @@ -515,22 +515,22 @@ export function registerBinanceUsAllOcoOrders(server: McpServer) { text: `📋 No OCO order history found`, }, ], - } + }; } const ocoList = response .slice(0, 10) .map((oco: any) => { - const orders = oco.orders || [] + const orders = oco.orders || []; return ( `• List ID: ${oco.orderListId} | ${oco.symbol} | ` + `Status: ${oco.listOrderStatus} | ` + `Orders: ${orders.length} | ` + `${new Date(oco.transactionTime).toISOString()}` - ) + ); }) - .join("\n") + .join("\n"); return { content: [ @@ -543,14 +543,14 @@ export function registerBinanceUsAllOcoOrders(server: McpServer) { `Full Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) - const codeMatch = errorMessage.match(/code:\s*(-?\d+)/) + const errorMessage = error instanceof Error ? error.message : String(error); + const codeMatch = errorMessage.match(/code:\s*(-?\d+)/); const additionalHelp = codeMatch && codeMatch[1] ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` - : "" + : ""; return { content: [ @@ -560,36 +560,36 @@ export function registerBinanceUsAllOcoOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } /** * Validate OCO order parameters */ function validateOcoParams(params: any): string | null { - const { side, price, stopPrice, stopLimitPrice, stopLimitTimeInForce, quantity } = params + const { side, price, stopPrice, stopLimitPrice, stopLimitTimeInForce, quantity } = params; // Validate quantity if (!quantity || quantity <= 0) { - return "❌ quantity must be greater than 0." + return "❌ quantity must be greater than 0."; } // Validate price if (!price || price <= 0) { - return "❌ price must be greater than 0." + return "❌ price must be greater than 0."; } // Validate stopPrice if (!stopPrice || stopPrice <= 0) { - return "❌ stopPrice must be greater than 0." + return "❌ stopPrice must be greater than 0."; } // Validate stop limit price requires time in force if (stopLimitPrice && !stopLimitTimeInForce) { - return "❌ stopLimitTimeInForce is required when stopLimitPrice is provided." + return "❌ stopLimitTimeInForce is required when stopLimitPrice is provided."; } // Validate price restrictions based on side with helpful warnings @@ -597,26 +597,26 @@ function validateOcoParams(params: any): string | null { return ( "⚠️ For SELL OCO orders, limit price should typically be greater than stop price. " + "Price restrictions: Limit Price > Last Price > Stop Price" - ) + ); } if (side === "BUY" && price >= stopPrice) { return ( "⚠️ For BUY OCO orders, limit price should typically be less than stop price. " + "Price restrictions: Limit Price < Last Price < Stop Price" - ) + ); } - return null + return null; } /** * Register all OCO order tools */ export function registerBinanceUsOcoTools(server: McpServer) { - registerBinanceUsNewOco(server) - registerBinanceUsGetOco(server) - registerBinanceUsCancelOco(server) - registerBinanceUsOpenOco(server) - registerBinanceUsAllOcoOrders(server) + registerBinanceUsNewOco(server); + registerBinanceUsGetOco(server); + registerBinanceUsCancelOco(server); + registerBinanceUsOpenOco(server); + registerBinanceUsAllOcoOrders(server); } diff --git a/src/tools/trade/orders.ts b/src/tools/trade/orders.ts index 7cbe8193..d3097960 100644 --- a/src/tools/trade/orders.ts +++ b/src/tools/trade/orders.ts @@ -1,13 +1,13 @@ // src/tools/trade/orders.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; import { BINANCE_US_CONFIG, hasApiCredentials, makeSignedRequest, -} from "../../config/binanceUsClient.js" +} from "../../config/binanceUsClient.js"; // Common Binance error codes for better error messages const BINANCE_ERROR_CODES: Record = { @@ -58,13 +58,13 @@ const BINANCE_ERROR_CODES: Record = { [-2022]: "ReduceOnly rejected - position already reduced", [-2024]: "Position does not exist", [-2026]: "Order would immediately match and trade", -} +}; /** * Get human-readable error message for Binance error code */ function getBinanceErrorMessage(code: number): string { - return BINANCE_ERROR_CODES[code] || `Unknown error code: ${code}` + return BINANCE_ERROR_CODES[code] || `Unknown error code: ${code}`; } /** @@ -72,10 +72,10 @@ function getBinanceErrorMessage(code: number): string { */ function checkCredentials(): string | null { if (!hasApiCredentials()) { - return "❌ API credentials not configured. Please set BINANCE_US_API_KEY and BINANCE_US_API_SECRET environment variables." + return "❌ API credentials not configured. Please set BINANCE_US_API_KEY and BINANCE_US_API_SECRET environment variables."; } - return null + return null; } /** @@ -83,10 +83,10 @@ function checkCredentials(): string | null { */ function validateRecvWindow(recvWindow?: number): string | null { if (recvWindow !== undefined && recvWindow > BINANCE_US_CONFIG.MAX_RECV_WINDOW) { - return `❌ recvWindow cannot exceed ${BINANCE_US_CONFIG.MAX_RECV_WINDOW}ms (60 seconds).` + return `❌ recvWindow cannot exceed ${BINANCE_US_CONFIG.MAX_RECV_WINDOW}ms (60 seconds).`; } - return null + return null; } /** @@ -94,13 +94,13 @@ function validateRecvWindow(recvWindow?: number): string | null { */ function validateSymbol(symbol: string): string | null { if (!symbol || symbol.length < 2 || symbol.length > 20) { - return "❌ Invalid symbol format. Symbol should be 2-20 characters (e.g., BTCUSD, ETHUSD)." + return "❌ Invalid symbol format. Symbol should be 2-20 characters (e.g., BTCUSD, ETHUSD)."; } if (!/^[A-Z0-9]+$/.test(symbol.toUpperCase())) { - return "❌ Invalid symbol format. Symbol should contain only letters and numbers." + return "❌ Invalid symbol format. Symbol should contain only letters and numbers."; } - return null + return null; } // Order type enum @@ -112,25 +112,25 @@ const OrderType = z.enum([ "TAKE_PROFIT", "TAKE_PROFIT_LIMIT", "LIMIT_MAKER", -]) +]); // Time in force enum -const TimeInForce = z.enum(["GTC", "IOC", "FOK"]) +const TimeInForce = z.enum(["GTC", "IOC", "FOK"]); // Order side enum -const OrderSide = z.enum(["BUY", "SELL"]) +const OrderSide = z.enum(["BUY", "SELL"]); // Response type enum -const OrderRespType = z.enum(["ACK", "RESULT", "FULL"]) +const OrderRespType = z.enum(["ACK", "RESULT", "FULL"]); // Self trade prevention mode enum -const SelfTradePreventionMode = z.enum(["EXPIRE_TAKER", "EXPIRE_MAKER", "EXPIRE_BOTH", "NONE"]) +const SelfTradePreventionMode = z.enum(["EXPIRE_TAKER", "EXPIRE_MAKER", "EXPIRE_BOTH", "NONE"]); // Cancel replace mode enum -const CancelReplaceMode = z.enum(["STOP_ON_FAILURE", "ALLOW_FAILURE"]) +const CancelReplaceMode = z.enum(["STOP_ON_FAILURE", "ALLOW_FAILURE"]); // Cancel restrictions enum -const CancelRestrictions = z.enum(["ONLY_NEW", "ONLY_PARTIALLY_FILLED"]) +const CancelRestrictions = z.enum(["ONLY_NEW", "ONLY_PARTIALLY_FILLED"]); /** * Register new order tool @@ -189,28 +189,28 @@ export function registerBinanceUsNewOrder(server: McpServer) { async (params) => { try { // Check API credentials first - const credError = checkCredentials() - if (credError) return { content: [{ type: "text", text: credError }], isError: true } + const credError = checkCredentials(); + if (credError) return { content: [{ type: "text", text: credError }], isError: true }; // Validate symbol - const symbolError = validateSymbol(params.symbol) - if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true } + const symbolError = validateSymbol(params.symbol); + if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true }; // Validate recvWindow - const recvWindowError = validateRecvWindow(params.recvWindow) + const recvWindowError = validateRecvWindow(params.recvWindow); if (recvWindowError) - return { content: [{ type: "text", text: recvWindowError }], isError: true } + return { content: [{ type: "text", text: recvWindowError }], isError: true }; // Validate order type requirements - const validationError = validateOrderParams(params) + const validationError = validateOrderParams(params); if (validationError) { return { content: [{ type: "text", text: validationError }], isError: true, - } + }; } - const response = await makeSignedRequest("POST", "/api/v3/order", params) + const response = await makeSignedRequest("POST", "/api/v3/order", params); return { content: [ @@ -229,25 +229,25 @@ export function registerBinanceUsNewOrder(server: McpServer) { `\nFull Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); // Try to extract Binance error code for better messaging - const codeMatch = errorMessage.match(/code:\s*(-?\d+)/) + const codeMatch = errorMessage.match(/code:\s*(-?\d+)/); const additionalHelp = codeMatch && codeMatch[1] ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` - : "" + : ""; return { content: [ { type: "text", text: `❌ Failed to place order: ${errorMessage}${additionalHelp}` }, ], isError: true, - } + }; } }, - ) + ); } /** @@ -283,25 +283,25 @@ export function registerBinanceUsTestOrder(server: McpServer) { async (params) => { try { // Check API credentials first - const credError = checkCredentials() - if (credError) return { content: [{ type: "text", text: credError }], isError: true } + const credError = checkCredentials(); + if (credError) return { content: [{ type: "text", text: credError }], isError: true }; // Validate symbol and recvWindow - const symbolError = validateSymbol(params.symbol) - if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true } - const recvWindowError = validateRecvWindow(params.recvWindow) + const symbolError = validateSymbol(params.symbol); + if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true }; + const recvWindowError = validateRecvWindow(params.recvWindow); if (recvWindowError) - return { content: [{ type: "text", text: recvWindowError }], isError: true } + return { content: [{ type: "text", text: recvWindowError }], isError: true }; - const validationError = validateOrderParams(params) + const validationError = validateOrderParams(params); if (validationError) { return { content: [{ type: "text", text: validationError }], isError: true, - } + }; } - await makeSignedRequest("POST", "/api/v3/order/test", params) + await makeSignedRequest("POST", "/api/v3/order/test", params); return { content: [ @@ -317,14 +317,14 @@ export function registerBinanceUsTestOrder(server: McpServer) { `\nThe order parameters are valid and can be submitted.`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) - const codeMatch = errorMessage.match(/code:\s*(-?\d+)/) + const errorMessage = error instanceof Error ? error.message : String(error); + const codeMatch = errorMessage.match(/code:\s*(-?\d+)/); const additionalHelp = codeMatch && codeMatch[1] ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` - : "" + : ""; return { content: [ @@ -334,10 +334,10 @@ export function registerBinanceUsTestOrder(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } /** @@ -356,15 +356,15 @@ export function registerBinanceUsGetOrder(server: McpServer) { async (params) => { try { // Check API credentials first - const credError = checkCredentials() - if (credError) return { content: [{ type: "text", text: credError }], isError: true } + const credError = checkCredentials(); + if (credError) return { content: [{ type: "text", text: credError }], isError: true }; // Validate symbol and recvWindow - const symbolError = validateSymbol(params.symbol) - if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true } - const recvWindowError = validateRecvWindow(params.recvWindow) + const symbolError = validateSymbol(params.symbol); + if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true }; + const recvWindowError = validateRecvWindow(params.recvWindow); if (recvWindowError) - return { content: [{ type: "text", text: recvWindowError }], isError: true } + return { content: [{ type: "text", text: recvWindowError }], isError: true }; if (!params.orderId && !params.origClientOrderId) { return { @@ -372,10 +372,10 @@ export function registerBinanceUsGetOrder(server: McpServer) { { type: "text", text: "❌ Either orderId or origClientOrderId must be provided." }, ], isError: true, - } + }; } - const response = await makeSignedRequest("GET", "/api/v3/order", params) + const response = await makeSignedRequest("GET", "/api/v3/order", params); return { content: [ @@ -398,24 +398,24 @@ export function registerBinanceUsGetOrder(server: McpServer) { `\nFull Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) - const codeMatch = errorMessage.match(/code:\s*(-?\d+)/) + const errorMessage = error instanceof Error ? error.message : String(error); + const codeMatch = errorMessage.match(/code:\s*(-?\d+)/); const additionalHelp = codeMatch && codeMatch[1] ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` - : "" + : ""; return { content: [ { type: "text", text: `❌ Failed to get order: ${errorMessage}${additionalHelp}` }, ], isError: true, - } + }; } }, - ) + ); } /** @@ -441,15 +441,15 @@ export function registerBinanceUsCancelOrder(server: McpServer) { async (params) => { try { // Check API credentials first - const credError = checkCredentials() - if (credError) return { content: [{ type: "text", text: credError }], isError: true } + const credError = checkCredentials(); + if (credError) return { content: [{ type: "text", text: credError }], isError: true }; // Validate symbol and recvWindow - const symbolError = validateSymbol(params.symbol) - if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true } - const recvWindowError = validateRecvWindow(params.recvWindow) + const symbolError = validateSymbol(params.symbol); + if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true }; + const recvWindowError = validateRecvWindow(params.recvWindow); if (recvWindowError) - return { content: [{ type: "text", text: recvWindowError }], isError: true } + return { content: [{ type: "text", text: recvWindowError }], isError: true }; if (!params.orderId && !params.origClientOrderId) { return { @@ -457,10 +457,10 @@ export function registerBinanceUsCancelOrder(server: McpServer) { { type: "text", text: "❌ Either orderId or origClientOrderId must be provided." }, ], isError: true, - } + }; } - const response = await makeSignedRequest("DELETE", "/api/v3/order", params) + const response = await makeSignedRequest("DELETE", "/api/v3/order", params); return { content: [ @@ -479,24 +479,24 @@ export function registerBinanceUsCancelOrder(server: McpServer) { `\nFull Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) - const codeMatch = errorMessage.match(/code:\s*(-?\d+)/) + const errorMessage = error instanceof Error ? error.message : String(error); + const codeMatch = errorMessage.match(/code:\s*(-?\d+)/); const additionalHelp = codeMatch && codeMatch[1] ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` - : "" + : ""; return { content: [ { type: "text", text: `❌ Failed to cancel order: ${errorMessage}${additionalHelp}` }, ], isError: true, - } + }; } }, - ) + ); } /** @@ -540,15 +540,15 @@ export function registerBinanceUsCancelReplace(server: McpServer) { async (params) => { try { // Check API credentials first - const credError = checkCredentials() - if (credError) return { content: [{ type: "text", text: credError }], isError: true } + const credError = checkCredentials(); + if (credError) return { content: [{ type: "text", text: credError }], isError: true }; // Validate symbol and recvWindow - const symbolError = validateSymbol(params.symbol) - if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true } - const recvWindowError = validateRecvWindow(params.recvWindow) + const symbolError = validateSymbol(params.symbol); + if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true }; + const recvWindowError = validateRecvWindow(params.recvWindow); if (recvWindowError) - return { content: [{ type: "text", text: recvWindowError }], isError: true } + return { content: [{ type: "text", text: recvWindowError }], isError: true }; if (!params.cancelOrderId && !params.cancelOrigClientOrderId) { return { @@ -559,10 +559,10 @@ export function registerBinanceUsCancelReplace(server: McpServer) { }, ], isError: true, - } + }; } - const response = await makeSignedRequest("POST", "/api/v3/order/cancelReplace", params) + const response = await makeSignedRequest("POST", "/api/v3/order/cancelReplace", params); return { content: [ @@ -587,14 +587,14 @@ export function registerBinanceUsCancelReplace(server: McpServer) { `\nFull Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) - const codeMatch = errorMessage.match(/code:\s*(-?\d+)/) + const errorMessage = error instanceof Error ? error.message : String(error); + const codeMatch = errorMessage.match(/code:\s*(-?\d+)/); const additionalHelp = codeMatch && codeMatch[1] ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` - : "" + : ""; return { content: [ @@ -604,10 +604,10 @@ export function registerBinanceUsCancelReplace(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } /** @@ -629,19 +629,19 @@ export function registerBinanceUsOpenOrders(server: McpServer) { async (params) => { try { // Check API credentials first - const credError = checkCredentials() - if (credError) return { content: [{ type: "text", text: credError }], isError: true } + const credError = checkCredentials(); + if (credError) return { content: [{ type: "text", text: credError }], isError: true }; // Validate optional symbol and recvWindow if (params.symbol) { - const symbolError = validateSymbol(params.symbol) - if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true } + const symbolError = validateSymbol(params.symbol); + if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true }; } - const recvWindowError = validateRecvWindow(params.recvWindow) + const recvWindowError = validateRecvWindow(params.recvWindow); if (recvWindowError) - return { content: [{ type: "text", text: recvWindowError }], isError: true } + return { content: [{ type: "text", text: recvWindowError }], isError: true }; - const response = await makeSignedRequest("GET", "/api/v3/openOrders", params) + const response = await makeSignedRequest("GET", "/api/v3/openOrders", params); if (!response || response.length === 0) { return { @@ -653,7 +653,7 @@ export function registerBinanceUsOpenOrders(server: McpServer) { : `📋 No open orders found`, }, ], - } + }; } const orderList = response @@ -663,7 +663,7 @@ export function registerBinanceUsOpenOrders(server: McpServer) { `Qty: ${order.origQty} @ ${order.price} | ` + `Status: ${order.status} | ID: ${order.orderId}`, ) - .join("\n") + .join("\n"); return { content: [ @@ -676,14 +676,14 @@ export function registerBinanceUsOpenOrders(server: McpServer) { `Full Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) - const codeMatch = errorMessage.match(/code:\s*(-?\d+)/) + const errorMessage = error instanceof Error ? error.message : String(error); + const codeMatch = errorMessage.match(/code:\s*(-?\d+)/); const additionalHelp = codeMatch && codeMatch[1] ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` - : "" + : ""; return { content: [ @@ -693,10 +693,10 @@ export function registerBinanceUsOpenOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } /** @@ -720,25 +720,25 @@ export function registerBinanceUsAllOrders(server: McpServer) { async (params) => { try { // Check API credentials first - const credError = checkCredentials() - if (credError) return { content: [{ type: "text", text: credError }], isError: true } + const credError = checkCredentials(); + if (credError) return { content: [{ type: "text", text: credError }], isError: true }; // Validate symbol and recvWindow - const symbolError = validateSymbol(params.symbol) - if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true } - const recvWindowError = validateRecvWindow(params.recvWindow) + const symbolError = validateSymbol(params.symbol); + if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true }; + const recvWindowError = validateRecvWindow(params.recvWindow); if (recvWindowError) - return { content: [{ type: "text", text: recvWindowError }], isError: true } + return { content: [{ type: "text", text: recvWindowError }], isError: true }; // Validate limit if (params.limit !== undefined && (params.limit < 1 || params.limit > 1000)) { return { content: [{ type: "text", text: "❌ limit must be between 1 and 1000." }], isError: true, - } + }; } - const response = await makeSignedRequest("GET", "/api/v3/allOrders", params) + const response = await makeSignedRequest("GET", "/api/v3/allOrders", params); if (!response || response.length === 0) { return { @@ -748,7 +748,7 @@ export function registerBinanceUsAllOrders(server: McpServer) { text: `📋 No orders found for ${params.symbol}`, }, ], - } + }; } const orderList = response @@ -758,7 +758,7 @@ export function registerBinanceUsAllOrders(server: McpServer) { `• ${order.side} ${order.type} | Qty: ${order.origQty} @ ${order.price} | ` + `Status: ${order.status} | ID: ${order.orderId} | ${new Date(order.time).toISOString()}`, ) - .join("\n") + .join("\n"); return { content: [ @@ -771,14 +771,14 @@ export function registerBinanceUsAllOrders(server: McpServer) { `Full Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) - const codeMatch = errorMessage.match(/code:\s*(-?\d+)/) + const errorMessage = error instanceof Error ? error.message : String(error); + const codeMatch = errorMessage.match(/code:\s*(-?\d+)/); const additionalHelp = codeMatch && codeMatch[1] ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` - : "" + : ""; return { content: [ @@ -788,10 +788,10 @@ export function registerBinanceUsAllOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } /** @@ -807,60 +807,60 @@ function validateOrderParams(params: any): string | null { stopPrice, trailingDelta, icebergQty, - } = params + } = params; switch (type) { case "LIMIT": - if (!timeInForce) return "❌ LIMIT orders require timeInForce parameter." - if (!quantity) return "❌ LIMIT orders require quantity parameter." - if (!price) return "❌ LIMIT orders require price parameter." - break + if (!timeInForce) return "❌ LIMIT orders require timeInForce parameter."; + if (!quantity) return "❌ LIMIT orders require quantity parameter."; + if (!price) return "❌ LIMIT orders require price parameter."; + break; case "MARKET": if (!quantity && !quoteOrderQty) - return "❌ MARKET orders require either quantity or quoteOrderQty." - break + return "❌ MARKET orders require either quantity or quoteOrderQty."; + break; case "STOP_LOSS": - if (!quantity) return "❌ STOP_LOSS orders require quantity parameter." + if (!quantity) return "❌ STOP_LOSS orders require quantity parameter."; if (!stopPrice && !trailingDelta) - return "❌ STOP_LOSS orders require stopPrice or trailingDelta." - break + return "❌ STOP_LOSS orders require stopPrice or trailingDelta."; + break; case "STOP_LOSS_LIMIT": - if (!timeInForce) return "❌ STOP_LOSS_LIMIT orders require timeInForce parameter." - if (!quantity) return "❌ STOP_LOSS_LIMIT orders require quantity parameter." - if (!price) return "❌ STOP_LOSS_LIMIT orders require price parameter." + if (!timeInForce) return "❌ STOP_LOSS_LIMIT orders require timeInForce parameter."; + if (!quantity) return "❌ STOP_LOSS_LIMIT orders require quantity parameter."; + if (!price) return "❌ STOP_LOSS_LIMIT orders require price parameter."; if (!stopPrice && !trailingDelta) - return "❌ STOP_LOSS_LIMIT orders require stopPrice or trailingDelta." - break + return "❌ STOP_LOSS_LIMIT orders require stopPrice or trailingDelta."; + break; case "TAKE_PROFIT": - if (!quantity) return "❌ TAKE_PROFIT orders require quantity parameter." + if (!quantity) return "❌ TAKE_PROFIT orders require quantity parameter."; if (!stopPrice && !trailingDelta) - return "❌ TAKE_PROFIT orders require stopPrice or trailingDelta." - break + return "❌ TAKE_PROFIT orders require stopPrice or trailingDelta."; + break; case "TAKE_PROFIT_LIMIT": - if (!timeInForce) return "❌ TAKE_PROFIT_LIMIT orders require timeInForce parameter." - if (!quantity) return "❌ TAKE_PROFIT_LIMIT orders require quantity parameter." - if (!price) return "❌ TAKE_PROFIT_LIMIT orders require price parameter." + if (!timeInForce) return "❌ TAKE_PROFIT_LIMIT orders require timeInForce parameter."; + if (!quantity) return "❌ TAKE_PROFIT_LIMIT orders require quantity parameter."; + if (!price) return "❌ TAKE_PROFIT_LIMIT orders require price parameter."; if (!stopPrice && !trailingDelta) - return "❌ TAKE_PROFIT_LIMIT orders require stopPrice or trailingDelta." - break + return "❌ TAKE_PROFIT_LIMIT orders require stopPrice or trailingDelta."; + break; case "LIMIT_MAKER": - if (!quantity) return "❌ LIMIT_MAKER orders require quantity parameter." - if (!price) return "❌ LIMIT_MAKER orders require price parameter." - break + if (!quantity) return "❌ LIMIT_MAKER orders require quantity parameter."; + if (!price) return "❌ LIMIT_MAKER orders require price parameter."; + break; } // Iceberg order validation if (icebergQty && timeInForce !== "GTC") { - return "❌ Iceberg orders must have timeInForce set to GTC." + return "❌ Iceberg orders must have timeInForce set to GTC."; } - return null + return null; } /** @@ -881,19 +881,19 @@ export function registerBinanceUsCancelAllOpenOrders(server: McpServer) { async (params) => { try { // Check API credentials first - const credError = checkCredentials() - if (credError) return { content: [{ type: "text", text: credError }], isError: true } + const credError = checkCredentials(); + if (credError) return { content: [{ type: "text", text: credError }], isError: true }; // Validate symbol - const symbolError = validateSymbol(params.symbol) - if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true } + const symbolError = validateSymbol(params.symbol); + if (symbolError) return { content: [{ type: "text", text: symbolError }], isError: true }; // Validate recvWindow - const recvWindowError = validateRecvWindow(params.recvWindow) + const recvWindowError = validateRecvWindow(params.recvWindow); if (recvWindowError) - return { content: [{ type: "text", text: recvWindowError }], isError: true } + return { content: [{ type: "text", text: recvWindowError }], isError: true }; - const response = await makeSignedRequest("DELETE", "/api/v3/openOrders", params) + const response = await makeSignedRequest("DELETE", "/api/v3/openOrders", params); if (!response || response.length === 0) { return { @@ -903,7 +903,7 @@ export function registerBinanceUsCancelAllOpenOrders(server: McpServer) { text: `📋 No open orders found to cancel for ${params.symbol}`, }, ], - } + }; } const cancelledList = response @@ -912,7 +912,7 @@ export function registerBinanceUsCancelAllOpenOrders(server: McpServer) { `• Order ID: ${order.orderId} | ${order.side} ${order.type} | ` + `Qty: ${order.origQty} @ ${order.price} | Status: ${order.status}`, ) - .join("\n") + .join("\n"); return { content: [ @@ -924,14 +924,14 @@ export function registerBinanceUsCancelAllOpenOrders(server: McpServer) { `Full Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) - const codeMatch = errorMessage.match(/code:\s*(-?\d+)/) + const errorMessage = error instanceof Error ? error.message : String(error); + const codeMatch = errorMessage.match(/code:\s*(-?\d+)/); const additionalHelp = codeMatch && codeMatch[1] ? `\n\nHint: ${getBinanceErrorMessage(parseInt(codeMatch[1]))}` - : "" + : ""; return { content: [ @@ -941,22 +941,22 @@ export function registerBinanceUsCancelAllOpenOrders(server: McpServer) { }, ], isError: true, - } + }; } }, - ) + ); } /** * Register all standard order tools */ export function registerBinanceUsOrderTools(server: McpServer) { - registerBinanceUsNewOrder(server) - registerBinanceUsTestOrder(server) - registerBinanceUsGetOrder(server) - registerBinanceUsCancelOrder(server) - registerBinanceUsCancelReplace(server) - registerBinanceUsCancelAllOpenOrders(server) - registerBinanceUsOpenOrders(server) - registerBinanceUsAllOrders(server) + registerBinanceUsNewOrder(server); + registerBinanceUsTestOrder(server); + registerBinanceUsGetOrder(server); + registerBinanceUsCancelOrder(server); + registerBinanceUsCancelReplace(server); + registerBinanceUsCancelAllOpenOrders(server); + registerBinanceUsOpenOrders(server); + registerBinanceUsAllOrders(server); } diff --git a/src/tools/userdata-stream/index.ts b/src/tools/userdata-stream/index.ts index 9a80a953..c5aa9815 100644 --- a/src/tools/userdata-stream/index.ts +++ b/src/tools/userdata-stream/index.ts @@ -2,11 +2,11 @@ // User Data Stream management for real-time account updates // These endpoints manage listen keys for WebSocket user data streams -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { BINANCE_US_CONFIG, makeSignedRequest } from "../../config/binanceUsClient.js" +import { BINANCE_US_CONFIG, makeSignedRequest } from "../../config/binanceUsClient.js"; /** * Register User Data Stream tools for Binance.US @@ -52,7 +52,7 @@ This endpoint requires API key but does NOT require signature.`, try { // This endpoint only requires API key, not signature // But we use makeSignedRequest since it adds the API key header - const response = await makeSignedRequest("POST", "/api/v3/userDataStream", {}) + const response = await makeSignedRequest("POST", "/api/v3/userDataStream", {}); return { content: [ @@ -72,17 +72,17 @@ WebSocket URL: ${BINANCE_US_CONFIG.WS_URL}/ws/${response.listenKey} Response: ${JSON.stringify(response, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to create listen key: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // PUT /api/v3/userDataStream - Keep-alive Listen Key @@ -102,7 +102,7 @@ This endpoint requires API key but does NOT require signature.`, }, async ({ listenKey }) => { try { - await makeSignedRequest("PUT", "/api/v3/userDataStream", { listenKey }) + await makeSignedRequest("PUT", "/api/v3/userDataStream", { listenKey }); return { content: [ @@ -116,17 +116,17 @@ New expiration: 60 minutes from now Remember to call this again in 30 minutes to maintain the connection.`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to extend listen key: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // DELETE /api/v3/userDataStream - Close Listen Key @@ -144,7 +144,7 @@ This endpoint requires API key but does NOT require signature.`, }, async ({ listenKey }) => { try { - await makeSignedRequest("DELETE", "/api/v3/userDataStream", { listenKey }) + await makeSignedRequest("DELETE", "/api/v3/userDataStream", { listenKey }); return { content: [ @@ -158,17 +158,17 @@ Listen Key ${listenKey} is no longer valid. To receive real-time updates again, create a new listen key.`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to close listen key: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================================== // Informational tool about WebSocket streams @@ -224,7 +224,7 @@ Returns details about: maxStreamsPerConnection: 1024, messageLimit: "5 messages per second per connection", }, - } + }; return { content: [ @@ -233,7 +233,7 @@ Returns details about: text: `Binance.US WebSocket Information:\n\n${JSON.stringify(info, null, 2)}`, }, ], - } + }; }, - ) + ); } diff --git a/src/tools/wallet/index.ts b/src/tools/wallet/index.ts index a0cbec03..5e77cbe9 100644 --- a/src/tools/wallet/index.ts +++ b/src/tools/wallet/index.ts @@ -1,9 +1,9 @@ // src/tools/wallet/index.ts -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { z } from "zod" +import { z } from "zod"; -import { makeSignedRequest } from "../../config/binanceUsClient.js" +import { makeSignedRequest } from "../../config/binanceUsClient.js"; /** * Register all Wallet-related tools for Binance.US @@ -29,10 +29,10 @@ export function registerWalletTools(server: McpServer) { }, async ({ recvWindow }) => { try { - const params: Record = {} - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = {}; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await makeSignedRequest("GET", "/sapi/v1/capital/config/getall", params) + const data = await makeSignedRequest("GET", "/sapi/v1/capital/config/getall", params); return { content: [ @@ -41,17 +41,17 @@ export function registerWalletTools(server: McpServer) { text: `Asset Configuration:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get asset config: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================== // binance_us_withdraw_crypto @@ -83,12 +83,12 @@ export function registerWalletTools(server: McpServer) { network, address, amount, - } - if (addressTag !== undefined) params.addressTag = addressTag - if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId - if (recvWindow !== undefined) params.recvWindow = recvWindow + }; + if (addressTag !== undefined) params.addressTag = addressTag; + if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await makeSignedRequest("POST", "/sapi/v1/capital/withdraw/apply", params) + const data = await makeSignedRequest("POST", "/sapi/v1/capital/withdraw/apply", params); return { content: [ @@ -97,17 +97,17 @@ export function registerWalletTools(server: McpServer) { text: `Withdrawal request submitted successfully!\nWithdrawal ID: ${data.id}\nCoin: ${coin}\nAmount: ${amount}\nNetwork: ${network}\nAddress: ${address}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to submit withdrawal: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================== // binance_us_withdraw_fiat @@ -133,10 +133,10 @@ export function registerWalletTools(server: McpServer) { paymentAccount, amount, fiatCurrency: fiatCurrency || "USD", - } - if (recvWindow !== undefined) params.recvWindow = recvWindow + }; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await makeSignedRequest("POST", "/sapi/v1/fiatpayment/withdraw/apply", params) + const data = await makeSignedRequest("POST", "/sapi/v1/fiatpayment/withdraw/apply", params); return { content: [ @@ -145,17 +145,17 @@ export function registerWalletTools(server: McpServer) { text: `Fiat withdrawal submitted!\nOrder ID: ${data.orderId}\nChannel: ${data.channelCode}\nAmount: ${data.amount} ${data.currencyCode}\nStatus: ${data.orderStatus}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to submit fiat withdrawal: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================== // binance_us_withdraw_history @@ -181,17 +181,17 @@ export function registerWalletTools(server: McpServer) { }, async ({ coin, withdrawOrderId, status, startTime, endTime, offset, limit, recvWindow }) => { try { - const params: Record = {} - if (coin !== undefined) params.coin = coin - if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId - if (status !== undefined) params.status = status - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (offset !== undefined) params.offset = offset - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = {}; + if (coin !== undefined) params.coin = coin; + if (withdrawOrderId !== undefined) params.withdrawOrderId = withdrawOrderId; + if (status !== undefined) params.status = status; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (offset !== undefined) params.offset = offset; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await makeSignedRequest("GET", "/sapi/v1/capital/withdraw/history", params) + const data = await makeSignedRequest("GET", "/sapi/v1/capital/withdraw/history", params); return { content: [ @@ -200,17 +200,17 @@ export function registerWalletTools(server: McpServer) { text: `Withdrawal History:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get withdrawal history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================== // binance_us_deposit_history @@ -233,16 +233,16 @@ export function registerWalletTools(server: McpServer) { }, async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { try { - const params: Record = {} - if (coin !== undefined) params.coin = coin - if (status !== undefined) params.status = status - if (startTime !== undefined) params.startTime = startTime - if (endTime !== undefined) params.endTime = endTime - if (offset !== undefined) params.offset = offset - if (limit !== undefined) params.limit = limit - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = {}; + if (coin !== undefined) params.coin = coin; + if (status !== undefined) params.status = status; + if (startTime !== undefined) params.startTime = startTime; + if (endTime !== undefined) params.endTime = endTime; + if (offset !== undefined) params.offset = offset; + if (limit !== undefined) params.limit = limit; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await makeSignedRequest("GET", "/sapi/v1/capital/deposit/hisrec", params) + const data = await makeSignedRequest("GET", "/sapi/v1/capital/deposit/hisrec", params); return { content: [ @@ -251,17 +251,17 @@ export function registerWalletTools(server: McpServer) { text: `Deposit History:\n${JSON.stringify(data, null, 2)}`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get deposit history: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); // ===================================================== // binance_us_deposit_address @@ -280,11 +280,11 @@ export function registerWalletTools(server: McpServer) { }, async ({ coin, network, recvWindow }) => { try { - const params: Record = { coin } - if (network !== undefined) params.network = network - if (recvWindow !== undefined) params.recvWindow = recvWindow + const params: Record = { coin }; + if (network !== undefined) params.network = network; + if (recvWindow !== undefined) params.recvWindow = recvWindow; - const data = await makeSignedRequest("GET", "/sapi/v1/capital/deposit/address", params) + const data = await makeSignedRequest("GET", "/sapi/v1/capital/deposit/address", params); return { content: [ @@ -293,15 +293,15 @@ export function registerWalletTools(server: McpServer) { text: `Deposit Address for ${coin}:\nAddress: ${data.address}\nTag/Memo: ${data.tag || "N/A"}\nURL: ${data.url || "N/A"}\n\n⚠️ Only send ${coin} to this address. Sending other assets may result in permanent loss.`, }, ], - } + }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error) + const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Failed to get deposit address: ${errorMessage}` }], isError: true, - } + }; } }, - ) + ); } diff --git a/src/utils/json.ts b/src/utils/json.ts new file mode 100644 index 00000000..da9b4ecd --- /dev/null +++ b/src/utils/json.ts @@ -0,0 +1,3 @@ +export function safeJsonStringify(value: unknown): string { + return JSON.stringify(value, (_key, v) => (typeof v === "bigint" ? v.toString() : v)); +} diff --git a/src/utils/logger.ts b/src/utils/logger.ts index 83fa542c..3c1783d3 100644 --- a/src/utils/logger.ts +++ b/src/utils/logger.ts @@ -1,48 +1,48 @@ // src/utils/logger.ts -type LogLevel = "DEBUG" | "INFO" | "WARN" | "ERROR" +type LogLevel = "DEBUG" | "INFO" | "WARN" | "ERROR"; const LOG_LEVELS: Record = { DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, -} +}; -const currentLevel = (process.env.LOG_LEVEL as LogLevel) || "INFO" +const currentLevel = (process.env.LOG_LEVEL as LogLevel) || "INFO"; function shouldLog(level: LogLevel): boolean { - return LOG_LEVELS[level] >= LOG_LEVELS[currentLevel] + return LOG_LEVELS[level] >= LOG_LEVELS[currentLevel]; } function formatMessage(level: LogLevel, message: string, ...args: unknown[]): string { - const timestamp = new Date().toISOString() - const formattedArgs = args.length > 0 ? " " + args.map((a) => JSON.stringify(a)).join(" ") : "" + const timestamp = new Date().toISOString(); + const formattedArgs = args.length > 0 ? " " + args.map((a) => JSON.stringify(a)).join(" ") : ""; - return `[${timestamp}] [${level}] ${message}${formattedArgs}` + return `[${timestamp}] [${level}] ${message}${formattedArgs}`; } const Logger = { debug: (message: string, ...args: unknown[]) => { if (shouldLog("DEBUG")) { - console.debug(formatMessage("DEBUG", message, ...args)) + console.debug(formatMessage("DEBUG", message, ...args)); } }, info: (message: string, ...args: unknown[]) => { if (shouldLog("INFO")) { - console.info(formatMessage("INFO", message, ...args)) + console.info(formatMessage("INFO", message, ...args)); } }, warn: (message: string, ...args: unknown[]) => { if (shouldLog("WARN")) { - console.warn(formatMessage("WARN", message, ...args)) + console.warn(formatMessage("WARN", message, ...args)); } }, error: (message: string, ...args: unknown[]) => { if (shouldLog("ERROR")) { - console.error(formatMessage("ERROR", message, ...args)) + console.error(formatMessage("ERROR", message, ...args)); } }, -} +}; -export default Logger +export default Logger; From 0c4587abdcd3d1e2ec422dd8a926543db1cf140e Mon Sep 17 00:00:00 2001 From: netpoe Date: Mon, 16 Mar 2026 14:00:26 -0600 Subject: [PATCH 05/16] feat: implement Streamable HTTP server, replacing deprecated SSE transport, and add logging for tool calls and results --- src/server/sse.ts | 76 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 74 insertions(+), 2 deletions(-) diff --git a/src/server/sse.ts b/src/server/sse.ts index db4a79b4..1178b1ba 100644 --- a/src/server/sse.ts +++ b/src/server/sse.ts @@ -13,6 +13,77 @@ import "dotenv/config"; const PORT = process.env.PORT || 3002; +/** + * How tool `content` flows when the SSE server runs a tool: + * + * 1. Tool handler (e.g. getAccount.ts) returns { content: [{ type: "text", text: "..." }] }. + * 2. McpServer (SDK) CallTool request handler runs the handler and returns that object. + * 3. Server (SDK) validates it as CallToolResult and returns it from the tools/call handler. + * 4. Protocol (SDK) puts it in response.result and calls transport.send({ jsonrpc, id, result }). + * 5. SSEServerTransport.send() writes the JSON to the SSE stream (event: message, data: ...). + * + * This wrapper logs every tools/call request and every tool result content when using SSE. + */ +function wrapTransportWithToolLogging(transport: SSEServerTransport) { + const pendingToolCalls = new Map(); + + return { + get sessionId() { + return transport.sessionId; + }, + get onmessage() { + return transport.onmessage; + }, + set onmessage(handler: typeof transport.onmessage) { + transport.onmessage = handler; + }, + get onclose() { + return transport.onclose; + }, + set onclose(handler: typeof transport.onclose) { + transport.onclose = handler; + }, + get onerror() { + return transport.onerror; + }, + set onerror(handler: typeof transport.onerror) { + transport.onerror = handler; + }, + async start() { + return transport.start(); + }, + async close() { + return transport.close(); + }, + async send(message: Parameters[0]) { + const msg = message as { id?: string | number; result?: { content?: unknown } }; + if (msg?.result && msg.result.content !== undefined) { + const toolName = pendingToolCalls.get(msg.id as string | number); + + console.log( + "[MCP SSE] tool result content", + toolName !== undefined ? `(tool: ${toolName})` : "", + JSON.stringify(msg.result.content), + ); + if (msg.id !== undefined) pendingToolCalls.delete(msg.id); + } + + return transport.send(message); + }, + async handlePostMessage(req: express.Request, res: express.Response, parsedBody?: unknown) { + const body = parsedBody ?? (req as express.Request & { body?: unknown }).body; + const parsed = typeof body === "string" ? JSON.parse(body as string) : body; + + if (parsed?.method === "tools/call" && parsed.params) { + console.log("[MCP SSE] tools/call request", parsed.params.name, parsed.params.arguments); + if (parsed.id !== undefined) pendingToolCalls.set(parsed.id, parsed.params.name); + } + + return transport.handlePostMessage(req, res, parsedBody ?? body); + }, + }; +} + // Start the server in SSE mode export const startSSEServer = async (): Promise => { try { @@ -21,12 +92,13 @@ export const startSSEServer = async (): Promise => { app.use(express.json()); // Store active transports and their associated server instances - const transports = new Map(); + const transports = new Map>(); // SSE endpoint — each connection gets its own McpServer instance app.get("/sse", async (req, res) => { const server = startServer(); - const transport = new SSEServerTransport("/message", res); + const rawTransport = new SSEServerTransport("/message", res); + const transport = wrapTransportWithToolLogging(rawTransport); Logger.info(`New SSE connection: ${transport.sessionId}`); transports.set(transport.sessionId, transport); From aa7d92b17355bde3d69bcf7fbf5e376968da037e Mon Sep 17 00:00:00 2001 From: netpoe Date: Mon, 16 Mar 2026 14:01:15 -0600 Subject: [PATCH 06/16] feat: enhance Streamable HTTP server implementation with improved request handling, logging, and session management --- src/server/sse.ts | 115 ++++++++++++++++++++++++++++------------------ 1 file changed, 70 insertions(+), 45 deletions(-) diff --git a/src/server/sse.ts b/src/server/sse.ts index 1178b1ba..a4a41214 100644 --- a/src/server/sse.ts +++ b/src/server/sse.ts @@ -1,8 +1,12 @@ +import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js"; import type { Server } from "http"; +import type { IncomingMessage, ServerResponse } from "node:http"; -import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js"; +import { randomUUID } from "node:crypto"; + +import { createMcpExpressApp } from "@modelcontextprotocol/sdk/server/express.js"; +import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js"; import cors from "cors"; -import express from "express"; import Logger from "../utils/logger.js"; @@ -13,18 +17,25 @@ import "dotenv/config"; const PORT = process.env.PORT || 3002; +/** Transport + Streamable HTTP handleRequest for routing and logging. */ +type StreamableTransportWithHandle = Transport & { + handleRequest(req: IncomingMessage, res: ServerResponse, parsedBody?: unknown): Promise; +}; + /** - * How tool `content` flows when the SSE server runs a tool: + * How tool `content` flows when the Streamable HTTP server runs a tool: * * 1. Tool handler (e.g. getAccount.ts) returns { content: [{ type: "text", text: "..." }] }. * 2. McpServer (SDK) CallTool request handler runs the handler and returns that object. * 3. Server (SDK) validates it as CallToolResult and returns it from the tools/call handler. * 4. Protocol (SDK) puts it in response.result and calls transport.send({ jsonrpc, id, result }). - * 5. SSEServerTransport.send() writes the JSON to the SSE stream (event: message, data: ...). + * 5. StreamableHTTPServerTransport.send() writes the JSON to the response/SSE stream. * - * This wrapper logs every tools/call request and every tool result content when using SSE. + * This wrapper logs every tools/call request and every tool result content. */ -function wrapTransportWithToolLogging(transport: SSEServerTransport) { +function wrapTransportWithToolLogging( + transport: StreamableHTTPServerTransport, +): StreamableTransportWithHandle { const pendingToolCalls = new Map(); return { @@ -55,90 +66,104 @@ function wrapTransportWithToolLogging(transport: SSEServerTransport) { async close() { return transport.close(); }, - async send(message: Parameters[0]) { + async send( + message: Parameters[0], + options?: Parameters[1], + ) { const msg = message as { id?: string | number; result?: { content?: unknown } }; if (msg?.result && msg.result.content !== undefined) { const toolName = pendingToolCalls.get(msg.id as string | number); console.log( - "[MCP SSE] tool result content", + "[MCP Streamable HTTP] tool result content", toolName !== undefined ? `(tool: ${toolName})` : "", JSON.stringify(msg.result.content), ); if (msg.id !== undefined) pendingToolCalls.delete(msg.id); } - return transport.send(message); + return transport.send(message, options); }, - async handlePostMessage(req: express.Request, res: express.Response, parsedBody?: unknown) { - const body = parsedBody ?? (req as express.Request & { body?: unknown }).body; + async handleRequest(req: IncomingMessage, res: ServerResponse, parsedBody?: unknown) { + const body = parsedBody ?? (req as IncomingMessage & { body?: unknown }).body; const parsed = typeof body === "string" ? JSON.parse(body as string) : body; if (parsed?.method === "tools/call" && parsed.params) { - console.log("[MCP SSE] tools/call request", parsed.params.name, parsed.params.arguments); + console.log( + "[MCP Streamable HTTP] tools/call request", + parsed.params.name, + parsed.params.arguments, + ); if (parsed.id !== undefined) pendingToolCalls.set(parsed.id, parsed.params.name); } - return transport.handlePostMessage(req, res, parsedBody ?? body); + return transport.handleRequest(req, res, parsedBody ?? body); }, }; } -// Start the server in SSE mode +interface SessionEntry { + transport: StreamableTransportWithHandle; + server: Awaited>; +} + +// Start the server in Streamable HTTP mode (replaces deprecated SSE transport) export const startSSEServer = async (): Promise => { try { - const app = express(); + const app = createMcpExpressApp(); app.use(cors()); - app.use(express.json()); - // Store active transports and their associated server instances - const transports = new Map>(); + const sessions = new Map(); - // SSE endpoint — each connection gets its own McpServer instance - app.get("/sse", async (req, res) => { + const createNewSession = (): SessionEntry => { const server = startServer(); - const rawTransport = new SSEServerTransport("/message", res); - const transport = wrapTransportWithToolLogging(rawTransport); - - Logger.info(`New SSE connection: ${transport.sessionId}`); - transports.set(transport.sessionId, transport); - - res.on("close", async () => { - Logger.info(`SSE connection closed: ${transport.sessionId}`); - transports.delete(transport.sessionId); - await server.close(); + const rawTransport = new StreamableHTTPServerTransport({ + sessionIdGenerator: () => randomUUID(), + onsessioninitialized: (sessionId) => { + sessions.set(sessionId, { transport, server }); + Logger.info(`Streamable HTTP session initialized: ${sessionId}`); + }, + onsessionclosed: (sessionId) => { + const entry = sessions.get(sessionId); + if (entry) { + sessions.delete(sessionId); + entry.server.close().catch(() => {}); + Logger.info(`Streamable HTTP session closed: ${sessionId}`); + } + }, }); + const transport = wrapTransportWithToolLogging(rawTransport); - await server.connect(transport); - }); - - // Message endpoint - app.post("/message", async (req, res) => { - const sessionId = req.query.sessionId as string; - const transport = transports.get(sessionId); + return { transport, server }; + }; - if (!transport) { - res.status(404).json({ error: "Session not found" }); + // Single endpoint for Streamable HTTP (GET for SSE, POST for JSON-RPC) + app.all("/mcp", async (req, res) => { + const sessionId = + req.get("mcp-session-id") ?? (req.headers["mcp-session-id"] as string | undefined); + let entry: SessionEntry | undefined = sessionId ? sessions.get(sessionId) : undefined; - return; + if (!entry) { + entry = createNewSession(); + await entry.server.connect(entry.transport); } - await transport.handlePostMessage(req, res); + await entry.transport.handleRequest(req, res, req.body); }); // Health check app.get("/health", (req, res) => { - res.json({ status: "ok", mode: "sse" }); + res.json({ status: "ok", mode: "streamable-http" }); }); const httpServer = app.listen(PORT, () => { - Logger.info(`Binance MCP Server running on SSE mode at http://localhost:${PORT}`); - Logger.info(`SSE endpoint: http://localhost:${PORT}/sse`); + Logger.info(`Binance MCP Server running in Streamable HTTP mode at http://localhost:${PORT}`); + Logger.info(`MCP endpoint: http://localhost:${PORT}/mcp`); }); return httpServer; } catch (error) { - Logger.error("Error starting Binance MCP SSE server:", error); + Logger.error("Error starting Binance MCP Streamable HTTP server:", error); return undefined; } From 390224464a57a75d77bf6e3bc44e012b2076fb27 Mon Sep 17 00:00:00 2001 From: netpoe Date: Mon, 16 Mar 2026 14:40:51 -0600 Subject: [PATCH 07/16] feat: update Binance API tools with enhanced parameter handling, improved error messages, and refined request validation --- package.json | 3 ++- src/modules/spot/account-api/getAccount.ts | 7 +++-- src/modules/spot/general-api/exchangeInfo.ts | 23 ++++++++++++---- src/modules/spot/trade-api/newOrder.ts | 26 +++++++++++++----- src/server/sse.ts | 18 +++++++++---- .../binance-spot/account-api/getAccount.ts | 22 ++++++++------- .../binance-spot/general-api/exchangeInfo.ts | 27 ++++++++++++++----- src/tools/binance-spot/trade-api/newOrder.ts | 26 +++++++++++++----- 8 files changed, 109 insertions(+), 43 deletions(-) diff --git a/package.json b/package.json index 232f8726..b7f33993 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "dev:sse": "bun --watch src/index.ts --sse", "build": "tsc", "init": "bun src/init.ts", - "test": "bunx @modelcontextprotocol/inspector bun src/index.ts", + "test": "bunx @modelcontextprotocol/inspector bun src/index.ts --sse", + "test:stdio": "bunx @modelcontextprotocol/inspector bun src/index.ts", "lint": "eslint src/", "lint:fix": "eslint src/ --fix", "format": "prettier --write \"src/**/*.ts\"", diff --git a/src/modules/spot/account-api/getAccount.ts b/src/modules/spot/account-api/getAccount.ts index d0db5720..0549a33f 100644 --- a/src/modules/spot/account-api/getAccount.ts +++ b/src/modules/spot/account-api/getAccount.ts @@ -1,10 +1,9 @@ -// src/tools/binance-spot/account-api/getAccount.ts import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; +import { JSONStringify } from "json-with-bigint"; import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; -import { safeJsonStringify } from "../../../utils/json.js"; export function registerBinanceGetAccount(server: McpServer) { server.tool( @@ -26,7 +25,7 @@ export function registerBinanceGetAccount(server: McpServer) { content: [ { type: "text", - text: `Retrieved account information. Account contains ${data.balances?.length || 0} balances. Response: ${safeJsonStringify(data)}`, + text: `Retrieved account information. Account contains ${data.balances?.length || 0} balances. Response: ${JSONStringify(data)}`, }, ], }; @@ -35,7 +34,7 @@ export function registerBinanceGetAccount(server: McpServer) { return { content: [ - { type: "text", text: `Failed to retrieve account information: ${errorMessage}` }, + { type: "text", text: `Failedddd to retrieve account information: ${errorMessage}` }, ], isError: true, }; diff --git a/src/modules/spot/general-api/exchangeInfo.ts b/src/modules/spot/general-api/exchangeInfo.ts index 33b2abcb..4bcb0c1d 100644 --- a/src/modules/spot/general-api/exchangeInfo.ts +++ b/src/modules/spot/general-api/exchangeInfo.ts @@ -10,17 +10,30 @@ export function registerBinanceExchangeInfo(server: McpServer) { "BinanceExchangeInfo", "Get exchange information including rate limits, symbol configs, etc.", { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - symbols: z.array(z.string()).optional().describe("Array of symbols to get info for"), + symbol: z + .string() + .optional() + .describe( + "Single trading pair in UPPERCASE, no separators (e.g. BTCUSDT, SOLUSDT). Use this for one pair; do not use both symbol and symbols.", + ), + symbols: z + .array(z.string()) + .optional() + .describe( + 'Multiple pairs as array; each symbol UPPERCASE (e.g. ["BTCUSDT","ETHUSDT"]). Do not use with symbol.', + ), permissions: z.array(z.string()).optional().describe("Array of permissions to filter by"), }, async ({ symbol, symbols, permissions }) => { try { const params: any = {}; - if (symbol) params.symbol = symbol; - if (symbols) params.symbols = symbols; - if (permissions) params.permissions = permissions; + if (symbol) params.symbol = symbol.toUpperCase(); + if (symbols?.length) { + params.symbols = JSON.stringify(symbols.map((s) => s.toUpperCase())); + } + if (permissions?.length && !params.symbol && !params.symbols) + params.permissions = permissions; const response = await spotClient.restAPI.exchangeInfo(params); diff --git a/src/modules/spot/trade-api/newOrder.ts b/src/modules/spot/trade-api/newOrder.ts index c61a2350..4e5ccca9 100644 --- a/src/modules/spot/trade-api/newOrder.ts +++ b/src/modules/spot/trade-api/newOrder.ts @@ -5,6 +5,11 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; +/** Binance allows only [a-zA-Z0-9-_], max 36 chars. */ +function sanitizeNewClientOrderId(value: string): string { + return value.replace(/[^a-zA-Z0-9-_]/g, "").slice(0, 36); +} + export function registerBinanceNewOrder(server: McpServer) { server.tool( "BinanceNewOrder", @@ -27,7 +32,10 @@ export function registerBinanceNewOrder(server: McpServer) { quantity: z.number().describe("Order quantity"), quoteOrderQty: z.number().optional().describe("Quote order quantity"), price: z.number().optional().describe("Order price"), - newClientOrderId: z.string().optional().describe("Client order ID"), + newClientOrderId: z + .string() + .optional() + .describe("Client order ID: only a-zA-Z0-9-_ allowed, max 36 chars"), stopPrice: z.number().optional().describe("Stop price"), icebergQty: z.number().optional().describe("Iceberg quantity"), newOrderRespType: z.enum(["ACK", "RESULT", "FULL"]).optional().describe("Response type"), @@ -53,11 +61,17 @@ export function registerBinanceNewOrder(server: McpServer) { quantity, }; - if (timeInForce) params.timeInForce = timeInForce; - if (quoteOrderQty !== undefined) params.quoteOrderQty = quoteOrderQty; - if (price !== undefined) params.price = price; - if (newClientOrderId) params.newClientOrderId = newClientOrderId; - if (stopPrice !== undefined) params.stopPrice = stopPrice; + const timeInForceTypes = ["LIMIT", "STOP_LOSS_LIMIT", "TAKE_PROFIT_LIMIT", "LIMIT_MAKER"]; + if (timeInForce && timeInForceTypes.includes(type)) params.timeInForce = timeInForce; + if (type === "MARKET" && quoteOrderQty !== undefined) params.quoteOrderQty = quoteOrderQty; + const priceTypes = ["LIMIT", "STOP_LOSS_LIMIT", "TAKE_PROFIT_LIMIT", "LIMIT_MAKER"]; + if (price !== undefined && priceTypes.includes(type)) params.price = price; + if (newClientOrderId) { + const sanitized = sanitizeNewClientOrderId(newClientOrderId); + if (sanitized) params.newClientOrderId = sanitized; + } + const stopOrderTypes = ["STOP_LOSS", "STOP_LOSS_LIMIT", "TAKE_PROFIT", "TAKE_PROFIT_LIMIT"]; + if (stopPrice !== undefined && stopOrderTypes.includes(type)) params.stopPrice = stopPrice; if (icebergQty !== undefined) params.icebergQty = icebergQty; if (newOrderRespType) params.newOrderRespType = newOrderRespType; diff --git a/src/server/sse.ts b/src/server/sse.ts index a4a41214..51e9c9dc 100644 --- a/src/server/sse.ts +++ b/src/server/sse.ts @@ -1,4 +1,5 @@ import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js"; +import type { Request, Response } from "express"; import type { Server } from "http"; import type { IncomingMessage, ServerResponse } from "node:http"; @@ -127,7 +128,7 @@ export const startSSEServer = async (): Promise => { const entry = sessions.get(sessionId); if (entry) { sessions.delete(sessionId); - entry.server.close().catch(() => {}); + entry.server.close().catch(() => undefined); Logger.info(`Streamable HTTP session closed: ${sessionId}`); } }, @@ -137,8 +138,8 @@ export const startSSEServer = async (): Promise => { return { transport, server }; }; - // Single endpoint for Streamable HTTP (GET for SSE, POST for JSON-RPC) - app.all("/mcp", async (req, res) => { + // Streamable HTTP handler (GET for SSE, POST for JSON-RPC) + const handleMcpRequest = async (req: Request, res: Response) => { const sessionId = req.get("mcp-session-id") ?? (req.headers["mcp-session-id"] as string | undefined); let entry: SessionEntry | undefined = sessionId ? sessions.get(sessionId) : undefined; @@ -149,7 +150,14 @@ export const startSSEServer = async (): Promise => { } await entry.transport.handleRequest(req, res, req.body); - }); + }; + + // Primary endpoint (Streamable HTTP) + app.all("/mcp", handleMcpRequest); + // Alias for MCP Inspector and clients that default to /sse. + // Use transport type "streamable-http" in the inspector (not deprecated "sse") so the + // client sends POST initialize before GET; otherwise the server returns 400. + app.all("/sse", handleMcpRequest); // Health check app.get("/health", (req, res) => { @@ -158,7 +166,7 @@ export const startSSEServer = async (): Promise => { const httpServer = app.listen(PORT, () => { Logger.info(`Binance MCP Server running in Streamable HTTP mode at http://localhost:${PORT}`); - Logger.info(`MCP endpoint: http://localhost:${PORT}/mcp`); + Logger.info(`MCP endpoints: http://localhost:${PORT}/mcp and http://localhost:${PORT}/sse`); }); return httpServer; diff --git a/src/tools/binance-spot/account-api/getAccount.ts b/src/tools/binance-spot/account-api/getAccount.ts index d0db5720..5fb3ba53 100644 --- a/src/tools/binance-spot/account-api/getAccount.ts +++ b/src/tools/binance-spot/account-api/getAccount.ts @@ -1,10 +1,9 @@ -// src/tools/binance-spot/account-api/getAccount.ts import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; +import { JSONStringify } from "json-with-bigint"; import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; -import { safeJsonStringify } from "../../../utils/json.js"; export function registerBinanceGetAccount(server: McpServer) { server.tool( @@ -22,14 +21,17 @@ export function registerBinanceGetAccount(server: McpServer) { const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Retrieved account information. Account contains ${data.balances?.length || 0} balances. Response: ${safeJsonStringify(data)}`, - }, - ], - }; + // This `content` is the CallToolResult payload: it flows up through McpServer → Server → Protocol + // and is sent to the client via transport.send(). When using SSE, see server/sse.ts for logging. + const content = [ + { + type: "text" as const, + text: `Retrieved account information. Account contains ${data.balances?.length || 0} balances. Response: ${JSONStringify(data)}`, + }, + ]; + console.log("[MCP tool BinanceGetAccount] returning content (length)", content.length); + + return { content }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); diff --git a/src/tools/binance-spot/general-api/exchangeInfo.ts b/src/tools/binance-spot/general-api/exchangeInfo.ts index 33b2abcb..a54a5222 100644 --- a/src/tools/binance-spot/general-api/exchangeInfo.ts +++ b/src/tools/binance-spot/general-api/exchangeInfo.ts @@ -10,17 +10,32 @@ export function registerBinanceExchangeInfo(server: McpServer) { "BinanceExchangeInfo", "Get exchange information including rate limits, symbol configs, etc.", { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - symbols: z.array(z.string()).optional().describe("Array of symbols to get info for"), + symbol: z + .string() + .optional() + .describe( + "Single trading pair in UPPERCASE, no separators (e.g. BTCUSDT, SOLUSDT). Use this for one pair; do not use both symbol and symbols.", + ), + symbols: z + .array(z.string()) + .optional() + .describe( + 'Multiple pairs as array; each symbol UPPERCASE (e.g. ["BTCUSDT","ETHUSDT"]). Do not use with symbol.', + ), permissions: z.array(z.string()).optional().describe("Array of permissions to filter by"), }, async ({ symbol, symbols, permissions }) => { try { - const params: any = {}; + const params: Record = {}; - if (symbol) params.symbol = symbol; - if (symbols) params.symbols = symbols; - if (permissions) params.permissions = permissions; + if (symbol) params.symbol = symbol.toUpperCase(); + if (symbols?.length) { + // Binance expects symbols as a JSON string; symbols must be UPPERCASE (legal range: [^a-z]). + params.symbols = JSON.stringify(symbols.map((s) => s.toUpperCase())); + } + // Only send permissions when not filtering by symbol(s); API rejects "permissions" when symbol/symbols are present. + if (permissions?.length && !params.symbol && !params.symbols) + params.permissions = permissions; const response = await spotClient.restAPI.exchangeInfo(params); diff --git a/src/tools/binance-spot/trade-api/newOrder.ts b/src/tools/binance-spot/trade-api/newOrder.ts index c61a2350..4e5ccca9 100644 --- a/src/tools/binance-spot/trade-api/newOrder.ts +++ b/src/tools/binance-spot/trade-api/newOrder.ts @@ -5,6 +5,11 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; +/** Binance allows only [a-zA-Z0-9-_], max 36 chars. */ +function sanitizeNewClientOrderId(value: string): string { + return value.replace(/[^a-zA-Z0-9-_]/g, "").slice(0, 36); +} + export function registerBinanceNewOrder(server: McpServer) { server.tool( "BinanceNewOrder", @@ -27,7 +32,10 @@ export function registerBinanceNewOrder(server: McpServer) { quantity: z.number().describe("Order quantity"), quoteOrderQty: z.number().optional().describe("Quote order quantity"), price: z.number().optional().describe("Order price"), - newClientOrderId: z.string().optional().describe("Client order ID"), + newClientOrderId: z + .string() + .optional() + .describe("Client order ID: only a-zA-Z0-9-_ allowed, max 36 chars"), stopPrice: z.number().optional().describe("Stop price"), icebergQty: z.number().optional().describe("Iceberg quantity"), newOrderRespType: z.enum(["ACK", "RESULT", "FULL"]).optional().describe("Response type"), @@ -53,11 +61,17 @@ export function registerBinanceNewOrder(server: McpServer) { quantity, }; - if (timeInForce) params.timeInForce = timeInForce; - if (quoteOrderQty !== undefined) params.quoteOrderQty = quoteOrderQty; - if (price !== undefined) params.price = price; - if (newClientOrderId) params.newClientOrderId = newClientOrderId; - if (stopPrice !== undefined) params.stopPrice = stopPrice; + const timeInForceTypes = ["LIMIT", "STOP_LOSS_LIMIT", "TAKE_PROFIT_LIMIT", "LIMIT_MAKER"]; + if (timeInForce && timeInForceTypes.includes(type)) params.timeInForce = timeInForce; + if (type === "MARKET" && quoteOrderQty !== undefined) params.quoteOrderQty = quoteOrderQty; + const priceTypes = ["LIMIT", "STOP_LOSS_LIMIT", "TAKE_PROFIT_LIMIT", "LIMIT_MAKER"]; + if (price !== undefined && priceTypes.includes(type)) params.price = price; + if (newClientOrderId) { + const sanitized = sanitizeNewClientOrderId(newClientOrderId); + if (sanitized) params.newClientOrderId = sanitized; + } + const stopOrderTypes = ["STOP_LOSS", "STOP_LOSS_LIMIT", "TAKE_PROFIT", "TAKE_PROFIT_LIMIT"]; + if (stopPrice !== undefined && stopOrderTypes.includes(type)) params.stopPrice = stopPrice; if (icebergQty !== undefined) params.icebergQty = icebergQty; if (newOrderRespType) params.newOrderRespType = newOrderRespType; From 490cddc1d6c53f9bf4fdf189d895d68af8a762ce Mon Sep 17 00:00:00 2001 From: netpoe Date: Mon, 16 Mar 2026 14:54:33 -0600 Subject: [PATCH 08/16] feat: introduce codemod script to replace deprecated server.tool(...) calls with server.registerTool(...) for improved API consistency --- scripts/codemod-register-tool.mjs | 183 ++++++++++ src/modules/algo/future-algo/TwapNewTrade.ts | 81 ++--- src/modules/algo/future-algo/VPNewTrade.ts | 71 ++-- .../algo/future-algo/cancelAlgoOrder.ts | 11 +- .../algo/future-algo/currentAlgoOpenOrders.ts | 9 +- .../algo/future-algo/historicalAlgoOrder.ts | 51 +-- src/modules/algo/future-algo/subOrders.ts | 29 +- .../algo/spot-algo/cancelOpenTWAPOrder.ts | 11 +- .../algo/spot-algo/currentAlgoOpenOrders.ts | 9 +- .../algo/spot-algo/historicalAlgoOrders.ts | 51 +-- src/modules/algo/spot-algo/spotTWAPOrder.ts | 59 ++-- src/modules/algo/spot-algo/subOrders.ts | 29 +- src/modules/auto-invest/changePlanStatus.ts | 16 +- src/modules/auto-invest/createPlan.ts | 56 +-- src/modules/auto-invest/editPlan.ts | 54 +-- src/modules/auto-invest/getHistoryList.ts | 40 +-- src/modules/auto-invest/getIndexInfo.ts | 11 +- .../getIndexLinkedPlanPositionDetails.ts | 11 +- .../auto-invest/getIndexUserSummary.ts | 10 +- src/modules/auto-invest/getPlanList.ts | 16 +- src/modules/auto-invest/getSourceAssetList.ts | 23 +- src/modules/auto-invest/getTargetAssetList.ts | 30 +- .../auto-invest/getTargetAssetRoiData.ts | 17 +- src/modules/auto-invest/oneTimeTransaction.ts | 42 ++- src/modules/auto-invest/rebalanceHistory.ts | 29 +- src/modules/auto-invest/redemption.ts | 12 +- src/modules/c2c/C2C/getAds.ts | 19 +- src/modules/c2c/C2C/getC2CTradeHistory.ts | 15 +- .../market-data-api/listAllConvertPairs.ts | 11 +- .../queryOrderQuantityPrecisionPerAsset.ts | 19 +- src/modules/convert/trade-api/acceptQuote.ts | 21 +- .../convert/trade-api/cancelLimitOrder.ts | 21 +- .../trade-api/getConvertTradeHistory.ts | 25 +- src/modules/convert/trade-api/orderStatus.ts | 11 +- .../convert/trade-api/placeLimitOrder.ts | 67 ++-- .../convert/trade-api/queryLimitOpenOrders.ts | 19 +- .../convert/trade-api/sendQuoteRequest.ts | 55 +-- .../FutureCopyTrading-api/followTrader.ts | 40 ++- .../FutureCopyTrading-api/getCopyOrders.ts | 17 +- .../FutureCopyTrading-api/getCopyPositions.ts | 9 +- .../getFollowingTraders.ts | 9 +- .../getFuturesLeadTraderStatus.ts | 13 +- .../getFuturesLeadTradingSymbolWhitelist.ts | 13 +- .../FutureCopyTrading-api/getLeadTraders.ts | 17 +- .../getTraderPerformance.ts | 13 +- .../getTraderPositions.ts | 13 +- .../getTraderSymbolStats.ts | 13 +- .../FutureCopyTrading-api/unfollowTrader.ts | 11 +- .../crypto-loans/flexible/adjustLTV.ts | 21 +- src/modules/crypto-loans/flexible/borrow.ts | 29 +- .../crypto-loans/flexible/getBorrowHistory.ts | 20 +- .../flexible/getFlexibleCollateralAssets.ts | 11 +- .../flexible/getFlexibleLoanAssets.ts | 11 +- .../crypto-loans/flexible/getOngoingOrders.ts | 17 +- .../crypto-loans/flexible/getRepayHistory.ts | 20 +- src/modules/crypto-loans/flexible/repay.ts | 19 +- .../getDualInvestmentProductList.ts | 41 +-- .../trade-api/changeAutoCompoundStatus.ts | 29 +- .../trade-api/checkDualInvestmentAccounts.ts | 19 +- .../trade-api/getDualInvestmentPositions.ts | 63 ++-- .../subscribeDualInvestmentProducts.ts | 31 +- .../fiat-api/getFiatDepositWithdrawHistory.ts | 37 +- .../fiat/fiat-api/getFiatPaymentsHistory.ts | 33 +- src/modules/mining/mining-api/accountList.ts | 17 +- .../mining/mining-api/acquiringAlgorithm.ts | 8 +- .../mining/mining-api/acquiringCoinname.ts | 8 +- .../cancelHashrateResaleConfiguration.ts | 13 +- src/modules/mining/mining-api/earningsList.ts | 54 +-- .../mining/mining-api/extraBonusList.ts | 44 +-- .../mining/mining-api/hashrateResaleDetail.ts | 39 ++- .../mining/mining-api/hashrateResaleList.ts | 39 ++- .../mining-api/hashrateResaleRequest.ts | 35 +- .../mining/mining-api/miningAccountEarning.ts | 31 +- .../mining-api/requestForDetailMinerList.ts | 15 +- .../mining/mining-api/requestForMinerList.ts | 71 ++-- .../mining/mining-api/statisticList.ts | 21 +- src/modules/nft/nft-api/getNFTAsset.ts | 27 +- .../nft/nft-api/getNFTDepositHistory.ts | 31 +- .../nft/nft-api/getNFTTransactionHistory.ts | 41 ++- .../nft/nft-api/getNFTWithdrawHistory.ts | 31 +- src/modules/options/account-api/getAccount.ts | 8 +- .../options/account-api/getBillHistory.ts | 31 +- .../options/account-api/getIncomeAsyn.ts | 13 +- .../options/account-api/getIncomeAsynId.ts | 11 +- .../options/account-api/getPosition.ts | 15 +- src/modules/options/market-api/depth.ts | 23 +- .../options/market-api/exchangeInfo.ts | 8 +- .../options/market-api/exerciseHistory.ts | 27 +- .../options/market-api/historicalTrades.ts | 32 +- src/modules/options/market-api/indexPrice.ts | 9 +- src/modules/options/market-api/klines.ts | 33 +- src/modules/options/market-api/mark.ts | 19 +- src/modules/options/market-api/ping.ts | 5 +- src/modules/options/market-api/ticker.ts | 19 +- src/modules/options/market-api/time.ts | 5 +- src/modules/options/market-api/trades.ts | 23 +- src/modules/options/trade-api/batchOrders.ts | 43 +-- .../options/trade-api/cancelAllOrders.ts | 11 +- .../options/trade-api/cancelBatchOrders.ts | 27 +- .../options/trade-api/cancelBySymbol.ts | 11 +- src/modules/options/trade-api/cancelOrder.ts | 14 +- .../options/trade-api/getHistoryOrders.ts | 30 +- .../options/trade-api/getOpenOrders.ts | 15 +- .../options/trade-api/getUserTrades.ts | 36 +- src/modules/options/trade-api/newOrder.ts | 35 +- .../options/userdata-api/createListenKey.ts | 8 +- .../options/userdata-api/deleteListenKey.ts | 15 +- .../options/userdata-api/renewListenKey.ts | 15 +- src/modules/pay/pay-api/createOrder.ts | 23 +- src/modules/pay/pay-api/getHistory.ts | 27 +- src/modules/pay/pay-api/getPayTradeHistory.ts | 29 +- src/modules/pay/pay-api/queryOrder.ts | 14 +- .../account/getAccountInfo.ts | 9 +- .../portfolio-margin/account/getBalance.ts | 16 +- .../portfolio-margin/account/getCmAccount.ts | 8 +- .../portfolio-margin/account/getCmPosition.ts | 12 +- .../account/getMarginAccount.ts | 8 +- .../account/getMaxBorrowable.ts | 11 +- .../account/getMaxWithdraw.ts | 11 +- .../portfolio-margin/account/getUmAccount.ts | 8 +- .../portfolio-margin/account/getUmPosition.ts | 10 +- .../cm-trade/cancelAllOrders.ts | 11 +- .../portfolio-margin/cm-trade/cancelOrder.ts | 14 +- .../cm-trade/changeLeverage.ts | 13 +- .../cm-trade/changeMarginType.ts | 13 +- .../portfolio-margin/cm-trade/getAllOrders.ts | 33 +- .../cm-trade/getOpenOrders.ts | 12 +- .../portfolio-margin/cm-trade/getOrder.ts | 14 +- .../cm-trade/getUserTrades.ts | 32 +- .../portfolio-margin/cm-trade/newOrder.ts | 55 +-- .../margin-trade/cancelAllOrders.ts | 11 +- .../margin-trade/cancelOrder.ts | 14 +- .../margin-trade/getAllOrders.ts | 31 +- .../margin-trade/getOpenOrders.ts | 10 +- .../portfolio-margin/margin-trade/getOrder.ts | 14 +- .../margin-trade/getUserTrades.ts | 30 +- .../margin-trade/marginLoan.ts | 13 +- .../margin-trade/marginRepay.ts | 12 +- .../portfolio-margin/margin-trade/newOrder.ts | 55 +-- .../um-trade/cancelAllOrders.ts | 11 +- .../portfolio-margin/um-trade/cancelOrder.ts | 14 +- .../um-trade/changeLeverage.ts | 13 +- .../um-trade/changeMarginType.ts | 13 +- .../portfolio-margin/um-trade/getAllOrders.ts | 31 +- .../um-trade/getOpenOrders.ts | 10 +- .../portfolio-margin/um-trade/getOrder.ts | 14 +- .../um-trade/getUserTrades.ts | 30 +- .../portfolio-margin/um-trade/newOrder.ts | 55 +-- .../userdata/createListenKey.ts | 8 +- .../userdata/deleteListenKey.ts | 9 +- .../userdata/renewListenKey.ts | 8 +- .../rebate-api/getSpotRebateHistoryRecords.ts | 19 +- .../account-api/getFlexibleProductPosition.ts | 43 +-- .../simpleEarnFlexibleProductList.ts | 41 +-- src/modules/simple-earn/account/getAccount.ts | 9 +- .../account/getCollateralRecord.ts | 20 +- .../simple-earn/account/getRewardRecord.ts | 23 +- .../earn-api/redeemFlexibleProduct.ts | 31 +- .../earn-api/subscribeFlexibleProduct.ts | 23 +- .../flexible/getFlexiblePosition.ts | 17 +- .../flexible/getFlexibleProductList.ts | 27 +- .../getFlexibleSubscriptionPreview.ts | 13 +- .../simple-earn/flexible/getRateHistory.ts | 19 +- .../flexible/getRedemptionRecord.ts | 23 +- .../flexible/getSubscriptionRecord.ts | 23 +- .../simple-earn/flexible/redeemFlexible.ts | 31 +- .../simple-earn/flexible/subscribeFlexible.ts | 29 +- .../locked/getLockedPersonalQuota.ts | 11 +- .../simple-earn/locked/getLockedPosition.ts | 19 +- .../locked/getLockedProductList.ts | 27 +- .../locked/getLockedSubscriptionPreview.ts | 15 +- .../simple-earn/locked/getRedemptionRecord.ts | 23 +- .../locked/getSubscriptionRecord.ts | 21 +- .../simple-earn/locked/redeemLocked.ts | 11 +- .../simple-earn/locked/setAutoSubscribe.ts | 13 +- .../simple-earn/locked/subscribeLocked.ts | 23 +- .../spot/account-api/accountCommission.ts | 10 +- src/modules/spot/account-api/getAccount.ts | 8 +- src/modules/spot/account-api/myAllocations.ts | 18 +- .../spot/account-api/myPreventedMatches.ts | 18 +- src/modules/spot/account-api/myTrades.ts | 20 +- .../spot/account-api/rateLimitOrder.ts | 8 +- src/modules/spot/general-api/exchangeInfo.ts | 32 +- src/modules/spot/general-api/ping.ts | 44 +-- src/modules/spot/general-api/time.ts | 52 +-- src/modules/spot/market-api/aggTrades.ts | 16 +- src/modules/spot/market-api/avgPrice.ts | 8 +- src/modules/spot/market-api/depth.ts | 10 +- src/modules/spot/market-api/getTrades.ts | 10 +- .../spot/market-api/historicalTrades.ts | 12 +- src/modules/spot/market-api/klines.ts | 52 +-- src/modules/spot/market-api/ticker.ts | 17 +- src/modules/spot/market-api/ticker24hr.ts | 8 +- .../spot/market-api/tickerBookTicker.ts | 8 +- src/modules/spot/market-api/tickerPrice.ts | 8 +- .../spot/market-api/tickerTradingDay.ts | 8 +- src/modules/spot/market-api/uiKlines.ts | 52 +-- src/modules/spot/trade-api/allOrders.ts | 22 +- .../spot/trade-api/deleteOpenOrders.ts | 8 +- src/modules/spot/trade-api/deleteOrder.ts | 12 +- src/modules/spot/trade-api/getOpenOrders.ts | 8 +- src/modules/spot/trade-api/getOrder.ts | 12 +- src/modules/spot/trade-api/newOrder.ts | 54 +-- src/modules/spot/trade-api/openOrderList.ts | 8 +- src/modules/spot/trade-api/orderOco.ts | 34 +- .../deleteUserDataStream.ts | 8 +- .../userdatastream-api/newUserDataStream.ts | 5 +- .../userdatastream-api/putUserDataStream.ts | 8 +- .../ETH-staking-api/ethStakingAccount.ts | 9 +- .../getCurrentEthStakingQuota.ts | 9 +- .../getEthRedemptionHistory.ts | 59 ++-- .../ETH-staking-api/getEthStakingHistory.ts | 59 ++-- .../ETH-staking-api/getWbethRateHistory.ts | 51 +-- .../ETH-staking-api/getWbethRewardsHistory.ts | 59 ++-- .../ETH-staking-api/getWbethUnwrapHistory.ts | 51 +-- .../ETH-staking-api/getWbethWrapHistory.ts | 43 +-- .../staking/ETH-staking-api/redeemEth.ts | 21 +- .../ETH-staking-api/subscribeEthStaking.ts | 11 +- .../staking/ETH-staking-api/wrapBeth.ts | 11 +- .../SOL-staking-api/claimBoostRewards.ts | 9 +- .../SOL-staking-api/getBnsolRateHistory.ts | 43 +-- .../SOL-staking-api/getBnsolRewardsHistory.ts | 51 +-- .../SOL-staking-api/getBoostRewardsHistory.ts | 51 +-- .../getSolRedemptionHistory.ts | 43 +-- .../SOL-staking-api/getSolStakingHistory.ts | 43 +-- .../getSolStakingQuotaDetails.ts | 9 +- .../SOL-staking-api/getUnclaimedRewards.ts | 9 +- .../staking/SOL-staking-api/redeemSol.ts | 19 +- .../SOL-staking-api/solStakingAccount.ts | 9 +- .../SOL-staking-api/subscribeSolStaking.ts | 11 +- .../market-api/getBorrowInterestRate.ts | 15 +- .../market-api/getCollateralAssetData.ts | 15 +- .../market-api/getLoanableAssetsData.ts | 25 +- .../vip-loan/trade-api/vipLoanBorrow.ts | 43 ++- .../vip-loan/trade-api/vipLoanRenew.ts | 25 +- .../vip-loan/trade-api/vipLoanRepay.ts | 17 +- .../checkVIPLoanCollateralAccount.ts | 17 +- .../getVIPLoanOngoingOrders.ts | 49 +-- .../queryApplicationStatus.ts | 29 +- .../account-api/accountApiTradingStatus.ts | 8 +- src/modules/wallet/account-api/accountInfo.ts | 8 +- .../wallet/account-api/accountStatus.ts | 8 +- .../account-api/dailyAccountSnapshot.ts | 16 +- .../account-api/disableFastWithdrawSwitch.ts | 8 +- .../account-api/enableFastWithdrawSwitch.ts | 8 +- .../wallet/account-api/getApiKeyPermission.ts | 8 +- src/modules/wallet/asset-api/assetDetail.ts | 10 +- .../wallet/asset-api/assetDividendRecord.ts | 16 +- src/modules/wallet/asset-api/dustTransfer.ts | 10 +- src/modules/wallet/asset-api/dustlog.ts | 12 +- src/modules/wallet/asset-api/fundingWallet.ts | 12 +- .../getAssetsThatCanBeConvertedIntoBnb.ts | 8 +- .../getCloudMiningPaymentAndRefundHistory.ts | 16 +- .../wallet/asset-api/getOpenSymbolList.ts | 44 +-- .../asset-api/queryUserDelegationHistory.ts | 18 +- .../queryUserUniversalTransferHistory.ts | 22 +- .../asset-api/queryUserWalletBalance.ts | 8 +- ...ggleBnbBurnOnSpotTradeAndMarginInterest.ts | 12 +- src/modules/wallet/asset-api/tradeFee.ts | 10 +- src/modules/wallet/asset-api/userAsset.ts | 10 +- .../wallet/asset-api/userUniversalTransfer.ts | 18 +- .../wallet/capital-api/allCoinsInformation.ts | 8 +- .../wallet/capital-api/depositAddress.ts | 12 +- .../wallet/capital-api/depositHistory.ts | 20 +- .../fetchDepositAddressListWithNetwork.ts | 12 +- .../capital-api/fetchWithdrawAddressList.ts | 5 +- .../oneClickArrivalDepositApply.ts | 10 +- src/modules/wallet/capital-api/withdraw.ts | 26 +- .../wallet/capital-api/withdrawHistory.ts | 22 +- .../getSymbolsDelistScheduleForSpot.ts | 5 +- src/modules/wallet/others-api/systemStatus.ts | 44 +-- .../wallet/travel-rule-api/brokerWithdraw.ts | 30 +- .../depositHistoryTravelRule.ts | 20 +- .../travel-rule-api/onboardedVaspList.ts | 5 +- .../submitDepositQuestionnaire.ts | 18 +- .../submitDepositQuestionnaireTravelRule.ts | 12 +- .../travel-rule-api/withdrawHistoryV1.ts | 20 +- .../travel-rule-api/withdrawHistoryV2.ts | 20 +- .../travel-rule-api/withdrawTravelRule.ts | 24 +- src/tools/account/index.ts | 80 +++-- .../binance-algo/future-algo/TwapNewTrade.ts | 81 ++--- .../binance-algo/future-algo/VPNewTrade.ts | 71 ++-- .../future-algo/cancelAlgoOrder.ts | 11 +- .../future-algo/currentAlgoOpenOrders.ts | 9 +- .../future-algo/historicalAlgoOrder.ts | 51 +-- .../binance-algo/future-algo/subOrders.ts | 29 +- .../spot-algo/cancelOpenTWAPOrder.ts | 11 +- .../spot-algo/currentAlgoOpenOrders.ts | 9 +- .../spot-algo/historicalAlgoOrders.ts | 51 +-- .../binance-algo/spot-algo/spotTWAPOrder.ts | 59 ++-- src/tools/binance-algo/spot-algo/subOrders.ts | 29 +- .../changeIndexPlanStatus.ts | 12 +- .../binance-auto-invest/changePlanStatus.ts | 10 +- src/tools/binance-auto-invest/createPlan.ts | 36 +- src/tools/binance-auto-invest/editPlan.ts | 38 ++- .../binance-auto-invest/getHistoryList.ts | 33 +- src/tools/binance-auto-invest/getIndexInfo.ts | 11 +- .../getIndexLinkedPlanPositionDetails.ts | 10 +- .../getIndexLinkedPlanPositionList.ts | 8 +- .../getIndexLinkedPlanRebalanceHistory.ts | 16 +- .../getIndexUserSummary.ts | 11 +- .../binance-auto-invest/getOneTimePlans.ts | 10 +- src/tools/binance-auto-invest/getPlanList.ts | 8 +- .../binance-auto-invest/getSourceAssetList.ts | 20 +- .../getSubscriptionHistory.ts | 20 +- .../binance-auto-invest/getTargetAssetList.ts | 12 +- .../binance-auto-invest/getTargetAssetROI.ts | 14 +- .../getTargetAssetRoiData.ts | 17 +- .../binance-auto-invest/oneTimeTransaction.ts | 42 ++- .../binance-auto-invest/rebalanceHistory.ts | 22 +- .../redeemIndexLinkedPlan.ts | 12 +- src/tools/binance-auto-invest/redemption.ts | 20 +- .../binance-c2c/C2C/getC2CTradeHistory.ts | 15 +- .../market-data-api/listAllConvertPairs.ts | 11 +- .../queryOrderQuantityPrecisionPerAsset.ts | 19 +- .../binance-convert/trade-api/acceptQuote.ts | 21 +- .../trade-api/cancelLimitOrder.ts | 21 +- .../trade-api/getConvertTradeHistory.ts | 25 +- .../binance-convert/trade-api/orderStatus.ts | 11 +- .../trade-api/placeLimitOrder.ts | 67 ++-- .../trade-api/queryLimitOpenOrders.ts | 19 +- .../trade-api/sendQuoteRequest.ts | 55 +-- .../FutureCopyTrading-api/followTrader.ts | 47 +-- .../FutureCopyTrading-api/getCopyOrders.ts | 21 +- .../FutureCopyTrading-api/getCopyPositions.ts | 13 +- .../getFollowingTraders.ts | 8 +- .../getFuturesLeadTraderStatus.ts | 13 +- .../getFuturesLeadTradingSymbolWhitelist.ts | 13 +- .../FutureCopyTrading-api/getLeadTraders.ts | 19 +- .../getTraderPerformance.ts | 11 +- .../FutureCopyTrading-api/unfollowTrader.ts | 11 +- .../fixed-api/adjustLTV.ts | 18 +- .../binance-crypto-loans/fixed-api/borrow.ts | 31 +- .../fixed-api/checkCollateralRate.ts | 15 +- .../fixed-api/customizeMarginCall.ts | 13 +- .../fixed-api/getBorrowHistory.ts | 22 +- .../fixed-api/getFixedCollateralData.ts | 13 +- .../fixed-api/getFixedLoanData.ts | 25 +- .../fixed-api/getOngoingOrders.ts | 19 +- .../fixed-api/getRepayHistory.ts | 22 +- .../binance-crypto-loans/fixed-api/repay.ts | 28 +- .../flexible-api/adjustLTV.ts | 25 +- .../flexible-api/borrow.ts | 29 +- .../flexible-api/getBorrowHistory.ts | 21 +- .../getFlexibleCollateralAssets.ts | 17 +- .../flexible-api/getFlexibleLoanAssets.ts | 17 +- .../flexible-api/getOngoingOrders.ts | 17 +- .../flexible-api/getRepayHistory.ts | 21 +- .../flexible-api/repay.ts | 25 +- .../flexibleLoanAdjustLTV.ts | 18 +- .../flexibleLoanBorrow.ts | 14 +- .../flexibleLoanBorrowHistory.ts | 18 +- .../flexibleLoanCollateralAssets.ts | 8 +- .../flexibleLoanLTVAdjustmentHistory.ts | 18 +- .../flexibleLoanLoanableAssets.ts | 10 +- .../flexibleLoanOngoingOrders.ts | 14 +- .../binance-crypto-loans/flexibleLoanRepay.ts | 16 +- .../flexibleLoanRepayHistory.ts | 18 +- .../getCollateralAssetsData.ts | 10 +- .../getCollateralRepayRate.ts | 12 +- .../getLoanableAssetsData.ts | 10 +- .../getDualInvestmentProductList.ts | 41 +-- .../trade-api/changeAutoCompoundStatus.ts | 29 +- .../trade-api/checkDualInvestmentAccounts.ts | 19 +- .../trade-api/getDualInvestmentPositions.ts | 63 ++-- .../subscribeDualInvestmentProducts.ts | 31 +- .../fiat-api/getFiatDepositWithdrawHistory.ts | 37 +- .../fiat-api/getFiatPaymentsHistory.ts | 33 +- .../account-api/account.ts | 9 +- .../account-api/adlQuantile.ts | 11 +- .../account-api/balance.ts | 8 +- .../account-api/commissionRate.ts | 10 +- .../account-api/forceOrders.ts | 18 +- .../account-api/income.ts | 49 +-- .../account-api/leverageBracket.ts | 11 +- .../account-api/positionMode.ts | 8 +- .../account-api/positionRisk.ts | 13 +- .../account-api/userTrades.ts | 20 +- src/tools/binance-futures-coinm/account.ts | 8 +- .../binance-futures-coinm/adlQuantile.ts | 18 +- src/tools/binance-futures-coinm/aggTrades.ts | 28 +- src/tools/binance-futures-coinm/allOrders.ts | 18 +- src/tools/binance-futures-coinm/balance.ts | 8 +- .../binance-futures-coinm/batchOrders.ts | 16 +- src/tools/binance-futures-coinm/bookTicker.ts | 21 +- .../binance-futures-coinm/cancelAllOrders.ts | 10 +- .../cancelBatchOrders.ts | 18 +- .../binance-futures-coinm/cancelOrder.ts | 14 +- .../binance-futures-coinm/commissionRate.ts | 8 +- .../binance-futures-coinm/continuousKlines.ts | 58 ++-- src/tools/binance-futures-coinm/depth.ts | 20 +- .../binance-futures-coinm/exchangeInfo.ts | 7 +- .../binance-futures-coinm/forceOrders.ts | 22 +- .../binance-futures-coinm/fundingRate.ts | 14 +- src/tools/binance-futures-coinm/getOrder.ts | 14 +- .../binance-futures-coinm/historicalTrades.ts | 18 +- src/tools/binance-futures-coinm/income.ts | 46 +-- .../binance-futures-coinm/indexPriceKlines.ts | 52 +-- src/tools/binance-futures-coinm/klines.ts | 52 +-- src/tools/binance-futures-coinm/leverage.ts | 12 +- src/tools/binance-futures-coinm/listenKey.ts | 18 +- src/tools/binance-futures-coinm/marginType.ts | 10 +- .../binance-futures-coinm/markPriceKlines.ts | 52 +-- .../market-api/aggTrades.ts | 17 +- .../market-api/bookTicker.ts | 16 +- .../market-api/continuousKlines.ts | 59 ++-- .../binance-futures-coinm/market-api/depth.ts | 18 +- .../market-api/exchangeInfo.ts | 8 +- .../market-api/fundingRate.ts | 14 +- .../market-api/historicalTrades.ts | 13 +- .../market-api/indexPriceKlines.ts | 52 +-- .../market-api/klines.ts | 52 +-- .../market-api/markPriceKlines.ts | 53 +-- .../market-api/openInterest.ts | 8 +- .../market-api/openInterestHist.ts | 27 +- .../binance-futures-coinm/market-api/ping.ts | 8 +- .../market-api/premiumIndex.ts | 14 +- .../market-api/ticker24hr.ts | 16 +- .../market-api/tickerPrice.ts | 16 +- .../binance-futures-coinm/market-api/time.ts | 5 +- .../market-api/trades.ts | 10 +- src/tools/binance-futures-coinm/newOrder.ts | 54 +-- .../binance-futures-coinm/openInterest.ts | 8 +- src/tools/binance-futures-coinm/openOrders.ts | 12 +- src/tools/binance-futures-coinm/ping.ts | 5 +- .../binance-futures-coinm/positionMargin.ts | 20 +- .../binance-futures-coinm/positionMode.ts | 8 +- .../binance-futures-coinm/positionRisk.ts | 12 +- .../binance-futures-coinm/premiumIndex.ts | 18 +- src/tools/binance-futures-coinm/ticker24hr.ts | 20 +- .../binance-futures-coinm/tickerPrice.ts | 20 +- src/tools/binance-futures-coinm/time.ts | 5 +- .../trade-api/allOrders.ts | 20 +- .../trade-api/batchOrders.ts | 12 +- .../trade-api/cancelAllOrders.ts | 10 +- .../trade-api/cancelBatchOrders.ts | 14 +- .../trade-api/cancelOrder.ts | 14 +- .../trade-api/changeLeverage.ts | 13 +- .../trade-api/changeMarginType.ts | 12 +- .../trade-api/changePositionMode.ts | 10 +- .../trade-api/countdownCancelAll.ts | 16 +- .../trade-api/getAllOrders.ts | 20 +- .../trade-api/getOrder.ts | 14 +- .../trade-api/modifyIsolatedPositionMargin.ts | 22 +- .../trade-api/newOrder.ts | 82 ++--- .../trade-api/openOrder.ts | 14 +- .../trade-api/openOrders.ts | 12 +- src/tools/binance-futures-coinm/trades.ts | 10 +- src/tools/binance-futures-coinm/userTrades.ts | 20 +- .../userdatastream-api/closeListenKey.ts | 10 +- .../userdatastream-api/createListenKey.ts | 9 +- .../userdatastream-api/keepAliveListenKey.ts | 11 +- .../account-api/account.ts | 9 +- .../account-api/adlQuantile.ts | 10 +- .../account-api/apiTradingStatus.ts | 10 +- .../account-api/balance.ts | 8 +- .../account-api/commissionRate.ts | 10 +- .../account-api/downloadId.ts | 12 +- .../account-api/forceOrders.ts | 18 +- .../account-api/income.ts | 64 ++-- .../account-api/leverage.ts | 23 +- .../account-api/leverageBracket.ts | 10 +- .../account-api/marginType.ts | 13 +- .../account-api/multiAssetsMode.ts | 8 +- .../account-api/positionMargin.ts | 40 ++- .../account-api/positionMode.ts | 8 +- .../account-api/positionRisk.ts | 10 +- .../account-api/userTrades.ts | 20 +- src/tools/binance-futures-usdm/account.ts | 8 +- src/tools/binance-futures-usdm/adlQuantile.ts | 18 +- src/tools/binance-futures-usdm/aggTrades.ts | 28 +- src/tools/binance-futures-usdm/allOrders.ts | 16 +- src/tools/binance-futures-usdm/balance.ts | 5 +- src/tools/binance-futures-usdm/batchOrders.ts | 16 +- src/tools/binance-futures-usdm/bookTicker.ts | 19 +- .../binance-futures-usdm/cancelAllOrders.ts | 8 +- .../binance-futures-usdm/cancelBatchOrders.ts | 18 +- src/tools/binance-futures-usdm/cancelOrder.ts | 12 +- .../binance-futures-usdm/commissionRate.ts | 8 +- .../binance-futures-usdm/continuousKlines.ts | 58 ++-- src/tools/binance-futures-usdm/depth.ts | 20 +- .../binance-futures-usdm/exchangeInfo.ts | 5 +- src/tools/binance-futures-usdm/forceOrders.ts | 22 +- src/tools/binance-futures-usdm/fundingRate.ts | 14 +- src/tools/binance-futures-usdm/getOrder.ts | 12 +- .../binance-futures-usdm/historicalTrades.ts | 18 +- src/tools/binance-futures-usdm/income.ts | 62 ++-- .../binance-futures-usdm/indexPriceKlines.ts | 52 +-- src/tools/binance-futures-usdm/klines.ts | 52 +-- src/tools/binance-futures-usdm/leverage.ts | 10 +- src/tools/binance-futures-usdm/listenKey.ts | 18 +- src/tools/binance-futures-usdm/marginType.ts | 10 +- .../binance-futures-usdm/markPriceKlines.ts | 52 +-- .../market-api/aggTrades.ts | 16 +- .../market-api/assetIndex.ts | 8 +- .../market-api/continuousKlines.ts | 58 ++-- .../binance-futures-usdm/market-api/depth.ts | 18 +- .../market-api/exchangeInfo.ts | 5 +- .../market-api/fundingInfo.ts | 5 +- .../market-api/fundingRate.ts | 14 +- .../market-api/globalLongShortAccountRatio.ts | 30 +- .../market-api/historicalTrades.ts | 12 +- .../market-api/indexInfo.ts | 8 +- .../market-api/indexPriceKlines.ts | 52 +-- .../binance-futures-usdm/market-api/klines.ts | 52 +-- .../market-api/lvtKlines.ts | 62 ++-- .../market-api/markPriceKlines.ts | 52 +-- .../market-api/openInterest.ts | 8 +- .../market-api/openInterestHist.ts | 30 +- .../binance-futures-usdm/market-api/ping.ts | 5 +- .../market-api/premiumIndex.ts | 14 +- .../market-api/takerLongShortRatio.ts | 30 +- .../market-api/ticker24hr.ts | 8 +- .../market-api/tickerBookTicker.ts | 14 +- .../market-api/tickerPrice.ts | 8 +- .../binance-futures-usdm/market-api/time.ts | 44 +-- .../market-api/topLongShortAccountRatio.ts | 30 +- .../market-api/topLongShortPositionRatio.ts | 30 +- .../binance-futures-usdm/market-api/trades.ts | 18 +- .../binance-futures-usdm/multiAssetsMode.ts | 12 +- src/tools/binance-futures-usdm/newOrder.ts | 91 ++--- .../binance-futures-usdm/openInterest.ts | 8 +- src/tools/binance-futures-usdm/openOrders.ts | 18 +- src/tools/binance-futures-usdm/ping.ts | 5 +- .../binance-futures-usdm/positionMargin.ts | 20 +- .../binance-futures-usdm/positionMode.ts | 8 +- .../binance-futures-usdm/positionRisk.ts | 18 +- .../binance-futures-usdm/premiumIndex.ts | 18 +- src/tools/binance-futures-usdm/ticker24hr.ts | 18 +- src/tools/binance-futures-usdm/tickerPrice.ts | 18 +- src/tools/binance-futures-usdm/time.ts | 5 +- .../trade-api/allOrders.ts | 17 +- .../trade-api/batchOrders.ts | 21 +- .../trade-api/cancelAllOpenOrders.ts | 9 +- .../trade-api/cancelAllOrders.ts | 11 +- .../trade-api/cancelBatchOrders.ts | 30 +- .../trade-api/cancelOrder.ts | 14 +- .../trade-api/changeLeverage.ts | 23 +- .../trade-api/changeMarginType.ts | 21 +- .../trade-api/changeMultiAssetsMode.ts | 11 +- .../trade-api/changePositionMode.ts | 15 +- .../trade-api/countdownCancelAll.ts | 19 +- .../trade-api/getAllOrders.ts | 28 +- .../trade-api/getOpenOrder.ts | 14 +- .../trade-api/getOpenOrders.ts | 16 +- .../trade-api/getOrder.ts | 14 +- .../trade-api/modifyIsolatedPositionMargin.ts | 23 +- .../trade-api/modifyOrder.ts | 46 +-- .../trade-api/newOrder.ts | 104 +++--- .../trade-api/openOrder.ts | 13 +- .../trade-api/openOrders.ts | 15 +- .../trade-api/positionMarginHistory.ts | 19 +- src/tools/binance-futures-usdm/trades.ts | 10 +- src/tools/binance-futures-usdm/userTrades.ts | 18 +- .../userdatastream-api/closeListenKey.ts | 17 +- .../userdatastream-api/createListenKey.ts | 9 +- .../userdatastream-api/keepAliveListenKey.ts | 17 +- src/tools/binance-gift-card/buyCode.ts | 15 +- src/tools/binance-gift-card/createCode.ts | 13 +- .../binance-gift-card/createDualTokenCode.ts | 21 +- .../createDualTokenGiftCard.ts | 17 +- src/tools/binance-gift-card/createGiftCard.ts | 13 +- src/tools/binance-gift-card/getTokenLimit.ts | 11 +- src/tools/binance-gift-card/redeemCode.ts | 15 +- .../redeemDualTokenGiftCard.ts | 12 +- src/tools/binance-gift-card/redeemGiftCard.ts | 12 +- src/tools/binance-gift-card/rsaPublicKey.ts | 8 +- src/tools/binance-gift-card/tokenLimit.ts | 11 +- src/tools/binance-gift-card/verify.ts | 11 +- src/tools/binance-gift-card/verifyGiftCard.ts | 11 +- .../cross-margin-api/crossMarginAccount.ts | 9 +- .../cross-margin-api/crossMarginAllAssets.ts | 21 +- .../cross-margin-api/crossMarginAllOrders.ts | 21 +- .../crossMarginAvailableInventory.ts | 14 +- .../cross-margin-api/crossMarginBorrow.ts | 23 +- .../crossMarginCancelAllOrders.ts | 11 +- .../crossMarginCancelOrder.ts | 23 +- .../crossMarginCapitalFlow.ts | 53 +-- .../cross-margin-api/crossMarginDelist.ts | 8 +- .../cross-margin-api/crossMarginDustLog.ts | 13 +- .../cross-margin-api/crossMarginFee.ts | 21 +- .../crossMarginForceLiquidationRec.ts | 19 +- .../crossMarginInterestHistory.ts | 22 +- .../crossMarginInterestRateHistory.ts | 24 +- .../cross-margin-api/crossMarginLoanRecord.ts | 24 +- .../crossMarginMaxBorrowable.ts | 12 +- .../crossMarginMaxTransferable.ts | 12 +- .../cross-margin-api/crossMarginMyTrades.ts | 22 +- .../cross-margin-api/crossMarginNewOrder.ts | 78 +++-- .../cross-margin-api/crossMarginOpenOrders.ts | 13 +- .../cross-margin-api/crossMarginPairs.ts | 9 +- .../cross-margin-api/crossMarginPriceIndex.ts | 9 +- .../cross-margin-api/crossMarginRepay.ts | 23 +- .../crossMarginRepayRecord.ts | 24 +- .../crossMarginSmallLiabilityExchange.ts | 15 +- ...rossMarginSmallLiabilityExchangeHistory.ts | 16 +- .../cross-margin-api/crossMarginTransfer.ts | 15 +- .../disableIsolatedMarginAccount.ts | 11 +- .../enableIsolatedMarginAccount.ts | 10 +- .../isolated-margin-api/getBnbBurnStatus.ts | 8 +- .../isolatedMarginAccount.ts | 17 +- .../isolatedMarginAccountLimit.ts | 9 +- .../isolatedMarginAllOrders.ts | 19 +- .../isolatedMarginAllPairs.ts | 8 +- .../isolatedMarginAllSymbols.ts | 8 +- .../isolatedMarginBorrow.ts | 14 +- .../isolatedMarginCancelOrder.ts | 23 +- .../isolated-margin-api/isolatedMarginFee.ts | 20 +- .../isolatedMarginMyTrades.ts | 20 +- .../isolatedMarginNewOrder.ts | 78 +++-- .../isolatedMarginOpenOrders.ts | 10 +- .../isolated-margin-api/isolatedMarginPair.ts | 11 +- .../isolatedMarginRepay.ts | 14 +- .../isolatedMarginSymbol.ts | 10 +- .../isolatedMarginTierData.ts | 13 +- .../isolatedMarginTransfer.ts | 19 +- .../isolatedMarginTransferHistory.ts | 26 +- .../isolated-margin-api/toggleBnbBurn.ts | 25 +- .../margin-order-api/marginCancelOco.ts | 31 +- .../margin-order-api/marginGetAllOco.ts | 33 +- .../margin-order-api/marginGetOco.ts | 29 +- .../margin-order-api/marginGetOpenOco.ts | 24 +- .../margin-order-api/marginNewOco.ts | 73 ++-- .../binance-mining/mining-api/accountList.ts | 17 +- .../mining-api/acquiringAlgorithm.ts | 8 +- .../mining-api/acquiringCoinname.ts | 8 +- .../cancelHashrateResaleConfiguration.ts | 13 +- .../binance-mining/mining-api/earningsList.ts | 54 +-- .../mining-api/extraBonusList.ts | 44 +-- .../mining-api/hashrateResaleDetail.ts | 39 ++- .../mining-api/hashrateResaleList.ts | 39 ++- .../mining-api/hashrateResaleRequest.ts | 35 +- .../mining-api/miningAccountEarning.ts | 31 +- .../mining-api/requestForDetailMinerList.ts | 15 +- .../mining-api/requestForMinerList.ts | 71 ++-- .../mining-api/statisticList.ts | 21 +- src/tools/binance-nft/nft-api/getNFTAsset.ts | 27 +- .../nft-api/getNFTDepositHistory.ts | 31 +- .../nft-api/getNFTTransactionHistory.ts | 41 ++- .../nft-api/getNFTWithdrawHistory.ts | 31 +- src/tools/binance-options/account.ts | 42 +-- src/tools/binance-options/batchOrders.ts | 16 +- src/tools/binance-options/bill.ts | 19 +- src/tools/binance-options/cancelAllOrders.ts | 8 +- .../binance-options/cancelBatchOrders.ts | 18 +- src/tools/binance-options/cancelOrder.ts | 12 +- src/tools/binance-options/depth.ts | 10 +- src/tools/binance-options/exchangeInfo.ts | 8 +- src/tools/binance-options/exerciseHistory.ts | 14 +- src/tools/binance-options/exerciseRecord.ts | 17 +- src/tools/binance-options/getOrder.ts | 12 +- src/tools/binance-options/historicalTrades.ts | 12 +- src/tools/binance-options/historyOrders.ts | 16 +- src/tools/binance-options/indexPrice.ts | 8 +- src/tools/binance-options/klines.ts | 20 +- src/tools/binance-options/listenKey.ts | 21 +- src/tools/binance-options/mark.ts | 8 +- src/tools/binance-options/newOrder.ts | 26 +- src/tools/binance-options/openInterest.ts | 10 +- src/tools/binance-options/openOrders.ts | 8 +- src/tools/binance-options/ping.ts | 5 +- src/tools/binance-options/position.ts | 8 +- src/tools/binance-options/ticker.ts | 8 +- src/tools/binance-options/time.ts | 5 +- src/tools/binance-options/trades.ts | 10 +- src/tools/binance-options/userTrades.ts | 16 +- .../binance-pay/pay-api/getPayTradeHistory.ts | 29 +- .../binance-portfolio-margin/bnbTransfer.ts | 16 +- .../changeAutoRepayFutures.ts | 10 +- .../fundAutoCollection.ts | 8 +- .../fundCollection.ts | 10 +- .../getAccountBalance.ts | 16 +- .../getAutoRepayFuturesStatus.ts | 8 +- .../getCollateralRate.ts | 8 +- .../getPortfolioMarginAccount.ts | 9 +- .../getPortfolioMarginAssetIndexPrice.ts | 16 +- .../getPortfolioMarginAssetLeverage.ts | 8 +- .../getPortfolioMarginBankruptcyLoanAmount.ts | 8 +- .../getPortfolioMarginInterestHistory.ts | 16 +- .../repayFuturesNegativeBalance.ts | 8 +- .../repayPortfolioMarginBankruptcyLoan.ts | 8 +- .../rebate-api/getSpotRebateHistoryRecords.ts | 19 +- .../account-api/getFlexibleProductPosition.ts | 43 +-- .../simpleEarnFlexibleProductList.ts | 41 +-- .../earn-api/redeemFlexibleProduct.ts | 31 +- .../earn-api/subscribeFlexibleProduct.ts | 23 +- .../account-api/accountCommission.ts | 10 +- .../binance-spot/account-api/getAccount.ts | 8 +- .../binance-spot/account-api/myAllocations.ts | 18 +- .../account-api/myPreventedMatches.ts | 18 +- .../binance-spot/account-api/myTrades.ts | 20 +- .../account-api/rateLimitOrder.ts | 8 +- .../binance-spot/general-api/exchangeInfo.ts | 32 +- src/tools/binance-spot/general-api/ping.ts | 44 +-- src/tools/binance-spot/general-api/time.ts | 52 +-- .../binance-spot/market-api/aggTrades.ts | 16 +- src/tools/binance-spot/market-api/avgPrice.ts | 8 +- src/tools/binance-spot/market-api/depth.ts | 10 +- .../binance-spot/market-api/getTrades.ts | 10 +- .../market-api/historicalTrades.ts | 12 +- src/tools/binance-spot/market-api/klines.ts | 52 +-- src/tools/binance-spot/market-api/ticker.ts | 17 +- .../binance-spot/market-api/ticker24hr.ts | 8 +- .../market-api/tickerBookTicker.ts | 8 +- .../binance-spot/market-api/tickerPrice.ts | 8 +- .../market-api/tickerTradingDay.ts | 8 +- src/tools/binance-spot/market-api/uiKlines.ts | 52 +-- src/tools/binance-spot/trade-api/allOrders.ts | 22 +- .../trade-api/deleteOpenOrders.ts | 8 +- .../binance-spot/trade-api/deleteOrder.ts | 12 +- .../binance-spot/trade-api/getOpenOrders.ts | 8 +- src/tools/binance-spot/trade-api/getOrder.ts | 12 +- src/tools/binance-spot/trade-api/newOrder.ts | 54 +-- .../binance-spot/trade-api/openOrderList.ts | 8 +- src/tools/binance-spot/trade-api/orderOco.ts | 34 +- .../deleteUserDataStream.ts | 8 +- .../userdatastream-api/newUserDataStream.ts | 5 +- .../userdatastream-api/putUserDataStream.ts | 8 +- .../ETH-staking-api/ethStakingAccount.ts | 9 +- .../getCurrentEthStakingQuota.ts | 9 +- .../getEthRedemptionHistory.ts | 59 ++-- .../ETH-staking-api/getEthStakingHistory.ts | 59 ++-- .../ETH-staking-api/getWbethRateHistory.ts | 51 +-- .../ETH-staking-api/getWbethRewardsHistory.ts | 59 ++-- .../ETH-staking-api/getWbethUnwrapHistory.ts | 51 +-- .../ETH-staking-api/getWbethWrapHistory.ts | 43 +-- .../ETH-staking-api/redeemEth.ts | 21 +- .../ETH-staking-api/subscribeEthStaking.ts | 11 +- .../ETH-staking-api/wrapBeth.ts | 11 +- .../SOL-staking-api/claimBoostRewards.ts | 9 +- .../SOL-staking-api/getBnsolRateHistory.ts | 43 +-- .../SOL-staking-api/getBnsolRewardsHistory.ts | 51 +-- .../SOL-staking-api/getBoostRewardsHistory.ts | 51 +-- .../getSolRedemptionHistory.ts | 43 +-- .../SOL-staking-api/getSolStakingHistory.ts | 43 +-- .../getSolStakingQuotaDetails.ts | 9 +- .../SOL-staking-api/getUnclaimedRewards.ts | 9 +- .../SOL-staking-api/redeemSol.ts | 19 +- .../SOL-staking-api/solStakingAccount.ts | 9 +- .../SOL-staking-api/subscribeSolStaking.ts | 11 +- .../assets-api/getFuturesAssetsSummary.ts | 17 +- .../assets-api/getFuturesPositionRisk.ts | 19 +- .../assets-api/getMarginAssetsSummary.ts | 9 +- .../assets-api/getSpotAssetsSummary.ts | 27 +- .../assets-api/getSubAccountAssets.ts | 11 +- src/tools/binance-sub-account/createApiKey.ts | 16 +- .../createVirtualSubAccount.ts | 11 +- src/tools/binance-sub-account/deleteApiKey.ts | 12 +- .../deposit-api/getDepositAddress.ts | 15 +- .../deposit-api/getDepositHistory.ts | 35 +- .../binance-sub-account/enableFutures.ts | 10 +- src/tools/binance-sub-account/enableMargin.ts | 10 +- .../getApiKeyIpRestriction.ts | 12 +- .../getSubAccountAssets.ts | 10 +- .../getSubAccountDepositAddress.ts | 14 +- .../getSubAccountDepositHistory.ts | 28 +- .../getSubAccountFuturesPositionRisk.ts | 18 +- .../getSubAccountFuturesSummary.ts | 10 +- .../binance-sub-account/getSubAccountList.ts | 16 +- .../getSubAccountMarginSummary.ts | 10 +- .../getSubAccountSpotSummary.ts | 20 +- .../getSubAccountStatus.ts | 10 +- .../getSubAccountTransferHistory.ts | 18 +- .../getUniversalTransferHistory.ts | 20 +- .../management-api/createSubAccount.ts | 19 +- .../management-api/enableFutures.ts | 11 +- .../management-api/enableMargin.ts | 11 +- .../getSubAccountApiPermission.ts | 13 +- .../management-api/getSubAccountList.ts | 29 +- .../management-api/getSubAccountStatus.ts | 11 +- .../transfer-api/futuresTransfer.ts | 19 +- .../transfer-api/getTransferHistory.ts | 25 +- .../transfer-api/transferToMaster.ts | 12 +- .../transfer-api/transferToSubAccount.ts | 15 +- .../transfer-api/universalTransfer.ts | 49 +-- .../binance-sub-account/transferToMaster.ts | 13 +- .../transferToSubAccount.ts | 14 +- .../binance-sub-account/universalTransfer.ts | 40 +-- .../updateIpRestriction.ts | 16 +- .../market-api/getBorrowInterestRate.ts | 15 +- .../market-api/getCollateralAssetData.ts | 15 +- .../market-api/getLoanableAssetsData.ts | 25 +- .../trade-api/vipLoanBorrow.ts | 43 ++- .../trade-api/vipLoanRenew.ts | 25 +- .../trade-api/vipLoanRepay.ts | 17 +- .../checkVIPLoanCollateralAccount.ts | 17 +- .../getVIPLoanOngoingOrders.ts | 49 +-- .../queryApplicationStatus.ts | 29 +- .../account-api/accountApiTradingStatus.ts | 8 +- .../binance-wallet/account-api/accountInfo.ts | 8 +- .../account-api/accountStatus.ts | 8 +- .../account-api/dailyAccountSnapshot.ts | 16 +- .../account-api/disableFastWithdrawSwitch.ts | 8 +- .../account-api/enableFastWithdrawSwitch.ts | 8 +- .../account-api/getApiKeyPermission.ts | 8 +- .../binance-wallet/asset-api/assetDetail.ts | 10 +- .../asset-api/assetDividendRecord.ts | 16 +- .../binance-wallet/asset-api/dustTransfer.ts | 10 +- src/tools/binance-wallet/asset-api/dustlog.ts | 12 +- .../binance-wallet/asset-api/fundingWallet.ts | 12 +- .../getAssetsThatCanBeConvertedIntoBnb.ts | 8 +- .../getCloudMiningPaymentAndRefundHistory.ts | 16 +- .../asset-api/getOpenSymbolList.ts | 44 +-- .../asset-api/queryUserDelegationHistory.ts | 18 +- .../queryUserUniversalTransferHistory.ts | 22 +- .../asset-api/queryUserWalletBalance.ts | 8 +- ...ggleBnbBurnOnSpotTradeAndMarginInterest.ts | 12 +- .../binance-wallet/asset-api/tradeFee.ts | 10 +- .../binance-wallet/asset-api/userAsset.ts | 10 +- .../asset-api/userUniversalTransfer.ts | 18 +- .../capital-api/allCoinsInformation.ts | 8 +- .../capital-api/depositAddress.ts | 12 +- .../capital-api/depositHistory.ts | 20 +- .../fetchDepositAddressListWithNetwork.ts | 12 +- .../capital-api/fetchWithdrawAddressList.ts | 5 +- .../oneClickArrivalDepositApply.ts | 10 +- .../binance-wallet/capital-api/withdraw.ts | 26 +- .../capital-api/withdrawHistory.ts | 22 +- .../getSymbolsDelistScheduleForSpot.ts | 5 +- .../binance-wallet/others-api/systemStatus.ts | 44 +-- .../travel-rule-api/brokerWithdraw.ts | 30 +- .../depositHistoryTravelRule.ts | 20 +- .../travel-rule-api/onboardedVaspList.ts | 5 +- .../submitDepositQuestionnaire.ts | 18 +- .../submitDepositQuestionnaireTravelRule.ts | 12 +- .../travel-rule-api/withdrawHistoryV1.ts | 20 +- .../travel-rule-api/withdrawHistoryV2.ts | 20 +- .../travel-rule-api/withdrawTravelRule.ts | 24 +- src/tools/binanceAccountInfo.ts | 112 +++--- src/tools/binanceOrderBook.ts | 8 +- src/tools/binanceSpotPlaceOrder.ts | 3 +- ...nanceTimeWeightedAveragePriceFutureAlgo.ts | 3 +- src/tools/credit-line/index.ts | 12 +- src/tools/creditline/index.ts | 15 +- src/tools/custodial-solution/index.ts | 27 +- src/tools/custodial/index.ts | 57 ++-- src/tools/general/index.ts | 57 ++-- src/tools/market/index.ts | 262 ++++++++------- src/tools/otc/index.ts | 18 +- src/tools/staking/index.ts | 18 +- src/tools/subaccount/index.ts | 86 +++-- src/tools/trade/oco.ts | 136 ++++---- src/tools/trade/orders.ts | 318 ++++++++++-------- src/tools/userdata-stream/index.ts | 12 +- src/tools/wallet/index.ts | 144 ++++---- 845 files changed, 10759 insertions(+), 8162 deletions(-) create mode 100644 scripts/codemod-register-tool.mjs diff --git a/scripts/codemod-register-tool.mjs b/scripts/codemod-register-tool.mjs new file mode 100644 index 00000000..0066def3 --- /dev/null +++ b/scripts/codemod-register-tool.mjs @@ -0,0 +1,183 @@ +#!/usr/bin/env node +/** + * Codemod: Replace deprecated server.tool(...) with server.registerTool(...). + * Patterns: + * server.tool(name, description, schema, cb) -> server.registerTool(name, { description, inputSchema: schema }, cb) + * server.tool(name, description, {}, cb) -> server.registerTool(name, { description }, cb) + * server.tool(name, schema, cb) -> server.registerTool(name, { inputSchema: schema }, cb) + */ +import fs from "fs"; +import path from "path"; +import { fileURLToPath } from "url"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const SRC = path.join(__dirname, "..", "src"); + +function findMatchingBrace(str, start, open = "{", close = "}") { + let depth = 0; + for (let i = start; i < str.length; i++) { + if (str[i] === open) depth++; + else if (str[i] === close) { + depth--; + if (depth === 0) return i; + } + } + + return -1; +} + +function findMatchingParen(str, start) { + return findMatchingBrace(str, start, "(", ")"); +} + +/** Find end of next top-level argument (string, object, or async function start). */ +function skipArg(content, i) { + const rest = content.slice(i); + const trimmed = rest.replace(/^\s*,?\s*/s, ""); + const skipped = rest.length - trimmed.length; + i += skipped; + const ch = content[i]; + if (ch === '"' || ch === "'") { + const q = ch; + i++; + while (i < content.length && content[i] !== q) { + if (content[i] === "\\") i++; + i++; + } + + return i + 1; + } + if (ch === "{") { + const end = findMatchingBrace(content, i); + + return end >= 0 ? end + 1 : i; + } + if (ch === "(") { + const end = findMatchingParen(content, i); + + return end >= 0 ? end + 1 : i; + } + if (ch === "a" && content.slice(i, i + 5) === "async") { + const parenStart = content.indexOf("(", i); + if (parenStart >= 0) { + const end = findMatchingParen(content, parenStart); + + return end >= 0 ? end + 1 : i; + } + } + + return i; +} + +function transformFile(filePath) { + let content = fs.readFileSync(filePath, "utf8"); + const original = content; + let changed = false; + + while (true) { + const idx = content.indexOf("server.tool("); + if (idx < 0) break; + + const openParen = idx + "server.tool".length; + const closeParen = findMatchingParen(content, openParen); + if (closeParen < 0) break; + + const argsStr = content.slice(openParen + 1, closeParen); + let i = 0; + while (i < argsStr.length && /\s/.test(argsStr[i])) i++; + if (i >= argsStr.length) break; + + const firstCh = argsStr[i]; + if (firstCh !== '"' && firstCh !== "'") break; + + const q = firstCh; + let nameEnd = i + 1; + while (nameEnd < argsStr.length && argsStr[nameEnd] !== q) { + if (argsStr[nameEnd] === "\\") nameEnd++; + nameEnd++; + } + const name = argsStr.slice(i + 1, nameEnd).replace(/\\"/g, '"'); + i = nameEnd + 1; + while (i < argsStr.length && /[\s,]/.test(argsStr[i])) i++; + if (i >= argsStr.length) break; + const secondCh = argsStr[i]; + let description = null; + let schemaStr = null; + + if (secondCh === '"' || secondCh === "'") { + const q2 = secondCh; + let descEnd = i + 1; + while (descEnd < argsStr.length && argsStr[descEnd] !== q2) { + if (argsStr[descEnd] === "\\") descEnd++; + descEnd++; + } + description = argsStr.slice(i + 1, descEnd).replace(/\\"/g, '"'); + i = descEnd + 1; + while (i < argsStr.length && /[\s,]/.test(argsStr[i])) i++; + if (i >= argsStr.length) break; + if (argsStr[i] === "{") { + const end = findMatchingBrace(argsStr, i); + schemaStr = end >= 0 ? argsStr.slice(i, end + 1) : "{}"; + i = end + 1; + } + } else if (secondCh === "{") { + const end = findMatchingBrace(argsStr, i); + schemaStr = end >= 0 ? argsStr.slice(i, end + 1) : "{}"; + i = end + 1; + } + + while (i < argsStr.length && /[\s,]/.test(argsStr[i])) i++; + const callbackStart = i; + const callbackStr = argsStr.slice(callbackStart).trim(); + const restOfCall = content.slice(closeParen + 1); + + const isEmptySchema = + schemaStr === "{}" || (schemaStr && schemaStr.replace(/\s/g, "") === "{}"); + let configObj; + if (description !== null && isEmptySchema) { + configObj = `{ description: ${JSON.stringify(description)} }`; + } else if (description !== null && schemaStr) { + configObj = `{\n description: ${JSON.stringify(description)},\n inputSchema: ${schemaStr},\n }`; + } else if (schemaStr) { + configObj = `{\n inputSchema: ${schemaStr},\n }`; + } else { + configObj = "{}"; + } + + const newArgs = `"${name.replace(/"/g, '\\"')}",\n ${configObj},\n ${callbackStr}`; + content = content.slice(0, idx) + "server.registerTool(" + newArgs + content.slice(closeParen); + changed = true; + } + + if (changed) { + fs.writeFileSync(filePath, content, "utf8"); + + return true; + } + + return false; +} + +function walk(dir) { + const entries = fs.readdirSync(dir, { withFileTypes: true }); + for (const e of entries) { + const full = path.join(dir, e.name); + if (e.isDirectory() && e.name !== "node_modules") { + walk(full); + } else if (e.isFile() && e.name.endsWith(".ts")) { + try { + const raw = fs.readFileSync(full, "utf8"); + if (raw.includes("server.tool(")) { + if (transformFile(full)) { + console.log("Updated:", path.relative(SRC, full)); + } + } + } catch (err) { + console.error("Error processing", full, err.message); + } + } + } +} + +walk(SRC); +console.log("Done."); diff --git a/src/modules/algo/future-algo/TwapNewTrade.ts b/src/modules/algo/future-algo/TwapNewTrade.ts index cc8c2713..89aef9f6 100644 --- a/src/modules/algo/future-algo/TwapNewTrade.ts +++ b/src/modules/algo/future-algo/TwapNewTrade.ts @@ -6,47 +6,50 @@ import { z } from "zod"; import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceTwapNewTrade(server: McpServer) { - server.tool( + server.registerTool( "BinanceTimeWeightedAveragePriceNewOrder", - "The Time-Weighted Average Price (TWAP) New Order API allows users to place a TWAP order on USDⓈ-M Contracts in Binance Futures. TWAP orders execute gradually over a specified duration to achieve a better average execution price while minimizing market impact.", { - symbol: z.string().describe("Trading symbol (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Trading side (BUY or SELL)"), - positionSide: z - .enum(["BOTH", "LONG", "SHORT"]) - .optional() - .describe( - "Default BOTH for One-way Mode; LONG or SHORT for Hedge Mode. Must be sent in Hedge Mode.", - ), - quantity: z - .number() - .positive() - .min(1000) - .max(1000000) - .describe("Quantity of base asset; Notional must be between 1,000 and 1,000,000 USDT"), - duration: z - .number() - .int() - .min(300) - .max(86400) - .describe("Duration for TWAP orders in seconds. Must be between 300 and 86400"), - clientAlgoId: z - .string() - .length(32) - .optional() - .describe("A unique 32-character ID among Algo orders"), - reduceOnly: z - .boolean() - .optional() - .describe( - "true or false. Default false; Cannot be sent in Hedge Mode or when opening a position", - ), - limitPrice: z - .number() - .positive() - .optional() - .describe("Limit price of the order; Defaults to market price if not sent"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "The Time-Weighted Average Price (TWAP) New Order API allows users to place a TWAP order on USDⓈ-M Contracts in Binance Futures. TWAP orders execute gradually over a specified duration to achieve a better average execution price while minimizing market impact.", + inputSchema: { + symbol: z.string().describe("Trading symbol (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Trading side (BUY or SELL)"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe( + "Default BOTH for One-way Mode; LONG or SHORT for Hedge Mode. Must be sent in Hedge Mode.", + ), + quantity: z + .number() + .positive() + .min(1000) + .max(1000000) + .describe("Quantity of base asset; Notional must be between 1,000 and 1,000,000 USDT"), + duration: z + .number() + .int() + .min(300) + .max(86400) + .describe("Duration for TWAP orders in seconds. Must be between 300 and 86400"), + clientAlgoId: z + .string() + .length(32) + .optional() + .describe("A unique 32-character ID among Algo orders"), + reduceOnly: z + .boolean() + .optional() + .describe( + "true or false. Default false; Cannot be sent in Hedge Mode or when opening a position", + ), + limitPrice: z + .number() + .positive() + .optional() + .describe("Limit price of the order; Defaults to market price if not sent"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/algo/future-algo/VPNewTrade.ts b/src/modules/algo/future-algo/VPNewTrade.ts index 007c0f01..66056935 100644 --- a/src/modules/algo/future-algo/VPNewTrade.ts +++ b/src/modules/algo/future-algo/VPNewTrade.ts @@ -6,42 +6,45 @@ import { z } from "zod"; import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceVPNewTrade(server: McpServer) { - server.tool( + server.registerTool( "BinanceVolumeParticipationNewTrade", - "The Volume Participation (VP) New Order API allows users to place a VP order on USDⓈ-M Contracts in Binance Futures.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Trading side (BUY or SELL)"), - positionSide: z - .enum(["BOTH", "LONG", "SHORT"]) - .optional() - .describe( - "Default BOTH for One-way Mode; LONG or SHORT for Hedge Mode. It must be sent in Hedge Mode.", - ), - quantity: z - .number() - .positive() - .min(10000) - .max(1000000) - .describe("Quantity of base asset; Notional must be between 10,000 and 1,000,000 USDT"), - urgency: z.enum(["LOW", "MEDIUM", "HIGH"]).describe("Execution speed: LOW, MEDIUM, HIGH"), - clientAlgoId: z - .string() - .length(32) - .optional() - .describe("A unique 32-character ID among Algo orders"), - reduceOnly: z - .boolean() - .optional() - .describe( - "true or false. Default false; Cannot be sent in Hedge Mode or when opening a position", - ), - limitPrice: z - .number() - .positive() - .optional() - .describe("Limit price of the order; Defaults to market price if not sent"), - recvWindow: z.number().int().describe("Time window for request validity"), + description: + "The Volume Participation (VP) New Order API allows users to place a VP order on USDⓈ-M Contracts in Binance Futures.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Trading side (BUY or SELL)"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe( + "Default BOTH for One-way Mode; LONG or SHORT for Hedge Mode. It must be sent in Hedge Mode.", + ), + quantity: z + .number() + .positive() + .min(10000) + .max(1000000) + .describe("Quantity of base asset; Notional must be between 10,000 and 1,000,000 USDT"), + urgency: z.enum(["LOW", "MEDIUM", "HIGH"]).describe("Execution speed: LOW, MEDIUM, HIGH"), + clientAlgoId: z + .string() + .length(32) + .optional() + .describe("A unique 32-character ID among Algo orders"), + reduceOnly: z + .boolean() + .optional() + .describe( + "true or false. Default false; Cannot be sent in Hedge Mode or when opening a position", + ), + limitPrice: z + .number() + .positive() + .optional() + .describe("Limit price of the order; Defaults to market price if not sent"), + recvWindow: z.number().int().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/algo/future-algo/cancelAlgoOrder.ts b/src/modules/algo/future-algo/cancelAlgoOrder.ts index d41e0867..4fc24f40 100644 --- a/src/modules/algo/future-algo/cancelAlgoOrder.ts +++ b/src/modules/algo/future-algo/cancelAlgoOrder.ts @@ -6,12 +6,15 @@ import { z } from "zod"; import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceFutureCancelAlgoOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceFutureCancelAlgoOrder", - "The Cancel Algo Order API allows users to cancel an active algorithmic order on USDⓈ-M Contracts in Binance Futures.", { - algoId: z.number().int().describe("Algo order ID (e.g., 14511)"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "The Cancel Algo Order API allows users to cancel an active algorithmic order on USDⓈ-M Contracts in Binance Futures.", + inputSchema: { + algoId: z.number().int().describe("Algo order ID (e.g., 14511)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/algo/future-algo/currentAlgoOpenOrders.ts b/src/modules/algo/future-algo/currentAlgoOpenOrders.ts index 1001a67b..32dda635 100644 --- a/src/modules/algo/future-algo/currentAlgoOpenOrders.ts +++ b/src/modules/algo/future-algo/currentAlgoOpenOrders.ts @@ -6,11 +6,14 @@ import { z } from "zod"; import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceFutureCurrentAlgoOpenOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceFutureCurrentAlgoOpenOrders", - "The Query Current Algo Open Orders API retrieves a list of currently active algorithmic orders for USDⓈ-M Contracts in Binance Futures.", { - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "The Query Current Algo Open Orders API retrieves a list of currently active algorithmic orders for USDⓈ-M Contracts in Binance Futures.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/algo/future-algo/historicalAlgoOrder.ts b/src/modules/algo/future-algo/historicalAlgoOrder.ts index edafa7a9..2e693e63 100644 --- a/src/modules/algo/future-algo/historicalAlgoOrder.ts +++ b/src/modules/algo/future-algo/historicalAlgoOrder.ts @@ -6,32 +6,35 @@ import { z } from "zod"; import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceFutureHistoricalAlgoOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceFutureHistoricalAlgoOrder", - "The Query Historical Algo Orders API retrieves a list of past algorithmic orders for USDⓈ-M Contracts in Binance Futures.", { - symbol: z.string().optional().describe("Trading symbol (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).optional().describe("Trading side (BUY or SELL)"), - startTime: z - .number() - .int() - .optional() - .describe("Start time in milliseconds (e.g., 1641522717552)"), - endTime: z - .number() - .int() - .optional() - .describe("End time in milliseconds (e.g., 1641522526562)"), - page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), - pageSize: z - .number() - .int() - .min(1) - .max(100) - .default(100) - .optional() - .describe("Number of results per page, MIN 1, MAX 100, default is 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "The Query Historical Algo Orders API retrieves a list of past algorithmic orders for USDⓈ-M Contracts in Binance Futures.", + inputSchema: { + symbol: z.string().optional().describe("Trading symbol (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).optional().describe("Trading side (BUY or SELL)"), + startTime: z + .number() + .int() + .optional() + .describe("Start time in milliseconds (e.g., 1641522717552)"), + endTime: z + .number() + .int() + .optional() + .describe("End time in milliseconds (e.g., 1641522526562)"), + page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), + pageSize: z + .number() + .int() + .min(1) + .max(100) + .default(100) + .optional() + .describe("Number of results per page, MIN 1, MAX 100, default is 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/algo/future-algo/subOrders.ts b/src/modules/algo/future-algo/subOrders.ts index e0306890..f36cbc6d 100644 --- a/src/modules/algo/future-algo/subOrders.ts +++ b/src/modules/algo/future-algo/subOrders.ts @@ -6,21 +6,24 @@ import { z } from "zod"; import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceFutureSubOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceFutureSubOrders", - "The Sub Orders API retrieves sub-orders associated with a specified algoId for USDⓈ-M Contracts in Binance Futures.", { - algoId: z.number().int().describe("Algo order ID"), - page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), - pageSize: z - .number() - .int() - .min(1) - .max(100) - .default(100) - .optional() - .describe("Number of results per page, MIN 1, MAX 100, default is 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "The Sub Orders API retrieves sub-orders associated with a specified algoId for USDⓈ-M Contracts in Binance Futures.", + inputSchema: { + algoId: z.number().int().describe("Algo order ID"), + page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), + pageSize: z + .number() + .int() + .min(1) + .max(100) + .default(100) + .optional() + .describe("Number of results per page, MIN 1, MAX 100, default is 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/algo/spot-algo/cancelOpenTWAPOrder.ts b/src/modules/algo/spot-algo/cancelOpenTWAPOrder.ts index 3652e326..e2068e02 100644 --- a/src/modules/algo/spot-algo/cancelOpenTWAPOrder.ts +++ b/src/modules/algo/spot-algo/cancelOpenTWAPOrder.ts @@ -6,12 +6,15 @@ import { z } from "zod"; import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceSpotCancelOpenTWAPOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceSpotCancelOpenTWAPOrder", - "The Cancel Algo Order API allows users to cancel an open TWAP algorithmic order for spot trading on Binance.", { - algoId: z.number().int().describe("Algo order ID (e.g., 14511)"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "The Cancel Algo Order API allows users to cancel an open TWAP algorithmic order for spot trading on Binance.", + inputSchema: { + algoId: z.number().int().describe("Algo order ID (e.g., 14511)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/algo/spot-algo/currentAlgoOpenOrders.ts b/src/modules/algo/spot-algo/currentAlgoOpenOrders.ts index 28bca403..ad57c20a 100644 --- a/src/modules/algo/spot-algo/currentAlgoOpenOrders.ts +++ b/src/modules/algo/spot-algo/currentAlgoOpenOrders.ts @@ -6,11 +6,14 @@ import { z } from "zod"; import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceSpotCurrentAlgoOpenOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceSpotCurrentAlgoOpenOrders", - "This API retrieves all open SPOT TWAP (Time-Weighted Average Price) orders on Binance.", { - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "This API retrieves all open SPOT TWAP (Time-Weighted Average Price) orders on Binance.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/algo/spot-algo/historicalAlgoOrders.ts b/src/modules/algo/spot-algo/historicalAlgoOrders.ts index bcdba16c..9c26464b 100644 --- a/src/modules/algo/spot-algo/historicalAlgoOrders.ts +++ b/src/modules/algo/spot-algo/historicalAlgoOrders.ts @@ -6,32 +6,35 @@ import { z } from "zod"; import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceSpotHistoricalAlgoOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceSpotHistoricalAlgoOrders", - "This API retrieves all historical SPOT TWAP (Time-Weighted Average Price) orders from Binance.", { - symbol: z.string().optional().describe("Trading symbol (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).optional().describe("Trading side (BUY or SELL)"), - startTime: z - .number() - .int() - .optional() - .describe("Start time in milliseconds (e.g., 1641522717552)"), - endTime: z - .number() - .int() - .optional() - .describe("End time in milliseconds (e.g., 1641522526562)"), - page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), - pageSize: z - .number() - .int() - .min(1) - .max(100) - .default(100) - .optional() - .describe("Number of results per page, MIN 1, MAX 100, default is 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "This API retrieves all historical SPOT TWAP (Time-Weighted Average Price) orders from Binance.", + inputSchema: { + symbol: z.string().optional().describe("Trading symbol (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).optional().describe("Trading side (BUY or SELL)"), + startTime: z + .number() + .int() + .optional() + .describe("Start time in milliseconds (e.g., 1641522717552)"), + endTime: z + .number() + .int() + .optional() + .describe("End time in milliseconds (e.g., 1641522526562)"), + page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), + pageSize: z + .number() + .int() + .min(1) + .max(100) + .default(100) + .optional() + .describe("Number of results per page, MIN 1, MAX 100, default is 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/algo/spot-algo/spotTWAPOrder.ts b/src/modules/algo/spot-algo/spotTWAPOrder.ts index 05f6b156..0d69adf7 100644 --- a/src/modules/algo/spot-algo/spotTWAPOrder.ts +++ b/src/modules/algo/spot-algo/spotTWAPOrder.ts @@ -6,36 +6,39 @@ import { z } from "zod"; import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceSpotTwapNewTrade(server: McpServer) { - server.tool( + server.registerTool( "BinanceSpotTimeWeightedAveragePriceNewOrder", - "The TWAP (Time-Weighted Average Price) New Order API allows users to place TWAP algorithmic orders for USDⓈ-M Futures on Binance.", { - symbol: z.string().describe("Trading symbol (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Trading side (BUY or SELL)"), - quantity: z - .number() - .positive() - .describe( - "Quantity of base asset; Maximum notional per order is 200k, 2mm, or 10mm, depending on the symbol", - ), - duration: z - .number() - .int() - .min(300) - .max(86400) - .describe("Duration for TWAP orders in seconds. Must be between 300 and 86400"), - clientAlgoId: z - .string() - .length(32) - .optional() - .describe( - "A unique 32-character ID among Algo orders. If not sent, a default value will be assigned", - ), - limitPrice: z - .number() - .positive() - .optional() - .describe("Limit price of the order; Defaults to market price if not sent"), + description: + "The TWAP (Time-Weighted Average Price) New Order API allows users to place TWAP algorithmic orders for USDⓈ-M Futures on Binance.", + inputSchema: { + symbol: z.string().describe("Trading symbol (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Trading side (BUY or SELL)"), + quantity: z + .number() + .positive() + .describe( + "Quantity of base asset; Maximum notional per order is 200k, 2mm, or 10mm, depending on the symbol", + ), + duration: z + .number() + .int() + .min(300) + .max(86400) + .describe("Duration for TWAP orders in seconds. Must be between 300 and 86400"), + clientAlgoId: z + .string() + .length(32) + .optional() + .describe( + "A unique 32-character ID among Algo orders. If not sent, a default value will be assigned", + ), + limitPrice: z + .number() + .positive() + .optional() + .describe("Limit price of the order; Defaults to market price if not sent"), + }, }, async (params) => { try { diff --git a/src/modules/algo/spot-algo/subOrders.ts b/src/modules/algo/spot-algo/subOrders.ts index 03bd51f7..ba459141 100644 --- a/src/modules/algo/spot-algo/subOrders.ts +++ b/src/modules/algo/spot-algo/subOrders.ts @@ -6,21 +6,24 @@ import { z } from "zod"; import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceSpotSubOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceSpotSubOrders", - "The Query Sub Orders API retrieves details of sub-orders associated with a specific algorithmic (Algo) order for spot trading on Binance.", { - algoId: z.number().int().describe("Algo order ID"), - page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), - pageSize: z - .number() - .int() - .min(1) - .max(100) - .default(100) - .optional() - .describe("Number of results per page, MIN 1, MAX 100, default is 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "The Query Sub Orders API retrieves details of sub-orders associated with a specific algorithmic (Algo) order for spot trading on Binance.", + inputSchema: { + algoId: z.number().int().describe("Algo order ID"), + page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), + pageSize: z + .number() + .int() + .min(1) + .max(100) + .default(100) + .optional() + .describe("Number of results per page, MIN 1, MAX 100, default is 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/auto-invest/changePlanStatus.ts b/src/modules/auto-invest/changePlanStatus.ts index 91337e6b..2eddef03 100644 --- a/src/modules/auto-invest/changePlanStatus.ts +++ b/src/modules/auto-invest/changePlanStatus.ts @@ -12,15 +12,17 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerAutoInvestChangePlanStatus(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestChangePlanStatus", - "Change the status of an auto-invest plan (pause or resume).", { - planId: z.number().int().describe("Plan ID to modify"), - status: z - .enum(["ONGOING", "PAUSED"]) - .describe("New status (ONGOING to resume, PAUSED to pause)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Change the status of an auto-invest plan (pause or resume).", + inputSchema: { + planId: z.number().int().describe("Plan ID to modify"), + status: z + .enum(["ONGOING", "PAUSED"]) + .describe("New status (ONGOING to resume, PAUSED to pause)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/auto-invest/createPlan.ts b/src/modules/auto-invest/createPlan.ts index 203e8197..97782ab4 100644 --- a/src/modules/auto-invest/createPlan.ts +++ b/src/modules/auto-invest/createPlan.ts @@ -12,33 +12,39 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerAutoInvestCreatePlan(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestCreatePlan", - "Create an auto-invest plan for dollar-cost averaging. Automatically purchases crypto at regular intervals.", { - sourceType: z.enum(["MAIN_SITE", "TR"]).describe("Source type"), - planType: z.enum(["SINGLE", "PORTFOLIO", "INDEX"]).describe("Plan type"), - subscriptionAmount: z.string().describe("Amount per subscription"), - subscriptionCycle: z - .enum(["H1", "H4", "H8", "H12", "WEEKLY", "DAILY", "MONTHLY", "BI_WEEKLY"]) - .describe("Subscription frequency"), - subscriptionStartDay: z - .number() - .int() - .optional() - .describe("Start day (1-31 for MONTHLY, 1-7 for WEEKLY)"), - subscriptionStartTime: z.number().int().min(0).max(23).describe("Start hour (0-23)"), - sourceAsset: z.string().describe("Source asset (e.g., 'USDT')"), - flexibleAllowedToUse: z.boolean().optional().describe("Allow using flexible savings balance"), - details: z - .array( - z.object({ - targetAsset: z.string().describe("Target asset to purchase"), - percentage: z.number().describe("Percentage allocation (0-100)"), - }), - ) - .describe("Target assets and allocation percentages"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Create an auto-invest plan for dollar-cost averaging. Automatically purchases crypto at regular intervals.", + inputSchema: { + sourceType: z.enum(["MAIN_SITE", "TR"]).describe("Source type"), + planType: z.enum(["SINGLE", "PORTFOLIO", "INDEX"]).describe("Plan type"), + subscriptionAmount: z.string().describe("Amount per subscription"), + subscriptionCycle: z + .enum(["H1", "H4", "H8", "H12", "WEEKLY", "DAILY", "MONTHLY", "BI_WEEKLY"]) + .describe("Subscription frequency"), + subscriptionStartDay: z + .number() + .int() + .optional() + .describe("Start day (1-31 for MONTHLY, 1-7 for WEEKLY)"), + subscriptionStartTime: z.number().int().min(0).max(23).describe("Start hour (0-23)"), + sourceAsset: z.string().describe("Source asset (e.g., 'USDT')"), + flexibleAllowedToUse: z + .boolean() + .optional() + .describe("Allow using flexible savings balance"), + details: z + .array( + z.object({ + targetAsset: z.string().describe("Target asset to purchase"), + percentage: z.number().describe("Percentage allocation (0-100)"), + }), + ) + .describe("Target assets and allocation percentages"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/auto-invest/editPlan.ts b/src/modules/auto-invest/editPlan.ts index a7df3faf..552e84d5 100644 --- a/src/modules/auto-invest/editPlan.ts +++ b/src/modules/auto-invest/editPlan.ts @@ -12,32 +12,38 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerAutoInvestEditPlan(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestEditPlan", - "Edit an existing auto-invest plan. Modify subscription amount, cycle, or target allocations.", { - planId: z.number().int().describe("Plan ID to edit"), - subscriptionAmount: z.string().describe("New amount per subscription"), - subscriptionCycle: z - .enum(["H1", "H4", "H8", "H12", "WEEKLY", "DAILY", "MONTHLY", "BI_WEEKLY"]) - .describe("New subscription frequency"), - subscriptionStartDay: z - .number() - .int() - .optional() - .describe("New start day (1-31 for MONTHLY, 1-7 for WEEKLY)"), - subscriptionStartTime: z.number().int().min(0).max(23).describe("New start hour (0-23)"), - sourceAsset: z.string().describe("Source asset (e.g., 'USDT')"), - flexibleAllowedToUse: z.boolean().optional().describe("Allow using flexible savings balance"), - details: z - .array( - z.object({ - targetAsset: z.string().describe("Target asset to purchase"), - percentage: z.number().describe("Percentage allocation (0-100)"), - }), - ) - .describe("New target assets and allocation percentages"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Edit an existing auto-invest plan. Modify subscription amount, cycle, or target allocations.", + inputSchema: { + planId: z.number().int().describe("Plan ID to edit"), + subscriptionAmount: z.string().describe("New amount per subscription"), + subscriptionCycle: z + .enum(["H1", "H4", "H8", "H12", "WEEKLY", "DAILY", "MONTHLY", "BI_WEEKLY"]) + .describe("New subscription frequency"), + subscriptionStartDay: z + .number() + .int() + .optional() + .describe("New start day (1-31 for MONTHLY, 1-7 for WEEKLY)"), + subscriptionStartTime: z.number().int().min(0).max(23).describe("New start hour (0-23)"), + sourceAsset: z.string().describe("Source asset (e.g., 'USDT')"), + flexibleAllowedToUse: z + .boolean() + .optional() + .describe("Allow using flexible savings balance"), + details: z + .array( + z.object({ + targetAsset: z.string().describe("Target asset to purchase"), + percentage: z.number().describe("Percentage allocation (0-100)"), + }), + ) + .describe("New target assets and allocation percentages"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/auto-invest/getHistoryList.ts b/src/modules/auto-invest/getHistoryList.ts index 09222360..4f458d9c 100644 --- a/src/modules/auto-invest/getHistoryList.ts +++ b/src/modules/auto-invest/getHistoryList.ts @@ -12,27 +12,29 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerAutoInvestGetHistoryList(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestGetHistoryList", - "Get auto-invest transaction history. Shows all past recurring purchases.", { - planId: z.number().int().optional().describe("Filter by plan ID"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - targetAsset: z.string().optional().describe("Filter by target asset"), - planType: z - .enum(["SINGLE", "PORTFOLIO", "INDEX", "ALL"]) - .optional() - .describe("Plan type filter"), - size: z - .number() - .int() - .min(1) - .max(100) - .optional() - .describe("Number of results (default 10, max 100)"), - current: z.number().int().min(1).optional().describe("Page number (default 1)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Get auto-invest transaction history. Shows all past recurring purchases.", + inputSchema: { + planId: z.number().int().optional().describe("Filter by plan ID"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + targetAsset: z.string().optional().describe("Filter by target asset"), + planType: z + .enum(["SINGLE", "PORTFOLIO", "INDEX", "ALL"]) + .optional() + .describe("Plan type filter"), + size: z + .number() + .int() + .min(1) + .max(100) + .optional() + .describe("Number of results (default 10, max 100)"), + current: z.number().int().min(1).optional().describe("Page number (default 1)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/auto-invest/getIndexInfo.ts b/src/modules/auto-invest/getIndexInfo.ts index 2cc94533..292cdb36 100644 --- a/src/modules/auto-invest/getIndexInfo.ts +++ b/src/modules/auto-invest/getIndexInfo.ts @@ -12,12 +12,15 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerAutoInvestGetIndexInfo(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestGetIndexInfo", - "Get auto-invest index information. Index plans allow investing in a basket of cryptocurrencies.", { - indexId: z.number().int().optional().describe("Specific index ID to query"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get auto-invest index information. Index plans allow investing in a basket of cryptocurrencies.", + inputSchema: { + indexId: z.number().int().optional().describe("Specific index ID to query"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/auto-invest/getIndexLinkedPlanPositionDetails.ts b/src/modules/auto-invest/getIndexLinkedPlanPositionDetails.ts index 8af4df8c..6e43198f 100644 --- a/src/modules/auto-invest/getIndexLinkedPlanPositionDetails.ts +++ b/src/modules/auto-invest/getIndexLinkedPlanPositionDetails.ts @@ -12,12 +12,15 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerAutoInvestGetIndexLinkedPlanPositionDetails(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestGetPlanDetails", - "Get detailed information about a specific auto-invest plan including position details.", { - planId: z.number().int().describe("Plan ID to query"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get detailed information about a specific auto-invest plan including position details.", + inputSchema: { + planId: z.number().int().describe("Plan ID to query"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/auto-invest/getIndexUserSummary.ts b/src/modules/auto-invest/getIndexUserSummary.ts index d71bd812..557e8219 100644 --- a/src/modules/auto-invest/getIndexUserSummary.ts +++ b/src/modules/auto-invest/getIndexUserSummary.ts @@ -12,12 +12,14 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerAutoInvestGetIndexUserSummary(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestGetIndexUserSummary", - "Get user's auto-invest index subscription summary.", { - indexId: z.number().int().describe("Index ID to query"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Get user's auto-invest index subscription summary.", + inputSchema: { + indexId: z.number().int().describe("Index ID to query"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/auto-invest/getPlanList.ts b/src/modules/auto-invest/getPlanList.ts index d3e93e3e..e7b04dc9 100644 --- a/src/modules/auto-invest/getPlanList.ts +++ b/src/modules/auto-invest/getPlanList.ts @@ -12,15 +12,17 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerAutoInvestGetPlanList(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestGetPlanList", - "Get list of user's auto-invest plans. Shows all recurring investment plans.", { - planType: z - .enum(["SINGLE", "PORTFOLIO", "INDEX", "ALL"]) - .optional() - .describe("Plan type filter"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Get list of user's auto-invest plans. Shows all recurring investment plans.", + inputSchema: { + planType: z + .enum(["SINGLE", "PORTFOLIO", "INDEX", "ALL"]) + .optional() + .describe("Plan type filter"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/auto-invest/getSourceAssetList.ts b/src/modules/auto-invest/getSourceAssetList.ts index dc991fd2..53d32955 100644 --- a/src/modules/auto-invest/getSourceAssetList.ts +++ b/src/modules/auto-invest/getSourceAssetList.ts @@ -12,18 +12,21 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerAutoInvestGetSourceAssetList(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestGetSourceAssetList", - "Get the list of available source assets for auto-invest plans. These are the assets you can use to fund your recurring purchases.", { - usageType: z.enum(["RECURRING", "ONE_TIME"]).optional().describe("Usage type filter"), - targetAsset: z.string().optional().describe("Filter by target asset"), - indexId: z.number().int().optional().describe("Index ID filter"), - flexibleAllowedToUse: z - .boolean() - .optional() - .describe("Filter by flexible savings availability"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get the list of available source assets for auto-invest plans. These are the assets you can use to fund your recurring purchases.", + inputSchema: { + usageType: z.enum(["RECURRING", "ONE_TIME"]).optional().describe("Usage type filter"), + targetAsset: z.string().optional().describe("Filter by target asset"), + indexId: z.number().int().optional().describe("Index ID filter"), + flexibleAllowedToUse: z + .boolean() + .optional() + .describe("Filter by flexible savings availability"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/auto-invest/getTargetAssetList.ts b/src/modules/auto-invest/getTargetAssetList.ts index b693fcc4..99e22db0 100644 --- a/src/modules/auto-invest/getTargetAssetList.ts +++ b/src/modules/auto-invest/getTargetAssetList.ts @@ -12,20 +12,26 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerAutoInvestGetTargetAssetList(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestGetTargetAssetList", - "Get the list of available target assets for auto-invest plans. Shows assets available for dollar-cost averaging.", { - targetAsset: z.string().optional().describe("Filter by specific target asset (e.g., 'BTC')"), - size: z - .number() - .int() - .min(1) - .max(100) - .optional() - .describe("Number of results (default 10, max 100)"), - current: z.number().int().min(1).optional().describe("Page number (default 1)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get the list of available target assets for auto-invest plans. Shows assets available for dollar-cost averaging.", + inputSchema: { + targetAsset: z + .string() + .optional() + .describe("Filter by specific target asset (e.g., 'BTC')"), + size: z + .number() + .int() + .min(1) + .max(100) + .optional() + .describe("Number of results (default 10, max 100)"), + current: z.number().int().min(1).optional().describe("Page number (default 1)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/auto-invest/getTargetAssetRoiData.ts b/src/modules/auto-invest/getTargetAssetRoiData.ts index ba3f3ff5..e371e0c9 100644 --- a/src/modules/auto-invest/getTargetAssetRoiData.ts +++ b/src/modules/auto-invest/getTargetAssetRoiData.ts @@ -12,15 +12,18 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerAutoInvestGetTargetAssetRoiData(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestGetTargetAssetRoiData", - "Get ROI (Return on Investment) data for auto-invest target assets. Shows historical performance data.", { - targetAsset: z.string().describe("Target asset (e.g., 'BTC')"), - hisRoiType: z - .enum(["FIVE_YEAR", "THREE_YEAR", "ONE_YEAR", "SIX_MONTH", "THREE_MONTH", "SEVEN_DAY"]) - .describe("Historical ROI time period"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get ROI (Return on Investment) data for auto-invest target assets. Shows historical performance data.", + inputSchema: { + targetAsset: z.string().describe("Target asset (e.g., 'BTC')"), + hisRoiType: z + .enum(["FIVE_YEAR", "THREE_YEAR", "ONE_YEAR", "SIX_MONTH", "THREE_MONTH", "SEVEN_DAY"]) + .describe("Historical ROI time period"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/auto-invest/oneTimeTransaction.ts b/src/modules/auto-invest/oneTimeTransaction.ts index c1ce3cda..2610bb66 100644 --- a/src/modules/auto-invest/oneTimeTransaction.ts +++ b/src/modules/auto-invest/oneTimeTransaction.ts @@ -12,26 +12,32 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerAutoInvestOneTimeTransaction(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestOneTimeTransaction", - "Execute a one-time auto-invest purchase. Instantly buy crypto using auto-invest infrastructure.", { - sourceType: z.enum(["MAIN_SITE", "TR"]).describe("Source type"), - subscriptionAmount: z.string().describe("Amount to invest"), - sourceAsset: z.string().describe("Source asset (e.g., 'USDT')"), - flexibleAllowedToUse: z.boolean().optional().describe("Allow using flexible savings balance"), - planId: z.number().int().optional().describe("Plan ID for plan-based one-time purchase"), - indexId: z.number().int().optional().describe("Index ID for index-based purchase"), - details: z - .array( - z.object({ - targetAsset: z.string().describe("Target asset to purchase"), - percentage: z.number().describe("Percentage allocation (0-100)"), - }), - ) - .optional() - .describe("Target assets and allocation (for non-plan purchases)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Execute a one-time auto-invest purchase. Instantly buy crypto using auto-invest infrastructure.", + inputSchema: { + sourceType: z.enum(["MAIN_SITE", "TR"]).describe("Source type"), + subscriptionAmount: z.string().describe("Amount to invest"), + sourceAsset: z.string().describe("Source asset (e.g., 'USDT')"), + flexibleAllowedToUse: z + .boolean() + .optional() + .describe("Allow using flexible savings balance"), + planId: z.number().int().optional().describe("Plan ID for plan-based one-time purchase"), + indexId: z.number().int().optional().describe("Index ID for index-based purchase"), + details: z + .array( + z.object({ + targetAsset: z.string().describe("Target asset to purchase"), + percentage: z.number().describe("Percentage allocation (0-100)"), + }), + ) + .optional() + .describe("Target assets and allocation (for non-plan purchases)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/auto-invest/rebalanceHistory.ts b/src/modules/auto-invest/rebalanceHistory.ts index 65bfeca3..15321c9d 100644 --- a/src/modules/auto-invest/rebalanceHistory.ts +++ b/src/modules/auto-invest/rebalanceHistory.ts @@ -12,21 +12,24 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerAutoInvestRebalanceHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestRebalanceHistory", - "Get auto-invest portfolio rebalance history. Shows past rebalancing transactions.", { - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - size: z - .number() - .int() - .min(1) - .max(100) - .optional() - .describe("Number of results (default 10, max 100)"), - current: z.number().int().min(1).optional().describe("Page number (default 1)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get auto-invest portfolio rebalance history. Shows past rebalancing transactions.", + inputSchema: { + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + size: z + .number() + .int() + .min(1) + .max(100) + .optional() + .describe("Number of results (default 10, max 100)"), + current: z.number().int().min(1).optional().describe("Page number (default 1)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/auto-invest/redemption.ts b/src/modules/auto-invest/redemption.ts index 7860d1da..5cf886be 100644 --- a/src/modules/auto-invest/redemption.ts +++ b/src/modules/auto-invest/redemption.ts @@ -12,13 +12,15 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerAutoInvestRedemption(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestRedemption", - "Redeem/sell assets from an auto-invest index plan.", { - indexId: z.number().int().describe("Index ID to redeem from"), - redemptionPercentage: z.number().min(0).max(100).describe("Percentage to redeem (0-100)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Redeem/sell assets from an auto-invest index plan.", + inputSchema: { + indexId: z.number().int().describe("Index ID to redeem from"), + redemptionPercentage: z.number().min(0).max(100).describe("Percentage to redeem (0-100)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/c2c/C2C/getAds.ts b/src/modules/c2c/C2C/getAds.ts index 75cdbcdc..2b0cf5b1 100644 --- a/src/modules/c2c/C2C/getAds.ts +++ b/src/modules/c2c/C2C/getAds.ts @@ -12,16 +12,19 @@ import { z } from "zod"; import { c2cClient } from "../../../config/binanceClient.js"; export function registerBinanceC2CGetAds(server: McpServer) { - server.tool( + server.registerTool( "BinanceC2CGetAds", - "Get available C2C/P2P trading advertisements. Browse buy/sell offers from other users.", { - asset: z.string().optional().describe("Filter by crypto asset (e.g., 'BTC', 'USDT')"), - fiat: z.string().optional().describe("Filter by fiat currency (e.g., 'USD', 'EUR')"), - tradeType: z.enum(["BUY", "SELL"]).optional().describe("Filter by trade type"), - page: z.number().int().min(1).default(1).optional().describe("Page number"), - rows: z.number().int().min(1).max(20).default(10).optional().describe("Number of rows"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get available C2C/P2P trading advertisements. Browse buy/sell offers from other users.", + inputSchema: { + asset: z.string().optional().describe("Filter by crypto asset (e.g., 'BTC', 'USDT')"), + fiat: z.string().optional().describe("Filter by fiat currency (e.g., 'USD', 'EUR')"), + tradeType: z.enum(["BUY", "SELL"]).optional().describe("Filter by trade type"), + page: z.number().int().min(1).default(1).optional().describe("Page number"), + rows: z.number().int().min(1).max(20).default(10).optional().describe("Number of rows"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/c2c/C2C/getC2CTradeHistory.ts b/src/modules/c2c/C2C/getC2CTradeHistory.ts index 1049e84a..b7d007b5 100644 --- a/src/modules/c2c/C2C/getC2CTradeHistory.ts +++ b/src/modules/c2c/C2C/getC2CTradeHistory.ts @@ -6,14 +6,17 @@ import { z } from "zod"; import { c2cClient } from "../../../config/binanceClient.js"; export function registerBinanceGetC2CTradeHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetC2CTradeHistory", - "Allows the user to retrieve their own past C2C trades, including details such as asset type, trade direction (BUY/SELL), fiat currency used, trade status, and more.", { - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - page: z.number().int().optional().describe("Page number, default is 1"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Allows the user to retrieve their own past C2C trades, including details such as asset type, trade direction (BUY/SELL), fiat currency used, trade status, and more.", + inputSchema: { + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + page: z.number().int().optional().describe("Page number, default is 1"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/convert/market-data-api/listAllConvertPairs.ts b/src/modules/convert/market-data-api/listAllConvertPairs.ts index 25de6bef..08a9bb1f 100644 --- a/src/modules/convert/market-data-api/listAllConvertPairs.ts +++ b/src/modules/convert/market-data-api/listAllConvertPairs.ts @@ -6,12 +6,15 @@ import { z } from "zod"; import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertGetListAllConvertPairs(server: McpServer) { - server.tool( + server.registerTool( "BinanceConvertGetListAllConvertPairs", - "Query available conversion pairs (like BTC to USDT), and shows the minimum and maximum allowed amounts for both the source and destination tokens.", { - fromAsset: z.string().optional().describe("User spends coin"), - toAsset: z.string().optional().describe("User receives coin"), + description: + "Query available conversion pairs (like BTC to USDT), and shows the minimum and maximum allowed amounts for both the source and destination tokens.", + inputSchema: { + fromAsset: z.string().optional().describe("User spends coin"), + toAsset: z.string().optional().describe("User receives coin"), + }, }, async (params) => { try { diff --git a/src/modules/convert/market-data-api/queryOrderQuantityPrecisionPerAsset.ts b/src/modules/convert/market-data-api/queryOrderQuantityPrecisionPerAsset.ts index 21ac758a..a37b5c20 100644 --- a/src/modules/convert/market-data-api/queryOrderQuantityPrecisionPerAsset.ts +++ b/src/modules/convert/market-data-api/queryOrderQuantityPrecisionPerAsset.ts @@ -6,16 +6,19 @@ import { z } from "zod"; import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertQueryOrderQuantityPrecisionPerAsset(server: McpServer) { - server.tool( + server.registerTool( "BinanceConvertQueryOrderQuantityPrecisionPerAsset", - "Retrieve decimal precision (fraction) information for each supported asset in the Convert feature.", { - recvWindow: z - .number() - .int() - .max(60000, "recvWindow cannot be greater than 60000") - .optional() - .describe("The value cannot be greater than 60000"), + description: + "Retrieve decimal precision (fraction) information for each supported asset in the Convert feature.", + inputSchema: { + recvWindow: z + .number() + .int() + .max(60000, "recvWindow cannot be greater than 60000") + .optional() + .describe("The value cannot be greater than 60000"), + }, }, async (params) => { try { diff --git a/src/modules/convert/trade-api/acceptQuote.ts b/src/modules/convert/trade-api/acceptQuote.ts index 23deb653..3df62cc2 100644 --- a/src/modules/convert/trade-api/acceptQuote.ts +++ b/src/modules/convert/trade-api/acceptQuote.ts @@ -6,17 +6,20 @@ import { z } from "zod"; import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertAcceptQuote(server: McpServer) { - server.tool( + server.registerTool( "BinanceConvertAcceptQuote", - "The API confirms and executes a token conversion using a previously received quote ID.", { - quoteId: z.string().describe("Quote ID"), - recvWindow: z - .number() - .int() - .max(60000, "recvWindow cannot be greater than 60000") - .optional() - .describe("The value cannot be greater than 60000"), + description: + "The API confirms and executes a token conversion using a previously received quote ID.", + inputSchema: { + quoteId: z.string().describe("Quote ID"), + recvWindow: z + .number() + .int() + .max(60000, "recvWindow cannot be greater than 60000") + .optional() + .describe("The value cannot be greater than 60000"), + }, }, async (params) => { try { diff --git a/src/modules/convert/trade-api/cancelLimitOrder.ts b/src/modules/convert/trade-api/cancelLimitOrder.ts index 7982e671..4da9c70d 100644 --- a/src/modules/convert/trade-api/cancelLimitOrder.ts +++ b/src/modules/convert/trade-api/cancelLimitOrder.ts @@ -6,17 +6,20 @@ import { z } from "zod"; import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertCancelLimitOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceConvertCancelLimitOrder", - "Cancels a previously placed limit order using the orderId and returns the cancellation status along with the orderId.", { - orderId: z.number().int().describe("The orderId from placeOrder API"), - recvWindow: z - .number() - .int() - .max(60000, "recvWindow cannot be greater than 60000") - .optional() - .describe("Time window for request validity"), + description: + "Cancels a previously placed limit order using the orderId and returns the cancellation status along with the orderId.", + inputSchema: { + orderId: z.number().int().describe("The orderId from placeOrder API"), + recvWindow: z + .number() + .int() + .max(60000, "recvWindow cannot be greater than 60000") + .optional() + .describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/convert/trade-api/getConvertTradeHistory.ts b/src/modules/convert/trade-api/getConvertTradeHistory.ts index 5eafcf10..8c8fbe37 100644 --- a/src/modules/convert/trade-api/getConvertTradeHistory.ts +++ b/src/modules/convert/trade-api/getConvertTradeHistory.ts @@ -6,19 +6,22 @@ import { z } from "zod"; import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceGetConvertTradeHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetConvertTradeHistory", - "The API retrieves your token conversion trade history within a specified time range, with support for pagination using the limit parameter (up to 1000 records).", { - startTime: z.number().int().describe("Start time in milliseconds"), - endTime: z.number().int().describe("End time in milliseconds"), - limit: z - .number() - .int() - .max(1000, "Limit cannot be greater than 1000") - .optional() - .describe("Default 100, Max 1000"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "The API retrieves your token conversion trade history within a specified time range, with support for pagination using the limit parameter (up to 1000 records).", + inputSchema: { + startTime: z.number().int().describe("Start time in milliseconds"), + endTime: z.number().int().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(1000, "Limit cannot be greater than 1000") + .optional() + .describe("Default 100, Max 1000"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/convert/trade-api/orderStatus.ts b/src/modules/convert/trade-api/orderStatus.ts index 2f0db587..32ee7073 100644 --- a/src/modules/convert/trade-api/orderStatus.ts +++ b/src/modules/convert/trade-api/orderStatus.ts @@ -6,12 +6,15 @@ import { z } from "zod"; import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertOrderStatus(server: McpServer) { - server.tool( + server.registerTool( "BinanceConvertOrderStatus", - "The API checks the status of a token conversion order using either the orderId or quoteId, and returns details like conversion status, assets involved, amounts, exchange rate, and order creation time.", { - orderId: z.string().optional().describe("Order ID (either this or quoteId is required)"), - quoteId: z.string().optional().describe("Quote ID (either this or orderId is required)"), + description: + "The API checks the status of a token conversion order using either the orderId or quoteId, and returns details like conversion status, assets involved, amounts, exchange rate, and order creation time.", + inputSchema: { + orderId: z.string().optional().describe("Order ID (either this or quoteId is required)"), + quoteId: z.string().optional().describe("Quote ID (either this or orderId is required)"), + }, }, async (params) => { try { diff --git a/src/modules/convert/trade-api/placeLimitOrder.ts b/src/modules/convert/trade-api/placeLimitOrder.ts index 54896a32..2639e773 100644 --- a/src/modules/convert/trade-api/placeLimitOrder.ts +++ b/src/modules/convert/trade-api/placeLimitOrder.ts @@ -6,40 +6,43 @@ import { z } from "zod"; import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertPlaceLimitOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceConvertPlaceLimitOrder", - "Places a limit order to convert between two tokens at a specified price, using either base or quote amount, with options for wallet type and order expiry.", { - baseAsset: z.string().describe("Base asset (from `fromIsBase` in /exchangeInfo API)"), - quoteAsset: z.string().describe("Quote asset"), - limitPrice: z - .number() - .positive() - .describe("Symbol limit price (from baseAsset to quoteAsset)"), - baseAmount: z - .number() - .positive() - .optional() - .describe("Base asset amount (either this or quoteAmount is required)"), - quoteAmount: z - .number() - .positive() - .optional() - .describe("Quote asset amount (either this or baseAmount is required)"), - side: z.enum(["BUY", "SELL"]).describe("BUY or SELL"), - walletType: z - .enum(["SPOT", "FUNDING", "SPOT_FUNDING"]) - .optional() - .describe("Type of assets used: SPOT, FUNDING, or SPOT_FUNDING. Default is SPOT"), - expiredType: z - .enum(["1_D", "3_D", "7_D", "30_D"]) - .describe("Expiration type: 1_D, 3_D, 7_D, or 30_D (D = days)"), - recvWindow: z - .number() - .int() - .max(60000, "recvWindow cannot be greater than 60000") - .optional() - .describe("Time window for request validity"), + description: + "Places a limit order to convert between two tokens at a specified price, using either base or quote amount, with options for wallet type and order expiry.", + inputSchema: { + baseAsset: z.string().describe("Base asset (from `fromIsBase` in /exchangeInfo API)"), + quoteAsset: z.string().describe("Quote asset"), + limitPrice: z + .number() + .positive() + .describe("Symbol limit price (from baseAsset to quoteAsset)"), + baseAmount: z + .number() + .positive() + .optional() + .describe("Base asset amount (either this or quoteAmount is required)"), + quoteAmount: z + .number() + .positive() + .optional() + .describe("Quote asset amount (either this or baseAmount is required)"), + side: z.enum(["BUY", "SELL"]).describe("BUY or SELL"), + walletType: z + .enum(["SPOT", "FUNDING", "SPOT_FUNDING"]) + .optional() + .describe("Type of assets used: SPOT, FUNDING, or SPOT_FUNDING. Default is SPOT"), + expiredType: z + .enum(["1_D", "3_D", "7_D", "30_D"]) + .describe("Expiration type: 1_D, 3_D, 7_D, or 30_D (D = days)"), + recvWindow: z + .number() + .int() + .max(60000, "recvWindow cannot be greater than 60000") + .optional() + .describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/convert/trade-api/queryLimitOpenOrders.ts b/src/modules/convert/trade-api/queryLimitOpenOrders.ts index a55f4f73..d96ede06 100644 --- a/src/modules/convert/trade-api/queryLimitOpenOrders.ts +++ b/src/modules/convert/trade-api/queryLimitOpenOrders.ts @@ -6,16 +6,19 @@ import { z } from "zod"; import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertQueryLimitOpenOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceConvertQueryLimitOpenOrders", - "Retrieves all your open limit orders for token conversions, showing details like assets, amounts, exchange rate, order status, and expiration time.", { - recvWindow: z - .number() - .int() - .max(60000, "recvWindow must not be greater than 60000") - .optional() - .describe("This value must not exceed 60000"), + description: + "Retrieves all your open limit orders for token conversions, showing details like assets, amounts, exchange rate, order status, and expiration time.", + inputSchema: { + recvWindow: z + .number() + .int() + .max(60000, "recvWindow must not be greater than 60000") + .optional() + .describe("This value must not exceed 60000"), + }, }, async (params) => { try { diff --git a/src/modules/convert/trade-api/sendQuoteRequest.ts b/src/modules/convert/trade-api/sendQuoteRequest.ts index e7ae7a91..c564cdc3 100644 --- a/src/modules/convert/trade-api/sendQuoteRequest.ts +++ b/src/modules/convert/trade-api/sendQuoteRequest.ts @@ -6,32 +6,39 @@ import { z } from "zod"; import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertSendQuoteRequest(server: McpServer) { - server.tool( + server.registerTool( "BinanceConvertSendQuoteRequest", - "Get a real-time quote to convert one token to another, including rate and amount, if you have enough funds.", { - fromAsset: z.string().describe("Asset you will spend (required)"), - toAsset: z.string().describe("Asset you will receive (required)"), - fromAmount: z - .number() - .positive() - .optional() - .describe("Amount to be debited after conversion"), - toAmount: z.number().positive().optional().describe("Amount to be credited after conversion"), - walletType: z - .enum(["SPOT", "FUNDING"]) - .optional() - .describe("SPOT or FUNDING. Default is SPOT"), - validTime: z - .enum(["10s", "30s", "1m"]) - .optional() - .describe("Quote validity duration: 10s, 30s, 1m; default is 10s"), - recvWindow: z - .number() - .int() - .max(60000, "recvWindow cannot be greater than 60000") - .optional() - .describe("The value cannot be greater than 60000"), + description: + "Get a real-time quote to convert one token to another, including rate and amount, if you have enough funds.", + inputSchema: { + fromAsset: z.string().describe("Asset you will spend (required)"), + toAsset: z.string().describe("Asset you will receive (required)"), + fromAmount: z + .number() + .positive() + .optional() + .describe("Amount to be debited after conversion"), + toAmount: z + .number() + .positive() + .optional() + .describe("Amount to be credited after conversion"), + walletType: z + .enum(["SPOT", "FUNDING"]) + .optional() + .describe("SPOT or FUNDING. Default is SPOT"), + validTime: z + .enum(["10s", "30s", "1m"]) + .optional() + .describe("Quote validity duration: 10s, 30s, 1m; default is 10s"), + recvWindow: z + .number() + .int() + .max(60000, "recvWindow cannot be greater than 60000") + .optional() + .describe("The value cannot be greater than 60000"), + }, }, async (params) => { try { diff --git a/src/modules/copy-trading/FutureCopyTrading-api/followTrader.ts b/src/modules/copy-trading/FutureCopyTrading-api/followTrader.ts index a63b969c..53d10e44 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/followTrader.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/followTrader.ts @@ -12,25 +12,31 @@ import { z } from "zod"; import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceCopyTradingFollowTrader(server: McpServer) { - server.tool( + server.registerTool( "BinanceCopyTradingFollowTrader", - "Start following a lead trader to automatically copy their trades. ⚠️ RISK: Your funds will be used to copy trades. Only follow traders you trust.", { - leadPortfolioId: z.string().describe("Lead trader's portfolio ID to follow"), - copyRatio: z.number().min(0.1).max(10).describe("Copy ratio (0.1-10x of their trades)"), - fixedAmount: z.string().optional().describe("Fixed amount per trade (alternative to ratio)"), - stopLossRatio: z - .number() - .min(0.01) - .max(1) - .optional() - .describe("Stop loss ratio (e.g., 0.1 = stop if 10% loss)"), - takeProfitRatio: z - .number() - .min(0.01) - .optional() - .describe("Take profit ratio (e.g., 0.5 = take profit at 50% gain)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Start following a lead trader to automatically copy their trades. ⚠️ RISK: Your funds will be used to copy trades. Only follow traders you trust.", + inputSchema: { + leadPortfolioId: z.string().describe("Lead trader's portfolio ID to follow"), + copyRatio: z.number().min(0.1).max(10).describe("Copy ratio (0.1-10x of their trades)"), + fixedAmount: z + .string() + .optional() + .describe("Fixed amount per trade (alternative to ratio)"), + stopLossRatio: z + .number() + .min(0.01) + .max(1) + .optional() + .describe("Stop loss ratio (e.g., 0.1 = stop if 10% loss)"), + takeProfitRatio: z + .number() + .min(0.01) + .optional() + .describe("Take profit ratio (e.g., 0.5 = take profit at 50% gain)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getCopyOrders.ts b/src/modules/copy-trading/FutureCopyTrading-api/getCopyOrders.ts index ad7b80ba..20442f99 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getCopyOrders.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getCopyOrders.ts @@ -12,15 +12,18 @@ import { z } from "zod"; import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceCopyTradingGetCopyOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceCopyTradingGetCopyOrders", - "Get your copy trading order history. Shows all orders executed from copying lead traders.", { - startTime: z.number().int().optional().describe("Start time in ms"), - endTime: z.number().int().optional().describe("End time in ms"), - pageNumber: z.number().int().min(1).default(1).optional().describe("Page number"), - pageSize: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get your copy trading order history. Shows all orders executed from copying lead traders.", + inputSchema: { + startTime: z.number().int().optional().describe("Start time in ms"), + endTime: z.number().int().optional().describe("End time in ms"), + pageNumber: z.number().int().min(1).default(1).optional().describe("Page number"), + pageSize: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getCopyPositions.ts b/src/modules/copy-trading/FutureCopyTrading-api/getCopyPositions.ts index 47ba1390..7bd22969 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getCopyPositions.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getCopyPositions.ts @@ -12,11 +12,14 @@ import { z } from "zod"; import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceCopyTradingGetCopyPositions(server: McpServer) { - server.tool( + server.registerTool( "BinanceCopyTradingGetCopyPositions", - "Get your current positions from copy trading. Shows all open positions created by following lead traders.", { - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get your current positions from copy trading. Shows all open positions created by following lead traders.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getFollowingTraders.ts b/src/modules/copy-trading/FutureCopyTrading-api/getFollowingTraders.ts index 931d5617..4c7d452c 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getFollowingTraders.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getFollowingTraders.ts @@ -12,11 +12,14 @@ import { z } from "zod"; import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceCopyTradingGetFollowingTraders(server: McpServer) { - server.tool( + server.registerTool( "BinanceCopyTradingGetFollowingTraders", - "Get the list of traders you are currently following. Shows copy settings and performance for each.", { - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get the list of traders you are currently following. Shows copy settings and performance for each.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts b/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts index d824f411..1241044c 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts @@ -6,11 +6,18 @@ import { z } from "zod"; import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetFuturesLeadTraderStatus(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetFuturesLeadTraderStatus", - "Checks and returns whether the user is currently a Futures Lead Trader in Binance Copy Trading, along with the timestamp of the status check.", { - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Checks and returns whether the user is currently a Futures Lead Trader in Binance Copy Trading, along with the timestamp of the status check.", + inputSchema: { + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts b/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts index 5efe5667..b86d8cc0 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts @@ -6,11 +6,18 @@ import { z } from "zod"; import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetFuturesLeadTradingSymbolWhitelist(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetFuturesLeadTradingSymbolWhitelist", - "Whitelist of trading pairs (symbols) that are allowed for Futures Lead Traders in copy trading, including base and quote assets.", { - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Whitelist of trading pairs (symbols) that are allowed for Futures Lead Traders in copy trading, including base and quote assets.", + inputSchema: { + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getLeadTraders.ts b/src/modules/copy-trading/FutureCopyTrading-api/getLeadTraders.ts index dc946882..70917a21 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getLeadTraders.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getLeadTraders.ts @@ -12,15 +12,18 @@ import { z } from "zod"; import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetLeadTraders(server: McpServer) { - server.tool( + server.registerTool( "BinanceCopyTradingGetLeadTraders", - "Browse available lead traders for copy trading. View their performance stats and follower count to find traders to copy.", { - isShared: z.boolean().optional().describe("Filter by shared portfolio traders"), - tradeType: z.enum(["PERPETUAL"]).optional().describe("Trade type filter"), - pageNumber: z.number().int().min(1).default(1).optional().describe("Page number"), - pageSize: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Browse available lead traders for copy trading. View their performance stats and follower count to find traders to copy.", + inputSchema: { + isShared: z.boolean().optional().describe("Filter by shared portfolio traders"), + tradeType: z.enum(["PERPETUAL"]).optional().describe("Trade type filter"), + pageNumber: z.number().int().min(1).default(1).optional().describe("Page number"), + pageSize: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getTraderPerformance.ts b/src/modules/copy-trading/FutureCopyTrading-api/getTraderPerformance.ts index a6785301..044e0b5e 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getTraderPerformance.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getTraderPerformance.ts @@ -12,13 +12,16 @@ import { z } from "zod"; import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetTraderPerformance(server: McpServer) { - server.tool( + server.registerTool( "BinanceCopyTradingGetTraderPerformance", - "Get detailed performance statistics for a lead trader. Includes ROI, PNL, win rate, and other metrics.", { - leadPortfolioId: z.string().describe("Lead trader's portfolio ID"), - tradeType: z.enum(["PERPETUAL"]).optional().describe("Trade type"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get detailed performance statistics for a lead trader. Includes ROI, PNL, win rate, and other metrics.", + inputSchema: { + leadPortfolioId: z.string().describe("Lead trader's portfolio ID"), + tradeType: z.enum(["PERPETUAL"]).optional().describe("Trade type"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getTraderPositions.ts b/src/modules/copy-trading/FutureCopyTrading-api/getTraderPositions.ts index f084a767..3b042d45 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getTraderPositions.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getTraderPositions.ts @@ -12,13 +12,16 @@ import { z } from "zod"; import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetTraderPositions(server: McpServer) { - server.tool( + server.registerTool( "BinanceCopyTradingGetTraderPositions", - "View a lead trader's current open positions. See what positions they are holding to understand their strategy.", { - leadPortfolioId: z.string().describe("Lead trader's portfolio ID"), - tradeType: z.enum(["PERPETUAL"]).optional().describe("Trade type"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "View a lead trader's current open positions. See what positions they are holding to understand their strategy.", + inputSchema: { + leadPortfolioId: z.string().describe("Lead trader's portfolio ID"), + tradeType: z.enum(["PERPETUAL"]).optional().describe("Trade type"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getTraderSymbolStats.ts b/src/modules/copy-trading/FutureCopyTrading-api/getTraderSymbolStats.ts index 10ba5762..841efa9d 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getTraderSymbolStats.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getTraderSymbolStats.ts @@ -12,13 +12,16 @@ import { z } from "zod"; import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetTraderSymbolStats(server: McpServer) { - server.tool( + server.registerTool( "BinanceCopyTradingGetTraderSymbolStats", - "Get a lead trader's trading statistics per symbol. Shows which symbols they trade most and their success rate.", { - leadPortfolioId: z.string().describe("Lead trader's portfolio ID"), - tradeType: z.enum(["PERPETUAL"]).optional().describe("Trade type"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get a lead trader's trading statistics per symbol. Shows which symbols they trade most and their success rate.", + inputSchema: { + leadPortfolioId: z.string().describe("Lead trader's portfolio ID"), + tradeType: z.enum(["PERPETUAL"]).optional().describe("Trade type"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/copy-trading/FutureCopyTrading-api/unfollowTrader.ts b/src/modules/copy-trading/FutureCopyTrading-api/unfollowTrader.ts index 5096f3d4..f52408b1 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/unfollowTrader.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/unfollowTrader.ts @@ -12,12 +12,15 @@ import { z } from "zod"; import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceCopyTradingUnfollowTrader(server: McpServer) { - server.tool( + server.registerTool( "BinanceCopyTradingUnfollowTrader", - "Stop following a lead trader. Your existing copied positions will remain open until manually closed.", { - leadPortfolioId: z.string().describe("Lead trader's portfolio ID to unfollow"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Stop following a lead trader. Your existing copied positions will remain open until manually closed.", + inputSchema: { + leadPortfolioId: z.string().describe("Lead trader's portfolio ID to unfollow"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/crypto-loans/flexible/adjustLTV.ts b/src/modules/crypto-loans/flexible/adjustLTV.ts index 3f5f90ad..b9291807 100644 --- a/src/modules/crypto-loans/flexible/adjustLTV.ts +++ b/src/modules/crypto-loans/flexible/adjustLTV.ts @@ -12,17 +12,20 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerFlexibleLoanAdjustLTV(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoanFlexibleAdjustLTV", - "Adjust LTV (Loan-to-Value) ratio by adding or removing collateral. Lower LTV = safer position.", { - loanCoin: z.string().describe("Loan coin"), - collateralCoin: z.string().describe("Collateral coin"), - adjustmentAmount: z.string().describe("Amount to add (positive) or remove (negative)"), - direction: z - .enum(["ADDITIONAL", "REDUCED"]) - .describe("ADDITIONAL to add collateral, REDUCED to remove"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Adjust LTV (Loan-to-Value) ratio by adding or removing collateral. Lower LTV = safer position.", + inputSchema: { + loanCoin: z.string().describe("Loan coin"), + collateralCoin: z.string().describe("Collateral coin"), + adjustmentAmount: z.string().describe("Amount to add (positive) or remove (negative)"), + direction: z + .enum(["ADDITIONAL", "REDUCED"]) + .describe("ADDITIONAL to add collateral, REDUCED to remove"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/crypto-loans/flexible/borrow.ts b/src/modules/crypto-loans/flexible/borrow.ts index 01a196c1..5edff76f 100644 --- a/src/modules/crypto-loans/flexible/borrow.ts +++ b/src/modules/crypto-loans/flexible/borrow.ts @@ -12,21 +12,24 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerFlexibleLoanBorrow(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoanFlexibleBorrow", - "Borrow crypto using a flexible loan. ⚠️ Your collateral will be locked. Interest accrues daily. Monitor LTV ratio to avoid liquidation.", { - loanCoin: z.string().describe("Coin to borrow (e.g., 'USDT')"), - loanAmount: z - .string() - .optional() - .describe("Amount to borrow (provide either loanAmount or collateralAmount)"), - collateralCoin: z.string().describe("Collateral coin (e.g., 'BTC')"), - collateralAmount: z - .string() - .optional() - .describe("Collateral amount (provide either loanAmount or collateralAmount)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Borrow crypto using a flexible loan. ⚠️ Your collateral will be locked. Interest accrues daily. Monitor LTV ratio to avoid liquidation.", + inputSchema: { + loanCoin: z.string().describe("Coin to borrow (e.g., 'USDT')"), + loanAmount: z + .string() + .optional() + .describe("Amount to borrow (provide either loanAmount or collateralAmount)"), + collateralCoin: z.string().describe("Collateral coin (e.g., 'BTC')"), + collateralAmount: z + .string() + .optional() + .describe("Collateral amount (provide either loanAmount or collateralAmount)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/crypto-loans/flexible/getBorrowHistory.ts b/src/modules/crypto-loans/flexible/getBorrowHistory.ts index 077e5c36..cdd85eec 100644 --- a/src/modules/crypto-loans/flexible/getBorrowHistory.ts +++ b/src/modules/crypto-loans/flexible/getBorrowHistory.ts @@ -12,17 +12,19 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerFlexibleLoanBorrowHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoanFlexibleBorrowHistory", - "Get your flexible loan borrowing history.", { - loanCoin: z.string().optional().describe("Filter by loan coin"), - collateralCoin: z.string().optional().describe("Filter by collateral coin"), - startTime: z.number().int().optional().describe("Start time in ms"), - endTime: z.number().int().optional().describe("End time in ms"), - current: z.number().int().min(1).default(1).optional().describe("Page number"), - limit: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Get your flexible loan borrowing history.", + inputSchema: { + loanCoin: z.string().optional().describe("Filter by loan coin"), + collateralCoin: z.string().optional().describe("Filter by collateral coin"), + startTime: z.number().int().optional().describe("Start time in ms"), + endTime: z.number().int().optional().describe("End time in ms"), + current: z.number().int().min(1).default(1).optional().describe("Page number"), + limit: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/crypto-loans/flexible/getFlexibleCollateralAssets.ts b/src/modules/crypto-loans/flexible/getFlexibleCollateralAssets.ts index 3f350770..2e4262c4 100644 --- a/src/modules/crypto-loans/flexible/getFlexibleCollateralAssets.ts +++ b/src/modules/crypto-loans/flexible/getFlexibleCollateralAssets.ts @@ -12,12 +12,15 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerFlexibleCollateralAssets(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoanFlexibleCollateralAssets", - "Get available collateral assets for flexible crypto loans. Shows which assets you can use as collateral.", { - collateralCoin: z.string().optional().describe("Filter by collateral coin"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get available collateral assets for flexible crypto loans. Shows which assets you can use as collateral.", + inputSchema: { + collateralCoin: z.string().optional().describe("Filter by collateral coin"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/crypto-loans/flexible/getFlexibleLoanAssets.ts b/src/modules/crypto-loans/flexible/getFlexibleLoanAssets.ts index 4cfba523..ecebe941 100644 --- a/src/modules/crypto-loans/flexible/getFlexibleLoanAssets.ts +++ b/src/modules/crypto-loans/flexible/getFlexibleLoanAssets.ts @@ -12,12 +12,15 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerFlexibleLoanAssets(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoanFlexibleAssets", - "Get available assets for flexible crypto loans. Shows which assets you can borrow and their rates.", { - loanCoin: z.string().optional().describe("Filter by loan coin (e.g., 'USDT', 'BUSD')"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get available assets for flexible crypto loans. Shows which assets you can borrow and their rates.", + inputSchema: { + loanCoin: z.string().optional().describe("Filter by loan coin (e.g., 'USDT', 'BUSD')"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/crypto-loans/flexible/getOngoingOrders.ts b/src/modules/crypto-loans/flexible/getOngoingOrders.ts index 8e3c52d9..a0369b61 100644 --- a/src/modules/crypto-loans/flexible/getOngoingOrders.ts +++ b/src/modules/crypto-loans/flexible/getOngoingOrders.ts @@ -12,15 +12,18 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerFlexibleLoanOngoingOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoanFlexibleOngoingOrders", - "Get your current flexible loan positions. Shows outstanding amounts, collateral, and LTV ratios.", { - loanCoin: z.string().optional().describe("Filter by loan coin"), - collateralCoin: z.string().optional().describe("Filter by collateral coin"), - current: z.number().int().min(1).default(1).optional().describe("Page number"), - limit: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get your current flexible loan positions. Shows outstanding amounts, collateral, and LTV ratios.", + inputSchema: { + loanCoin: z.string().optional().describe("Filter by loan coin"), + collateralCoin: z.string().optional().describe("Filter by collateral coin"), + current: z.number().int().min(1).default(1).optional().describe("Page number"), + limit: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/crypto-loans/flexible/getRepayHistory.ts b/src/modules/crypto-loans/flexible/getRepayHistory.ts index 17008e3f..62ed6275 100644 --- a/src/modules/crypto-loans/flexible/getRepayHistory.ts +++ b/src/modules/crypto-loans/flexible/getRepayHistory.ts @@ -12,17 +12,19 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerFlexibleLoanRepayHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoanFlexibleRepayHistory", - "Get your flexible loan repayment history.", { - loanCoin: z.string().optional().describe("Filter by loan coin"), - collateralCoin: z.string().optional().describe("Filter by collateral coin"), - startTime: z.number().int().optional().describe("Start time in ms"), - endTime: z.number().int().optional().describe("End time in ms"), - current: z.number().int().min(1).default(1).optional().describe("Page number"), - limit: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Get your flexible loan repayment history.", + inputSchema: { + loanCoin: z.string().optional().describe("Filter by loan coin"), + collateralCoin: z.string().optional().describe("Filter by collateral coin"), + startTime: z.number().int().optional().describe("Start time in ms"), + endTime: z.number().int().optional().describe("End time in ms"), + current: z.number().int().min(1).default(1).optional().describe("Page number"), + limit: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/crypto-loans/flexible/repay.ts b/src/modules/crypto-loans/flexible/repay.ts index 8b807f21..8d0cd81c 100644 --- a/src/modules/crypto-loans/flexible/repay.ts +++ b/src/modules/crypto-loans/flexible/repay.ts @@ -12,16 +12,19 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerFlexibleLoanRepay(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoanFlexibleRepay", - "Repay a flexible crypto loan. Your collateral will be released proportionally. 💸", { - loanCoin: z.string().describe("Loan coin to repay"), - collateralCoin: z.string().describe("Collateral coin"), - repayAmount: z.string().describe("Amount to repay"), - collateralReturn: z.boolean().optional().describe("Return collateral after full repayment"), - fullRepayment: z.boolean().optional().describe("Repay full outstanding amount"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Repay a flexible crypto loan. Your collateral will be released proportionally. 💸", + inputSchema: { + loanCoin: z.string().describe("Loan coin to repay"), + collateralCoin: z.string().describe("Collateral coin"), + repayAmount: z.string().describe("Amount to repay"), + collateralReturn: z.boolean().optional().describe("Return collateral after full repayment"), + fullRepayment: z.boolean().optional().describe("Repay full outstanding amount"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/dual-investment/market-api/getDualInvestmentProductList.ts b/src/modules/dual-investment/market-api/getDualInvestmentProductList.ts index 0af64c24..3676a381 100644 --- a/src/modules/dual-investment/market-api/getDualInvestmentProductList.ts +++ b/src/modules/dual-investment/market-api/getDualInvestmentProductList.ts @@ -6,27 +6,30 @@ import { z } from "zod"; import { dualInvestmentClient } from "../../../config/binanceClient.js"; export function registerBinanceGetDualInvestmentProductList(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetDualInvestmentProductList", - "Retrieve available Dual Investment products (CALL or PUT options), specifying invest and exercised coins, to view details like APR, strike price, duration, and purchase availability.", { - optionType: z.enum(["CALL", "PUT"]).describe("Input CALL or PUT"), - exercisedCoin: z.string().describe("Target exercised asset, e.g., USDT or BNB"), - investCoin: z.string().describe("Asset used for subscribing, e.g., BNB or USDT"), - pageSize: z - .number() - .int() - .max(100, "Maximum pageSize is 100") - .default(10) - .optional() - .describe("Number of records per page, default 10, max 100"), - pageIndex: z.number().int().default(1).optional().describe("Page index, default is 1"), - recvWindow: z - .number() - .int() - .max(60000, "recvWindow cannot be greater than 60000") - .optional() - .describe("Optional time window for request validity"), + description: + "Retrieve available Dual Investment products (CALL or PUT options), specifying invest and exercised coins, to view details like APR, strike price, duration, and purchase availability.", + inputSchema: { + optionType: z.enum(["CALL", "PUT"]).describe("Input CALL or PUT"), + exercisedCoin: z.string().describe("Target exercised asset, e.g., USDT or BNB"), + investCoin: z.string().describe("Asset used for subscribing, e.g., BNB or USDT"), + pageSize: z + .number() + .int() + .max(100, "Maximum pageSize is 100") + .default(10) + .optional() + .describe("Number of records per page, default 10, max 100"), + pageIndex: z.number().int().default(1).optional().describe("Page index, default is 1"), + recvWindow: z + .number() + .int() + .max(60000, "recvWindow cannot be greater than 60000") + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/dual-investment/trade-api/changeAutoCompoundStatus.ts b/src/modules/dual-investment/trade-api/changeAutoCompoundStatus.ts index 97749554..888ad64b 100644 --- a/src/modules/dual-investment/trade-api/changeAutoCompoundStatus.ts +++ b/src/modules/dual-investment/trade-api/changeAutoCompoundStatus.ts @@ -6,21 +6,24 @@ import { z } from "zod"; import { dualInvestmentClient } from "../../../config/binanceClient.js"; export function registerBinanceChangeAutoCompoundStatus(server: McpServer) { - server.tool( + server.registerTool( "registerBinanceChangeAutoCompoundStatus", - "Change the Auto-Compound plan for a Dual Investment position to NONE, STANDARD, or ADVANCED using the position ID.", { - positionId: z.string().describe("Get positionId from /sapi/v1/dci/product/positions"), - autoCompoundPlan: z - .enum(["NONE", "STANDARD", "ADVANCED"]) - .optional() - .describe("Auto compound plan: NONE, STANDARD, or ADVANCED"), - recvWindow: z - .number() - .int() - .max(60000) - .optional() - .describe("Optional time window for request validity (max 60000)"), + description: + "Change the Auto-Compound plan for a Dual Investment position to NONE, STANDARD, or ADVANCED using the position ID.", + inputSchema: { + positionId: z.string().describe("Get positionId from /sapi/v1/dci/product/positions"), + autoCompoundPlan: z + .enum(["NONE", "STANDARD", "ADVANCED"]) + .optional() + .describe("Auto compound plan: NONE, STANDARD, or ADVANCED"), + recvWindow: z + .number() + .int() + .max(60000) + .optional() + .describe("Optional time window for request validity (max 60000)"), + }, }, async (params) => { try { diff --git a/src/modules/dual-investment/trade-api/checkDualInvestmentAccounts.ts b/src/modules/dual-investment/trade-api/checkDualInvestmentAccounts.ts index 4fa4e18b..cca74369 100644 --- a/src/modules/dual-investment/trade-api/checkDualInvestmentAccounts.ts +++ b/src/modules/dual-investment/trade-api/checkDualInvestmentAccounts.ts @@ -6,16 +6,19 @@ import { z } from "zod"; import { dualInvestmentClient } from "../../../config/binanceClient.js"; export function registerBinanceCheckDualInvestmentAccounts(server: McpServer) { - server.tool( + server.registerTool( "BinanceCheckDualInvestmentAccounts", - "Retrieve Dual Investment account balances, including total value in BTC and USDT equivalents.", { - recvWindow: z - .number() - .int() - .max(60000) - .optional() - .describe("Optional time window for request validity (max 60000)"), + description: + "Retrieve Dual Investment account balances, including total value in BTC and USDT equivalents.", + inputSchema: { + recvWindow: z + .number() + .int() + .max(60000) + .optional() + .describe("Optional time window for request validity (max 60000)"), + }, }, async (params) => { try { diff --git a/src/modules/dual-investment/trade-api/getDualInvestmentPositions.ts b/src/modules/dual-investment/trade-api/getDualInvestmentPositions.ts index f7138155..34115870 100644 --- a/src/modules/dual-investment/trade-api/getDualInvestmentPositions.ts +++ b/src/modules/dual-investment/trade-api/getDualInvestmentPositions.ts @@ -6,38 +6,41 @@ import { z } from "zod"; import { dualInvestmentClient } from "../../../config/binanceClient.js"; export function registerBinanceGetDualInvestmentPositions(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetDualInvestmentPositions", - "Fetch Dual Investment positions in batch, including status, subscription details, APR, and settlement info. Filter by status or paginate results.", { - status: z - .enum([ - "PENDING", - "PURCHASE_SUCCESS", - "SETTLED", - "PURCHASE_FAIL", - "REFUNDING", - "REFUND_SUCCESS", - "SETTLING", - ]) - .optional() - .describe( - "Position status: PENDING (awaiting results), PURCHASE_SUCCESS, SETTLED, PURCHASE_FAIL, REFUNDING, REFUND_SUCCESS, or SETTLING. If not provided, returns all.", - ), - pageSize: z - .number() - .int() - .min(1) - .max(100) - .optional() - .describe("Number of items per page, default 10, max 100"), - pageIndex: z.number().int().min(1).optional().describe("Page index, default 1"), - recvWindow: z - .number() - .int() - .max(60000) - .optional() - .describe("Optional time window for request validity (max 60000)"), + description: + "Fetch Dual Investment positions in batch, including status, subscription details, APR, and settlement info. Filter by status or paginate results.", + inputSchema: { + status: z + .enum([ + "PENDING", + "PURCHASE_SUCCESS", + "SETTLED", + "PURCHASE_FAIL", + "REFUNDING", + "REFUND_SUCCESS", + "SETTLING", + ]) + .optional() + .describe( + "Position status: PENDING (awaiting results), PURCHASE_SUCCESS, SETTLED, PURCHASE_FAIL, REFUNDING, REFUND_SUCCESS, or SETTLING. If not provided, returns all.", + ), + pageSize: z + .number() + .int() + .min(1) + .max(100) + .optional() + .describe("Number of items per page, default 10, max 100"), + pageIndex: z.number().int().min(1).optional().describe("Page index, default 1"), + recvWindow: z + .number() + .int() + .max(60000) + .optional() + .describe("Optional time window for request validity (max 60000)"), + }, }, async (params) => { try { diff --git a/src/modules/dual-investment/trade-api/subscribeDualInvestmentProducts.ts b/src/modules/dual-investment/trade-api/subscribeDualInvestmentProducts.ts index b9b179fc..5f84f4d4 100644 --- a/src/modules/dual-investment/trade-api/subscribeDualInvestmentProducts.ts +++ b/src/modules/dual-investment/trade-api/subscribeDualInvestmentProducts.ts @@ -6,22 +6,25 @@ import { z } from "zod"; import { dualInvestmentClient } from "../../../config/binanceClient.js"; export function registerBinanceSubscribeDualInvestmentProducts(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubscribeDualInvestmentProducts", - "Subscribe to Dual Investment products by providing product ID, order ID, deposit amount, and auto compound plan to initiate investment with specified terms.", { - id: z.string().describe("Product ID from /sapi/v1/dci/product/list"), - orderId: z.string().describe("Order ID from /sapi/v1/dci/product/list"), - depositAmount: z.number().positive().describe("The amount for subscribing"), - autoCompoundPlan: z - .enum(["NONE", "STANDARD", "ADVANCED"]) - .describe("Auto-compound plan: NONE (off), STANDARD, or ADVANCED"), - recvWindow: z - .number() - .int() - .max(60000, "recvWindow cannot be greater than 60000") - .optional() - .describe("Optional time window for request validity"), + description: + "Subscribe to Dual Investment products by providing product ID, order ID, deposit amount, and auto compound plan to initiate investment with specified terms.", + inputSchema: { + id: z.string().describe("Product ID from /sapi/v1/dci/product/list"), + orderId: z.string().describe("Order ID from /sapi/v1/dci/product/list"), + depositAmount: z.number().positive().describe("The amount for subscribing"), + autoCompoundPlan: z + .enum(["NONE", "STANDARD", "ADVANCED"]) + .describe("Auto-compound plan: NONE (off), STANDARD, or ADVANCED"), + recvWindow: z + .number() + .int() + .max(60000, "recvWindow cannot be greater than 60000") + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/fiat/fiat-api/getFiatDepositWithdrawHistory.ts b/src/modules/fiat/fiat-api/getFiatDepositWithdrawHistory.ts index df6445a1..9b7e5f96 100644 --- a/src/modules/fiat/fiat-api/getFiatDepositWithdrawHistory.ts +++ b/src/modules/fiat/fiat-api/getFiatDepositWithdrawHistory.ts @@ -6,23 +6,30 @@ import { z } from "zod"; import { fiatClient } from "../../../config/binanceClient.js"; export function registerBinanceGetFiatDepositWithdrawHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetFiatDepositWithdrawHistory", - "Fetches fiat deposit or withdrawal history, showing transaction details like amount, currency, method, status, and timestamps.", { - transactionType: z - .enum(["0", "1"]) - .describe("Transaction type: 0 for deposit, 1 for withdraw"), - beginTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - page: z.number().int().optional().describe("Page number, default is 1"), - rows: z - .number() - .int() - .max(500, "Rows cannot be greater than 500") - .optional() - .describe("Number of records per page, default 100, max 500"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Fetches fiat deposit or withdrawal history, showing transaction details like amount, currency, method, status, and timestamps.", + inputSchema: { + transactionType: z + .enum(["0", "1"]) + .describe("Transaction type: 0 for deposit, 1 for withdraw"), + beginTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + page: z.number().int().optional().describe("Page number, default is 1"), + rows: z + .number() + .int() + .max(500, "Rows cannot be greater than 500") + .optional() + .describe("Number of records per page, default 100, max 500"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/fiat/fiat-api/getFiatPaymentsHistory.ts b/src/modules/fiat/fiat-api/getFiatPaymentsHistory.ts index 0629c1c4..b2e4a1dc 100644 --- a/src/modules/fiat/fiat-api/getFiatPaymentsHistory.ts +++ b/src/modules/fiat/fiat-api/getFiatPaymentsHistory.ts @@ -6,21 +6,28 @@ import { z } from "zod"; import { fiatClient } from "../../../config/binanceClient.js"; export function registerBinanceGetFiatPaymentsHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetFiatPaymentsHistory", - "Retrieves fiat buy/sell payment history, including trade amount, currency, crypto received, fees, status, payment method, and timestamps.", { - transactionType: z.enum(["0", "1"]).describe("Transaction type: 0 for buy, 1 for sell"), - beginTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - page: z.number().int().optional().describe("Page number, default is 1"), - rows: z - .number() - .int() - .max(500, "Rows cannot be greater than 500") - .optional() - .describe("Number of records per page, default 100, max 500"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Retrieves fiat buy/sell payment history, including trade amount, currency, crypto received, fees, status, payment method, and timestamps.", + inputSchema: { + transactionType: z.enum(["0", "1"]).describe("Transaction type: 0 for buy, 1 for sell"), + beginTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + page: z.number().int().optional().describe("Page number, default is 1"), + rows: z + .number() + .int() + .max(500, "Rows cannot be greater than 500") + .optional() + .describe("Number of records per page, default 100, max 500"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/mining/mining-api/accountList.ts b/src/modules/mining/mining-api/accountList.ts index 5d43881a..cff3381d 100644 --- a/src/modules/mining/mining-api/accountList.ts +++ b/src/modules/mining/mining-api/accountList.ts @@ -6,13 +6,20 @@ import { z } from "zod"; import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceAccountList(server: McpServer) { - server.tool( + server.registerTool( "BinanceAccountList", - "Retrieve hashrate statistics for a mining account. It returns both hourly (H_hashrate) and daily (D_hashrate) data, including timestamps, hashrate values, and rejection rates.", { - algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), - userName: z.string().min(1).describe("Mining account"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Retrieve hashrate statistics for a mining account. It returns both hourly (H_hashrate) and daily (D_hashrate) data, including timestamps, hashrate values, and rejection rates.", + inputSchema: { + algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), + userName: z.string().min(1).describe("Mining account"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/mining/mining-api/acquiringAlgorithm.ts b/src/modules/mining/mining-api/acquiringAlgorithm.ts index c02d7f3a..df7ed419 100644 --- a/src/modules/mining/mining-api/acquiringAlgorithm.ts +++ b/src/modules/mining/mining-api/acquiringAlgorithm.ts @@ -4,10 +4,12 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceAcquiringAlgorithm(server: McpServer) { - server.tool( + server.registerTool( "BinanceAcquiringAlgorithm", - "Retrieve a list of available mining algorithms, including their name, ID, sequence, and unit.", - {}, + { + description: + "Retrieve a list of available mining algorithms, including their name, ID, sequence, and unit.", + }, async () => { try { const response = await miningClient.restAPI.acquiringAlgorithm(); diff --git a/src/modules/mining/mining-api/acquiringCoinname.ts b/src/modules/mining/mining-api/acquiringCoinname.ts index f5ff7b69..852f5276 100644 --- a/src/modules/mining/mining-api/acquiringCoinname.ts +++ b/src/modules/mining/mining-api/acquiringCoinname.ts @@ -4,10 +4,12 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceAcquiringCoinName(server: McpServer) { - server.tool( + server.registerTool( "BinanceAcquiringCoinName", - "Fetch supported mining coins with details like coin name, ID, algorithm name, and associated algorithm ID.", - {}, + { + description: + "Fetch supported mining coins with details like coin name, ID, algorithm name, and associated algorithm ID.", + }, async () => { try { const response = await miningClient.restAPI.acquiringCoinname(); diff --git a/src/modules/mining/mining-api/cancelHashrateResaleConfiguration.ts b/src/modules/mining/mining-api/cancelHashrateResaleConfiguration.ts index 7ec167a4..0db4a335 100644 --- a/src/modules/mining/mining-api/cancelHashrateResaleConfiguration.ts +++ b/src/modules/mining/mining-api/cancelHashrateResaleConfiguration.ts @@ -6,13 +6,16 @@ import { z } from "zod"; import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceCancelHashRateResaleConfiguration(server: McpServer) { - server.tool( + server.registerTool( "BinanceCancelHashRateResaleConfiguration", - "Cancel an existing hashrate resale configuration using the mining ID and account details.", { - configId: z.number().int().describe("Mining ID").min(1), - userName: z.string().min(1).describe("Mining Account"), - recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + description: + "Cancel an existing hashrate resale configuration using the mining ID and account details.", + inputSchema: { + configId: z.number().int().describe("Mining ID").min(1), + userName: z.string().min(1).describe("Mining Account"), + recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + }, }, async (params) => { try { diff --git a/src/modules/mining/mining-api/earningsList.ts b/src/modules/mining/mining-api/earningsList.ts index 2e768d70..5067ff6c 100644 --- a/src/modules/mining/mining-api/earningsList.ts +++ b/src/modules/mining/mining-api/earningsList.ts @@ -6,32 +6,38 @@ import { z } from "zod"; import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceEarningsList(server: McpServer) { - server.tool( + server.registerTool( "BinanceEarningsList", - "Retrieves list of earnings related to mining activities, including transferred hashrate, daily hashrate, profit amount, and the status of the payment (unpaid, paying, or paid).", { - algo: z.string().min(1).describe("Transfer algorithm (e.g., sha256)"), - userName: z.string().min(1).describe("Mining account username"), - coin: z.string().optional().describe("Coin name (optional)"), - startDate: z - .number() - .optional() - .describe("Search start date (milliseconds timestamp, optional)"), - endDate: z.number().optional().describe("Search end date (milliseconds timestamp, optional)"), - pageIndex: z - .number() - .int() - .min(1) - .optional() - .describe("Page number, default is the first page starting from 1"), - pageSize: z - .number() - .int() - .min(10) - .max(200) - .optional() - .describe("Number of pages, minimum 10, maximum 200"), - recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + description: + "Retrieves list of earnings related to mining activities, including transferred hashrate, daily hashrate, profit amount, and the status of the payment (unpaid, paying, or paid).", + inputSchema: { + algo: z.string().min(1).describe("Transfer algorithm (e.g., sha256)"), + userName: z.string().min(1).describe("Mining account username"), + coin: z.string().optional().describe("Coin name (optional)"), + startDate: z + .number() + .optional() + .describe("Search start date (milliseconds timestamp, optional)"), + endDate: z + .number() + .optional() + .describe("Search end date (milliseconds timestamp, optional)"), + pageIndex: z + .number() + .int() + .min(1) + .optional() + .describe("Page number, default is the first page starting from 1"), + pageSize: z + .number() + .int() + .min(10) + .max(200) + .optional() + .describe("Number of pages, minimum 10, maximum 200"), + recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + }, }, async (params) => { try { diff --git a/src/modules/mining/mining-api/extraBonusList.ts b/src/modules/mining/mining-api/extraBonusList.ts index a8a2c38c..fa6c330d 100644 --- a/src/modules/mining/mining-api/extraBonusList.ts +++ b/src/modules/mining/mining-api/extraBonusList.ts @@ -6,27 +6,33 @@ import { z } from "zod"; import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceExtraBonusList(server: McpServer) { - server.tool( + server.registerTool( "BinanceExtraBonusList", - "Retrieves extra bonuses related to mining activities, including merged mining, activity bonuses, rebates, smart pool bonuses, income transfers, and pool savings.", { - algo: z.string().min(1).describe("Transfer algorithm (e.g., sha256)"), - userName: z.string().min(1).describe("Mining account username"), - coin: z.string().optional().describe("Coin name (optional)"), - startDate: z - .number() - .optional() - .describe("Search start date (milliseconds timestamp, optional)"), - endDate: z.number().optional().describe("Search end date (milliseconds timestamp, optional)"), - pageIndex: z.number().int().min(1).optional().describe("Page number, default is 1"), - pageSize: z - .number() - .int() - .min(10) - .max(200) - .optional() - .describe("Number of pages, minimum 10, maximum 200"), - recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + description: + "Retrieves extra bonuses related to mining activities, including merged mining, activity bonuses, rebates, smart pool bonuses, income transfers, and pool savings.", + inputSchema: { + algo: z.string().min(1).describe("Transfer algorithm (e.g., sha256)"), + userName: z.string().min(1).describe("Mining account username"), + coin: z.string().optional().describe("Coin name (optional)"), + startDate: z + .number() + .optional() + .describe("Search start date (milliseconds timestamp, optional)"), + endDate: z + .number() + .optional() + .describe("Search end date (milliseconds timestamp, optional)"), + pageIndex: z.number().int().min(1).optional().describe("Page number, default is 1"), + pageSize: z + .number() + .int() + .min(10) + .max(200) + .optional() + .describe("Number of pages, minimum 10, maximum 200"), + recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + }, }, async (params) => { try { diff --git a/src/modules/mining/mining-api/hashrateResaleDetail.ts b/src/modules/mining/mining-api/hashrateResaleDetail.ts index b5b37a68..481f2138 100644 --- a/src/modules/mining/mining-api/hashrateResaleDetail.ts +++ b/src/modules/mining/mining-api/hashrateResaleDetail.ts @@ -6,26 +6,29 @@ import { z } from "zod"; import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceHashRateResaleDetail(server: McpServer) { - server.tool( + server.registerTool( "BinanceHashRateResaleDetail", - "Retrieves details of hashrate resale transactions, including the transferring and receiving subaccounts, algorithm, hash rate, transfer date, and associated income.", { - configId: z.number().int().min(1).describe("Mining ID"), - userName: z.string().min(1).describe("Mining Account"), - pageIndex: z - .number() - .int() - .min(1) - .optional() - .describe("Page number, default is the first page starting from 1"), - pageSize: z - .number() - .int() - .min(10) - .max(200) - .optional() - .describe("Number of pages, minimum 10, maximum 200"), - recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + description: + "Retrieves details of hashrate resale transactions, including the transferring and receiving subaccounts, algorithm, hash rate, transfer date, and associated income.", + inputSchema: { + configId: z.number().int().min(1).describe("Mining ID"), + userName: z.string().min(1).describe("Mining Account"), + pageIndex: z + .number() + .int() + .min(1) + .optional() + .describe("Page number, default is the first page starting from 1"), + pageSize: z + .number() + .int() + .min(10) + .max(200) + .optional() + .describe("Number of pages, minimum 10, maximum 200"), + recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + }, }, async (params) => { try { diff --git a/src/modules/mining/mining-api/hashrateResaleList.ts b/src/modules/mining/mining-api/hashrateResaleList.ts index 7c91d0bc..328fd0de 100644 --- a/src/modules/mining/mining-api/hashrateResaleList.ts +++ b/src/modules/mining/mining-api/hashrateResaleList.ts @@ -6,24 +6,31 @@ import { z } from "zod"; import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceHashRateResaleList(server: McpServer) { - server.tool( + server.registerTool( "BinanceHashRateResaleList", - "Returns the list of hashRate resale configurations including transfer details such as algorithm, hashrate amount, sender and receiver pool usernames, start and end dates, and status of the transfer.", { - pageIndex: z - .number() - .int() - .min(1) - .optional() - .describe("Page number, default is the first page starting from 1"), - pageSize: z - .number() - .int() - .min(10) - .max(200) - .optional() - .describe("Number of records per page, min 10, max 200"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Returns the list of hashRate resale configurations including transfer details such as algorithm, hashrate amount, sender and receiver pool usernames, start and end dates, and status of the transfer.", + inputSchema: { + pageIndex: z + .number() + .int() + .min(1) + .optional() + .describe("Page number, default is the first page starting from 1"), + pageSize: z + .number() + .int() + .min(10) + .max(200) + .optional() + .describe("Number of records per page, min 10, max 200"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/mining/mining-api/hashrateResaleRequest.ts b/src/modules/mining/mining-api/hashrateResaleRequest.ts index e8029938..6f81a5b4 100644 --- a/src/modules/mining/mining-api/hashrateResaleRequest.ts +++ b/src/modules/mining/mining-api/hashrateResaleRequest.ts @@ -6,24 +6,27 @@ import { z } from "zod"; import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceHashRateResaleRequest(server: McpServer) { - server.tool( + server.registerTool( "BinanceHashRateResaleRequest", - "Retrieve a request for setting up a hashrate resale, specifying the mining account, algorithm, start and end times, target mining account for resale, and the amount of hashrate to transfer", { - userName: z.string().min(1).describe("Mining Account"), - algo: z.string().min(1).describe("Transfer algorithm (e.g., sha256)"), - endDate: z.number().int().describe("Resale End Time (Millisecond timestamp)"), - startDate: z.number().int().describe("Resale Start Time (Millisecond timestamp)"), - toPoolUser: z.string().min(1).describe("Mining Account of the recipient pool user"), - hashRate: z - .number() - .int() - .describe("Resale hashrate h/s must be transferred (BTC > 500000000000, ETH > 500000)"), - recvWindow: z - .number() - .int() - .optional() - .describe("Optional: Time window for request validity"), + description: + "Retrieve a request for setting up a hashrate resale, specifying the mining account, algorithm, start and end times, target mining account for resale, and the amount of hashrate to transfer", + inputSchema: { + userName: z.string().min(1).describe("Mining Account"), + algo: z.string().min(1).describe("Transfer algorithm (e.g., sha256)"), + endDate: z.number().int().describe("Resale End Time (Millisecond timestamp)"), + startDate: z.number().int().describe("Resale Start Time (Millisecond timestamp)"), + toPoolUser: z.string().min(1).describe("Mining Account of the recipient pool user"), + hashRate: z + .number() + .int() + .describe("Resale hashrate h/s must be transferred (BTC > 500000000000, ETH > 500000)"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional: Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/mining/mining-api/miningAccountEarning.ts b/src/modules/mining/mining-api/miningAccountEarning.ts index 5b1d4e86..0bd262c0 100644 --- a/src/modules/mining/mining-api/miningAccountEarning.ts +++ b/src/modules/mining/mining-api/miningAccountEarning.ts @@ -6,22 +6,25 @@ import { z } from "zod"; import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceMiningAccountEarning(server: McpServer) { - server.tool( + server.registerTool( "BinanceMiningAccountEarning", - "Retrieves the earnings associated with a mining account, including the type of earnings (e.g., rebate, referral, refund), sub-account ID, the mining account name, and the amount earned. It also supports pagination for large data sets.", { - algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), - startDate: z.number().int().optional().describe("Millisecond timestamp for the start date"), - endDate: z.number().int().optional().describe("Millisecond timestamp for the end date"), - pageIndex: z.number().int().min(1).optional().describe("Page number, default is 1"), - pageSize: z - .number() - .int() - .min(10) - .max(200) - .optional() - .describe("Number of records per page, min 10, max 200"), - recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + description: + "Retrieves the earnings associated with a mining account, including the type of earnings (e.g., rebate, referral, refund), sub-account ID, the mining account name, and the amount earned. It also supports pagination for large data sets.", + inputSchema: { + algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), + startDate: z.number().int().optional().describe("Millisecond timestamp for the start date"), + endDate: z.number().int().optional().describe("Millisecond timestamp for the end date"), + pageIndex: z.number().int().min(1).optional().describe("Page number, default is 1"), + pageSize: z + .number() + .int() + .min(10) + .max(200) + .optional() + .describe("Number of records per page, min 10, max 200"), + recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + }, }, async (params) => { try { diff --git a/src/modules/mining/mining-api/requestForDetailMinerList.ts b/src/modules/mining/mining-api/requestForDetailMinerList.ts index 5302c9aa..3e2fde8b 100644 --- a/src/modules/mining/mining-api/requestForDetailMinerList.ts +++ b/src/modules/mining/mining-api/requestForDetailMinerList.ts @@ -6,14 +6,17 @@ import { z } from "zod"; import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceRequestForDetailMinerList(server: McpServer) { - server.tool( + server.registerTool( "BinanceRequestForDetailMinerList", - "Retrieves detailed hashrate data for a specific miner, including both hourly (H_hashrate) and daily (D_hashrate) metrics such as time, hashrate, and rejection rate.", { - algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), - userName: z.string().min(1).describe("Mining account username"), - workerName: z.string().min(1).describe("Miner’s name (required), e.g., bhdc1.16A10404B"), - recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + description: + "Retrieves detailed hashrate data for a specific miner, including both hourly (H_hashrate) and daily (D_hashrate) metrics such as time, hashrate, and rejection rate.", + inputSchema: { + algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), + userName: z.string().min(1).describe("Mining account username"), + workerName: z.string().min(1).describe("Miner’s name (required), e.g., bhdc1.16A10404B"), + recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + }, }, async (params) => { try { diff --git a/src/modules/mining/mining-api/requestForMinerList.ts b/src/modules/mining/mining-api/requestForMinerList.ts index b344712a..8385bacb 100644 --- a/src/modules/mining/mining-api/requestForMinerList.ts +++ b/src/modules/mining/mining-api/requestForMinerList.ts @@ -6,42 +6,45 @@ import { z } from "zod"; import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceRequestForMinerList(server: McpServer) { - server.tool( + server.registerTool( "BinanceRequestForMinerList", - "Retrieves a list of miners (workers) associated with a mining account, including details such as miner name, status, real-time hashrate, 24H hashrate, rejection rate, and last submission time.", { - algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), - userName: z.string().min(1).describe("Mining account username"), - pageIndex: z - .number() - .int() - .min(1) - .optional() - .describe("Page number, default is first page, starting from 1"), - sort: z - .number() - .int() - .min(0) - .max(1) - .optional() - .describe("Sort sequence: 0 = ascending (default), 1 = descending"), - sortColumn: z - .number() - .int() - .min(1) - .max(5) - .optional() - .describe( - `Sort by (default = 1): 1: miner name, 2: real-time computing power, 3: daily average computing power, 4: real-time rejection rate, 5: last submission time`, - ), - workerStatus: z - .number() - .int() - .min(0) - .max(3) - .optional() - .describe("Miner status (default = 0): 0 = all, 1 = valid, 2 = invalid, 3 = failure"), - recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + description: + "Retrieves a list of miners (workers) associated with a mining account, including details such as miner name, status, real-time hashrate, 24H hashrate, rejection rate, and last submission time.", + inputSchema: { + algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), + userName: z.string().min(1).describe("Mining account username"), + pageIndex: z + .number() + .int() + .min(1) + .optional() + .describe("Page number, default is first page, starting from 1"), + sort: z + .number() + .int() + .min(0) + .max(1) + .optional() + .describe("Sort sequence: 0 = ascending (default), 1 = descending"), + sortColumn: z + .number() + .int() + .min(1) + .max(5) + .optional() + .describe( + `Sort by (default = 1): 1: miner name, 2: real-time computing power, 3: daily average computing power, 4: real-time rejection rate, 5: last submission time`, + ), + workerStatus: z + .number() + .int() + .min(0) + .max(3) + .optional() + .describe("Miner status (default = 0): 0 = all, 1 = valid, 2 = invalid, 3 = failure"), + recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + }, }, async (params) => { try { diff --git a/src/modules/mining/mining-api/statisticList.ts b/src/modules/mining/mining-api/statisticList.ts index 6957833f..187bbde7 100644 --- a/src/modules/mining/mining-api/statisticList.ts +++ b/src/modules/mining/mining-api/statisticList.ts @@ -6,17 +6,20 @@ import { z } from "zod"; import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceStatisticList(server: McpServer) { - server.tool( + server.registerTool( "BinanceStatisticList", - "Retrieve mining statistics for a specific account, including hash rates for the past 15 minutes and 24 hours, the number of valid and invalid mining units, and the estimated profit for today and yesterday in various cryptocurrencies.", { - algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), - userName: z.string().min(1).describe("Mining account username"), - recvWindow: z - .number() - .int() - .optional() - .describe("Optional: Time window for request validity"), + description: + "Retrieve mining statistics for a specific account, including hash rates for the past 15 minutes and 24 hours, the number of valid and invalid mining units, and the estimated profit for today and yesterday in various cryptocurrencies.", + inputSchema: { + algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), + userName: z.string().min(1).describe("Mining account username"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional: Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/nft/nft-api/getNFTAsset.ts b/src/modules/nft/nft-api/getNFTAsset.ts index 335bc2c3..028b6474 100644 --- a/src/modules/nft/nft-api/getNFTAsset.ts +++ b/src/modules/nft/nft-api/getNFTAsset.ts @@ -6,18 +6,25 @@ import { z } from "zod"; import { nftClient } from "../../../config/binanceClient.js"; export function registerBinanceGetNFTAsset(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetNFTAsset", - "Retrieve NFT assets associated with a user's account. It returns details about the network, contract address, and token IDs for each NFT asset.", { - limit: z - .number() - .int() - .max(50, "Limit cannot be greater than 50") - .default(50) - .describe("Number of records to return, default 50, max 50"), - page: z.number().int().default(1).describe("Page number, default is 1"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Retrieve NFT assets associated with a user's account. It returns details about the network, contract address, and token IDs for each NFT asset.", + inputSchema: { + limit: z + .number() + .int() + .max(50, "Limit cannot be greater than 50") + .default(50) + .describe("Number of records to return, default 50, max 50"), + page: z.number().int().default(1).describe("Page number, default is 1"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/nft/nft-api/getNFTDepositHistory.ts b/src/modules/nft/nft-api/getNFTDepositHistory.ts index 57fec721..41a7ab5a 100644 --- a/src/modules/nft/nft-api/getNFTDepositHistory.ts +++ b/src/modules/nft/nft-api/getNFTDepositHistory.ts @@ -6,20 +6,27 @@ import { z } from "zod"; import { nftClient } from "../../../config/binanceClient.js"; export function registerBinanceGetNFTDepositHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetNFTDepositHistory", - "Retrieves NFT deposit history, including network, contract address, token ID, transaction ID (if available), and timestamps.", { - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .max(50, "Limit cannot be greater than 50") - .optional() - .describe("Number of records to return, default 50, max 50"), - page: z.number().int().optional().describe("Page number, default is 1"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Retrieves NFT deposit history, including network, contract address, token ID, transaction ID (if available), and timestamps.", + inputSchema: { + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(50, "Limit cannot be greater than 50") + .optional() + .describe("Number of records to return, default 50, max 50"), + page: z.number().int().optional().describe("Page number, default is 1"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/nft/nft-api/getNFTTransactionHistory.ts b/src/modules/nft/nft-api/getNFTTransactionHistory.ts index 0320072f..ecbbc676 100644 --- a/src/modules/nft/nft-api/getNFTTransactionHistory.ts +++ b/src/modules/nft/nft-api/getNFTTransactionHistory.ts @@ -6,25 +6,32 @@ import { z } from "zod"; import { nftClient } from "../../../config/binanceClient.js"; export function registerBinanceGetNFTTransactionHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetNFTTransactionHistory", - "Retrieves NFT transaction history, including purchase orders, sale orders, royalty income, primary market orders, and mint fees. It returns details about the NFT network, token IDs, contract addresses, transaction times, trade amounts, and the currencies used in the transactions.", { - orderType: z - .number() - .describe( - "Order type: 0 for purchase order, 1 for sell order, 2 for royalty income, 3 for primary market order, 4 for mint fee", - ), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .max(50, "Limit cannot be greater than 50") - .default(50) - .describe("Number of records to return, default 50, max 50"), - page: z.number().int().default(1).describe("Page number, default is 1"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Retrieves NFT transaction history, including purchase orders, sale orders, royalty income, primary market orders, and mint fees. It returns details about the NFT network, token IDs, contract addresses, transaction times, trade amounts, and the currencies used in the transactions.", + inputSchema: { + orderType: z + .number() + .describe( + "Order type: 0 for purchase order, 1 for sell order, 2 for royalty income, 3 for primary market order, 4 for mint fee", + ), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(50, "Limit cannot be greater than 50") + .default(50) + .describe("Number of records to return, default 50, max 50"), + page: z.number().int().default(1).describe("Page number, default is 1"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/nft/nft-api/getNFTWithdrawHistory.ts b/src/modules/nft/nft-api/getNFTWithdrawHistory.ts index b14b3cd9..924599a8 100644 --- a/src/modules/nft/nft-api/getNFTWithdrawHistory.ts +++ b/src/modules/nft/nft-api/getNFTWithdrawHistory.ts @@ -6,20 +6,27 @@ import { z } from "zod"; import { nftClient } from "../../../config/binanceClient.js"; export function registerBinanceGetNFTWithdrawHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetNFTWithdrawHistory", - "Retrieves NFT withdraw history, including network, transaction ID, contract address, token ID, withdrawal fee, fee asset, and timestamps.", { - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .max(50, "Limit cannot be greater than 50") - .default(50) - .describe("Number of records to return, default 50, max 50"), - page: z.number().int().default(1).describe("Page number, default is 1"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Retrieves NFT withdraw history, including network, transaction ID, contract address, token ID, withdrawal fee, fee asset, and timestamps.", + inputSchema: { + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(50, "Limit cannot be greater than 50") + .default(50) + .describe("Number of records to return, default 50, max 50"), + page: z.number().int().default(1).describe("Page number, default is 1"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/options/account-api/getAccount.ts b/src/modules/options/account-api/getAccount.ts index 6809abbe..b309833f 100644 --- a/src/modules/options/account-api/getAccount.ts +++ b/src/modules/options/account-api/getAccount.ts @@ -12,11 +12,13 @@ import { z } from "zod"; import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsGetAccount(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsGetAccount", - "Get options account information including balances and Greeks.", { - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Get options account information including balances and Greeks.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/options/account-api/getBillHistory.ts b/src/modules/options/account-api/getBillHistory.ts index 4a431c14..43855e27 100644 --- a/src/modules/options/account-api/getBillHistory.ts +++ b/src/modules/options/account-api/getBillHistory.ts @@ -12,22 +12,25 @@ import { z } from "zod"; import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsGetBillHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsGetBillHistory", - "Get options account funding flow (bill history). Shows transfers, fees, PnL, and other account activities.", { - currency: z.string().describe("Currency (e.g., 'USDT')"), - recordId: z.number().int().optional().describe("Record ID to start from"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .min(1) - .max(1000) - .optional() - .describe("Number of records to return (default 100, max 1000)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get options account funding flow (bill history). Shows transfers, fees, PnL, and other account activities.", + inputSchema: { + currency: z.string().describe("Currency (e.g., 'USDT')"), + recordId: z.number().int().optional().describe("Record ID to start from"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .describe("Number of records to return (default 100, max 1000)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/options/account-api/getIncomeAsyn.ts b/src/modules/options/account-api/getIncomeAsyn.ts index 8a138e17..eb7a213e 100644 --- a/src/modules/options/account-api/getIncomeAsyn.ts +++ b/src/modules/options/account-api/getIncomeAsyn.ts @@ -12,13 +12,16 @@ import { z } from "zod"; import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsGetIncomeAsyn(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsGetIncomeAsyn", - "Request to generate an async download ID for options income history. Use with BinanceOptionsGetIncomeAsynId to retrieve results.", { - startTime: z.number().int().describe("Start time in milliseconds"), - endTime: z.number().int().describe("End time in milliseconds"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Request to generate an async download ID for options income history. Use with BinanceOptionsGetIncomeAsynId to retrieve results.", + inputSchema: { + startTime: z.number().int().describe("Start time in milliseconds"), + endTime: z.number().int().describe("End time in milliseconds"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/options/account-api/getIncomeAsynId.ts b/src/modules/options/account-api/getIncomeAsynId.ts index f8038037..63894c37 100644 --- a/src/modules/options/account-api/getIncomeAsynId.ts +++ b/src/modules/options/account-api/getIncomeAsynId.ts @@ -12,12 +12,15 @@ import { z } from "zod"; import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsGetIncomeAsynId(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsGetIncomeAsynId", - "Get the download URL for options income history using a download ID from BinanceOptionsGetIncomeAsyn.", { - downloadId: z.string().describe("Download ID from BinanceOptionsGetIncomeAsyn"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get the download URL for options income history using a download ID from BinanceOptionsGetIncomeAsyn.", + inputSchema: { + downloadId: z.string().describe("Download ID from BinanceOptionsGetIncomeAsyn"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/options/account-api/getPosition.ts b/src/modules/options/account-api/getPosition.ts index 33d74956..065c4311 100644 --- a/src/modules/options/account-api/getPosition.ts +++ b/src/modules/options/account-api/getPosition.ts @@ -12,13 +12,18 @@ import { z } from "zod"; import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsGetPosition(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsGetPosition", - "Get current options positions. Shows all active option contracts held.", { - symbol: z.string().optional().describe("Option symbol to filter by"), - underlying: z.string().optional().describe("Underlying asset to filter by (e.g., 'BTCUSDT')"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Get current options positions. Shows all active option contracts held.", + inputSchema: { + symbol: z.string().optional().describe("Option symbol to filter by"), + underlying: z + .string() + .optional() + .describe("Underlying asset to filter by (e.g., 'BTCUSDT')"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/options/market-api/depth.ts b/src/modules/options/market-api/depth.ts index 4057042c..426b4001 100644 --- a/src/modules/options/market-api/depth.ts +++ b/src/modules/options/market-api/depth.ts @@ -12,18 +12,21 @@ import { z } from "zod"; import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsMarketDepth(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsDepth", - "Get the order book depth for an options contract. Shows current bids and asks at various price levels.", { - symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), - limit: z - .number() - .int() - .min(1) - .max(1000) - .optional() - .describe("Limit the number of price levels returned (default 100, max 1000)"), + description: + "Get the order book depth for an options contract. Shows current bids and asks at various price levels.", + inputSchema: { + symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), + limit: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .describe("Limit the number of price levels returned (default 100, max 1000)"), + }, }, async (params) => { try { diff --git a/src/modules/options/market-api/exchangeInfo.ts b/src/modules/options/market-api/exchangeInfo.ts index d795f193..5a5e02c0 100644 --- a/src/modules/options/market-api/exchangeInfo.ts +++ b/src/modules/options/market-api/exchangeInfo.ts @@ -10,10 +10,12 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsMarketExchangeInfo(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsExchangeInfo", - "Get current exchange trading rules and symbol information for options. Returns available option contracts, trading pairs, and their specifications.", - {}, + { + description: + "Get current exchange trading rules and symbol information for options. Returns available option contracts, trading pairs, and their specifications.", + }, async () => { try { const response = await optionsClient.restAPI.exchangeInfo(); diff --git a/src/modules/options/market-api/exerciseHistory.ts b/src/modules/options/market-api/exerciseHistory.ts index fdfd36c1..77de9d59 100644 --- a/src/modules/options/market-api/exerciseHistory.ts +++ b/src/modules/options/market-api/exerciseHistory.ts @@ -12,20 +12,23 @@ import { z } from "zod"; import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsMarketExerciseHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsExerciseHistory", - "Get the exercise history for options contracts. Shows historical exercise records and settlement prices.", { - underlying: z.string().optional().describe("Underlying asset (e.g., 'BTCUSDT')"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .min(1) - .max(100) - .optional() - .describe("Number of records to return (default 100, max 100)"), + description: + "Get the exercise history for options contracts. Shows historical exercise records and settlement prices.", + inputSchema: { + underlying: z.string().optional().describe("Underlying asset (e.g., 'BTCUSDT')"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .min(1) + .max(100) + .optional() + .describe("Number of records to return (default 100, max 100)"), + }, }, async (params) => { try { diff --git a/src/modules/options/market-api/historicalTrades.ts b/src/modules/options/market-api/historicalTrades.ts index ad905961..c4c2574d 100644 --- a/src/modules/options/market-api/historicalTrades.ts +++ b/src/modules/options/market-api/historicalTrades.ts @@ -12,23 +12,25 @@ import { z } from "zod"; import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsMarketHistoricalTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsHistoricalTrades", - "Get older market trades for an options contract. Requires API key.", { - symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), - limit: z - .number() - .int() - .min(1) - .max(500) - .optional() - .describe("Number of trades to return (default 100, max 500)"), - fromId: z - .number() - .int() - .optional() - .describe("Trade ID to fetch from. Default gets most recent trades"), + description: "Get older market trades for an options contract. Requires API key.", + inputSchema: { + symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), + limit: z + .number() + .int() + .min(1) + .max(500) + .optional() + .describe("Number of trades to return (default 100, max 500)"), + fromId: z + .number() + .int() + .optional() + .describe("Trade ID to fetch from. Default gets most recent trades"), + }, }, async (params) => { try { diff --git a/src/modules/options/market-api/indexPrice.ts b/src/modules/options/market-api/indexPrice.ts index 06f2872c..c6da2667 100644 --- a/src/modules/options/market-api/indexPrice.ts +++ b/src/modules/options/market-api/indexPrice.ts @@ -12,11 +12,14 @@ import { z } from "zod"; import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsMarketIndex(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsIndex", - "Get the current index price for the underlying asset. The index price is used as a reference for options pricing.", { - underlying: z.string().describe("Underlying asset (e.g., 'BTCUSDT', 'ETHUSDT')"), + description: + "Get the current index price for the underlying asset. The index price is used as a reference for options pricing.", + inputSchema: { + underlying: z.string().describe("Underlying asset (e.g., 'BTCUSDT', 'ETHUSDT')"), + }, }, async (params) => { try { diff --git a/src/modules/options/market-api/klines.ts b/src/modules/options/market-api/klines.ts index a72702bc..69172df3 100644 --- a/src/modules/options/market-api/klines.ts +++ b/src/modules/options/market-api/klines.ts @@ -12,23 +12,26 @@ import { z } from "zod"; import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsMarketKlines(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsKlines", - "Get kline/candlestick data for an options contract. Returns OHLCV data for technical analysis.", { - symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), - interval: z - .enum(["1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d", "3d", "1w"]) - .describe("Kline interval"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .min(1) - .max(1500) - .optional() - .describe("Number of klines to return (default 500, max 1500)"), + description: + "Get kline/candlestick data for an options contract. Returns OHLCV data for technical analysis.", + inputSchema: { + symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), + interval: z + .enum(["1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d", "3d", "1w"]) + .describe("Kline interval"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .min(1) + .max(1500) + .optional() + .describe("Number of klines to return (default 500, max 1500)"), + }, }, async (params) => { try { diff --git a/src/modules/options/market-api/mark.ts b/src/modules/options/market-api/mark.ts index 360d6e62..40160cb9 100644 --- a/src/modules/options/market-api/mark.ts +++ b/src/modules/options/market-api/mark.ts @@ -12,16 +12,19 @@ import { z } from "zod"; import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsMarketMark(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsMark", - "Get the mark price for options contracts. Mark price is used for liquidation and margin calculations.", { - symbol: z - .string() - .optional() - .describe( - "Option symbol (e.g., 'BTC-240126-40000-C'). If not provided, returns all mark prices", - ), + description: + "Get the mark price for options contracts. Mark price is used for liquidation and margin calculations.", + inputSchema: { + symbol: z + .string() + .optional() + .describe( + "Option symbol (e.g., 'BTC-240126-40000-C'). If not provided, returns all mark prices", + ), + }, }, async (params) => { try { diff --git a/src/modules/options/market-api/ping.ts b/src/modules/options/market-api/ping.ts index bbd5a58d..54e28546 100644 --- a/src/modules/options/market-api/ping.ts +++ b/src/modules/options/market-api/ping.ts @@ -10,10 +10,9 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsMarketPing(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsPing", - "Test connectivity to the Options API. Returns empty object if successful.", - {}, + { description: "Test connectivity to the Options API. Returns empty object if successful." }, async () => { try { const response = await optionsClient.restAPI.ping(); diff --git a/src/modules/options/market-api/ticker.ts b/src/modules/options/market-api/ticker.ts index f36445c0..a753f62c 100644 --- a/src/modules/options/market-api/ticker.ts +++ b/src/modules/options/market-api/ticker.ts @@ -12,16 +12,19 @@ import { z } from "zod"; import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsMarketTicker(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsTicker", - "Get 24hr ticker price change statistics for options contracts. Returns price change, volume, and other trading stats.", { - symbol: z - .string() - .optional() - .describe( - "Option symbol (e.g., 'BTC-240126-40000-C'). If not provided, returns all tickers", - ), + description: + "Get 24hr ticker price change statistics for options contracts. Returns price change, volume, and other trading stats.", + inputSchema: { + symbol: z + .string() + .optional() + .describe( + "Option symbol (e.g., 'BTC-240126-40000-C'). If not provided, returns all tickers", + ), + }, }, async (params) => { try { diff --git a/src/modules/options/market-api/time.ts b/src/modules/options/market-api/time.ts index 76337b9d..440ea170 100644 --- a/src/modules/options/market-api/time.ts +++ b/src/modules/options/market-api/time.ts @@ -10,10 +10,9 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsMarketTime(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsTime", - "Get the current server time from the Options API.", - {}, + { description: "Get the current server time from the Options API." }, async () => { try { const response = await optionsClient.restAPI.time(); diff --git a/src/modules/options/market-api/trades.ts b/src/modules/options/market-api/trades.ts index cc9b2fd4..0cb9f2af 100644 --- a/src/modules/options/market-api/trades.ts +++ b/src/modules/options/market-api/trades.ts @@ -12,18 +12,21 @@ import { z } from "zod"; import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsMarketTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsTrades", - "Get recent trades for an options contract. Shows the most recent executed trades.", { - symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), - limit: z - .number() - .int() - .min(1) - .max(500) - .optional() - .describe("Number of trades to return (default 100, max 500)"), + description: + "Get recent trades for an options contract. Shows the most recent executed trades.", + inputSchema: { + symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), + limit: z + .number() + .int() + .min(1) + .max(500) + .optional() + .describe("Number of trades to return (default 100, max 500)"), + }, }, async (params) => { try { diff --git a/src/modules/options/trade-api/batchOrders.ts b/src/modules/options/trade-api/batchOrders.ts index a1cd1bf7..255274f4 100644 --- a/src/modules/options/trade-api/batchOrders.ts +++ b/src/modules/options/trade-api/batchOrders.ts @@ -12,28 +12,31 @@ import { z } from "zod"; import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsBatchOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsBatchOrders", - "Place multiple options orders in a single request. Maximum 5 orders per request. ⚠️ HIGH RISK: Options can expire worthless.", { - orders: z - .array( - z.object({ - symbol: z.string().describe("Option symbol"), - side: z.enum(["BUY", "SELL"]).describe("Order side"), - type: z.enum(["LIMIT"]).describe("Order type"), - quantity: z.string().describe("Number of contracts"), - price: z.string().describe("Limit price"), - timeInForce: z.enum(["GTC", "IOC", "FOK"]).optional(), - reduceOnly: z.boolean().optional(), - postOnly: z.boolean().optional(), - newClientOrderId: z.string().optional(), - }), - ) - .min(1) - .max(5) - .describe("Array of orders (max 5)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Place multiple options orders in a single request. Maximum 5 orders per request. ⚠️ HIGH RISK: Options can expire worthless.", + inputSchema: { + orders: z + .array( + z.object({ + symbol: z.string().describe("Option symbol"), + side: z.enum(["BUY", "SELL"]).describe("Order side"), + type: z.enum(["LIMIT"]).describe("Order type"), + quantity: z.string().describe("Number of contracts"), + price: z.string().describe("Limit price"), + timeInForce: z.enum(["GTC", "IOC", "FOK"]).optional(), + reduceOnly: z.boolean().optional(), + postOnly: z.boolean().optional(), + newClientOrderId: z.string().optional(), + }), + ) + .min(1) + .max(5) + .describe("Array of orders (max 5)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/options/trade-api/cancelAllOrders.ts b/src/modules/options/trade-api/cancelAllOrders.ts index cd6489d3..70ad7dbb 100644 --- a/src/modules/options/trade-api/cancelAllOrders.ts +++ b/src/modules/options/trade-api/cancelAllOrders.ts @@ -12,12 +12,15 @@ import { z } from "zod"; import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsCancelAllOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsCancelAllOrders", - "Cancel all open options orders for a specific symbol. ⚠️ This will cancel ALL open orders for the symbol.", { - symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Cancel all open options orders for a specific symbol. ⚠️ This will cancel ALL open orders for the symbol.", + inputSchema: { + symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/options/trade-api/cancelBatchOrders.ts b/src/modules/options/trade-api/cancelBatchOrders.ts index eff4472d..1bab4df2 100644 --- a/src/modules/options/trade-api/cancelBatchOrders.ts +++ b/src/modules/options/trade-api/cancelBatchOrders.ts @@ -12,20 +12,23 @@ import { z } from "zod"; import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsCancelBatchOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsCancelBatchOrders", - "Cancel multiple options orders in a single request. Maximum 5 orders per request.", { - symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), - orderIds: z - .array(z.number().int()) - .optional() - .describe("Array of order IDs to cancel (max 5)"), - clientOrderIds: z - .array(z.string()) - .optional() - .describe("Array of client order IDs to cancel (max 5)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Cancel multiple options orders in a single request. Maximum 5 orders per request.", + inputSchema: { + symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), + orderIds: z + .array(z.number().int()) + .optional() + .describe("Array of order IDs to cancel (max 5)"), + clientOrderIds: z + .array(z.string()) + .optional() + .describe("Array of client order IDs to cancel (max 5)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/options/trade-api/cancelBySymbol.ts b/src/modules/options/trade-api/cancelBySymbol.ts index a9983c94..3cbedfe2 100644 --- a/src/modules/options/trade-api/cancelBySymbol.ts +++ b/src/modules/options/trade-api/cancelBySymbol.ts @@ -12,12 +12,15 @@ import { z } from "zod"; import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsCancelBySymbol(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsCancelByUnderlying", - "Cancel all open options orders for all contracts of an underlying asset (e.g., all BTC options). ⚠️ This will cancel ALL open orders for the underlying.", { - underlying: z.string().describe("Underlying asset (e.g., 'BTCUSDT')"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Cancel all open options orders for all contracts of an underlying asset (e.g., all BTC options). ⚠️ This will cancel ALL open orders for the underlying.", + inputSchema: { + underlying: z.string().describe("Underlying asset (e.g., 'BTCUSDT')"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/options/trade-api/cancelOrder.ts b/src/modules/options/trade-api/cancelOrder.ts index 70aa7357..b7dee3a8 100644 --- a/src/modules/options/trade-api/cancelOrder.ts +++ b/src/modules/options/trade-api/cancelOrder.ts @@ -12,14 +12,16 @@ import { z } from "zod"; import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsCancelOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsCancelOrder", - "Cancel an active options order by order ID or client order ID.", { - symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), - orderId: z.number().int().optional().describe("Order ID to cancel"), - clientOrderId: z.string().optional().describe("Client order ID to cancel"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Cancel an active options order by order ID or client order ID.", + inputSchema: { + symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), + orderId: z.number().int().optional().describe("Order ID to cancel"), + clientOrderId: z.string().optional().describe("Client order ID to cancel"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/options/trade-api/getHistoryOrders.ts b/src/modules/options/trade-api/getHistoryOrders.ts index 825ffe76..c08ae742 100644 --- a/src/modules/options/trade-api/getHistoryOrders.ts +++ b/src/modules/options/trade-api/getHistoryOrders.ts @@ -12,22 +12,24 @@ import { z } from "zod"; import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsGetHistoryOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsGetHistoryOrders", - "Get historical options orders. Returns filled, cancelled, and expired orders.", { - symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), - orderId: z.number().int().optional().describe("Order ID to start from"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .min(1) - .max(1000) - .optional() - .describe("Number of orders to return (default 500, max 1000)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Get historical options orders. Returns filled, cancelled, and expired orders.", + inputSchema: { + symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), + orderId: z.number().int().optional().describe("Order ID to start from"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .describe("Number of orders to return (default 500, max 1000)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/options/trade-api/getOpenOrders.ts b/src/modules/options/trade-api/getOpenOrders.ts index 3e6d834d..99bdb69f 100644 --- a/src/modules/options/trade-api/getOpenOrders.ts +++ b/src/modules/options/trade-api/getOpenOrders.ts @@ -12,13 +12,18 @@ import { z } from "zod"; import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsGetOpenOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsGetOpenOrders", - "Get all open options orders. Can filter by symbol or underlying asset.", { - symbol: z.string().optional().describe("Option symbol to filter by"), - underlying: z.string().optional().describe("Underlying asset to filter by (e.g., 'BTCUSDT')"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Get all open options orders. Can filter by symbol or underlying asset.", + inputSchema: { + symbol: z.string().optional().describe("Option symbol to filter by"), + underlying: z + .string() + .optional() + .describe("Underlying asset to filter by (e.g., 'BTCUSDT')"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/options/trade-api/getUserTrades.ts b/src/modules/options/trade-api/getUserTrades.ts index e59e46cc..78d74a4b 100644 --- a/src/modules/options/trade-api/getUserTrades.ts +++ b/src/modules/options/trade-api/getUserTrades.ts @@ -12,23 +12,29 @@ import { z } from "zod"; import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsGetUserTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsGetUserTrades", - "Get user's options trade history. Returns executed trades with prices and quantities.", { - symbol: z.string().optional().describe("Option symbol to filter by"), - underlying: z.string().optional().describe("Underlying asset to filter by (e.g., 'BTCUSDT')"), - fromId: z.number().int().optional().describe("Trade ID to fetch from"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .min(1) - .max(1000) - .optional() - .describe("Number of trades to return (default 100, max 1000)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get user's options trade history. Returns executed trades with prices and quantities.", + inputSchema: { + symbol: z.string().optional().describe("Option symbol to filter by"), + underlying: z + .string() + .optional() + .describe("Underlying asset to filter by (e.g., 'BTCUSDT')"), + fromId: z.number().int().optional().describe("Trade ID to fetch from"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .describe("Number of trades to return (default 100, max 1000)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/options/trade-api/newOrder.ts b/src/modules/options/trade-api/newOrder.ts index 4a5512e2..df7362ca 100644 --- a/src/modules/options/trade-api/newOrder.ts +++ b/src/modules/options/trade-api/newOrder.ts @@ -12,24 +12,27 @@ import { z } from "zod"; import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsNewOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsNewOrder", - "Place a new options order. Options trading allows you to buy/sell call and put contracts. ⚠️ HIGH RISK: Options can expire worthless.", { - symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), - side: z.enum(["BUY", "SELL"]).describe("Order side"), - type: z.enum(["LIMIT"]).describe("Order type (only LIMIT supported)"), - quantity: z.string().describe("Number of contracts"), - price: z.string().describe("Limit price per contract"), - timeInForce: z - .enum(["GTC", "IOC", "FOK"]) - .optional() - .describe("Time in force (default: GTC)"), - reduceOnly: z.boolean().optional().describe("Reduce position only (default: false)"), - postOnly: z.boolean().optional().describe("Post only order (default: false)"), - newClientOrderId: z.string().optional().describe("Custom client order ID"), - isMmp: z.boolean().optional().describe("Is market maker protection order"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Place a new options order. Options trading allows you to buy/sell call and put contracts. ⚠️ HIGH RISK: Options can expire worthless.", + inputSchema: { + symbol: z.string().describe("Option symbol (e.g., 'BTC-240126-40000-C')"), + side: z.enum(["BUY", "SELL"]).describe("Order side"), + type: z.enum(["LIMIT"]).describe("Order type (only LIMIT supported)"), + quantity: z.string().describe("Number of contracts"), + price: z.string().describe("Limit price per contract"), + timeInForce: z + .enum(["GTC", "IOC", "FOK"]) + .optional() + .describe("Time in force (default: GTC)"), + reduceOnly: z.boolean().optional().describe("Reduce position only (default: false)"), + postOnly: z.boolean().optional().describe("Post only order (default: false)"), + newClientOrderId: z.string().optional().describe("Custom client order ID"), + isMmp: z.boolean().optional().describe("Is market maker protection order"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/options/userdata-api/createListenKey.ts b/src/modules/options/userdata-api/createListenKey.ts index e722ad36..74116287 100644 --- a/src/modules/options/userdata-api/createListenKey.ts +++ b/src/modules/options/userdata-api/createListenKey.ts @@ -10,10 +10,12 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsCreateListenKey(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsCreateListenKey", - "Create a listen key for options user data stream. The listen key is used to subscribe to account updates via WebSocket.", - {}, + { + description: + "Create a listen key for options user data stream. The listen key is used to subscribe to account updates via WebSocket.", + }, async () => { try { const response = await optionsClient.restAPI.createListenKey(); diff --git a/src/modules/options/userdata-api/deleteListenKey.ts b/src/modules/options/userdata-api/deleteListenKey.ts index 9fab2770..14da4084 100644 --- a/src/modules/options/userdata-api/deleteListenKey.ts +++ b/src/modules/options/userdata-api/deleteListenKey.ts @@ -12,14 +12,17 @@ import { z } from "zod"; import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsDeleteListenKey(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsDeleteListenKey", - "Close/delete an options listen key. This will terminate the user data stream connection.", { - listenKey: z - .string() - .optional() - .describe("Listen key to delete. If not provided, deletes the current active key"), + description: + "Close/delete an options listen key. This will terminate the user data stream connection.", + inputSchema: { + listenKey: z + .string() + .optional() + .describe("Listen key to delete. If not provided, deletes the current active key"), + }, }, async (params) => { try { diff --git a/src/modules/options/userdata-api/renewListenKey.ts b/src/modules/options/userdata-api/renewListenKey.ts index d78e408b..87cc6389 100644 --- a/src/modules/options/userdata-api/renewListenKey.ts +++ b/src/modules/options/userdata-api/renewListenKey.ts @@ -12,14 +12,17 @@ import { z } from "zod"; import { optionsClient } from "../../../config/binanceClient.js"; export function registerOptionsRenewListenKey(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsRenewListenKey", - "Extend the validity of an options listen key by 60 minutes. Should be called periodically to keep the user data stream active.", { - listenKey: z - .string() - .optional() - .describe("Listen key to renew. If not provided, renews the current active key"), + description: + "Extend the validity of an options listen key by 60 minutes. Should be called periodically to keep the user data stream active.", + inputSchema: { + listenKey: z + .string() + .optional() + .describe("Listen key to renew. If not provided, renews the current active key"), + }, }, async (params) => { try { diff --git a/src/modules/pay/pay-api/createOrder.ts b/src/modules/pay/pay-api/createOrder.ts index dd5f7ddf..685119f4 100644 --- a/src/modules/pay/pay-api/createOrder.ts +++ b/src/modules/pay/pay-api/createOrder.ts @@ -12,18 +12,21 @@ import { z } from "zod"; import { payClient } from "../../../config/binanceClient.js"; export function registerBinancePayCreateOrder(server: McpServer) { - server.tool( + server.registerTool( "BinancePayCreateOrder", - "Create a Binance Pay order for receiving crypto payments. Generate payment links for e-commerce or P2P transactions. 💳", { - merchantId: z.string().optional().describe("Merchant ID (for business accounts)"), - orderId: z.string().describe("Unique order ID for your reference"), - currency: z.string().describe("Payment currency (e.g., 'USDT', 'BTC')"), - totalAmount: z.string().describe("Total payment amount"), - description: z.string().optional().describe("Order description"), - goodsName: z.string().optional().describe("Name of goods/service"), - goodsDetail: z.string().optional().describe("Details of goods/service"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Create a Binance Pay order for receiving crypto payments. Generate payment links for e-commerce or P2P transactions. 💳", + inputSchema: { + merchantId: z.string().optional().describe("Merchant ID (for business accounts)"), + orderId: z.string().describe("Unique order ID for your reference"), + currency: z.string().describe("Payment currency (e.g., 'USDT', 'BTC')"), + totalAmount: z.string().describe("Total payment amount"), + description: z.string().optional().describe("Order description"), + goodsName: z.string().optional().describe("Name of goods/service"), + goodsDetail: z.string().optional().describe("Details of goods/service"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/pay/pay-api/getHistory.ts b/src/modules/pay/pay-api/getHistory.ts index b2f17e42..8199df23 100644 --- a/src/modules/pay/pay-api/getHistory.ts +++ b/src/modules/pay/pay-api/getHistory.ts @@ -12,20 +12,23 @@ import { z } from "zod"; import { payClient } from "../../../config/binanceClient.js"; export function registerBinancePayGetHistory(server: McpServer) { - server.tool( + server.registerTool( "BinancePayGetHistory", - "Get your Binance Pay transaction history. Shows all Pay transactions including C2C transfers, merchant payments, and refunds.", { - startTime: z.number().int().optional().describe("Start time in ms"), - endTime: z.number().int().optional().describe("End time in ms"), - limit: z - .number() - .int() - .max(100) - .default(100) - .optional() - .describe("Number of records (max 100)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get your Binance Pay transaction history. Shows all Pay transactions including C2C transfers, merchant payments, and refunds.", + inputSchema: { + startTime: z.number().int().optional().describe("Start time in ms"), + endTime: z.number().int().optional().describe("End time in ms"), + limit: z + .number() + .int() + .max(100) + .default(100) + .optional() + .describe("Number of records (max 100)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/pay/pay-api/getPayTradeHistory.ts b/src/modules/pay/pay-api/getPayTradeHistory.ts index 479cd14d..ac62322d 100644 --- a/src/modules/pay/pay-api/getPayTradeHistory.ts +++ b/src/modules/pay/pay-api/getPayTradeHistory.ts @@ -6,19 +6,26 @@ import { z } from "zod"; import { payClient } from "../../../config/binanceClient.js"; export function registerBinanceGetPayTradeHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetPayTradeHistory", - "Retrieve Binance Pay trade history using GET to fetch transaction records such as C2C transfers, merchant payments, crypto box activity, refunds, payouts, and remittance details.", { - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .max(100, "Limit cannot be greater than 100") - .default(100) - .describe("Number of records to return, default 100, max 100"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Retrieve Binance Pay trade history using GET to fetch transaction records such as C2C transfers, merchant payments, crypto box activity, refunds, payouts, and remittance details.", + inputSchema: { + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(100, "Limit cannot be greater than 100") + .default(100) + .describe("Number of records to return, default 100, max 100"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/pay/pay-api/queryOrder.ts b/src/modules/pay/pay-api/queryOrder.ts index bf9fd4b0..932deab7 100644 --- a/src/modules/pay/pay-api/queryOrder.ts +++ b/src/modules/pay/pay-api/queryOrder.ts @@ -12,14 +12,16 @@ import { z } from "zod"; import { payClient } from "../../../config/binanceClient.js"; export function registerBinancePayQueryOrder(server: McpServer) { - server.tool( + server.registerTool( "BinancePayQueryOrder", - "Query the status of a Binance Pay order. Check if payment has been received.", { - merchantId: z.string().optional().describe("Merchant ID"), - prepayId: z.string().optional().describe("Prepay ID from order creation"), - merchantTradeNo: z.string().optional().describe("Your merchant trade number"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Query the status of a Binance Pay order. Check if payment has been received.", + inputSchema: { + merchantId: z.string().optional().describe("Merchant ID"), + prepayId: z.string().optional().describe("Prepay ID from order creation"), + merchantTradeNo: z.string().optional().describe("Your merchant trade number"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/account/getAccountInfo.ts b/src/modules/portfolio-margin/account/getAccountInfo.ts index 85928852..2db214db 100644 --- a/src/modules/portfolio-margin/account/getAccountInfo.ts +++ b/src/modules/portfolio-margin/account/getAccountInfo.ts @@ -12,11 +12,14 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginGetAccountInfo(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginGetAccount", - "Get Portfolio Margin account information including unified account equity, margin status, and risk levels.", { - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get Portfolio Margin account information including unified account equity, margin status, and risk levels.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/account/getBalance.ts b/src/modules/portfolio-margin/account/getBalance.ts index cdf2c075..885aed98 100644 --- a/src/modules/portfolio-margin/account/getBalance.ts +++ b/src/modules/portfolio-margin/account/getBalance.ts @@ -12,15 +12,17 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginGetBalance(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginGetBalance", - "Get Portfolio Margin account balance information for all assets.", { - asset: z - .string() - .optional() - .describe("Asset to query (e.g., 'USDT'). If not provided, returns all assets"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Get Portfolio Margin account balance information for all assets.", + inputSchema: { + asset: z + .string() + .optional() + .describe("Asset to query (e.g., 'USDT'). If not provided, returns all assets"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/account/getCmAccount.ts b/src/modules/portfolio-margin/account/getCmAccount.ts index 841becbf..cdef7e09 100644 --- a/src/modules/portfolio-margin/account/getCmAccount.ts +++ b/src/modules/portfolio-margin/account/getCmAccount.ts @@ -12,11 +12,13 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginGetCmAccount(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginGetCmAccount", - "Get COIN-M Futures account information within Portfolio Margin mode.", { - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Get COIN-M Futures account information within Portfolio Margin mode.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/account/getCmPosition.ts b/src/modules/portfolio-margin/account/getCmPosition.ts index bdb012a3..33f456e3 100644 --- a/src/modules/portfolio-margin/account/getCmPosition.ts +++ b/src/modules/portfolio-margin/account/getCmPosition.ts @@ -12,13 +12,15 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginGetCmPosition(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginGetCmPosition", - "Get COIN-M Futures position risk information within Portfolio Margin mode.", { - marginAsset: z.string().optional().describe("Margin asset (e.g., 'BTC')"), - pair: z.string().optional().describe("Trading pair (e.g., 'BTCUSD')"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Get COIN-M Futures position risk information within Portfolio Margin mode.", + inputSchema: { + marginAsset: z.string().optional().describe("Margin asset (e.g., 'BTC')"), + pair: z.string().optional().describe("Trading pair (e.g., 'BTCUSD')"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/account/getMarginAccount.ts b/src/modules/portfolio-margin/account/getMarginAccount.ts index d35453b7..7f42ca0c 100644 --- a/src/modules/portfolio-margin/account/getMarginAccount.ts +++ b/src/modules/portfolio-margin/account/getMarginAccount.ts @@ -12,11 +12,13 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginGetMarginAccount(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginGetMarginAccount", - "Get cross margin account information within Portfolio Margin mode.", { - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Get cross margin account information within Portfolio Margin mode.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/account/getMaxBorrowable.ts b/src/modules/portfolio-margin/account/getMaxBorrowable.ts index c0f3acd6..dd809420 100644 --- a/src/modules/portfolio-margin/account/getMaxBorrowable.ts +++ b/src/modules/portfolio-margin/account/getMaxBorrowable.ts @@ -12,12 +12,15 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginGetMaxBorrowable(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginGetMaxBorrowable", - "Query the maximum amount that can be borrowed for a specific asset in Portfolio Margin mode.", { - asset: z.string().describe("Asset to query (e.g., 'USDT')"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Query the maximum amount that can be borrowed for a specific asset in Portfolio Margin mode.", + inputSchema: { + asset: z.string().describe("Asset to query (e.g., 'USDT')"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/account/getMaxWithdraw.ts b/src/modules/portfolio-margin/account/getMaxWithdraw.ts index 0119f922..afc7d9d8 100644 --- a/src/modules/portfolio-margin/account/getMaxWithdraw.ts +++ b/src/modules/portfolio-margin/account/getMaxWithdraw.ts @@ -12,12 +12,15 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginGetMaxWithdraw(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginGetMaxWithdraw", - "Query the maximum amount that can be withdrawn for a specific asset from Portfolio Margin account.", { - asset: z.string().describe("Asset to query (e.g., 'USDT')"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Query the maximum amount that can be withdrawn for a specific asset from Portfolio Margin account.", + inputSchema: { + asset: z.string().describe("Asset to query (e.g., 'USDT')"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/account/getUmAccount.ts b/src/modules/portfolio-margin/account/getUmAccount.ts index b2abcb39..c3ac2e88 100644 --- a/src/modules/portfolio-margin/account/getUmAccount.ts +++ b/src/modules/portfolio-margin/account/getUmAccount.ts @@ -12,11 +12,13 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginGetUmAccount(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginGetUmAccount", - "Get USDT-M Futures account information within Portfolio Margin mode.", { - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Get USDT-M Futures account information within Portfolio Margin mode.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/account/getUmPosition.ts b/src/modules/portfolio-margin/account/getUmPosition.ts index 3c382210..b2afb700 100644 --- a/src/modules/portfolio-margin/account/getUmPosition.ts +++ b/src/modules/portfolio-margin/account/getUmPosition.ts @@ -12,12 +12,14 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginGetUmPosition(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginGetUmPosition", - "Get USDT-M Futures position risk information within Portfolio Margin mode.", { - symbol: z.string().optional().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Get USDT-M Futures position risk information within Portfolio Margin mode.", + inputSchema: { + symbol: z.string().optional().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/cm-trade/cancelAllOrders.ts b/src/modules/portfolio-margin/cm-trade/cancelAllOrders.ts index ae7d8dba..98f57f5c 100644 --- a/src/modules/portfolio-margin/cm-trade/cancelAllOrders.ts +++ b/src/modules/portfolio-margin/cm-trade/cancelAllOrders.ts @@ -12,12 +12,15 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginCmCancelAllOrders(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginCmCancelAllOrders", - "Cancel all open COIN-M Futures orders for a symbol in Portfolio Margin mode. ⚠️ This will cancel ALL open orders.", { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Cancel all open COIN-M Futures orders for a symbol in Portfolio Margin mode. ⚠️ This will cancel ALL open orders.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/cm-trade/cancelOrder.ts b/src/modules/portfolio-margin/cm-trade/cancelOrder.ts index c5c9f8c4..aee5bc81 100644 --- a/src/modules/portfolio-margin/cm-trade/cancelOrder.ts +++ b/src/modules/portfolio-margin/cm-trade/cancelOrder.ts @@ -12,14 +12,16 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginCmCancelOrder(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginCmCancelOrder", - "Cancel an active COIN-M Futures order in Portfolio Margin mode.", { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), - orderId: z.number().int().optional().describe("Order ID to cancel"), - origClientOrderId: z.string().optional().describe("Original client order ID to cancel"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Cancel an active COIN-M Futures order in Portfolio Margin mode.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), + orderId: z.number().int().optional().describe("Order ID to cancel"), + origClientOrderId: z.string().optional().describe("Original client order ID to cancel"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/cm-trade/changeLeverage.ts b/src/modules/portfolio-margin/cm-trade/changeLeverage.ts index 7bbf0540..da0c82da 100644 --- a/src/modules/portfolio-margin/cm-trade/changeLeverage.ts +++ b/src/modules/portfolio-margin/cm-trade/changeLeverage.ts @@ -12,13 +12,16 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginCmChangeLeverage(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginCmChangeLeverage", - "Change leverage for a COIN-M Futures symbol in Portfolio Margin mode. ⚠️ Higher leverage increases risk.", { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), - leverage: z.number().int().min(1).max(125).describe("Target leverage (1-125)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Change leverage for a COIN-M Futures symbol in Portfolio Margin mode. ⚠️ Higher leverage increases risk.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), + leverage: z.number().int().min(1).max(125).describe("Target leverage (1-125)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/cm-trade/changeMarginType.ts b/src/modules/portfolio-margin/cm-trade/changeMarginType.ts index 11c25050..c1311646 100644 --- a/src/modules/portfolio-margin/cm-trade/changeMarginType.ts +++ b/src/modules/portfolio-margin/cm-trade/changeMarginType.ts @@ -12,13 +12,16 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginCmChangeMarginType(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginCmChangeMarginType", - "Change margin type (ISOLATED/CROSSED) for a COIN-M Futures symbol in Portfolio Margin mode.", { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), - marginType: z.enum(["ISOLATED", "CROSSED"]).describe("Margin type"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Change margin type (ISOLATED/CROSSED) for a COIN-M Futures symbol in Portfolio Margin mode.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), + marginType: z.enum(["ISOLATED", "CROSSED"]).describe("Margin type"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/cm-trade/getAllOrders.ts b/src/modules/portfolio-margin/cm-trade/getAllOrders.ts index 46858f7f..0548c032 100644 --- a/src/modules/portfolio-margin/cm-trade/getAllOrders.ts +++ b/src/modules/portfolio-margin/cm-trade/getAllOrders.ts @@ -12,23 +12,26 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginCmGetAllOrders(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginCmGetAllOrders", - "Get all COIN-M Futures orders (active, cancelled, filled) in Portfolio Margin mode.", { - symbol: z.string().optional().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), - pair: z.string().optional().describe("Trading pair (e.g., 'BTCUSD')"), - orderId: z.number().int().optional().describe("Order ID to start from"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .min(1) - .max(1000) - .optional() - .describe("Number of orders to return (default 500, max 1000)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get all COIN-M Futures orders (active, cancelled, filled) in Portfolio Margin mode.", + inputSchema: { + symbol: z.string().optional().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), + pair: z.string().optional().describe("Trading pair (e.g., 'BTCUSD')"), + orderId: z.number().int().optional().describe("Order ID to start from"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .describe("Number of orders to return (default 500, max 1000)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/cm-trade/getOpenOrders.ts b/src/modules/portfolio-margin/cm-trade/getOpenOrders.ts index 491a9bc0..2f022c6e 100644 --- a/src/modules/portfolio-margin/cm-trade/getOpenOrders.ts +++ b/src/modules/portfolio-margin/cm-trade/getOpenOrders.ts @@ -12,13 +12,15 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginCmGetOpenOrders(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginCmGetOpenOrders", - "Get all open COIN-M Futures orders in Portfolio Margin mode.", { - symbol: z.string().optional().describe("Trading pair symbol to filter by"), - pair: z.string().optional().describe("Trading pair to filter by (e.g., 'BTCUSD')"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Get all open COIN-M Futures orders in Portfolio Margin mode.", + inputSchema: { + symbol: z.string().optional().describe("Trading pair symbol to filter by"), + pair: z.string().optional().describe("Trading pair to filter by (e.g., 'BTCUSD')"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/cm-trade/getOrder.ts b/src/modules/portfolio-margin/cm-trade/getOrder.ts index 35695500..a41c90e2 100644 --- a/src/modules/portfolio-margin/cm-trade/getOrder.ts +++ b/src/modules/portfolio-margin/cm-trade/getOrder.ts @@ -12,14 +12,16 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginCmGetOrder(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginCmGetOrder", - "Query a specific COIN-M Futures order in Portfolio Margin mode.", { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), - orderId: z.number().int().optional().describe("Order ID to query"), - origClientOrderId: z.string().optional().describe("Original client order ID to query"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Query a specific COIN-M Futures order in Portfolio Margin mode.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), + orderId: z.number().int().optional().describe("Order ID to query"), + origClientOrderId: z.string().optional().describe("Original client order ID to query"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/cm-trade/getUserTrades.ts b/src/modules/portfolio-margin/cm-trade/getUserTrades.ts index 1fd6c12a..f42e5ef6 100644 --- a/src/modules/portfolio-margin/cm-trade/getUserTrades.ts +++ b/src/modules/portfolio-margin/cm-trade/getUserTrades.ts @@ -12,23 +12,25 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginCmGetUserTrades(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginCmGetUserTrades", - "Get COIN-M Futures trade history in Portfolio Margin mode.", { - symbol: z.string().optional().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), - pair: z.string().optional().describe("Trading pair (e.g., 'BTCUSD')"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - fromId: z.number().int().optional().describe("Trade ID to start from"), - limit: z - .number() - .int() - .min(1) - .max(1000) - .optional() - .describe("Number of trades to return (default 500, max 1000)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Get COIN-M Futures trade history in Portfolio Margin mode.", + inputSchema: { + symbol: z.string().optional().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), + pair: z.string().optional().describe("Trading pair (e.g., 'BTCUSD')"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + fromId: z.number().int().optional().describe("Trade ID to start from"), + limit: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .describe("Number of trades to return (default 500, max 1000)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/cm-trade/newOrder.ts b/src/modules/portfolio-margin/cm-trade/newOrder.ts index f575a436..e0835fbb 100644 --- a/src/modules/portfolio-margin/cm-trade/newOrder.ts +++ b/src/modules/portfolio-margin/cm-trade/newOrder.ts @@ -12,34 +12,37 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginCmNewOrder(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginCmNewOrder", - "Place a new COIN-M Futures order in Portfolio Margin mode. ⚠️ HIGH RISK: Futures trading involves leverage.", { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), - side: z.enum(["BUY", "SELL"]).describe("Order side"), - type: z - .enum([ - "LIMIT", - "MARKET", - "STOP", - "STOP_MARKET", - "TAKE_PROFIT", - "TAKE_PROFIT_MARKET", - "TRAILING_STOP_MARKET", - ]) - .describe("Order type"), - quantity: z.string().optional().describe("Order quantity in contracts"), - price: z.string().optional().describe("Limit price (required for LIMIT orders)"), - stopPrice: z.string().optional().describe("Stop price (required for STOP orders)"), - timeInForce: z.enum(["GTC", "IOC", "FOK", "GTX"]).optional().describe("Time in force"), - reduceOnly: z.boolean().optional().describe("Reduce position only"), - newClientOrderId: z.string().optional().describe("Custom client order ID"), - positionSide: z - .enum(["BOTH", "LONG", "SHORT"]) - .optional() - .describe("Position side for hedge mode"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Place a new COIN-M Futures order in Portfolio Margin mode. ⚠️ HIGH RISK: Futures trading involves leverage.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSD_PERP')"), + side: z.enum(["BUY", "SELL"]).describe("Order side"), + type: z + .enum([ + "LIMIT", + "MARKET", + "STOP", + "STOP_MARKET", + "TAKE_PROFIT", + "TAKE_PROFIT_MARKET", + "TRAILING_STOP_MARKET", + ]) + .describe("Order type"), + quantity: z.string().optional().describe("Order quantity in contracts"), + price: z.string().optional().describe("Limit price (required for LIMIT orders)"), + stopPrice: z.string().optional().describe("Stop price (required for STOP orders)"), + timeInForce: z.enum(["GTC", "IOC", "FOK", "GTX"]).optional().describe("Time in force"), + reduceOnly: z.boolean().optional().describe("Reduce position only"), + newClientOrderId: z.string().optional().describe("Custom client order ID"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe("Position side for hedge mode"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/margin-trade/cancelAllOrders.ts b/src/modules/portfolio-margin/margin-trade/cancelAllOrders.ts index 5ac587c8..e6352c5c 100644 --- a/src/modules/portfolio-margin/margin-trade/cancelAllOrders.ts +++ b/src/modules/portfolio-margin/margin-trade/cancelAllOrders.ts @@ -12,12 +12,15 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginMarginCancelAllOrders(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginMarginCancelAllOrders", - "Cancel all open cross margin orders for a symbol in Portfolio Margin mode. ⚠️ This will cancel ALL open orders.", { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Cancel all open cross margin orders for a symbol in Portfolio Margin mode. ⚠️ This will cancel ALL open orders.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/margin-trade/cancelOrder.ts b/src/modules/portfolio-margin/margin-trade/cancelOrder.ts index 0f4bb11e..e2f67b37 100644 --- a/src/modules/portfolio-margin/margin-trade/cancelOrder.ts +++ b/src/modules/portfolio-margin/margin-trade/cancelOrder.ts @@ -12,14 +12,16 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginMarginCancelOrder(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginMarginCancelOrder", - "Cancel an active cross margin order in Portfolio Margin mode.", { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - orderId: z.number().int().optional().describe("Order ID to cancel"), - origClientOrderId: z.string().optional().describe("Original client order ID to cancel"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Cancel an active cross margin order in Portfolio Margin mode.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + orderId: z.number().int().optional().describe("Order ID to cancel"), + origClientOrderId: z.string().optional().describe("Original client order ID to cancel"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/margin-trade/getAllOrders.ts b/src/modules/portfolio-margin/margin-trade/getAllOrders.ts index 733d1495..f499669b 100644 --- a/src/modules/portfolio-margin/margin-trade/getAllOrders.ts +++ b/src/modules/portfolio-margin/margin-trade/getAllOrders.ts @@ -12,22 +12,25 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginMarginGetAllOrders(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginMarginGetAllOrders", - "Get all cross margin orders (active, cancelled, filled) in Portfolio Margin mode.", { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - orderId: z.number().int().optional().describe("Order ID to start from"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .min(1) - .max(500) - .optional() - .describe("Number of orders to return (default 500, max 500)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get all cross margin orders (active, cancelled, filled) in Portfolio Margin mode.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + orderId: z.number().int().optional().describe("Order ID to start from"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .min(1) + .max(500) + .optional() + .describe("Number of orders to return (default 500, max 500)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/margin-trade/getOpenOrders.ts b/src/modules/portfolio-margin/margin-trade/getOpenOrders.ts index 9f689513..c0054ddb 100644 --- a/src/modules/portfolio-margin/margin-trade/getOpenOrders.ts +++ b/src/modules/portfolio-margin/margin-trade/getOpenOrders.ts @@ -12,12 +12,14 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginMarginGetOpenOrders(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginMarginGetOpenOrders", - "Get all open cross margin orders in Portfolio Margin mode.", { - symbol: z.string().optional().describe("Trading pair symbol to filter by"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Get all open cross margin orders in Portfolio Margin mode.", + inputSchema: { + symbol: z.string().optional().describe("Trading pair symbol to filter by"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/margin-trade/getOrder.ts b/src/modules/portfolio-margin/margin-trade/getOrder.ts index 6b56ee43..33660a06 100644 --- a/src/modules/portfolio-margin/margin-trade/getOrder.ts +++ b/src/modules/portfolio-margin/margin-trade/getOrder.ts @@ -12,14 +12,16 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginMarginGetOrder(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginMarginGetOrder", - "Query a specific cross margin order in Portfolio Margin mode.", { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - orderId: z.number().int().optional().describe("Order ID to query"), - origClientOrderId: z.string().optional().describe("Original client order ID to query"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Query a specific cross margin order in Portfolio Margin mode.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + orderId: z.number().int().optional().describe("Order ID to query"), + origClientOrderId: z.string().optional().describe("Original client order ID to query"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/margin-trade/getUserTrades.ts b/src/modules/portfolio-margin/margin-trade/getUserTrades.ts index a666b15a..48b976ee 100644 --- a/src/modules/portfolio-margin/margin-trade/getUserTrades.ts +++ b/src/modules/portfolio-margin/margin-trade/getUserTrades.ts @@ -12,22 +12,24 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginMarginGetUserTrades(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginMarginGetUserTrades", - "Get cross margin trade history in Portfolio Margin mode.", { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - fromId: z.number().int().optional().describe("Trade ID to start from"), - limit: z - .number() - .int() - .min(1) - .max(1000) - .optional() - .describe("Number of trades to return (default 500, max 1000)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Get cross margin trade history in Portfolio Margin mode.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + fromId: z.number().int().optional().describe("Trade ID to start from"), + limit: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .describe("Number of trades to return (default 500, max 1000)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/margin-trade/marginLoan.ts b/src/modules/portfolio-margin/margin-trade/marginLoan.ts index 9c46c51d..e3d7f410 100644 --- a/src/modules/portfolio-margin/margin-trade/marginLoan.ts +++ b/src/modules/portfolio-margin/margin-trade/marginLoan.ts @@ -12,13 +12,16 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginMarginLoan(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginMarginLoan", - "Borrow funds for margin trading in Portfolio Margin mode. ⚠️ Borrowed funds accrue interest.", { - asset: z.string().describe("Asset to borrow (e.g., 'USDT')"), - amount: z.string().describe("Amount to borrow"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Borrow funds for margin trading in Portfolio Margin mode. ⚠️ Borrowed funds accrue interest.", + inputSchema: { + asset: z.string().describe("Asset to borrow (e.g., 'USDT')"), + amount: z.string().describe("Amount to borrow"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/margin-trade/marginRepay.ts b/src/modules/portfolio-margin/margin-trade/marginRepay.ts index 4ee1f2e9..102346ff 100644 --- a/src/modules/portfolio-margin/margin-trade/marginRepay.ts +++ b/src/modules/portfolio-margin/margin-trade/marginRepay.ts @@ -12,13 +12,15 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginMarginRepay(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginMarginRepay", - "Repay borrowed funds in Portfolio Margin mode.", { - asset: z.string().describe("Asset to repay (e.g., 'USDT')"), - amount: z.string().describe("Amount to repay"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Repay borrowed funds in Portfolio Margin mode.", + inputSchema: { + asset: z.string().describe("Asset to repay (e.g., 'USDT')"), + amount: z.string().describe("Amount to repay"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/margin-trade/newOrder.ts b/src/modules/portfolio-margin/margin-trade/newOrder.ts index 2d44fbe8..65ed229c 100644 --- a/src/modules/portfolio-margin/margin-trade/newOrder.ts +++ b/src/modules/portfolio-margin/margin-trade/newOrder.ts @@ -12,34 +12,37 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginMarginNewOrder(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginMarginNewOrder", - "Place a new cross margin order in Portfolio Margin mode. ⚠️ Margin trading involves borrowing and interest.", { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - side: z.enum(["BUY", "SELL"]).describe("Order side"), - type: z - .enum([ - "LIMIT", - "MARKET", - "STOP_LOSS", - "STOP_LOSS_LIMIT", - "TAKE_PROFIT", - "TAKE_PROFIT_LIMIT", - "LIMIT_MAKER", - ]) - .describe("Order type"), - quantity: z.string().optional().describe("Order quantity"), - quoteOrderQty: z.string().optional().describe("Quote quantity (for MARKET orders)"), - price: z.string().optional().describe("Limit price"), - stopPrice: z.string().optional().describe("Stop price"), - timeInForce: z.enum(["GTC", "IOC", "FOK"]).optional().describe("Time in force"), - newClientOrderId: z.string().optional().describe("Custom client order ID"), - sideEffectType: z - .enum(["NO_SIDE_EFFECT", "MARGIN_BUY", "AUTO_REPAY", "AUTO_BORROW_REPAY"]) - .optional() - .describe("Side effect type for margin orders"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Place a new cross margin order in Portfolio Margin mode. ⚠️ Margin trading involves borrowing and interest.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + side: z.enum(["BUY", "SELL"]).describe("Order side"), + type: z + .enum([ + "LIMIT", + "MARKET", + "STOP_LOSS", + "STOP_LOSS_LIMIT", + "TAKE_PROFIT", + "TAKE_PROFIT_LIMIT", + "LIMIT_MAKER", + ]) + .describe("Order type"), + quantity: z.string().optional().describe("Order quantity"), + quoteOrderQty: z.string().optional().describe("Quote quantity (for MARKET orders)"), + price: z.string().optional().describe("Limit price"), + stopPrice: z.string().optional().describe("Stop price"), + timeInForce: z.enum(["GTC", "IOC", "FOK"]).optional().describe("Time in force"), + newClientOrderId: z.string().optional().describe("Custom client order ID"), + sideEffectType: z + .enum(["NO_SIDE_EFFECT", "MARGIN_BUY", "AUTO_REPAY", "AUTO_BORROW_REPAY"]) + .optional() + .describe("Side effect type for margin orders"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/um-trade/cancelAllOrders.ts b/src/modules/portfolio-margin/um-trade/cancelAllOrders.ts index 999a9d82..63f3e420 100644 --- a/src/modules/portfolio-margin/um-trade/cancelAllOrders.ts +++ b/src/modules/portfolio-margin/um-trade/cancelAllOrders.ts @@ -12,12 +12,15 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginUmCancelAllOrders(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginUmCancelAllOrders", - "Cancel all open USDT-M Futures orders for a symbol in Portfolio Margin mode. ⚠️ This will cancel ALL open orders.", { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Cancel all open USDT-M Futures orders for a symbol in Portfolio Margin mode. ⚠️ This will cancel ALL open orders.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/um-trade/cancelOrder.ts b/src/modules/portfolio-margin/um-trade/cancelOrder.ts index dae64324..71443165 100644 --- a/src/modules/portfolio-margin/um-trade/cancelOrder.ts +++ b/src/modules/portfolio-margin/um-trade/cancelOrder.ts @@ -12,14 +12,16 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginUmCancelOrder(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginUmCancelOrder", - "Cancel an active USDT-M Futures order in Portfolio Margin mode.", { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - orderId: z.number().int().optional().describe("Order ID to cancel"), - origClientOrderId: z.string().optional().describe("Original client order ID to cancel"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Cancel an active USDT-M Futures order in Portfolio Margin mode.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + orderId: z.number().int().optional().describe("Order ID to cancel"), + origClientOrderId: z.string().optional().describe("Original client order ID to cancel"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/um-trade/changeLeverage.ts b/src/modules/portfolio-margin/um-trade/changeLeverage.ts index 4571e579..9d46ed31 100644 --- a/src/modules/portfolio-margin/um-trade/changeLeverage.ts +++ b/src/modules/portfolio-margin/um-trade/changeLeverage.ts @@ -12,13 +12,16 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginUmChangeLeverage(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginUmChangeLeverage", - "Change leverage for a USDT-M Futures symbol in Portfolio Margin mode. ⚠️ Higher leverage increases risk.", { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - leverage: z.number().int().min(1).max(125).describe("Target leverage (1-125)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Change leverage for a USDT-M Futures symbol in Portfolio Margin mode. ⚠️ Higher leverage increases risk.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + leverage: z.number().int().min(1).max(125).describe("Target leverage (1-125)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/um-trade/changeMarginType.ts b/src/modules/portfolio-margin/um-trade/changeMarginType.ts index f0ab1897..49a66e86 100644 --- a/src/modules/portfolio-margin/um-trade/changeMarginType.ts +++ b/src/modules/portfolio-margin/um-trade/changeMarginType.ts @@ -12,13 +12,16 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginUmChangeMarginType(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginUmChangeMarginType", - "Change margin type (ISOLATED/CROSSED) for a USDT-M Futures symbol in Portfolio Margin mode.", { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - marginType: z.enum(["ISOLATED", "CROSSED"]).describe("Margin type"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Change margin type (ISOLATED/CROSSED) for a USDT-M Futures symbol in Portfolio Margin mode.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + marginType: z.enum(["ISOLATED", "CROSSED"]).describe("Margin type"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/um-trade/getAllOrders.ts b/src/modules/portfolio-margin/um-trade/getAllOrders.ts index 001bc607..aac202cb 100644 --- a/src/modules/portfolio-margin/um-trade/getAllOrders.ts +++ b/src/modules/portfolio-margin/um-trade/getAllOrders.ts @@ -12,22 +12,25 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginUmGetAllOrders(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginUmGetAllOrders", - "Get all USDT-M Futures orders (active, cancelled, filled) in Portfolio Margin mode.", { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - orderId: z.number().int().optional().describe("Order ID to start from"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .min(1) - .max(1000) - .optional() - .describe("Number of orders to return (default 500, max 1000)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get all USDT-M Futures orders (active, cancelled, filled) in Portfolio Margin mode.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + orderId: z.number().int().optional().describe("Order ID to start from"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .describe("Number of orders to return (default 500, max 1000)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/um-trade/getOpenOrders.ts b/src/modules/portfolio-margin/um-trade/getOpenOrders.ts index d3aa19a1..edf6a51c 100644 --- a/src/modules/portfolio-margin/um-trade/getOpenOrders.ts +++ b/src/modules/portfolio-margin/um-trade/getOpenOrders.ts @@ -12,12 +12,14 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginUmGetOpenOrders(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginUmGetOpenOrders", - "Get all open USDT-M Futures orders in Portfolio Margin mode.", { - symbol: z.string().optional().describe("Trading pair symbol to filter by"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Get all open USDT-M Futures orders in Portfolio Margin mode.", + inputSchema: { + symbol: z.string().optional().describe("Trading pair symbol to filter by"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/um-trade/getOrder.ts b/src/modules/portfolio-margin/um-trade/getOrder.ts index 8da97df6..81a79298 100644 --- a/src/modules/portfolio-margin/um-trade/getOrder.ts +++ b/src/modules/portfolio-margin/um-trade/getOrder.ts @@ -12,14 +12,16 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginUmGetOrder(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginUmGetOrder", - "Query a specific USDT-M Futures order in Portfolio Margin mode.", { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - orderId: z.number().int().optional().describe("Order ID to query"), - origClientOrderId: z.string().optional().describe("Original client order ID to query"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Query a specific USDT-M Futures order in Portfolio Margin mode.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + orderId: z.number().int().optional().describe("Order ID to query"), + origClientOrderId: z.string().optional().describe("Original client order ID to query"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/um-trade/getUserTrades.ts b/src/modules/portfolio-margin/um-trade/getUserTrades.ts index ede71702..7a58e045 100644 --- a/src/modules/portfolio-margin/um-trade/getUserTrades.ts +++ b/src/modules/portfolio-margin/um-trade/getUserTrades.ts @@ -12,22 +12,24 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginUmGetUserTrades(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginUmGetUserTrades", - "Get USDT-M Futures trade history in Portfolio Margin mode.", { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - fromId: z.number().int().optional().describe("Trade ID to start from"), - limit: z - .number() - .int() - .min(1) - .max(1000) - .optional() - .describe("Number of trades to return (default 500, max 1000)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Get USDT-M Futures trade history in Portfolio Margin mode.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + fromId: z.number().int().optional().describe("Trade ID to start from"), + limit: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .describe("Number of trades to return (default 500, max 1000)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/um-trade/newOrder.ts b/src/modules/portfolio-margin/um-trade/newOrder.ts index 62a1eb0b..d7fc0d75 100644 --- a/src/modules/portfolio-margin/um-trade/newOrder.ts +++ b/src/modules/portfolio-margin/um-trade/newOrder.ts @@ -12,34 +12,37 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginUmNewOrder(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginUmNewOrder", - "Place a new USDT-M Futures order in Portfolio Margin mode. ⚠️ HIGH RISK: Futures trading involves leverage.", { - symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), - side: z.enum(["BUY", "SELL"]).describe("Order side"), - type: z - .enum([ - "LIMIT", - "MARKET", - "STOP", - "STOP_MARKET", - "TAKE_PROFIT", - "TAKE_PROFIT_MARKET", - "TRAILING_STOP_MARKET", - ]) - .describe("Order type"), - quantity: z.string().optional().describe("Order quantity"), - price: z.string().optional().describe("Limit price (required for LIMIT orders)"), - stopPrice: z.string().optional().describe("Stop price (required for STOP orders)"), - timeInForce: z.enum(["GTC", "IOC", "FOK", "GTX"]).optional().describe("Time in force"), - reduceOnly: z.boolean().optional().describe("Reduce position only"), - newClientOrderId: z.string().optional().describe("Custom client order ID"), - positionSide: z - .enum(["BOTH", "LONG", "SHORT"]) - .optional() - .describe("Position side for hedge mode"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Place a new USDT-M Futures order in Portfolio Margin mode. ⚠️ HIGH RISK: Futures trading involves leverage.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., 'BTCUSDT')"), + side: z.enum(["BUY", "SELL"]).describe("Order side"), + type: z + .enum([ + "LIMIT", + "MARKET", + "STOP", + "STOP_MARKET", + "TAKE_PROFIT", + "TAKE_PROFIT_MARKET", + "TRAILING_STOP_MARKET", + ]) + .describe("Order type"), + quantity: z.string().optional().describe("Order quantity"), + price: z.string().optional().describe("Limit price (required for LIMIT orders)"), + stopPrice: z.string().optional().describe("Stop price (required for STOP orders)"), + timeInForce: z.enum(["GTC", "IOC", "FOK", "GTX"]).optional().describe("Time in force"), + reduceOnly: z.boolean().optional().describe("Reduce position only"), + newClientOrderId: z.string().optional().describe("Custom client order ID"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe("Position side for hedge mode"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/userdata/createListenKey.ts b/src/modules/portfolio-margin/userdata/createListenKey.ts index 322fa887..1c42a930 100644 --- a/src/modules/portfolio-margin/userdata/createListenKey.ts +++ b/src/modules/portfolio-margin/userdata/createListenKey.ts @@ -10,10 +10,12 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginCreateListenKey(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginCreateListenKey", - "Create a listen key for Portfolio Margin user data stream. The listen key is used to subscribe to account updates via WebSocket.", - {}, + { + description: + "Create a listen key for Portfolio Margin user data stream. The listen key is used to subscribe to account updates via WebSocket.", + }, async () => { try { const response = await portfolioMarginClient.restAPI.createListenKey(); diff --git a/src/modules/portfolio-margin/userdata/deleteListenKey.ts b/src/modules/portfolio-margin/userdata/deleteListenKey.ts index 76f0324b..353026cb 100644 --- a/src/modules/portfolio-margin/userdata/deleteListenKey.ts +++ b/src/modules/portfolio-margin/userdata/deleteListenKey.ts @@ -12,11 +12,14 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginDeleteListenKey(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginDeleteListenKey", - "Close/delete a Portfolio Margin listen key. This will terminate the user data stream connection.", { - listenKey: z.string().optional().describe("Listen key to delete"), + description: + "Close/delete a Portfolio Margin listen key. This will terminate the user data stream connection.", + inputSchema: { + listenKey: z.string().optional().describe("Listen key to delete"), + }, }, async (params) => { try { diff --git a/src/modules/portfolio-margin/userdata/renewListenKey.ts b/src/modules/portfolio-margin/userdata/renewListenKey.ts index 69b4cb68..4c051b41 100644 --- a/src/modules/portfolio-margin/userdata/renewListenKey.ts +++ b/src/modules/portfolio-margin/userdata/renewListenKey.ts @@ -12,11 +12,13 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../../config/binanceClient.js"; export function registerPortfolioMarginRenewListenKey(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginRenewListenKey", - "Extend the validity of a Portfolio Margin listen key by 60 minutes.", { - listenKey: z.string().optional().describe("Listen key to renew"), + description: "Extend the validity of a Portfolio Margin listen key by 60 minutes.", + inputSchema: { + listenKey: z.string().optional().describe("Listen key to renew"), + }, }, async (params) => { try { diff --git a/src/modules/rebate/rebate-api/getSpotRebateHistoryRecords.ts b/src/modules/rebate/rebate-api/getSpotRebateHistoryRecords.ts index e0855594..cc36b657 100644 --- a/src/modules/rebate/rebate-api/getSpotRebateHistoryRecords.ts +++ b/src/modules/rebate/rebate-api/getSpotRebateHistoryRecords.ts @@ -6,14 +6,21 @@ import { z } from "zod"; import { rebateClient } from "../../../config/binanceClient.js"; export function registerBinanceGetSpotRebateHistoryRecords(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetSpotRebateHistoryRecords", - "Retrieve the history of spot rebate records, including commission rebates and referral kickbacks, for the past 7 days or a custom date range (within 30 days).", { - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - page: z.number().int().default(1).describe("Page number, default is 1"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Retrieve the history of spot rebate records, including commission rebates and referral kickbacks, for the past 7 days or a custom date range (within 30 days).", + inputSchema: { + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + page: z.number().int().default(1).describe("Page number, default is 1"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/simple-earn/account-api/getFlexibleProductPosition.ts b/src/modules/simple-earn/account-api/getFlexibleProductPosition.ts index 3b657330..6be31cea 100644 --- a/src/modules/simple-earn/account-api/getFlexibleProductPosition.ts +++ b/src/modules/simple-earn/account-api/getFlexibleProductPosition.ts @@ -6,28 +6,31 @@ import { z } from "zod"; import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerBinanceGetFlexibleProductPosition(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetFlexibleProductPosition", - "Fetch your current holdings in Simple Earn Flexible Products, including total amount, reward rates, and redeem status.", { - asset: z.string().optional().describe("Asset symbol (optional)"), - productId: z.string().optional().describe("Product ID (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying the page. Starts from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Page size. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Fetch your current holdings in Simple Earn Flexible Products, including total amount, reward rates, and redeem status.", + inputSchema: { + asset: z.string().optional().describe("Asset symbol (optional)"), + productId: z.string().optional().describe("Product ID (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying the page. Starts from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Page size. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/simple-earn/account-api/simpleEarnFlexibleProductList.ts b/src/modules/simple-earn/account-api/simpleEarnFlexibleProductList.ts index 0ad34c15..0219d0d1 100644 --- a/src/modules/simple-earn/account-api/simpleEarnFlexibleProductList.ts +++ b/src/modules/simple-earn/account-api/simpleEarnFlexibleProductList.ts @@ -6,27 +6,30 @@ import { z } from "zod"; import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerBinanceSimpleEarnFlexibleProductList(server: McpServer) { - server.tool( + server.registerTool( "BinanceSimpleEarnFlexibleProductList", - "Retrieve a list of available Simple Earn Flexible Products, including details like APR, purchase status, and subscription limits.", { - asset: z.string().optional().describe("Asset symbol (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Starts from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Page size. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Retrieve a list of available Simple Earn Flexible Products, including details like APR, purchase status, and subscription limits.", + inputSchema: { + asset: z.string().optional().describe("Asset symbol (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Starts from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Page size. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/simple-earn/account/getAccount.ts b/src/modules/simple-earn/account/getAccount.ts index 68f3c7c1..a3e0d930 100644 --- a/src/modules/simple-earn/account/getAccount.ts +++ b/src/modules/simple-earn/account/getAccount.ts @@ -12,11 +12,14 @@ import { z } from "zod"; import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnAccount(server: McpServer) { - server.tool( + server.registerTool( "BinanceSimpleEarnAccount", - "Get your Simple Earn account overview. Shows total amounts in flexible and locked products, and pending rewards.", { - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get your Simple Earn account overview. Shows total amounts in flexible and locked products, and pending rewards.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/simple-earn/account/getCollateralRecord.ts b/src/modules/simple-earn/account/getCollateralRecord.ts index 8f935693..f1dad3b3 100644 --- a/src/modules/simple-earn/account/getCollateralRecord.ts +++ b/src/modules/simple-earn/account/getCollateralRecord.ts @@ -12,17 +12,19 @@ import { z } from "zod"; import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnCollateralRecord(server: McpServer) { - server.tool( + server.registerTool( "BinanceSimpleEarnCollateralRecord", - "Get your collateral record history for flexible products used as collateral.", { - productId: z.string().optional().describe("Filter by product ID"), - asset: z.string().optional().describe("Filter by asset"), - startTime: z.number().int().optional().describe("Start time in ms"), - endTime: z.number().int().optional().describe("End time in ms"), - current: z.number().int().min(1).default(1).optional().describe("Page number"), - size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Get your collateral record history for flexible products used as collateral.", + inputSchema: { + productId: z.string().optional().describe("Filter by product ID"), + asset: z.string().optional().describe("Filter by asset"), + startTime: z.number().int().optional().describe("Start time in ms"), + endTime: z.number().int().optional().describe("End time in ms"), + current: z.number().int().min(1).default(1).optional().describe("Page number"), + size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/simple-earn/account/getRewardRecord.ts b/src/modules/simple-earn/account/getRewardRecord.ts index 5f334819..4687924d 100644 --- a/src/modules/simple-earn/account/getRewardRecord.ts +++ b/src/modules/simple-earn/account/getRewardRecord.ts @@ -12,18 +12,21 @@ import { z } from "zod"; import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnRewardRecord(server: McpServer) { - server.tool( + server.registerTool( "BinanceSimpleEarnRewardRecord", - "Get your reward distribution history. Shows all rewards earned from Simple Earn products.", { - productId: z.string().optional().describe("Filter by product ID"), - asset: z.string().optional().describe("Filter by asset"), - type: z.enum(["BONUS", "REALTIME", "REWARDS"]).optional().describe("Filter by reward type"), - startTime: z.number().int().optional().describe("Start time in ms"), - endTime: z.number().int().optional().describe("End time in ms"), - current: z.number().int().min(1).default(1).optional().describe("Page number"), - size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get your reward distribution history. Shows all rewards earned from Simple Earn products.", + inputSchema: { + productId: z.string().optional().describe("Filter by product ID"), + asset: z.string().optional().describe("Filter by asset"), + type: z.enum(["BONUS", "REALTIME", "REWARDS"]).optional().describe("Filter by reward type"), + startTime: z.number().int().optional().describe("Start time in ms"), + endTime: z.number().int().optional().describe("End time in ms"), + current: z.number().int().min(1).default(1).optional().describe("Page number"), + size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/simple-earn/earn-api/redeemFlexibleProduct.ts b/src/modules/simple-earn/earn-api/redeemFlexibleProduct.ts index 0ffd3e25..d8029896 100644 --- a/src/modules/simple-earn/earn-api/redeemFlexibleProduct.ts +++ b/src/modules/simple-earn/earn-api/redeemFlexibleProduct.ts @@ -6,22 +6,25 @@ import { z } from "zod"; import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerBinanceRedeemFlexibleProduct(server: McpServer) { - server.tool( + server.registerTool( "BinanceRedeemFlexibleProduct", - "Allows users to redeem their funds from a Flexible Earn investment product using a programmatic HTTP POST request.", { - productId: z.string().describe("Product ID"), - redeemAll: z.boolean().optional().describe("true or false, default to false"), - amount: z - .number() - .positive() - .optional() - .describe("If redeemAll is false, amount is mandatory"), - destAccount: z - .enum(["SPOT", "FUND"]) - .optional() - .describe("Destination account: SPOT or FUND; default is SPOT"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Allows users to redeem their funds from a Flexible Earn investment product using a programmatic HTTP POST request.", + inputSchema: { + productId: z.string().describe("Product ID"), + redeemAll: z.boolean().optional().describe("true or false, default to false"), + amount: z + .number() + .positive() + .optional() + .describe("If redeemAll is false, amount is mandatory"), + destAccount: z + .enum(["SPOT", "FUND"]) + .optional() + .describe("Destination account: SPOT or FUND; default is SPOT"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/simple-earn/earn-api/subscribeFlexibleProduct.ts b/src/modules/simple-earn/earn-api/subscribeFlexibleProduct.ts index 7d269ed4..08742103 100644 --- a/src/modules/simple-earn/earn-api/subscribeFlexibleProduct.ts +++ b/src/modules/simple-earn/earn-api/subscribeFlexibleProduct.ts @@ -6,18 +6,21 @@ import { z } from "zod"; import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerBinanceSubscribeFlexibleProduct(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubscribeFlexibleProduct", - "Subscribe to a Simple Earn Flexible Product by specifying the product ID and amount. Optional parameters include auto-subscribe and source account. ", { - productId: z.string().describe("Product ID"), - amount: z.number().positive().describe("Amount to purchase"), - autoSubscribe: z.boolean().optional().describe("true or false, default is true"), - sourceAccount: z - .enum(["SPOT", "FUND", "ALL"]) - .optional() - .describe("Source account: SPOT, FUND, or ALL; default is SPOT"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Subscribe to a Simple Earn Flexible Product by specifying the product ID and amount. Optional parameters include auto-subscribe and source account. ", + inputSchema: { + productId: z.string().describe("Product ID"), + amount: z.number().positive().describe("Amount to purchase"), + autoSubscribe: z.boolean().optional().describe("true or false, default is true"), + sourceAccount: z + .enum(["SPOT", "FUND", "ALL"]) + .optional() + .describe("Source account: SPOT, FUND, or ALL; default is SPOT"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/simple-earn/flexible/getFlexiblePosition.ts b/src/modules/simple-earn/flexible/getFlexiblePosition.ts index a8a7f377..a9705655 100644 --- a/src/modules/simple-earn/flexible/getFlexiblePosition.ts +++ b/src/modules/simple-earn/flexible/getFlexiblePosition.ts @@ -12,15 +12,18 @@ import { z } from "zod"; import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnFlexiblePosition(server: McpServer) { - server.tool( + server.registerTool( "BinanceSimpleEarnFlexiblePosition", - "Get your current Simple Earn Flexible positions. Shows subscribed amount, cumulative rewards, and APR for each product.", { - asset: z.string().optional().describe("Filter by asset symbol"), - productId: z.string().optional().describe("Filter by product ID"), - current: z.number().int().min(1).default(1).optional().describe("Page number"), - size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get your current Simple Earn Flexible positions. Shows subscribed amount, cumulative rewards, and APR for each product.", + inputSchema: { + asset: z.string().optional().describe("Filter by asset symbol"), + productId: z.string().optional().describe("Filter by product ID"), + current: z.number().int().min(1).default(1).optional().describe("Page number"), + size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/simple-earn/flexible/getFlexibleProductList.ts b/src/modules/simple-earn/flexible/getFlexibleProductList.ts index fa33b856..f9287999 100644 --- a/src/modules/simple-earn/flexible/getFlexibleProductList.ts +++ b/src/modules/simple-earn/flexible/getFlexibleProductList.ts @@ -12,20 +12,23 @@ import { z } from "zod"; import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnFlexibleProductList(server: McpServer) { - server.tool( + server.registerTool( "BinanceSimpleEarnFlexibleProductList", - "Get available Simple Earn Flexible products. Returns product details including APR, minimum purchase amount, and availability status.", { - asset: z.string().optional().describe("Filter by asset symbol (e.g., 'BTC', 'ETH')"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Page number, starting from 1"), - size: z.number().int().min(1).max(100).default(10).optional().describe("Page size (1-100)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get available Simple Earn Flexible products. Returns product details including APR, minimum purchase amount, and availability status.", + inputSchema: { + asset: z.string().optional().describe("Filter by asset symbol (e.g., 'BTC', 'ETH')"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Page number, starting from 1"), + size: z.number().int().min(1).max(100).default(10).optional().describe("Page size (1-100)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/simple-earn/flexible/getFlexibleSubscriptionPreview.ts b/src/modules/simple-earn/flexible/getFlexibleSubscriptionPreview.ts index 52870c41..9cd9f46c 100644 --- a/src/modules/simple-earn/flexible/getFlexibleSubscriptionPreview.ts +++ b/src/modules/simple-earn/flexible/getFlexibleSubscriptionPreview.ts @@ -12,13 +12,16 @@ import { z } from "zod"; import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnFlexibleSubscriptionPreview(server: McpServer) { - server.tool( + server.registerTool( "BinanceSimpleEarnFlexibleSubscriptionPreview", - "Preview a flexible product subscription before committing. Shows expected rewards and next interest date.", { - productId: z.string().describe("Product ID to preview"), - amount: z.number().positive().describe("Amount to preview subscription for"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Preview a flexible product subscription before committing. Shows expected rewards and next interest date.", + inputSchema: { + productId: z.string().describe("Product ID to preview"), + amount: z.number().positive().describe("Amount to preview subscription for"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/simple-earn/flexible/getRateHistory.ts b/src/modules/simple-earn/flexible/getRateHistory.ts index 2417d689..db0313bb 100644 --- a/src/modules/simple-earn/flexible/getRateHistory.ts +++ b/src/modules/simple-earn/flexible/getRateHistory.ts @@ -12,16 +12,19 @@ import { z } from "zod"; import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnFlexibleRateHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceSimpleEarnFlexibleRateHistory", - "Get historical APR rates for a flexible product. Useful for analyzing rate trends and making informed investment decisions.", { - productId: z.string().describe("Product ID to get rate history for"), - startTime: z.number().int().optional().describe("Start time in ms"), - endTime: z.number().int().optional().describe("End time in ms"), - current: z.number().int().min(1).default(1).optional().describe("Page number"), - size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get historical APR rates for a flexible product. Useful for analyzing rate trends and making informed investment decisions.", + inputSchema: { + productId: z.string().describe("Product ID to get rate history for"), + startTime: z.number().int().optional().describe("Start time in ms"), + endTime: z.number().int().optional().describe("End time in ms"), + current: z.number().int().min(1).default(1).optional().describe("Page number"), + size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/simple-earn/flexible/getRedemptionRecord.ts b/src/modules/simple-earn/flexible/getRedemptionRecord.ts index 17af75ef..fc84d459 100644 --- a/src/modules/simple-earn/flexible/getRedemptionRecord.ts +++ b/src/modules/simple-earn/flexible/getRedemptionRecord.ts @@ -12,18 +12,21 @@ import { z } from "zod"; import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnFlexibleRedemptionRecord(server: McpServer) { - server.tool( + server.registerTool( "BinanceSimpleEarnFlexibleRedemptionRecord", - "Get your flexible product redemption history. Shows all past redemptions with amounts, dates, and status.", { - productId: z.string().optional().describe("Filter by product ID"), - redeemId: z.string().optional().describe("Filter by redemption ID"), - asset: z.string().optional().describe("Filter by asset"), - startTime: z.number().int().optional().describe("Start time in ms"), - endTime: z.number().int().optional().describe("End time in ms"), - current: z.number().int().min(1).default(1).optional().describe("Page number"), - size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get your flexible product redemption history. Shows all past redemptions with amounts, dates, and status.", + inputSchema: { + productId: z.string().optional().describe("Filter by product ID"), + redeemId: z.string().optional().describe("Filter by redemption ID"), + asset: z.string().optional().describe("Filter by asset"), + startTime: z.number().int().optional().describe("Start time in ms"), + endTime: z.number().int().optional().describe("End time in ms"), + current: z.number().int().min(1).default(1).optional().describe("Page number"), + size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/simple-earn/flexible/getSubscriptionRecord.ts b/src/modules/simple-earn/flexible/getSubscriptionRecord.ts index c4fd3460..b5223cd6 100644 --- a/src/modules/simple-earn/flexible/getSubscriptionRecord.ts +++ b/src/modules/simple-earn/flexible/getSubscriptionRecord.ts @@ -12,18 +12,21 @@ import { z } from "zod"; import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnFlexibleSubscriptionRecord(server: McpServer) { - server.tool( + server.registerTool( "BinanceSimpleEarnFlexibleSubscriptionRecord", - "Get your flexible product subscription history. Shows all past subscriptions with amounts, dates, and status.", { - productId: z.string().optional().describe("Filter by product ID"), - purchaseId: z.string().optional().describe("Filter by purchase ID"), - asset: z.string().optional().describe("Filter by asset"), - startTime: z.number().int().optional().describe("Start time in ms"), - endTime: z.number().int().optional().describe("End time in ms"), - current: z.number().int().min(1).default(1).optional().describe("Page number"), - size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get your flexible product subscription history. Shows all past subscriptions with amounts, dates, and status.", + inputSchema: { + productId: z.string().optional().describe("Filter by product ID"), + purchaseId: z.string().optional().describe("Filter by purchase ID"), + asset: z.string().optional().describe("Filter by asset"), + startTime: z.number().int().optional().describe("Start time in ms"), + endTime: z.number().int().optional().describe("End time in ms"), + current: z.number().int().min(1).default(1).optional().describe("Page number"), + size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/simple-earn/flexible/redeemFlexible.ts b/src/modules/simple-earn/flexible/redeemFlexible.ts index 01015463..8411aac5 100644 --- a/src/modules/simple-earn/flexible/redeemFlexible.ts +++ b/src/modules/simple-earn/flexible/redeemFlexible.ts @@ -12,22 +12,25 @@ import { z } from "zod"; import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnRedeemFlexible(server: McpServer) { - server.tool( + server.registerTool( "BinanceSimpleEarnFlexibleRedeem", - "Redeem from a Simple Earn Flexible product. Funds are returned to your spot wallet. 💸 Instant redemption available!", { - productId: z.string().describe("Product ID to redeem from"), - redeemAll: z.boolean().optional().describe("Redeem all position (true/false)"), - amount: z - .number() - .positive() - .optional() - .describe("Amount to redeem (required if redeemAll is false)"), - destAccount: z - .enum(["SPOT", "FUND"]) - .optional() - .describe("Destination account (default: SPOT)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Redeem from a Simple Earn Flexible product. Funds are returned to your spot wallet. 💸 Instant redemption available!", + inputSchema: { + productId: z.string().describe("Product ID to redeem from"), + redeemAll: z.boolean().optional().describe("Redeem all position (true/false)"), + amount: z + .number() + .positive() + .optional() + .describe("Amount to redeem (required if redeemAll is false)"), + destAccount: z + .enum(["SPOT", "FUND"]) + .optional() + .describe("Destination account (default: SPOT)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/simple-earn/flexible/subscribeFlexible.ts b/src/modules/simple-earn/flexible/subscribeFlexible.ts index 4ccc384a..ce6b7b85 100644 --- a/src/modules/simple-earn/flexible/subscribeFlexible.ts +++ b/src/modules/simple-earn/flexible/subscribeFlexible.ts @@ -12,21 +12,24 @@ import { z } from "zod"; import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnSubscribeFlexible(server: McpServer) { - server.tool( + server.registerTool( "BinanceSimpleEarnFlexibleSubscribe", - "Subscribe to a Simple Earn Flexible product to earn daily rewards. Funds can be redeemed anytime. 💰 Start earning passive income on your crypto!", { - productId: z.string().describe("Product ID from flexible product list"), - amount: z.number().positive().describe("Amount to subscribe"), - autoSubscribe: z - .boolean() - .optional() - .describe("Auto-subscribe on redemption (default: true)"), - sourceAccount: z - .enum(["SPOT", "FUND", "ALL"]) - .optional() - .describe("Source account for funds (default: SPOT)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Subscribe to a Simple Earn Flexible product to earn daily rewards. Funds can be redeemed anytime. 💰 Start earning passive income on your crypto!", + inputSchema: { + productId: z.string().describe("Product ID from flexible product list"), + amount: z.number().positive().describe("Amount to subscribe"), + autoSubscribe: z + .boolean() + .optional() + .describe("Auto-subscribe on redemption (default: true)"), + sourceAccount: z + .enum(["SPOT", "FUND", "ALL"]) + .optional() + .describe("Source account for funds (default: SPOT)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/simple-earn/locked/getLockedPersonalQuota.ts b/src/modules/simple-earn/locked/getLockedPersonalQuota.ts index 5a94f6d9..fccc619c 100644 --- a/src/modules/simple-earn/locked/getLockedPersonalQuota.ts +++ b/src/modules/simple-earn/locked/getLockedPersonalQuota.ts @@ -12,12 +12,15 @@ import { z } from "zod"; import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnLockedPersonalQuota(server: McpServer) { - server.tool( + server.registerTool( "BinanceSimpleEarnLockedPersonalQuota", - "Get your personal subscription quota for a locked product. Shows remaining quota available to subscribe.", { - projectId: z.string().describe("Project ID to check quota for"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get your personal subscription quota for a locked product. Shows remaining quota available to subscribe.", + inputSchema: { + projectId: z.string().describe("Project ID to check quota for"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/simple-earn/locked/getLockedPosition.ts b/src/modules/simple-earn/locked/getLockedPosition.ts index d7ae6a68..b85672ad 100644 --- a/src/modules/simple-earn/locked/getLockedPosition.ts +++ b/src/modules/simple-earn/locked/getLockedPosition.ts @@ -12,16 +12,19 @@ import { z } from "zod"; import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnLockedPosition(server: McpServer) { - server.tool( + server.registerTool( "BinanceSimpleEarnLockedPosition", - "Get your current Simple Earn Locked positions. Shows locked amount, rewards, maturity date, and APR.", { - asset: z.string().optional().describe("Filter by asset symbol"), - positionId: z.string().optional().describe("Filter by position ID"), - projectId: z.string().optional().describe("Filter by project ID"), - current: z.number().int().min(1).default(1).optional().describe("Page number"), - size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get your current Simple Earn Locked positions. Shows locked amount, rewards, maturity date, and APR.", + inputSchema: { + asset: z.string().optional().describe("Filter by asset symbol"), + positionId: z.string().optional().describe("Filter by position ID"), + projectId: z.string().optional().describe("Filter by project ID"), + current: z.number().int().min(1).default(1).optional().describe("Page number"), + size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/simple-earn/locked/getLockedProductList.ts b/src/modules/simple-earn/locked/getLockedProductList.ts index 3df600b1..b2d28631 100644 --- a/src/modules/simple-earn/locked/getLockedProductList.ts +++ b/src/modules/simple-earn/locked/getLockedProductList.ts @@ -12,20 +12,23 @@ import { z } from "zod"; import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnLockedProductList(server: McpServer) { - server.tool( + server.registerTool( "BinanceSimpleEarnLockedProductList", - "Get available Simple Earn Locked products. Locked products offer higher APR in exchange for locking funds for a fixed duration.", { - asset: z.string().optional().describe("Filter by asset symbol (e.g., 'BTC', 'ETH')"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Page number, starting from 1"), - size: z.number().int().min(1).max(100).default(10).optional().describe("Page size (1-100)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get available Simple Earn Locked products. Locked products offer higher APR in exchange for locking funds for a fixed duration.", + inputSchema: { + asset: z.string().optional().describe("Filter by asset symbol (e.g., 'BTC', 'ETH')"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Page number, starting from 1"), + size: z.number().int().min(1).max(100).default(10).optional().describe("Page size (1-100)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/simple-earn/locked/getLockedSubscriptionPreview.ts b/src/modules/simple-earn/locked/getLockedSubscriptionPreview.ts index d609758a..c279f4d3 100644 --- a/src/modules/simple-earn/locked/getLockedSubscriptionPreview.ts +++ b/src/modules/simple-earn/locked/getLockedSubscriptionPreview.ts @@ -12,14 +12,17 @@ import { z } from "zod"; import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnLockedSubscriptionPreview(server: McpServer) { - server.tool( + server.registerTool( "BinanceSimpleEarnLockedSubscriptionPreview", - "Preview a locked product subscription before committing. Shows expected rewards, lock duration, and maturity date.", { - projectId: z.string().describe("Project ID to preview"), - amount: z.number().positive().describe("Amount to preview subscription for"), - autoSubscribe: z.boolean().optional().describe("Include auto-subscribe in preview"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Preview a locked product subscription before committing. Shows expected rewards, lock duration, and maturity date.", + inputSchema: { + projectId: z.string().describe("Project ID to preview"), + amount: z.number().positive().describe("Amount to preview subscription for"), + autoSubscribe: z.boolean().optional().describe("Include auto-subscribe in preview"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/simple-earn/locked/getRedemptionRecord.ts b/src/modules/simple-earn/locked/getRedemptionRecord.ts index bd6c6152..11755a40 100644 --- a/src/modules/simple-earn/locked/getRedemptionRecord.ts +++ b/src/modules/simple-earn/locked/getRedemptionRecord.ts @@ -12,18 +12,21 @@ import { z } from "zod"; import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnLockedRedemptionRecord(server: McpServer) { - server.tool( + server.registerTool( "BinanceSimpleEarnLockedRedemptionRecord", - "Get your locked product redemption history. Shows all redemptions including early redemptions and matured positions.", { - positionId: z.string().optional().describe("Filter by position ID"), - redeemId: z.string().optional().describe("Filter by redemption ID"), - asset: z.string().optional().describe("Filter by asset"), - startTime: z.number().int().optional().describe("Start time in ms"), - endTime: z.number().int().optional().describe("End time in ms"), - current: z.number().int().min(1).default(1).optional().describe("Page number"), - size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get your locked product redemption history. Shows all redemptions including early redemptions and matured positions.", + inputSchema: { + positionId: z.string().optional().describe("Filter by position ID"), + redeemId: z.string().optional().describe("Filter by redemption ID"), + asset: z.string().optional().describe("Filter by asset"), + startTime: z.number().int().optional().describe("Start time in ms"), + endTime: z.number().int().optional().describe("End time in ms"), + current: z.number().int().min(1).default(1).optional().describe("Page number"), + size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/simple-earn/locked/getSubscriptionRecord.ts b/src/modules/simple-earn/locked/getSubscriptionRecord.ts index e968deae..19dcf949 100644 --- a/src/modules/simple-earn/locked/getSubscriptionRecord.ts +++ b/src/modules/simple-earn/locked/getSubscriptionRecord.ts @@ -12,17 +12,20 @@ import { z } from "zod"; import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnLockedSubscriptionRecord(server: McpServer) { - server.tool( + server.registerTool( "BinanceSimpleEarnLockedSubscriptionRecord", - "Get your locked product subscription history. Shows all past subscriptions with amounts, dates, and status.", { - purchaseId: z.string().optional().describe("Filter by purchase ID"), - asset: z.string().optional().describe("Filter by asset"), - startTime: z.number().int().optional().describe("Start time in ms"), - endTime: z.number().int().optional().describe("End time in ms"), - current: z.number().int().min(1).default(1).optional().describe("Page number"), - size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get your locked product subscription history. Shows all past subscriptions with amounts, dates, and status.", + inputSchema: { + purchaseId: z.string().optional().describe("Filter by purchase ID"), + asset: z.string().optional().describe("Filter by asset"), + startTime: z.number().int().optional().describe("Start time in ms"), + endTime: z.number().int().optional().describe("End time in ms"), + current: z.number().int().min(1).default(1).optional().describe("Page number"), + size: z.number().int().min(1).max(100).default(10).optional().describe("Page size"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/simple-earn/locked/redeemLocked.ts b/src/modules/simple-earn/locked/redeemLocked.ts index c043cfd8..141e403c 100644 --- a/src/modules/simple-earn/locked/redeemLocked.ts +++ b/src/modules/simple-earn/locked/redeemLocked.ts @@ -12,12 +12,15 @@ import { z } from "zod"; import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnRedeemLocked(server: McpServer) { - server.tool( + server.registerTool( "BinanceSimpleEarnLockedRedeem", - "Redeem from a Simple Earn Locked product. ⚠️ Early redemption may forfeit rewards. Check product terms first.", { - positionId: z.string().describe("Position ID to redeem"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Redeem from a Simple Earn Locked product. ⚠️ Early redemption may forfeit rewards. Check product terms first.", + inputSchema: { + positionId: z.string().describe("Position ID to redeem"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/simple-earn/locked/setAutoSubscribe.ts b/src/modules/simple-earn/locked/setAutoSubscribe.ts index f19acc06..fdac0fe7 100644 --- a/src/modules/simple-earn/locked/setAutoSubscribe.ts +++ b/src/modules/simple-earn/locked/setAutoSubscribe.ts @@ -12,13 +12,16 @@ import { z } from "zod"; import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnSetAutoSubscribe(server: McpServer) { - server.tool( + server.registerTool( "BinanceSimpleEarnLockedSetAutoSubscribe", - "Enable or disable auto-subscribe for a locked position. When enabled, funds automatically re-subscribe when the lock period ends.", { - positionId: z.string().describe("Position ID to update"), - autoSubscribe: z.boolean().describe("Enable (true) or disable (false) auto-subscribe"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Enable or disable auto-subscribe for a locked position. When enabled, funds automatically re-subscribe when the lock period ends.", + inputSchema: { + positionId: z.string().describe("Position ID to update"), + autoSubscribe: z.boolean().describe("Enable (true) or disable (false) auto-subscribe"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/simple-earn/locked/subscribeLocked.ts b/src/modules/simple-earn/locked/subscribeLocked.ts index 971c2709..4e3f0048 100644 --- a/src/modules/simple-earn/locked/subscribeLocked.ts +++ b/src/modules/simple-earn/locked/subscribeLocked.ts @@ -12,18 +12,21 @@ import { z } from "zod"; import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerSimpleEarnSubscribeLocked(server: McpServer) { - server.tool( + server.registerTool( "BinanceSimpleEarnLockedSubscribe", - "Subscribe to a Simple Earn Locked product. ⚠️ Funds will be locked for the specified duration. Higher APR than flexible products!", { - projectId: z.string().describe("Locked product project ID"), - amount: z.number().positive().describe("Amount to subscribe"), - autoSubscribe: z.boolean().optional().describe("Auto-resubscribe when position matures"), - sourceAccount: z - .enum(["SPOT", "FUND", "ALL"]) - .optional() - .describe("Source account for funds (default: SPOT)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Subscribe to a Simple Earn Locked product. ⚠️ Funds will be locked for the specified duration. Higher APR than flexible products!", + inputSchema: { + projectId: z.string().describe("Locked product project ID"), + amount: z.number().positive().describe("Amount to subscribe"), + autoSubscribe: z.boolean().optional().describe("Auto-resubscribe when position matures"), + sourceAccount: z + .enum(["SPOT", "FUND", "ALL"]) + .optional() + .describe("Source account for funds (default: SPOT)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/modules/spot/account-api/accountCommission.ts b/src/modules/spot/account-api/accountCommission.ts index b0603a78..b176b579 100644 --- a/src/modules/spot/account-api/accountCommission.ts +++ b/src/modules/spot/account-api/accountCommission.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceAccountCommission(server: McpServer) { - server.tool( + server.registerTool( "BinanceAccountCommission", - "Get account commission rates for a specific symbol.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get account commission rates for a specific symbol.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ symbol, recvWindow }) => { try { diff --git a/src/modules/spot/account-api/getAccount.ts b/src/modules/spot/account-api/getAccount.ts index 0549a33f..40b9ab14 100644 --- a/src/modules/spot/account-api/getAccount.ts +++ b/src/modules/spot/account-api/getAccount.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceGetAccount(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetAccount", - "Get current account information.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get current account information.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/modules/spot/account-api/myAllocations.ts b/src/modules/spot/account-api/myAllocations.ts index 2d1668a3..a000150c 100644 --- a/src/modules/spot/account-api/myAllocations.ts +++ b/src/modules/spot/account-api/myAllocations.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceMyAllocations(server: McpServer) { - server.tool( + server.registerTool( "BinanceMyAllocations", - "Get SOR allocations for Self-Trade Prevention.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - allocationId: z.number().optional().describe("Allocation ID"), - orderId: z.number().optional().describe("Order ID"), - fromAllocationId: z.number().optional().describe("Allocation ID to fetch from"), - limit: z.number().optional().describe("Default 500; max 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get SOR allocations for Self-Trade Prevention.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + allocationId: z.number().optional().describe("Allocation ID"), + orderId: z.number().optional().describe("Order ID"), + fromAllocationId: z.number().optional().describe("Allocation ID to fetch from"), + limit: z.number().optional().describe("Default 500; max 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ symbol, allocationId, orderId, fromAllocationId, limit, recvWindow }) => { try { diff --git a/src/modules/spot/account-api/myPreventedMatches.ts b/src/modules/spot/account-api/myPreventedMatches.ts index 0181e33e..cff226cb 100644 --- a/src/modules/spot/account-api/myPreventedMatches.ts +++ b/src/modules/spot/account-api/myPreventedMatches.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceMyPreventedMatches(server: McpServer) { - server.tool( + server.registerTool( "BinanceMyPreventedMatches", - "Get prevented matches for Self-Trade Prevention.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - preventedMatchId: z.number().optional().describe("Prevented match ID"), - orderId: z.number().optional().describe("Order ID"), - fromPreventedMatchId: z.number().optional().describe("Prevented match ID to fetch from"), - limit: z.number().optional().describe("Default 500; max 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get prevented matches for Self-Trade Prevention.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + preventedMatchId: z.number().optional().describe("Prevented match ID"), + orderId: z.number().optional().describe("Order ID"), + fromPreventedMatchId: z.number().optional().describe("Prevented match ID to fetch from"), + limit: z.number().optional().describe("Default 500; max 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ symbol, preventedMatchId, orderId, fromPreventedMatchId, limit, recvWindow }) => { try { diff --git a/src/modules/spot/account-api/myTrades.ts b/src/modules/spot/account-api/myTrades.ts index 81e110b9..c7576641 100644 --- a/src/modules/spot/account-api/myTrades.ts +++ b/src/modules/spot/account-api/myTrades.ts @@ -6,17 +6,19 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceMyTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceMyTrades", - "Get trades for a specific account and symbol.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - orderId: z.number().optional().describe("Order ID"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - fromId: z.number().optional().describe("Trade ID to fetch from"), - limit: z.number().optional().describe("Default 500; max 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get trades for a specific account and symbol.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + orderId: z.number().optional().describe("Order ID"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + fromId: z.number().optional().describe("Trade ID to fetch from"), + limit: z.number().optional().describe("Default 500; max 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ symbol, orderId, startTime, endTime, fromId, limit, recvWindow }) => { try { diff --git a/src/modules/spot/account-api/rateLimitOrder.ts b/src/modules/spot/account-api/rateLimitOrder.ts index 83fe3be2..a8956267 100644 --- a/src/modules/spot/account-api/rateLimitOrder.ts +++ b/src/modules/spot/account-api/rateLimitOrder.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceRateLimitOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceRateLimitOrder", - "Get current order count usage for each rate limit.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get current order count usage for each rate limit.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/modules/spot/general-api/exchangeInfo.ts b/src/modules/spot/general-api/exchangeInfo.ts index 4bcb0c1d..befab108 100644 --- a/src/modules/spot/general-api/exchangeInfo.ts +++ b/src/modules/spot/general-api/exchangeInfo.ts @@ -6,23 +6,25 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceExchangeInfo(server: McpServer) { - server.tool( + server.registerTool( "BinanceExchangeInfo", - "Get exchange information including rate limits, symbol configs, etc.", { - symbol: z - .string() - .optional() - .describe( - "Single trading pair in UPPERCASE, no separators (e.g. BTCUSDT, SOLUSDT). Use this for one pair; do not use both symbol and symbols.", - ), - symbols: z - .array(z.string()) - .optional() - .describe( - 'Multiple pairs as array; each symbol UPPERCASE (e.g. ["BTCUSDT","ETHUSDT"]). Do not use with symbol.', - ), - permissions: z.array(z.string()).optional().describe("Array of permissions to filter by"), + description: "Get exchange information including rate limits, symbol configs, etc.", + inputSchema: { + symbol: z + .string() + .optional() + .describe( + "Single trading pair in UPPERCASE, no separators (e.g. BTCUSDT, SOLUSDT). Use this for one pair; do not use both symbol and symbols.", + ), + symbols: z + .array(z.string()) + .optional() + .describe( + 'Multiple pairs as array; each symbol UPPERCASE (e.g. ["BTCUSDT","ETHUSDT"]). Do not use with symbol.', + ), + permissions: z.array(z.string()).optional().describe("Array of permissions to filter by"), + }, }, async ({ symbol, symbols, permissions }) => { try { diff --git a/src/modules/spot/general-api/ping.ts b/src/modules/spot/general-api/ping.ts index ebce997e..bddc02d5 100644 --- a/src/modules/spot/general-api/ping.ts +++ b/src/modules/spot/general-api/ping.ts @@ -4,27 +4,31 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinancePing(server: McpServer) { - server.tool("BinancePing", "Test connectivity to the Binance API.", {}, async () => { - try { - const response = await spotClient.restAPI.ping(); + server.registerTool( + "BinancePing", + { description: "Test connectivity to the Binance API." }, + async () => { + try { + const response = await spotClient.restAPI.ping(); - const data = await response.data(); + const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Successfully pinged Binance API. Response: ${JSON.stringify(data)}`, - }, - ], - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); + return { + content: [ + { + type: "text", + text: `Successfully pinged Binance API. Response: ${JSON.stringify(data)}`, + }, + ], + }; + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to ping Binance API: ${errorMessage}` }], - isError: true, - }; - } - }); + return { + content: [{ type: "text", text: `Failed to ping Binance API: ${errorMessage}` }], + isError: true, + }; + } + }, + ); } diff --git a/src/modules/spot/general-api/time.ts b/src/modules/spot/general-api/time.ts index 01df870a..601054ff 100644 --- a/src/modules/spot/general-api/time.ts +++ b/src/modules/spot/general-api/time.ts @@ -4,32 +4,36 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceTime(server: McpServer) { - server.tool("BinanceTime", "Get the current server time from Binance API.", {}, async () => { - try { - const response = await spotClient.restAPI.time(); + server.registerTool( + "BinanceTime", + { description: "Get the current server time from Binance API." }, + async () => { + try { + const response = await spotClient.restAPI.time(); - const data = await response.data(); + const data = await response.data(); - // @ts-expect-error - serverTime not in generated type definition - const serverTime = new Date(data.serverTime).toISOString(); + // @ts-expect-error - serverTime not in generated type definition + const serverTime = new Date(data.serverTime).toISOString(); - return { - content: [ - { - type: "text", - text: `Current Binance server time: ${serverTime} (${ - data.serverTime - }). Response: ${JSON.stringify(data)}`, - }, - ], - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); + return { + content: [ + { + type: "text", + text: `Current Binance server time: ${serverTime} (${ + data.serverTime + }). Response: ${JSON.stringify(data)}`, + }, + ], + }; + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to retrieve server time: ${errorMessage}` }], - isError: true, - }; - } - }); + return { + content: [{ type: "text", text: `Failed to retrieve server time: ${errorMessage}` }], + isError: true, + }; + } + }, + ); } diff --git a/src/modules/spot/market-api/aggTrades.ts b/src/modules/spot/market-api/aggTrades.ts index 378358ef..0f4e8f65 100644 --- a/src/modules/spot/market-api/aggTrades.ts +++ b/src/modules/spot/market-api/aggTrades.ts @@ -6,15 +6,17 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceAggTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceAggTrades", - "Get compressed, aggregate trades for a specific trading pair.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - fromId: z.number().optional().describe("ID to get aggregate trades from"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1000"), + description: "Get compressed, aggregate trades for a specific trading pair.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + fromId: z.number().optional().describe("ID to get aggregate trades from"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1000"), + }, }, async ({ symbol, fromId, startTime, endTime, limit }) => { try { diff --git a/src/modules/spot/market-api/avgPrice.ts b/src/modules/spot/market-api/avgPrice.ts index 6603c81b..299e44d8 100644 --- a/src/modules/spot/market-api/avgPrice.ts +++ b/src/modules/spot/market-api/avgPrice.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceAvgPrice(server: McpServer) { - server.tool( + server.registerTool( "BinanceAvgPrice", - "Get current average price for a trading pair.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + description: "Get current average price for a trading pair.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, }, async ({ symbol }) => { try { diff --git a/src/modules/spot/market-api/depth.ts b/src/modules/spot/market-api/depth.ts index 31b78959..106c39d7 100644 --- a/src/modules/spot/market-api/depth.ts +++ b/src/modules/spot/market-api/depth.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceDepth(server: McpServer) { - server.tool( + server.registerTool( "BinanceDepth", - "Get order book depth data for a specific trading pair.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - limit: z.number().optional().describe("Depth of the order book. Default 100; max 5000."), + description: "Get order book depth data for a specific trading pair.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + limit: z.number().optional().describe("Depth of the order book. Default 100; max 5000."), + }, }, async ({ symbol, limit }) => { try { diff --git a/src/modules/spot/market-api/getTrades.ts b/src/modules/spot/market-api/getTrades.ts index 2e1ed4c1..1d0dace1 100644 --- a/src/modules/spot/market-api/getTrades.ts +++ b/src/modules/spot/market-api/getTrades.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceGetTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetTrades", - "Get recent trades for a specific trading pair.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - limit: z.number().optional().describe("Default 500; max 1000"), + description: "Get recent trades for a specific trading pair.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + limit: z.number().optional().describe("Default 500; max 1000"), + }, }, async ({ symbol, limit }) => { try { diff --git a/src/modules/spot/market-api/historicalTrades.ts b/src/modules/spot/market-api/historicalTrades.ts index 07a7b27d..85299c2a 100644 --- a/src/modules/spot/market-api/historicalTrades.ts +++ b/src/modules/spot/market-api/historicalTrades.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceHistoricalTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceHistoricalTrades", - "Get older historical trades for a specific trading pair.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - limit: z.number().optional().describe("Default 500; max 1000"), - fromId: z.number().optional().describe("Trade ID to fetch from"), + description: "Get older historical trades for a specific trading pair.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + limit: z.number().optional().describe("Default 500; max 1000"), + fromId: z.number().optional().describe("Trade ID to fetch from"), + }, }, async ({ symbol, limit, fromId }) => { try { diff --git a/src/modules/spot/market-api/klines.ts b/src/modules/spot/market-api/klines.ts index 8ab84f65..12d97fea 100644 --- a/src/modules/spot/market-api/klines.ts +++ b/src/modules/spot/market-api/klines.ts @@ -6,33 +6,35 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceKlines(server: McpServer) { - server.tool( + server.registerTool( "BinanceKlines", - "Get candlestick data (klines) for a specific trading pair and interval.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - interval: z - .enum([ - "1m", - "3m", - "5m", - "15m", - "30m", - "1h", - "2h", - "4h", - "6h", - "8h", - "12h", - "1d", - "3d", - "1w", - "1M", - ]) - .describe("Kline interval"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1000"), + description: "Get candlestick data (klines) for a specific trading pair and interval.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1000"), + }, }, async ({ symbol, interval, startTime, endTime, limit }) => { try { diff --git a/src/modules/spot/market-api/ticker.ts b/src/modules/spot/market-api/ticker.ts index fca26210..dc71f02d 100644 --- a/src/modules/spot/market-api/ticker.ts +++ b/src/modules/spot/market-api/ticker.ts @@ -6,15 +6,18 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceTicker(server: McpServer) { - server.tool( + server.registerTool( "BinanceTicker", - "Get 24-hour rolling window price change statistics for a symbol or all symbols.", { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - windowSize: z - .string() - .optional() - .describe("Defaults to 1d. Valid values: 1d, 2d, 3d, 4d, 5d, 6d, 7d"), + description: + "Get 24-hour rolling window price change statistics for a symbol or all symbols.", + inputSchema: { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + windowSize: z + .string() + .optional() + .describe("Defaults to 1d. Valid values: 1d, 2d, 3d, 4d, 5d, 6d, 7d"), + }, }, async ({ symbol, windowSize }) => { try { diff --git a/src/modules/spot/market-api/ticker24hr.ts b/src/modules/spot/market-api/ticker24hr.ts index bb9cf669..06fb1f9b 100644 --- a/src/modules/spot/market-api/ticker24hr.ts +++ b/src/modules/spot/market-api/ticker24hr.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceTicker24hr(server: McpServer) { - server.tool( + server.registerTool( "BinanceTicker24hr", - "Get 24-hour price change statistics for a symbol or all symbols.", { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + description: "Get 24-hour price change statistics for a symbol or all symbols.", + inputSchema: { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, }, async ({ symbol }) => { try { diff --git a/src/modules/spot/market-api/tickerBookTicker.ts b/src/modules/spot/market-api/tickerBookTicker.ts index 0c59dc80..ab275052 100644 --- a/src/modules/spot/market-api/tickerBookTicker.ts +++ b/src/modules/spot/market-api/tickerBookTicker.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceTickerBookTicker(server: McpServer) { - server.tool( + server.registerTool( "BinanceTickerBookTicker", - "Get best price/quantity on the order book for a symbol or all symbols.", { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + description: "Get best price/quantity on the order book for a symbol or all symbols.", + inputSchema: { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, }, async ({ symbol }) => { try { diff --git a/src/modules/spot/market-api/tickerPrice.ts b/src/modules/spot/market-api/tickerPrice.ts index 1480cdcb..f1da8d7c 100644 --- a/src/modules/spot/market-api/tickerPrice.ts +++ b/src/modules/spot/market-api/tickerPrice.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceTickerPrice(server: McpServer) { - server.tool( + server.registerTool( "BinanceTickerPrice", - "Get latest price for a symbol or all symbols.", { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + description: "Get latest price for a symbol or all symbols.", + inputSchema: { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, }, async ({ symbol }) => { try { diff --git a/src/modules/spot/market-api/tickerTradingDay.ts b/src/modules/spot/market-api/tickerTradingDay.ts index 8ec97804..1fcedc0f 100644 --- a/src/modules/spot/market-api/tickerTradingDay.ts +++ b/src/modules/spot/market-api/tickerTradingDay.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceTickerTradingDay(server: McpServer) { - server.tool( + server.registerTool( "BinanceTickerTradingDay", - "Get statistics for the current trading day for a symbol or all symbols.", { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + description: "Get statistics for the current trading day for a symbol or all symbols.", + inputSchema: { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, }, async ({ symbol }) => { try { diff --git a/src/modules/spot/market-api/uiKlines.ts b/src/modules/spot/market-api/uiKlines.ts index 10cc184e..697bf896 100644 --- a/src/modules/spot/market-api/uiKlines.ts +++ b/src/modules/spot/market-api/uiKlines.ts @@ -6,33 +6,35 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceUiKlines(server: McpServer) { - server.tool( + server.registerTool( "BinanceUiKlines", - "Get UI-optimized candlestick data for a specific trading pair and interval.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - interval: z - .enum([ - "1m", - "3m", - "5m", - "15m", - "30m", - "1h", - "2h", - "4h", - "6h", - "8h", - "12h", - "1d", - "3d", - "1w", - "1M", - ]) - .describe("Kline interval"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1000"), + description: "Get UI-optimized candlestick data for a specific trading pair and interval.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1000"), + }, }, async ({ symbol, interval, startTime, endTime, limit }) => { try { diff --git a/src/modules/spot/trade-api/allOrders.ts b/src/modules/spot/trade-api/allOrders.ts index 939a32f8..d8ab32d9 100644 --- a/src/modules/spot/trade-api/allOrders.ts +++ b/src/modules/spot/trade-api/allOrders.ts @@ -6,18 +6,20 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceAllOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceAllOrders", - "Get all account orders for a specific symbol; active, canceled, or filled.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - orderId: z.number().optional().describe("Order ID to start from"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z - .number() - .optional() - .describe("Maximum number of orders to return (default 500, max 1000)"), + description: "Get all account orders for a specific symbol; active, canceled, or filled.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + orderId: z.number().optional().describe("Order ID to start from"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z + .number() + .optional() + .describe("Maximum number of orders to return (default 500, max 1000)"), + }, }, async ({ symbol, orderId, startTime, endTime, limit }) => { try { diff --git a/src/modules/spot/trade-api/deleteOpenOrders.ts b/src/modules/spot/trade-api/deleteOpenOrders.ts index 1d37e077..22d06c31 100644 --- a/src/modules/spot/trade-api/deleteOpenOrders.ts +++ b/src/modules/spot/trade-api/deleteOpenOrders.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceDeleteOpenOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeleteOpenOrders", - "Cancel all open orders on Binance for a specific symbol.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + description: "Cancel all open orders on Binance for a specific symbol.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, }, async ({ symbol }) => { try { diff --git a/src/modules/spot/trade-api/deleteOrder.ts b/src/modules/spot/trade-api/deleteOrder.ts index 8bbe0e5f..9768877b 100644 --- a/src/modules/spot/trade-api/deleteOrder.ts +++ b/src/modules/spot/trade-api/deleteOrder.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceDeleteOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeleteOrder", - "Cancel an active order on Binance for a specific trading pair.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - orderId: z.string().optional().describe("The order ID to cancel"), - origClientOrderId: z.string().optional().describe("Original client order ID"), + description: "Cancel an active order on Binance for a specific trading pair.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + orderId: z.string().optional().describe("The order ID to cancel"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + }, }, async ({ symbol, orderId, origClientOrderId }) => { try { diff --git a/src/modules/spot/trade-api/getOpenOrders.ts b/src/modules/spot/trade-api/getOpenOrders.ts index 5d30259d..4abe2229 100644 --- a/src/modules/spot/trade-api/getOpenOrders.ts +++ b/src/modules/spot/trade-api/getOpenOrders.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceGetOpenOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetOpenOrders", - "Get all open orders on Binance for a specific symbol or all symbols.", { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + description: "Get all open orders on Binance for a specific symbol or all symbols.", + inputSchema: { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, }, async ({ symbol }) => { try { diff --git a/src/modules/spot/trade-api/getOrder.ts b/src/modules/spot/trade-api/getOrder.ts index e76b7bf5..b3e2afa9 100644 --- a/src/modules/spot/trade-api/getOrder.ts +++ b/src/modules/spot/trade-api/getOrder.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceGetOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetOrder", - "Check an order's status on Binance for a specific trading pair.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - orderId: z.string().optional().describe("The order ID to query"), - origClientOrderId: z.string().optional().describe("Original client order ID"), + description: "Check an order's status on Binance for a specific trading pair.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + orderId: z.string().optional().describe("The order ID to query"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + }, }, async ({ symbol, orderId, origClientOrderId }) => { try { diff --git a/src/modules/spot/trade-api/newOrder.ts b/src/modules/spot/trade-api/newOrder.ts index 4e5ccca9..00773a80 100644 --- a/src/modules/spot/trade-api/newOrder.ts +++ b/src/modules/spot/trade-api/newOrder.ts @@ -11,34 +11,36 @@ function sanitizeNewClientOrderId(value: string): string { } export function registerBinanceNewOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceNewOrder", - "Create a new order on Binance for a specific trading pair.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Order side: BUY or SELL"), - type: z - .enum([ - "LIMIT", - "MARKET", - "STOP_LOSS", - "STOP_LOSS_LIMIT", - "TAKE_PROFIT", - "TAKE_PROFIT_LIMIT", - "LIMIT_MAKER", - ]) - .describe("Order type"), - timeInForce: z.enum(["GTC", "IOC", "FOK"]).optional().describe("Time in force"), - quantity: z.number().describe("Order quantity"), - quoteOrderQty: z.number().optional().describe("Quote order quantity"), - price: z.number().optional().describe("Order price"), - newClientOrderId: z - .string() - .optional() - .describe("Client order ID: only a-zA-Z0-9-_ allowed, max 36 chars"), - stopPrice: z.number().optional().describe("Stop price"), - icebergQty: z.number().optional().describe("Iceberg quantity"), - newOrderRespType: z.enum(["ACK", "RESULT", "FULL"]).optional().describe("Response type"), + description: "Create a new order on Binance for a specific trading pair.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Order side: BUY or SELL"), + type: z + .enum([ + "LIMIT", + "MARKET", + "STOP_LOSS", + "STOP_LOSS_LIMIT", + "TAKE_PROFIT", + "TAKE_PROFIT_LIMIT", + "LIMIT_MAKER", + ]) + .describe("Order type"), + timeInForce: z.enum(["GTC", "IOC", "FOK"]).optional().describe("Time in force"), + quantity: z.number().describe("Order quantity"), + quoteOrderQty: z.number().optional().describe("Quote order quantity"), + price: z.number().optional().describe("Order price"), + newClientOrderId: z + .string() + .optional() + .describe("Client order ID: only a-zA-Z0-9-_ allowed, max 36 chars"), + stopPrice: z.number().optional().describe("Stop price"), + icebergQty: z.number().optional().describe("Iceberg quantity"), + newOrderRespType: z.enum(["ACK", "RESULT", "FULL"]).optional().describe("Response type"), + }, }, async ({ symbol, diff --git a/src/modules/spot/trade-api/openOrderList.ts b/src/modules/spot/trade-api/openOrderList.ts index 2a8c3ee9..12c9a3a4 100644 --- a/src/modules/spot/trade-api/openOrderList.ts +++ b/src/modules/spot/trade-api/openOrderList.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceOpenOrderList(server: McpServer) { - server.tool( + server.registerTool( "BinanceOpenOrderList", - "Query open OCO orders for a specific account or symbol.", { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + description: "Query open OCO orders for a specific account or symbol.", + inputSchema: { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, }, async ({ symbol }) => { try { diff --git a/src/modules/spot/trade-api/orderOco.ts b/src/modules/spot/trade-api/orderOco.ts index 42803c26..33348c6d 100644 --- a/src/modules/spot/trade-api/orderOco.ts +++ b/src/modules/spot/trade-api/orderOco.ts @@ -6,24 +6,26 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceOrderOco(server: McpServer) { - server.tool( + server.registerTool( "BinanceOrderOco", - "Send a new OCO (One-Cancels-the-Other) order on Binance.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Order side: BUY or SELL"), - quantity: z.number().describe("Order quantity"), - price: z.number().describe("Order price"), - stopPrice: z.number().describe("Stop price"), - stopLimitPrice: z.number().optional().describe("Stop limit price"), - stopLimitTimeInForce: z - .enum(["GTC", "IOC", "FOK"]) - .optional() - .describe("Stop limit time in force"), - newClientOrderId: z.string().optional().describe("Client order ID for the limit order"), - stopClientOrderId: z.string().optional().describe("Client order ID for the stop order"), - limitIcebergQty: z.number().optional().describe("Limit iceberg quantity"), - stopIcebergQty: z.number().optional().describe("Stop iceberg quantity"), + description: "Send a new OCO (One-Cancels-the-Other) order on Binance.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Order side: BUY or SELL"), + quantity: z.number().describe("Order quantity"), + price: z.number().describe("Order price"), + stopPrice: z.number().describe("Stop price"), + stopLimitPrice: z.number().optional().describe("Stop limit price"), + stopLimitTimeInForce: z + .enum(["GTC", "IOC", "FOK"]) + .optional() + .describe("Stop limit time in force"), + newClientOrderId: z.string().optional().describe("Client order ID for the limit order"), + stopClientOrderId: z.string().optional().describe("Client order ID for the stop order"), + limitIcebergQty: z.number().optional().describe("Limit iceberg quantity"), + stopIcebergQty: z.number().optional().describe("Stop iceberg quantity"), + }, }, async ({ symbol, diff --git a/src/modules/spot/userdatastream-api/deleteUserDataStream.ts b/src/modules/spot/userdatastream-api/deleteUserDataStream.ts index 823a10cd..47eb16f3 100644 --- a/src/modules/spot/userdatastream-api/deleteUserDataStream.ts +++ b/src/modules/spot/userdatastream-api/deleteUserDataStream.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceDeleteUserDataStream(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeleteUserDataStream", - "Close a user data stream by invalidating the listen key.", { - listenKey: z.string().describe("Listen key to close"), + description: "Close a user data stream by invalidating the listen key.", + inputSchema: { + listenKey: z.string().describe("Listen key to close"), + }, }, async ({ listenKey }) => { try { diff --git a/src/modules/spot/userdatastream-api/newUserDataStream.ts b/src/modules/spot/userdatastream-api/newUserDataStream.ts index 053ed45c..e7bd9d50 100644 --- a/src/modules/spot/userdatastream-api/newUserDataStream.ts +++ b/src/modules/spot/userdatastream-api/newUserDataStream.ts @@ -4,10 +4,9 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceNewUserDataStream(server: McpServer) { - server.tool( + server.registerTool( "BinanceNewUserDataStream", - "Create a new user data stream to receive account updates via WebSocket.", - {}, + { description: "Create a new user data stream to receive account updates via WebSocket." }, async () => { try { const response = await spotClient.restAPI.newUserDataStream(); diff --git a/src/modules/spot/userdatastream-api/putUserDataStream.ts b/src/modules/spot/userdatastream-api/putUserDataStream.ts index 3579e98d..73d4783e 100644 --- a/src/modules/spot/userdatastream-api/putUserDataStream.ts +++ b/src/modules/spot/userdatastream-api/putUserDataStream.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinancePutUserDataStream(server: McpServer) { - server.tool( + server.registerTool( "BinancePutUserDataStream", - "Extend the validity of a user data stream listen key.", { - listenKey: z.string().describe("Listen key to keep alive"), + description: "Extend the validity of a user data stream listen key.", + inputSchema: { + listenKey: z.string().describe("Listen key to keep alive"), + }, }, async ({ listenKey }) => { try { diff --git a/src/modules/staking/ETH-staking-api/ethStakingAccount.ts b/src/modules/staking/ETH-staking-api/ethStakingAccount.ts index b6b73263..cad0c72b 100644 --- a/src/modules/staking/ETH-staking-api/ethStakingAccount.ts +++ b/src/modules/staking/ETH-staking-api/ethStakingAccount.ts @@ -6,11 +6,14 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceEthStakingAccount(server: McpServer) { - server.tool( + server.registerTool( "BinanceEthStakingAccount", - "ETH Staking Account API allows users to retrieve their current ETH staking holdings and 30-day profit details, including amounts from WBETH and BETH", { - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "ETH Staking Account API allows users to retrieve their current ETH staking holdings and 30-day profit details, including amounts from WBETH and BETH", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/staking/ETH-staking-api/getCurrentEthStakingQuota.ts b/src/modules/staking/ETH-staking-api/getCurrentEthStakingQuota.ts index cb23363b..7275a607 100644 --- a/src/modules/staking/ETH-staking-api/getCurrentEthStakingQuota.ts +++ b/src/modules/staking/ETH-staking-api/getCurrentEthStakingQuota.ts @@ -6,11 +6,14 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetCurrentEthStakingQuota(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetCurrentEthStakingQuota", - "Get Current ETH Staking Quota API allows users to retrieve their available ETH staking and redemption quotas, reflecting personal and daily limits.", { - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Get Current ETH Staking Quota API allows users to retrieve their available ETH staking and redemption quotas, reflecting personal and daily limits.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/staking/ETH-staking-api/getEthRedemptionHistory.ts b/src/modules/staking/ETH-staking-api/getEthRedemptionHistory.ts index 4ca27d3d..98eeae75 100644 --- a/src/modules/staking/ETH-staking-api/getEthRedemptionHistory.ts +++ b/src/modules/staking/ETH-staking-api/getEthRedemptionHistory.ts @@ -6,36 +6,39 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetEthRedemptionHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetEthRedemptionHistory", - "Get ETH Redemption History API allows users to retrieve their historical ETH staking redemption records, including details like asset type, amount, status, and time of redemption.", { - startTime: z - .number() - .int() - .optional() - .describe("Start time in milliseconds (e.g., 1641522717552)"), - endTime: z - .number() - .int() - .optional() - .describe("End time in milliseconds (e.g., 1641522526562)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page, start from 1. Default is 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page, Default is 10, Max is 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Get ETH Redemption History API allows users to retrieve their historical ETH staking redemption records, including details like asset type, amount, status, and time of redemption.", + inputSchema: { + startTime: z + .number() + .int() + .optional() + .describe("Start time in milliseconds (e.g., 1641522717552)"), + endTime: z + .number() + .int() + .optional() + .describe("End time in milliseconds (e.g., 1641522526562)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page, start from 1. Default is 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page, Default is 10, Max is 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/staking/ETH-staking-api/getEthStakingHistory.ts b/src/modules/staking/ETH-staking-api/getEthStakingHistory.ts index 6f2405f4..e41ef5ac 100644 --- a/src/modules/staking/ETH-staking-api/getEthStakingHistory.ts +++ b/src/modules/staking/ETH-staking-api/getEthStakingHistory.ts @@ -6,36 +6,39 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetEthStakingHistory(server: McpServer) { - server.tool( + server.registerTool( "registerBinanceGetEthStakingHistory", - "Get ETH Staking History API allows users to retrieve their historical ETH staking records, including details like asset type, amount, status, and time of staking", { - startTime: z - .number() - .int() - .optional() - .describe("Start time in milliseconds (e.g., 1641522717552)"), - endTime: z - .number() - .int() - .optional() - .describe("End time in milliseconds (e.g., 1641522526562)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default is 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default is 10, Max is 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Get ETH Staking History API allows users to retrieve their historical ETH staking records, including details like asset type, amount, status, and time of staking", + inputSchema: { + startTime: z + .number() + .int() + .optional() + .describe("Start time in milliseconds (e.g., 1641522717552)"), + endTime: z + .number() + .int() + .optional() + .describe("End time in milliseconds (e.g., 1641522526562)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default is 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default is 10, Max is 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/staking/ETH-staking-api/getWbethRateHistory.ts b/src/modules/staking/ETH-staking-api/getWbethRateHistory.ts index 4f354623..e2c1056e 100644 --- a/src/modules/staking/ETH-staking-api/getWbethRateHistory.ts +++ b/src/modules/staking/ETH-staking-api/getWbethRateHistory.ts @@ -6,33 +6,36 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetWbethRateHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetWbethRateHistory", - "Get WBETH Rate History API allows users to retrieve historical WBETH exchange rates and BETH annual percentage rates (APR) within a specified time range.", { - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Starts from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), + description: + "Get WBETH Rate History API allows users to retrieve historical WBETH exchange rates and BETH annual percentage rates (APR) within a specified time range.", + inputSchema: { + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Starts from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z - .number() - .int() - .optional() - .describe("Time window for request validity (in milliseconds)"), + recvWindow: z + .number() + .int() + .optional() + .describe("Time window for request validity (in milliseconds)"), + }, }, async (params) => { try { diff --git a/src/modules/staking/ETH-staking-api/getWbethRewardsHistory.ts b/src/modules/staking/ETH-staking-api/getWbethRewardsHistory.ts index 697014e7..a02a08ff 100644 --- a/src/modules/staking/ETH-staking-api/getWbethRewardsHistory.ts +++ b/src/modules/staking/ETH-staking-api/getWbethRewardsHistory.ts @@ -6,36 +6,39 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetWbethRewardsHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetWbethRewardsHistory", - "Get WBETH Rewards History API allows users to retrieve historical reward data earned from WBETH holdings, including estimated rewards in ETH, holding amounts, and APR details.", { - startTime: z - .number() - .int() - .optional() - .describe("Start time in milliseconds (e.g., 1641522717552)"), - endTime: z - .number() - .int() - .optional() - .describe("End time in milliseconds (e.g., 1641522720000)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Get WBETH Rewards History API allows users to retrieve historical reward data earned from WBETH holdings, including estimated rewards in ETH, holding amounts, and APR details.", + inputSchema: { + startTime: z + .number() + .int() + .optional() + .describe("Start time in milliseconds (e.g., 1641522717552)"), + endTime: z + .number() + .int() + .optional() + .describe("End time in milliseconds (e.g., 1641522720000)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/staking/ETH-staking-api/getWbethUnwrapHistory.ts b/src/modules/staking/ETH-staking-api/getWbethUnwrapHistory.ts index d36db1e5..12fcdb90 100644 --- a/src/modules/staking/ETH-staking-api/getWbethUnwrapHistory.ts +++ b/src/modules/staking/ETH-staking-api/getWbethUnwrapHistory.ts @@ -6,32 +6,35 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetWbethUnwrapHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetWbethUnwrapHistory", - "Get WBETH Unwrap History API allows users to retrieve historical records of WBETH unwrap operations, including asset conversion details, exchange rates, and transaction status.", { - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z - .number() - .int() - .optional() - .describe("Time window for request validity (in milliseconds)"), + description: + "Get WBETH Unwrap History API allows users to retrieve historical records of WBETH unwrap operations, including asset conversion details, exchange rates, and transaction status.", + inputSchema: { + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z + .number() + .int() + .optional() + .describe("Time window for request validity (in milliseconds)"), + }, }, async (params) => { try { diff --git a/src/modules/staking/ETH-staking-api/getWbethWrapHistory.ts b/src/modules/staking/ETH-staking-api/getWbethWrapHistory.ts index 29d4e678..5b69ef1d 100644 --- a/src/modules/staking/ETH-staking-api/getWbethWrapHistory.ts +++ b/src/modules/staking/ETH-staking-api/getWbethWrapHistory.ts @@ -6,28 +6,31 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetWbethWrapHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetWbethWrapHistory", - "Get WBETH Wrap History API allows users to retrieve historical records of WBETH wrap operations, including asset conversion details, exchange rates, and transaction status.", { - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Get WBETH Wrap History API allows users to retrieve historical records of WBETH wrap operations, including asset conversion details, exchange rates, and transaction status.", + inputSchema: { + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/staking/ETH-staking-api/redeemEth.ts b/src/modules/staking/ETH-staking-api/redeemEth.ts index 53d22e97..ba81b6fb 100644 --- a/src/modules/staking/ETH-staking-api/redeemEth.ts +++ b/src/modules/staking/ETH-staking-api/redeemEth.ts @@ -6,17 +6,20 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceRedeemEth(server: McpServer) { - server.tool( + server.registerTool( "BinanceRedeemEth", - "Redeem ETH API allows users to redeem WBETH or BETH for ETH, providing the amount, conversion ratio, and arrival time details.", { - amount: z.number().min(0).describe("Amount in BETH, limit 8 decimals (mandatory)"), - asset: z - .string() - .optional() - .default("BETH") - .describe("Asset type, either WBETH or BETH. Default: BETH"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Redeem ETH API allows users to redeem WBETH or BETH for ETH, providing the amount, conversion ratio, and arrival time details.", + inputSchema: { + amount: z.number().min(0).describe("Amount in BETH, limit 8 decimals (mandatory)"), + asset: z + .string() + .optional() + .default("BETH") + .describe("Asset type, either WBETH or BETH. Default: BETH"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/staking/ETH-staking-api/subscribeEthStaking.ts b/src/modules/staking/ETH-staking-api/subscribeEthStaking.ts index b9c9272d..ef4108b9 100644 --- a/src/modules/staking/ETH-staking-api/subscribeEthStaking.ts +++ b/src/modules/staking/ETH-staking-api/subscribeEthStaking.ts @@ -6,12 +6,15 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceSubscribeEthStaking(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubscribeEthStaking", - "Subscribe ETH Staking API allows users to stake ETH and receive WBETH, providing the staked amount and the conversion ratio for ETH to WBETH.", { - amount: z.number().min(0).describe("Amount in BETH, limit 4 decimals (mandatory)"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Subscribe ETH Staking API allows users to stake ETH and receive WBETH, providing the staked amount and the conversion ratio for ETH to WBETH.", + inputSchema: { + amount: z.number().min(0).describe("Amount in BETH, limit 4 decimals (mandatory)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/staking/ETH-staking-api/wrapBeth.ts b/src/modules/staking/ETH-staking-api/wrapBeth.ts index 596c5486..2d64825f 100644 --- a/src/modules/staking/ETH-staking-api/wrapBeth.ts +++ b/src/modules/staking/ETH-staking-api/wrapBeth.ts @@ -6,12 +6,15 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceWrapBeth(server: McpServer) { - server.tool( + server.registerTool( "BinanceWrapBeth", - "Wrap BETH API allows users to convert BETH into WBETH, providing the wrapped WBETH amount and the exchange rate from BETH to WBETH.", { - amount: z.number().min(0).describe("Amount in BETH, limit 4 decimals (mandatory)"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Wrap BETH API allows users to convert BETH into WBETH, providing the wrapped WBETH amount and the exchange rate from BETH to WBETH.", + inputSchema: { + amount: z.number().min(0).describe("Amount in BETH, limit 4 decimals (mandatory)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/staking/SOL-staking-api/claimBoostRewards.ts b/src/modules/staking/SOL-staking-api/claimBoostRewards.ts index f79e096c..dfb6a7f6 100644 --- a/src/modules/staking/SOL-staking-api/claimBoostRewards.ts +++ b/src/modules/staking/SOL-staking-api/claimBoostRewards.ts @@ -6,11 +6,14 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceClaimBoostRewards(server: McpServer) { - server.tool( + server.registerTool( "BinanceClaimBoostRewards", - "Claim Boost Rewards API allows users to claim their Boost APR airdrop rewards for staking.", { - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Claim Boost Rewards API allows users to claim their Boost APR airdrop rewards for staking.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/staking/SOL-staking-api/getBnsolRateHistory.ts b/src/modules/staking/SOL-staking-api/getBnsolRateHistory.ts index 12381dac..613f8029 100644 --- a/src/modules/staking/SOL-staking-api/getBnsolRateHistory.ts +++ b/src/modules/staking/SOL-staking-api/getBnsolRateHistory.ts @@ -6,28 +6,31 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetBnsolRateHistory(server: McpServer) { - server.tool( + server.registerTool( "registerBinanceGetBnsolRateHistory", - " Get BNSOL Rate History API allows users to retrieve the historical data of the BNSOL staking rate, including APR and exchange rates for SOL to BNSOL.", { - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + " Get BNSOL Rate History API allows users to retrieve the historical data of the BNSOL staking rate, including APR and exchange rates for SOL to BNSOL.", + inputSchema: { + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/staking/SOL-staking-api/getBnsolRewardsHistory.ts b/src/modules/staking/SOL-staking-api/getBnsolRewardsHistory.ts index a11cfcab..a74c3c10 100644 --- a/src/modules/staking/SOL-staking-api/getBnsolRewardsHistory.ts +++ b/src/modules/staking/SOL-staking-api/getBnsolRewardsHistory.ts @@ -6,32 +6,35 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetBnsolRewardsHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetBnsolRewardsHistory", - "Get Boost Rewards History API allows users to retrieve their historical boost rewards data for staking, including the amount of rewards, token type (e.g., SOL), and status of the rewards (e.g., CLAIM, DISTRIBUTE).", { - type: z - .enum(["CLAIM", "DISTRIBUTE"]) - .default("CLAIM") - .describe('Type of action. Must be "CLAIM" or "DISTRIBUTE". Default: "CLAIM"'), - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Get Boost Rewards History API allows users to retrieve their historical boost rewards data for staking, including the amount of rewards, token type (e.g., SOL), and status of the rewards (e.g., CLAIM, DISTRIBUTE).", + inputSchema: { + type: z + .enum(["CLAIM", "DISTRIBUTE"]) + .default("CLAIM") + .describe('Type of action. Must be "CLAIM" or "DISTRIBUTE". Default: "CLAIM"'), + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/staking/SOL-staking-api/getBoostRewardsHistory.ts b/src/modules/staking/SOL-staking-api/getBoostRewardsHistory.ts index 674bcca5..f0d856f9 100644 --- a/src/modules/staking/SOL-staking-api/getBoostRewardsHistory.ts +++ b/src/modules/staking/SOL-staking-api/getBoostRewardsHistory.ts @@ -6,32 +6,35 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetBoostRewardsHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetBoostRewardsHistory", - "Get Boost Rewards History API allows users to retrieve their boost rewards history for staking activities. This includes the amount of rewards received, the token type (e.g., SOL), and the status of the rewards (e.g., CLAIM or DISTRIBUTE).", { - type: z - .enum(["CLAIM", "DISTRIBUTE"]) - .default("CLAIM") - .describe('Type of action. Must be "CLAIM" or "DISTRIBUTE". Default: "CLAIM"'), - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Get Boost Rewards History API allows users to retrieve their boost rewards history for staking activities. This includes the amount of rewards received, the token type (e.g., SOL), and the status of the rewards (e.g., CLAIM or DISTRIBUTE).", + inputSchema: { + type: z + .enum(["CLAIM", "DISTRIBUTE"]) + .default("CLAIM") + .describe('Type of action. Must be "CLAIM" or "DISTRIBUTE". Default: "CLAIM"'), + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/staking/SOL-staking-api/getSolRedemptionHistory.ts b/src/modules/staking/SOL-staking-api/getSolRedemptionHistory.ts index de4997af..678447ab 100644 --- a/src/modules/staking/SOL-staking-api/getSolRedemptionHistory.ts +++ b/src/modules/staking/SOL-staking-api/getSolRedemptionHistory.ts @@ -6,28 +6,31 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetSolRedemptionHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetSolRedemptionHistory", - "Get SOL Redemption History API allows users to retrieve their SOL redemption history, detailing the amount of BNSOL redeemed for SOL and the exchange rate.", { - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Get SOL Redemption History API allows users to retrieve their SOL redemption history, detailing the amount of BNSOL redeemed for SOL and the exchange rate.", + inputSchema: { + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/staking/SOL-staking-api/getSolStakingHistory.ts b/src/modules/staking/SOL-staking-api/getSolStakingHistory.ts index 4ebfba7b..5e059682 100644 --- a/src/modules/staking/SOL-staking-api/getSolStakingHistory.ts +++ b/src/modules/staking/SOL-staking-api/getSolStakingHistory.ts @@ -6,28 +6,31 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetSolStakingHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetSolStakingHistory", - "Get SOL Staking History API allows users to retrieve their SOL staking history, including details about the amount of SOL staked, the equivalent BNSOL amount distributed, the exchange rate, and the status of each staking.", { - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Get SOL Staking History API allows users to retrieve their SOL staking history, including details about the amount of SOL staked, the equivalent BNSOL amount distributed, the exchange rate, and the status of each staking.", + inputSchema: { + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/staking/SOL-staking-api/getSolStakingQuotaDetails.ts b/src/modules/staking/SOL-staking-api/getSolStakingQuotaDetails.ts index d2757f96..0caf796c 100644 --- a/src/modules/staking/SOL-staking-api/getSolStakingQuotaDetails.ts +++ b/src/modules/staking/SOL-staking-api/getSolStakingQuotaDetails.ts @@ -6,11 +6,14 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetSolStakingQuotaDetails(server: McpServer) { - server.tool( + server.registerTool( "getSolStakingQuotaDetails", - "Get SOL Staking Quota API allows users to retrieve their current SOL staking quota, including information such as the remaining staking and redemption limits, minimum staking and redeem amounts, commission fees, and the status of staking and redemption availability.", { - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Get SOL Staking Quota API allows users to retrieve their current SOL staking quota, including information such as the remaining staking and redemption limits, minimum staking and redeem amounts, commission fees, and the status of staking and redemption availability.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/staking/SOL-staking-api/getUnclaimedRewards.ts b/src/modules/staking/SOL-staking-api/getUnclaimedRewards.ts index 8d022775..ae1c5241 100644 --- a/src/modules/staking/SOL-staking-api/getUnclaimedRewards.ts +++ b/src/modules/staking/SOL-staking-api/getUnclaimedRewards.ts @@ -6,11 +6,14 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetUnclaimedRewards(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetUnclaimedRewards", - "Get Unclaimed Rewards API allows users to retrieve information about unclaimed rewards from their SOL staking activities.", { - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Get Unclaimed Rewards API allows users to retrieve information about unclaimed rewards from their SOL staking activities.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/staking/SOL-staking-api/redeemSol.ts b/src/modules/staking/SOL-staking-api/redeemSol.ts index 9121ac3c..49b98bb8 100644 --- a/src/modules/staking/SOL-staking-api/redeemSol.ts +++ b/src/modules/staking/SOL-staking-api/redeemSol.ts @@ -6,16 +6,19 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceRedeemSol(server: McpServer) { - server.tool( + server.registerTool( "registerBinanceRedeemSol", - " Redeem SOL API allows users to redeem BNSOL and receive SOL in exchange. It enables the conversion of BNSOL tokens into SOL based on the specified amount", { - amount: z - .number() - .min(0) - .max(99999999) - .describe("Amount in BNSOL, limit to 8 decimals (mandatory)"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + " Redeem SOL API allows users to redeem BNSOL and receive SOL in exchange. It enables the conversion of BNSOL tokens into SOL based on the specified amount", + inputSchema: { + amount: z + .number() + .min(0) + .max(99999999) + .describe("Amount in BNSOL, limit to 8 decimals (mandatory)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/staking/SOL-staking-api/solStakingAccount.ts b/src/modules/staking/SOL-staking-api/solStakingAccount.ts index 65e2d89b..54f9a305 100644 --- a/src/modules/staking/SOL-staking-api/solStakingAccount.ts +++ b/src/modules/staking/SOL-staking-api/solStakingAccount.ts @@ -6,11 +6,14 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceSolStakingAccount(server: McpServer) { - server.tool( + server.registerTool( "registerBinanceSolStakingAccount", - "SOL Staking Account API allows users to view their SOL staking account details, including their current BNSOL holdings, equivalent SOL balance, and the profit in SOL over the past 30 days.", { - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "SOL Staking Account API allows users to view their SOL staking account details, including their current BNSOL holdings, equivalent SOL balance, and the profit in SOL over the past 30 days.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/staking/SOL-staking-api/subscribeSolStaking.ts b/src/modules/staking/SOL-staking-api/subscribeSolStaking.ts index 6ac11d78..853b3a46 100644 --- a/src/modules/staking/SOL-staking-api/subscribeSolStaking.ts +++ b/src/modules/staking/SOL-staking-api/subscribeSolStaking.ts @@ -6,12 +6,15 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceSubscribeSolStaking(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubscribeSolStaking", - "Subscribe SOL Staking API allows users to stake SOL and receive BNSOL in return. This endpoint requires specifying the amount of SOL to stake, and the response includes the equivalent BNSOL amount and exchange rate for SOL to BNSOL.", { - amount: z.number().min(0).describe("Amount in SOL (mandatory)"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Subscribe SOL Staking API allows users to stake SOL and receive BNSOL in return. This endpoint requires specifying the amount of SOL to stake, and the response includes the equivalent BNSOL amount and exchange rate for SOL to BNSOL.", + inputSchema: { + amount: z.number().min(0).describe("Amount in SOL (mandatory)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/vip-loan/market-api/getBorrowInterestRate.ts b/src/modules/vip-loan/market-api/getBorrowInterestRate.ts index d4c0a1c7..44d6f45d 100644 --- a/src/modules/vip-loan/market-api/getBorrowInterestRate.ts +++ b/src/modules/vip-loan/market-api/getBorrowInterestRate.ts @@ -6,12 +6,19 @@ import { z } from "zod"; import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceGetBorrowInterestRate(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetBorrowInterestRate", - "Retrieves the interest rates for borrowing assets. It provides both daily and yearly interest rates for multiple assets (e.g., BUSD, BTC). You can specify the assets by using a comma-separated list.", { - loanCoin: z.string().min(1).describe("Max 10 assets, multiple split by ','"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Retrieves the interest rates for borrowing assets. It provides both daily and yearly interest rates for multiple assets (e.g., BUSD, BTC). You can specify the assets by using a comma-separated list.", + inputSchema: { + loanCoin: z.string().min(1).describe("Max 10 assets, multiple split by ','"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/vip-loan/market-api/getCollateralAssetData.ts b/src/modules/vip-loan/market-api/getCollateralAssetData.ts index 012f657a..2c87c84c 100644 --- a/src/modules/vip-loan/market-api/getCollateralAssetData.ts +++ b/src/modules/vip-loan/market-api/getCollateralAssetData.ts @@ -6,12 +6,19 @@ import { z } from "zod"; import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceGetCollateralAssetData(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetCollateralAssetData", - "Retrieves information about collateral assets, including collateral ratios and range values for different tiers of collateral. The ratios are used to determine the collateral requirement for various levels of borrowing.", { - collateralCoin: z.string().optional().describe("Optional: Coin used as collateral"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Retrieves information about collateral assets, including collateral ratios and range values for different tiers of collateral. The ratios are used to determine the collateral requirement for various levels of borrowing.", + inputSchema: { + collateralCoin: z.string().optional().describe("Optional: Coin used as collateral"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/vip-loan/market-api/getLoanableAssetsData.ts b/src/modules/vip-loan/market-api/getLoanableAssetsData.ts index f5a7c1c5..8c448656 100644 --- a/src/modules/vip-loan/market-api/getLoanableAssetsData.ts +++ b/src/modules/vip-loan/market-api/getLoanableAssetsData.ts @@ -6,17 +6,24 @@ import { z } from "zod"; import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceGetLoanableAssetsData(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetLoanableAssetsData", - "Retrieves interest rates and borrowing limits for loanable assets. The borrow limit is expressed in USD. You can request information for specific assets or leave it empty to query all available assets.", { - loanCoin: z.string().optional().describe("Optional: Coin for the loan"), - vipLevel: z - .number() - .int() - .optional() - .describe("Optional: User's VIP level (default is user's vip level)"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Retrieves interest rates and borrowing limits for loanable assets. The borrow limit is expressed in USD. You can request information for specific assets or leave it empty to query all available assets.", + inputSchema: { + loanCoin: z.string().optional().describe("Optional: Coin for the loan"), + vipLevel: z + .number() + .int() + .optional() + .describe("Optional: User's VIP level (default is user's vip level)"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/vip-loan/trade-api/vipLoanBorrow.ts b/src/modules/vip-loan/trade-api/vipLoanBorrow.ts index d47f03de..e69a71e2 100644 --- a/src/modules/vip-loan/trade-api/vipLoanBorrow.ts +++ b/src/modules/vip-loan/trade-api/vipLoanBorrow.ts @@ -6,25 +6,34 @@ import { z } from "zod"; import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceVipLoanBorrow(server: McpServer) { - server.tool( + server.registerTool( "BinanceVipLoanBorrow", - "Allow users (master account only) to apply for a loan by pledging collateral. Users specify the coin they want to borrow, the amount, and the collateral details.", { - loanAccountId: z.number().int().describe("Loan account ID"), - loanCoin: z.string().min(1).describe("Loan coin (e.g., BTC, ETH)"), - loanAmount: z.number().describe("Loan amount as decimal"), - collateralAccountId: z - .string() - .min(1) - .describe("Collateral account IDs, separated by commas"), - collateralCoin: z.string().min(1).describe("Collateral coins, separated by commas"), - isFlexibleRate: z.boolean().describe("TRUE: flexible rate, FALSE: fixed rate. Default: TRUE"), - loanTerm: z - .number() - .int() - .optional() - .describe("Loan term (only required if fixed rate, e.g., 30/60 days)"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Allow users (master account only) to apply for a loan by pledging collateral. Users specify the coin they want to borrow, the amount, and the collateral details.", + inputSchema: { + loanAccountId: z.number().int().describe("Loan account ID"), + loanCoin: z.string().min(1).describe("Loan coin (e.g., BTC, ETH)"), + loanAmount: z.number().describe("Loan amount as decimal"), + collateralAccountId: z + .string() + .min(1) + .describe("Collateral account IDs, separated by commas"), + collateralCoin: z.string().min(1).describe("Collateral coins, separated by commas"), + isFlexibleRate: z + .boolean() + .describe("TRUE: flexible rate, FALSE: fixed rate. Default: TRUE"), + loanTerm: z + .number() + .int() + .optional() + .describe("Loan term (only required if fixed rate, e.g., 30/60 days)"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/vip-loan/trade-api/vipLoanRenew.ts b/src/modules/vip-loan/trade-api/vipLoanRenew.ts index 7ffcc0ad..a05a1d43 100644 --- a/src/modules/vip-loan/trade-api/vipLoanRenew.ts +++ b/src/modules/vip-loan/trade-api/vipLoanRenew.ts @@ -6,19 +6,22 @@ import { z } from "zod"; import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceVipLoanRenew(server: McpServer) { - server.tool( + server.registerTool( "BinanceVipLoanRenew", - "Allow VIP users to renew an existing VIP loan for a specified term, either 30 or 60 days.", { - orderId: z.number().int().describe("The order ID for the loan request"), - loanTerm: z - .union([z.literal(30), z.literal(60)]) - .describe("Loan term in days, either 30 or 60"), - recvWindow: z - .number() - .int() - .optional() - .describe("Optional: Time window for request validity"), + description: + "Allow VIP users to renew an existing VIP loan for a specified term, either 30 or 60 days.", + inputSchema: { + orderId: z.number().int().describe("The order ID for the loan request"), + loanTerm: z + .union([z.literal(30), z.literal(60)]) + .describe("Loan term in days, either 30 or 60"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional: Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/vip-loan/trade-api/vipLoanRepay.ts b/src/modules/vip-loan/trade-api/vipLoanRepay.ts index 11fa3f64..3b8c2e71 100644 --- a/src/modules/vip-loan/trade-api/vipLoanRepay.ts +++ b/src/modules/vip-loan/trade-api/vipLoanRepay.ts @@ -6,13 +6,20 @@ import { z } from "zod"; import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceVipLoanRepay(server: McpServer) { - server.tool( + server.registerTool( "BinanceVipLoanRepay", - "Allow VIP users to repay a specified amount of their active loan, partially or fully. It updates the remaining principal and interest, and provides the repayment status.", { - orderId: z.number().int().describe("Order ID of the loan request"), - amount: z.number().describe("Amount to be processed (decimal allowed)"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Allow VIP users to repay a specified amount of their active loan, partially or fully. It updates the remaining principal and interest, and provides the repayment status.", + inputSchema: { + orderId: z.number().int().describe("Order ID of the loan request"), + amount: z.number().describe("Amount to be processed (decimal allowed)"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/vip-loan/userInformation-api/checkVIPLoanCollateralAccount.ts b/src/modules/vip-loan/userInformation-api/checkVIPLoanCollateralAccount.ts index 4d3b2b01..c7cea037 100644 --- a/src/modules/vip-loan/userInformation-api/checkVIPLoanCollateralAccount.ts +++ b/src/modules/vip-loan/userInformation-api/checkVIPLoanCollateralAccount.ts @@ -6,13 +6,20 @@ import { z } from "zod"; import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCheckVIPLoanCollateralAccount(server: McpServer) { - server.tool( + server.registerTool( "BinanceCheckVIPLoanCollateralAccount", - "Allow users to check their collateral accounts and the coins held as collateral. If the logged-in account is a loan account, it will return all associated collateral accounts. If it's a collateral account, it returns details of the current account only.", { - orderId: z.number().int().optional().describe("Optional order ID"), - collateralAccountId: z.number().int().optional().describe("Optional collateral account ID"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Allow users to check their collateral accounts and the coins held as collateral. If the logged-in account is a loan account, it will return all associated collateral accounts. If it's a collateral account, it returns details of the current account only.", + inputSchema: { + orderId: z.number().int().optional().describe("Optional order ID"), + collateralAccountId: z.number().int().optional().describe("Optional collateral account ID"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/vip-loan/userInformation-api/getVIPLoanOngoingOrders.ts b/src/modules/vip-loan/userInformation-api/getVIPLoanOngoingOrders.ts index 6f984328..f1edc4b2 100644 --- a/src/modules/vip-loan/userInformation-api/getVIPLoanOngoingOrders.ts +++ b/src/modules/vip-loan/userInformation-api/getVIPLoanOngoingOrders.ts @@ -6,29 +6,36 @@ import { z } from "zod"; import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceGetVIPLoanOngoingOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetVIPLoanOngoingOrders", - "Allows VIP users to retrieve a list of their current active loan orders. Users can filter results by loan coin, collateral coin, order ID, or collateral account ID.", { - orderId: z.number().int().optional().describe("Optional order ID"), - collateralAccountId: z.number().int().optional().describe("Optional collateral account ID"), - loanCoin: z.string().optional().describe("Optional loan coin"), - collateralCoin: z.string().optional().describe("Optional collateral coin"), - current: z - .number() - .int() - .min(1) - .max(1000) - .optional() - .describe("Current page, start from 1, max 1000"), - limit: z - .number() - .int() - .min(1) - .max(100) - .optional() - .describe("Results per page, default 10, max 100"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Allows VIP users to retrieve a list of their current active loan orders. Users can filter results by loan coin, collateral coin, order ID, or collateral account ID.", + inputSchema: { + orderId: z.number().int().optional().describe("Optional order ID"), + collateralAccountId: z.number().int().optional().describe("Optional collateral account ID"), + loanCoin: z.string().optional().describe("Optional loan coin"), + collateralCoin: z.string().optional().describe("Optional collateral coin"), + current: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .describe("Current page, start from 1, max 1000"), + limit: z + .number() + .int() + .min(1) + .max(100) + .optional() + .describe("Results per page, default 10, max 100"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/vip-loan/userInformation-api/queryApplicationStatus.ts b/src/modules/vip-loan/userInformation-api/queryApplicationStatus.ts index 9288868f..8d7d1b96 100644 --- a/src/modules/vip-loan/userInformation-api/queryApplicationStatus.ts +++ b/src/modules/vip-loan/userInformation-api/queryApplicationStatus.ts @@ -6,19 +6,26 @@ import { z } from "zod"; import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceQueryApplicationStatus(server: McpServer) { - server.tool( + server.registerTool( "BinanceQueryApplicationStatus", - "Allows VIP users to check the status of their loan applications. It returns a list of loan requests with details such as loan coin, amount, term, collateral details, and current application status", { - current: z - .number() - .int() - .min(1) - .max(1000) - .optional() - .describe("Currently querying page. Start from 1, default 1, max 1000"), - limit: z.number().int().min(1).max(100).optional().describe("Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Allows VIP users to check the status of their loan applications. It returns a list of loan requests with details such as loan coin, amount, term, collateral details, and current application status", + inputSchema: { + current: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .describe("Currently querying page. Start from 1, default 1, max 1000"), + limit: z.number().int().min(1).max(100).optional().describe("Default: 10, Max: 100"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/modules/wallet/account-api/accountApiTradingStatus.ts b/src/modules/wallet/account-api/accountApiTradingStatus.ts index d677bf15..798d26c2 100644 --- a/src/modules/wallet/account-api/accountApiTradingStatus.ts +++ b/src/modules/wallet/account-api/accountApiTradingStatus.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletAccountApiTradingStatus(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletAccountApiTradingStatus", - "Get account API trading status.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get account API trading status.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/modules/wallet/account-api/accountInfo.ts b/src/modules/wallet/account-api/accountInfo.ts index ce607633..16e6c3d8 100644 --- a/src/modules/wallet/account-api/accountInfo.ts +++ b/src/modules/wallet/account-api/accountInfo.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletAccountInfo(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletAccountInfo", - "Get Binance Wallet account information.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get Binance Wallet account information.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/modules/wallet/account-api/accountStatus.ts b/src/modules/wallet/account-api/accountStatus.ts index fd202436..e07e0734 100644 --- a/src/modules/wallet/account-api/accountStatus.ts +++ b/src/modules/wallet/account-api/accountStatus.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletAccountStatus(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletAccountStatus", - "Get Binance Wallet account status.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get Binance Wallet account status.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/modules/wallet/account-api/dailyAccountSnapshot.ts b/src/modules/wallet/account-api/dailyAccountSnapshot.ts index 39fe678f..6b14d247 100644 --- a/src/modules/wallet/account-api/dailyAccountSnapshot.ts +++ b/src/modules/wallet/account-api/dailyAccountSnapshot.ts @@ -6,15 +6,17 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletDailyAccountSnapshot(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletDailyAccountSnapshot", - "Get daily account snapshot.", { - type: z.string().describe("The account type (e.g., SPOT, MARGIN, FUTURES)"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 7, max 30"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get daily account snapshot.", + inputSchema: { + type: z.string().describe("The account type (e.g., SPOT, MARGIN, FUTURES)"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 7, max 30"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ type, startTime, endTime, limit, recvWindow }) => { try { diff --git a/src/modules/wallet/account-api/disableFastWithdrawSwitch.ts b/src/modules/wallet/account-api/disableFastWithdrawSwitch.ts index 66915d9a..3c3a86ab 100644 --- a/src/modules/wallet/account-api/disableFastWithdrawSwitch.ts +++ b/src/modules/wallet/account-api/disableFastWithdrawSwitch.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletDisableFastWithdrawSwitch(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletDisableFastWithdrawSwitch", - "Disable fast withdraw switch.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Disable fast withdraw switch.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/modules/wallet/account-api/enableFastWithdrawSwitch.ts b/src/modules/wallet/account-api/enableFastWithdrawSwitch.ts index 657cf9ee..e9e163ff 100644 --- a/src/modules/wallet/account-api/enableFastWithdrawSwitch.ts +++ b/src/modules/wallet/account-api/enableFastWithdrawSwitch.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletEnableFastWithdrawSwitch(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletEnableFastWithdrawSwitch", - "Enable fast withdraw switch.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Enable fast withdraw switch.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/modules/wallet/account-api/getApiKeyPermission.ts b/src/modules/wallet/account-api/getApiKeyPermission.ts index bda72cb5..fa9634a7 100644 --- a/src/modules/wallet/account-api/getApiKeyPermission.ts +++ b/src/modules/wallet/account-api/getApiKeyPermission.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletGetApiKeyPermission(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletGetApiKeyPermission", - "Get API key permission.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get API key permission.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/modules/wallet/asset-api/assetDetail.ts b/src/modules/wallet/asset-api/assetDetail.ts index c49f28fa..515bb0c6 100644 --- a/src/modules/wallet/asset-api/assetDetail.ts +++ b/src/modules/wallet/asset-api/assetDetail.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletAssetDetail(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletAssetDetail", - "Get asset details.", { - asset: z.string().optional().describe("Asset symbol"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get asset details.", + inputSchema: { + asset: z.string().optional().describe("Asset symbol"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ asset, recvWindow }) => { try { diff --git a/src/modules/wallet/asset-api/assetDividendRecord.ts b/src/modules/wallet/asset-api/assetDividendRecord.ts index 6944e01b..1edbc26d 100644 --- a/src/modules/wallet/asset-api/assetDividendRecord.ts +++ b/src/modules/wallet/asset-api/assetDividendRecord.ts @@ -6,15 +6,17 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletAssetDividendRecord(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletAssetDividendRecord", - "Get asset dividend record.", { - asset: z.string().optional().describe("Asset symbol"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 20, max 500"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get asset dividend record.", + inputSchema: { + asset: z.string().optional().describe("Asset symbol"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 20, max 500"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ asset, startTime, endTime, limit, recvWindow }) => { try { diff --git a/src/modules/wallet/asset-api/dustTransfer.ts b/src/modules/wallet/asset-api/dustTransfer.ts index 965f940e..0f04581a 100644 --- a/src/modules/wallet/asset-api/dustTransfer.ts +++ b/src/modules/wallet/asset-api/dustTransfer.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletDustTransfer(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletDustTransfer", - "Convert dust assets to BNB.", { - asset: z.array(z.string()).describe("Array of asset symbols to convert"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Convert dust assets to BNB.", + inputSchema: { + asset: z.array(z.string()).describe("Array of asset symbols to convert"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ asset, recvWindow }) => { try { diff --git a/src/modules/wallet/asset-api/dustlog.ts b/src/modules/wallet/asset-api/dustlog.ts index 62ede583..c42e419f 100644 --- a/src/modules/wallet/asset-api/dustlog.ts +++ b/src/modules/wallet/asset-api/dustlog.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletDustlog(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletDustlog", - "Get dust log (history of dust transfers).", { - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get dust log (history of dust transfers).", + inputSchema: { + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ startTime, endTime, recvWindow }) => { try { diff --git a/src/modules/wallet/asset-api/fundingWallet.ts b/src/modules/wallet/asset-api/fundingWallet.ts index 0a11d347..8403e5ae 100644 --- a/src/modules/wallet/asset-api/fundingWallet.ts +++ b/src/modules/wallet/asset-api/fundingWallet.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletFundingWallet(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletFundingWallet", - "Get funding wallet balance.", { - asset: z.string().optional().describe("Asset symbol"), - needBtcValuation: z.boolean().optional().describe("Whether to include BTC valuation"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get funding wallet balance.", + inputSchema: { + asset: z.string().optional().describe("Asset symbol"), + needBtcValuation: z.boolean().optional().describe("Whether to include BTC valuation"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ asset, needBtcValuation, recvWindow }) => { try { diff --git a/src/modules/wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts b/src/modules/wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts index 41a83029..4476777a 100644 --- a/src/modules/wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts +++ b/src/modules/wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletGetAssetsThatCanBeConvertedIntoBnb(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletGetAssetsThatCanBeConvertedIntoBnb", - "Get assets that can be converted to BNB.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get assets that can be converted to BNB.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/modules/wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts b/src/modules/wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts index 90b98913..4aaf8156 100644 --- a/src/modules/wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts +++ b/src/modules/wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts @@ -6,15 +6,17 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletGetCloudMiningPaymentAndRefundHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletGetCloudMiningPaymentAndRefundHistory", - "Get cloud mining payment and refund history.", { - startTime: z.number().describe("Start time in milliseconds"), - endTime: z.number().describe("End time in milliseconds"), - page: z.number().optional().describe("Page number"), - pageSize: z.number().optional().describe("Page size"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get cloud mining payment and refund history.", + inputSchema: { + startTime: z.number().describe("Start time in milliseconds"), + endTime: z.number().describe("End time in milliseconds"), + page: z.number().optional().describe("Page number"), + pageSize: z.number().optional().describe("Page size"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ startTime, endTime, page, pageSize, recvWindow }) => { try { diff --git a/src/modules/wallet/asset-api/getOpenSymbolList.ts b/src/modules/wallet/asset-api/getOpenSymbolList.ts index 0e112d72..1e575b53 100644 --- a/src/modules/wallet/asset-api/getOpenSymbolList.ts +++ b/src/modules/wallet/asset-api/getOpenSymbolList.ts @@ -4,26 +4,30 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletGetOpenSymbolList(server: McpServer) { - server.tool("BinanceWalletGetOpenSymbolList", "Get open symbol list.", {}, async () => { - try { - const response = await walletClient.restAPI.getOpenSymbolList(); - const data = await response.data(); + server.registerTool( + "BinanceWalletGetOpenSymbolList", + { description: "Get open symbol list." }, + async () => { + try { + const response = await walletClient.restAPI.getOpenSymbolList(); + const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Retrieved open symbol list. Response: ${JSON.stringify(data)}`, - }, - ], - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); + return { + content: [ + { + type: "text", + text: `Retrieved open symbol list. Response: ${JSON.stringify(data)}`, + }, + ], + }; + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to retrieve open symbol list: ${errorMessage}` }], - isError: true, - }; - } - }); + return { + content: [{ type: "text", text: `Failed to retrieve open symbol list: ${errorMessage}` }], + isError: true, + }; + } + }, + ); } diff --git a/src/modules/wallet/asset-api/queryUserDelegationHistory.ts b/src/modules/wallet/asset-api/queryUserDelegationHistory.ts index 58d0767d..679e40ff 100644 --- a/src/modules/wallet/asset-api/queryUserDelegationHistory.ts +++ b/src/modules/wallet/asset-api/queryUserDelegationHistory.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletQueryUserDelegationHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletQueryUserDelegationHistory", - "Query user delegation history.", { - email: z.string().describe("Email address"), - startTime: z.number().describe("Start time in milliseconds"), - endTime: z.number().describe("End time in milliseconds"), - page: z.number().optional().describe("Page number"), - limit: z.number().optional().describe("Results per page"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Query user delegation history.", + inputSchema: { + email: z.string().describe("Email address"), + startTime: z.number().describe("Start time in milliseconds"), + endTime: z.number().describe("End time in milliseconds"), + page: z.number().optional().describe("Page number"), + limit: z.number().optional().describe("Results per page"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ email, startTime, endTime, page, limit, recvWindow }) => { try { diff --git a/src/modules/wallet/asset-api/queryUserUniversalTransferHistory.ts b/src/modules/wallet/asset-api/queryUserUniversalTransferHistory.ts index f5c23c09..32c1f6f8 100644 --- a/src/modules/wallet/asset-api/queryUserUniversalTransferHistory.ts +++ b/src/modules/wallet/asset-api/queryUserUniversalTransferHistory.ts @@ -6,18 +6,20 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletQueryUserUniversalTransferHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletQueryUserUniversalTransferHistory", - "Query universal transfer history.", { - type: z.string().describe("Transfer type"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - current: z.number().optional().describe("Current page"), - size: z.number().optional().describe("Page size"), - fromSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), - toSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Query universal transfer history.", + inputSchema: { + type: z.string().describe("Transfer type"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + current: z.number().optional().describe("Current page"), + size: z.number().optional().describe("Page size"), + fromSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), + toSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ type, startTime, endTime, current, size, fromSymbol, toSymbol, recvWindow }) => { try { diff --git a/src/modules/wallet/asset-api/queryUserWalletBalance.ts b/src/modules/wallet/asset-api/queryUserWalletBalance.ts index 78ac08c1..a56c9a84 100644 --- a/src/modules/wallet/asset-api/queryUserWalletBalance.ts +++ b/src/modules/wallet/asset-api/queryUserWalletBalance.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletQueryUserWalletBalance(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletQueryUserWalletBalance", - "Query user wallet balance.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Query user wallet balance.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/modules/wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts b/src/modules/wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts index 7407c66e..6cd869d0 100644 --- a/src/modules/wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts +++ b/src/modules/wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest", - "Toggle BNB burn on spot trade and margin interest.", { - spotBNBBurn: z.string().optional().describe("'true' or 'false' for spot trade"), - interestBNBBurn: z.string().optional().describe("'true' or 'false' for margin interest"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Toggle BNB burn on spot trade and margin interest.", + inputSchema: { + spotBNBBurn: z.string().optional().describe("'true' or 'false' for spot trade"), + interestBNBBurn: z.string().optional().describe("'true' or 'false' for margin interest"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ spotBNBBurn, interestBNBBurn, recvWindow }) => { try { diff --git a/src/modules/wallet/asset-api/tradeFee.ts b/src/modules/wallet/asset-api/tradeFee.ts index 7eae5189..6cb90d45 100644 --- a/src/modules/wallet/asset-api/tradeFee.ts +++ b/src/modules/wallet/asset-api/tradeFee.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletTradeFee(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletTradeFee", - "Get trade fee.", { - symbol: z.string().optional().describe("Trading pair symbol"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get trade fee.", + inputSchema: { + symbol: z.string().optional().describe("Trading pair symbol"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ symbol, recvWindow }) => { try { diff --git a/src/modules/wallet/asset-api/userAsset.ts b/src/modules/wallet/asset-api/userAsset.ts index 8de08a7f..ee4207a6 100644 --- a/src/modules/wallet/asset-api/userAsset.ts +++ b/src/modules/wallet/asset-api/userAsset.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletUserAsset(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletUserAsset", - "Get user assets.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), - needBtcValuation: z.boolean().optional().describe("Whether to include BTC valuation"), + description: "Get user assets.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + needBtcValuation: z.boolean().optional().describe("Whether to include BTC valuation"), + }, }, async ({ recvWindow, needBtcValuation }) => { try { diff --git a/src/modules/wallet/asset-api/userUniversalTransfer.ts b/src/modules/wallet/asset-api/userUniversalTransfer.ts index 2edd3eb8..d59f97c8 100644 --- a/src/modules/wallet/asset-api/userUniversalTransfer.ts +++ b/src/modules/wallet/asset-api/userUniversalTransfer.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletUserUniversalTransfer(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletUserUniversalTransfer", - "Make universal transfer between different accounts.", { - type: z.string().describe("Transfer type"), - asset: z.string().describe("Asset symbol"), - amount: z.number().describe("Transfer amount"), - fromSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), - toSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Make universal transfer between different accounts.", + inputSchema: { + type: z.string().describe("Transfer type"), + asset: z.string().describe("Asset symbol"), + amount: z.number().describe("Transfer amount"), + fromSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), + toSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ type, asset, amount, fromSymbol, toSymbol, recvWindow }) => { try { diff --git a/src/modules/wallet/capital-api/allCoinsInformation.ts b/src/modules/wallet/capital-api/allCoinsInformation.ts index 98915cd0..661a3983 100644 --- a/src/modules/wallet/capital-api/allCoinsInformation.ts +++ b/src/modules/wallet/capital-api/allCoinsInformation.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletAllCoinsInformation(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletAllCoinsInformation", - "Get information for all coins.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get information for all coins.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/modules/wallet/capital-api/depositAddress.ts b/src/modules/wallet/capital-api/depositAddress.ts index 2ba1261c..49dc9a1d 100644 --- a/src/modules/wallet/capital-api/depositAddress.ts +++ b/src/modules/wallet/capital-api/depositAddress.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletDepositAddress(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletDepositAddress", - "Get deposit address for a specific coin.", { - coin: z.string().describe("Coin symbol"), - network: z.string().optional().describe("Network"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get deposit address for a specific coin.", + inputSchema: { + coin: z.string().describe("Coin symbol"), + network: z.string().optional().describe("Network"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ coin, network, recvWindow }) => { try { diff --git a/src/modules/wallet/capital-api/depositHistory.ts b/src/modules/wallet/capital-api/depositHistory.ts index 4d8d2a00..f654bcc8 100644 --- a/src/modules/wallet/capital-api/depositHistory.ts +++ b/src/modules/wallet/capital-api/depositHistory.ts @@ -6,17 +6,19 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletDepositHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletDepositHistory", - "Get deposit history.", { - coin: z.string().optional().describe("Coin symbol"), - status: z.number().optional().describe("Deposit status"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - offset: z.number().optional().describe("Pagination offset"), - limit: z.number().optional().describe("Number of records to return"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get deposit history.", + inputSchema: { + coin: z.string().optional().describe("Coin symbol"), + status: z.number().optional().describe("Deposit status"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + offset: z.number().optional().describe("Pagination offset"), + limit: z.number().optional().describe("Number of records to return"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { try { diff --git a/src/modules/wallet/capital-api/fetchDepositAddressListWithNetwork.ts b/src/modules/wallet/capital-api/fetchDepositAddressListWithNetwork.ts index d3b67cd8..2b3c1d58 100644 --- a/src/modules/wallet/capital-api/fetchDepositAddressListWithNetwork.ts +++ b/src/modules/wallet/capital-api/fetchDepositAddressListWithNetwork.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletFetchDepositAddressListWithNetwork(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletFetchDepositAddressListWithNetwork", - "Fetch deposit address with network.", { - coin: z.string().describe("Coin symbol"), - network: z.string().optional().describe("Network"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Fetch deposit address with network.", + inputSchema: { + coin: z.string().describe("Coin symbol"), + network: z.string().optional().describe("Network"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ coin, network, recvWindow }) => { try { diff --git a/src/modules/wallet/capital-api/fetchWithdrawAddressList.ts b/src/modules/wallet/capital-api/fetchWithdrawAddressList.ts index 81b1e60b..954e3bb9 100644 --- a/src/modules/wallet/capital-api/fetchWithdrawAddressList.ts +++ b/src/modules/wallet/capital-api/fetchWithdrawAddressList.ts @@ -4,10 +4,9 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletFetchWithdrawAddressList(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletFetchWithdrawAddressList", - "Fetch withdraw address list.", - {}, + { description: "Fetch withdraw address list." }, async () => { try { const response = await walletClient.restAPI.fetchWithdrawAddressList(); diff --git a/src/modules/wallet/capital-api/oneClickArrivalDepositApply.ts b/src/modules/wallet/capital-api/oneClickArrivalDepositApply.ts index 0d064983..7d9b28f8 100644 --- a/src/modules/wallet/capital-api/oneClickArrivalDepositApply.ts +++ b/src/modules/wallet/capital-api/oneClickArrivalDepositApply.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletOneClickArrivalDepositApply(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletOneClickArrivalDepositApply", - "Apply for one-click arrival deposit.", { - subAccountId: z.string().optional().describe("Sub-account ID"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Apply for one-click arrival deposit.", + inputSchema: { + subAccountId: z.string().optional().describe("Sub-account ID"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ subAccountId, recvWindow }) => { try { diff --git a/src/modules/wallet/capital-api/withdraw.ts b/src/modules/wallet/capital-api/withdraw.ts index 5e7570d7..a0779f6f 100644 --- a/src/modules/wallet/capital-api/withdraw.ts +++ b/src/modules/wallet/capital-api/withdraw.ts @@ -6,20 +6,22 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletWithdraw(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletWithdraw", - "Submit a withdraw request.", { - coin: z.string().describe("Coin symbol"), - address: z.string().describe("Withdrawal address"), - amount: z.number().describe("Withdrawal amount"), - withdrawOrderId: z.string().optional().describe("Client order id"), - network: z.string().optional().describe("Network"), - addressTag: z.string().optional().describe("Secondary address identifier (tag/memo)"), - name: z.string().optional().describe("Address name"), - walletType: z.number().optional().describe("Wallet type"), - transactionFeeFlag: z.boolean().optional().describe("Pay fee with BNB"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Submit a withdraw request.", + inputSchema: { + coin: z.string().describe("Coin symbol"), + address: z.string().describe("Withdrawal address"), + amount: z.number().describe("Withdrawal amount"), + withdrawOrderId: z.string().optional().describe("Client order id"), + network: z.string().optional().describe("Network"), + addressTag: z.string().optional().describe("Secondary address identifier (tag/memo)"), + name: z.string().optional().describe("Address name"), + walletType: z.number().optional().describe("Wallet type"), + transactionFeeFlag: z.boolean().optional().describe("Pay fee with BNB"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ coin, diff --git a/src/modules/wallet/capital-api/withdrawHistory.ts b/src/modules/wallet/capital-api/withdrawHistory.ts index 98354666..3f1387b4 100644 --- a/src/modules/wallet/capital-api/withdrawHistory.ts +++ b/src/modules/wallet/capital-api/withdrawHistory.ts @@ -6,18 +6,20 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletWithdrawHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletWithdrawHistory", - "Get withdraw history.", { - coin: z.string().optional().describe("Coin symbol"), - withdrawOrderId: z.string().optional().describe("Withdraw order ID"), - status: z.number().optional().describe("Withdraw status"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - offset: z.number().optional().describe("Pagination offset"), - limit: z.number().optional().describe("Number of records to return"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get withdraw history.", + inputSchema: { + coin: z.string().optional().describe("Coin symbol"), + withdrawOrderId: z.string().optional().describe("Withdraw order ID"), + status: z.number().optional().describe("Withdraw status"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + offset: z.number().optional().describe("Pagination offset"), + limit: z.number().optional().describe("Number of records to return"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ coin, withdrawOrderId, status, startTime, endTime, offset, limit, recvWindow }) => { try { diff --git a/src/modules/wallet/others-api/getSymbolsDelistScheduleForSpot.ts b/src/modules/wallet/others-api/getSymbolsDelistScheduleForSpot.ts index f549aac9..1e61100b 100644 --- a/src/modules/wallet/others-api/getSymbolsDelistScheduleForSpot.ts +++ b/src/modules/wallet/others-api/getSymbolsDelistScheduleForSpot.ts @@ -4,10 +4,9 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletGetSymbolsDelistScheduleForSpot(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletGetSymbolsDelistScheduleForSpot", - "Get delist schedule for spot symbols.", - {}, + { description: "Get delist schedule for spot symbols." }, async () => { try { const response = await walletClient.restAPI.getSymbolsDelistScheduleForSpot(); diff --git a/src/modules/wallet/others-api/systemStatus.ts b/src/modules/wallet/others-api/systemStatus.ts index 5121f4a9..59a2d1fa 100644 --- a/src/modules/wallet/others-api/systemStatus.ts +++ b/src/modules/wallet/others-api/systemStatus.ts @@ -4,26 +4,30 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletSystemStatus(server: McpServer) { - server.tool("BinanceWalletSystemStatus", "Get Binance Wallet system status.", {}, async () => { - try { - const response = await walletClient.restAPI.systemStatus(); - const data = await response.data(); + server.registerTool( + "BinanceWalletSystemStatus", + { description: "Get Binance Wallet system status." }, + async () => { + try { + const response = await walletClient.restAPI.systemStatus(); + const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Retrieved system status. Response: ${JSON.stringify(data)}`, - }, - ], - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); + return { + content: [ + { + type: "text", + text: `Retrieved system status. Response: ${JSON.stringify(data)}`, + }, + ], + }; + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to retrieve system status: ${errorMessage}` }], - isError: true, - }; - } - }); + return { + content: [{ type: "text", text: `Failed to retrieve system status: ${errorMessage}` }], + isError: true, + }; + } + }, + ); } diff --git a/src/modules/wallet/travel-rule-api/brokerWithdraw.ts b/src/modules/wallet/travel-rule-api/brokerWithdraw.ts index 369ff418..bd2e8553 100644 --- a/src/modules/wallet/travel-rule-api/brokerWithdraw.ts +++ b/src/modules/wallet/travel-rule-api/brokerWithdraw.ts @@ -6,22 +6,24 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletBrokerWithdraw(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletBrokerWithdraw", - "Initiate broker withdrawal with travel rule compliance.", { - subAccountId: z.string().describe("Sub-account ID"), - address: z.string().describe("Withdrawal address"), - coin: z.string().describe("Coin symbol"), - amount: z.number().describe("Withdrawal amount"), - withdrawOrderId: z.string().describe("Client order id"), - questionnaire: z.string().describe("Travel rule questionnaire"), - originatorPii: z.string().describe("Originator PII information"), - signature: z.string().describe("Signature"), - network: z.string().optional().describe("Network"), - addressTag: z.string().optional().describe("Secondary address identifier"), - name: z.string().optional().describe("Address name"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Initiate broker withdrawal with travel rule compliance.", + inputSchema: { + subAccountId: z.string().describe("Sub-account ID"), + address: z.string().describe("Withdrawal address"), + coin: z.string().describe("Coin symbol"), + amount: z.number().describe("Withdrawal amount"), + withdrawOrderId: z.string().describe("Client order id"), + questionnaire: z.string().describe("Travel rule questionnaire"), + originatorPii: z.string().describe("Originator PII information"), + signature: z.string().describe("Signature"), + network: z.string().optional().describe("Network"), + addressTag: z.string().optional().describe("Secondary address identifier"), + name: z.string().optional().describe("Address name"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ subAccountId, diff --git a/src/modules/wallet/travel-rule-api/depositHistoryTravelRule.ts b/src/modules/wallet/travel-rule-api/depositHistoryTravelRule.ts index 90060bfd..c2c76658 100644 --- a/src/modules/wallet/travel-rule-api/depositHistoryTravelRule.ts +++ b/src/modules/wallet/travel-rule-api/depositHistoryTravelRule.ts @@ -6,17 +6,19 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletDepositHistoryTravelRule(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletDepositHistoryTravelRule", - "Get deposit history for travel rule.", { - coin: z.string().optional().describe("Coin symbol"), - status: z.number().optional().describe("Deposit status"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - offset: z.number().optional().describe("Default 0"), - limit: z.number().optional().describe("Default 1000, max 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get deposit history for travel rule.", + inputSchema: { + coin: z.string().optional().describe("Coin symbol"), + status: z.number().optional().describe("Deposit status"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + offset: z.number().optional().describe("Default 0"), + limit: z.number().optional().describe("Default 1000, max 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { try { diff --git a/src/modules/wallet/travel-rule-api/onboardedVaspList.ts b/src/modules/wallet/travel-rule-api/onboardedVaspList.ts index a0f4e7b1..98e0ff33 100644 --- a/src/modules/wallet/travel-rule-api/onboardedVaspList.ts +++ b/src/modules/wallet/travel-rule-api/onboardedVaspList.ts @@ -4,10 +4,9 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletOnboardedVaspList(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletOnboardedVaspList", - "Get list of onboarded VASPs (Virtual Asset Service Providers).", - {}, + { description: "Get list of onboarded VASPs (Virtual Asset Service Providers)." }, async () => { try { const response = await walletClient.restAPI.onboardedVaspList(); diff --git a/src/modules/wallet/travel-rule-api/submitDepositQuestionnaire.ts b/src/modules/wallet/travel-rule-api/submitDepositQuestionnaire.ts index 90fa2b14..588322ed 100644 --- a/src/modules/wallet/travel-rule-api/submitDepositQuestionnaire.ts +++ b/src/modules/wallet/travel-rule-api/submitDepositQuestionnaire.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletSubmitDepositQuestionnaire(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletSubmitDepositQuestionnaire", - "Submit deposit questionnaire for broker deposit.", { - subAccountId: z.string().describe("Sub-account ID"), - depositId: z.string().describe("Deposit ID"), - questionnaire: z.string().describe("Travel rule questionnaire"), - beneficiaryPii: z.string().describe("Beneficiary PII information"), - signature: z.string().describe("Signature"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Submit deposit questionnaire for broker deposit.", + inputSchema: { + subAccountId: z.string().describe("Sub-account ID"), + depositId: z.string().describe("Deposit ID"), + questionnaire: z.string().describe("Travel rule questionnaire"), + beneficiaryPii: z.string().describe("Beneficiary PII information"), + signature: z.string().describe("Signature"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ subAccountId, depositId, questionnaire, beneficiaryPii, signature, recvWindow }) => { try { diff --git a/src/modules/wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts b/src/modules/wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts index 10614549..674df61b 100644 --- a/src/modules/wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts +++ b/src/modules/wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletSubmitDepositQuestionnaireTravelRule(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletSubmitDepositQuestionnaireTravelRule", - "Submit deposit questionnaire for travel rule.", { - tranId: z.number().describe("Transaction ID"), - questionnaire: z.string().describe("Travel rule questionnaire"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Submit deposit questionnaire for travel rule.", + inputSchema: { + tranId: z.number().describe("Transaction ID"), + questionnaire: z.string().describe("Travel rule questionnaire"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ tranId, questionnaire, recvWindow }) => { try { diff --git a/src/modules/wallet/travel-rule-api/withdrawHistoryV1.ts b/src/modules/wallet/travel-rule-api/withdrawHistoryV1.ts index 7787b949..fe55168a 100644 --- a/src/modules/wallet/travel-rule-api/withdrawHistoryV1.ts +++ b/src/modules/wallet/travel-rule-api/withdrawHistoryV1.ts @@ -6,17 +6,19 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletWithdrawHistoryV1(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletWithdrawHistoryV1", - "Get withdraw history (v1).", { - coin: z.string().optional().describe("Coin symbol"), - status: z.number().optional().describe("Withdraw status"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - offset: z.number().optional().describe("Default 0"), - limit: z.number().optional().describe("Default 1000, max 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get withdraw history (v1).", + inputSchema: { + coin: z.string().optional().describe("Coin symbol"), + status: z.number().optional().describe("Withdraw status"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + offset: z.number().optional().describe("Default 0"), + limit: z.number().optional().describe("Default 1000, max 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { try { diff --git a/src/modules/wallet/travel-rule-api/withdrawHistoryV2.ts b/src/modules/wallet/travel-rule-api/withdrawHistoryV2.ts index 5370bb7d..d61d6dc9 100644 --- a/src/modules/wallet/travel-rule-api/withdrawHistoryV2.ts +++ b/src/modules/wallet/travel-rule-api/withdrawHistoryV2.ts @@ -6,17 +6,19 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletWithdrawHistoryV2(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletWithdrawHistoryV2", - "Get withdraw history (v2).", { - coin: z.string().optional().describe("Coin symbol"), - status: z.number().optional().describe("Withdraw status"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - offset: z.number().optional().describe("Default 0"), - limit: z.number().optional().describe("Default 1000, max 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get withdraw history (v2).", + inputSchema: { + coin: z.string().optional().describe("Coin symbol"), + status: z.number().optional().describe("Withdraw status"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + offset: z.number().optional().describe("Default 0"), + limit: z.number().optional().describe("Default 1000, max 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { try { diff --git a/src/modules/wallet/travel-rule-api/withdrawTravelRule.ts b/src/modules/wallet/travel-rule-api/withdrawTravelRule.ts index 3c13a06f..279066f1 100644 --- a/src/modules/wallet/travel-rule-api/withdrawTravelRule.ts +++ b/src/modules/wallet/travel-rule-api/withdrawTravelRule.ts @@ -6,19 +6,21 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletWithdrawTravelRule(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletWithdrawTravelRule", - "Withdraw with travel rule compliance.", { - coin: z.string().describe("Coin symbol"), - address: z.string().describe("Withdrawal address"), - amount: z.number().describe("Withdrawal amount"), - withdrawOrderId: z.string().optional().describe("Client order id"), - network: z.string().optional().describe("Network"), - addressTag: z.string().optional().describe("Secondary address identifier"), - name: z.string().optional().describe("Address name"), - questionnaire: z.string().describe("Travel rule questionnaire"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Withdraw with travel rule compliance.", + inputSchema: { + coin: z.string().describe("Coin symbol"), + address: z.string().describe("Withdrawal address"), + amount: z.number().describe("Withdrawal amount"), + withdrawOrderId: z.string().optional().describe("Client order id"), + network: z.string().optional().describe("Network"), + addressTag: z.string().optional().describe("Secondary address identifier"), + name: z.string().optional().describe("Address name"), + questionnaire: z.string().describe("Travel rule questionnaire"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ coin, diff --git a/src/tools/account/index.ts b/src/tools/account/index.ts index 4806195d..d6f7b87c 100644 --- a/src/tools/account/index.ts +++ b/src/tools/account/index.ts @@ -20,14 +20,17 @@ export function registerAccountTools(server: McpServer) { // binance_us_account_info // GET /api/v3/account // ===================================================== - server.tool( + server.registerTool( "binance_us_account_info", - "Get current account information including balances and permissions. Returns all asset balances (free and locked), account permissions, and trading status.", { - recvWindow: z - .number() - .optional() - .describe("The value cannot be greater than 60000. Default: 5000"), + description: + "Get current account information including balances and permissions. Returns all asset balances (free and locked), account permissions, and trading status.", + inputSchema: { + recvWindow: z + .number() + .optional() + .describe("The value cannot be greater than 60000. Default: 5000"), + }, }, async ({ recvWindow }) => { try { @@ -82,20 +85,26 @@ export function registerAccountTools(server: McpServer) { // binance_us_my_trades // GET /api/v3/myTrades // ===================================================== - server.tool( + server.registerTool( "binance_us_my_trades", - "Get trade history for a specific trading pair. Returns executed trades including price, quantity, commission, and timestamps.", { - symbol: z.string().describe("Trading pair symbol, e.g., BTCUSD, ETHUSD"), - orderId: z.number().optional().describe("Filter by order ID"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - fromId: z - .number() - .optional() - .describe("Trade ID to fetch from. Default gets most recent trades."), - limit: z.number().optional().describe("Number of trades to return. Default: 500, Max: 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: + "Get trade history for a specific trading pair. Returns executed trades including price, quantity, commission, and timestamps.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol, e.g., BTCUSD, ETHUSD"), + orderId: z.number().optional().describe("Filter by order ID"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + fromId: z + .number() + .optional() + .describe("Trade ID to fetch from. Default gets most recent trades."), + limit: z + .number() + .optional() + .describe("Number of trades to return. Default: 500, Max: 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ symbol, orderId, startTime, endTime, fromId, limit, recvWindow }) => { try { @@ -132,11 +141,14 @@ export function registerAccountTools(server: McpServer) { // binance_us_rate_limits // GET /api/v3/rateLimit/order // ===================================================== - server.tool( + server.registerTool( "binance_us_rate_limits", - "Get current trade order count rate limits for all time intervals. Shows how many orders you can place within each interval.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: + "Get current trade order count rate limits for all time intervals. Shows how many orders you can place within each interval.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { @@ -168,15 +180,18 @@ export function registerAccountTools(server: McpServer) { // binance_us_trade_fee // GET /sapi/v1/asset/query/trading-fee // ===================================================== - server.tool( + server.registerTool( "binance_us_trade_fee", - "Get your current maker & taker fee rates for spot trading based on your VIP level. BNB fee discount (25% off) is not factored in.", { - symbol: z - .string() - .optional() - .describe("Trading pair symbol. If not specified, returns fees for all symbols."), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: + "Get your current maker & taker fee rates for spot trading based on your VIP level. BNB fee discount (25% off) is not factored in.", + inputSchema: { + symbol: z + .string() + .optional() + .describe("Trading pair symbol. If not specified, returns fees for all symbols."), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ symbol, recvWindow }) => { try { @@ -209,11 +224,14 @@ export function registerAccountTools(server: McpServer) { // binance_us_trade_volume // GET /sapi/v1/asset/query/trading-volume // ===================================================== - server.tool( + server.registerTool( "binance_us_trade_volume", - "Get total trade volume for the past 30 days. Volume is calculated on a rolling basis every day at 0:00 AM (UTC).", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: + "Get total trade volume for the past 30 days. Volume is calculated on a rolling basis every day at 0:00 AM (UTC).", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/tools/binance-algo/future-algo/TwapNewTrade.ts b/src/tools/binance-algo/future-algo/TwapNewTrade.ts index cc8c2713..89aef9f6 100644 --- a/src/tools/binance-algo/future-algo/TwapNewTrade.ts +++ b/src/tools/binance-algo/future-algo/TwapNewTrade.ts @@ -6,47 +6,50 @@ import { z } from "zod"; import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceTwapNewTrade(server: McpServer) { - server.tool( + server.registerTool( "BinanceTimeWeightedAveragePriceNewOrder", - "The Time-Weighted Average Price (TWAP) New Order API allows users to place a TWAP order on USDⓈ-M Contracts in Binance Futures. TWAP orders execute gradually over a specified duration to achieve a better average execution price while minimizing market impact.", { - symbol: z.string().describe("Trading symbol (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Trading side (BUY or SELL)"), - positionSide: z - .enum(["BOTH", "LONG", "SHORT"]) - .optional() - .describe( - "Default BOTH for One-way Mode; LONG or SHORT for Hedge Mode. Must be sent in Hedge Mode.", - ), - quantity: z - .number() - .positive() - .min(1000) - .max(1000000) - .describe("Quantity of base asset; Notional must be between 1,000 and 1,000,000 USDT"), - duration: z - .number() - .int() - .min(300) - .max(86400) - .describe("Duration for TWAP orders in seconds. Must be between 300 and 86400"), - clientAlgoId: z - .string() - .length(32) - .optional() - .describe("A unique 32-character ID among Algo orders"), - reduceOnly: z - .boolean() - .optional() - .describe( - "true or false. Default false; Cannot be sent in Hedge Mode or when opening a position", - ), - limitPrice: z - .number() - .positive() - .optional() - .describe("Limit price of the order; Defaults to market price if not sent"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "The Time-Weighted Average Price (TWAP) New Order API allows users to place a TWAP order on USDⓈ-M Contracts in Binance Futures. TWAP orders execute gradually over a specified duration to achieve a better average execution price while minimizing market impact.", + inputSchema: { + symbol: z.string().describe("Trading symbol (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Trading side (BUY or SELL)"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe( + "Default BOTH for One-way Mode; LONG or SHORT for Hedge Mode. Must be sent in Hedge Mode.", + ), + quantity: z + .number() + .positive() + .min(1000) + .max(1000000) + .describe("Quantity of base asset; Notional must be between 1,000 and 1,000,000 USDT"), + duration: z + .number() + .int() + .min(300) + .max(86400) + .describe("Duration for TWAP orders in seconds. Must be between 300 and 86400"), + clientAlgoId: z + .string() + .length(32) + .optional() + .describe("A unique 32-character ID among Algo orders"), + reduceOnly: z + .boolean() + .optional() + .describe( + "true or false. Default false; Cannot be sent in Hedge Mode or when opening a position", + ), + limitPrice: z + .number() + .positive() + .optional() + .describe("Limit price of the order; Defaults to market price if not sent"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-algo/future-algo/VPNewTrade.ts b/src/tools/binance-algo/future-algo/VPNewTrade.ts index 007c0f01..66056935 100644 --- a/src/tools/binance-algo/future-algo/VPNewTrade.ts +++ b/src/tools/binance-algo/future-algo/VPNewTrade.ts @@ -6,42 +6,45 @@ import { z } from "zod"; import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceVPNewTrade(server: McpServer) { - server.tool( + server.registerTool( "BinanceVolumeParticipationNewTrade", - "The Volume Participation (VP) New Order API allows users to place a VP order on USDⓈ-M Contracts in Binance Futures.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Trading side (BUY or SELL)"), - positionSide: z - .enum(["BOTH", "LONG", "SHORT"]) - .optional() - .describe( - "Default BOTH for One-way Mode; LONG or SHORT for Hedge Mode. It must be sent in Hedge Mode.", - ), - quantity: z - .number() - .positive() - .min(10000) - .max(1000000) - .describe("Quantity of base asset; Notional must be between 10,000 and 1,000,000 USDT"), - urgency: z.enum(["LOW", "MEDIUM", "HIGH"]).describe("Execution speed: LOW, MEDIUM, HIGH"), - clientAlgoId: z - .string() - .length(32) - .optional() - .describe("A unique 32-character ID among Algo orders"), - reduceOnly: z - .boolean() - .optional() - .describe( - "true or false. Default false; Cannot be sent in Hedge Mode or when opening a position", - ), - limitPrice: z - .number() - .positive() - .optional() - .describe("Limit price of the order; Defaults to market price if not sent"), - recvWindow: z.number().int().describe("Time window for request validity"), + description: + "The Volume Participation (VP) New Order API allows users to place a VP order on USDⓈ-M Contracts in Binance Futures.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Trading side (BUY or SELL)"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe( + "Default BOTH for One-way Mode; LONG or SHORT for Hedge Mode. It must be sent in Hedge Mode.", + ), + quantity: z + .number() + .positive() + .min(10000) + .max(1000000) + .describe("Quantity of base asset; Notional must be between 10,000 and 1,000,000 USDT"), + urgency: z.enum(["LOW", "MEDIUM", "HIGH"]).describe("Execution speed: LOW, MEDIUM, HIGH"), + clientAlgoId: z + .string() + .length(32) + .optional() + .describe("A unique 32-character ID among Algo orders"), + reduceOnly: z + .boolean() + .optional() + .describe( + "true or false. Default false; Cannot be sent in Hedge Mode or when opening a position", + ), + limitPrice: z + .number() + .positive() + .optional() + .describe("Limit price of the order; Defaults to market price if not sent"), + recvWindow: z.number().int().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-algo/future-algo/cancelAlgoOrder.ts b/src/tools/binance-algo/future-algo/cancelAlgoOrder.ts index d41e0867..4fc24f40 100644 --- a/src/tools/binance-algo/future-algo/cancelAlgoOrder.ts +++ b/src/tools/binance-algo/future-algo/cancelAlgoOrder.ts @@ -6,12 +6,15 @@ import { z } from "zod"; import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceFutureCancelAlgoOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceFutureCancelAlgoOrder", - "The Cancel Algo Order API allows users to cancel an active algorithmic order on USDⓈ-M Contracts in Binance Futures.", { - algoId: z.number().int().describe("Algo order ID (e.g., 14511)"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "The Cancel Algo Order API allows users to cancel an active algorithmic order on USDⓈ-M Contracts in Binance Futures.", + inputSchema: { + algoId: z.number().int().describe("Algo order ID (e.g., 14511)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-algo/future-algo/currentAlgoOpenOrders.ts b/src/tools/binance-algo/future-algo/currentAlgoOpenOrders.ts index 1001a67b..32dda635 100644 --- a/src/tools/binance-algo/future-algo/currentAlgoOpenOrders.ts +++ b/src/tools/binance-algo/future-algo/currentAlgoOpenOrders.ts @@ -6,11 +6,14 @@ import { z } from "zod"; import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceFutureCurrentAlgoOpenOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceFutureCurrentAlgoOpenOrders", - "The Query Current Algo Open Orders API retrieves a list of currently active algorithmic orders for USDⓈ-M Contracts in Binance Futures.", { - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "The Query Current Algo Open Orders API retrieves a list of currently active algorithmic orders for USDⓈ-M Contracts in Binance Futures.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-algo/future-algo/historicalAlgoOrder.ts b/src/tools/binance-algo/future-algo/historicalAlgoOrder.ts index edafa7a9..2e693e63 100644 --- a/src/tools/binance-algo/future-algo/historicalAlgoOrder.ts +++ b/src/tools/binance-algo/future-algo/historicalAlgoOrder.ts @@ -6,32 +6,35 @@ import { z } from "zod"; import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceFutureHistoricalAlgoOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceFutureHistoricalAlgoOrder", - "The Query Historical Algo Orders API retrieves a list of past algorithmic orders for USDⓈ-M Contracts in Binance Futures.", { - symbol: z.string().optional().describe("Trading symbol (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).optional().describe("Trading side (BUY or SELL)"), - startTime: z - .number() - .int() - .optional() - .describe("Start time in milliseconds (e.g., 1641522717552)"), - endTime: z - .number() - .int() - .optional() - .describe("End time in milliseconds (e.g., 1641522526562)"), - page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), - pageSize: z - .number() - .int() - .min(1) - .max(100) - .default(100) - .optional() - .describe("Number of results per page, MIN 1, MAX 100, default is 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "The Query Historical Algo Orders API retrieves a list of past algorithmic orders for USDⓈ-M Contracts in Binance Futures.", + inputSchema: { + symbol: z.string().optional().describe("Trading symbol (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).optional().describe("Trading side (BUY or SELL)"), + startTime: z + .number() + .int() + .optional() + .describe("Start time in milliseconds (e.g., 1641522717552)"), + endTime: z + .number() + .int() + .optional() + .describe("End time in milliseconds (e.g., 1641522526562)"), + page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), + pageSize: z + .number() + .int() + .min(1) + .max(100) + .default(100) + .optional() + .describe("Number of results per page, MIN 1, MAX 100, default is 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-algo/future-algo/subOrders.ts b/src/tools/binance-algo/future-algo/subOrders.ts index e0306890..f36cbc6d 100644 --- a/src/tools/binance-algo/future-algo/subOrders.ts +++ b/src/tools/binance-algo/future-algo/subOrders.ts @@ -6,21 +6,24 @@ import { z } from "zod"; import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceFutureSubOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceFutureSubOrders", - "The Sub Orders API retrieves sub-orders associated with a specified algoId for USDⓈ-M Contracts in Binance Futures.", { - algoId: z.number().int().describe("Algo order ID"), - page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), - pageSize: z - .number() - .int() - .min(1) - .max(100) - .default(100) - .optional() - .describe("Number of results per page, MIN 1, MAX 100, default is 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "The Sub Orders API retrieves sub-orders associated with a specified algoId for USDⓈ-M Contracts in Binance Futures.", + inputSchema: { + algoId: z.number().int().describe("Algo order ID"), + page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), + pageSize: z + .number() + .int() + .min(1) + .max(100) + .default(100) + .optional() + .describe("Number of results per page, MIN 1, MAX 100, default is 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-algo/spot-algo/cancelOpenTWAPOrder.ts b/src/tools/binance-algo/spot-algo/cancelOpenTWAPOrder.ts index 3652e326..e2068e02 100644 --- a/src/tools/binance-algo/spot-algo/cancelOpenTWAPOrder.ts +++ b/src/tools/binance-algo/spot-algo/cancelOpenTWAPOrder.ts @@ -6,12 +6,15 @@ import { z } from "zod"; import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceSpotCancelOpenTWAPOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceSpotCancelOpenTWAPOrder", - "The Cancel Algo Order API allows users to cancel an open TWAP algorithmic order for spot trading on Binance.", { - algoId: z.number().int().describe("Algo order ID (e.g., 14511)"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "The Cancel Algo Order API allows users to cancel an open TWAP algorithmic order for spot trading on Binance.", + inputSchema: { + algoId: z.number().int().describe("Algo order ID (e.g., 14511)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-algo/spot-algo/currentAlgoOpenOrders.ts b/src/tools/binance-algo/spot-algo/currentAlgoOpenOrders.ts index 28bca403..ad57c20a 100644 --- a/src/tools/binance-algo/spot-algo/currentAlgoOpenOrders.ts +++ b/src/tools/binance-algo/spot-algo/currentAlgoOpenOrders.ts @@ -6,11 +6,14 @@ import { z } from "zod"; import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceSpotCurrentAlgoOpenOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceSpotCurrentAlgoOpenOrders", - "This API retrieves all open SPOT TWAP (Time-Weighted Average Price) orders on Binance.", { - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "This API retrieves all open SPOT TWAP (Time-Weighted Average Price) orders on Binance.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-algo/spot-algo/historicalAlgoOrders.ts b/src/tools/binance-algo/spot-algo/historicalAlgoOrders.ts index bcdba16c..9c26464b 100644 --- a/src/tools/binance-algo/spot-algo/historicalAlgoOrders.ts +++ b/src/tools/binance-algo/spot-algo/historicalAlgoOrders.ts @@ -6,32 +6,35 @@ import { z } from "zod"; import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceSpotHistoricalAlgoOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceSpotHistoricalAlgoOrders", - "This API retrieves all historical SPOT TWAP (Time-Weighted Average Price) orders from Binance.", { - symbol: z.string().optional().describe("Trading symbol (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).optional().describe("Trading side (BUY or SELL)"), - startTime: z - .number() - .int() - .optional() - .describe("Start time in milliseconds (e.g., 1641522717552)"), - endTime: z - .number() - .int() - .optional() - .describe("End time in milliseconds (e.g., 1641522526562)"), - page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), - pageSize: z - .number() - .int() - .min(1) - .max(100) - .default(100) - .optional() - .describe("Number of results per page, MIN 1, MAX 100, default is 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "This API retrieves all historical SPOT TWAP (Time-Weighted Average Price) orders from Binance.", + inputSchema: { + symbol: z.string().optional().describe("Trading symbol (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).optional().describe("Trading side (BUY or SELL)"), + startTime: z + .number() + .int() + .optional() + .describe("Start time in milliseconds (e.g., 1641522717552)"), + endTime: z + .number() + .int() + .optional() + .describe("End time in milliseconds (e.g., 1641522526562)"), + page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), + pageSize: z + .number() + .int() + .min(1) + .max(100) + .default(100) + .optional() + .describe("Number of results per page, MIN 1, MAX 100, default is 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-algo/spot-algo/spotTWAPOrder.ts b/src/tools/binance-algo/spot-algo/spotTWAPOrder.ts index 05f6b156..0d69adf7 100644 --- a/src/tools/binance-algo/spot-algo/spotTWAPOrder.ts +++ b/src/tools/binance-algo/spot-algo/spotTWAPOrder.ts @@ -6,36 +6,39 @@ import { z } from "zod"; import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceSpotTwapNewTrade(server: McpServer) { - server.tool( + server.registerTool( "BinanceSpotTimeWeightedAveragePriceNewOrder", - "The TWAP (Time-Weighted Average Price) New Order API allows users to place TWAP algorithmic orders for USDⓈ-M Futures on Binance.", { - symbol: z.string().describe("Trading symbol (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Trading side (BUY or SELL)"), - quantity: z - .number() - .positive() - .describe( - "Quantity of base asset; Maximum notional per order is 200k, 2mm, or 10mm, depending on the symbol", - ), - duration: z - .number() - .int() - .min(300) - .max(86400) - .describe("Duration for TWAP orders in seconds. Must be between 300 and 86400"), - clientAlgoId: z - .string() - .length(32) - .optional() - .describe( - "A unique 32-character ID among Algo orders. If not sent, a default value will be assigned", - ), - limitPrice: z - .number() - .positive() - .optional() - .describe("Limit price of the order; Defaults to market price if not sent"), + description: + "The TWAP (Time-Weighted Average Price) New Order API allows users to place TWAP algorithmic orders for USDⓈ-M Futures on Binance.", + inputSchema: { + symbol: z.string().describe("Trading symbol (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Trading side (BUY or SELL)"), + quantity: z + .number() + .positive() + .describe( + "Quantity of base asset; Maximum notional per order is 200k, 2mm, or 10mm, depending on the symbol", + ), + duration: z + .number() + .int() + .min(300) + .max(86400) + .describe("Duration for TWAP orders in seconds. Must be between 300 and 86400"), + clientAlgoId: z + .string() + .length(32) + .optional() + .describe( + "A unique 32-character ID among Algo orders. If not sent, a default value will be assigned", + ), + limitPrice: z + .number() + .positive() + .optional() + .describe("Limit price of the order; Defaults to market price if not sent"), + }, }, async (params) => { try { diff --git a/src/tools/binance-algo/spot-algo/subOrders.ts b/src/tools/binance-algo/spot-algo/subOrders.ts index 03bd51f7..ba459141 100644 --- a/src/tools/binance-algo/spot-algo/subOrders.ts +++ b/src/tools/binance-algo/spot-algo/subOrders.ts @@ -6,21 +6,24 @@ import { z } from "zod"; import { algoClient } from "../../../config/binanceClient.js"; export function registerBinanceSpotSubOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceSpotSubOrders", - "The Query Sub Orders API retrieves details of sub-orders associated with a specific algorithmic (Algo) order for spot trading on Binance.", { - algoId: z.number().int().describe("Algo order ID"), - page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), - pageSize: z - .number() - .int() - .min(1) - .max(100) - .default(100) - .optional() - .describe("Number of results per page, MIN 1, MAX 100, default is 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "The Query Sub Orders API retrieves details of sub-orders associated with a specific algorithmic (Algo) order for spot trading on Binance.", + inputSchema: { + algoId: z.number().int().describe("Algo order ID"), + page: z.number().int().min(1).default(1).optional().describe("Page number, default is 1"), + pageSize: z + .number() + .int() + .min(1) + .max(100) + .default(100) + .optional() + .describe("Number of results per page, MIN 1, MAX 100, default is 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-auto-invest/changeIndexPlanStatus.ts b/src/tools/binance-auto-invest/changeIndexPlanStatus.ts index d451c76c..fc5ee01c 100644 --- a/src/tools/binance-auto-invest/changeIndexPlanStatus.ts +++ b/src/tools/binance-auto-invest/changeIndexPlanStatus.ts @@ -12,13 +12,15 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestChangeIndexPlanStatus(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestChangeIndexPlanStatus", - "Change the status of an index-linked auto-invest plan (pause/resume).", { - indexId: z.number().int().describe("Index ID"), - status: z.enum(["PAUSED", "ONGOING"]).describe("New plan status"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Change the status of an index-linked auto-invest plan (pause/resume).", + inputSchema: { + indexId: z.number().int().describe("Index ID"), + status: z.enum(["PAUSED", "ONGOING"]).describe("New plan status"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-auto-invest/changePlanStatus.ts b/src/tools/binance-auto-invest/changePlanStatus.ts index db103e2b..c1df225b 100644 --- a/src/tools/binance-auto-invest/changePlanStatus.ts +++ b/src/tools/binance-auto-invest/changePlanStatus.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestChangePlanStatus(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestChangePlanStatus", - "Change plan status (pause/resume) for auto-invest.", { - planId: z.number().describe("Plan ID"), - status: z.enum(["ONGOING", "PAUSED", "REMOVED"]).describe("New plan status"), + description: "Change plan status (pause/resume) for auto-invest.", + inputSchema: { + planId: z.number().describe("Plan ID"), + status: z.enum(["ONGOING", "PAUSED", "REMOVED"]).describe("New plan status"), + }, }, async ({ planId, status }) => { try { diff --git a/src/tools/binance-auto-invest/createPlan.ts b/src/tools/binance-auto-invest/createPlan.ts index 07dcc186..b4aea6c2 100644 --- a/src/tools/binance-auto-invest/createPlan.ts +++ b/src/tools/binance-auto-invest/createPlan.ts @@ -6,25 +6,27 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestCreatePlan(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestCreatePlan", - "Create an investment plan for auto-invest.", { - sourceType: z.enum(["MAIN_SITE", "TR"]).describe("Source type"), - planType: z.enum(["SINGLE", "PORTFOLIO", "INDEX"]).describe("Plan type"), - subscriptionAmount: z.number().describe("Subscription amount"), - subscriptionCycle: z - .enum(["H1", "H4", "H8", "H12", "WEEKLY", "DAILY", "MONTHLY", "BI_WEEKLY"]) - .describe("Subscription cycle"), - subscriptionStartTime: z.string().describe("Subscription start time"), - sourceAsset: z.string().describe("Source asset (e.g., USDT)"), - flexibleAllowedToUse: z - .boolean() - .optional() - .describe("Whether flexible products are allowed to use"), - details: z - .string() - .describe("JSON array of plan details including targetAsset and percentage"), + description: "Create an investment plan for auto-invest.", + inputSchema: { + sourceType: z.enum(["MAIN_SITE", "TR"]).describe("Source type"), + planType: z.enum(["SINGLE", "PORTFOLIO", "INDEX"]).describe("Plan type"), + subscriptionAmount: z.number().describe("Subscription amount"), + subscriptionCycle: z + .enum(["H1", "H4", "H8", "H12", "WEEKLY", "DAILY", "MONTHLY", "BI_WEEKLY"]) + .describe("Subscription cycle"), + subscriptionStartTime: z.string().describe("Subscription start time"), + sourceAsset: z.string().describe("Source asset (e.g., USDT)"), + flexibleAllowedToUse: z + .boolean() + .optional() + .describe("Whether flexible products are allowed to use"), + details: z + .string() + .describe("JSON array of plan details including targetAsset and percentage"), + }, }, async ({ sourceType, diff --git a/src/tools/binance-auto-invest/editPlan.ts b/src/tools/binance-auto-invest/editPlan.ts index d0957529..4d6911db 100644 --- a/src/tools/binance-auto-invest/editPlan.ts +++ b/src/tools/binance-auto-invest/editPlan.ts @@ -6,26 +6,28 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestEditPlan(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestEditPlan", - "Edit an existing investment plan for auto-invest.", { - planId: z.number().describe("Plan ID to edit"), - subscriptionAmount: z.number().optional().describe("Subscription amount"), - subscriptionCycle: z - .enum(["H1", "H4", "H8", "H12", "WEEKLY", "DAILY", "MONTHLY", "BI_WEEKLY"]) - .optional() - .describe("Subscription cycle"), - subscriptionStartTime: z.string().optional().describe("Subscription start time"), - sourceAsset: z.string().optional().describe("Source asset (e.g., USDT)"), - flexibleAllowedToUse: z - .boolean() - .optional() - .describe("Whether flexible products are allowed to use"), - details: z - .string() - .optional() - .describe("JSON array of plan details including targetAsset and percentage"), + description: "Edit an existing investment plan for auto-invest.", + inputSchema: { + planId: z.number().describe("Plan ID to edit"), + subscriptionAmount: z.number().optional().describe("Subscription amount"), + subscriptionCycle: z + .enum(["H1", "H4", "H8", "H12", "WEEKLY", "DAILY", "MONTHLY", "BI_WEEKLY"]) + .optional() + .describe("Subscription cycle"), + subscriptionStartTime: z.string().optional().describe("Subscription start time"), + sourceAsset: z.string().optional().describe("Source asset (e.g., USDT)"), + flexibleAllowedToUse: z + .boolean() + .optional() + .describe("Whether flexible products are allowed to use"), + details: z + .string() + .optional() + .describe("JSON array of plan details including targetAsset and percentage"), + }, }, async ({ planId, diff --git a/src/tools/binance-auto-invest/getHistoryList.ts b/src/tools/binance-auto-invest/getHistoryList.ts index ac7573ae..27b7ad8e 100644 --- a/src/tools/binance-auto-invest/getHistoryList.ts +++ b/src/tools/binance-auto-invest/getHistoryList.ts @@ -12,21 +12,28 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestGetHistoryList(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestGetHistoryList", - "Get auto-invest transaction history. View all past purchases and investments.", { - planId: z.number().int().optional().describe("Filter by plan ID"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - targetAsset: z.string().optional().describe("Filter by target asset"), - planType: z - .enum(["SINGLE", "PORTFOLIO", "INDEX", "ALL"]) - .optional() - .describe("Filter by plan type"), - size: z.number().int().max(100).optional().describe("Number of results. Default 10, max 100"), - current: z.number().int().optional().describe("Current page. Default 1"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Get auto-invest transaction history. View all past purchases and investments.", + inputSchema: { + planId: z.number().int().optional().describe("Filter by plan ID"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + targetAsset: z.string().optional().describe("Filter by target asset"), + planType: z + .enum(["SINGLE", "PORTFOLIO", "INDEX", "ALL"]) + .optional() + .describe("Filter by plan type"), + size: z + .number() + .int() + .max(100) + .optional() + .describe("Number of results. Default 10, max 100"), + current: z.number().int().optional().describe("Current page. Default 1"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-auto-invest/getIndexInfo.ts b/src/tools/binance-auto-invest/getIndexInfo.ts index 2c3c8705..505d000a 100644 --- a/src/tools/binance-auto-invest/getIndexInfo.ts +++ b/src/tools/binance-auto-invest/getIndexInfo.ts @@ -12,12 +12,15 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestGetIndexInfo(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestGetIndexInfo", - "Get information about auto-invest index portfolios. Index portfolios are pre-built diversified portfolios.", { - indexId: z.number().int().optional().describe("Specific index ID to query"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Get information about auto-invest index portfolios. Index portfolios are pre-built diversified portfolios.", + inputSchema: { + indexId: z.number().int().optional().describe("Specific index ID to query"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-auto-invest/getIndexLinkedPlanPositionDetails.ts b/src/tools/binance-auto-invest/getIndexLinkedPlanPositionDetails.ts index ed93bf1e..b4d68360 100644 --- a/src/tools/binance-auto-invest/getIndexLinkedPlanPositionDetails.ts +++ b/src/tools/binance-auto-invest/getIndexLinkedPlanPositionDetails.ts @@ -12,12 +12,14 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestGetIndexLinkedPlanPositionDetails(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestGetIndexLinkedPlanPositionDetails", - "Get position details for an index-linked auto-invest plan.", { - indexId: z.number().int().describe("Index ID"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Get position details for an index-linked auto-invest plan.", + inputSchema: { + indexId: z.number().int().describe("Index ID"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-auto-invest/getIndexLinkedPlanPositionList.ts b/src/tools/binance-auto-invest/getIndexLinkedPlanPositionList.ts index 96dd765e..c4236ac0 100644 --- a/src/tools/binance-auto-invest/getIndexLinkedPlanPositionList.ts +++ b/src/tools/binance-auto-invest/getIndexLinkedPlanPositionList.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestGetIndexLinkedPlanPositionList(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestGetIndexLinkedPlanPositionList", - "Query index linked plan position details for auto-invest.", { - indexId: z.number().describe("Index ID"), + description: "Query index linked plan position details for auto-invest.", + inputSchema: { + indexId: z.number().describe("Index ID"), + }, }, async ({ indexId }) => { try { diff --git a/src/tools/binance-auto-invest/getIndexLinkedPlanRebalanceHistory.ts b/src/tools/binance-auto-invest/getIndexLinkedPlanRebalanceHistory.ts index ec31435d..551c111a 100644 --- a/src/tools/binance-auto-invest/getIndexLinkedPlanRebalanceHistory.ts +++ b/src/tools/binance-auto-invest/getIndexLinkedPlanRebalanceHistory.ts @@ -6,15 +6,17 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestGetIndexLinkedPlanRebalanceHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestGetIndexLinkedPlanRebalanceHistory", - "Query index linked plan rebalance history for auto-invest.", { - indexId: z.number().describe("Index ID"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - current: z.number().optional().describe("Current page"), - size: z.number().optional().describe("Page size"), + description: "Query index linked plan rebalance history for auto-invest.", + inputSchema: { + indexId: z.number().describe("Index ID"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + current: z.number().optional().describe("Current page"), + size: z.number().optional().describe("Page size"), + }, }, async ({ indexId, startTime, endTime, current, size }) => { try { diff --git a/src/tools/binance-auto-invest/getIndexUserSummary.ts b/src/tools/binance-auto-invest/getIndexUserSummary.ts index d3576350..97989f4b 100644 --- a/src/tools/binance-auto-invest/getIndexUserSummary.ts +++ b/src/tools/binance-auto-invest/getIndexUserSummary.ts @@ -12,12 +12,15 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestGetIndexUserSummary(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestGetIndexUserSummary", - "Get user's index-linked plan summary including total invested and current value.", { - indexId: z.number().int().describe("Index ID to query"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Get user's index-linked plan summary including total invested and current value.", + inputSchema: { + indexId: z.number().int().describe("Index ID to query"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-auto-invest/getOneTimePlans.ts b/src/tools/binance-auto-invest/getOneTimePlans.ts index 48bbfda2..52ddb5d2 100644 --- a/src/tools/binance-auto-invest/getOneTimePlans.ts +++ b/src/tools/binance-auto-invest/getOneTimePlans.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestGetOneTimePlans(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestGetOneTimePlans", - "Query holding details of the plan.", { - planId: z.number().describe("Plan ID"), - requestId: z.string().optional().describe("Request ID"), + description: "Query holding details of the plan.", + inputSchema: { + planId: z.number().describe("Plan ID"), + requestId: z.string().optional().describe("Request ID"), + }, }, async ({ planId, requestId }) => { try { diff --git a/src/tools/binance-auto-invest/getPlanList.ts b/src/tools/binance-auto-invest/getPlanList.ts index f42ac288..1202892a 100644 --- a/src/tools/binance-auto-invest/getPlanList.ts +++ b/src/tools/binance-auto-invest/getPlanList.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestGetPlanList(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestGetPlanList", - "Query auto-invest plan list.", { - planType: z.enum(["SINGLE", "PORTFOLIO", "INDEX"]).optional().describe("Plan type"), + description: "Query auto-invest plan list.", + inputSchema: { + planType: z.enum(["SINGLE", "PORTFOLIO", "INDEX"]).optional().describe("Plan type"), + }, }, async ({ planType }) => { try { diff --git a/src/tools/binance-auto-invest/getSourceAssetList.ts b/src/tools/binance-auto-invest/getSourceAssetList.ts index 2bd3adcf..b9d3ef85 100644 --- a/src/tools/binance-auto-invest/getSourceAssetList.ts +++ b/src/tools/binance-auto-invest/getSourceAssetList.ts @@ -6,17 +6,19 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestGetSourceAssetList(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestGetSourceAssetList", - "Get source asset list for auto-invest.", { - usageType: z.string().optional().describe("Usage type"), - targetAsset: z.string().optional().describe("Target asset (e.g., BTC)"), - indexId: z.number().optional().describe("Index ID"), - flexibleAllowedToUse: z - .boolean() - .optional() - .describe("Whether flexible products are allowed to use"), + description: "Get source asset list for auto-invest.", + inputSchema: { + usageType: z.string().optional().describe("Usage type"), + targetAsset: z.string().optional().describe("Target asset (e.g., BTC)"), + indexId: z.number().optional().describe("Index ID"), + flexibleAllowedToUse: z + .boolean() + .optional() + .describe("Whether flexible products are allowed to use"), + }, }, async ({ usageType, targetAsset, indexId, flexibleAllowedToUse }) => { try { diff --git a/src/tools/binance-auto-invest/getSubscriptionHistory.ts b/src/tools/binance-auto-invest/getSubscriptionHistory.ts index 382c322b..9a4f2455 100644 --- a/src/tools/binance-auto-invest/getSubscriptionHistory.ts +++ b/src/tools/binance-auto-invest/getSubscriptionHistory.ts @@ -6,17 +6,19 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestGetSubscriptionHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestGetSubscriptionHistory", - "Query subscription transaction history for auto-invest.", { - planId: z.number().optional().describe("Plan ID"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - targetAsset: z.string().optional().describe("Target asset (e.g., BTC)"), - planType: z.enum(["SINGLE", "PORTFOLIO", "INDEX"]).optional().describe("Plan type"), - current: z.number().optional().describe("Current page"), - size: z.number().optional().describe("Page size"), + description: "Query subscription transaction history for auto-invest.", + inputSchema: { + planId: z.number().optional().describe("Plan ID"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + targetAsset: z.string().optional().describe("Target asset (e.g., BTC)"), + planType: z.enum(["SINGLE", "PORTFOLIO", "INDEX"]).optional().describe("Plan type"), + current: z.number().optional().describe("Current page"), + size: z.number().optional().describe("Page size"), + }, }, async ({ planId, startTime, endTime, targetAsset, planType, current, size }) => { try { diff --git a/src/tools/binance-auto-invest/getTargetAssetList.ts b/src/tools/binance-auto-invest/getTargetAssetList.ts index 7459cd0d..7ce93b5e 100644 --- a/src/tools/binance-auto-invest/getTargetAssetList.ts +++ b/src/tools/binance-auto-invest/getTargetAssetList.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestGetTargetAssetList(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestGetTargetAssetList", - "Get target asset list for auto-invest.", { - targetAsset: z.string().optional().describe("Target asset (e.g., BTC)"), - size: z.number().optional().describe("Page size"), - current: z.number().optional().describe("Current page"), + description: "Get target asset list for auto-invest.", + inputSchema: { + targetAsset: z.string().optional().describe("Target asset (e.g., BTC)"), + size: z.number().optional().describe("Page size"), + current: z.number().optional().describe("Current page"), + }, }, async ({ targetAsset, size, current }) => { try { diff --git a/src/tools/binance-auto-invest/getTargetAssetROI.ts b/src/tools/binance-auto-invest/getTargetAssetROI.ts index 1b7a6db8..99884d0c 100644 --- a/src/tools/binance-auto-invest/getTargetAssetROI.ts +++ b/src/tools/binance-auto-invest/getTargetAssetROI.ts @@ -6,14 +6,16 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestGetTargetAssetROI(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestGetTargetAssetROI", - "Get target asset ROI data for auto-invest.", { - targetAsset: z.string().describe("Target asset (e.g., BTC)"), - hisRoiType: z - .enum(["FIVE_YEAR", "THREE_YEAR", "ONE_YEAR", "SIX_MONTH", "THREE_MONTH", "ONE_MONTH"]) - .describe("Historical ROI type"), + description: "Get target asset ROI data for auto-invest.", + inputSchema: { + targetAsset: z.string().describe("Target asset (e.g., BTC)"), + hisRoiType: z + .enum(["FIVE_YEAR", "THREE_YEAR", "ONE_YEAR", "SIX_MONTH", "THREE_MONTH", "ONE_MONTH"]) + .describe("Historical ROI type"), + }, }, async ({ targetAsset, hisRoiType }) => { try { diff --git a/src/tools/binance-auto-invest/getTargetAssetRoiData.ts b/src/tools/binance-auto-invest/getTargetAssetRoiData.ts index e9a2e54b..200ef1c4 100644 --- a/src/tools/binance-auto-invest/getTargetAssetRoiData.ts +++ b/src/tools/binance-auto-invest/getTargetAssetRoiData.ts @@ -12,15 +12,18 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestGetTargetAssetRoiData(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestGetTargetAssetRoiData", - "Get ROI (Return on Investment) data for auto-invest target assets. Shows historical performance.", { - targetAsset: z.string().describe("Target asset (e.g., 'BTC', 'ETH')"), - hisRoiType: z - .enum(["FIVE_YEAR", "THREE_YEAR", "ONE_YEAR", "SIX_MONTH", "THREE_MONTH", "SEVEN_DAY"]) - .describe("Historical ROI period"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Get ROI (Return on Investment) data for auto-invest target assets. Shows historical performance.", + inputSchema: { + targetAsset: z.string().describe("Target asset (e.g., 'BTC', 'ETH')"), + hisRoiType: z + .enum(["FIVE_YEAR", "THREE_YEAR", "ONE_YEAR", "SIX_MONTH", "THREE_MONTH", "SEVEN_DAY"]) + .describe("Historical ROI period"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-auto-invest/oneTimeTransaction.ts b/src/tools/binance-auto-invest/oneTimeTransaction.ts index fa8de2d0..42f71d04 100644 --- a/src/tools/binance-auto-invest/oneTimeTransaction.ts +++ b/src/tools/binance-auto-invest/oneTimeTransaction.ts @@ -12,26 +12,32 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestOneTimeTransaction(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestOneTimeTransaction", - "Execute a one-time auto-invest purchase. Buy crypto instantly without creating a recurring plan.", { - sourceType: z.enum(["MAIN_SITE", "TR"]).describe("Source type"), - subscriptionAmount: z.string().describe("Amount to invest in source asset"), - sourceAsset: z.string().describe("Source asset (e.g., 'USDT')"), - flexibleAllowedToUse: z.boolean().optional().describe("Allow using Flexible Savings balance"), - planId: z.number().int().optional().describe("Plan ID if investing in existing plan"), - indexId: z.number().int().optional().describe("Index ID for index portfolio"), - details: z - .array( - z.object({ - targetAsset: z.string().describe("Target asset to purchase"), - percentage: z.number().min(0).max(100).describe("Allocation percentage"), - }), - ) - .optional() - .describe("Target assets and allocations (for ad-hoc purchase)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Execute a one-time auto-invest purchase. Buy crypto instantly without creating a recurring plan.", + inputSchema: { + sourceType: z.enum(["MAIN_SITE", "TR"]).describe("Source type"), + subscriptionAmount: z.string().describe("Amount to invest in source asset"), + sourceAsset: z.string().describe("Source asset (e.g., 'USDT')"), + flexibleAllowedToUse: z + .boolean() + .optional() + .describe("Allow using Flexible Savings balance"), + planId: z.number().int().optional().describe("Plan ID if investing in existing plan"), + indexId: z.number().int().optional().describe("Index ID for index portfolio"), + details: z + .array( + z.object({ + targetAsset: z.string().describe("Target asset to purchase"), + percentage: z.number().min(0).max(100).describe("Allocation percentage"), + }), + ) + .optional() + .describe("Target assets and allocations (for ad-hoc purchase)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-auto-invest/rebalanceHistory.ts b/src/tools/binance-auto-invest/rebalanceHistory.ts index 12998d76..855de9d6 100644 --- a/src/tools/binance-auto-invest/rebalanceHistory.ts +++ b/src/tools/binance-auto-invest/rebalanceHistory.ts @@ -12,15 +12,23 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestRebalanceHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestRebalanceHistory", - "Get rebalance history for portfolio/index plans. Shows when and how allocations were rebalanced.", { - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - size: z.number().int().max(100).optional().describe("Number of results. Default 10, max 100"), - current: z.number().int().optional().describe("Current page. Default 1"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Get rebalance history for portfolio/index plans. Shows when and how allocations were rebalanced.", + inputSchema: { + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + size: z + .number() + .int() + .max(100) + .optional() + .describe("Number of results. Default 10, max 100"), + current: z.number().int().optional().describe("Current page. Default 1"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-auto-invest/redeemIndexLinkedPlan.ts b/src/tools/binance-auto-invest/redeemIndexLinkedPlan.ts index 76a09618..8d902a95 100644 --- a/src/tools/binance-auto-invest/redeemIndexLinkedPlan.ts +++ b/src/tools/binance-auto-invest/redeemIndexLinkedPlan.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestRedeemIndexLinkedPlan(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestRedeemIndexLinkedPlan", - "Redeem index linked plan for auto-invest.", { - indexId: z.number().describe("Index ID"), - redemptionPercentage: z.number().describe("Redemption percentage (0-100)"), - requestId: z.string().optional().describe("Request ID for idempotency"), + description: "Redeem index linked plan for auto-invest.", + inputSchema: { + indexId: z.number().describe("Index ID"), + redemptionPercentage: z.number().describe("Redemption percentage (0-100)"), + requestId: z.string().optional().describe("Request ID for idempotency"), + }, }, async ({ indexId, redemptionPercentage, requestId }) => { try { diff --git a/src/tools/binance-auto-invest/redemption.ts b/src/tools/binance-auto-invest/redemption.ts index c85ad277..85311547 100644 --- a/src/tools/binance-auto-invest/redemption.ts +++ b/src/tools/binance-auto-invest/redemption.ts @@ -12,17 +12,19 @@ import { z } from "zod"; import { autoInvestClient } from "../../config/binanceClient.js"; export function registerBinanceAutoInvestRedemption(server: McpServer) { - server.tool( + server.registerTool( "BinanceAutoInvestRedemption", - "Redeem (sell) holdings from an auto-invest index-linked plan.", { - indexId: z.number().int().describe("Index ID to redeem from"), - redemptionPercentage: z - .number() - .min(0) - .max(100) - .describe("Percentage of holdings to redeem (0-100)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Redeem (sell) holdings from an auto-invest index-linked plan.", + inputSchema: { + indexId: z.number().int().describe("Index ID to redeem from"), + redemptionPercentage: z + .number() + .min(0) + .max(100) + .describe("Percentage of holdings to redeem (0-100)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-c2c/C2C/getC2CTradeHistory.ts b/src/tools/binance-c2c/C2C/getC2CTradeHistory.ts index 1049e84a..b7d007b5 100644 --- a/src/tools/binance-c2c/C2C/getC2CTradeHistory.ts +++ b/src/tools/binance-c2c/C2C/getC2CTradeHistory.ts @@ -6,14 +6,17 @@ import { z } from "zod"; import { c2cClient } from "../../../config/binanceClient.js"; export function registerBinanceGetC2CTradeHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetC2CTradeHistory", - "Allows the user to retrieve their own past C2C trades, including details such as asset type, trade direction (BUY/SELL), fiat currency used, trade status, and more.", { - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - page: z.number().int().optional().describe("Page number, default is 1"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Allows the user to retrieve their own past C2C trades, including details such as asset type, trade direction (BUY/SELL), fiat currency used, trade status, and more.", + inputSchema: { + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + page: z.number().int().optional().describe("Page number, default is 1"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-convert/market-data-api/listAllConvertPairs.ts b/src/tools/binance-convert/market-data-api/listAllConvertPairs.ts index 25de6bef..08a9bb1f 100644 --- a/src/tools/binance-convert/market-data-api/listAllConvertPairs.ts +++ b/src/tools/binance-convert/market-data-api/listAllConvertPairs.ts @@ -6,12 +6,15 @@ import { z } from "zod"; import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertGetListAllConvertPairs(server: McpServer) { - server.tool( + server.registerTool( "BinanceConvertGetListAllConvertPairs", - "Query available conversion pairs (like BTC to USDT), and shows the minimum and maximum allowed amounts for both the source and destination tokens.", { - fromAsset: z.string().optional().describe("User spends coin"), - toAsset: z.string().optional().describe("User receives coin"), + description: + "Query available conversion pairs (like BTC to USDT), and shows the minimum and maximum allowed amounts for both the source and destination tokens.", + inputSchema: { + fromAsset: z.string().optional().describe("User spends coin"), + toAsset: z.string().optional().describe("User receives coin"), + }, }, async (params) => { try { diff --git a/src/tools/binance-convert/market-data-api/queryOrderQuantityPrecisionPerAsset.ts b/src/tools/binance-convert/market-data-api/queryOrderQuantityPrecisionPerAsset.ts index 21ac758a..a37b5c20 100644 --- a/src/tools/binance-convert/market-data-api/queryOrderQuantityPrecisionPerAsset.ts +++ b/src/tools/binance-convert/market-data-api/queryOrderQuantityPrecisionPerAsset.ts @@ -6,16 +6,19 @@ import { z } from "zod"; import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertQueryOrderQuantityPrecisionPerAsset(server: McpServer) { - server.tool( + server.registerTool( "BinanceConvertQueryOrderQuantityPrecisionPerAsset", - "Retrieve decimal precision (fraction) information for each supported asset in the Convert feature.", { - recvWindow: z - .number() - .int() - .max(60000, "recvWindow cannot be greater than 60000") - .optional() - .describe("The value cannot be greater than 60000"), + description: + "Retrieve decimal precision (fraction) information for each supported asset in the Convert feature.", + inputSchema: { + recvWindow: z + .number() + .int() + .max(60000, "recvWindow cannot be greater than 60000") + .optional() + .describe("The value cannot be greater than 60000"), + }, }, async (params) => { try { diff --git a/src/tools/binance-convert/trade-api/acceptQuote.ts b/src/tools/binance-convert/trade-api/acceptQuote.ts index 23deb653..3df62cc2 100644 --- a/src/tools/binance-convert/trade-api/acceptQuote.ts +++ b/src/tools/binance-convert/trade-api/acceptQuote.ts @@ -6,17 +6,20 @@ import { z } from "zod"; import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertAcceptQuote(server: McpServer) { - server.tool( + server.registerTool( "BinanceConvertAcceptQuote", - "The API confirms and executes a token conversion using a previously received quote ID.", { - quoteId: z.string().describe("Quote ID"), - recvWindow: z - .number() - .int() - .max(60000, "recvWindow cannot be greater than 60000") - .optional() - .describe("The value cannot be greater than 60000"), + description: + "The API confirms and executes a token conversion using a previously received quote ID.", + inputSchema: { + quoteId: z.string().describe("Quote ID"), + recvWindow: z + .number() + .int() + .max(60000, "recvWindow cannot be greater than 60000") + .optional() + .describe("The value cannot be greater than 60000"), + }, }, async (params) => { try { diff --git a/src/tools/binance-convert/trade-api/cancelLimitOrder.ts b/src/tools/binance-convert/trade-api/cancelLimitOrder.ts index 7982e671..4da9c70d 100644 --- a/src/tools/binance-convert/trade-api/cancelLimitOrder.ts +++ b/src/tools/binance-convert/trade-api/cancelLimitOrder.ts @@ -6,17 +6,20 @@ import { z } from "zod"; import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertCancelLimitOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceConvertCancelLimitOrder", - "Cancels a previously placed limit order using the orderId and returns the cancellation status along with the orderId.", { - orderId: z.number().int().describe("The orderId from placeOrder API"), - recvWindow: z - .number() - .int() - .max(60000, "recvWindow cannot be greater than 60000") - .optional() - .describe("Time window for request validity"), + description: + "Cancels a previously placed limit order using the orderId and returns the cancellation status along with the orderId.", + inputSchema: { + orderId: z.number().int().describe("The orderId from placeOrder API"), + recvWindow: z + .number() + .int() + .max(60000, "recvWindow cannot be greater than 60000") + .optional() + .describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-convert/trade-api/getConvertTradeHistory.ts b/src/tools/binance-convert/trade-api/getConvertTradeHistory.ts index 5eafcf10..8c8fbe37 100644 --- a/src/tools/binance-convert/trade-api/getConvertTradeHistory.ts +++ b/src/tools/binance-convert/trade-api/getConvertTradeHistory.ts @@ -6,19 +6,22 @@ import { z } from "zod"; import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceGetConvertTradeHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetConvertTradeHistory", - "The API retrieves your token conversion trade history within a specified time range, with support for pagination using the limit parameter (up to 1000 records).", { - startTime: z.number().int().describe("Start time in milliseconds"), - endTime: z.number().int().describe("End time in milliseconds"), - limit: z - .number() - .int() - .max(1000, "Limit cannot be greater than 1000") - .optional() - .describe("Default 100, Max 1000"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "The API retrieves your token conversion trade history within a specified time range, with support for pagination using the limit parameter (up to 1000 records).", + inputSchema: { + startTime: z.number().int().describe("Start time in milliseconds"), + endTime: z.number().int().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(1000, "Limit cannot be greater than 1000") + .optional() + .describe("Default 100, Max 1000"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-convert/trade-api/orderStatus.ts b/src/tools/binance-convert/trade-api/orderStatus.ts index 2f0db587..32ee7073 100644 --- a/src/tools/binance-convert/trade-api/orderStatus.ts +++ b/src/tools/binance-convert/trade-api/orderStatus.ts @@ -6,12 +6,15 @@ import { z } from "zod"; import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertOrderStatus(server: McpServer) { - server.tool( + server.registerTool( "BinanceConvertOrderStatus", - "The API checks the status of a token conversion order using either the orderId or quoteId, and returns details like conversion status, assets involved, amounts, exchange rate, and order creation time.", { - orderId: z.string().optional().describe("Order ID (either this or quoteId is required)"), - quoteId: z.string().optional().describe("Quote ID (either this or orderId is required)"), + description: + "The API checks the status of a token conversion order using either the orderId or quoteId, and returns details like conversion status, assets involved, amounts, exchange rate, and order creation time.", + inputSchema: { + orderId: z.string().optional().describe("Order ID (either this or quoteId is required)"), + quoteId: z.string().optional().describe("Quote ID (either this or orderId is required)"), + }, }, async (params) => { try { diff --git a/src/tools/binance-convert/trade-api/placeLimitOrder.ts b/src/tools/binance-convert/trade-api/placeLimitOrder.ts index 54896a32..2639e773 100644 --- a/src/tools/binance-convert/trade-api/placeLimitOrder.ts +++ b/src/tools/binance-convert/trade-api/placeLimitOrder.ts @@ -6,40 +6,43 @@ import { z } from "zod"; import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertPlaceLimitOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceConvertPlaceLimitOrder", - "Places a limit order to convert between two tokens at a specified price, using either base or quote amount, with options for wallet type and order expiry.", { - baseAsset: z.string().describe("Base asset (from `fromIsBase` in /exchangeInfo API)"), - quoteAsset: z.string().describe("Quote asset"), - limitPrice: z - .number() - .positive() - .describe("Symbol limit price (from baseAsset to quoteAsset)"), - baseAmount: z - .number() - .positive() - .optional() - .describe("Base asset amount (either this or quoteAmount is required)"), - quoteAmount: z - .number() - .positive() - .optional() - .describe("Quote asset amount (either this or baseAmount is required)"), - side: z.enum(["BUY", "SELL"]).describe("BUY or SELL"), - walletType: z - .enum(["SPOT", "FUNDING", "SPOT_FUNDING"]) - .optional() - .describe("Type of assets used: SPOT, FUNDING, or SPOT_FUNDING. Default is SPOT"), - expiredType: z - .enum(["1_D", "3_D", "7_D", "30_D"]) - .describe("Expiration type: 1_D, 3_D, 7_D, or 30_D (D = days)"), - recvWindow: z - .number() - .int() - .max(60000, "recvWindow cannot be greater than 60000") - .optional() - .describe("Time window for request validity"), + description: + "Places a limit order to convert between two tokens at a specified price, using either base or quote amount, with options for wallet type and order expiry.", + inputSchema: { + baseAsset: z.string().describe("Base asset (from `fromIsBase` in /exchangeInfo API)"), + quoteAsset: z.string().describe("Quote asset"), + limitPrice: z + .number() + .positive() + .describe("Symbol limit price (from baseAsset to quoteAsset)"), + baseAmount: z + .number() + .positive() + .optional() + .describe("Base asset amount (either this or quoteAmount is required)"), + quoteAmount: z + .number() + .positive() + .optional() + .describe("Quote asset amount (either this or baseAmount is required)"), + side: z.enum(["BUY", "SELL"]).describe("BUY or SELL"), + walletType: z + .enum(["SPOT", "FUNDING", "SPOT_FUNDING"]) + .optional() + .describe("Type of assets used: SPOT, FUNDING, or SPOT_FUNDING. Default is SPOT"), + expiredType: z + .enum(["1_D", "3_D", "7_D", "30_D"]) + .describe("Expiration type: 1_D, 3_D, 7_D, or 30_D (D = days)"), + recvWindow: z + .number() + .int() + .max(60000, "recvWindow cannot be greater than 60000") + .optional() + .describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-convert/trade-api/queryLimitOpenOrders.ts b/src/tools/binance-convert/trade-api/queryLimitOpenOrders.ts index a55f4f73..d96ede06 100644 --- a/src/tools/binance-convert/trade-api/queryLimitOpenOrders.ts +++ b/src/tools/binance-convert/trade-api/queryLimitOpenOrders.ts @@ -6,16 +6,19 @@ import { z } from "zod"; import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertQueryLimitOpenOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceConvertQueryLimitOpenOrders", - "Retrieves all your open limit orders for token conversions, showing details like assets, amounts, exchange rate, order status, and expiration time.", { - recvWindow: z - .number() - .int() - .max(60000, "recvWindow must not be greater than 60000") - .optional() - .describe("This value must not exceed 60000"), + description: + "Retrieves all your open limit orders for token conversions, showing details like assets, amounts, exchange rate, order status, and expiration time.", + inputSchema: { + recvWindow: z + .number() + .int() + .max(60000, "recvWindow must not be greater than 60000") + .optional() + .describe("This value must not exceed 60000"), + }, }, async (params) => { try { diff --git a/src/tools/binance-convert/trade-api/sendQuoteRequest.ts b/src/tools/binance-convert/trade-api/sendQuoteRequest.ts index e7ae7a91..c564cdc3 100644 --- a/src/tools/binance-convert/trade-api/sendQuoteRequest.ts +++ b/src/tools/binance-convert/trade-api/sendQuoteRequest.ts @@ -6,32 +6,39 @@ import { z } from "zod"; import { convertClient } from "../../../config/binanceClient.js"; export function registerBinanceConvertSendQuoteRequest(server: McpServer) { - server.tool( + server.registerTool( "BinanceConvertSendQuoteRequest", - "Get a real-time quote to convert one token to another, including rate and amount, if you have enough funds.", { - fromAsset: z.string().describe("Asset you will spend (required)"), - toAsset: z.string().describe("Asset you will receive (required)"), - fromAmount: z - .number() - .positive() - .optional() - .describe("Amount to be debited after conversion"), - toAmount: z.number().positive().optional().describe("Amount to be credited after conversion"), - walletType: z - .enum(["SPOT", "FUNDING"]) - .optional() - .describe("SPOT or FUNDING. Default is SPOT"), - validTime: z - .enum(["10s", "30s", "1m"]) - .optional() - .describe("Quote validity duration: 10s, 30s, 1m; default is 10s"), - recvWindow: z - .number() - .int() - .max(60000, "recvWindow cannot be greater than 60000") - .optional() - .describe("The value cannot be greater than 60000"), + description: + "Get a real-time quote to convert one token to another, including rate and amount, if you have enough funds.", + inputSchema: { + fromAsset: z.string().describe("Asset you will spend (required)"), + toAsset: z.string().describe("Asset you will receive (required)"), + fromAmount: z + .number() + .positive() + .optional() + .describe("Amount to be debited after conversion"), + toAmount: z + .number() + .positive() + .optional() + .describe("Amount to be credited after conversion"), + walletType: z + .enum(["SPOT", "FUNDING"]) + .optional() + .describe("SPOT or FUNDING. Default is SPOT"), + validTime: z + .enum(["10s", "30s", "1m"]) + .optional() + .describe("Quote validity duration: 10s, 30s, 1m; default is 10s"), + recvWindow: z + .number() + .int() + .max(60000, "recvWindow cannot be greater than 60000") + .optional() + .describe("The value cannot be greater than 60000"), + }, }, async (params) => { try { diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/followTrader.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/followTrader.ts index 1b09a1a3..256a3621 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/followTrader.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/followTrader.ts @@ -6,30 +6,33 @@ import { z } from "zod"; import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceCopyTradingFollow(server: McpServer) { - server.tool( + server.registerTool( "BinanceCopyTradingFollow", - "Start following a lead trader in copy trading. ⚠️ WARNING: This will automatically copy their trades. You are trusting another trader with your capital. Past performance does not guarantee future results.", { - portfolioId: z.string().describe("Lead trader's portfolio ID to follow"), - copyRatio: z - .number() - .min(0.1) - .max(10) - .optional() - .describe("Copy ratio multiplier (0.1-10x, default 1x)"), - stopLossRatio: z - .number() - .min(0.01) - .max(1) - .optional() - .describe("Stop loss ratio (e.g., 0.1 = 10% loss triggers stop)"), - takeProfitRatio: z - .number() - .min(0.01) - .optional() - .describe("Take profit ratio (e.g., 0.5 = 50% profit triggers exit)"), - fixedAmount: z.string().optional().describe("Fixed amount per trade instead of ratio"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Start following a lead trader in copy trading. ⚠️ WARNING: This will automatically copy their trades. You are trusting another trader with your capital. Past performance does not guarantee future results.", + inputSchema: { + portfolioId: z.string().describe("Lead trader's portfolio ID to follow"), + copyRatio: z + .number() + .min(0.1) + .max(10) + .optional() + .describe("Copy ratio multiplier (0.1-10x, default 1x)"), + stopLossRatio: z + .number() + .min(0.01) + .max(1) + .optional() + .describe("Stop loss ratio (e.g., 0.1 = 10% loss triggers stop)"), + takeProfitRatio: z + .number() + .min(0.01) + .optional() + .describe("Take profit ratio (e.g., 0.5 = 50% profit triggers exit)"), + fixedAmount: z.string().optional().describe("Fixed amount per trade instead of ratio"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyOrders.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyOrders.ts index 40a8d3aa..4c1a31d6 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyOrders.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyOrders.ts @@ -6,17 +6,20 @@ import { z } from "zod"; import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceCopyTradingGetOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceCopyTradingGetOrders", - "Get copy trading orders. Shows orders that were placed as a result of following lead traders.", { - portfolioId: z.string().optional().describe("Filter by specific lead trader portfolio ID"), - symbol: z.string().optional().describe("Filter by trading symbol"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - pageNumber: z.number().int().min(1).optional().describe("Page number"), - pageSize: z.number().int().min(1).max(100).optional().describe("Results per page"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Get copy trading orders. Shows orders that were placed as a result of following lead traders.", + inputSchema: { + portfolioId: z.string().optional().describe("Filter by specific lead trader portfolio ID"), + symbol: z.string().optional().describe("Filter by trading symbol"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + pageNumber: z.number().int().min(1).optional().describe("Page number"), + pageSize: z.number().int().min(1).max(100).optional().describe("Results per page"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyPositions.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyPositions.ts index 763a245a..2150940d 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyPositions.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyPositions.ts @@ -6,13 +6,16 @@ import { z } from "zod"; import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceCopyTradingGetPositions(server: McpServer) { - server.tool( + server.registerTool( "BinanceCopyTradingGetPositions", - "Get current copy trading positions. Shows open positions from following lead traders.", { - portfolioId: z.string().optional().describe("Filter by specific lead trader portfolio ID"), - symbol: z.string().optional().describe("Filter by trading symbol"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Get current copy trading positions. Shows open positions from following lead traders.", + inputSchema: { + portfolioId: z.string().optional().describe("Filter by specific lead trader portfolio ID"), + symbol: z.string().optional().describe("Filter by trading symbol"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/getFollowingTraders.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/getFollowingTraders.ts index 1df3bcb9..e1fe7c16 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/getFollowingTraders.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/getFollowingTraders.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceCopyTradingGetFollowing(server: McpServer) { - server.tool( + server.registerTool( "BinanceCopyTradingGetFollowing", - "Get list of traders you are currently following in copy trading.", { - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: "Get list of traders you are currently following in copy trading.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts index d824f411..1241044c 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts @@ -6,11 +6,18 @@ import { z } from "zod"; import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetFuturesLeadTraderStatus(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetFuturesLeadTraderStatus", - "Checks and returns whether the user is currently a Futures Lead Trader in Binance Copy Trading, along with the timestamp of the status check.", { - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Checks and returns whether the user is currently a Futures Lead Trader in Binance Copy Trading, along with the timestamp of the status check.", + inputSchema: { + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts index 5efe5667..b86d8cc0 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts @@ -6,11 +6,18 @@ import { z } from "zod"; import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetFuturesLeadTradingSymbolWhitelist(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetFuturesLeadTradingSymbolWhitelist", - "Whitelist of trading pairs (symbols) that are allowed for Futures Lead Traders in copy trading, including base and quote assets.", { - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Whitelist of trading pairs (symbols) that are allowed for Futures Lead Traders in copy trading, including base and quote assets.", + inputSchema: { + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/getLeadTraders.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/getLeadTraders.ts index b058e89a..b5a38373 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/getLeadTraders.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/getLeadTraders.ts @@ -12,13 +12,22 @@ import { z } from "zod"; import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceCopyTradingGetLeaders(server: McpServer) { - server.tool( + server.registerTool( "BinanceCopyTradingGetLeaders", - "Get a list of lead traders available for copy trading. Shows their performance metrics and follower count.", { - pageNumber: z.number().int().min(1).optional().describe("Page number for pagination"), - pageSize: z.number().int().min(1).max(100).optional().describe("Results per page (max 100)"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Get a list of lead traders available for copy trading. Shows their performance metrics and follower count.", + inputSchema: { + pageNumber: z.number().int().min(1).optional().describe("Page number for pagination"), + pageSize: z + .number() + .int() + .min(1) + .max(100) + .optional() + .describe("Results per page (max 100)"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/getTraderPerformance.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/getTraderPerformance.ts index e206e5c0..3de63338 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/getTraderPerformance.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/getTraderPerformance.ts @@ -6,12 +6,15 @@ import { z } from "zod"; import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceCopyTradingGetPerformance(server: McpServer) { - server.tool( + server.registerTool( "BinanceCopyTradingGetPerformance", - "Get detailed performance statistics for a specific lead trader. Includes ROI, win rate, PnL history.", { - portfolioId: z.string().describe("Lead trader's portfolio ID"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Get detailed performance statistics for a specific lead trader. Includes ROI, win rate, PnL history.", + inputSchema: { + portfolioId: z.string().describe("Lead trader's portfolio ID"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/unfollowTrader.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/unfollowTrader.ts index 57775242..6769e956 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/unfollowTrader.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/unfollowTrader.ts @@ -6,12 +6,15 @@ import { z } from "zod"; import { copyTradingClient } from "../../../config/binanceClient.js"; export function registerBinanceCopyTradingUnfollow(server: McpServer) { - server.tool( + server.registerTool( "BinanceCopyTradingUnfollow", - "Stop following a lead trader. This will stop copying their trades but won't close existing positions.", { - portfolioId: z.string().describe("Lead trader's portfolio ID to unfollow"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Stop following a lead trader. This will stop copying their trades but won't close existing positions.", + inputSchema: { + portfolioId: z.string().describe("Lead trader's portfolio ID to unfollow"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-crypto-loans/fixed-api/adjustLTV.ts b/src/tools/binance-crypto-loans/fixed-api/adjustLTV.ts index 8a9d613d..27707343 100644 --- a/src/tools/binance-crypto-loans/fixed-api/adjustLTV.ts +++ b/src/tools/binance-crypto-loans/fixed-api/adjustLTV.ts @@ -12,16 +12,18 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFixedAdjustLTV(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoansFixedAdjustLTV", - "Adjust LTV for a fixed-term loan by adding or removing collateral.", { - orderId: z.number().int().describe("Loan order ID"), - amount: z.string().describe("Amount of collateral to add or remove"), - direction: z - .enum(["ADDITIONAL", "REDUCED"]) - .describe("Direction: ADDITIONAL to add collateral, REDUCED to remove"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: "Adjust LTV for a fixed-term loan by adding or removing collateral.", + inputSchema: { + orderId: z.number().int().describe("Loan order ID"), + amount: z.string().describe("Amount of collateral to add or remove"), + direction: z + .enum(["ADDITIONAL", "REDUCED"]) + .describe("Direction: ADDITIONAL to add collateral, REDUCED to remove"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-crypto-loans/fixed-api/borrow.ts b/src/tools/binance-crypto-loans/fixed-api/borrow.ts index 246a33b5..0acef4ef 100644 --- a/src/tools/binance-crypto-loans/fixed-api/borrow.ts +++ b/src/tools/binance-crypto-loans/fixed-api/borrow.ts @@ -12,22 +12,25 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFixedBorrow(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoansFixedBorrow", - "Borrow crypto using a fixed-term loan. ⚠️ WARNING: Fixed loans have a specific term. Your collateral is locked until repayment. Failure to repay may result in liquidation.", { - loanCoin: z.string().describe("Coin to borrow (e.g., 'USDT')"), - collateralCoin: z.string().describe("Collateral coin (e.g., 'BTC')"), - loanTerm: z.number().int().describe("Loan term in days (7, 14, 30, 90, 180)"), - loanAmount: z - .string() - .optional() - .describe("Amount to borrow (provide either loanAmount or collateralAmount)"), - collateralAmount: z - .string() - .optional() - .describe("Collateral amount (provide either loanAmount or collateralAmount)"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Borrow crypto using a fixed-term loan. ⚠️ WARNING: Fixed loans have a specific term. Your collateral is locked until repayment. Failure to repay may result in liquidation.", + inputSchema: { + loanCoin: z.string().describe("Coin to borrow (e.g., 'USDT')"), + collateralCoin: z.string().describe("Collateral coin (e.g., 'BTC')"), + loanTerm: z.number().int().describe("Loan term in days (7, 14, 30, 90, 180)"), + loanAmount: z + .string() + .optional() + .describe("Amount to borrow (provide either loanAmount or collateralAmount)"), + collateralAmount: z + .string() + .optional() + .describe("Collateral amount (provide either loanAmount or collateralAmount)"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-crypto-loans/fixed-api/checkCollateralRate.ts b/src/tools/binance-crypto-loans/fixed-api/checkCollateralRate.ts index 6edca8e9..b173f23b 100644 --- a/src/tools/binance-crypto-loans/fixed-api/checkCollateralRate.ts +++ b/src/tools/binance-crypto-loans/fixed-api/checkCollateralRate.ts @@ -12,14 +12,17 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFixedCollateralRate(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoansFixedCollateralRate", - "Check the collateral repay rate for a specific loan and collateral pair. Useful for planning repayments.", { - loanCoin: z.string().describe("Loan coin (e.g., 'USDT')"), - collateralCoin: z.string().describe("Collateral coin (e.g., 'BTC')"), - repayAmount: z.string().describe("Amount to repay"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Check the collateral repay rate for a specific loan and collateral pair. Useful for planning repayments.", + inputSchema: { + loanCoin: z.string().describe("Loan coin (e.g., 'USDT')"), + collateralCoin: z.string().describe("Collateral coin (e.g., 'BTC')"), + repayAmount: z.string().describe("Amount to repay"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-crypto-loans/fixed-api/customizeMarginCall.ts b/src/tools/binance-crypto-loans/fixed-api/customizeMarginCall.ts index de1420c3..56d5d7fc 100644 --- a/src/tools/binance-crypto-loans/fixed-api/customizeMarginCall.ts +++ b/src/tools/binance-crypto-loans/fixed-api/customizeMarginCall.ts @@ -12,13 +12,16 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFixedMarginCall(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoansFixedMarginCall", - "Customize margin call threshold for a loan. Set when you want to be notified about LTV changes.", { - orderId: z.number().int().describe("Loan order ID"), - marginCall: z.number().describe("Margin call LTV threshold (e.g., 0.8 for 80%)"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Customize margin call threshold for a loan. Set when you want to be notified about LTV changes.", + inputSchema: { + orderId: z.number().int().describe("Loan order ID"), + marginCall: z.number().describe("Margin call LTV threshold (e.g., 0.8 for 80%)"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-crypto-loans/fixed-api/getBorrowHistory.ts b/src/tools/binance-crypto-loans/fixed-api/getBorrowHistory.ts index d9476f36..420466e3 100644 --- a/src/tools/binance-crypto-loans/fixed-api/getBorrowHistory.ts +++ b/src/tools/binance-crypto-loans/fixed-api/getBorrowHistory.ts @@ -12,18 +12,20 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFixedBorrowHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoansFixedBorrowHistory", - "Get borrow history for fixed-term loans.", { - orderId: z.number().int().optional().describe("Filter by specific order ID"), - loanCoin: z.string().optional().describe("Filter by loan coin"), - collateralCoin: z.string().optional().describe("Filter by collateral coin"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - current: z.number().int().min(1).optional().describe("Current page"), - limit: z.number().int().min(1).max(100).optional().describe("Results per page (max 100)"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: "Get borrow history for fixed-term loans.", + inputSchema: { + orderId: z.number().int().optional().describe("Filter by specific order ID"), + loanCoin: z.string().optional().describe("Filter by loan coin"), + collateralCoin: z.string().optional().describe("Filter by collateral coin"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + current: z.number().int().min(1).optional().describe("Current page"), + limit: z.number().int().min(1).max(100).optional().describe("Results per page (max 100)"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-crypto-loans/fixed-api/getFixedCollateralData.ts b/src/tools/binance-crypto-loans/fixed-api/getFixedCollateralData.ts index a214f3da..9adc596f 100644 --- a/src/tools/binance-crypto-loans/fixed-api/getFixedCollateralData.ts +++ b/src/tools/binance-crypto-loans/fixed-api/getFixedCollateralData.ts @@ -12,13 +12,16 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFixedCollateral(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoansFixedCollateral", - "Get list of collateral assets for fixed-term loans. Shows LTV ratios and limits.", { - collateralCoin: z.string().optional().describe("Filter by specific collateral coin"), - vipLevel: z.number().int().min(0).max(9).optional().describe("VIP level"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Get list of collateral assets for fixed-term loans. Shows LTV ratios and limits.", + inputSchema: { + collateralCoin: z.string().optional().describe("Filter by specific collateral coin"), + vipLevel: z.number().int().min(0).max(9).optional().describe("VIP level"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-crypto-loans/fixed-api/getFixedLoanData.ts b/src/tools/binance-crypto-loans/fixed-api/getFixedLoanData.ts index fb58d306..b85cb474 100644 --- a/src/tools/binance-crypto-loans/fixed-api/getFixedLoanData.ts +++ b/src/tools/binance-crypto-loans/fixed-api/getFixedLoanData.ts @@ -12,19 +12,22 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFixedAssets(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoansFixedAssets", - "Get list of assets available for fixed-term crypto loans. Shows borrowable assets with interest rates, terms, and limits.", { - loanCoin: z.string().optional().describe("Filter by specific loan coin"), - vipLevel: z - .number() - .int() - .min(0) - .max(9) - .optional() - .describe("VIP level for rate calculation"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Get list of assets available for fixed-term crypto loans. Shows borrowable assets with interest rates, terms, and limits.", + inputSchema: { + loanCoin: z.string().optional().describe("Filter by specific loan coin"), + vipLevel: z + .number() + .int() + .min(0) + .max(9) + .optional() + .describe("VIP level for rate calculation"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-crypto-loans/fixed-api/getOngoingOrders.ts b/src/tools/binance-crypto-loans/fixed-api/getOngoingOrders.ts index 7038e592..5c73da43 100644 --- a/src/tools/binance-crypto-loans/fixed-api/getOngoingOrders.ts +++ b/src/tools/binance-crypto-loans/fixed-api/getOngoingOrders.ts @@ -12,16 +12,19 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFixedOngoing(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoansFixedOngoing", - "Get ongoing fixed-term loan orders. Shows current loans with term, principal, interest, and LTV.", { - orderId: z.number().int().optional().describe("Filter by specific order ID"), - loanCoin: z.string().optional().describe("Filter by loan coin"), - collateralCoin: z.string().optional().describe("Filter by collateral coin"), - current: z.number().int().min(1).optional().describe("Current page"), - limit: z.number().int().min(1).max(100).optional().describe("Results per page (max 100)"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Get ongoing fixed-term loan orders. Shows current loans with term, principal, interest, and LTV.", + inputSchema: { + orderId: z.number().int().optional().describe("Filter by specific order ID"), + loanCoin: z.string().optional().describe("Filter by loan coin"), + collateralCoin: z.string().optional().describe("Filter by collateral coin"), + current: z.number().int().min(1).optional().describe("Current page"), + limit: z.number().int().min(1).max(100).optional().describe("Results per page (max 100)"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-crypto-loans/fixed-api/getRepayHistory.ts b/src/tools/binance-crypto-loans/fixed-api/getRepayHistory.ts index c4945403..36d3745e 100644 --- a/src/tools/binance-crypto-loans/fixed-api/getRepayHistory.ts +++ b/src/tools/binance-crypto-loans/fixed-api/getRepayHistory.ts @@ -12,18 +12,20 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFixedRepayHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoansFixedRepayHistory", - "Get repayment history for fixed-term loans.", { - orderId: z.number().int().optional().describe("Filter by specific order ID"), - loanCoin: z.string().optional().describe("Filter by loan coin"), - collateralCoin: z.string().optional().describe("Filter by collateral coin"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - current: z.number().int().min(1).optional().describe("Current page"), - limit: z.number().int().min(1).max(100).optional().describe("Results per page (max 100)"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: "Get repayment history for fixed-term loans.", + inputSchema: { + orderId: z.number().int().optional().describe("Filter by specific order ID"), + loanCoin: z.string().optional().describe("Filter by loan coin"), + collateralCoin: z.string().optional().describe("Filter by collateral coin"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + current: z.number().int().min(1).optional().describe("Current page"), + limit: z.number().int().min(1).max(100).optional().describe("Results per page (max 100)"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-crypto-loans/fixed-api/repay.ts b/src/tools/binance-crypto-loans/fixed-api/repay.ts index 29783976..bccd0cac 100644 --- a/src/tools/binance-crypto-loans/fixed-api/repay.ts +++ b/src/tools/binance-crypto-loans/fixed-api/repay.ts @@ -12,21 +12,23 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFixedRepay(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoansFixedRepay", - "Repay a fixed-term crypto loan. Repaying unlocks your collateral.", { - orderId: z.number().int().describe("Loan order ID to repay"), - amount: z.string().describe("Amount to repay"), - type: z - .enum(["1", "2"]) - .optional() - .describe("Repay type: 1 = repay with borrowed coin, 2 = repay with collateral"), - collateralReturn: z - .boolean() - .optional() - .describe("Whether to return collateral after full repayment"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: "Repay a fixed-term crypto loan. Repaying unlocks your collateral.", + inputSchema: { + orderId: z.number().int().describe("Loan order ID to repay"), + amount: z.string().describe("Amount to repay"), + type: z + .enum(["1", "2"]) + .optional() + .describe("Repay type: 1 = repay with borrowed coin, 2 = repay with collateral"), + collateralReturn: z + .boolean() + .optional() + .describe("Whether to return collateral after full repayment"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-crypto-loans/flexible-api/adjustLTV.ts b/src/tools/binance-crypto-loans/flexible-api/adjustLTV.ts index 7e661c3d..193cd80c 100644 --- a/src/tools/binance-crypto-loans/flexible-api/adjustLTV.ts +++ b/src/tools/binance-crypto-loans/flexible-api/adjustLTV.ts @@ -12,19 +12,22 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFlexibleAdjustLTV(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoansFlexibleAdjustLTV", - "Adjust LTV (Loan-to-Value) ratio by adding or removing collateral. Lower LTV reduces liquidation risk.", { - loanCoin: z.string().describe("Loan coin (e.g., 'USDT')"), - collateralCoin: z.string().describe("Collateral coin (e.g., 'BTC')"), - adjustmentAmount: z.string().describe("Amount of collateral to add or remove"), - direction: z - .enum(["ADDITIONAL", "REDUCED"]) - .describe( - "Direction: ADDITIONAL to add collateral (lower LTV), REDUCED to remove collateral (higher LTV)", - ), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Adjust LTV (Loan-to-Value) ratio by adding or removing collateral. Lower LTV reduces liquidation risk.", + inputSchema: { + loanCoin: z.string().describe("Loan coin (e.g., 'USDT')"), + collateralCoin: z.string().describe("Collateral coin (e.g., 'BTC')"), + adjustmentAmount: z.string().describe("Amount of collateral to add or remove"), + direction: z + .enum(["ADDITIONAL", "REDUCED"]) + .describe( + "Direction: ADDITIONAL to add collateral (lower LTV), REDUCED to remove collateral (higher LTV)", + ), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-crypto-loans/flexible-api/borrow.ts b/src/tools/binance-crypto-loans/flexible-api/borrow.ts index 7f08a77f..8e4179e6 100644 --- a/src/tools/binance-crypto-loans/flexible-api/borrow.ts +++ b/src/tools/binance-crypto-loans/flexible-api/borrow.ts @@ -12,21 +12,24 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFlexibleBorrow(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoansFlexibleBorrow", - "Borrow crypto using a flexible loan. ⚠️ WARNING: Your collateral will be locked. Interest accrues daily. If LTV ratio exceeds threshold, liquidation may occur.", { - loanCoin: z.string().describe("Coin to borrow (e.g., 'USDT', 'BUSD')"), - collateralCoin: z.string().describe("Collateral coin (e.g., 'BTC', 'ETH')"), - loanAmount: z - .string() - .optional() - .describe("Amount to borrow (provide either loanAmount or collateralAmount)"), - collateralAmount: z - .string() - .optional() - .describe("Collateral amount (provide either loanAmount or collateralAmount)"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Borrow crypto using a flexible loan. ⚠️ WARNING: Your collateral will be locked. Interest accrues daily. If LTV ratio exceeds threshold, liquidation may occur.", + inputSchema: { + loanCoin: z.string().describe("Coin to borrow (e.g., 'USDT', 'BUSD')"), + collateralCoin: z.string().describe("Collateral coin (e.g., 'BTC', 'ETH')"), + loanAmount: z + .string() + .optional() + .describe("Amount to borrow (provide either loanAmount or collateralAmount)"), + collateralAmount: z + .string() + .optional() + .describe("Collateral amount (provide either loanAmount or collateralAmount)"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-crypto-loans/flexible-api/getBorrowHistory.ts b/src/tools/binance-crypto-loans/flexible-api/getBorrowHistory.ts index 4da463be..b83dcf6b 100644 --- a/src/tools/binance-crypto-loans/flexible-api/getBorrowHistory.ts +++ b/src/tools/binance-crypto-loans/flexible-api/getBorrowHistory.ts @@ -12,17 +12,20 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFlexibleBorrowHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoansFlexibleBorrowHistory", - "Get borrow history for flexible loans. Shows all past and current borrow transactions.", { - loanCoin: z.string().optional().describe("Filter by loan coin"), - collateralCoin: z.string().optional().describe("Filter by collateral coin"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - current: z.number().int().min(1).optional().describe("Current page (default 1)"), - limit: z.number().int().min(1).max(100).optional().describe("Results per page (max 100)"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Get borrow history for flexible loans. Shows all past and current borrow transactions.", + inputSchema: { + loanCoin: z.string().optional().describe("Filter by loan coin"), + collateralCoin: z.string().optional().describe("Filter by collateral coin"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + current: z.number().int().min(1).optional().describe("Current page (default 1)"), + limit: z.number().int().min(1).max(100).optional().describe("Results per page (max 100)"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-crypto-loans/flexible-api/getFlexibleCollateralAssets.ts b/src/tools/binance-crypto-loans/flexible-api/getFlexibleCollateralAssets.ts index 74b2656f..5a8c3dfd 100644 --- a/src/tools/binance-crypto-loans/flexible-api/getFlexibleCollateralAssets.ts +++ b/src/tools/binance-crypto-loans/flexible-api/getFlexibleCollateralAssets.ts @@ -12,15 +12,18 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFlexibleCollateral(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoansFlexibleCollateral", - "Get list of assets that can be used as collateral for flexible loans. Shows LTV ratios and collateral limits.", { - collateralCoin: z - .string() - .optional() - .describe("Filter by specific collateral coin (e.g., 'BTC', 'ETH')"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Get list of assets that can be used as collateral for flexible loans. Shows LTV ratios and collateral limits.", + inputSchema: { + collateralCoin: z + .string() + .optional() + .describe("Filter by specific collateral coin (e.g., 'BTC', 'ETH')"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-crypto-loans/flexible-api/getFlexibleLoanAssets.ts b/src/tools/binance-crypto-loans/flexible-api/getFlexibleLoanAssets.ts index 0c481fec..dc697410 100644 --- a/src/tools/binance-crypto-loans/flexible-api/getFlexibleLoanAssets.ts +++ b/src/tools/binance-crypto-loans/flexible-api/getFlexibleLoanAssets.ts @@ -12,15 +12,18 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFlexibleAssets(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoansFlexibleAssets", - "Get list of assets available for flexible crypto loans. Shows borrowable assets with interest rates and limits.", { - loanCoin: z - .string() - .optional() - .describe("Filter by specific loan coin (e.g., 'USDT', 'BUSD')"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Get list of assets available for flexible crypto loans. Shows borrowable assets with interest rates and limits.", + inputSchema: { + loanCoin: z + .string() + .optional() + .describe("Filter by specific loan coin (e.g., 'USDT', 'BUSD')"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-crypto-loans/flexible-api/getOngoingOrders.ts b/src/tools/binance-crypto-loans/flexible-api/getOngoingOrders.ts index ed2ff6d0..8a4f3122 100644 --- a/src/tools/binance-crypto-loans/flexible-api/getOngoingOrders.ts +++ b/src/tools/binance-crypto-loans/flexible-api/getOngoingOrders.ts @@ -12,15 +12,18 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFlexibleOngoing(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoansFlexibleOngoing", - "Get all ongoing flexible loan orders. Shows current loans with principal, interest, collateral, and LTV information.", { - loanCoin: z.string().optional().describe("Filter by loan coin"), - collateralCoin: z.string().optional().describe("Filter by collateral coin"), - current: z.number().int().min(1).optional().describe("Current page (default 1)"), - limit: z.number().int().min(1).max(100).optional().describe("Results per page (max 100)"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Get all ongoing flexible loan orders. Shows current loans with principal, interest, collateral, and LTV information.", + inputSchema: { + loanCoin: z.string().optional().describe("Filter by loan coin"), + collateralCoin: z.string().optional().describe("Filter by collateral coin"), + current: z.number().int().min(1).optional().describe("Current page (default 1)"), + limit: z.number().int().min(1).max(100).optional().describe("Results per page (max 100)"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-crypto-loans/flexible-api/getRepayHistory.ts b/src/tools/binance-crypto-loans/flexible-api/getRepayHistory.ts index 2eb02dca..a8b888d2 100644 --- a/src/tools/binance-crypto-loans/flexible-api/getRepayHistory.ts +++ b/src/tools/binance-crypto-loans/flexible-api/getRepayHistory.ts @@ -12,17 +12,20 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFlexibleRepayHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoansFlexibleRepayHistory", - "Get repayment history for flexible loans. Shows all past repayment transactions.", { - loanCoin: z.string().optional().describe("Filter by loan coin"), - collateralCoin: z.string().optional().describe("Filter by collateral coin"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - current: z.number().int().min(1).optional().describe("Current page (default 1)"), - limit: z.number().int().min(1).max(100).optional().describe("Results per page (max 100)"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Get repayment history for flexible loans. Shows all past repayment transactions.", + inputSchema: { + loanCoin: z.string().optional().describe("Filter by loan coin"), + collateralCoin: z.string().optional().describe("Filter by collateral coin"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + current: z.number().int().min(1).optional().describe("Current page (default 1)"), + limit: z.number().int().min(1).max(100).optional().describe("Results per page (max 100)"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-crypto-loans/flexible-api/repay.ts b/src/tools/binance-crypto-loans/flexible-api/repay.ts index 0e92e3ee..bb51e60a 100644 --- a/src/tools/binance-crypto-loans/flexible-api/repay.ts +++ b/src/tools/binance-crypto-loans/flexible-api/repay.ts @@ -12,19 +12,22 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCryptoLoansFlexibleRepay(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoansFlexibleRepay", - "Repay a flexible crypto loan. Repaying reduces your debt and unlocks collateral proportionally.", { - loanCoin: z.string().describe("Loan coin to repay (e.g., 'USDT')"), - collateralCoin: z.string().describe("Collateral coin used for the loan (e.g., 'BTC')"), - repayAmount: z.string().describe("Amount to repay"), - collateralReturn: z - .boolean() - .optional() - .describe("Whether to return collateral after full repayment (default: true)"), - fullRepayment: z.boolean().optional().describe("Whether this is a full repayment"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Repay a flexible crypto loan. Repaying reduces your debt and unlocks collateral proportionally.", + inputSchema: { + loanCoin: z.string().describe("Loan coin to repay (e.g., 'USDT')"), + collateralCoin: z.string().describe("Collateral coin used for the loan (e.g., 'BTC')"), + repayAmount: z.string().describe("Amount to repay"), + collateralReturn: z + .boolean() + .optional() + .describe("Whether to return collateral after full repayment (default: true)"), + fullRepayment: z.boolean().optional().describe("Whether this is a full repayment"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-crypto-loans/flexibleLoanAdjustLTV.ts b/src/tools/binance-crypto-loans/flexibleLoanAdjustLTV.ts index 8c1dbb36..7d092b06 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanAdjustLTV.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanAdjustLTV.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../config/binanceClient.js"; export function registerBinanceCryptoLoanFlexibleLoanAdjustLTV(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoanFlexibleLoanAdjustLTV", - "Flexible loan adjust LTV (Loan-to-Value).", { - loanCoin: z.string().describe("Loan coin (e.g., USDT)"), - collateralCoin: z.string().describe("Collateral coin (e.g., BTC)"), - adjustmentAmount: z.number().describe("Adjustment amount"), - direction: z - .enum(["ADDITIONAL", "REDUCED"]) - .describe("Direction: ADDITIONAL = add collateral, REDUCED = reduce collateral"), + description: "Flexible loan adjust LTV (Loan-to-Value).", + inputSchema: { + loanCoin: z.string().describe("Loan coin (e.g., USDT)"), + collateralCoin: z.string().describe("Collateral coin (e.g., BTC)"), + adjustmentAmount: z.number().describe("Adjustment amount"), + direction: z + .enum(["ADDITIONAL", "REDUCED"]) + .describe("Direction: ADDITIONAL = add collateral, REDUCED = reduce collateral"), + }, }, async ({ loanCoin, collateralCoin, adjustmentAmount, direction }) => { try { diff --git a/src/tools/binance-crypto-loans/flexibleLoanBorrow.ts b/src/tools/binance-crypto-loans/flexibleLoanBorrow.ts index e021b0ca..f798c1b0 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanBorrow.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanBorrow.ts @@ -6,14 +6,16 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../config/binanceClient.js"; export function registerBinanceCryptoLoanFlexibleLoanBorrow(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoanFlexibleLoanBorrow", - "Flexible loan borrow.", { - loanCoin: z.string().describe("Loan coin (e.g., USDT)"), - collateralCoin: z.string().describe("Collateral coin (e.g., BTC)"), - loanAmount: z.number().optional().describe("Loan amount"), - collateralAmount: z.number().optional().describe("Collateral amount"), + description: "Flexible loan borrow.", + inputSchema: { + loanCoin: z.string().describe("Loan coin (e.g., USDT)"), + collateralCoin: z.string().describe("Collateral coin (e.g., BTC)"), + loanAmount: z.number().optional().describe("Loan amount"), + collateralAmount: z.number().optional().describe("Collateral amount"), + }, }, async ({ loanCoin, collateralCoin, loanAmount, collateralAmount }) => { try { diff --git a/src/tools/binance-crypto-loans/flexibleLoanBorrowHistory.ts b/src/tools/binance-crypto-loans/flexibleLoanBorrowHistory.ts index 3ad7d3b2..4c5d5a38 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanBorrowHistory.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanBorrowHistory.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../config/binanceClient.js"; export function registerBinanceCryptoLoanFlexibleLoanBorrowHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoanFlexibleLoanBorrowHistory", - "Get flexible loan borrow history.", { - loanCoin: z.string().optional().describe("Loan coin (e.g., USDT)"), - collateralCoin: z.string().optional().describe("Collateral coin (e.g., BTC)"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - current: z.number().optional().describe("Current page"), - limit: z.number().optional().describe("Page size, max 100"), + description: "Get flexible loan borrow history.", + inputSchema: { + loanCoin: z.string().optional().describe("Loan coin (e.g., USDT)"), + collateralCoin: z.string().optional().describe("Collateral coin (e.g., BTC)"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + current: z.number().optional().describe("Current page"), + limit: z.number().optional().describe("Page size, max 100"), + }, }, async ({ loanCoin, collateralCoin, startTime, endTime, current, limit }) => { try { diff --git a/src/tools/binance-crypto-loans/flexibleLoanCollateralAssets.ts b/src/tools/binance-crypto-loans/flexibleLoanCollateralAssets.ts index 30b88153..654e9bab 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanCollateralAssets.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanCollateralAssets.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../config/binanceClient.js"; export function registerBinanceCryptoLoanFlexibleLoanCollateralAssets(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoanFlexibleLoanCollateralAssets", - "Get flexible loan collateral assets.", { - collateralCoin: z.string().optional().describe("Collateral coin (e.g., BTC)"), + description: "Get flexible loan collateral assets.", + inputSchema: { + collateralCoin: z.string().optional().describe("Collateral coin (e.g., BTC)"), + }, }, async ({ collateralCoin }) => { try { diff --git a/src/tools/binance-crypto-loans/flexibleLoanLTVAdjustmentHistory.ts b/src/tools/binance-crypto-loans/flexibleLoanLTVAdjustmentHistory.ts index 0e3a78b5..8064ea68 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanLTVAdjustmentHistory.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanLTVAdjustmentHistory.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../config/binanceClient.js"; export function registerBinanceCryptoLoanFlexibleLoanLTVAdjustmentHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoanFlexibleLoanLTVAdjustmentHistory", - "Get flexible loan LTV adjustment history.", { - loanCoin: z.string().optional().describe("Loan coin (e.g., USDT)"), - collateralCoin: z.string().optional().describe("Collateral coin (e.g., BTC)"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - current: z.number().optional().describe("Current page"), - limit: z.number().optional().describe("Page size, max 100"), + description: "Get flexible loan LTV adjustment history.", + inputSchema: { + loanCoin: z.string().optional().describe("Loan coin (e.g., USDT)"), + collateralCoin: z.string().optional().describe("Collateral coin (e.g., BTC)"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + current: z.number().optional().describe("Current page"), + limit: z.number().optional().describe("Page size, max 100"), + }, }, async ({ loanCoin, collateralCoin, startTime, endTime, current, limit }) => { try { diff --git a/src/tools/binance-crypto-loans/flexibleLoanLoanableAssets.ts b/src/tools/binance-crypto-loans/flexibleLoanLoanableAssets.ts index 28f6e0fe..9e24f0bf 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanLoanableAssets.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanLoanableAssets.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../config/binanceClient.js"; export function registerBinanceCryptoLoanFlexibleLoanableAssets(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoanFlexibleLoanableAssets", - "Get flexible loan loanable assets data.", { - loanCoin: z.string().optional().describe("Loan coin"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Get flexible loan loanable assets data.", + inputSchema: { + loanCoin: z.string().optional().describe("Loan coin"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-crypto-loans/flexibleLoanOngoingOrders.ts b/src/tools/binance-crypto-loans/flexibleLoanOngoingOrders.ts index 3ea1c402..04ae6576 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanOngoingOrders.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanOngoingOrders.ts @@ -6,14 +6,16 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../config/binanceClient.js"; export function registerBinanceCryptoLoanFlexibleLoanOngoingOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoanFlexibleLoanOngoingOrders", - "Get flexible loan ongoing orders.", { - loanCoin: z.string().optional().describe("Loan coin (e.g., USDT)"), - collateralCoin: z.string().optional().describe("Collateral coin (e.g., BTC)"), - current: z.number().optional().describe("Current page"), - limit: z.number().optional().describe("Page size, max 100"), + description: "Get flexible loan ongoing orders.", + inputSchema: { + loanCoin: z.string().optional().describe("Loan coin (e.g., USDT)"), + collateralCoin: z.string().optional().describe("Collateral coin (e.g., BTC)"), + current: z.number().optional().describe("Current page"), + limit: z.number().optional().describe("Page size, max 100"), + }, }, async ({ loanCoin, collateralCoin, current, limit }) => { try { diff --git a/src/tools/binance-crypto-loans/flexibleLoanRepay.ts b/src/tools/binance-crypto-loans/flexibleLoanRepay.ts index b5f9311e..2f46d92c 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanRepay.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanRepay.ts @@ -6,15 +6,17 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../config/binanceClient.js"; export function registerBinanceCryptoLoanFlexibleLoanRepay(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoanFlexibleLoanRepay", - "Flexible loan repay.", { - loanCoin: z.string().describe("Loan coin (e.g., USDT)"), - collateralCoin: z.string().describe("Collateral coin (e.g., BTC)"), - repayAmount: z.number().describe("Repay amount"), - collateralReturn: z.boolean().optional().describe("Whether to return collateral"), - fullRepayment: z.boolean().optional().describe("Whether to do full repayment"), + description: "Flexible loan repay.", + inputSchema: { + loanCoin: z.string().describe("Loan coin (e.g., USDT)"), + collateralCoin: z.string().describe("Collateral coin (e.g., BTC)"), + repayAmount: z.number().describe("Repay amount"), + collateralReturn: z.boolean().optional().describe("Whether to return collateral"), + fullRepayment: z.boolean().optional().describe("Whether to do full repayment"), + }, }, async ({ loanCoin, collateralCoin, repayAmount, collateralReturn, fullRepayment }) => { try { diff --git a/src/tools/binance-crypto-loans/flexibleLoanRepayHistory.ts b/src/tools/binance-crypto-loans/flexibleLoanRepayHistory.ts index 838e96c3..5f3a209f 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanRepayHistory.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanRepayHistory.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../config/binanceClient.js"; export function registerBinanceCryptoLoanFlexibleLoanRepayHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoanFlexibleLoanRepayHistory", - "Get flexible loan repayment history.", { - loanCoin: z.string().optional().describe("Loan coin (e.g., USDT)"), - collateralCoin: z.string().optional().describe("Collateral coin (e.g., BTC)"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - current: z.number().optional().describe("Current page"), - limit: z.number().optional().describe("Page size, max 100"), + description: "Get flexible loan repayment history.", + inputSchema: { + loanCoin: z.string().optional().describe("Loan coin (e.g., USDT)"), + collateralCoin: z.string().optional().describe("Collateral coin (e.g., BTC)"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + current: z.number().optional().describe("Current page"), + limit: z.number().optional().describe("Page size, max 100"), + }, }, async ({ loanCoin, collateralCoin, startTime, endTime, current, limit }) => { try { diff --git a/src/tools/binance-crypto-loans/getCollateralAssetsData.ts b/src/tools/binance-crypto-loans/getCollateralAssetsData.ts index 7f7706fe..78051e62 100644 --- a/src/tools/binance-crypto-loans/getCollateralAssetsData.ts +++ b/src/tools/binance-crypto-loans/getCollateralAssetsData.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../config/binanceClient.js"; export function registerBinanceCryptoLoanGetCollateralAssetsDataV2(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoanGetCollateralAssetsDataV2", - "Get collateral assets data V2 for flexible crypto loans.", { - collateralCoin: z.string().optional().describe("Collateral coin (e.g., BTC)"), - vipLevel: z.number().optional().describe("VIP level"), + description: "Get collateral assets data V2 for flexible crypto loans.", + inputSchema: { + collateralCoin: z.string().optional().describe("Collateral coin (e.g., BTC)"), + vipLevel: z.number().optional().describe("VIP level"), + }, }, async ({ collateralCoin, vipLevel }) => { try { diff --git a/src/tools/binance-crypto-loans/getCollateralRepayRate.ts b/src/tools/binance-crypto-loans/getCollateralRepayRate.ts index cc06d5b0..57c52810 100644 --- a/src/tools/binance-crypto-loans/getCollateralRepayRate.ts +++ b/src/tools/binance-crypto-loans/getCollateralRepayRate.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../config/binanceClient.js"; export function registerBinanceCryptoLoanGetCollateralRepayRate(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoanGetCollateralRepayRate", - "Check collateral repay rate for crypto loans.", { - loanCoin: z.string().describe("Loan coin (e.g., USDT)"), - collateralCoin: z.string().describe("Collateral coin (e.g., BTC)"), - repayAmount: z.number().describe("Repay amount"), + description: "Check collateral repay rate for crypto loans.", + inputSchema: { + loanCoin: z.string().describe("Loan coin (e.g., USDT)"), + collateralCoin: z.string().describe("Collateral coin (e.g., BTC)"), + repayAmount: z.number().describe("Repay amount"), + }, }, async ({ loanCoin, collateralCoin, repayAmount }) => { try { diff --git a/src/tools/binance-crypto-loans/getLoanableAssetsData.ts b/src/tools/binance-crypto-loans/getLoanableAssetsData.ts index 94f0b89f..f8bbb8fd 100644 --- a/src/tools/binance-crypto-loans/getLoanableAssetsData.ts +++ b/src/tools/binance-crypto-loans/getLoanableAssetsData.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { cryptoLoanClient } from "../../config/binanceClient.js"; export function registerBinanceCryptoLoanGetLoanableAssetsDataV2(server: McpServer) { - server.tool( + server.registerTool( "BinanceCryptoLoanGetLoanableAssetsDataV2", - "Get loanable assets data V2 for flexible crypto loans.", { - loanCoin: z.string().optional().describe("Loan coin (e.g., USDT)"), - vipLevel: z.number().optional().describe("VIP level"), + description: "Get loanable assets data V2 for flexible crypto loans.", + inputSchema: { + loanCoin: z.string().optional().describe("Loan coin (e.g., USDT)"), + vipLevel: z.number().optional().describe("VIP level"), + }, }, async ({ loanCoin, vipLevel }) => { try { diff --git a/src/tools/binance-dual-investment/market-api/getDualInvestmentProductList.ts b/src/tools/binance-dual-investment/market-api/getDualInvestmentProductList.ts index 0af64c24..3676a381 100644 --- a/src/tools/binance-dual-investment/market-api/getDualInvestmentProductList.ts +++ b/src/tools/binance-dual-investment/market-api/getDualInvestmentProductList.ts @@ -6,27 +6,30 @@ import { z } from "zod"; import { dualInvestmentClient } from "../../../config/binanceClient.js"; export function registerBinanceGetDualInvestmentProductList(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetDualInvestmentProductList", - "Retrieve available Dual Investment products (CALL or PUT options), specifying invest and exercised coins, to view details like APR, strike price, duration, and purchase availability.", { - optionType: z.enum(["CALL", "PUT"]).describe("Input CALL or PUT"), - exercisedCoin: z.string().describe("Target exercised asset, e.g., USDT or BNB"), - investCoin: z.string().describe("Asset used for subscribing, e.g., BNB or USDT"), - pageSize: z - .number() - .int() - .max(100, "Maximum pageSize is 100") - .default(10) - .optional() - .describe("Number of records per page, default 10, max 100"), - pageIndex: z.number().int().default(1).optional().describe("Page index, default is 1"), - recvWindow: z - .number() - .int() - .max(60000, "recvWindow cannot be greater than 60000") - .optional() - .describe("Optional time window for request validity"), + description: + "Retrieve available Dual Investment products (CALL or PUT options), specifying invest and exercised coins, to view details like APR, strike price, duration, and purchase availability.", + inputSchema: { + optionType: z.enum(["CALL", "PUT"]).describe("Input CALL or PUT"), + exercisedCoin: z.string().describe("Target exercised asset, e.g., USDT or BNB"), + investCoin: z.string().describe("Asset used for subscribing, e.g., BNB or USDT"), + pageSize: z + .number() + .int() + .max(100, "Maximum pageSize is 100") + .default(10) + .optional() + .describe("Number of records per page, default 10, max 100"), + pageIndex: z.number().int().default(1).optional().describe("Page index, default is 1"), + recvWindow: z + .number() + .int() + .max(60000, "recvWindow cannot be greater than 60000") + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-dual-investment/trade-api/changeAutoCompoundStatus.ts b/src/tools/binance-dual-investment/trade-api/changeAutoCompoundStatus.ts index 97749554..888ad64b 100644 --- a/src/tools/binance-dual-investment/trade-api/changeAutoCompoundStatus.ts +++ b/src/tools/binance-dual-investment/trade-api/changeAutoCompoundStatus.ts @@ -6,21 +6,24 @@ import { z } from "zod"; import { dualInvestmentClient } from "../../../config/binanceClient.js"; export function registerBinanceChangeAutoCompoundStatus(server: McpServer) { - server.tool( + server.registerTool( "registerBinanceChangeAutoCompoundStatus", - "Change the Auto-Compound plan for a Dual Investment position to NONE, STANDARD, or ADVANCED using the position ID.", { - positionId: z.string().describe("Get positionId from /sapi/v1/dci/product/positions"), - autoCompoundPlan: z - .enum(["NONE", "STANDARD", "ADVANCED"]) - .optional() - .describe("Auto compound plan: NONE, STANDARD, or ADVANCED"), - recvWindow: z - .number() - .int() - .max(60000) - .optional() - .describe("Optional time window for request validity (max 60000)"), + description: + "Change the Auto-Compound plan for a Dual Investment position to NONE, STANDARD, or ADVANCED using the position ID.", + inputSchema: { + positionId: z.string().describe("Get positionId from /sapi/v1/dci/product/positions"), + autoCompoundPlan: z + .enum(["NONE", "STANDARD", "ADVANCED"]) + .optional() + .describe("Auto compound plan: NONE, STANDARD, or ADVANCED"), + recvWindow: z + .number() + .int() + .max(60000) + .optional() + .describe("Optional time window for request validity (max 60000)"), + }, }, async (params) => { try { diff --git a/src/tools/binance-dual-investment/trade-api/checkDualInvestmentAccounts.ts b/src/tools/binance-dual-investment/trade-api/checkDualInvestmentAccounts.ts index 4fa4e18b..cca74369 100644 --- a/src/tools/binance-dual-investment/trade-api/checkDualInvestmentAccounts.ts +++ b/src/tools/binance-dual-investment/trade-api/checkDualInvestmentAccounts.ts @@ -6,16 +6,19 @@ import { z } from "zod"; import { dualInvestmentClient } from "../../../config/binanceClient.js"; export function registerBinanceCheckDualInvestmentAccounts(server: McpServer) { - server.tool( + server.registerTool( "BinanceCheckDualInvestmentAccounts", - "Retrieve Dual Investment account balances, including total value in BTC and USDT equivalents.", { - recvWindow: z - .number() - .int() - .max(60000) - .optional() - .describe("Optional time window for request validity (max 60000)"), + description: + "Retrieve Dual Investment account balances, including total value in BTC and USDT equivalents.", + inputSchema: { + recvWindow: z + .number() + .int() + .max(60000) + .optional() + .describe("Optional time window for request validity (max 60000)"), + }, }, async (params) => { try { diff --git a/src/tools/binance-dual-investment/trade-api/getDualInvestmentPositions.ts b/src/tools/binance-dual-investment/trade-api/getDualInvestmentPositions.ts index f7138155..34115870 100644 --- a/src/tools/binance-dual-investment/trade-api/getDualInvestmentPositions.ts +++ b/src/tools/binance-dual-investment/trade-api/getDualInvestmentPositions.ts @@ -6,38 +6,41 @@ import { z } from "zod"; import { dualInvestmentClient } from "../../../config/binanceClient.js"; export function registerBinanceGetDualInvestmentPositions(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetDualInvestmentPositions", - "Fetch Dual Investment positions in batch, including status, subscription details, APR, and settlement info. Filter by status or paginate results.", { - status: z - .enum([ - "PENDING", - "PURCHASE_SUCCESS", - "SETTLED", - "PURCHASE_FAIL", - "REFUNDING", - "REFUND_SUCCESS", - "SETTLING", - ]) - .optional() - .describe( - "Position status: PENDING (awaiting results), PURCHASE_SUCCESS, SETTLED, PURCHASE_FAIL, REFUNDING, REFUND_SUCCESS, or SETTLING. If not provided, returns all.", - ), - pageSize: z - .number() - .int() - .min(1) - .max(100) - .optional() - .describe("Number of items per page, default 10, max 100"), - pageIndex: z.number().int().min(1).optional().describe("Page index, default 1"), - recvWindow: z - .number() - .int() - .max(60000) - .optional() - .describe("Optional time window for request validity (max 60000)"), + description: + "Fetch Dual Investment positions in batch, including status, subscription details, APR, and settlement info. Filter by status or paginate results.", + inputSchema: { + status: z + .enum([ + "PENDING", + "PURCHASE_SUCCESS", + "SETTLED", + "PURCHASE_FAIL", + "REFUNDING", + "REFUND_SUCCESS", + "SETTLING", + ]) + .optional() + .describe( + "Position status: PENDING (awaiting results), PURCHASE_SUCCESS, SETTLED, PURCHASE_FAIL, REFUNDING, REFUND_SUCCESS, or SETTLING. If not provided, returns all.", + ), + pageSize: z + .number() + .int() + .min(1) + .max(100) + .optional() + .describe("Number of items per page, default 10, max 100"), + pageIndex: z.number().int().min(1).optional().describe("Page index, default 1"), + recvWindow: z + .number() + .int() + .max(60000) + .optional() + .describe("Optional time window for request validity (max 60000)"), + }, }, async (params) => { try { diff --git a/src/tools/binance-dual-investment/trade-api/subscribeDualInvestmentProducts.ts b/src/tools/binance-dual-investment/trade-api/subscribeDualInvestmentProducts.ts index b9b179fc..5f84f4d4 100644 --- a/src/tools/binance-dual-investment/trade-api/subscribeDualInvestmentProducts.ts +++ b/src/tools/binance-dual-investment/trade-api/subscribeDualInvestmentProducts.ts @@ -6,22 +6,25 @@ import { z } from "zod"; import { dualInvestmentClient } from "../../../config/binanceClient.js"; export function registerBinanceSubscribeDualInvestmentProducts(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubscribeDualInvestmentProducts", - "Subscribe to Dual Investment products by providing product ID, order ID, deposit amount, and auto compound plan to initiate investment with specified terms.", { - id: z.string().describe("Product ID from /sapi/v1/dci/product/list"), - orderId: z.string().describe("Order ID from /sapi/v1/dci/product/list"), - depositAmount: z.number().positive().describe("The amount for subscribing"), - autoCompoundPlan: z - .enum(["NONE", "STANDARD", "ADVANCED"]) - .describe("Auto-compound plan: NONE (off), STANDARD, or ADVANCED"), - recvWindow: z - .number() - .int() - .max(60000, "recvWindow cannot be greater than 60000") - .optional() - .describe("Optional time window for request validity"), + description: + "Subscribe to Dual Investment products by providing product ID, order ID, deposit amount, and auto compound plan to initiate investment with specified terms.", + inputSchema: { + id: z.string().describe("Product ID from /sapi/v1/dci/product/list"), + orderId: z.string().describe("Order ID from /sapi/v1/dci/product/list"), + depositAmount: z.number().positive().describe("The amount for subscribing"), + autoCompoundPlan: z + .enum(["NONE", "STANDARD", "ADVANCED"]) + .describe("Auto-compound plan: NONE (off), STANDARD, or ADVANCED"), + recvWindow: z + .number() + .int() + .max(60000, "recvWindow cannot be greater than 60000") + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-fiat/fiat-api/getFiatDepositWithdrawHistory.ts b/src/tools/binance-fiat/fiat-api/getFiatDepositWithdrawHistory.ts index df6445a1..9b7e5f96 100644 --- a/src/tools/binance-fiat/fiat-api/getFiatDepositWithdrawHistory.ts +++ b/src/tools/binance-fiat/fiat-api/getFiatDepositWithdrawHistory.ts @@ -6,23 +6,30 @@ import { z } from "zod"; import { fiatClient } from "../../../config/binanceClient.js"; export function registerBinanceGetFiatDepositWithdrawHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetFiatDepositWithdrawHistory", - "Fetches fiat deposit or withdrawal history, showing transaction details like amount, currency, method, status, and timestamps.", { - transactionType: z - .enum(["0", "1"]) - .describe("Transaction type: 0 for deposit, 1 for withdraw"), - beginTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - page: z.number().int().optional().describe("Page number, default is 1"), - rows: z - .number() - .int() - .max(500, "Rows cannot be greater than 500") - .optional() - .describe("Number of records per page, default 100, max 500"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Fetches fiat deposit or withdrawal history, showing transaction details like amount, currency, method, status, and timestamps.", + inputSchema: { + transactionType: z + .enum(["0", "1"]) + .describe("Transaction type: 0 for deposit, 1 for withdraw"), + beginTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + page: z.number().int().optional().describe("Page number, default is 1"), + rows: z + .number() + .int() + .max(500, "Rows cannot be greater than 500") + .optional() + .describe("Number of records per page, default 100, max 500"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-fiat/fiat-api/getFiatPaymentsHistory.ts b/src/tools/binance-fiat/fiat-api/getFiatPaymentsHistory.ts index 0629c1c4..b2e4a1dc 100644 --- a/src/tools/binance-fiat/fiat-api/getFiatPaymentsHistory.ts +++ b/src/tools/binance-fiat/fiat-api/getFiatPaymentsHistory.ts @@ -6,21 +6,28 @@ import { z } from "zod"; import { fiatClient } from "../../../config/binanceClient.js"; export function registerBinanceGetFiatPaymentsHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetFiatPaymentsHistory", - "Retrieves fiat buy/sell payment history, including trade amount, currency, crypto received, fees, status, payment method, and timestamps.", { - transactionType: z.enum(["0", "1"]).describe("Transaction type: 0 for buy, 1 for sell"), - beginTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - page: z.number().int().optional().describe("Page number, default is 1"), - rows: z - .number() - .int() - .max(500, "Rows cannot be greater than 500") - .optional() - .describe("Number of records per page, default 100, max 500"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Retrieves fiat buy/sell payment history, including trade amount, currency, crypto received, fees, status, payment method, and timestamps.", + inputSchema: { + transactionType: z.enum(["0", "1"]).describe("Transaction type: 0 for buy, 1 for sell"), + beginTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + page: z.number().int().optional().describe("Page number, default is 1"), + rows: z + .number() + .int() + .max(500, "Rows cannot be greater than 500") + .optional() + .describe("Number of records per page, default 100, max 500"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/account-api/account.ts b/src/tools/binance-futures-coinm/account-api/account.ts index a8933ef9..fadf824e 100644 --- a/src/tools/binance-futures-coinm/account-api/account.ts +++ b/src/tools/binance-futures-coinm/account-api/account.ts @@ -12,11 +12,14 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryAccount(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryAccount", - "Get current COIN-M Futures account information including assets, positions, and risk metrics.", { - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Get current COIN-M Futures account information including assets, positions, and risk metrics.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/account-api/adlQuantile.ts b/src/tools/binance-futures-coinm/account-api/adlQuantile.ts index 83bde3af..c97e0a2b 100644 --- a/src/tools/binance-futures-coinm/account-api/adlQuantile.ts +++ b/src/tools/binance-futures-coinm/account-api/adlQuantile.ts @@ -12,12 +12,15 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryAdlQuantile(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryAdlQuantile", - "Get ADL (Auto-Deleveraging) quantile estimation for COIN-M Futures positions. Higher values indicate higher priority for deleveraging.", { - symbol: z.string().optional().describe("Contract symbol filter"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Get ADL (Auto-Deleveraging) quantile estimation for COIN-M Futures positions. Higher values indicate higher priority for deleveraging.", + inputSchema: { + symbol: z.string().optional().describe("Contract symbol filter"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/account-api/balance.ts b/src/tools/binance-futures-coinm/account-api/balance.ts index b7ddeca3..3b739867 100644 --- a/src/tools/binance-futures-coinm/account-api/balance.ts +++ b/src/tools/binance-futures-coinm/account-api/balance.ts @@ -12,11 +12,13 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryBalance(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryBalance", - "Get current COIN-M Futures account balance.", { - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Get current COIN-M Futures account balance.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/account-api/commissionRate.ts b/src/tools/binance-futures-coinm/account-api/commissionRate.ts index 1b79d54e..1bc92a49 100644 --- a/src/tools/binance-futures-coinm/account-api/commissionRate.ts +++ b/src/tools/binance-futures-coinm/account-api/commissionRate.ts @@ -12,12 +12,14 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryCommissionRate(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryCommissionRate", - "Get user's COIN-M Futures commission rate for a symbol.", { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Get user's COIN-M Futures commission rate for a symbol.", + inputSchema: { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/account-api/forceOrders.ts b/src/tools/binance-futures-coinm/account-api/forceOrders.ts index c9f3e7ff..a9368ebd 100644 --- a/src/tools/binance-futures-coinm/account-api/forceOrders.ts +++ b/src/tools/binance-futures-coinm/account-api/forceOrders.ts @@ -12,16 +12,18 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryForceOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryForceOrders", - "Get user's COIN-M Futures force (liquidation) order history.", { - symbol: z.string().optional().describe("Contract symbol filter"), - autoCloseType: z.enum(["LIQUIDATION", "ADL"]).optional().describe("LIQUIDATION or ADL"), - startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().int().optional().describe("End timestamp in milliseconds"), - limit: z.number().int().optional().describe("Number of results (default 50, max 100)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Get user's COIN-M Futures force (liquidation) order history.", + inputSchema: { + symbol: z.string().optional().describe("Contract symbol filter"), + autoCloseType: z.enum(["LIQUIDATION", "ADL"]).optional().describe("LIQUIDATION or ADL"), + startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().int().optional().describe("End timestamp in milliseconds"), + limit: z.number().int().optional().describe("Number of results (default 50, max 100)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/account-api/income.ts b/src/tools/binance-futures-coinm/account-api/income.ts index d1ca0038..eeaae0a1 100644 --- a/src/tools/binance-futures-coinm/account-api/income.ts +++ b/src/tools/binance-futures-coinm/account-api/income.ts @@ -12,31 +12,34 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryIncome(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryIncome", - "Get COIN-M Futures income history including realized PnL, funding fees, commissions, etc.", { - symbol: z.string().optional().describe("Contract symbol filter"), - incomeType: z - .enum([ - "TRANSFER", - "WELCOME_BONUS", - "REALIZED_PNL", - "FUNDING_FEE", - "COMMISSION", - "INSURANCE_CLEAR", - "REFERRAL_KICKBACK", - "COMMISSION_REBATE", - "DELIVERED_SETTELMENT", - "COIN_SWAP_DEPOSIT", - "COIN_SWAP_WITHDRAW", - ]) - .optional() - .describe("Income type filter"), - startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().int().optional().describe("End timestamp in milliseconds"), - limit: z.number().int().optional().describe("Number of results (default 100, max 1000)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Get COIN-M Futures income history including realized PnL, funding fees, commissions, etc.", + inputSchema: { + symbol: z.string().optional().describe("Contract symbol filter"), + incomeType: z + .enum([ + "TRANSFER", + "WELCOME_BONUS", + "REALIZED_PNL", + "FUNDING_FEE", + "COMMISSION", + "INSURANCE_CLEAR", + "REFERRAL_KICKBACK", + "COMMISSION_REBATE", + "DELIVERED_SETTELMENT", + "COIN_SWAP_DEPOSIT", + "COIN_SWAP_WITHDRAW", + ]) + .optional() + .describe("Income type filter"), + startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().int().optional().describe("End timestamp in milliseconds"), + limit: z.number().int().optional().describe("Number of results (default 100, max 1000)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/account-api/leverageBracket.ts b/src/tools/binance-futures-coinm/account-api/leverageBracket.ts index b1962b19..f36b5e48 100644 --- a/src/tools/binance-futures-coinm/account-api/leverageBracket.ts +++ b/src/tools/binance-futures-coinm/account-api/leverageBracket.ts @@ -12,12 +12,15 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryLeverageBracket(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryLeverageBracket", - "Get notional and leverage bracket information for COIN-M Futures. Shows max leverage at different position sizes.", { - pair: z.string().optional().describe("Filter by underlying pair (e.g., BTCUSD)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Get notional and leverage bracket information for COIN-M Futures. Shows max leverage at different position sizes.", + inputSchema: { + pair: z.string().optional().describe("Filter by underlying pair (e.g., BTCUSD)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/account-api/positionMode.ts b/src/tools/binance-futures-coinm/account-api/positionMode.ts index fac0cabc..db6f6c34 100644 --- a/src/tools/binance-futures-coinm/account-api/positionMode.ts +++ b/src/tools/binance-futures-coinm/account-api/positionMode.ts @@ -12,11 +12,13 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryPositionMode(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryPositionMode", - "Get current COIN-M Futures position mode (Hedge Mode or One-way Mode).", { - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Get current COIN-M Futures position mode (Hedge Mode or One-way Mode).", + inputSchema: { + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/account-api/positionRisk.ts b/src/tools/binance-futures-coinm/account-api/positionRisk.ts index 7e705ed1..fe074f7e 100644 --- a/src/tools/binance-futures-coinm/account-api/positionRisk.ts +++ b/src/tools/binance-futures-coinm/account-api/positionRisk.ts @@ -12,13 +12,16 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryPositionRisk(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryPositionRisk", - "Get current COIN-M Futures position information including unrealized PnL and liquidation price.", { - marginAsset: z.string().optional().describe("Filter by margin asset (e.g., BTC)"), - pair: z.string().optional().describe("Filter by trading pair (e.g., BTCUSD)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Get current COIN-M Futures position information including unrealized PnL and liquidation price.", + inputSchema: { + marginAsset: z.string().optional().describe("Filter by margin asset (e.g., BTC)"), + pair: z.string().optional().describe("Filter by trading pair (e.g., BTCUSD)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/account-api/userTrades.ts b/src/tools/binance-futures-coinm/account-api/userTrades.ts index 5c0a64b7..ed501673 100644 --- a/src/tools/binance-futures-coinm/account-api/userTrades.ts +++ b/src/tools/binance-futures-coinm/account-api/userTrades.ts @@ -12,17 +12,19 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryUserTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryUserTrades", - "Get COIN-M Futures account trade history for a symbol.", { - symbol: z.string().optional().describe("Contract symbol (e.g., BTCUSD_PERP)"), - pair: z.string().optional().describe("Filter by underlying pair (e.g., BTCUSD)"), - startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().int().optional().describe("End timestamp in milliseconds"), - fromId: z.number().int().optional().describe("Trade ID to fetch from"), - limit: z.number().int().optional().describe("Number of results (default 50, max 1000)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Get COIN-M Futures account trade history for a symbol.", + inputSchema: { + symbol: z.string().optional().describe("Contract symbol (e.g., BTCUSD_PERP)"), + pair: z.string().optional().describe("Filter by underlying pair (e.g., BTCUSD)"), + startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().int().optional().describe("End timestamp in milliseconds"), + fromId: z.number().int().optional().describe("Trade ID to fetch from"), + limit: z.number().int().optional().describe("Number of results (default 50, max 1000)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/account.ts b/src/tools/binance-futures-coinm/account.ts index c00edf69..06cb9e21 100644 --- a/src/tools/binance-futures-coinm/account.ts +++ b/src/tools/binance-futures-coinm/account.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMAccount(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMAccount", - "Get current COIN-M futures account information.", { - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Get current COIN-M futures account information.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/adlQuantile.ts b/src/tools/binance-futures-coinm/adlQuantile.ts index 44c4f3e0..8d6cdabf 100644 --- a/src/tools/binance-futures-coinm/adlQuantile.ts +++ b/src/tools/binance-futures-coinm/adlQuantile.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMADLQuantile(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMADLQuantile", - "Get position ADL (Auto-Deleveraging) quantile estimate for COIN-M Futures.", { - symbol: z - .string() - .optional() - .describe( - "Symbol of the trading pair (e.g., BTCUSD_PERP). If not provided, returns all positions", - ), + description: "Get position ADL (Auto-Deleveraging) quantile estimate for COIN-M Futures.", + inputSchema: { + symbol: z + .string() + .optional() + .describe( + "Symbol of the trading pair (e.g., BTCUSD_PERP). If not provided, returns all positions", + ), + }, }, async ({ symbol }) => { try { diff --git a/src/tools/binance-futures-coinm/aggTrades.ts b/src/tools/binance-futures-coinm/aggTrades.ts index 6d7bb54f..5861ff10 100644 --- a/src/tools/binance-futures-coinm/aggTrades.ts +++ b/src/tools/binance-futures-coinm/aggTrades.ts @@ -6,21 +6,23 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMAggTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMAggTrades", - "Get compressed, aggregate trades for a specific COIN-M Futures trading pair.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), - fromId: z.number().optional().describe("ID to get aggregate trades from INCLUSIVE"), - startTime: z - .number() - .optional() - .describe("Timestamp in ms to get aggregate trades from INCLUSIVE"), - endTime: z - .number() - .optional() - .describe("Timestamp in ms to get aggregate trades until INCLUSIVE"), - limit: z.number().optional().describe("Default 500; max 1000"), + description: "Get compressed, aggregate trades for a specific COIN-M Futures trading pair.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + fromId: z.number().optional().describe("ID to get aggregate trades from INCLUSIVE"), + startTime: z + .number() + .optional() + .describe("Timestamp in ms to get aggregate trades from INCLUSIVE"), + endTime: z + .number() + .optional() + .describe("Timestamp in ms to get aggregate trades until INCLUSIVE"), + limit: z.number().optional().describe("Default 500; max 1000"), + }, }, async ({ symbol, fromId, startTime, endTime, limit }) => { try { diff --git a/src/tools/binance-futures-coinm/allOrders.ts b/src/tools/binance-futures-coinm/allOrders.ts index d2b37912..74bd1d11 100644 --- a/src/tools/binance-futures-coinm/allOrders.ts +++ b/src/tools/binance-futures-coinm/allOrders.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMAllOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMAllOrders", - "Get all orders (active, canceled, or filled) for COIN-M Futures.", { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), - pair: z.string().optional().describe("Trading pair (e.g., BTCUSD)"), - orderId: z.number().optional().describe("Order ID to start from"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1000"), + description: "Get all orders (active, canceled, or filled) for COIN-M Futures.", + inputSchema: { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + pair: z.string().optional().describe("Trading pair (e.g., BTCUSD)"), + orderId: z.number().optional().describe("Order ID to start from"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1000"), + }, }, async ({ symbol, pair, orderId, startTime, endTime, limit }) => { try { diff --git a/src/tools/binance-futures-coinm/balance.ts b/src/tools/binance-futures-coinm/balance.ts index a833070a..3bba3204 100644 --- a/src/tools/binance-futures-coinm/balance.ts +++ b/src/tools/binance-futures-coinm/balance.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMBalance(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMBalance", - "Get COIN-M futures account balance.", { - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Get COIN-M futures account balance.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/batchOrders.ts b/src/tools/binance-futures-coinm/batchOrders.ts index 35d6bfc4..97ae8023 100644 --- a/src/tools/binance-futures-coinm/batchOrders.ts +++ b/src/tools/binance-futures-coinm/batchOrders.ts @@ -6,15 +6,17 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMBatchOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMBatchOrders", - "Place multiple orders for COIN-M Futures (max 5 orders).", { - batchOrders: z - .string() - .describe( - "JSON string of order list. Max 5 orders. Each order has: symbol, side, type, and optional parameters", - ), + description: "Place multiple orders for COIN-M Futures (max 5 orders).", + inputSchema: { + batchOrders: z + .string() + .describe( + "JSON string of order list. Max 5 orders. Each order has: symbol, side, type, and optional parameters", + ), + }, }, async ({ batchOrders }) => { try { diff --git a/src/tools/binance-futures-coinm/bookTicker.ts b/src/tools/binance-futures-coinm/bookTicker.ts index ebfa9ea4..c37b4847 100644 --- a/src/tools/binance-futures-coinm/bookTicker.ts +++ b/src/tools/binance-futures-coinm/bookTicker.ts @@ -6,17 +6,20 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMBookTicker(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMBookTicker", - "Get best price/qty on the order book for a symbol or symbols for COIN-M Futures.", { - symbol: z - .string() - .optional() - .describe( - "Symbol of the trading pair (e.g., BTCUSD_PERP). If not provided, returns all symbols", - ), - pair: z.string().optional().describe("Trading pair (e.g., BTCUSD)"), + description: + "Get best price/qty on the order book for a symbol or symbols for COIN-M Futures.", + inputSchema: { + symbol: z + .string() + .optional() + .describe( + "Symbol of the trading pair (e.g., BTCUSD_PERP). If not provided, returns all symbols", + ), + pair: z.string().optional().describe("Trading pair (e.g., BTCUSD)"), + }, }, async ({ symbol, pair }) => { try { diff --git a/src/tools/binance-futures-coinm/cancelAllOrders.ts b/src/tools/binance-futures-coinm/cancelAllOrders.ts index f73df3b1..84d96cc5 100644 --- a/src/tools/binance-futures-coinm/cancelAllOrders.ts +++ b/src/tools/binance-futures-coinm/cancelAllOrders.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMCancelAllOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMCancelAllOrders", - "Cancel all open COIN-M futures orders for a symbol.", { - symbol: z.string().describe("Trading symbol"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Cancel all open COIN-M futures orders for a symbol.", + inputSchema: { + symbol: z.string().describe("Trading symbol"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/cancelBatchOrders.ts b/src/tools/binance-futures-coinm/cancelBatchOrders.ts index 2e21f9dc..cee5ac46 100644 --- a/src/tools/binance-futures-coinm/cancelBatchOrders.ts +++ b/src/tools/binance-futures-coinm/cancelBatchOrders.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMCancelBatchOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMCancelBatchOrders", - "Cancel multiple orders for COIN-M Futures.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), - orderIdList: z.string().optional().describe("Comma-separated list of order IDs (max 10)"), - origClientOrderIdList: z - .string() - .optional() - .describe("Comma-separated list of client order IDs (max 10)"), + description: "Cancel multiple orders for COIN-M Futures.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + orderIdList: z.string().optional().describe("Comma-separated list of order IDs (max 10)"), + origClientOrderIdList: z + .string() + .optional() + .describe("Comma-separated list of client order IDs (max 10)"), + }, }, async ({ symbol, orderIdList, origClientOrderIdList }) => { try { diff --git a/src/tools/binance-futures-coinm/cancelOrder.ts b/src/tools/binance-futures-coinm/cancelOrder.ts index e19d369d..52530b0c 100644 --- a/src/tools/binance-futures-coinm/cancelOrder.ts +++ b/src/tools/binance-futures-coinm/cancelOrder.ts @@ -6,14 +6,16 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMCancelOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMCancelOrder", - "Cancel a COIN-M futures order.", { - symbol: z.string().describe("Trading symbol"), - orderId: z.number().int().optional().describe("Order ID"), - origClientOrderId: z.string().optional().describe("Original client order ID"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Cancel a COIN-M futures order.", + inputSchema: { + symbol: z.string().describe("Trading symbol"), + orderId: z.number().int().optional().describe("Order ID"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/commissionRate.ts b/src/tools/binance-futures-coinm/commissionRate.ts index b24060ab..aa7f198c 100644 --- a/src/tools/binance-futures-coinm/commissionRate.ts +++ b/src/tools/binance-futures-coinm/commissionRate.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMCommissionRate(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMCommissionRate", - "Get user commission rate for COIN-M Futures.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + description: "Get user commission rate for COIN-M Futures.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + }, }, async ({ symbol }) => { try { diff --git a/src/tools/binance-futures-coinm/continuousKlines.ts b/src/tools/binance-futures-coinm/continuousKlines.ts index d4db7fbc..54e044d4 100644 --- a/src/tools/binance-futures-coinm/continuousKlines.ts +++ b/src/tools/binance-futures-coinm/continuousKlines.ts @@ -6,36 +6,38 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMContinuousKlines(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMContinuousKlines", - "Get continuous contract Kline/candlestick data for COIN-M Futures.", { - pair: z.string().describe("Trading pair (e.g., BTCUSD)"), - contractType: z - .enum(["PERPETUAL", "CURRENT_QUARTER", "NEXT_QUARTER"]) - .describe("Contract type"), - interval: z - .enum([ - "1m", - "3m", - "5m", - "15m", - "30m", - "1h", - "2h", - "4h", - "6h", - "8h", - "12h", - "1d", - "3d", - "1w", - "1M", - ]) - .describe("Kline interval"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1500"), + description: "Get continuous contract Kline/candlestick data for COIN-M Futures.", + inputSchema: { + pair: z.string().describe("Trading pair (e.g., BTCUSD)"), + contractType: z + .enum(["PERPETUAL", "CURRENT_QUARTER", "NEXT_QUARTER"]) + .describe("Contract type"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1500"), + }, }, async ({ pair, contractType, interval, startTime, endTime, limit }) => { try { diff --git a/src/tools/binance-futures-coinm/depth.ts b/src/tools/binance-futures-coinm/depth.ts index badc7b41..e89a5a50 100644 --- a/src/tools/binance-futures-coinm/depth.ts +++ b/src/tools/binance-futures-coinm/depth.ts @@ -6,17 +6,19 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMDepth(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMDepth", - "Get order book depth data for a specific COIN-M Futures trading pair.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), - limit: z - .number() - .optional() - .describe( - "Depth of the order book. Default 500; max 1000. Valid limits: [5, 10, 20, 50, 100, 500, 1000]", - ), + description: "Get order book depth data for a specific COIN-M Futures trading pair.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + limit: z + .number() + .optional() + .describe( + "Depth of the order book. Default 500; max 1000. Valid limits: [5, 10, 20, 50, 100, 500, 1000]", + ), + }, }, async ({ symbol, limit }) => { try { diff --git a/src/tools/binance-futures-coinm/exchangeInfo.ts b/src/tools/binance-futures-coinm/exchangeInfo.ts index b7fa79e2..f431af75 100644 --- a/src/tools/binance-futures-coinm/exchangeInfo.ts +++ b/src/tools/binance-futures-coinm/exchangeInfo.ts @@ -4,10 +4,11 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMExchangeInfo(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMExchangeInfo", - "Get current exchange trading rules and symbol information for COIN-M Futures.", - {}, + { + description: "Get current exchange trading rules and symbol information for COIN-M Futures.", + }, async () => { try { const data = await deliveryClient.exchangeInfo(); diff --git a/src/tools/binance-futures-coinm/forceOrders.ts b/src/tools/binance-futures-coinm/forceOrders.ts index 15d9bcde..4b956f55 100644 --- a/src/tools/binance-futures-coinm/forceOrders.ts +++ b/src/tools/binance-futures-coinm/forceOrders.ts @@ -6,18 +6,20 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMForceOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMForceOrders", - "Get user force orders (liquidation orders) for COIN-M Futures.", { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), - autoCloseType: z - .enum(["LIQUIDATION", "ADL"]) - .optional() - .describe("Auto close type: LIQUIDATION or ADL"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 50; max 100"), + description: "Get user force orders (liquidation orders) for COIN-M Futures.", + inputSchema: { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + autoCloseType: z + .enum(["LIQUIDATION", "ADL"]) + .optional() + .describe("Auto close type: LIQUIDATION or ADL"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 50; max 100"), + }, }, async ({ symbol, autoCloseType, startTime, endTime, limit }) => { try { diff --git a/src/tools/binance-futures-coinm/fundingRate.ts b/src/tools/binance-futures-coinm/fundingRate.ts index d7da615a..24f62e3b 100644 --- a/src/tools/binance-futures-coinm/fundingRate.ts +++ b/src/tools/binance-futures-coinm/fundingRate.ts @@ -6,14 +6,16 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMFundingRate(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMFundingRate", - "Get funding rate history for COIN-M Futures.", { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 100; max 1000"), + description: "Get funding rate history for COIN-M Futures.", + inputSchema: { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 100; max 1000"), + }, }, async ({ symbol, startTime, endTime, limit }) => { try { diff --git a/src/tools/binance-futures-coinm/getOrder.ts b/src/tools/binance-futures-coinm/getOrder.ts index 545d1e92..dd25d9d3 100644 --- a/src/tools/binance-futures-coinm/getOrder.ts +++ b/src/tools/binance-futures-coinm/getOrder.ts @@ -6,14 +6,16 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMGetOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMGetOrder", - "Query a COIN-M futures order.", { - symbol: z.string().describe("Trading symbol"), - orderId: z.number().int().optional().describe("Order ID"), - origClientOrderId: z.string().optional().describe("Original client order ID"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Query a COIN-M futures order.", + inputSchema: { + symbol: z.string().describe("Trading symbol"), + orderId: z.number().int().optional().describe("Order ID"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/historicalTrades.ts b/src/tools/binance-futures-coinm/historicalTrades.ts index fbc1bd29..d30785c7 100644 --- a/src/tools/binance-futures-coinm/historicalTrades.ts +++ b/src/tools/binance-futures-coinm/historicalTrades.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMHistoricalTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMHistoricalTrades", - "Get older market historical trades for a specific COIN-M Futures trading pair.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), - limit: z.number().optional().describe("Number of trades to return. Default 500; max 1000"), - fromId: z - .number() - .optional() - .describe("Trade ID to fetch from. Default gets most recent trades"), + description: "Get older market historical trades for a specific COIN-M Futures trading pair.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + limit: z.number().optional().describe("Number of trades to return. Default 500; max 1000"), + fromId: z + .number() + .optional() + .describe("Trade ID to fetch from. Default gets most recent trades"), + }, }, async ({ symbol, limit, fromId }) => { try { diff --git a/src/tools/binance-futures-coinm/income.ts b/src/tools/binance-futures-coinm/income.ts index 6559b393..4b3a9eaf 100644 --- a/src/tools/binance-futures-coinm/income.ts +++ b/src/tools/binance-futures-coinm/income.ts @@ -6,30 +6,32 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMIncome(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMIncome", - "Get income history for COIN-M Futures.", { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), - incomeType: z - .enum([ - "TRANSFER", - "WELCOME_BONUS", - "REALIZED_PNL", - "FUNDING_FEE", - "COMMISSION", - "INSURANCE_CLEAR", - "REFERRAL_KICKBACK", - "COMMISSION_REBATE", - "DELIVERED_SETTELMENT", - "COIN_SWAP_DEPOSIT", - "COIN_SWAP_WITHDRAW", - ]) - .optional() - .describe("Income type"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 100; max 1000"), + description: "Get income history for COIN-M Futures.", + inputSchema: { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + incomeType: z + .enum([ + "TRANSFER", + "WELCOME_BONUS", + "REALIZED_PNL", + "FUNDING_FEE", + "COMMISSION", + "INSURANCE_CLEAR", + "REFERRAL_KICKBACK", + "COMMISSION_REBATE", + "DELIVERED_SETTELMENT", + "COIN_SWAP_DEPOSIT", + "COIN_SWAP_WITHDRAW", + ]) + .optional() + .describe("Income type"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 100; max 1000"), + }, }, async ({ symbol, incomeType, startTime, endTime, limit }) => { try { diff --git a/src/tools/binance-futures-coinm/indexPriceKlines.ts b/src/tools/binance-futures-coinm/indexPriceKlines.ts index c6702409..a6291ce0 100644 --- a/src/tools/binance-futures-coinm/indexPriceKlines.ts +++ b/src/tools/binance-futures-coinm/indexPriceKlines.ts @@ -6,33 +6,35 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMIndexPriceKlines(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMIndexPriceKlines", - "Get index price Kline/candlestick data for COIN-M Futures.", { - pair: z.string().describe("Trading pair (e.g., BTCUSD)"), - interval: z - .enum([ - "1m", - "3m", - "5m", - "15m", - "30m", - "1h", - "2h", - "4h", - "6h", - "8h", - "12h", - "1d", - "3d", - "1w", - "1M", - ]) - .describe("Kline interval"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1500"), + description: "Get index price Kline/candlestick data for COIN-M Futures.", + inputSchema: { + pair: z.string().describe("Trading pair (e.g., BTCUSD)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1500"), + }, }, async ({ pair, interval, startTime, endTime, limit }) => { try { diff --git a/src/tools/binance-futures-coinm/klines.ts b/src/tools/binance-futures-coinm/klines.ts index 79045839..e2eca7a1 100644 --- a/src/tools/binance-futures-coinm/klines.ts +++ b/src/tools/binance-futures-coinm/klines.ts @@ -6,33 +6,35 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMKlines(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMKlines", - "Get Kline/candlestick bars for a specific COIN-M Futures trading pair.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), - interval: z - .enum([ - "1m", - "3m", - "5m", - "15m", - "30m", - "1h", - "2h", - "4h", - "6h", - "8h", - "12h", - "1d", - "3d", - "1w", - "1M", - ]) - .describe("Kline interval"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1500"), + description: "Get Kline/candlestick bars for a specific COIN-M Futures trading pair.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1500"), + }, }, async ({ symbol, interval, startTime, endTime, limit }) => { try { diff --git a/src/tools/binance-futures-coinm/leverage.ts b/src/tools/binance-futures-coinm/leverage.ts index c240f986..a008c58a 100644 --- a/src/tools/binance-futures-coinm/leverage.ts +++ b/src/tools/binance-futures-coinm/leverage.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMLeverage(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMLeverage", - "Change initial leverage for COIN-M futures symbol.", { - symbol: z.string().describe("Trading symbol"), - leverage: z.number().int().min(1).max(125).describe("Target leverage (1-125)"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Change initial leverage for COIN-M futures symbol.", + inputSchema: { + symbol: z.string().describe("Trading symbol"), + leverage: z.number().int().min(1).max(125).describe("Target leverage (1-125)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/listenKey.ts b/src/tools/binance-futures-coinm/listenKey.ts index 91ea97e1..a7226e7d 100644 --- a/src/tools/binance-futures-coinm/listenKey.ts +++ b/src/tools/binance-futures-coinm/listenKey.ts @@ -4,10 +4,12 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMListenKeyCreate(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMListenKeyCreate", - "Start a new user data stream for COIN-M Futures. Returns a listenKey for WebSocket connection.", - {}, + { + description: + "Start a new user data stream for COIN-M Futures. Returns a listenKey for WebSocket connection.", + }, async () => { try { const data = await deliveryClient.createListenKey(); @@ -35,10 +37,9 @@ export function registerBinanceFuturesCOINMListenKeyCreate(server: McpServer) { } export function registerBinanceFuturesCOINMListenKeyRenew(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMListenKeyRenew", - "Keepalive a user data stream to prevent timeout for COIN-M Futures.", - {}, + { description: "Keepalive a user data stream to prevent timeout for COIN-M Futures." }, async () => { try { const data = await deliveryClient.keepAliveListenKey(); @@ -66,10 +67,9 @@ export function registerBinanceFuturesCOINMListenKeyRenew(server: McpServer) { } export function registerBinanceFuturesCOINMListenKeyClose(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMListenKeyClose", - "Close a user data stream for COIN-M Futures.", - {}, + { description: "Close a user data stream for COIN-M Futures." }, async () => { try { const data = await deliveryClient.closeListenKey(); diff --git a/src/tools/binance-futures-coinm/marginType.ts b/src/tools/binance-futures-coinm/marginType.ts index c6482677..d2056dd6 100644 --- a/src/tools/binance-futures-coinm/marginType.ts +++ b/src/tools/binance-futures-coinm/marginType.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMMarginType(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMMarginType", - "Change margin type for a symbol in COIN-M Futures.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), - marginType: z.enum(["ISOLATED", "CROSSED"]).describe("Margin type: ISOLATED or CROSSED"), + description: "Change margin type for a symbol in COIN-M Futures.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + marginType: z.enum(["ISOLATED", "CROSSED"]).describe("Margin type: ISOLATED or CROSSED"), + }, }, async ({ symbol, marginType }) => { try { diff --git a/src/tools/binance-futures-coinm/markPriceKlines.ts b/src/tools/binance-futures-coinm/markPriceKlines.ts index bd11c57d..90b6cbc6 100644 --- a/src/tools/binance-futures-coinm/markPriceKlines.ts +++ b/src/tools/binance-futures-coinm/markPriceKlines.ts @@ -6,33 +6,35 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMMarkPriceKlines(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMMarkPriceKlines", - "Get mark price Kline/candlestick data for COIN-M Futures.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), - interval: z - .enum([ - "1m", - "3m", - "5m", - "15m", - "30m", - "1h", - "2h", - "4h", - "6h", - "8h", - "12h", - "1d", - "3d", - "1w", - "1M", - ]) - .describe("Kline interval"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1500"), + description: "Get mark price Kline/candlestick data for COIN-M Futures.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1500"), + }, }, async ({ symbol, interval, startTime, endTime, limit }) => { try { diff --git a/src/tools/binance-futures-coinm/market-api/aggTrades.ts b/src/tools/binance-futures-coinm/market-api/aggTrades.ts index 2f9aef26..95f81634 100644 --- a/src/tools/binance-futures-coinm/market-api/aggTrades.ts +++ b/src/tools/binance-futures-coinm/market-api/aggTrades.ts @@ -12,15 +12,18 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryAggTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryAggTrades", - "Get compressed/aggregate trades for a COIN-M Futures symbol. Trades that fill at the same time, from the same order, with the same price will be aggregated.", { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - fromId: z.number().int().optional().describe("ID to get aggregate trades from INCLUSIVE"), - startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().int().optional().describe("End timestamp in milliseconds"), - limit: z.number().int().optional().describe("Number of trades (default 500, max 1000)"), + description: + "Get compressed/aggregate trades for a COIN-M Futures symbol. Trades that fill at the same time, from the same order, with the same price will be aggregated.", + inputSchema: { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + fromId: z.number().int().optional().describe("ID to get aggregate trades from INCLUSIVE"), + startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().int().optional().describe("End timestamp in milliseconds"), + limit: z.number().int().optional().describe("Number of trades (default 500, max 1000)"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/market-api/bookTicker.ts b/src/tools/binance-futures-coinm/market-api/bookTicker.ts index 9b989efa..db0e45e2 100644 --- a/src/tools/binance-futures-coinm/market-api/bookTicker.ts +++ b/src/tools/binance-futures-coinm/market-api/bookTicker.ts @@ -12,15 +12,17 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryTickerBookTicker(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryTickerBookTicker", - "Get best bid/ask price and quantity for COIN-M Futures symbol(s).", { - symbol: z - .string() - .optional() - .describe("Contract symbol (e.g., BTCUSD_PERP). If not provided, returns all symbols"), - pair: z.string().optional().describe("Filter by underlying pair (e.g., BTCUSD)"), + description: "Get best bid/ask price and quantity for COIN-M Futures symbol(s).", + inputSchema: { + symbol: z + .string() + .optional() + .describe("Contract symbol (e.g., BTCUSD_PERP). If not provided, returns all symbols"), + pair: z.string().optional().describe("Filter by underlying pair (e.g., BTCUSD)"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/market-api/continuousKlines.ts b/src/tools/binance-futures-coinm/market-api/continuousKlines.ts index b398e4fd..87cc354b 100644 --- a/src/tools/binance-futures-coinm/market-api/continuousKlines.ts +++ b/src/tools/binance-futures-coinm/market-api/continuousKlines.ts @@ -12,36 +12,39 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryContinuousKlines(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryContinuousKlines", - "Get continuous contract kline/candlestick data for a COIN-M Futures pair. Continuous contract uses the price of the current delivery period contract.", { - pair: z.string().describe("Underlying pair (e.g., BTCUSD)"), - contractType: z - .enum(["PERPETUAL", "CURRENT_QUARTER", "NEXT_QUARTER"]) - .describe("Contract type"), - interval: z - .enum([ - "1m", - "3m", - "5m", - "15m", - "30m", - "1h", - "2h", - "4h", - "6h", - "8h", - "12h", - "1d", - "3d", - "1w", - "1M", - ]) - .describe("Kline interval"), - startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().int().optional().describe("End timestamp in milliseconds"), - limit: z.number().int().optional().describe("Number of klines (default 500, max 1500)"), + description: + "Get continuous contract kline/candlestick data for a COIN-M Futures pair. Continuous contract uses the price of the current delivery period contract.", + inputSchema: { + pair: z.string().describe("Underlying pair (e.g., BTCUSD)"), + contractType: z + .enum(["PERPETUAL", "CURRENT_QUARTER", "NEXT_QUARTER"]) + .describe("Contract type"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().int().optional().describe("End timestamp in milliseconds"), + limit: z.number().int().optional().describe("Number of klines (default 500, max 1500)"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/market-api/depth.ts b/src/tools/binance-futures-coinm/market-api/depth.ts index 2cf2936e..e246c4d3 100644 --- a/src/tools/binance-futures-coinm/market-api/depth.ts +++ b/src/tools/binance-futures-coinm/market-api/depth.ts @@ -12,16 +12,18 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryDepth(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryDepth", - "Get COIN-M Futures order book depth for a symbol.", { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP, BTCUSD_230630)"), - limit: z - .number() - .int() - .optional() - .describe("Depth limit: 5, 10, 20, 50, 100, 500, 1000 (default 500)"), + description: "Get COIN-M Futures order book depth for a symbol.", + inputSchema: { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP, BTCUSD_230630)"), + limit: z + .number() + .int() + .optional() + .describe("Depth limit: 5, 10, 20, 50, 100, 500, 1000 (default 500)"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/market-api/exchangeInfo.ts b/src/tools/binance-futures-coinm/market-api/exchangeInfo.ts index 630a8a12..d884c6cd 100644 --- a/src/tools/binance-futures-coinm/market-api/exchangeInfo.ts +++ b/src/tools/binance-futures-coinm/market-api/exchangeInfo.ts @@ -10,10 +10,12 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryExchangeInfo(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryExchangeInfo", - "Get COIN-M Futures exchange information including trading rules, symbol info, and rate limits.", - {}, + { + description: + "Get COIN-M Futures exchange information including trading rules, symbol info, and rate limits.", + }, async () => { try { const response = await deliveryClient.restAPI.exchangeInfo(); diff --git a/src/tools/binance-futures-coinm/market-api/fundingRate.ts b/src/tools/binance-futures-coinm/market-api/fundingRate.ts index 03e8f488..20a10d37 100644 --- a/src/tools/binance-futures-coinm/market-api/fundingRate.ts +++ b/src/tools/binance-futures-coinm/market-api/fundingRate.ts @@ -12,14 +12,16 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryFundingRate(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryFundingRate", - "Get funding rate history for a COIN-M Futures perpetual contract.", { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().int().optional().describe("End timestamp in milliseconds"), - limit: z.number().int().optional().describe("Number of results (default 100, max 1000)"), + description: "Get funding rate history for a COIN-M Futures perpetual contract.", + inputSchema: { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().int().optional().describe("End timestamp in milliseconds"), + limit: z.number().int().optional().describe("Number of results (default 100, max 1000)"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/market-api/historicalTrades.ts b/src/tools/binance-futures-coinm/market-api/historicalTrades.ts index 5816c6b0..a1d62e94 100644 --- a/src/tools/binance-futures-coinm/market-api/historicalTrades.ts +++ b/src/tools/binance-futures-coinm/market-api/historicalTrades.ts @@ -12,13 +12,16 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryHistoricalTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryHistoricalTrades", - "Get older market historical trades for a COIN-M Futures symbol. Requires API key.", { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - limit: z.number().int().optional().describe("Number of trades (default 500, max 1000)"), - fromId: z.number().int().optional().describe("Trade ID to fetch from (older trades)"), + description: + "Get older market historical trades for a COIN-M Futures symbol. Requires API key.", + inputSchema: { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + limit: z.number().int().optional().describe("Number of trades (default 500, max 1000)"), + fromId: z.number().int().optional().describe("Trade ID to fetch from (older trades)"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/market-api/indexPriceKlines.ts b/src/tools/binance-futures-coinm/market-api/indexPriceKlines.ts index 3f41d979..b8b4cf53 100644 --- a/src/tools/binance-futures-coinm/market-api/indexPriceKlines.ts +++ b/src/tools/binance-futures-coinm/market-api/indexPriceKlines.ts @@ -12,33 +12,35 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryIndexPriceKlines(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryIndexPriceKlines", - "Get index price kline/candlestick data for a COIN-M Futures pair.", { - pair: z.string().describe("Underlying pair (e.g., BTCUSD)"), - interval: z - .enum([ - "1m", - "3m", - "5m", - "15m", - "30m", - "1h", - "2h", - "4h", - "6h", - "8h", - "12h", - "1d", - "3d", - "1w", - "1M", - ]) - .describe("Kline interval"), - startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().int().optional().describe("End timestamp in milliseconds"), - limit: z.number().int().optional().describe("Number of klines (default 500, max 1500)"), + description: "Get index price kline/candlestick data for a COIN-M Futures pair.", + inputSchema: { + pair: z.string().describe("Underlying pair (e.g., BTCUSD)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().int().optional().describe("End timestamp in milliseconds"), + limit: z.number().int().optional().describe("Number of klines (default 500, max 1500)"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/market-api/klines.ts b/src/tools/binance-futures-coinm/market-api/klines.ts index bbb624fb..2f499688 100644 --- a/src/tools/binance-futures-coinm/market-api/klines.ts +++ b/src/tools/binance-futures-coinm/market-api/klines.ts @@ -12,33 +12,35 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryKlines(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryKlines", - "Get kline/candlestick data for a COIN-M Futures symbol.", { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - interval: z - .enum([ - "1m", - "3m", - "5m", - "15m", - "30m", - "1h", - "2h", - "4h", - "6h", - "8h", - "12h", - "1d", - "3d", - "1w", - "1M", - ]) - .describe("Kline interval"), - startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().int().optional().describe("End timestamp in milliseconds"), - limit: z.number().int().optional().describe("Number of klines (default 500, max 1500)"), + description: "Get kline/candlestick data for a COIN-M Futures symbol.", + inputSchema: { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().int().optional().describe("End timestamp in milliseconds"), + limit: z.number().int().optional().describe("Number of klines (default 500, max 1500)"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/market-api/markPriceKlines.ts b/src/tools/binance-futures-coinm/market-api/markPriceKlines.ts index 99b460dc..e018f9f4 100644 --- a/src/tools/binance-futures-coinm/market-api/markPriceKlines.ts +++ b/src/tools/binance-futures-coinm/market-api/markPriceKlines.ts @@ -12,33 +12,36 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryMarkPriceKlines(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryMarkPriceKlines", - "Get mark price kline/candlestick data for a COIN-M Futures symbol. Mark price is used for liquidation calculations.", { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - interval: z - .enum([ - "1m", - "3m", - "5m", - "15m", - "30m", - "1h", - "2h", - "4h", - "6h", - "8h", - "12h", - "1d", - "3d", - "1w", - "1M", - ]) - .describe("Kline interval"), - startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().int().optional().describe("End timestamp in milliseconds"), - limit: z.number().int().optional().describe("Number of klines (default 500, max 1500)"), + description: + "Get mark price kline/candlestick data for a COIN-M Futures symbol. Mark price is used for liquidation calculations.", + inputSchema: { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().int().optional().describe("End timestamp in milliseconds"), + limit: z.number().int().optional().describe("Number of klines (default 500, max 1500)"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/market-api/openInterest.ts b/src/tools/binance-futures-coinm/market-api/openInterest.ts index 290e0ff5..6f795711 100644 --- a/src/tools/binance-futures-coinm/market-api/openInterest.ts +++ b/src/tools/binance-futures-coinm/market-api/openInterest.ts @@ -12,11 +12,13 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryOpenInterest(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryOpenInterest", - "Get present open interest for a specific COIN-M Futures contract.", { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + description: "Get present open interest for a specific COIN-M Futures contract.", + inputSchema: { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/market-api/openInterestHist.ts b/src/tools/binance-futures-coinm/market-api/openInterestHist.ts index 943250f9..ff7af6ef 100644 --- a/src/tools/binance-futures-coinm/market-api/openInterestHist.ts +++ b/src/tools/binance-futures-coinm/market-api/openInterestHist.ts @@ -12,20 +12,23 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryOpenInterestHist(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryOpenInterestHist", - "Get historical open interest for a COIN-M Futures pair. Requires VIP 2+ or higher.", { - pair: z.string().describe("Underlying pair (e.g., BTCUSD)"), - contractType: z - .enum(["ALL", "PERPETUAL", "CURRENT_QUARTER", "NEXT_QUARTER"]) - .describe("Contract type"), - period: z - .enum(["5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d"]) - .describe("Time period"), - startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().int().optional().describe("End timestamp in milliseconds"), - limit: z.number().int().optional().describe("Number of results (default 30, max 500)"), + description: + "Get historical open interest for a COIN-M Futures pair. Requires VIP 2+ or higher.", + inputSchema: { + pair: z.string().describe("Underlying pair (e.g., BTCUSD)"), + contractType: z + .enum(["ALL", "PERPETUAL", "CURRENT_QUARTER", "NEXT_QUARTER"]) + .describe("Contract type"), + period: z + .enum(["5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d"]) + .describe("Time period"), + startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().int().optional().describe("End timestamp in milliseconds"), + limit: z.number().int().optional().describe("Number of results (default 30, max 500)"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/market-api/ping.ts b/src/tools/binance-futures-coinm/market-api/ping.ts index 5bbc1956..90fde8a3 100644 --- a/src/tools/binance-futures-coinm/market-api/ping.ts +++ b/src/tools/binance-futures-coinm/market-api/ping.ts @@ -10,10 +10,12 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryPing(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryPing", - "Test connectivity to the COIN-M Futures API. Returns empty object if successful.", - {}, + { + description: + "Test connectivity to the COIN-M Futures API. Returns empty object if successful.", + }, async () => { try { const response = await deliveryClient.restAPI.ping(); diff --git a/src/tools/binance-futures-coinm/market-api/premiumIndex.ts b/src/tools/binance-futures-coinm/market-api/premiumIndex.ts index cce3c788..80b8fe76 100644 --- a/src/tools/binance-futures-coinm/market-api/premiumIndex.ts +++ b/src/tools/binance-futures-coinm/market-api/premiumIndex.ts @@ -12,14 +12,16 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryPremiumIndex(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryPremiumIndex", - "Get mark price and funding rate for COIN-M Futures contracts.", { - symbol: z - .string() - .optional() - .describe("Contract symbol (e.g., BTCUSD_PERP). If not provided, returns all symbols"), + description: "Get mark price and funding rate for COIN-M Futures contracts.", + inputSchema: { + symbol: z + .string() + .optional() + .describe("Contract symbol (e.g., BTCUSD_PERP). If not provided, returns all symbols"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/market-api/ticker24hr.ts b/src/tools/binance-futures-coinm/market-api/ticker24hr.ts index 7fe99e89..40aea579 100644 --- a/src/tools/binance-futures-coinm/market-api/ticker24hr.ts +++ b/src/tools/binance-futures-coinm/market-api/ticker24hr.ts @@ -12,15 +12,17 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDelivery24hrTicker(server: McpServer) { - server.tool( + server.registerTool( "BinanceDelivery24hrTicker", - "Get 24hr rolling window price change statistics for COIN-M Futures.", { - symbol: z - .string() - .optional() - .describe("Contract symbol (e.g., BTCUSD_PERP). If not provided, returns all symbols"), - pair: z.string().optional().describe("Filter by underlying pair (e.g., BTCUSD)"), + description: "Get 24hr rolling window price change statistics for COIN-M Futures.", + inputSchema: { + symbol: z + .string() + .optional() + .describe("Contract symbol (e.g., BTCUSD_PERP). If not provided, returns all symbols"), + pair: z.string().optional().describe("Filter by underlying pair (e.g., BTCUSD)"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/market-api/tickerPrice.ts b/src/tools/binance-futures-coinm/market-api/tickerPrice.ts index 3b24c079..f28b61e8 100644 --- a/src/tools/binance-futures-coinm/market-api/tickerPrice.ts +++ b/src/tools/binance-futures-coinm/market-api/tickerPrice.ts @@ -12,15 +12,17 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryTickerPrice(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryTickerPrice", - "Get latest price for COIN-M Futures symbol(s).", { - symbol: z - .string() - .optional() - .describe("Contract symbol (e.g., BTCUSD_PERP). If not provided, returns all symbols"), - pair: z.string().optional().describe("Filter by underlying pair (e.g., BTCUSD)"), + description: "Get latest price for COIN-M Futures symbol(s).", + inputSchema: { + symbol: z + .string() + .optional() + .describe("Contract symbol (e.g., BTCUSD_PERP). If not provided, returns all symbols"), + pair: z.string().optional().describe("Filter by underlying pair (e.g., BTCUSD)"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/market-api/time.ts b/src/tools/binance-futures-coinm/market-api/time.ts index 92630a21..f3d9247b 100644 --- a/src/tools/binance-futures-coinm/market-api/time.ts +++ b/src/tools/binance-futures-coinm/market-api/time.ts @@ -10,10 +10,9 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryTime(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryTime", - "Get the current server time from COIN-M Futures API.", - {}, + { description: "Get the current server time from COIN-M Futures API." }, async () => { try { const response = await deliveryClient.restAPI.time(); diff --git a/src/tools/binance-futures-coinm/market-api/trades.ts b/src/tools/binance-futures-coinm/market-api/trades.ts index 16749900..b1d7e611 100644 --- a/src/tools/binance-futures-coinm/market-api/trades.ts +++ b/src/tools/binance-futures-coinm/market-api/trades.ts @@ -12,12 +12,14 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryTrades", - "Get recent trades for a COIN-M Futures symbol.", { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - limit: z.number().int().optional().describe("Number of trades (default 500, max 1000)"), + description: "Get recent trades for a COIN-M Futures symbol.", + inputSchema: { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + limit: z.number().int().optional().describe("Number of trades (default 500, max 1000)"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/newOrder.ts b/src/tools/binance-futures-coinm/newOrder.ts index 0a5a6003..00deb303 100644 --- a/src/tools/binance-futures-coinm/newOrder.ts +++ b/src/tools/binance-futures-coinm/newOrder.ts @@ -6,34 +6,36 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMNewOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMNewOrder", - "Send a new COIN-M futures order.", { - symbol: z.string().describe("Trading symbol (e.g., BTCUSD_PERP)"), - side: z.enum(["BUY", "SELL"]).describe("Order side"), - type: z - .enum([ - "LIMIT", - "MARKET", - "STOP", - "STOP_MARKET", - "TAKE_PROFIT", - "TAKE_PROFIT_MARKET", - "TRAILING_STOP_MARKET", - ]) - .describe("Order type"), - positionSide: z - .enum(["BOTH", "LONG", "SHORT"]) - .optional() - .describe("Position side for hedge mode"), - quantity: z.number().optional().describe("Order quantity"), - price: z.number().optional().describe("Order price (required for LIMIT orders)"), - stopPrice: z.number().optional().describe("Stop price for stop orders"), - timeInForce: z.enum(["GTC", "IOC", "FOK", "GTX"]).optional().describe("Time in force"), - reduceOnly: z.boolean().optional().describe("Reduce only order"), - newClientOrderId: z.string().optional().describe("Client order ID"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Send a new COIN-M futures order.", + inputSchema: { + symbol: z.string().describe("Trading symbol (e.g., BTCUSD_PERP)"), + side: z.enum(["BUY", "SELL"]).describe("Order side"), + type: z + .enum([ + "LIMIT", + "MARKET", + "STOP", + "STOP_MARKET", + "TAKE_PROFIT", + "TAKE_PROFIT_MARKET", + "TRAILING_STOP_MARKET", + ]) + .describe("Order type"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe("Position side for hedge mode"), + quantity: z.number().optional().describe("Order quantity"), + price: z.number().optional().describe("Order price (required for LIMIT orders)"), + stopPrice: z.number().optional().describe("Stop price for stop orders"), + timeInForce: z.enum(["GTC", "IOC", "FOK", "GTX"]).optional().describe("Time in force"), + reduceOnly: z.boolean().optional().describe("Reduce only order"), + newClientOrderId: z.string().optional().describe("Client order ID"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/openInterest.ts b/src/tools/binance-futures-coinm/openInterest.ts index f45a384a..50276523 100644 --- a/src/tools/binance-futures-coinm/openInterest.ts +++ b/src/tools/binance-futures-coinm/openInterest.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMOpenInterest(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMOpenInterest", - "Get present open interest of a specific symbol for COIN-M Futures.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + description: "Get present open interest of a specific symbol for COIN-M Futures.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + }, }, async ({ symbol }) => { try { diff --git a/src/tools/binance-futures-coinm/openOrders.ts b/src/tools/binance-futures-coinm/openOrders.ts index c6b39009..e98c1129 100644 --- a/src/tools/binance-futures-coinm/openOrders.ts +++ b/src/tools/binance-futures-coinm/openOrders.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMOpenOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMOpenOrders", - "Get current COIN-M futures open orders.", { - symbol: z.string().optional().describe("Trading symbol (optional)"), - pair: z.string().optional().describe("Trading pair"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Get current COIN-M futures open orders.", + inputSchema: { + symbol: z.string().optional().describe("Trading symbol (optional)"), + pair: z.string().optional().describe("Trading pair"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/ping.ts b/src/tools/binance-futures-coinm/ping.ts index 3b09dedc..92d1efab 100644 --- a/src/tools/binance-futures-coinm/ping.ts +++ b/src/tools/binance-futures-coinm/ping.ts @@ -4,10 +4,9 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMPing(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMPing", - "Test connectivity to the COIN-M Futures REST API.", - {}, + { description: "Test connectivity to the COIN-M Futures REST API." }, async () => { try { const data = await deliveryClient.ping(); diff --git a/src/tools/binance-futures-coinm/positionMargin.ts b/src/tools/binance-futures-coinm/positionMargin.ts index 1c65b698..bf80e5af 100644 --- a/src/tools/binance-futures-coinm/positionMargin.ts +++ b/src/tools/binance-futures-coinm/positionMargin.ts @@ -6,17 +6,19 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMPositionMargin(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMPositionMargin", - "Modify isolated position margin for COIN-M Futures.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), - positionSide: z - .enum(["BOTH", "LONG", "SHORT"]) - .optional() - .describe("Position side. Default BOTH for One-way Mode"), - amount: z.number().describe("Amount to add or remove"), - type: z.number().describe("1: Add margin, 2: Remove margin"), + description: "Modify isolated position margin for COIN-M Futures.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe("Position side. Default BOTH for One-way Mode"), + amount: z.number().describe("Amount to add or remove"), + type: z.number().describe("1: Add margin, 2: Remove margin"), + }, }, async ({ symbol, positionSide, amount, type }) => { try { diff --git a/src/tools/binance-futures-coinm/positionMode.ts b/src/tools/binance-futures-coinm/positionMode.ts index 3c0eaa1d..ab19607a 100644 --- a/src/tools/binance-futures-coinm/positionMode.ts +++ b/src/tools/binance-futures-coinm/positionMode.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMPositionMode(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMPositionMode", - "Change position mode for COIN-M Futures (One-way or Hedge Mode).", { - dualSidePosition: z.boolean().describe("true: Hedge Mode, false: One-way Mode"), + description: "Change position mode for COIN-M Futures (One-way or Hedge Mode).", + inputSchema: { + dualSidePosition: z.boolean().describe("true: Hedge Mode, false: One-way Mode"), + }, }, async ({ dualSidePosition }) => { try { diff --git a/src/tools/binance-futures-coinm/positionRisk.ts b/src/tools/binance-futures-coinm/positionRisk.ts index 7184eddd..6a41cdb5 100644 --- a/src/tools/binance-futures-coinm/positionRisk.ts +++ b/src/tools/binance-futures-coinm/positionRisk.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMPositionRisk(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMPositionRisk", - "Get COIN-M futures position information.", { - marginAsset: z.string().optional().describe("Margin asset"), - pair: z.string().optional().describe("Trading pair"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Get COIN-M futures position information.", + inputSchema: { + marginAsset: z.string().optional().describe("Margin asset"), + pair: z.string().optional().describe("Trading pair"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/premiumIndex.ts b/src/tools/binance-futures-coinm/premiumIndex.ts index 1060f03b..04d3d339 100644 --- a/src/tools/binance-futures-coinm/premiumIndex.ts +++ b/src/tools/binance-futures-coinm/premiumIndex.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMPremiumIndex(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMPremiumIndex", - "Get mark price and funding rate for COIN-M Futures.", { - symbol: z - .string() - .optional() - .describe( - "Symbol of the trading pair (e.g., BTCUSD_PERP). If not provided, returns all symbols", - ), + description: "Get mark price and funding rate for COIN-M Futures.", + inputSchema: { + symbol: z + .string() + .optional() + .describe( + "Symbol of the trading pair (e.g., BTCUSD_PERP). If not provided, returns all symbols", + ), + }, }, async ({ symbol }) => { try { diff --git a/src/tools/binance-futures-coinm/ticker24hr.ts b/src/tools/binance-futures-coinm/ticker24hr.ts index 8a7cd21d..1bc55f50 100644 --- a/src/tools/binance-futures-coinm/ticker24hr.ts +++ b/src/tools/binance-futures-coinm/ticker24hr.ts @@ -6,17 +6,19 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMTicker24hr(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMTicker24hr", - "Get 24-hour rolling window price change statistics for COIN-M Futures.", { - symbol: z - .string() - .optional() - .describe( - "Symbol of the trading pair (e.g., BTCUSD_PERP). If not provided, returns all symbols", - ), - pair: z.string().optional().describe("Trading pair (e.g., BTCUSD)"), + description: "Get 24-hour rolling window price change statistics for COIN-M Futures.", + inputSchema: { + symbol: z + .string() + .optional() + .describe( + "Symbol of the trading pair (e.g., BTCUSD_PERP). If not provided, returns all symbols", + ), + pair: z.string().optional().describe("Trading pair (e.g., BTCUSD)"), + }, }, async ({ symbol, pair }) => { try { diff --git a/src/tools/binance-futures-coinm/tickerPrice.ts b/src/tools/binance-futures-coinm/tickerPrice.ts index c1b2ebd3..8c8d14a8 100644 --- a/src/tools/binance-futures-coinm/tickerPrice.ts +++ b/src/tools/binance-futures-coinm/tickerPrice.ts @@ -6,17 +6,19 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMTickerPrice(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMTickerPrice", - "Get latest price for a symbol or symbols for COIN-M Futures.", { - symbol: z - .string() - .optional() - .describe( - "Symbol of the trading pair (e.g., BTCUSD_PERP). If not provided, returns all symbols", - ), - pair: z.string().optional().describe("Trading pair (e.g., BTCUSD)"), + description: "Get latest price for a symbol or symbols for COIN-M Futures.", + inputSchema: { + symbol: z + .string() + .optional() + .describe( + "Symbol of the trading pair (e.g., BTCUSD_PERP). If not provided, returns all symbols", + ), + pair: z.string().optional().describe("Trading pair (e.g., BTCUSD)"), + }, }, async ({ symbol, pair }) => { try { diff --git a/src/tools/binance-futures-coinm/time.ts b/src/tools/binance-futures-coinm/time.ts index 81d2473a..000f1bbe 100644 --- a/src/tools/binance-futures-coinm/time.ts +++ b/src/tools/binance-futures-coinm/time.ts @@ -4,10 +4,9 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMTime(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMTime", - "Get the current server time from the COIN-M Futures API.", - {}, + { description: "Get the current server time from the COIN-M Futures API." }, async () => { try { const data = await deliveryClient.time(); diff --git a/src/tools/binance-futures-coinm/trade-api/allOrders.ts b/src/tools/binance-futures-coinm/trade-api/allOrders.ts index a259db70..89b95535 100644 --- a/src/tools/binance-futures-coinm/trade-api/allOrders.ts +++ b/src/tools/binance-futures-coinm/trade-api/allOrders.ts @@ -12,17 +12,19 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryAllOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryAllOrders", - "Get all COIN-M Futures account orders (active, canceled, or filled).", { - symbol: z.string().optional().describe("Contract symbol filter"), - pair: z.string().optional().describe("Filter by underlying pair"), - orderId: z.number().int().optional().describe("Return orders >= this orderId"), - startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().int().optional().describe("End timestamp in milliseconds"), - limit: z.number().int().optional().describe("Number of results (default 500, max 1000)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Get all COIN-M Futures account orders (active, canceled, or filled).", + inputSchema: { + symbol: z.string().optional().describe("Contract symbol filter"), + pair: z.string().optional().describe("Filter by underlying pair"), + orderId: z.number().int().optional().describe("Return orders >= this orderId"), + startTime: z.number().int().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().int().optional().describe("End timestamp in milliseconds"), + limit: z.number().int().optional().describe("Number of results (default 500, max 1000)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/trade-api/batchOrders.ts b/src/tools/binance-futures-coinm/trade-api/batchOrders.ts index 3fb6dc04..9e2fe02d 100644 --- a/src/tools/binance-futures-coinm/trade-api/batchOrders.ts +++ b/src/tools/binance-futures-coinm/trade-api/batchOrders.ts @@ -12,13 +12,15 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryBatchOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryBatchOrders", - "Place multiple COIN-M Futures orders in batch (max 5 orders).", { - batchOrders: z - .string() - .describe("JSON string array of orders. Each order must have: symbol, side, type"), + description: "Place multiple COIN-M Futures orders in batch (max 5 orders).", + inputSchema: { + batchOrders: z + .string() + .describe("JSON string array of orders. Each order must have: symbol, side, type"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/trade-api/cancelAllOrders.ts b/src/tools/binance-futures-coinm/trade-api/cancelAllOrders.ts index b14a3436..51ba6fc0 100644 --- a/src/tools/binance-futures-coinm/trade-api/cancelAllOrders.ts +++ b/src/tools/binance-futures-coinm/trade-api/cancelAllOrders.ts @@ -12,12 +12,14 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryCancelAllOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryCancelAllOrders", - "Cancel all open COIN-M Futures orders for a symbol. ⚠️ Use with caution!", { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Cancel all open COIN-M Futures orders for a symbol. ⚠️ Use with caution!", + inputSchema: { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/trade-api/cancelBatchOrders.ts b/src/tools/binance-futures-coinm/trade-api/cancelBatchOrders.ts index 53051595..0503cec3 100644 --- a/src/tools/binance-futures-coinm/trade-api/cancelBatchOrders.ts +++ b/src/tools/binance-futures-coinm/trade-api/cancelBatchOrders.ts @@ -12,14 +12,16 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryCancelBatchOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryCancelBatchOrders", - "Cancel multiple COIN-M Futures orders in batch (max 10).", { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - orderIdList: z.string().optional().describe("JSON array of order IDs to cancel"), - origClientOrderIdList: z.string().optional().describe("JSON array of client order IDs"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Cancel multiple COIN-M Futures orders in batch (max 10).", + inputSchema: { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + orderIdList: z.string().optional().describe("JSON array of order IDs to cancel"), + origClientOrderIdList: z.string().optional().describe("JSON array of client order IDs"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/trade-api/cancelOrder.ts b/src/tools/binance-futures-coinm/trade-api/cancelOrder.ts index 9a272fa1..9db198eb 100644 --- a/src/tools/binance-futures-coinm/trade-api/cancelOrder.ts +++ b/src/tools/binance-futures-coinm/trade-api/cancelOrder.ts @@ -12,14 +12,16 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryCancelOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryCancelOrder", - "Cancel an active COIN-M Futures order.", { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - orderId: z.number().int().optional().describe("Order ID to cancel"), - origClientOrderId: z.string().optional().describe("Original client order ID"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Cancel an active COIN-M Futures order.", + inputSchema: { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + orderId: z.number().int().optional().describe("Order ID to cancel"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/trade-api/changeLeverage.ts b/src/tools/binance-futures-coinm/trade-api/changeLeverage.ts index 1886851c..be989504 100644 --- a/src/tools/binance-futures-coinm/trade-api/changeLeverage.ts +++ b/src/tools/binance-futures-coinm/trade-api/changeLeverage.ts @@ -12,13 +12,16 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryChangeLeverage(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryChangeLeverage", - "Change initial leverage for a COIN-M Futures symbol. ⚠️ Higher leverage = higher risk.", { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - leverage: z.number().int().min(1).max(125).describe("Target leverage (1-125)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Change initial leverage for a COIN-M Futures symbol. ⚠️ Higher leverage = higher risk.", + inputSchema: { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + leverage: z.number().int().min(1).max(125).describe("Target leverage (1-125)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/trade-api/changeMarginType.ts b/src/tools/binance-futures-coinm/trade-api/changeMarginType.ts index e29dda85..3ccbba8a 100644 --- a/src/tools/binance-futures-coinm/trade-api/changeMarginType.ts +++ b/src/tools/binance-futures-coinm/trade-api/changeMarginType.ts @@ -12,13 +12,15 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryChangeMarginType(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryChangeMarginType", - "Change margin type between ISOLATED and CROSSED for COIN-M Futures.", { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - marginType: z.enum(["ISOLATED", "CROSSED"]).describe("Margin type"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Change margin type between ISOLATED and CROSSED for COIN-M Futures.", + inputSchema: { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + marginType: z.enum(["ISOLATED", "CROSSED"]).describe("Margin type"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/trade-api/changePositionMode.ts b/src/tools/binance-futures-coinm/trade-api/changePositionMode.ts index fb6e6bb0..0ca57811 100644 --- a/src/tools/binance-futures-coinm/trade-api/changePositionMode.ts +++ b/src/tools/binance-futures-coinm/trade-api/changePositionMode.ts @@ -12,12 +12,14 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryChangePositionMode(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryChangePositionMode", - "Change COIN-M Futures position mode between Hedge Mode and One-way Mode.", { - dualSidePosition: z.boolean().describe("true = Hedge Mode, false = One-way Mode"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Change COIN-M Futures position mode between Hedge Mode and One-way Mode.", + inputSchema: { + dualSidePosition: z.boolean().describe("true = Hedge Mode, false = One-way Mode"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/trade-api/countdownCancelAll.ts b/src/tools/binance-futures-coinm/trade-api/countdownCancelAll.ts index e28d29c9..1f964e03 100644 --- a/src/tools/binance-futures-coinm/trade-api/countdownCancelAll.ts +++ b/src/tools/binance-futures-coinm/trade-api/countdownCancelAll.ts @@ -12,13 +12,19 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryCountdownCancelAll(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryCountdownCancelAll", - "Set countdown timer to cancel all COIN-M orders. Dead man's switch. Set to 0 to cancel.", { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - countdownTime: z.number().int().describe("Countdown in milliseconds. 0 to cancel. Min 10000"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Set countdown timer to cancel all COIN-M orders. Dead man's switch. Set to 0 to cancel.", + inputSchema: { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + countdownTime: z + .number() + .int() + .describe("Countdown in milliseconds. 0 to cancel. Min 10000"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/trade-api/getAllOrders.ts b/src/tools/binance-futures-coinm/trade-api/getAllOrders.ts index f215e351..5c5efb2b 100644 --- a/src/tools/binance-futures-coinm/trade-api/getAllOrders.ts +++ b/src/tools/binance-futures-coinm/trade-api/getAllOrders.ts @@ -12,17 +12,19 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryGetAllOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryGetAllOrders", - "Get all COIN-M Futures orders (active, canceled, filled) for a symbol.", { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - pair: z.string().optional().describe("Contract pair (e.g., BTCUSD)"), - orderId: z.number().int().optional().describe("Order ID to start from"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - limit: z.number().int().optional().describe("Number of orders (default 500, max 1000)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Get all COIN-M Futures orders (active, canceled, filled) for a symbol.", + inputSchema: { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + pair: z.string().optional().describe("Contract pair (e.g., BTCUSD)"), + orderId: z.number().int().optional().describe("Order ID to start from"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + limit: z.number().int().optional().describe("Number of orders (default 500, max 1000)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/trade-api/getOrder.ts b/src/tools/binance-futures-coinm/trade-api/getOrder.ts index 545835b3..65b53e60 100644 --- a/src/tools/binance-futures-coinm/trade-api/getOrder.ts +++ b/src/tools/binance-futures-coinm/trade-api/getOrder.ts @@ -12,14 +12,16 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryGetOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryGetOrder", - "Query a specific COIN-M Futures order's status.", { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - orderId: z.number().int().optional().describe("Order ID"), - origClientOrderId: z.string().optional().describe("Original client order ID"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Query a specific COIN-M Futures order's status.", + inputSchema: { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + orderId: z.number().int().optional().describe("Order ID"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/trade-api/modifyIsolatedPositionMargin.ts b/src/tools/binance-futures-coinm/trade-api/modifyIsolatedPositionMargin.ts index 24c263cf..888baf6e 100644 --- a/src/tools/binance-futures-coinm/trade-api/modifyIsolatedPositionMargin.ts +++ b/src/tools/binance-futures-coinm/trade-api/modifyIsolatedPositionMargin.ts @@ -12,18 +12,20 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryModifyIsolatedPositionMargin(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryModifyIsolatedPositionMargin", - "Add or reduce margin to/from an isolated COIN-M Futures position.", { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - amount: z.string().describe("Amount of margin to add or reduce"), - type: z.enum(["1", "2"]).describe("1 = Add margin, 2 = Reduce margin"), - positionSide: z - .enum(["BOTH", "LONG", "SHORT"]) - .optional() - .describe("Position side for Hedge Mode"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Add or reduce margin to/from an isolated COIN-M Futures position.", + inputSchema: { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + amount: z.string().describe("Amount of margin to add or reduce"), + type: z.enum(["1", "2"]).describe("1 = Add margin, 2 = Reduce margin"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe("Position side for Hedge Mode"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/trade-api/newOrder.ts b/src/tools/binance-futures-coinm/trade-api/newOrder.ts index 90281ec8..8f5c618b 100644 --- a/src/tools/binance-futures-coinm/trade-api/newOrder.ts +++ b/src/tools/binance-futures-coinm/trade-api/newOrder.ts @@ -5,46 +5,52 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryNewOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryNewOrder", - "Place a new COIN-M Futures (Delivery) order. COIN-M futures are settled in the coin itself (e.g., BTC). ⚠️ RISK: Futures trading involves leverage and liquidation risk.", { - symbol: z.string().describe("Delivery futures symbol (e.g., BTCUSD_PERP, BTCUSD_240329)"), - side: z.enum(["BUY", "SELL"]).describe("Order side"), - positionSide: z - .enum(["BOTH", "LONG", "SHORT"]) - .optional() - .describe("Position side for Hedge Mode. Use BOTH for One-Way Mode"), - type: z - .enum([ - "LIMIT", - "MARKET", - "STOP", - "STOP_MARKET", - "TAKE_PROFIT", - "TAKE_PROFIT_MARKET", - "TRAILING_STOP_MARKET", - ]) - .describe("Order type"), - quantity: z.string().optional().describe("Order quantity in contracts"), - price: z.string().optional().describe("Limit price (required for LIMIT orders)"), - stopPrice: z.string().optional().describe("Stop price (required for STOP orders)"), - timeInForce: z.enum(["GTC", "IOC", "FOK", "GTX"]).optional().describe("Time in force"), - reduceOnly: z.boolean().optional().describe("Reduce position only"), - closePosition: z.boolean().optional().describe("Close entire position"), - activationPrice: z.string().optional().describe("Activation price for TRAILING_STOP_MARKET"), - callbackRate: z - .string() - .optional() - .describe("Callback rate for TRAILING_STOP_MARKET (0.1% - 5%)"), - workingType: z - .enum(["MARK_PRICE", "CONTRACT_PRICE"]) - .optional() - .describe("Stop price trigger type"), - priceProtect: z.boolean().optional().describe("Price protection"), - newClientOrderId: z.string().optional().describe("Custom order ID"), - newOrderRespType: z.enum(["ACK", "RESULT"]).optional().describe("Response type"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Place a new COIN-M Futures (Delivery) order. COIN-M futures are settled in the coin itself (e.g., BTC). ⚠️ RISK: Futures trading involves leverage and liquidation risk.", + inputSchema: { + symbol: z.string().describe("Delivery futures symbol (e.g., BTCUSD_PERP, BTCUSD_240329)"), + side: z.enum(["BUY", "SELL"]).describe("Order side"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe("Position side for Hedge Mode. Use BOTH for One-Way Mode"), + type: z + .enum([ + "LIMIT", + "MARKET", + "STOP", + "STOP_MARKET", + "TAKE_PROFIT", + "TAKE_PROFIT_MARKET", + "TRAILING_STOP_MARKET", + ]) + .describe("Order type"), + quantity: z.string().optional().describe("Order quantity in contracts"), + price: z.string().optional().describe("Limit price (required for LIMIT orders)"), + stopPrice: z.string().optional().describe("Stop price (required for STOP orders)"), + timeInForce: z.enum(["GTC", "IOC", "FOK", "GTX"]).optional().describe("Time in force"), + reduceOnly: z.boolean().optional().describe("Reduce position only"), + closePosition: z.boolean().optional().describe("Close entire position"), + activationPrice: z + .string() + .optional() + .describe("Activation price for TRAILING_STOP_MARKET"), + callbackRate: z + .string() + .optional() + .describe("Callback rate for TRAILING_STOP_MARKET (0.1% - 5%)"), + workingType: z + .enum(["MARK_PRICE", "CONTRACT_PRICE"]) + .optional() + .describe("Stop price trigger type"), + priceProtect: z.boolean().optional().describe("Price protection"), + newClientOrderId: z.string().optional().describe("Custom order ID"), + newOrderRespType: z.enum(["ACK", "RESULT"]).optional().describe("Response type"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/trade-api/openOrder.ts b/src/tools/binance-futures-coinm/trade-api/openOrder.ts index 61ac2dc9..8049b208 100644 --- a/src/tools/binance-futures-coinm/trade-api/openOrder.ts +++ b/src/tools/binance-futures-coinm/trade-api/openOrder.ts @@ -12,14 +12,16 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryOpenOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryOpenOrder", - "Query a single open COIN-M Futures order.", { - symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), - orderId: z.number().int().optional().describe("Order ID"), - origClientOrderId: z.string().optional().describe("Original client order ID"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Query a single open COIN-M Futures order.", + inputSchema: { + symbol: z.string().describe("Contract symbol (e.g., BTCUSD_PERP)"), + orderId: z.number().int().optional().describe("Order ID"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/trade-api/openOrders.ts b/src/tools/binance-futures-coinm/trade-api/openOrders.ts index 41f07da1..c166e66a 100644 --- a/src/tools/binance-futures-coinm/trade-api/openOrders.ts +++ b/src/tools/binance-futures-coinm/trade-api/openOrders.ts @@ -12,13 +12,15 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryOpenOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryOpenOrders", - "Get all current open COIN-M Futures orders.", { - symbol: z.string().optional().describe("Contract symbol filter"), - pair: z.string().optional().describe("Filter by underlying pair"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Get all current open COIN-M Futures orders.", + inputSchema: { + symbol: z.string().optional().describe("Contract symbol filter"), + pair: z.string().optional().describe("Filter by underlying pair"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/trades.ts b/src/tools/binance-futures-coinm/trades.ts index 250a4408..36eb277b 100644 --- a/src/tools/binance-futures-coinm/trades.ts +++ b/src/tools/binance-futures-coinm/trades.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMTrades", - "Get recent trades for a specific COIN-M Futures trading pair.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), - limit: z.number().optional().describe("Number of trades to return. Default 500; max 1000"), + description: "Get recent trades for a specific COIN-M Futures trading pair.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + limit: z.number().optional().describe("Number of trades to return. Default 500; max 1000"), + }, }, async ({ symbol, limit }) => { try { diff --git a/src/tools/binance-futures-coinm/userTrades.ts b/src/tools/binance-futures-coinm/userTrades.ts index 9f958e9b..66e1cbe9 100644 --- a/src/tools/binance-futures-coinm/userTrades.ts +++ b/src/tools/binance-futures-coinm/userTrades.ts @@ -6,17 +6,19 @@ import { z } from "zod"; import { deliveryClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesCOINMUserTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCOINMUserTrades", - "Get account trade list for COIN-M Futures.", { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), - pair: z.string().optional().describe("Trading pair (e.g., BTCUSD)"), - orderId: z.number().optional().describe("Filter by order ID"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - fromId: z.number().optional().describe("Trade ID to start from"), - limit: z.number().optional().describe("Default 500; max 1000"), + description: "Get account trade list for COIN-M Futures.", + inputSchema: { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSD_PERP)"), + pair: z.string().optional().describe("Trading pair (e.g., BTCUSD)"), + orderId: z.number().optional().describe("Filter by order ID"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + fromId: z.number().optional().describe("Trade ID to start from"), + limit: z.number().optional().describe("Default 500; max 1000"), + }, }, async ({ symbol, pair, orderId, startTime, endTime, fromId, limit }) => { try { diff --git a/src/tools/binance-futures-coinm/userdatastream-api/closeListenKey.ts b/src/tools/binance-futures-coinm/userdatastream-api/closeListenKey.ts index 4ef25abb..cebf3eaf 100644 --- a/src/tools/binance-futures-coinm/userdatastream-api/closeListenKey.ts +++ b/src/tools/binance-futures-coinm/userdatastream-api/closeListenKey.ts @@ -12,12 +12,14 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryCloseListenKey(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryCloseListenKey", - "Close a COIN-M Futures user data stream listen key.", { - listenKey: z.string().optional().describe("Listen key to close"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Close a COIN-M Futures user data stream listen key.", + inputSchema: { + listenKey: z.string().optional().describe("Listen key to close"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/userdatastream-api/createListenKey.ts b/src/tools/binance-futures-coinm/userdatastream-api/createListenKey.ts index 4bc1fb90..771e683a 100644 --- a/src/tools/binance-futures-coinm/userdatastream-api/createListenKey.ts +++ b/src/tools/binance-futures-coinm/userdatastream-api/createListenKey.ts @@ -12,11 +12,14 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryCreateListenKey(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryCreateListenKey", - "Create a new COIN-M Futures user data stream listen key. The listen key is valid for 60 minutes and can be used to receive account updates via WebSocket.", { - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Create a new COIN-M Futures user data stream listen key. The listen key is valid for 60 minutes and can be used to receive account updates via WebSocket.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-coinm/userdatastream-api/keepAliveListenKey.ts b/src/tools/binance-futures-coinm/userdatastream-api/keepAliveListenKey.ts index 4aae924c..a9b5b60b 100644 --- a/src/tools/binance-futures-coinm/userdatastream-api/keepAliveListenKey.ts +++ b/src/tools/binance-futures-coinm/userdatastream-api/keepAliveListenKey.ts @@ -12,12 +12,15 @@ import { z } from "zod"; import { deliveryClient } from "../../../config/binanceClient.js"; export function registerBinanceDeliveryKeepAliveListenKey(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeliveryKeepAliveListenKey", - "Keep alive a COIN-M Futures user data stream listen key. Extends validity by 60 minutes. Should be called at least every 60 minutes to prevent timeout.", { - listenKey: z.string().optional().describe("Listen key to keep alive"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Keep alive a COIN-M Futures user data stream listen key. Extends validity by 60 minutes. Should be called at least every 60 minutes to prevent timeout.", + inputSchema: { + listenKey: z.string().optional().describe("Listen key to keep alive"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/account-api/account.ts b/src/tools/binance-futures-usdm/account-api/account.ts index 95fee00c..fbc5d989 100644 --- a/src/tools/binance-futures-usdm/account-api/account.ts +++ b/src/tools/binance-futures-usdm/account-api/account.ts @@ -12,11 +12,14 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesAccount(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesAccount", - "Get current USD-M Futures account information including positions, balances, and unrealized PnL.", { - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Get current USD-M Futures account information including positions, balances, and unrealized PnL.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/account-api/adlQuantile.ts b/src/tools/binance-futures-usdm/account-api/adlQuantile.ts index 4aadf214..8c737e01 100644 --- a/src/tools/binance-futures-usdm/account-api/adlQuantile.ts +++ b/src/tools/binance-futures-usdm/account-api/adlQuantile.ts @@ -12,12 +12,14 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesADLQuantile(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesADLQuantile", - "Get Position ADL (Auto-Deleveraging) Quantile estimation for USD-M Futures.", { - symbol: z.string().optional().describe("Futures symbol"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Get Position ADL (Auto-Deleveraging) Quantile estimation for USD-M Futures.", + inputSchema: { + symbol: z.string().optional().describe("Futures symbol"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/account-api/apiTradingStatus.ts b/src/tools/binance-futures-usdm/account-api/apiTradingStatus.ts index 7895e944..ace208fd 100644 --- a/src/tools/binance-futures-usdm/account-api/apiTradingStatus.ts +++ b/src/tools/binance-futures-usdm/account-api/apiTradingStatus.ts @@ -12,12 +12,14 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesApiTradingStatus(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesApiTradingStatus", - "Get API trading quantitative rules indicators for USD-M Futures.", { - symbol: z.string().optional().describe("Futures symbol"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Get API trading quantitative rules indicators for USD-M Futures.", + inputSchema: { + symbol: z.string().optional().describe("Futures symbol"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/account-api/balance.ts b/src/tools/binance-futures-usdm/account-api/balance.ts index f786ecb6..4c53a961 100644 --- a/src/tools/binance-futures-usdm/account-api/balance.ts +++ b/src/tools/binance-futures-usdm/account-api/balance.ts @@ -12,11 +12,13 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesBalance(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesBalance", - "Get current USD-M Futures account balance information.", { - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Get current USD-M Futures account balance information.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/account-api/commissionRate.ts b/src/tools/binance-futures-usdm/account-api/commissionRate.ts index d8efc193..7b72c121 100644 --- a/src/tools/binance-futures-usdm/account-api/commissionRate.ts +++ b/src/tools/binance-futures-usdm/account-api/commissionRate.ts @@ -12,12 +12,14 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesCommissionRate(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCommissionRate", - "Get user commission rate for a USD-M Futures symbol.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Get user commission rate for a USD-M Futures symbol.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/account-api/downloadId.ts b/src/tools/binance-futures-usdm/account-api/downloadId.ts index c9b882a4..034f3f92 100644 --- a/src/tools/binance-futures-usdm/account-api/downloadId.ts +++ b/src/tools/binance-futures-usdm/account-api/downloadId.ts @@ -12,13 +12,15 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesDownloadIdForFuturesTransactionHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesDownloadId", - "Get download ID for USD-M Futures transaction history.", { - startTime: z.number().int().describe("Start timestamp in ms"), - endTime: z.number().int().describe("End timestamp in ms"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Get download ID for USD-M Futures transaction history.", + inputSchema: { + startTime: z.number().int().describe("Start timestamp in ms"), + endTime: z.number().int().describe("End timestamp in ms"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/account-api/forceOrders.ts b/src/tools/binance-futures-usdm/account-api/forceOrders.ts index 1e91df37..87c6d293 100644 --- a/src/tools/binance-futures-usdm/account-api/forceOrders.ts +++ b/src/tools/binance-futures-usdm/account-api/forceOrders.ts @@ -12,16 +12,18 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesForceOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesForceOrders", - "Get user's force orders (liquidation orders) for USD-M Futures.", { - symbol: z.string().optional().describe("Futures symbol"), - autoCloseType: z.enum(["LIQUIDATION", "ADL"]).optional().describe("Type of force order"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - limit: z.number().int().optional().describe("Number of results. Default 50, max 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Get user's force orders (liquidation orders) for USD-M Futures.", + inputSchema: { + symbol: z.string().optional().describe("Futures symbol"), + autoCloseType: z.enum(["LIQUIDATION", "ADL"]).optional().describe("Type of force order"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + limit: z.number().int().optional().describe("Number of results. Default 50, max 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/account-api/income.ts b/src/tools/binance-futures-usdm/account-api/income.ts index 468e2ea7..1fcb8273 100644 --- a/src/tools/binance-futures-usdm/account-api/income.ts +++ b/src/tools/binance-futures-usdm/account-api/income.ts @@ -12,39 +12,41 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesIncome(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesIncome", - "Get income history for USD-M Futures account.", { - symbol: z.string().optional().describe("Futures symbol"), - incomeType: z - .enum([ - "TRANSFER", - "WELCOME_BONUS", - "REALIZED_PNL", - "FUNDING_FEE", - "COMMISSION", - "INSURANCE_CLEAR", - "REFERRAL_KICKBACK", - "COMMISSION_REBATE", - "API_REBATE", - "CONTEST_REWARD", - "CROSS_COLLATERAL_TRANSFER", - "OPTIONS_PREMIUM_FEE", - "OPTIONS_SETTLE_PROFIT", - "INTERNAL_TRANSFER", - "AUTO_EXCHANGE", - "DELIVERED_SETTELMENT", - "COIN_SWAP_DEPOSIT", - "COIN_SWAP_WITHDRAW", - "POSITION_LIMIT_INCREASE_FEE", - ]) - .optional() - .describe("Type of income"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - limit: z.number().int().optional().describe("Number of results. Default 100, max 1000"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Get income history for USD-M Futures account.", + inputSchema: { + symbol: z.string().optional().describe("Futures symbol"), + incomeType: z + .enum([ + "TRANSFER", + "WELCOME_BONUS", + "REALIZED_PNL", + "FUNDING_FEE", + "COMMISSION", + "INSURANCE_CLEAR", + "REFERRAL_KICKBACK", + "COMMISSION_REBATE", + "API_REBATE", + "CONTEST_REWARD", + "CROSS_COLLATERAL_TRANSFER", + "OPTIONS_PREMIUM_FEE", + "OPTIONS_SETTLE_PROFIT", + "INTERNAL_TRANSFER", + "AUTO_EXCHANGE", + "DELIVERED_SETTELMENT", + "COIN_SWAP_DEPOSIT", + "COIN_SWAP_WITHDRAW", + "POSITION_LIMIT_INCREASE_FEE", + ]) + .optional() + .describe("Type of income"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + limit: z.number().int().optional().describe("Number of results. Default 100, max 1000"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/account-api/leverage.ts b/src/tools/binance-futures-usdm/account-api/leverage.ts index a8ac0902..21a751e1 100644 --- a/src/tools/binance-futures-usdm/account-api/leverage.ts +++ b/src/tools/binance-futures-usdm/account-api/leverage.ts @@ -12,18 +12,21 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesLeverage(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesChangeLeverage", - "Change initial leverage for a USD-M Futures symbol. ⚠️ Leverage changes affect your liquidation price and margin requirements.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - leverage: z - .number() - .int() - .min(1) - .max(125) - .describe("Target leverage (1-125, varies by symbol)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Change initial leverage for a USD-M Futures symbol. ⚠️ Leverage changes affect your liquidation price and margin requirements.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + leverage: z + .number() + .int() + .min(1) + .max(125) + .describe("Target leverage (1-125, varies by symbol)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/account-api/leverageBracket.ts b/src/tools/binance-futures-usdm/account-api/leverageBracket.ts index 6c264900..0e1ed30a 100644 --- a/src/tools/binance-futures-usdm/account-api/leverageBracket.ts +++ b/src/tools/binance-futures-usdm/account-api/leverageBracket.ts @@ -12,12 +12,14 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesLeverageBracket(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesLeverageBracket", - "Get notional and leverage brackets for USD-M Futures symbols.", { - symbol: z.string().optional().describe("Futures symbol. If omitted, returns all"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Get notional and leverage brackets for USD-M Futures symbols.", + inputSchema: { + symbol: z.string().optional().describe("Futures symbol. If omitted, returns all"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/account-api/marginType.ts b/src/tools/binance-futures-usdm/account-api/marginType.ts index 405ee18e..a4896b30 100644 --- a/src/tools/binance-futures-usdm/account-api/marginType.ts +++ b/src/tools/binance-futures-usdm/account-api/marginType.ts @@ -12,13 +12,16 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesMarginType(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesChangeMarginType", - "Change margin type between ISOLATED and CROSSED for a USD-M Futures symbol. ⚠️ Cannot change if you have existing positions or open orders.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - marginType: z.enum(["ISOLATED", "CROSSED"]).describe("Margin type: ISOLATED or CROSSED"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Change margin type between ISOLATED and CROSSED for a USD-M Futures symbol. ⚠️ Cannot change if you have existing positions or open orders.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + marginType: z.enum(["ISOLATED", "CROSSED"]).describe("Margin type: ISOLATED or CROSSED"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/account-api/multiAssetsMode.ts b/src/tools/binance-futures-usdm/account-api/multiAssetsMode.ts index 3878d1d5..f9381d9e 100644 --- a/src/tools/binance-futures-usdm/account-api/multiAssetsMode.ts +++ b/src/tools/binance-futures-usdm/account-api/multiAssetsMode.ts @@ -12,11 +12,13 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesMultiAssetsMode(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesGetMultiAssetsMode", - "Get current Multi-Assets Mode for USD-M Futures.", { - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Get current Multi-Assets Mode for USD-M Futures.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/account-api/positionMargin.ts b/src/tools/binance-futures-usdm/account-api/positionMargin.ts index 8264690d..bf51dd49 100644 --- a/src/tools/binance-futures-usdm/account-api/positionMargin.ts +++ b/src/tools/binance-futures-usdm/account-api/positionMargin.ts @@ -13,18 +13,20 @@ import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesPositionMargin(server: McpServer) { // Modify Isolated Position Margin - server.tool( + server.registerTool( "BinanceFuturesModifyPositionMargin", - "Add or reduce margin for an isolated position in USD-M Futures.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - amount: z.string().describe("Amount of margin to add (positive) or remove (negative)"), - type: z.enum(["1", "2"]).describe("1: Add margin, 2: Reduce margin"), - positionSide: z - .enum(["BOTH", "LONG", "SHORT"]) - .optional() - .describe("Position side for Hedge Mode"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Add or reduce margin for an isolated position in USD-M Futures.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + amount: z.string().describe("Amount of margin to add (positive) or remove (negative)"), + type: z.enum(["1", "2"]).describe("1: Add margin, 2: Reduce margin"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe("Position side for Hedge Mode"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { @@ -57,16 +59,18 @@ export function registerBinanceFuturesPositionMargin(server: McpServer) { ); // Get Position Margin Change History - server.tool( + server.registerTool( "BinanceFuturesGetPositionMarginHistory", - "Get position margin change history for a USD-M Futures symbol.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - type: z.enum(["1", "2"]).optional().describe("1: Add margin, 2: Reduce margin"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z.number().int().max(500).optional().describe("Number of records. Default 500"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Get position margin change history for a USD-M Futures symbol.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + type: z.enum(["1", "2"]).optional().describe("1: Add margin, 2: Reduce margin"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z.number().int().max(500).optional().describe("Number of records. Default 500"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/account-api/positionMode.ts b/src/tools/binance-futures-usdm/account-api/positionMode.ts index f3424d9e..a4c88bcb 100644 --- a/src/tools/binance-futures-usdm/account-api/positionMode.ts +++ b/src/tools/binance-futures-usdm/account-api/positionMode.ts @@ -12,11 +12,13 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesPositionMode(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesGetPositionMode", - "Get current position mode (Hedge Mode or One-way Mode) for USD-M Futures.", { - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Get current position mode (Hedge Mode or One-way Mode) for USD-M Futures.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/account-api/positionRisk.ts b/src/tools/binance-futures-usdm/account-api/positionRisk.ts index 46a76327..9158c4cc 100644 --- a/src/tools/binance-futures-usdm/account-api/positionRisk.ts +++ b/src/tools/binance-futures-usdm/account-api/positionRisk.ts @@ -12,12 +12,14 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesPositionRisk(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesPositionRisk", - "Get current position information for USD-M Futures.", { - symbol: z.string().optional().describe("Futures symbol. If omitted, returns all positions"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Get current position information for USD-M Futures.", + inputSchema: { + symbol: z.string().optional().describe("Futures symbol. If omitted, returns all positions"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/account-api/userTrades.ts b/src/tools/binance-futures-usdm/account-api/userTrades.ts index b767f698..90257611 100644 --- a/src/tools/binance-futures-usdm/account-api/userTrades.ts +++ b/src/tools/binance-futures-usdm/account-api/userTrades.ts @@ -12,17 +12,19 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesUserTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUserTrades", - "Get trades for a specific USD-M Futures account and symbol.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - orderId: z.number().int().optional().describe("Order ID to filter trades"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - fromId: z.number().int().optional().describe("Trade ID to start from"), - limit: z.number().int().optional().describe("Number of results. Default 500, max 1000"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Get trades for a specific USD-M Futures account and symbol.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + orderId: z.number().int().optional().describe("Order ID to filter trades"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + fromId: z.number().int().optional().describe("Trade ID to start from"), + limit: z.number().int().optional().describe("Number of results. Default 500, max 1000"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/account.ts b/src/tools/binance-futures-usdm/account.ts index 7709cf36..beccd190 100644 --- a/src/tools/binance-futures-usdm/account.ts +++ b/src/tools/binance-futures-usdm/account.ts @@ -4,10 +4,12 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMAccount(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMAccount", - "Get current USD-M Futures account information including positions and balances.", - {}, + { + description: + "Get current USD-M Futures account information including positions and balances.", + }, async () => { try { const data = await futuresClient.account(); diff --git a/src/tools/binance-futures-usdm/adlQuantile.ts b/src/tools/binance-futures-usdm/adlQuantile.ts index 32950a3b..c9069996 100644 --- a/src/tools/binance-futures-usdm/adlQuantile.ts +++ b/src/tools/binance-futures-usdm/adlQuantile.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMADLQuantile(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMADLQuantile", - "Get position ADL (Auto-Deleveraging) quantile estimate for USD-M Futures.", { - symbol: z - .string() - .optional() - .describe( - "Symbol of the trading pair (e.g., BTCUSDT). If not provided, returns all positions", - ), + description: "Get position ADL (Auto-Deleveraging) quantile estimate for USD-M Futures.", + inputSchema: { + symbol: z + .string() + .optional() + .describe( + "Symbol of the trading pair (e.g., BTCUSDT). If not provided, returns all positions", + ), + }, }, async ({ symbol }) => { try { diff --git a/src/tools/binance-futures-usdm/aggTrades.ts b/src/tools/binance-futures-usdm/aggTrades.ts index 3950a8b6..f3e70103 100644 --- a/src/tools/binance-futures-usdm/aggTrades.ts +++ b/src/tools/binance-futures-usdm/aggTrades.ts @@ -6,21 +6,23 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMAggTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMAggTrades", - "Get compressed, aggregate trades for a specific USD-M Futures trading pair.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - fromId: z.number().optional().describe("ID to get aggregate trades from INCLUSIVE"), - startTime: z - .number() - .optional() - .describe("Timestamp in ms to get aggregate trades from INCLUSIVE"), - endTime: z - .number() - .optional() - .describe("Timestamp in ms to get aggregate trades until INCLUSIVE"), - limit: z.number().optional().describe("Default 500; max 1000"), + description: "Get compressed, aggregate trades for a specific USD-M Futures trading pair.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + fromId: z.number().optional().describe("ID to get aggregate trades from INCLUSIVE"), + startTime: z + .number() + .optional() + .describe("Timestamp in ms to get aggregate trades from INCLUSIVE"), + endTime: z + .number() + .optional() + .describe("Timestamp in ms to get aggregate trades until INCLUSIVE"), + limit: z.number().optional().describe("Default 500; max 1000"), + }, }, async ({ symbol, fromId, startTime, endTime, limit }) => { try { diff --git a/src/tools/binance-futures-usdm/allOrders.ts b/src/tools/binance-futures-usdm/allOrders.ts index 377fe845..85299f53 100644 --- a/src/tools/binance-futures-usdm/allOrders.ts +++ b/src/tools/binance-futures-usdm/allOrders.ts @@ -6,15 +6,17 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMAllOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMAllOrders", - "Get all orders (active, canceled, or filled) for USD-M Futures.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - orderId: z.number().optional().describe("Order ID to start from"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1000"), + description: "Get all orders (active, canceled, or filled) for USD-M Futures.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + orderId: z.number().optional().describe("Order ID to start from"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1000"), + }, }, async ({ symbol, orderId, startTime, endTime, limit }) => { try { diff --git a/src/tools/binance-futures-usdm/balance.ts b/src/tools/binance-futures-usdm/balance.ts index be180aa0..272160fc 100644 --- a/src/tools/binance-futures-usdm/balance.ts +++ b/src/tools/binance-futures-usdm/balance.ts @@ -4,10 +4,9 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMBalance(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMBalance", - "Get current USD-M Futures account balance.", - {}, + { description: "Get current USD-M Futures account balance." }, async () => { try { const data = await futuresClient.balance(); diff --git a/src/tools/binance-futures-usdm/batchOrders.ts b/src/tools/binance-futures-usdm/batchOrders.ts index 0c607127..cb0744a5 100644 --- a/src/tools/binance-futures-usdm/batchOrders.ts +++ b/src/tools/binance-futures-usdm/batchOrders.ts @@ -6,15 +6,17 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMBatchOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMBatchOrders", - "Place multiple orders for USD-M Futures (max 5 orders).", { - batchOrders: z - .string() - .describe( - "JSON string of order list. Max 5 orders. Each order has: symbol, side, type, and optional parameters like positionSide, timeInForce, quantity, reduceOnly, price, newClientOrderId, stopPrice, activationPrice, callbackRate, workingType, priceProtect", - ), + description: "Place multiple orders for USD-M Futures (max 5 orders).", + inputSchema: { + batchOrders: z + .string() + .describe( + "JSON string of order list. Max 5 orders. Each order has: symbol, side, type, and optional parameters like positionSide, timeInForce, quantity, reduceOnly, price, newClientOrderId, stopPrice, activationPrice, callbackRate, workingType, priceProtect", + ), + }, }, async ({ batchOrders }) => { try { diff --git a/src/tools/binance-futures-usdm/bookTicker.ts b/src/tools/binance-futures-usdm/bookTicker.ts index ae6f6ff7..1e58188f 100644 --- a/src/tools/binance-futures-usdm/bookTicker.ts +++ b/src/tools/binance-futures-usdm/bookTicker.ts @@ -6,16 +6,19 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMBookTicker(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMBookTicker", - "Get best price/qty on the order book for a symbol or symbols for USD-M Futures.", { - symbol: z - .string() - .optional() - .describe( - "Symbol of the trading pair (e.g., BTCUSDT). If not provided, returns all symbols", - ), + description: + "Get best price/qty on the order book for a symbol or symbols for USD-M Futures.", + inputSchema: { + symbol: z + .string() + .optional() + .describe( + "Symbol of the trading pair (e.g., BTCUSDT). If not provided, returns all symbols", + ), + }, }, async ({ symbol }) => { try { diff --git a/src/tools/binance-futures-usdm/cancelAllOrders.ts b/src/tools/binance-futures-usdm/cancelAllOrders.ts index f5353a73..8323cea0 100644 --- a/src/tools/binance-futures-usdm/cancelAllOrders.ts +++ b/src/tools/binance-futures-usdm/cancelAllOrders.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMCancelAllOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMCancelAllOrders", - "Cancel all open orders for a symbol in USD-M Futures.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + description: "Cancel all open orders for a symbol in USD-M Futures.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, }, async ({ symbol }) => { try { diff --git a/src/tools/binance-futures-usdm/cancelBatchOrders.ts b/src/tools/binance-futures-usdm/cancelBatchOrders.ts index 8d81ea14..a1ebabe4 100644 --- a/src/tools/binance-futures-usdm/cancelBatchOrders.ts +++ b/src/tools/binance-futures-usdm/cancelBatchOrders.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMCancelBatchOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMCancelBatchOrders", - "Cancel multiple orders for USD-M Futures.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - orderIdList: z.string().optional().describe("Comma-separated list of order IDs (max 10)"), - origClientOrderIdList: z - .string() - .optional() - .describe("Comma-separated list of client order IDs (max 10)"), + description: "Cancel multiple orders for USD-M Futures.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + orderIdList: z.string().optional().describe("Comma-separated list of order IDs (max 10)"), + origClientOrderIdList: z + .string() + .optional() + .describe("Comma-separated list of client order IDs (max 10)"), + }, }, async ({ symbol, orderIdList, origClientOrderIdList }) => { try { diff --git a/src/tools/binance-futures-usdm/cancelOrder.ts b/src/tools/binance-futures-usdm/cancelOrder.ts index 719bc2ec..d2285206 100644 --- a/src/tools/binance-futures-usdm/cancelOrder.ts +++ b/src/tools/binance-futures-usdm/cancelOrder.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMCancelOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMCancelOrder", - "Cancel an existing order for USD-M Futures.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - orderId: z.number().optional().describe("Order ID"), - origClientOrderId: z.string().optional().describe("Original client order ID"), + description: "Cancel an existing order for USD-M Futures.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + orderId: z.number().optional().describe("Order ID"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + }, }, async ({ symbol, orderId, origClientOrderId }) => { try { diff --git a/src/tools/binance-futures-usdm/commissionRate.ts b/src/tools/binance-futures-usdm/commissionRate.ts index 48c76fb8..b81c8b85 100644 --- a/src/tools/binance-futures-usdm/commissionRate.ts +++ b/src/tools/binance-futures-usdm/commissionRate.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMCommissionRate(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMCommissionRate", - "Get user commission rate for USD-M Futures.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + description: "Get user commission rate for USD-M Futures.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, }, async ({ symbol }) => { try { diff --git a/src/tools/binance-futures-usdm/continuousKlines.ts b/src/tools/binance-futures-usdm/continuousKlines.ts index 0492d329..41ddebee 100644 --- a/src/tools/binance-futures-usdm/continuousKlines.ts +++ b/src/tools/binance-futures-usdm/continuousKlines.ts @@ -6,36 +6,38 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMContinuousKlines(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMContinuousKlines", - "Get continuous contract Kline/candlestick data for USD-M Futures.", { - pair: z.string().describe("Trading pair (e.g., BTCUSDT)"), - contractType: z - .enum(["PERPETUAL", "CURRENT_MONTH", "NEXT_MONTH", "CURRENT_QUARTER", "NEXT_QUARTER"]) - .describe("Contract type"), - interval: z - .enum([ - "1m", - "3m", - "5m", - "15m", - "30m", - "1h", - "2h", - "4h", - "6h", - "8h", - "12h", - "1d", - "3d", - "1w", - "1M", - ]) - .describe("Kline interval"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1500"), + description: "Get continuous contract Kline/candlestick data for USD-M Futures.", + inputSchema: { + pair: z.string().describe("Trading pair (e.g., BTCUSDT)"), + contractType: z + .enum(["PERPETUAL", "CURRENT_MONTH", "NEXT_MONTH", "CURRENT_QUARTER", "NEXT_QUARTER"]) + .describe("Contract type"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1500"), + }, }, async ({ pair, contractType, interval, startTime, endTime, limit }) => { try { diff --git a/src/tools/binance-futures-usdm/depth.ts b/src/tools/binance-futures-usdm/depth.ts index 092723c3..1cb17135 100644 --- a/src/tools/binance-futures-usdm/depth.ts +++ b/src/tools/binance-futures-usdm/depth.ts @@ -6,17 +6,19 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMDepth(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMDepth", - "Get order book depth data for a specific USD-M Futures trading pair.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - limit: z - .number() - .optional() - .describe( - "Depth of the order book. Default 500; max 1000. Valid limits: [5, 10, 20, 50, 100, 500, 1000]", - ), + description: "Get order book depth data for a specific USD-M Futures trading pair.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + limit: z + .number() + .optional() + .describe( + "Depth of the order book. Default 500; max 1000. Valid limits: [5, 10, 20, 50, 100, 500, 1000]", + ), + }, }, async ({ symbol, limit }) => { try { diff --git a/src/tools/binance-futures-usdm/exchangeInfo.ts b/src/tools/binance-futures-usdm/exchangeInfo.ts index d17251aa..ebc8c483 100644 --- a/src/tools/binance-futures-usdm/exchangeInfo.ts +++ b/src/tools/binance-futures-usdm/exchangeInfo.ts @@ -4,10 +4,9 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMExchangeInfo(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMExchangeInfo", - "Get current exchange trading rules and symbol information for USD-M Futures.", - {}, + { description: "Get current exchange trading rules and symbol information for USD-M Futures." }, async () => { try { const data = await futuresClient.exchangeInfo(); diff --git a/src/tools/binance-futures-usdm/forceOrders.ts b/src/tools/binance-futures-usdm/forceOrders.ts index d6a9befb..bf78b05f 100644 --- a/src/tools/binance-futures-usdm/forceOrders.ts +++ b/src/tools/binance-futures-usdm/forceOrders.ts @@ -6,18 +6,20 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMForceOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMForceOrders", - "Get user force orders (liquidation orders) for USD-M Futures.", { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - autoCloseType: z - .enum(["LIQUIDATION", "ADL"]) - .optional() - .describe("Auto close type: LIQUIDATION or ADL"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 50; max 100"), + description: "Get user force orders (liquidation orders) for USD-M Futures.", + inputSchema: { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + autoCloseType: z + .enum(["LIQUIDATION", "ADL"]) + .optional() + .describe("Auto close type: LIQUIDATION or ADL"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 50; max 100"), + }, }, async ({ symbol, autoCloseType, startTime, endTime, limit }) => { try { diff --git a/src/tools/binance-futures-usdm/fundingRate.ts b/src/tools/binance-futures-usdm/fundingRate.ts index a6204028..f1fcfcdf 100644 --- a/src/tools/binance-futures-usdm/fundingRate.ts +++ b/src/tools/binance-futures-usdm/fundingRate.ts @@ -6,14 +6,16 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMFundingRate(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMFundingRate", - "Get funding rate history for USD-M Futures.", { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 100; max 1000"), + description: "Get funding rate history for USD-M Futures.", + inputSchema: { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 100; max 1000"), + }, }, async ({ symbol, startTime, endTime, limit }) => { try { diff --git a/src/tools/binance-futures-usdm/getOrder.ts b/src/tools/binance-futures-usdm/getOrder.ts index cd572708..2c4807d7 100644 --- a/src/tools/binance-futures-usdm/getOrder.ts +++ b/src/tools/binance-futures-usdm/getOrder.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMGetOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMGetOrder", - "Query an existing order for USD-M Futures.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - orderId: z.number().optional().describe("Order ID"), - origClientOrderId: z.string().optional().describe("Original client order ID"), + description: "Query an existing order for USD-M Futures.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + orderId: z.number().optional().describe("Order ID"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + }, }, async ({ symbol, orderId, origClientOrderId }) => { try { diff --git a/src/tools/binance-futures-usdm/historicalTrades.ts b/src/tools/binance-futures-usdm/historicalTrades.ts index 202fb103..f93bc093 100644 --- a/src/tools/binance-futures-usdm/historicalTrades.ts +++ b/src/tools/binance-futures-usdm/historicalTrades.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMHistoricalTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMHistoricalTrades", - "Get older market historical trades for a specific USD-M Futures trading pair.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - limit: z.number().optional().describe("Number of trades to return. Default 500; max 1000"), - fromId: z - .number() - .optional() - .describe("Trade ID to fetch from. Default gets most recent trades"), + description: "Get older market historical trades for a specific USD-M Futures trading pair.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + limit: z.number().optional().describe("Number of trades to return. Default 500; max 1000"), + fromId: z + .number() + .optional() + .describe("Trade ID to fetch from. Default gets most recent trades"), + }, }, async ({ symbol, limit, fromId }) => { try { diff --git a/src/tools/binance-futures-usdm/income.ts b/src/tools/binance-futures-usdm/income.ts index 076f0dc0..c6e183b6 100644 --- a/src/tools/binance-futures-usdm/income.ts +++ b/src/tools/binance-futures-usdm/income.ts @@ -6,38 +6,40 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMIncome(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMIncome", - "Get income history for USD-M Futures.", { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - incomeType: z - .enum([ - "TRANSFER", - "WELCOME_BONUS", - "REALIZED_PNL", - "FUNDING_FEE", - "COMMISSION", - "INSURANCE_CLEAR", - "REFERRAL_KICKBACK", - "COMMISSION_REBATE", - "API_REBATE", - "CONTEST_REWARD", - "CROSS_COLLATERAL_TRANSFER", - "OPTIONS_PREMIUM_FEE", - "OPTIONS_SETTLE_PROFIT", - "INTERNAL_TRANSFER", - "AUTO_EXCHANGE", - "DELIVERED_SETTELMENT", - "COIN_SWAP_DEPOSIT", - "COIN_SWAP_WITHDRAW", - "POSITION_LIMIT_INCREASE_FEE", - ]) - .optional() - .describe("Income type"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 100; max 1000"), + description: "Get income history for USD-M Futures.", + inputSchema: { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + incomeType: z + .enum([ + "TRANSFER", + "WELCOME_BONUS", + "REALIZED_PNL", + "FUNDING_FEE", + "COMMISSION", + "INSURANCE_CLEAR", + "REFERRAL_KICKBACK", + "COMMISSION_REBATE", + "API_REBATE", + "CONTEST_REWARD", + "CROSS_COLLATERAL_TRANSFER", + "OPTIONS_PREMIUM_FEE", + "OPTIONS_SETTLE_PROFIT", + "INTERNAL_TRANSFER", + "AUTO_EXCHANGE", + "DELIVERED_SETTELMENT", + "COIN_SWAP_DEPOSIT", + "COIN_SWAP_WITHDRAW", + "POSITION_LIMIT_INCREASE_FEE", + ]) + .optional() + .describe("Income type"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 100; max 1000"), + }, }, async ({ symbol, incomeType, startTime, endTime, limit }) => { try { diff --git a/src/tools/binance-futures-usdm/indexPriceKlines.ts b/src/tools/binance-futures-usdm/indexPriceKlines.ts index 5f935bc2..1e9dafa9 100644 --- a/src/tools/binance-futures-usdm/indexPriceKlines.ts +++ b/src/tools/binance-futures-usdm/indexPriceKlines.ts @@ -6,33 +6,35 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMIndexPriceKlines(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMIndexPriceKlines", - "Get index price Kline/candlestick data for USD-M Futures.", { - pair: z.string().describe("Trading pair (e.g., BTCUSDT)"), - interval: z - .enum([ - "1m", - "3m", - "5m", - "15m", - "30m", - "1h", - "2h", - "4h", - "6h", - "8h", - "12h", - "1d", - "3d", - "1w", - "1M", - ]) - .describe("Kline interval"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1500"), + description: "Get index price Kline/candlestick data for USD-M Futures.", + inputSchema: { + pair: z.string().describe("Trading pair (e.g., BTCUSDT)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1500"), + }, }, async ({ pair, interval, startTime, endTime, limit }) => { try { diff --git a/src/tools/binance-futures-usdm/klines.ts b/src/tools/binance-futures-usdm/klines.ts index 11077e2f..5e0c7680 100644 --- a/src/tools/binance-futures-usdm/klines.ts +++ b/src/tools/binance-futures-usdm/klines.ts @@ -6,33 +6,35 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMKlines(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMKlines", - "Get Kline/candlestick bars for a specific USD-M Futures trading pair.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - interval: z - .enum([ - "1m", - "3m", - "5m", - "15m", - "30m", - "1h", - "2h", - "4h", - "6h", - "8h", - "12h", - "1d", - "3d", - "1w", - "1M", - ]) - .describe("Kline interval"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1500"), + description: "Get Kline/candlestick bars for a specific USD-M Futures trading pair.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1500"), + }, }, async ({ symbol, interval, startTime, endTime, limit }) => { try { diff --git a/src/tools/binance-futures-usdm/leverage.ts b/src/tools/binance-futures-usdm/leverage.ts index a99949bd..e5443ccb 100644 --- a/src/tools/binance-futures-usdm/leverage.ts +++ b/src/tools/binance-futures-usdm/leverage.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMLeverage(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMLeverage", - "Change initial leverage for a symbol in USD-M Futures.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - leverage: z.number().describe("Target leverage (1-125)"), + description: "Change initial leverage for a symbol in USD-M Futures.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + leverage: z.number().describe("Target leverage (1-125)"), + }, }, async ({ symbol, leverage }) => { try { diff --git a/src/tools/binance-futures-usdm/listenKey.ts b/src/tools/binance-futures-usdm/listenKey.ts index 2fa7a6e2..0e1cf8ee 100644 --- a/src/tools/binance-futures-usdm/listenKey.ts +++ b/src/tools/binance-futures-usdm/listenKey.ts @@ -4,10 +4,12 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMListenKeyCreate(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMListenKeyCreate", - "Start a new user data stream for USD-M Futures. Returns a listenKey for WebSocket connection.", - {}, + { + description: + "Start a new user data stream for USD-M Futures. Returns a listenKey for WebSocket connection.", + }, async () => { try { const data = await futuresClient.createListenKey(); @@ -35,10 +37,9 @@ export function registerBinanceFuturesUSDMListenKeyCreate(server: McpServer) { } export function registerBinanceFuturesUSDMListenKeyRenew(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMListenKeyRenew", - "Keepalive a user data stream to prevent timeout for USD-M Futures.", - {}, + { description: "Keepalive a user data stream to prevent timeout for USD-M Futures." }, async () => { try { const data = await futuresClient.keepAliveListenKey(); @@ -66,10 +67,9 @@ export function registerBinanceFuturesUSDMListenKeyRenew(server: McpServer) { } export function registerBinanceFuturesUSDMListenKeyClose(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMListenKeyClose", - "Close a user data stream for USD-M Futures.", - {}, + { description: "Close a user data stream for USD-M Futures." }, async () => { try { const data = await futuresClient.closeListenKey(); diff --git a/src/tools/binance-futures-usdm/marginType.ts b/src/tools/binance-futures-usdm/marginType.ts index 4bc93724..c3f134c8 100644 --- a/src/tools/binance-futures-usdm/marginType.ts +++ b/src/tools/binance-futures-usdm/marginType.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMMarginType(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMMarginType", - "Change margin type for a symbol in USD-M Futures.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - marginType: z.enum(["ISOLATED", "CROSSED"]).describe("Margin type: ISOLATED or CROSSED"), + description: "Change margin type for a symbol in USD-M Futures.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + marginType: z.enum(["ISOLATED", "CROSSED"]).describe("Margin type: ISOLATED or CROSSED"), + }, }, async ({ symbol, marginType }) => { try { diff --git a/src/tools/binance-futures-usdm/markPriceKlines.ts b/src/tools/binance-futures-usdm/markPriceKlines.ts index 29314874..93da02b3 100644 --- a/src/tools/binance-futures-usdm/markPriceKlines.ts +++ b/src/tools/binance-futures-usdm/markPriceKlines.ts @@ -6,33 +6,35 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMMarkPriceKlines(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMMarkPriceKlines", - "Get mark price Kline/candlestick data for USD-M Futures.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - interval: z - .enum([ - "1m", - "3m", - "5m", - "15m", - "30m", - "1h", - "2h", - "4h", - "6h", - "8h", - "12h", - "1d", - "3d", - "1w", - "1M", - ]) - .describe("Kline interval"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1500"), + description: "Get mark price Kline/candlestick data for USD-M Futures.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1500"), + }, }, async ({ symbol, interval, startTime, endTime, limit }) => { try { diff --git a/src/tools/binance-futures-usdm/market-api/aggTrades.ts b/src/tools/binance-futures-usdm/market-api/aggTrades.ts index 148d3a6f..13acacab 100644 --- a/src/tools/binance-futures-usdm/market-api/aggTrades.ts +++ b/src/tools/binance-futures-usdm/market-api/aggTrades.ts @@ -12,15 +12,17 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesAggTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesAggTrades", - "Get compressed aggregate trades for a USD-M Futures symbol.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - fromId: z.number().int().optional().describe("Trade ID to start from"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - limit: z.number().int().optional().describe("Number of trades. Default 500, max 1000"), + description: "Get compressed aggregate trades for a USD-M Futures symbol.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + fromId: z.number().int().optional().describe("Trade ID to start from"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + limit: z.number().int().optional().describe("Number of trades. Default 500, max 1000"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/market-api/assetIndex.ts b/src/tools/binance-futures-usdm/market-api/assetIndex.ts index 7d4438d4..0cac1013 100644 --- a/src/tools/binance-futures-usdm/market-api/assetIndex.ts +++ b/src/tools/binance-futures-usdm/market-api/assetIndex.ts @@ -12,11 +12,13 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesAssetIndex(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesAssetIndex", - "Get asset index for Multi-Asset margin mode.", { - symbol: z.string().optional().describe("Symbol (e.g., BTCUSD)"), + description: "Get asset index for Multi-Asset margin mode.", + inputSchema: { + symbol: z.string().optional().describe("Symbol (e.g., BTCUSD)"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/market-api/continuousKlines.ts b/src/tools/binance-futures-usdm/market-api/continuousKlines.ts index 94ba88b9..dab1ba41 100644 --- a/src/tools/binance-futures-usdm/market-api/continuousKlines.ts +++ b/src/tools/binance-futures-usdm/market-api/continuousKlines.ts @@ -12,36 +12,38 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesContinuousKlines(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesContinuousKlines", - "Get continuous contract kline data for USD-M Futures.", { - pair: z.string().describe("Underlying pair (e.g., BTCUSDT)"), - contractType: z - .enum(["PERPETUAL", "CURRENT_MONTH", "NEXT_MONTH", "CURRENT_QUARTER", "NEXT_QUARTER"]) - .describe("Contract type"), - interval: z - .enum([ - "1m", - "3m", - "5m", - "15m", - "30m", - "1h", - "2h", - "4h", - "6h", - "8h", - "12h", - "1d", - "3d", - "1w", - "1M", - ]) - .describe("Kline interval"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - limit: z.number().int().optional().describe("Number of klines. Default 500, max 1500"), + description: "Get continuous contract kline data for USD-M Futures.", + inputSchema: { + pair: z.string().describe("Underlying pair (e.g., BTCUSDT)"), + contractType: z + .enum(["PERPETUAL", "CURRENT_MONTH", "NEXT_MONTH", "CURRENT_QUARTER", "NEXT_QUARTER"]) + .describe("Contract type"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + limit: z.number().int().optional().describe("Number of klines. Default 500, max 1500"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/market-api/depth.ts b/src/tools/binance-futures-usdm/market-api/depth.ts index 111d78ea..6639aec2 100644 --- a/src/tools/binance-futures-usdm/market-api/depth.ts +++ b/src/tools/binance-futures-usdm/market-api/depth.ts @@ -12,16 +12,18 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesDepth(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesDepth", - "Get order book depth data for a USD-M Futures symbol.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - limit: z - .number() - .int() - .optional() - .describe("Depth limit: 5, 10, 20, 50, 100, 500, 1000. Default 500"), + description: "Get order book depth data for a USD-M Futures symbol.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + limit: z + .number() + .int() + .optional() + .describe("Depth limit: 5, 10, 20, 50, 100, 500, 1000. Default 500"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/market-api/exchangeInfo.ts b/src/tools/binance-futures-usdm/market-api/exchangeInfo.ts index 62d13f08..e664441a 100644 --- a/src/tools/binance-futures-usdm/market-api/exchangeInfo.ts +++ b/src/tools/binance-futures-usdm/market-api/exchangeInfo.ts @@ -10,10 +10,9 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesExchangeInfo(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesExchangeInfo", - "Get current USD-M Futures exchange trading rules and symbol information.", - {}, + { description: "Get current USD-M Futures exchange trading rules and symbol information." }, async () => { try { const response = await futuresClient.restAPI.exchangeInfo(); diff --git a/src/tools/binance-futures-usdm/market-api/fundingInfo.ts b/src/tools/binance-futures-usdm/market-api/fundingInfo.ts index 9fe2fd3a..e03d9106 100644 --- a/src/tools/binance-futures-usdm/market-api/fundingInfo.ts +++ b/src/tools/binance-futures-usdm/market-api/fundingInfo.ts @@ -10,10 +10,9 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesFundingInfo(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesFundingInfo", - "Get funding rate info for all perpetual symbols on USD-M Futures.", - {}, + { description: "Get funding rate info for all perpetual symbols on USD-M Futures." }, async () => { try { const response = await futuresClient.restAPI.fundingInfo(); diff --git a/src/tools/binance-futures-usdm/market-api/fundingRate.ts b/src/tools/binance-futures-usdm/market-api/fundingRate.ts index 3d2b4896..0d19e521 100644 --- a/src/tools/binance-futures-usdm/market-api/fundingRate.ts +++ b/src/tools/binance-futures-usdm/market-api/fundingRate.ts @@ -12,14 +12,16 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesFundingRate(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesFundingRate", - "Get funding rate history for USD-M Futures.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - limit: z.number().int().optional().describe("Number of results. Default 100, max 1000"), + description: "Get funding rate history for USD-M Futures.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + limit: z.number().int().optional().describe("Number of results. Default 100, max 1000"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/market-api/globalLongShortAccountRatio.ts b/src/tools/binance-futures-usdm/market-api/globalLongShortAccountRatio.ts index 3ec1b594..b99d78ce 100644 --- a/src/tools/binance-futures-usdm/market-api/globalLongShortAccountRatio.ts +++ b/src/tools/binance-futures-usdm/market-api/globalLongShortAccountRatio.ts @@ -12,22 +12,24 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesGlobalLongShortAccountRatio(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesGlobalLongShortAccountRatio", - "Get global long/short account ratio for USD-M Futures.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - period: z - .enum(["5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d"]) - .describe("Data period"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .max(500) - .optional() - .describe("Number of records. Default 30, max 500"), + description: "Get global long/short account ratio for USD-M Futures.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + period: z + .enum(["5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d"]) + .describe("Data period"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(500) + .optional() + .describe("Number of records. Default 30, max 500"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/market-api/historicalTrades.ts b/src/tools/binance-futures-usdm/market-api/historicalTrades.ts index ecb1689e..0955dac1 100644 --- a/src/tools/binance-futures-usdm/market-api/historicalTrades.ts +++ b/src/tools/binance-futures-usdm/market-api/historicalTrades.ts @@ -12,13 +12,15 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesHistoricalTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesHistoricalTrades", - "Get older trades for a USD-M Futures symbol.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - limit: z.number().int().optional().describe("Number of trades. Default 500, max 1000"), - fromId: z.number().int().optional().describe("Trade ID to start from"), + description: "Get older trades for a USD-M Futures symbol.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + limit: z.number().int().optional().describe("Number of trades. Default 500, max 1000"), + fromId: z.number().int().optional().describe("Trade ID to start from"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/market-api/indexInfo.ts b/src/tools/binance-futures-usdm/market-api/indexInfo.ts index 99fdd727..72b29a54 100644 --- a/src/tools/binance-futures-usdm/market-api/indexInfo.ts +++ b/src/tools/binance-futures-usdm/market-api/indexInfo.ts @@ -12,11 +12,13 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesIndexInfo(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesIndexInfo", - "Get composite index symbol information for USD-M Futures.", { - symbol: z.string().optional().describe("Composite index symbol (e.g., DEFIUSDT)"), + description: "Get composite index symbol information for USD-M Futures.", + inputSchema: { + symbol: z.string().optional().describe("Composite index symbol (e.g., DEFIUSDT)"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/market-api/indexPriceKlines.ts b/src/tools/binance-futures-usdm/market-api/indexPriceKlines.ts index d5ef2692..9c47bb3a 100644 --- a/src/tools/binance-futures-usdm/market-api/indexPriceKlines.ts +++ b/src/tools/binance-futures-usdm/market-api/indexPriceKlines.ts @@ -12,33 +12,35 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesIndexPriceKlines(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesIndexPriceKlines", - "Get index price kline data for USD-M Futures.", { - pair: z.string().describe("Underlying pair (e.g., BTCUSDT)"), - interval: z - .enum([ - "1m", - "3m", - "5m", - "15m", - "30m", - "1h", - "2h", - "4h", - "6h", - "8h", - "12h", - "1d", - "3d", - "1w", - "1M", - ]) - .describe("Kline interval"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - limit: z.number().int().optional().describe("Number of klines. Default 500, max 1500"), + description: "Get index price kline data for USD-M Futures.", + inputSchema: { + pair: z.string().describe("Underlying pair (e.g., BTCUSDT)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + limit: z.number().int().optional().describe("Number of klines. Default 500, max 1500"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/market-api/klines.ts b/src/tools/binance-futures-usdm/market-api/klines.ts index aa44ba0d..13d88677 100644 --- a/src/tools/binance-futures-usdm/market-api/klines.ts +++ b/src/tools/binance-futures-usdm/market-api/klines.ts @@ -12,33 +12,35 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesKlines(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesKlines", - "Get kline/candlestick data for a USD-M Futures symbol.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - interval: z - .enum([ - "1m", - "3m", - "5m", - "15m", - "30m", - "1h", - "2h", - "4h", - "6h", - "8h", - "12h", - "1d", - "3d", - "1w", - "1M", - ]) - .describe("Kline interval"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - limit: z.number().int().optional().describe("Number of klines. Default 500, max 1500"), + description: "Get kline/candlestick data for a USD-M Futures symbol.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + limit: z.number().int().optional().describe("Number of klines. Default 500, max 1500"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/market-api/lvtKlines.ts b/src/tools/binance-futures-usdm/market-api/lvtKlines.ts index 21b8d2cc..9224bbc2 100644 --- a/src/tools/binance-futures-usdm/market-api/lvtKlines.ts +++ b/src/tools/binance-futures-usdm/market-api/lvtKlines.ts @@ -12,38 +12,40 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesLvtKlines(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesLvtKlines", - "Get historical BLVT NAV Kline/candlestick data.", { - symbol: z.string().describe("BLVT symbol (e.g., BTCDOWN, BTCUP)"), - interval: z - .enum([ - "1m", - "3m", - "5m", - "15m", - "30m", - "1h", - "2h", - "4h", - "6h", - "8h", - "12h", - "1d", - "3d", - "1w", - "1M", - ]) - .describe("Kline interval"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .max(1000) - .optional() - .describe("Number of klines. Default 500, max 1000"), + description: "Get historical BLVT NAV Kline/candlestick data.", + inputSchema: { + symbol: z.string().describe("BLVT symbol (e.g., BTCDOWN, BTCUP)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(1000) + .optional() + .describe("Number of klines. Default 500, max 1000"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/market-api/markPriceKlines.ts b/src/tools/binance-futures-usdm/market-api/markPriceKlines.ts index 4cfbab5c..8e0dac13 100644 --- a/src/tools/binance-futures-usdm/market-api/markPriceKlines.ts +++ b/src/tools/binance-futures-usdm/market-api/markPriceKlines.ts @@ -12,33 +12,35 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesMarkPriceKlines(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesMarkPriceKlines", - "Get mark price kline data for USD-M Futures.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - interval: z - .enum([ - "1m", - "3m", - "5m", - "15m", - "30m", - "1h", - "2h", - "4h", - "6h", - "8h", - "12h", - "1d", - "3d", - "1w", - "1M", - ]) - .describe("Kline interval"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - limit: z.number().int().optional().describe("Number of klines. Default 500, max 1500"), + description: "Get mark price kline data for USD-M Futures.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + limit: z.number().int().optional().describe("Number of klines. Default 500, max 1500"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/market-api/openInterest.ts b/src/tools/binance-futures-usdm/market-api/openInterest.ts index 3371a0ca..07b164d3 100644 --- a/src/tools/binance-futures-usdm/market-api/openInterest.ts +++ b/src/tools/binance-futures-usdm/market-api/openInterest.ts @@ -12,11 +12,13 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesOpenInterest(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesOpenInterest", - "Get current open interest for USD-M Futures symbol.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + description: "Get current open interest for USD-M Futures symbol.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/market-api/openInterestHist.ts b/src/tools/binance-futures-usdm/market-api/openInterestHist.ts index 8a5378a6..2f99d265 100644 --- a/src/tools/binance-futures-usdm/market-api/openInterestHist.ts +++ b/src/tools/binance-futures-usdm/market-api/openInterestHist.ts @@ -12,22 +12,24 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesOpenInterestHist(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesOpenInterestHist", - "Get historical open interest statistics for USD-M Futures.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - period: z - .enum(["5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d"]) - .describe("Data period"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .max(500) - .optional() - .describe("Number of records. Default 30, max 500"), + description: "Get historical open interest statistics for USD-M Futures.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + period: z + .enum(["5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d"]) + .describe("Data period"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(500) + .optional() + .describe("Number of records. Default 30, max 500"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/market-api/ping.ts b/src/tools/binance-futures-usdm/market-api/ping.ts index ae407443..f2d290db 100644 --- a/src/tools/binance-futures-usdm/market-api/ping.ts +++ b/src/tools/binance-futures-usdm/market-api/ping.ts @@ -10,10 +10,9 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesPing(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesPing", - "Test connectivity to the USD-M Futures REST API.", - {}, + { description: "Test connectivity to the USD-M Futures REST API." }, async () => { try { const response = await futuresClient.restAPI.ping(); diff --git a/src/tools/binance-futures-usdm/market-api/premiumIndex.ts b/src/tools/binance-futures-usdm/market-api/premiumIndex.ts index cd0bb2a0..ce7e52ee 100644 --- a/src/tools/binance-futures-usdm/market-api/premiumIndex.ts +++ b/src/tools/binance-futures-usdm/market-api/premiumIndex.ts @@ -12,14 +12,16 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesPremiumIndex(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesPremiumIndex", - "Get mark price and funding rate for USD-M Futures symbols.", { - symbol: z - .string() - .optional() - .describe("Futures symbol (e.g., BTCUSDT). If omitted, returns all symbols"), + description: "Get mark price and funding rate for USD-M Futures symbols.", + inputSchema: { + symbol: z + .string() + .optional() + .describe("Futures symbol (e.g., BTCUSDT). If omitted, returns all symbols"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/market-api/takerLongShortRatio.ts b/src/tools/binance-futures-usdm/market-api/takerLongShortRatio.ts index fd421ee2..be6f2fde 100644 --- a/src/tools/binance-futures-usdm/market-api/takerLongShortRatio.ts +++ b/src/tools/binance-futures-usdm/market-api/takerLongShortRatio.ts @@ -12,22 +12,24 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesTakerLongShortRatio(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesTakerLongShortRatio", - "Get taker long/short ratio (buy/sell volume) for USD-M Futures.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - period: z - .enum(["5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d"]) - .describe("Data period"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .max(500) - .optional() - .describe("Number of records. Default 30, max 500"), + description: "Get taker long/short ratio (buy/sell volume) for USD-M Futures.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + period: z + .enum(["5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d"]) + .describe("Data period"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(500) + .optional() + .describe("Number of records. Default 30, max 500"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/market-api/ticker24hr.ts b/src/tools/binance-futures-usdm/market-api/ticker24hr.ts index 59b30d9a..58ef192d 100644 --- a/src/tools/binance-futures-usdm/market-api/ticker24hr.ts +++ b/src/tools/binance-futures-usdm/market-api/ticker24hr.ts @@ -12,11 +12,13 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesTicker24hr(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesTicker24hr", - "Get 24 hour rolling window price change statistics for USD-M Futures.", { - symbol: z.string().optional().describe("Futures symbol. If omitted, returns all symbols"), + description: "Get 24 hour rolling window price change statistics for USD-M Futures.", + inputSchema: { + symbol: z.string().optional().describe("Futures symbol. If omitted, returns all symbols"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/market-api/tickerBookTicker.ts b/src/tools/binance-futures-usdm/market-api/tickerBookTicker.ts index 8da1b53d..60a8bf9b 100644 --- a/src/tools/binance-futures-usdm/market-api/tickerBookTicker.ts +++ b/src/tools/binance-futures-usdm/market-api/tickerBookTicker.ts @@ -12,14 +12,16 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesTickerBookTicker(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesTickerBookTicker", - "Get best price/qty on the order book for USD-M Futures symbol(s).", { - symbol: z - .string() - .optional() - .describe("Futures symbol (e.g., BTCUSDT). If not provided, returns all symbols"), + description: "Get best price/qty on the order book for USD-M Futures symbol(s).", + inputSchema: { + symbol: z + .string() + .optional() + .describe("Futures symbol (e.g., BTCUSDT). If not provided, returns all symbols"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/market-api/tickerPrice.ts b/src/tools/binance-futures-usdm/market-api/tickerPrice.ts index 3a2accaa..c433c203 100644 --- a/src/tools/binance-futures-usdm/market-api/tickerPrice.ts +++ b/src/tools/binance-futures-usdm/market-api/tickerPrice.ts @@ -12,11 +12,13 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesTickerPrice(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesTickerPrice", - "Get latest price for a USD-M Futures symbol or all symbols.", { - symbol: z.string().optional().describe("Futures symbol. If omitted, returns all symbols"), + description: "Get latest price for a USD-M Futures symbol or all symbols.", + inputSchema: { + symbol: z.string().optional().describe("Futures symbol. If omitted, returns all symbols"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/market-api/time.ts b/src/tools/binance-futures-usdm/market-api/time.ts index 59d450de..89de3693 100644 --- a/src/tools/binance-futures-usdm/market-api/time.ts +++ b/src/tools/binance-futures-usdm/market-api/time.ts @@ -10,26 +10,30 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesTime(server: McpServer) { - server.tool("BinanceFuturesTime", "Get current USD-M Futures server time.", {}, async () => { - try { - const response = await futuresClient.restAPI.time(); - const data = await response.data(); + server.registerTool( + "BinanceFuturesTime", + { description: "Get current USD-M Futures server time." }, + async () => { + try { + const response = await futuresClient.restAPI.time(); + const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Futures server time: ${JSON.stringify(data)}`, - }, - ], - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); + return { + content: [ + { + type: "text", + text: `Futures server time: ${JSON.stringify(data)}`, + }, + ], + }; + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get server time: ${errorMessage}` }], - isError: true, - }; - } - }); + return { + content: [{ type: "text", text: `Failed to get server time: ${errorMessage}` }], + isError: true, + }; + } + }, + ); } diff --git a/src/tools/binance-futures-usdm/market-api/topLongShortAccountRatio.ts b/src/tools/binance-futures-usdm/market-api/topLongShortAccountRatio.ts index e74d5201..a18872f6 100644 --- a/src/tools/binance-futures-usdm/market-api/topLongShortAccountRatio.ts +++ b/src/tools/binance-futures-usdm/market-api/topLongShortAccountRatio.ts @@ -12,22 +12,24 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesTopLongShortAccountRatio(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesTopLongShortAccountRatio", - "Get top trader long/short account ratio for USD-M Futures.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - period: z - .enum(["5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d"]) - .describe("Data period"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .max(500) - .optional() - .describe("Number of records. Default 30, max 500"), + description: "Get top trader long/short account ratio for USD-M Futures.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + period: z + .enum(["5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d"]) + .describe("Data period"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(500) + .optional() + .describe("Number of records. Default 30, max 500"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/market-api/topLongShortPositionRatio.ts b/src/tools/binance-futures-usdm/market-api/topLongShortPositionRatio.ts index 53201415..b6800199 100644 --- a/src/tools/binance-futures-usdm/market-api/topLongShortPositionRatio.ts +++ b/src/tools/binance-futures-usdm/market-api/topLongShortPositionRatio.ts @@ -12,22 +12,24 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesTopLongShortPositionRatio(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesTopLongShortPositionRatio", - "Get top trader long/short position ratio for USD-M Futures.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - period: z - .enum(["5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d"]) - .describe("Data period"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .max(500) - .optional() - .describe("Number of records. Default 30, max 500"), + description: "Get top trader long/short position ratio for USD-M Futures.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + period: z + .enum(["5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d"]) + .describe("Data period"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(500) + .optional() + .describe("Number of records. Default 30, max 500"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/market-api/trades.ts b/src/tools/binance-futures-usdm/market-api/trades.ts index e510f479..396f1473 100644 --- a/src/tools/binance-futures-usdm/market-api/trades.ts +++ b/src/tools/binance-futures-usdm/market-api/trades.ts @@ -12,16 +12,18 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesTrades", - "Get recent trades for a USD-M Futures symbol.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - limit: z - .number() - .int() - .optional() - .describe("Number of trades to return. Default 500, max 1000"), + description: "Get recent trades for a USD-M Futures symbol.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + limit: z + .number() + .int() + .optional() + .describe("Number of trades to return. Default 500, max 1000"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/multiAssetsMode.ts b/src/tools/binance-futures-usdm/multiAssetsMode.ts index 910ea7b2..09a2cf33 100644 --- a/src/tools/binance-futures-usdm/multiAssetsMode.ts +++ b/src/tools/binance-futures-usdm/multiAssetsMode.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMMultiAssetsMode(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMMultiAssetsMode", - "Change multi-assets mode for USD-M Futures.", { - multiAssetsMargin: z - .boolean() - .describe("true: Enable multi-assets mode, false: Disable multi-assets mode"), + description: "Change multi-assets mode for USD-M Futures.", + inputSchema: { + multiAssetsMargin: z + .boolean() + .describe("true: Enable multi-assets mode, false: Disable multi-assets mode"), + }, }, async ({ multiAssetsMargin }) => { try { diff --git a/src/tools/binance-futures-usdm/newOrder.ts b/src/tools/binance-futures-usdm/newOrder.ts index 9d96435a..1af05ec1 100644 --- a/src/tools/binance-futures-usdm/newOrder.ts +++ b/src/tools/binance-futures-usdm/newOrder.ts @@ -6,51 +6,56 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMNewOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMNewOrder", - "Create a new order for USD-M Futures.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Order side"), - type: z - .enum([ - "LIMIT", - "MARKET", - "STOP", - "STOP_MARKET", - "TAKE_PROFIT", - "TAKE_PROFIT_MARKET", - "TRAILING_STOP_MARKET", - ]) - .describe("Order type"), - positionSide: z - .enum(["BOTH", "LONG", "SHORT"]) - .optional() - .describe("Position side. Default BOTH for One-way Mode; LONG or SHORT for Hedge Mode"), - timeInForce: z.enum(["GTC", "IOC", "FOK", "GTX"]).optional().describe("Time in force"), - quantity: z.number().optional().describe("Order quantity"), - reduceOnly: z - .boolean() - .optional() - .describe("Cannot be sent in Hedge Mode; cannot be sent with closePosition=true"), - price: z.number().optional().describe("Order price"), - newClientOrderId: z.string().optional().describe("Client order ID"), - stopPrice: z - .number() - .optional() - .describe("Stop price for STOP/STOP_MARKET/TAKE_PROFIT/TAKE_PROFIT_MARKET"), - closePosition: z - .boolean() - .optional() - .describe("Close all position. Used with STOP_MARKET or TAKE_PROFIT_MARKET"), - activationPrice: z.number().optional().describe("Activation price for TRAILING_STOP_MARKET"), - callbackRate: z.number().optional().describe("Callback rate for TRAILING_STOP_MARKET"), - workingType: z - .enum(["MARK_PRICE", "CONTRACT_PRICE"]) - .optional() - .describe("StopPrice triggered by MARK_PRICE or CONTRACT_PRICE"), - priceProtect: z.boolean().optional().describe("Price protect"), - newOrderRespType: z.enum(["ACK", "RESULT"]).optional().describe("Response type"), + description: "Create a new order for USD-M Futures.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Order side"), + type: z + .enum([ + "LIMIT", + "MARKET", + "STOP", + "STOP_MARKET", + "TAKE_PROFIT", + "TAKE_PROFIT_MARKET", + "TRAILING_STOP_MARKET", + ]) + .describe("Order type"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe("Position side. Default BOTH for One-way Mode; LONG or SHORT for Hedge Mode"), + timeInForce: z.enum(["GTC", "IOC", "FOK", "GTX"]).optional().describe("Time in force"), + quantity: z.number().optional().describe("Order quantity"), + reduceOnly: z + .boolean() + .optional() + .describe("Cannot be sent in Hedge Mode; cannot be sent with closePosition=true"), + price: z.number().optional().describe("Order price"), + newClientOrderId: z.string().optional().describe("Client order ID"), + stopPrice: z + .number() + .optional() + .describe("Stop price for STOP/STOP_MARKET/TAKE_PROFIT/TAKE_PROFIT_MARKET"), + closePosition: z + .boolean() + .optional() + .describe("Close all position. Used with STOP_MARKET or TAKE_PROFIT_MARKET"), + activationPrice: z + .number() + .optional() + .describe("Activation price for TRAILING_STOP_MARKET"), + callbackRate: z.number().optional().describe("Callback rate for TRAILING_STOP_MARKET"), + workingType: z + .enum(["MARK_PRICE", "CONTRACT_PRICE"]) + .optional() + .describe("StopPrice triggered by MARK_PRICE or CONTRACT_PRICE"), + priceProtect: z.boolean().optional().describe("Price protect"), + newOrderRespType: z.enum(["ACK", "RESULT"]).optional().describe("Response type"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/openInterest.ts b/src/tools/binance-futures-usdm/openInterest.ts index 9fb53914..d9e3ec12 100644 --- a/src/tools/binance-futures-usdm/openInterest.ts +++ b/src/tools/binance-futures-usdm/openInterest.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMOpenInterest(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMOpenInterest", - "Get present open interest of a specific symbol for USD-M Futures.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + description: "Get present open interest of a specific symbol for USD-M Futures.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, }, async ({ symbol }) => { try { diff --git a/src/tools/binance-futures-usdm/openOrders.ts b/src/tools/binance-futures-usdm/openOrders.ts index 1355f0b6..3c81ad2b 100644 --- a/src/tools/binance-futures-usdm/openOrders.ts +++ b/src/tools/binance-futures-usdm/openOrders.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMOpenOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMOpenOrders", - "Get all current open orders for USD-M Futures.", { - symbol: z - .string() - .optional() - .describe( - "Symbol of the trading pair (e.g., BTCUSDT). If not provided, returns all open orders", - ), + description: "Get all current open orders for USD-M Futures.", + inputSchema: { + symbol: z + .string() + .optional() + .describe( + "Symbol of the trading pair (e.g., BTCUSDT). If not provided, returns all open orders", + ), + }, }, async ({ symbol }) => { try { diff --git a/src/tools/binance-futures-usdm/ping.ts b/src/tools/binance-futures-usdm/ping.ts index 2280f15f..bc3019da 100644 --- a/src/tools/binance-futures-usdm/ping.ts +++ b/src/tools/binance-futures-usdm/ping.ts @@ -4,10 +4,9 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMPing(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMPing", - "Test connectivity to the USD-M Futures REST API.", - {}, + { description: "Test connectivity to the USD-M Futures REST API." }, async () => { try { const data = await futuresClient.ping(); diff --git a/src/tools/binance-futures-usdm/positionMargin.ts b/src/tools/binance-futures-usdm/positionMargin.ts index 4cca6c71..a63232cb 100644 --- a/src/tools/binance-futures-usdm/positionMargin.ts +++ b/src/tools/binance-futures-usdm/positionMargin.ts @@ -6,17 +6,19 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMPositionMargin(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMPositionMargin", - "Modify isolated position margin for USD-M Futures.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - positionSide: z - .enum(["BOTH", "LONG", "SHORT"]) - .optional() - .describe("Position side. Default BOTH for One-way Mode"), - amount: z.number().describe("Amount to add or remove"), - type: z.number().describe("1: Add margin, 2: Remove margin"), + description: "Modify isolated position margin for USD-M Futures.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe("Position side. Default BOTH for One-way Mode"), + amount: z.number().describe("Amount to add or remove"), + type: z.number().describe("1: Add margin, 2: Remove margin"), + }, }, async ({ symbol, positionSide, amount, type }) => { try { diff --git a/src/tools/binance-futures-usdm/positionMode.ts b/src/tools/binance-futures-usdm/positionMode.ts index 2514b1b9..f12b8dc5 100644 --- a/src/tools/binance-futures-usdm/positionMode.ts +++ b/src/tools/binance-futures-usdm/positionMode.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMPositionMode(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMPositionMode", - "Change position mode for USD-M Futures (One-way or Hedge Mode).", { - dualSidePosition: z.boolean().describe("true: Hedge Mode, false: One-way Mode"), + description: "Change position mode for USD-M Futures (One-way or Hedge Mode).", + inputSchema: { + dualSidePosition: z.boolean().describe("true: Hedge Mode, false: One-way Mode"), + }, }, async ({ dualSidePosition }) => { try { diff --git a/src/tools/binance-futures-usdm/positionRisk.ts b/src/tools/binance-futures-usdm/positionRisk.ts index 22d6a912..631bea23 100644 --- a/src/tools/binance-futures-usdm/positionRisk.ts +++ b/src/tools/binance-futures-usdm/positionRisk.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMPositionRisk(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMPositionRisk", - "Get current position information for USD-M Futures.", { - symbol: z - .string() - .optional() - .describe( - "Symbol of the trading pair (e.g., BTCUSDT). If not provided, returns all positions", - ), + description: "Get current position information for USD-M Futures.", + inputSchema: { + symbol: z + .string() + .optional() + .describe( + "Symbol of the trading pair (e.g., BTCUSDT). If not provided, returns all positions", + ), + }, }, async ({ symbol }) => { try { diff --git a/src/tools/binance-futures-usdm/premiumIndex.ts b/src/tools/binance-futures-usdm/premiumIndex.ts index a5fd5cc0..3ca4143d 100644 --- a/src/tools/binance-futures-usdm/premiumIndex.ts +++ b/src/tools/binance-futures-usdm/premiumIndex.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMPremiumIndex(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMPremiumIndex", - "Get mark price and funding rate for USD-M Futures.", { - symbol: z - .string() - .optional() - .describe( - "Symbol of the trading pair (e.g., BTCUSDT). If not provided, returns all symbols", - ), + description: "Get mark price and funding rate for USD-M Futures.", + inputSchema: { + symbol: z + .string() + .optional() + .describe( + "Symbol of the trading pair (e.g., BTCUSDT). If not provided, returns all symbols", + ), + }, }, async ({ symbol }) => { try { diff --git a/src/tools/binance-futures-usdm/ticker24hr.ts b/src/tools/binance-futures-usdm/ticker24hr.ts index 72685c0f..81816689 100644 --- a/src/tools/binance-futures-usdm/ticker24hr.ts +++ b/src/tools/binance-futures-usdm/ticker24hr.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMTicker24hr(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMTicker24hr", - "Get 24-hour rolling window price change statistics for USD-M Futures.", { - symbol: z - .string() - .optional() - .describe( - "Symbol of the trading pair (e.g., BTCUSDT). If not provided, returns all symbols", - ), + description: "Get 24-hour rolling window price change statistics for USD-M Futures.", + inputSchema: { + symbol: z + .string() + .optional() + .describe( + "Symbol of the trading pair (e.g., BTCUSDT). If not provided, returns all symbols", + ), + }, }, async ({ symbol }) => { try { diff --git a/src/tools/binance-futures-usdm/tickerPrice.ts b/src/tools/binance-futures-usdm/tickerPrice.ts index f77bd50d..66e3e1a0 100644 --- a/src/tools/binance-futures-usdm/tickerPrice.ts +++ b/src/tools/binance-futures-usdm/tickerPrice.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMTickerPrice(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMTickerPrice", - "Get latest price for a symbol or symbols for USD-M Futures.", { - symbol: z - .string() - .optional() - .describe( - "Symbol of the trading pair (e.g., BTCUSDT). If not provided, returns all symbols", - ), + description: "Get latest price for a symbol or symbols for USD-M Futures.", + inputSchema: { + symbol: z + .string() + .optional() + .describe( + "Symbol of the trading pair (e.g., BTCUSDT). If not provided, returns all symbols", + ), + }, }, async ({ symbol }) => { try { diff --git a/src/tools/binance-futures-usdm/time.ts b/src/tools/binance-futures-usdm/time.ts index a93084a7..6c38ecd4 100644 --- a/src/tools/binance-futures-usdm/time.ts +++ b/src/tools/binance-futures-usdm/time.ts @@ -4,10 +4,9 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMTime(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMTime", - "Get the current server time from the USD-M Futures API.", - {}, + { description: "Get the current server time from the USD-M Futures API." }, async () => { try { const data = await futuresClient.time(); diff --git a/src/tools/binance-futures-usdm/trade-api/allOrders.ts b/src/tools/binance-futures-usdm/trade-api/allOrders.ts index 5b0f8af5..d84fb3c7 100644 --- a/src/tools/binance-futures-usdm/trade-api/allOrders.ts +++ b/src/tools/binance-futures-usdm/trade-api/allOrders.ts @@ -12,15 +12,18 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesAllOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesAllOrders", - "Get all account orders (active, canceled, or filled) for a symbol. Returns orders from the last 7 days by default.", { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), - orderId: z.number().optional().describe("If set, return orders >= this orderId"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Number of results (default 500, max 1000)"), + description: + "Get all account orders (active, canceled, or filled) for a symbol. Returns orders from the last 7 days by default.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), + orderId: z.number().optional().describe("If set, return orders >= this orderId"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Number of results (default 500, max 1000)"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/trade-api/batchOrders.ts b/src/tools/binance-futures-usdm/trade-api/batchOrders.ts index 5f5135b6..ab2fda1c 100644 --- a/src/tools/binance-futures-usdm/trade-api/batchOrders.ts +++ b/src/tools/binance-futures-usdm/trade-api/batchOrders.ts @@ -35,17 +35,20 @@ const orderSchema = z.object({ }); export function registerBinanceFuturesBatchOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesBatchOrders", - "Place multiple USD-M Futures orders in a batch (max 5 orders). ⚠️ RISK: Futures trading involves leverage and liquidation risk.", { - batchOrders: z - .array(orderSchema) - .max(5) - .describe( - "Array of orders (max 5). Each order has: symbol, side, type, quantity, price, etc.", - ), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Place multiple USD-M Futures orders in a batch (max 5 orders). ⚠️ RISK: Futures trading involves leverage and liquidation risk.", + inputSchema: { + batchOrders: z + .array(orderSchema) + .max(5) + .describe( + "Array of orders (max 5). Each order has: symbol, side, type, quantity, price, etc.", + ), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/trade-api/cancelAllOpenOrders.ts b/src/tools/binance-futures-usdm/trade-api/cancelAllOpenOrders.ts index 3f684db8..5ec1b34b 100644 --- a/src/tools/binance-futures-usdm/trade-api/cancelAllOpenOrders.ts +++ b/src/tools/binance-futures-usdm/trade-api/cancelAllOpenOrders.ts @@ -12,11 +12,14 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesCancelAllOpenOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCancelAllOpenOrders", - "Cancel all open orders for a symbol. Use with caution as this cancels ALL open orders.", { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), + description: + "Cancel all open orders for a symbol. Use with caution as this cancels ALL open orders.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/trade-api/cancelAllOrders.ts b/src/tools/binance-futures-usdm/trade-api/cancelAllOrders.ts index 21949562..9183cf01 100644 --- a/src/tools/binance-futures-usdm/trade-api/cancelAllOrders.ts +++ b/src/tools/binance-futures-usdm/trade-api/cancelAllOrders.ts @@ -12,12 +12,15 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesCancelAllOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCancelAllOrders", - "Cancel all open USD-M Futures orders for a symbol. ⚠️ This will cancel ALL open orders for the specified symbol.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Cancel all open USD-M Futures orders for a symbol. ⚠️ This will cancel ALL open orders for the specified symbol.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/trade-api/cancelBatchOrders.ts b/src/tools/binance-futures-usdm/trade-api/cancelBatchOrders.ts index c7cfa7dc..75886962 100644 --- a/src/tools/binance-futures-usdm/trade-api/cancelBatchOrders.ts +++ b/src/tools/binance-futures-usdm/trade-api/cancelBatchOrders.ts @@ -12,22 +12,24 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesCancelBatchOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCancelBatchOrders", - "Cancel multiple USD-M Futures orders in batch (max 10 orders).", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - orderIdList: z - .array(z.number().int()) - .max(10) - .optional() - .describe("List of order IDs to cancel (max 10)"), - origClientOrderIdList: z - .array(z.string()) - .max(10) - .optional() - .describe("List of client order IDs to cancel (max 10)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Cancel multiple USD-M Futures orders in batch (max 10 orders).", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + orderIdList: z + .array(z.number().int()) + .max(10) + .optional() + .describe("List of order IDs to cancel (max 10)"), + origClientOrderIdList: z + .array(z.string()) + .max(10) + .optional() + .describe("List of client order IDs to cancel (max 10)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/trade-api/cancelOrder.ts b/src/tools/binance-futures-usdm/trade-api/cancelOrder.ts index 4ca3a64e..3a0e0d67 100644 --- a/src/tools/binance-futures-usdm/trade-api/cancelOrder.ts +++ b/src/tools/binance-futures-usdm/trade-api/cancelOrder.ts @@ -12,14 +12,16 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesCancelOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCancelOrder", - "Cancel a specific USD-M Futures order by orderId or origClientOrderId.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - orderId: z.number().int().optional().describe("Order ID"), - origClientOrderId: z.string().optional().describe("Original client order ID"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Cancel a specific USD-M Futures order by orderId or origClientOrderId.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + orderId: z.number().int().optional().describe("Order ID"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/trade-api/changeLeverage.ts b/src/tools/binance-futures-usdm/trade-api/changeLeverage.ts index add264f6..2b57aad0 100644 --- a/src/tools/binance-futures-usdm/trade-api/changeLeverage.ts +++ b/src/tools/binance-futures-usdm/trade-api/changeLeverage.ts @@ -12,18 +12,21 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesChangeLeverage(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesChangeLeverage", - "Change the initial leverage for a USD-M Futures symbol. Max leverage depends on notional value tier. ⚠️ Higher leverage increases both profit potential and liquidation risk.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - leverage: z - .number() - .int() - .min(1) - .max(125) - .describe("Target leverage (1-125, actual max depends on symbol)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Change the initial leverage for a USD-M Futures symbol. Max leverage depends on notional value tier. ⚠️ Higher leverage increases both profit potential and liquidation risk.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + leverage: z + .number() + .int() + .min(1) + .max(125) + .describe("Target leverage (1-125, actual max depends on symbol)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/trade-api/changeMarginType.ts b/src/tools/binance-futures-usdm/trade-api/changeMarginType.ts index 57630489..4ec76e95 100644 --- a/src/tools/binance-futures-usdm/trade-api/changeMarginType.ts +++ b/src/tools/binance-futures-usdm/trade-api/changeMarginType.ts @@ -12,17 +12,20 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesChangeMarginType(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesChangeMarginType", - "Change margin type between ISOLATED and CROSSED for a USD-M Futures symbol. ISOLATED: Position uses its own margin. CROSSED: All positions share account margin.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - marginType: z - .enum(["ISOLATED", "CROSSED"]) - .describe( - "ISOLATED: Separate margin per position. CROSSED: Shared margin across positions", - ), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Change margin type between ISOLATED and CROSSED for a USD-M Futures symbol. ISOLATED: Position uses its own margin. CROSSED: All positions share account margin.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + marginType: z + .enum(["ISOLATED", "CROSSED"]) + .describe( + "ISOLATED: Separate margin per position. CROSSED: Shared margin across positions", + ), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/trade-api/changeMultiAssetsMode.ts b/src/tools/binance-futures-usdm/trade-api/changeMultiAssetsMode.ts index c3f9b3af..c4849950 100644 --- a/src/tools/binance-futures-usdm/trade-api/changeMultiAssetsMode.ts +++ b/src/tools/binance-futures-usdm/trade-api/changeMultiAssetsMode.ts @@ -12,12 +12,15 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesChangeMultiAssetsMode(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesChangeMultiAssetsMode", - "Change Multi-Assets Mode setting. When enabled, margin from multiple assets (USDT, BUSD) can be used to avoid liquidation.", { - multiAssetsMargin: z.boolean().describe("true = Enable Multi-Assets Mode, false = Disable"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Change Multi-Assets Mode setting. When enabled, margin from multiple assets (USDT, BUSD) can be used to avoid liquidation.", + inputSchema: { + multiAssetsMargin: z.boolean().describe("true = Enable Multi-Assets Mode, false = Disable"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/trade-api/changePositionMode.ts b/src/tools/binance-futures-usdm/trade-api/changePositionMode.ts index 01db6f39..751f16ae 100644 --- a/src/tools/binance-futures-usdm/trade-api/changePositionMode.ts +++ b/src/tools/binance-futures-usdm/trade-api/changePositionMode.ts @@ -12,14 +12,17 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesChangePositionMode(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesChangePositionMode", - "Change position mode between Hedge Mode and One-way Mode. HEDGE: Can hold both LONG and SHORT positions simultaneously. ONE-WAY: Only one direction at a time (positionSide=BOTH).", { - dualSidePosition: z - .boolean() - .describe("true = Hedge Mode (Long/Short), false = One-way Mode (BOTH)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Change position mode between Hedge Mode and One-way Mode. HEDGE: Can hold both LONG and SHORT positions simultaneously. ONE-WAY: Only one direction at a time (positionSide=BOTH).", + inputSchema: { + dualSidePosition: z + .boolean() + .describe("true = Hedge Mode (Long/Short), false = One-way Mode (BOTH)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/trade-api/countdownCancelAll.ts b/src/tools/binance-futures-usdm/trade-api/countdownCancelAll.ts index 83236b23..335a4d5e 100644 --- a/src/tools/binance-futures-usdm/trade-api/countdownCancelAll.ts +++ b/src/tools/binance-futures-usdm/trade-api/countdownCancelAll.ts @@ -12,16 +12,19 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesCountdownCancelAll(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCountdownCancelAll", - "Set auto-cancel all open orders after countdown. Use as dead man's switch for protection. ⚠️ System will cancel orders automatically if no heartbeat received.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - countdownTime: z - .number() - .int() - .describe("Countdown time in milliseconds. 0 to cancel the countdown."), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Set auto-cancel all open orders after countdown. Use as dead man's switch for protection. ⚠️ System will cancel orders automatically if no heartbeat received.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + countdownTime: z + .number() + .int() + .describe("Countdown time in milliseconds. 0 to cancel the countdown."), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/trade-api/getAllOrders.ts b/src/tools/binance-futures-usdm/trade-api/getAllOrders.ts index 27d431dd..baca051e 100644 --- a/src/tools/binance-futures-usdm/trade-api/getAllOrders.ts +++ b/src/tools/binance-futures-usdm/trade-api/getAllOrders.ts @@ -12,21 +12,23 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesGetAllOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesGetAllOrders", - "Get all USD-M Futures orders (active, canceled, or filled) for a symbol.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - orderId: z.number().int().optional().describe("If set, get orders >= this orderId"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .max(1000) - .optional() - .describe("Number of orders. Default 500, max 1000"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Get all USD-M Futures orders (active, canceled, or filled) for a symbol.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + orderId: z.number().int().optional().describe("If set, get orders >= this orderId"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(1000) + .optional() + .describe("Number of orders. Default 500, max 1000"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/trade-api/getOpenOrder.ts b/src/tools/binance-futures-usdm/trade-api/getOpenOrder.ts index 5e47b858..9c8fa380 100644 --- a/src/tools/binance-futures-usdm/trade-api/getOpenOrder.ts +++ b/src/tools/binance-futures-usdm/trade-api/getOpenOrder.ts @@ -12,14 +12,16 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesGetOpenOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesGetOpenOrder", - "Query a specific open USD-M Futures order by orderId or origClientOrderId.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - orderId: z.number().int().optional().describe("Order ID"), - origClientOrderId: z.string().optional().describe("Original client order ID"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Query a specific open USD-M Futures order by orderId or origClientOrderId.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + orderId: z.number().int().optional().describe("Order ID"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/trade-api/getOpenOrders.ts b/src/tools/binance-futures-usdm/trade-api/getOpenOrders.ts index a6a1d8ed..f9668460 100644 --- a/src/tools/binance-futures-usdm/trade-api/getOpenOrders.ts +++ b/src/tools/binance-futures-usdm/trade-api/getOpenOrders.ts @@ -12,15 +12,17 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesGetOpenOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesGetOpenOrders", - "Get all open USD-M Futures orders for a symbol or all symbols.", { - symbol: z - .string() - .optional() - .describe("Futures symbol (e.g., BTCUSDT). If not provided, returns all open orders"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Get all open USD-M Futures orders for a symbol or all symbols.", + inputSchema: { + symbol: z + .string() + .optional() + .describe("Futures symbol (e.g., BTCUSDT). If not provided, returns all open orders"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/trade-api/getOrder.ts b/src/tools/binance-futures-usdm/trade-api/getOrder.ts index 53734951..7fffb442 100644 --- a/src/tools/binance-futures-usdm/trade-api/getOrder.ts +++ b/src/tools/binance-futures-usdm/trade-api/getOrder.ts @@ -12,14 +12,16 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesGetOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesGetOrder", - "Query a specific USD-M Futures order by orderId or origClientOrderId.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - orderId: z.number().int().optional().describe("Order ID"), - origClientOrderId: z.string().optional().describe("Original client order ID"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Query a specific USD-M Futures order by orderId or origClientOrderId.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + orderId: z.number().int().optional().describe("Order ID"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/trade-api/modifyIsolatedPositionMargin.ts b/src/tools/binance-futures-usdm/trade-api/modifyIsolatedPositionMargin.ts index cae00b4d..d57510fe 100644 --- a/src/tools/binance-futures-usdm/trade-api/modifyIsolatedPositionMargin.ts +++ b/src/tools/binance-futures-usdm/trade-api/modifyIsolatedPositionMargin.ts @@ -12,18 +12,21 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesModifyIsolatedPositionMargin(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesModifyIsolatedPositionMargin", - "Add or reduce margin to/from an isolated margin position. Only works when margin type is ISOLATED.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - amount: z.string().describe("Amount of margin to add or reduce"), - type: z.enum(["1", "2"]).describe("1 = Add margin, 2 = Reduce margin"), - positionSide: z - .enum(["BOTH", "LONG", "SHORT"]) - .optional() - .describe("Position side for Hedge Mode (default BOTH)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Add or reduce margin to/from an isolated margin position. Only works when margin type is ISOLATED.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + amount: z.string().describe("Amount of margin to add or reduce"), + type: z.enum(["1", "2"]).describe("1 = Add margin, 2 = Reduce margin"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe("Position side for Hedge Mode (default BOTH)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/trade-api/modifyOrder.ts b/src/tools/binance-futures-usdm/trade-api/modifyOrder.ts index 5d2d5a0b..010898f1 100644 --- a/src/tools/binance-futures-usdm/trade-api/modifyOrder.ts +++ b/src/tools/binance-futures-usdm/trade-api/modifyOrder.ts @@ -12,30 +12,32 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesModifyOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesModifyOrder", - "Modify an existing USD-M Futures order. Can modify price, quantity, or both.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - orderId: z.number().int().optional().describe("Order ID"), - origClientOrderId: z.string().optional().describe("Original client order ID"), - side: z.enum(["BUY", "SELL"]).describe("Order side"), - quantity: z.string().optional().describe("New quantity"), - price: z.string().optional().describe("New price"), - priceMatch: z - .enum([ - "OPPONENT", - "OPPONENT_5", - "OPPONENT_10", - "OPPONENT_20", - "QUEUE", - "QUEUE_5", - "QUEUE_10", - "QUEUE_20", - ]) - .optional() - .describe("Price match mode"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: "Modify an existing USD-M Futures order. Can modify price, quantity, or both.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + orderId: z.number().int().optional().describe("Order ID"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + side: z.enum(["BUY", "SELL"]).describe("Order side"), + quantity: z.string().optional().describe("New quantity"), + price: z.string().optional().describe("New price"), + priceMatch: z + .enum([ + "OPPONENT", + "OPPONENT_5", + "OPPONENT_10", + "OPPONENT_20", + "QUEUE", + "QUEUE_5", + "QUEUE_10", + "QUEUE_20", + ]) + .optional() + .describe("Price match mode"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/trade-api/newOrder.ts b/src/tools/binance-futures-usdm/trade-api/newOrder.ts index 02105af7..e85ff613 100644 --- a/src/tools/binance-futures-usdm/trade-api/newOrder.ts +++ b/src/tools/binance-futures-usdm/trade-api/newOrder.ts @@ -12,57 +12,63 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesNewOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesNewOrder", - "Place a new USD-M Futures order. Supports LIMIT, MARKET, STOP, TAKE_PROFIT, and TRAILING_STOP_MARKET orders. ⚠️ RISK: Futures trading involves leverage and liquidation risk.", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Order side"), - positionSide: z - .enum(["BOTH", "LONG", "SHORT"]) - .optional() - .describe("Position side for Hedge Mode. Use BOTH for One-Way Mode"), - type: z - .enum([ - "LIMIT", - "MARKET", - "STOP", - "STOP_MARKET", - "TAKE_PROFIT", - "TAKE_PROFIT_MARKET", - "TRAILING_STOP_MARKET", - ]) - .describe("Order type"), - quantity: z.string().optional().describe("Order quantity"), - price: z.string().optional().describe("Limit price (required for LIMIT orders)"), - stopPrice: z.string().optional().describe("Stop price (required for STOP orders)"), - timeInForce: z - .enum(["GTC", "IOC", "FOK", "GTX"]) - .optional() - .describe( - "Time in force. GTC=Good Till Cancel, IOC=Immediate Or Cancel, FOK=Fill Or Kill, GTX=Good Till Crossing", - ), - reduceOnly: z - .boolean() - .optional() - .describe("Reduce position only (cannot be used with closePosition)"), - closePosition: z - .boolean() - .optional() - .describe("Close entire position (cannot be used with quantity or reduceOnly)"), - activationPrice: z.string().optional().describe("Activation price for TRAILING_STOP_MARKET"), - callbackRate: z - .string() - .optional() - .describe("Callback rate for TRAILING_STOP_MARKET (0.1% - 5%)"), - workingType: z - .enum(["MARK_PRICE", "CONTRACT_PRICE"]) - .optional() - .describe("Stop price trigger type"), - priceProtect: z.boolean().optional().describe("Price protection"), - newClientOrderId: z.string().optional().describe("Custom order ID"), - newOrderRespType: z.enum(["ACK", "RESULT"]).optional().describe("Response type"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Place a new USD-M Futures order. Supports LIMIT, MARKET, STOP, TAKE_PROFIT, and TRAILING_STOP_MARKET orders. ⚠️ RISK: Futures trading involves leverage and liquidation risk.", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Order side"), + positionSide: z + .enum(["BOTH", "LONG", "SHORT"]) + .optional() + .describe("Position side for Hedge Mode. Use BOTH for One-Way Mode"), + type: z + .enum([ + "LIMIT", + "MARKET", + "STOP", + "STOP_MARKET", + "TAKE_PROFIT", + "TAKE_PROFIT_MARKET", + "TRAILING_STOP_MARKET", + ]) + .describe("Order type"), + quantity: z.string().optional().describe("Order quantity"), + price: z.string().optional().describe("Limit price (required for LIMIT orders)"), + stopPrice: z.string().optional().describe("Stop price (required for STOP orders)"), + timeInForce: z + .enum(["GTC", "IOC", "FOK", "GTX"]) + .optional() + .describe( + "Time in force. GTC=Good Till Cancel, IOC=Immediate Or Cancel, FOK=Fill Or Kill, GTX=Good Till Crossing", + ), + reduceOnly: z + .boolean() + .optional() + .describe("Reduce position only (cannot be used with closePosition)"), + closePosition: z + .boolean() + .optional() + .describe("Close entire position (cannot be used with quantity or reduceOnly)"), + activationPrice: z + .string() + .optional() + .describe("Activation price for TRAILING_STOP_MARKET"), + callbackRate: z + .string() + .optional() + .describe("Callback rate for TRAILING_STOP_MARKET (0.1% - 5%)"), + workingType: z + .enum(["MARK_PRICE", "CONTRACT_PRICE"]) + .optional() + .describe("Stop price trigger type"), + priceProtect: z.boolean().optional().describe("Price protection"), + newClientOrderId: z.string().optional().describe("Custom order ID"), + newOrderRespType: z.enum(["ACK", "RESULT"]).optional().describe("Response type"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/trade-api/openOrder.ts b/src/tools/binance-futures-usdm/trade-api/openOrder.ts index 24d4a8f3..2d40146d 100644 --- a/src/tools/binance-futures-usdm/trade-api/openOrder.ts +++ b/src/tools/binance-futures-usdm/trade-api/openOrder.ts @@ -12,13 +12,16 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesOpenOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesOpenOrder", - "Query a single open order. Either orderId or origClientOrderId must be provided.", { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), - orderId: z.number().optional().describe("Order ID"), - origClientOrderId: z.string().optional().describe("Original client order ID"), + description: + "Query a single open order. Either orderId or origClientOrderId must be provided.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), + orderId: z.number().optional().describe("Order ID"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/trade-api/openOrders.ts b/src/tools/binance-futures-usdm/trade-api/openOrders.ts index 77849fa3..9a9c33eb 100644 --- a/src/tools/binance-futures-usdm/trade-api/openOrders.ts +++ b/src/tools/binance-futures-usdm/trade-api/openOrders.ts @@ -12,14 +12,17 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesOpenOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesOpenOrders", - "Get all current open orders. If symbol is provided, returns orders for that symbol only. Otherwise returns all open orders (use with caution due to rate limits).", { - symbol: z - .string() - .optional() - .describe("Trading pair symbol (e.g., BTCUSDT). If omitted, returns all open orders."), + description: + "Get all current open orders. If symbol is provided, returns orders for that symbol only. Otherwise returns all open orders (use with caution due to rate limits).", + inputSchema: { + symbol: z + .string() + .optional() + .describe("Trading pair symbol (e.g., BTCUSDT). If omitted, returns all open orders."), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/trade-api/positionMarginHistory.ts b/src/tools/binance-futures-usdm/trade-api/positionMarginHistory.ts index 0bbcf451..c751a0c9 100644 --- a/src/tools/binance-futures-usdm/trade-api/positionMarginHistory.ts +++ b/src/tools/binance-futures-usdm/trade-api/positionMarginHistory.ts @@ -12,16 +12,19 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesPositionMarginHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesPositionMarginHistory", - "Get the history of isolated position margin changes (additions and reductions).", { - symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), - type: z.enum(["1", "2"]).optional().describe("1 = Add margin, 2 = Reduce margin (filter)"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z.number().int().optional().describe("Number of results (default 500, max 500)"), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Get the history of isolated position margin changes (additions and reductions).", + inputSchema: { + symbol: z.string().describe("Futures symbol (e.g., BTCUSDT)"), + type: z.enum(["1", "2"]).optional().describe("1 = Add margin, 2 = Reduce margin (filter)"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z.number().int().optional().describe("Number of results (default 500, max 500)"), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/trades.ts b/src/tools/binance-futures-usdm/trades.ts index d12b9ce8..f6ad3d76 100644 --- a/src/tools/binance-futures-usdm/trades.ts +++ b/src/tools/binance-futures-usdm/trades.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMTrades", - "Get recent trades for a specific USD-M Futures trading pair.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - limit: z.number().optional().describe("Number of trades to return. Default 500; max 1000"), + description: "Get recent trades for a specific USD-M Futures trading pair.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + limit: z.number().optional().describe("Number of trades to return. Default 500; max 1000"), + }, }, async ({ symbol, limit }) => { try { diff --git a/src/tools/binance-futures-usdm/userTrades.ts b/src/tools/binance-futures-usdm/userTrades.ts index 56a8a4a5..81f4526d 100644 --- a/src/tools/binance-futures-usdm/userTrades.ts +++ b/src/tools/binance-futures-usdm/userTrades.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { futuresClient } from "../../config/binanceClient.js"; export function registerBinanceFuturesUSDMUserTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesUSDMUserTrades", - "Get account trade list for USD-M Futures.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - orderId: z.number().optional().describe("Filter by order ID"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - fromId: z.number().optional().describe("Trade ID to start from"), - limit: z.number().optional().describe("Default 500; max 1000"), + description: "Get account trade list for USD-M Futures.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + orderId: z.number().optional().describe("Filter by order ID"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + fromId: z.number().optional().describe("Trade ID to start from"), + limit: z.number().optional().describe("Default 500; max 1000"), + }, }, async ({ symbol, orderId, startTime, endTime, fromId, limit }) => { try { diff --git a/src/tools/binance-futures-usdm/userdatastream-api/closeListenKey.ts b/src/tools/binance-futures-usdm/userdatastream-api/closeListenKey.ts index f2a263e3..98ae03bf 100644 --- a/src/tools/binance-futures-usdm/userdatastream-api/closeListenKey.ts +++ b/src/tools/binance-futures-usdm/userdatastream-api/closeListenKey.ts @@ -12,15 +12,18 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesCloseListenKey(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCloseListenKey", - "Close a USD-M Futures user data stream listen key. This invalidates the listen key and closes the associated WebSocket stream.", { - listenKey: z - .string() - .optional() - .describe("Listen key to close. If not provided, closes the default listen key."), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Close a USD-M Futures user data stream listen key. This invalidates the listen key and closes the associated WebSocket stream.", + inputSchema: { + listenKey: z + .string() + .optional() + .describe("Listen key to close. If not provided, closes the default listen key."), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/userdatastream-api/createListenKey.ts b/src/tools/binance-futures-usdm/userdatastream-api/createListenKey.ts index a99098b4..67674320 100644 --- a/src/tools/binance-futures-usdm/userdatastream-api/createListenKey.ts +++ b/src/tools/binance-futures-usdm/userdatastream-api/createListenKey.ts @@ -12,11 +12,14 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesCreateListenKey(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesCreateListenKey", - "Create a new USD-M Futures user data stream listen key. The listen key is valid for 60 minutes and can be used to receive account updates via WebSocket. Must be kept alive with keepAlive endpoint.", { - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Create a new USD-M Futures user data stream listen key. The listen key is valid for 60 minutes and can be used to receive account updates via WebSocket. Must be kept alive with keepAlive endpoint.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-futures-usdm/userdatastream-api/keepAliveListenKey.ts b/src/tools/binance-futures-usdm/userdatastream-api/keepAliveListenKey.ts index 2320049b..409d3832 100644 --- a/src/tools/binance-futures-usdm/userdatastream-api/keepAliveListenKey.ts +++ b/src/tools/binance-futures-usdm/userdatastream-api/keepAliveListenKey.ts @@ -12,15 +12,18 @@ import { z } from "zod"; import { futuresClient } from "../../../config/binanceClient.js"; export function registerBinanceFuturesKeepAliveListenKey(server: McpServer) { - server.tool( + server.registerTool( "BinanceFuturesKeepAliveListenKey", - "Keepalive a USD-M Futures user data stream listen key. Extends the validity by 60 minutes. Should be called every 30-50 minutes to maintain the connection.", { - listenKey: z - .string() - .optional() - .describe("Listen key to keep alive. If not provided, uses the default listen key."), - recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + description: + "Keepalive a USD-M Futures user data stream listen key. Extends the validity by 60 minutes. Should be called every 30-50 minutes to maintain the connection.", + inputSchema: { + listenKey: z + .string() + .optional() + .describe("Listen key to keep alive. If not provided, uses the default listen key."), + recvWindow: z.number().int().optional().describe("Recv window in milliseconds"), + }, }, async (params) => { try { diff --git a/src/tools/binance-gift-card/buyCode.ts b/src/tools/binance-gift-card/buyCode.ts index c7f7d0eb..ede9a19c 100644 --- a/src/tools/binance-gift-card/buyCode.ts +++ b/src/tools/binance-gift-card/buyCode.ts @@ -6,14 +6,17 @@ import { z } from "zod"; import { giftCardClient } from "../../config/binanceClient.js"; export function registerBinanceGiftCardBuyCode(server: McpServer) { - server.tool( + server.registerTool( "BinanceGiftCardBuyCode", - "Buy a Binance Gift Card code using another token as payment. The base token is used to purchase a gift card of the face token.", { - baseToken: z.string().describe("The token used to pay for the gift card (e.g., USDT)"), - faceToken: z.string().describe("The token the gift card will contain (e.g., BNB)"), - baseTokenAmount: z.number().describe("The amount of base token to spend"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: + "Buy a Binance Gift Card code using another token as payment. The base token is used to purchase a gift card of the face token.", + inputSchema: { + baseToken: z.string().describe("The token used to pay for the gift card (e.g., USDT)"), + faceToken: z.string().describe("The token the gift card will contain (e.g., BNB)"), + baseTokenAmount: z.number().describe("The amount of base token to spend"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ baseToken, faceToken, baseTokenAmount, recvWindow }) => { try { diff --git a/src/tools/binance-gift-card/createCode.ts b/src/tools/binance-gift-card/createCode.ts index 9c1a6e81..5fa085ed 100644 --- a/src/tools/binance-gift-card/createCode.ts +++ b/src/tools/binance-gift-card/createCode.ts @@ -6,13 +6,16 @@ import { z } from "zod"; import { giftCardClient } from "../../config/binanceClient.js"; export function registerBinanceGiftCardCreateCode(server: McpServer) { - server.tool( + server.registerTool( "BinanceGiftCardCreateCode", - "Create a Binance Gift Card code. This allows you to generate a gift card with a specified token and amount.", { - token: z.string().describe("The token to include in the gift card (e.g., BNB, USDT)"), - amount: z.number().describe("The amount of the token to include in the gift card"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: + "Create a Binance Gift Card code. This allows you to generate a gift card with a specified token and amount.", + inputSchema: { + token: z.string().describe("The token to include in the gift card (e.g., BNB, USDT)"), + amount: z.number().describe("The amount of the token to include in the gift card"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ token, amount, recvWindow }) => { try { diff --git a/src/tools/binance-gift-card/createDualTokenCode.ts b/src/tools/binance-gift-card/createDualTokenCode.ts index 8d559177..443cc3b1 100644 --- a/src/tools/binance-gift-card/createDualTokenCode.ts +++ b/src/tools/binance-gift-card/createDualTokenCode.ts @@ -6,17 +6,20 @@ import { z } from "zod"; import { giftCardClient } from "../../config/binanceClient.js"; export function registerBinanceGiftCardCreateDualTokenCode(server: McpServer) { - server.tool( + server.registerTool( "BinanceGiftCardCreateDualTokenCode", - "Create a dual-token Binance Gift Card. This creates a gift card where the base token is exchanged to the face token for redemption.", { - baseToken: z - .string() - .describe("The token used as the base for the gift card (token you pay with)"), - faceToken: z.string().describe("The token the recipient will receive when redeeming"), - baseTokenAmount: z.number().describe("The amount of base token to convert"), - discount: z.number().optional().describe("Discount percentage (if applicable)"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: + "Create a dual-token Binance Gift Card. This creates a gift card where the base token is exchanged to the face token for redemption.", + inputSchema: { + baseToken: z + .string() + .describe("The token used as the base for the gift card (token you pay with)"), + faceToken: z.string().describe("The token the recipient will receive when redeeming"), + baseTokenAmount: z.number().describe("The amount of base token to convert"), + discount: z.number().optional().describe("Discount percentage (if applicable)"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ baseToken, faceToken, baseTokenAmount, discount, recvWindow }) => { try { diff --git a/src/tools/binance-gift-card/createDualTokenGiftCard.ts b/src/tools/binance-gift-card/createDualTokenGiftCard.ts index bb9eb2ca..b865e399 100644 --- a/src/tools/binance-gift-card/createDualTokenGiftCard.ts +++ b/src/tools/binance-gift-card/createDualTokenGiftCard.ts @@ -12,15 +12,18 @@ import { z } from "zod"; import { giftCardClient } from "../../config/binanceClient.js"; export function registerBinanceGiftCardCreateDualToken(server: McpServer) { - server.tool( + server.registerTool( "BinanceGiftCardCreateDualToken", - "Create a dual-token Binance Gift Card. Allows creating a gift card using one token that the recipient will receive as another token.", { - baseToken: z.string().describe("Token used to pay for the gift card (e.g., 'USDT')"), - faceToken: z.string().describe("Token that the recipient will receive (e.g., 'BNB')"), - baseTokenAmount: z.string().describe("Amount of base token to spend"), - discount: z.number().optional().describe("Discount rate (0-100)"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Create a dual-token Binance Gift Card. Allows creating a gift card using one token that the recipient will receive as another token.", + inputSchema: { + baseToken: z.string().describe("Token used to pay for the gift card (e.g., 'USDT')"), + faceToken: z.string().describe("Token that the recipient will receive (e.g., 'BNB')"), + baseTokenAmount: z.string().describe("Amount of base token to spend"), + discount: z.number().optional().describe("Discount rate (0-100)"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-gift-card/createGiftCard.ts b/src/tools/binance-gift-card/createGiftCard.ts index 83320ad6..a0be0c43 100644 --- a/src/tools/binance-gift-card/createGiftCard.ts +++ b/src/tools/binance-gift-card/createGiftCard.ts @@ -12,13 +12,16 @@ import { z } from "zod"; import { giftCardClient } from "../../config/binanceClient.js"; export function registerBinanceGiftCardCreate(server: McpServer) { - server.tool( + server.registerTool( "BinanceGiftCardCreate", - "Create a Binance Gift Card. The card will be deducted from your spot wallet balance.", { - token: z.string().describe("Token type (e.g., 'BNB', 'USDT', 'BTC')"), - amount: z.string().describe("Amount of tokens to include in gift card"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Create a Binance Gift Card. The card will be deducted from your spot wallet balance.", + inputSchema: { + token: z.string().describe("Token type (e.g., 'BNB', 'USDT', 'BTC')"), + amount: z.string().describe("Amount of tokens to include in gift card"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-gift-card/getTokenLimit.ts b/src/tools/binance-gift-card/getTokenLimit.ts index d6519370..5c8940a1 100644 --- a/src/tools/binance-gift-card/getTokenLimit.ts +++ b/src/tools/binance-gift-card/getTokenLimit.ts @@ -6,12 +6,15 @@ import { z } from "zod"; import { giftCardClient } from "../../config/binanceClient.js"; export function registerBinanceGiftCardGetTokenLimit(server: McpServer) { - server.tool( + server.registerTool( "BinanceGiftCardGetTokenLimit", - "Fetch the token limits for buying gift cards, including minimum and maximum amounts.", { - baseToken: z.string().describe("The base token to check limits for (e.g., USDT)"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: + "Fetch the token limits for buying gift cards, including minimum and maximum amounts.", + inputSchema: { + baseToken: z.string().describe("The base token to check limits for (e.g., USDT)"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ baseToken, recvWindow }) => { try { diff --git a/src/tools/binance-gift-card/redeemCode.ts b/src/tools/binance-gift-card/redeemCode.ts index 2ab59318..c4b630ea 100644 --- a/src/tools/binance-gift-card/redeemCode.ts +++ b/src/tools/binance-gift-card/redeemCode.ts @@ -6,13 +6,18 @@ import { z } from "zod"; import { giftCardClient } from "../../config/binanceClient.js"; export function registerBinanceGiftCardRedeemCode(server: McpServer) { - server.tool( + server.registerTool( "BinanceGiftCardRedeemCode", - "Redeem a Binance Gift Card code. The tokens will be credited to your account.", { - code: z.string().describe("The gift card code to redeem"), - externalUid: z.string().optional().describe("External unique identifier for the redemption"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Redeem a Binance Gift Card code. The tokens will be credited to your account.", + inputSchema: { + code: z.string().describe("The gift card code to redeem"), + externalUid: z + .string() + .optional() + .describe("External unique identifier for the redemption"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ code, externalUid, recvWindow }) => { try { diff --git a/src/tools/binance-gift-card/redeemDualTokenGiftCard.ts b/src/tools/binance-gift-card/redeemDualTokenGiftCard.ts index bf933dd4..28c9c4da 100644 --- a/src/tools/binance-gift-card/redeemDualTokenGiftCard.ts +++ b/src/tools/binance-gift-card/redeemDualTokenGiftCard.ts @@ -12,13 +12,15 @@ import { z } from "zod"; import { giftCardClient } from "../../config/binanceClient.js"; export function registerBinanceGiftCardRedeemDualToken(server: McpServer) { - server.tool( + server.registerTool( "BinanceGiftCardRedeemDualToken", - "Redeem a dual-token Binance Gift Card.", { - code: z.string().describe("Gift card redemption code"), - externalUid: z.string().optional().describe("External user ID for partner integration"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Redeem a dual-token Binance Gift Card.", + inputSchema: { + code: z.string().describe("Gift card redemption code"), + externalUid: z.string().optional().describe("External user ID for partner integration"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-gift-card/redeemGiftCard.ts b/src/tools/binance-gift-card/redeemGiftCard.ts index e5d20d1b..101e3770 100644 --- a/src/tools/binance-gift-card/redeemGiftCard.ts +++ b/src/tools/binance-gift-card/redeemGiftCard.ts @@ -12,13 +12,15 @@ import { z } from "zod"; import { giftCardClient } from "../../config/binanceClient.js"; export function registerBinanceGiftCardRedeem(server: McpServer) { - server.tool( + server.registerTool( "BinanceGiftCardRedeem", - "Redeem a Binance Gift Card. The tokens will be credited to your spot wallet.", { - code: z.string().describe("Gift card redemption code"), - externalUid: z.string().optional().describe("External user ID for partner integration"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: "Redeem a Binance Gift Card. The tokens will be credited to your spot wallet.", + inputSchema: { + code: z.string().describe("Gift card redemption code"), + externalUid: z.string().optional().describe("External user ID for partner integration"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-gift-card/rsaPublicKey.ts b/src/tools/binance-gift-card/rsaPublicKey.ts index c50d4c4e..2f4f3505 100644 --- a/src/tools/binance-gift-card/rsaPublicKey.ts +++ b/src/tools/binance-gift-card/rsaPublicKey.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { giftCardClient } from "../../config/binanceClient.js"; export function registerBinanceGiftCardRsaPublicKey(server: McpServer) { - server.tool( + server.registerTool( "BinanceGiftCardRsaPublicKey", - "Fetch the RSA public key for encrypting gift card codes.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Fetch the RSA public key for encrypting gift card codes.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/tools/binance-gift-card/tokenLimit.ts b/src/tools/binance-gift-card/tokenLimit.ts index d4203e46..bc860cf8 100644 --- a/src/tools/binance-gift-card/tokenLimit.ts +++ b/src/tools/binance-gift-card/tokenLimit.ts @@ -12,12 +12,15 @@ import { z } from "zod"; import { giftCardClient } from "../../config/binanceClient.js"; export function registerBinanceGiftCardTokenLimit(server: McpServer) { - server.tool( + server.registerTool( "BinanceGiftCardTokenLimit", - "Get token limit information for Binance Gift Card creation. Shows minimum and maximum amounts.", { - baseToken: z.string().describe("Base token for buying gift cards (e.g., 'USDT')"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Get token limit information for Binance Gift Card creation. Shows minimum and maximum amounts.", + inputSchema: { + baseToken: z.string().describe("Base token for buying gift cards (e.g., 'USDT')"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-gift-card/verify.ts b/src/tools/binance-gift-card/verify.ts index f05b7322..76a71925 100644 --- a/src/tools/binance-gift-card/verify.ts +++ b/src/tools/binance-gift-card/verify.ts @@ -6,12 +6,15 @@ import { z } from "zod"; import { giftCardClient } from "../../config/binanceClient.js"; export function registerBinanceGiftCardVerify(server: McpServer) { - server.tool( + server.registerTool( "BinanceGiftCardVerify", - "Verify a Binance Gift Card code to check its validity and status without redeeming it.", { - referenceNo: z.string().describe("The reference number of the gift card to verify"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: + "Verify a Binance Gift Card code to check its validity and status without redeeming it.", + inputSchema: { + referenceNo: z.string().describe("The reference number of the gift card to verify"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ referenceNo, recvWindow }) => { try { diff --git a/src/tools/binance-gift-card/verifyGiftCard.ts b/src/tools/binance-gift-card/verifyGiftCard.ts index e2790824..61f4a009 100644 --- a/src/tools/binance-gift-card/verifyGiftCard.ts +++ b/src/tools/binance-gift-card/verifyGiftCard.ts @@ -12,12 +12,15 @@ import { z } from "zod"; import { giftCardClient } from "../../config/binanceClient.js"; export function registerBinanceGiftCardVerify(server: McpServer) { - server.tool( + server.registerTool( "BinanceGiftCardVerify", - "Verify a Binance Gift Card code. Check if the code is valid and see its details before redeeming.", { - referenceNo: z.string().describe("Gift card reference number"), - recvWindow: z.number().int().optional().describe("Request validity window in ms"), + description: + "Verify a Binance Gift Card code. Check if the code is valid and see its details before redeeming.", + inputSchema: { + referenceNo: z.string().describe("Gift card reference number"), + recvWindow: z.number().int().optional().describe("Request validity window in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginAccount.ts b/src/tools/binance-margin/cross-margin-api/crossMarginAccount.ts index f4d2c6f1..eeb5bffa 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginAccount.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginAccount.ts @@ -6,11 +6,14 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginAccount(server: McpServer) { - server.tool( + server.registerTool( "BinanceCrossMarginAccount", - "Query Cross Margin account details including balances, margin level, and collateral info.", { - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Query Cross Margin account details including balances, margin level, and collateral info.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginAllAssets.ts b/src/tools/binance-margin/cross-margin-api/crossMarginAllAssets.ts index b810b1d3..69d56a35 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginAllAssets.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginAllAssets.ts @@ -12,17 +12,20 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginAllAssets(server: McpServer) { - server.tool( + server.registerTool( "BinanceCrossMarginAllAssets", - "Get all assets available for cross margin trading, including borrowable status, daily interest rates, and limits.", { - asset: z - .string() - .optional() - .describe( - "Specific asset to query (e.g., BTC, USDT). If not provided, returns all assets.", - ), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Get all assets available for cross margin trading, including borrowable status, daily interest rates, and limits.", + inputSchema: { + asset: z + .string() + .optional() + .describe( + "Specific asset to query (e.g., BTC, USDT). If not provided, returns all assets.", + ), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginAllOrders.ts b/src/tools/binance-margin/cross-margin-api/crossMarginAllOrders.ts index aa73d933..5b3561a9 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginAllOrders.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginAllOrders.ts @@ -6,17 +6,20 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginAllOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceCrossMarginAllOrders", - "Query all margin orders for a symbol. Returns both open and filled/cancelled orders.", { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), - isIsolated: z.enum(["TRUE", "FALSE"]).optional().describe("For isolated margin or not"), - orderId: z.number().int().optional().describe("Order ID to start from"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z.number().int().optional().describe("Number of results (default 500, max 500)"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Query all margin orders for a symbol. Returns both open and filled/cancelled orders.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), + isIsolated: z.enum(["TRUE", "FALSE"]).optional().describe("For isolated margin or not"), + orderId: z.number().int().optional().describe("Order ID to start from"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z.number().int().optional().describe("Number of results (default 500, max 500)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginAvailableInventory.ts b/src/tools/binance-margin/cross-margin-api/crossMarginAvailableInventory.ts index 967d61a6..1253a8f6 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginAvailableInventory.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginAvailableInventory.ts @@ -6,14 +6,16 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginAvailableInventory(server: McpServer) { - server.tool( + server.registerTool( "BinanceCrossMarginAvailableInventory", - "Query margin available inventory for borrowing.", { - type: z - .enum(["MARGIN", "ISOLATED"]) - .describe("Type of margin (MARGIN for cross, ISOLATED for isolated)"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Query margin available inventory for borrowing.", + inputSchema: { + type: z + .enum(["MARGIN", "ISOLATED"]) + .describe("Type of margin (MARGIN for cross, ISOLATED for isolated)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginBorrow.ts b/src/tools/binance-margin/cross-margin-api/crossMarginBorrow.ts index 683ca1ef..dfcc3a36 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginBorrow.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginBorrow.ts @@ -6,18 +6,21 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginBorrow(server: McpServer) { - server.tool( + server.registerTool( "BinanceCrossMarginBorrow", - "Borrow assets in Cross Margin account. Apply for a loan with the specified asset and amount.", { - asset: z.string().describe("Asset to borrow (e.g., BTC, USDT)"), - amount: z.string().describe("Amount to borrow"), - isIsolated: z - .enum(["TRUE", "FALSE"]) - .optional() - .describe("For isolated margin or not, default FALSE"), - symbol: z.string().optional().describe("Isolated symbol, required when isIsolated=TRUE"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Borrow assets in Cross Margin account. Apply for a loan with the specified asset and amount.", + inputSchema: { + asset: z.string().describe("Asset to borrow (e.g., BTC, USDT)"), + amount: z.string().describe("Amount to borrow"), + isIsolated: z + .enum(["TRUE", "FALSE"]) + .optional() + .describe("For isolated margin or not, default FALSE"), + symbol: z.string().optional().describe("Isolated symbol, required when isIsolated=TRUE"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginCancelAllOrders.ts b/src/tools/binance-margin/cross-margin-api/crossMarginCancelAllOrders.ts index 875b8d43..d9ec609f 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginCancelAllOrders.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginCancelAllOrders.ts @@ -6,12 +6,15 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginCancelAllOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceCrossMarginCancelAllOrders", - "Cancel all open margin orders for a specific trading pair. This will cancel all open orders on the symbol.", { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Cancel all open margin orders for a specific trading pair. This will cancel all open orders on the symbol.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginCancelOrder.ts b/src/tools/binance-margin/cross-margin-api/crossMarginCancelOrder.ts index e49a57b8..763f0724 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginCancelOrder.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginCancelOrder.ts @@ -6,18 +6,21 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginCancelOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceCrossMarginCancelOrder", - "Cancel an active margin order. Either orderId or origClientOrderId must be provided.", { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), - orderId: z.number().int().optional().describe("Order ID to cancel"), - origClientOrderId: z.string().optional().describe("Original client order ID to cancel"), - newClientOrderId: z - .string() - .optional() - .describe("New client order ID for the cancel request"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Cancel an active margin order. Either orderId or origClientOrderId must be provided.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), + orderId: z.number().int().optional().describe("Order ID to cancel"), + origClientOrderId: z.string().optional().describe("Original client order ID to cancel"), + newClientOrderId: z + .string() + .optional() + .describe("New client order ID for the cancel request"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginCapitalFlow.ts b/src/tools/binance-margin/cross-margin-api/crossMarginCapitalFlow.ts index 270cdfca..07280173 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginCapitalFlow.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginCapitalFlow.ts @@ -6,33 +6,36 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginCapitalFlow(server: McpServer) { - server.tool( + server.registerTool( "BinanceCrossMarginCapitalFlow", - "Get cross margin capital flow history including transfers, borrows, repays, and interest.", { - asset: z.string().optional().describe("Filter by asset symbol"), - symbol: z.string().optional().describe("Filter by trading pair symbol"), - type: z - .enum([ - "TRANSFER_IN", - "TRANSFER_OUT", - "BORROW", - "REPAY", - "BUY_INCOME", - "SELL_LOSS", - "TRADING_COMMISSION", - "LIQUIDATION", - "INTEREST", - "SMALL_LIABILITY_EXCHANGE", - "SMALL_ASSETS_EXCHANGE", - ]) - .optional() - .describe("Type of capital flow"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - fromId: z.number().int().optional().describe("Start from ID"), - limit: z.number().int().optional().describe("Number of results (default 500, max 1000)"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Get cross margin capital flow history including transfers, borrows, repays, and interest.", + inputSchema: { + asset: z.string().optional().describe("Filter by asset symbol"), + symbol: z.string().optional().describe("Filter by trading pair symbol"), + type: z + .enum([ + "TRANSFER_IN", + "TRANSFER_OUT", + "BORROW", + "REPAY", + "BUY_INCOME", + "SELL_LOSS", + "TRADING_COMMISSION", + "LIQUIDATION", + "INTEREST", + "SMALL_LIABILITY_EXCHANGE", + "SMALL_ASSETS_EXCHANGE", + ]) + .optional() + .describe("Type of capital flow"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + fromId: z.number().int().optional().describe("Start from ID"), + limit: z.number().int().optional().describe("Number of results (default 500, max 1000)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginDelist.ts b/src/tools/binance-margin/cross-margin-api/crossMarginDelist.ts index 5f24729e..6ae78f3f 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginDelist.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginDelist.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginDelist(server: McpServer) { - server.tool( + server.registerTool( "BinanceCrossMarginDelist", - "Get delist schedule for cross margin trading pairs. Shows upcoming delistings.", { - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Get delist schedule for cross margin trading pairs. Shows upcoming delistings.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginDustLog.ts b/src/tools/binance-margin/cross-margin-api/crossMarginDustLog.ts index f19927b6..31aa0e03 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginDustLog.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginDustLog.ts @@ -6,13 +6,16 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginDustLog(server: McpServer) { - server.tool( + server.registerTool( "BinanceCrossMarginDustLog", - "Query margin dust conversion log. Shows history of small balance conversions to BNB.", { - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Query margin dust conversion log. Shows history of small balance conversions to BNB.", + inputSchema: { + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginFee.ts b/src/tools/binance-margin/cross-margin-api/crossMarginFee.ts index 2050471a..9d0e4441 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginFee.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginFee.ts @@ -6,17 +6,20 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginFee(server: McpServer) { - server.tool( + server.registerTool( "BinanceCrossMarginFee", - "Query cross margin fee data including interest rates and collateral ratios for margin pairs.", { - vipLevel: z - .number() - .int() - .optional() - .describe("VIP level (default uses current account VIP level)"), - coin: z.string().optional().describe("Filter by specific coin"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Query cross margin fee data including interest rates and collateral ratios for margin pairs.", + inputSchema: { + vipLevel: z + .number() + .int() + .optional() + .describe("VIP level (default uses current account VIP level)"), + coin: z.string().optional().describe("Filter by specific coin"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginForceLiquidationRec.ts b/src/tools/binance-margin/cross-margin-api/crossMarginForceLiquidationRec.ts index 675ba4ed..55113bd5 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginForceLiquidationRec.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginForceLiquidationRec.ts @@ -6,16 +6,19 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginForceLiquidationRec(server: McpServer) { - server.tool( + server.registerTool( "BinanceCrossMarginForceLiquidationRec", - "Get force liquidation record for margin account. Shows historical liquidation events.", { - isolatedSymbol: z.string().optional().describe("Isolated symbol for isolated margin"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - current: z.number().int().optional().describe("Current page (default 1)"), - size: z.number().int().optional().describe("Page size (default 10, max 100)"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Get force liquidation record for margin account. Shows historical liquidation events.", + inputSchema: { + isolatedSymbol: z.string().optional().describe("Isolated symbol for isolated margin"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + current: z.number().int().optional().describe("Current page (default 1)"), + size: z.number().int().optional().describe("Page size (default 10, max 100)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginInterestHistory.ts b/src/tools/binance-margin/cross-margin-api/crossMarginInterestHistory.ts index 00c24200..23887d38 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginInterestHistory.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginInterestHistory.ts @@ -6,18 +6,20 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginInterestHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceCrossMarginInterestHistory", - "Query interest history for Cross Margin account.", { - asset: z.string().optional().describe("Asset (e.g., BTC, USDT)"), - isolatedSymbol: z.string().optional().describe("Isolated symbol"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - current: z.number().int().optional().describe("Current page, default 1"), - size: z.number().int().optional().describe("Page size, default 10, max 100"), - archived: z.boolean().optional().describe("Query archived data, default false"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Query interest history for Cross Margin account.", + inputSchema: { + asset: z.string().optional().describe("Asset (e.g., BTC, USDT)"), + isolatedSymbol: z.string().optional().describe("Isolated symbol"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + current: z.number().int().optional().describe("Current page, default 1"), + size: z.number().int().optional().describe("Page size, default 10, max 100"), + archived: z.boolean().optional().describe("Query archived data, default false"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginInterestRateHistory.ts b/src/tools/binance-margin/cross-margin-api/crossMarginInterestRateHistory.ts index 874a8ffa..8deb735a 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginInterestRateHistory.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginInterestRateHistory.ts @@ -6,19 +6,21 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginInterestRateHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceCrossMarginInterestRateHistory", - "Query margin interest rate history for a specific asset.", { - asset: z.string().describe("Asset symbol (e.g., BTC, USDT)"), - vipLevel: z - .number() - .int() - .optional() - .describe("VIP level (default uses current account VIP level)"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Query margin interest rate history for a specific asset.", + inputSchema: { + asset: z.string().describe("Asset symbol (e.g., BTC, USDT)"), + vipLevel: z + .number() + .int() + .optional() + .describe("VIP level (default uses current account VIP level)"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginLoanRecord.ts b/src/tools/binance-margin/cross-margin-api/crossMarginLoanRecord.ts index 51ce3d28..1d27e87c 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginLoanRecord.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginLoanRecord.ts @@ -6,19 +6,21 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginLoanRecord(server: McpServer) { - server.tool( + server.registerTool( "BinanceCrossMarginLoanRecord", - "Query loan record for Cross Margin account.", { - asset: z.string().describe("Asset (e.g., BTC, USDT)"), - isolatedSymbol: z.string().optional().describe("Isolated symbol"), - txId: z.number().int().optional().describe("Transaction ID"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - current: z.number().int().optional().describe("Current page, default 1"), - size: z.number().int().optional().describe("Page size, default 10, max 100"), - archived: z.boolean().optional().describe("Query archived data, default false"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Query loan record for Cross Margin account.", + inputSchema: { + asset: z.string().describe("Asset (e.g., BTC, USDT)"), + isolatedSymbol: z.string().optional().describe("Isolated symbol"), + txId: z.number().int().optional().describe("Transaction ID"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + current: z.number().int().optional().describe("Current page, default 1"), + size: z.number().int().optional().describe("Page size, default 10, max 100"), + archived: z.boolean().optional().describe("Query archived data, default false"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginMaxBorrowable.ts b/src/tools/binance-margin/cross-margin-api/crossMarginMaxBorrowable.ts index 7d27407b..9ee7f4c6 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginMaxBorrowable.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginMaxBorrowable.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginMaxBorrowable(server: McpServer) { - server.tool( + server.registerTool( "BinanceCrossMarginMaxBorrowable", - "Query maximum borrowable amount for an asset in Cross Margin.", { - asset: z.string().describe("Asset (e.g., BTC, USDT)"), - isolatedSymbol: z.string().optional().describe("Isolated symbol"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Query maximum borrowable amount for an asset in Cross Margin.", + inputSchema: { + asset: z.string().describe("Asset (e.g., BTC, USDT)"), + isolatedSymbol: z.string().optional().describe("Isolated symbol"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginMaxTransferable.ts b/src/tools/binance-margin/cross-margin-api/crossMarginMaxTransferable.ts index e1e7690c..e1d3ef28 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginMaxTransferable.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginMaxTransferable.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginMaxTransferable(server: McpServer) { - server.tool( + server.registerTool( "BinanceCrossMarginMaxTransferable", - "Query maximum transferable amount for an asset in Cross Margin.", { - asset: z.string().describe("Asset (e.g., BTC, USDT)"), - isolatedSymbol: z.string().optional().describe("Isolated symbol"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Query maximum transferable amount for an asset in Cross Margin.", + inputSchema: { + asset: z.string().describe("Asset (e.g., BTC, USDT)"), + isolatedSymbol: z.string().optional().describe("Isolated symbol"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginMyTrades.ts b/src/tools/binance-margin/cross-margin-api/crossMarginMyTrades.ts index b832a576..8b1d3f74 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginMyTrades.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginMyTrades.ts @@ -6,18 +6,20 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginMyTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceCrossMarginMyTrades", - "Query margin account trade history for a specific symbol.", { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), - isIsolated: z.enum(["TRUE", "FALSE"]).optional().describe("For isolated margin or not"), - orderId: z.number().int().optional().describe("Filter by order ID"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - fromId: z.number().int().optional().describe("Trade ID to start from"), - limit: z.number().int().optional().describe("Number of results (default 500, max 1000)"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Query margin account trade history for a specific symbol.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), + isIsolated: z.enum(["TRUE", "FALSE"]).optional().describe("For isolated margin or not"), + orderId: z.number().int().optional().describe("Filter by order ID"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + fromId: z.number().int().optional().describe("Trade ID to start from"), + limit: z.number().int().optional().describe("Number of results (default 500, max 1000)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginNewOrder.ts b/src/tools/binance-margin/cross-margin-api/crossMarginNewOrder.ts index 5fe112f7..b1372bff 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginNewOrder.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginNewOrder.ts @@ -6,44 +6,50 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginNewOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceCrossMarginNewOrder", - "Post a new margin order in Cross Margin account. Supports various order types including LIMIT, MARKET, STOP_LOSS, etc.", { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Order side"), - type: z - .enum([ - "LIMIT", - "MARKET", - "STOP_LOSS", - "STOP_LOSS_LIMIT", - "TAKE_PROFIT", - "TAKE_PROFIT_LIMIT", - "LIMIT_MAKER", - ]) - .describe("Order type"), - quantity: z.string().optional().describe("Order quantity"), - quoteOrderQty: z.string().optional().describe("Quote order quantity for MARKET orders"), - price: z.string().optional().describe("Order price (required for LIMIT orders)"), - stopPrice: z.string().optional().describe("Stop price for STOP_LOSS and TAKE_PROFIT orders"), - newClientOrderId: z.string().optional().describe("Unique client order ID"), - icebergQty: z.string().optional().describe("Iceberg quantity"), - newOrderRespType: z.enum(["ACK", "RESULT", "FULL"]).optional().describe("Response type"), - sideEffectType: z - .enum(["NO_SIDE_EFFECT", "MARGIN_BUY", "AUTO_REPAY", "AUTO_BORROW_REPAY"]) - .optional() - .describe("Side effect type for margin orders"), - timeInForce: z.enum(["GTC", "IOC", "FOK"]).optional().describe("Time in force"), - selfTradePreventionMode: z - .enum(["EXPIRE_TAKER", "EXPIRE_MAKER", "EXPIRE_BOTH", "NONE"]) - .optional() - .describe("Self-trade prevention mode"), - autoRepayAtCancel: z - .boolean() - .optional() - .describe("Auto repay at cancel, only for AUTO_BORROW_REPAY"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Post a new margin order in Cross Margin account. Supports various order types including LIMIT, MARKET, STOP_LOSS, etc.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Order side"), + type: z + .enum([ + "LIMIT", + "MARKET", + "STOP_LOSS", + "STOP_LOSS_LIMIT", + "TAKE_PROFIT", + "TAKE_PROFIT_LIMIT", + "LIMIT_MAKER", + ]) + .describe("Order type"), + quantity: z.string().optional().describe("Order quantity"), + quoteOrderQty: z.string().optional().describe("Quote order quantity for MARKET orders"), + price: z.string().optional().describe("Order price (required for LIMIT orders)"), + stopPrice: z + .string() + .optional() + .describe("Stop price for STOP_LOSS and TAKE_PROFIT orders"), + newClientOrderId: z.string().optional().describe("Unique client order ID"), + icebergQty: z.string().optional().describe("Iceberg quantity"), + newOrderRespType: z.enum(["ACK", "RESULT", "FULL"]).optional().describe("Response type"), + sideEffectType: z + .enum(["NO_SIDE_EFFECT", "MARGIN_BUY", "AUTO_REPAY", "AUTO_BORROW_REPAY"]) + .optional() + .describe("Side effect type for margin orders"), + timeInForce: z.enum(["GTC", "IOC", "FOK"]).optional().describe("Time in force"), + selfTradePreventionMode: z + .enum(["EXPIRE_TAKER", "EXPIRE_MAKER", "EXPIRE_BOTH", "NONE"]) + .optional() + .describe("Self-trade prevention mode"), + autoRepayAtCancel: z + .boolean() + .optional() + .describe("Auto repay at cancel, only for AUTO_BORROW_REPAY"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginOpenOrders.ts b/src/tools/binance-margin/cross-margin-api/crossMarginOpenOrders.ts index ced9ca76..20a398c0 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginOpenOrders.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginOpenOrders.ts @@ -6,13 +6,16 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginOpenOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceCrossMarginOpenOrders", - "Query all open margin orders. If symbol is provided, only orders for that symbol are returned.", { - symbol: z.string().optional().describe("Trading pair symbol (e.g., BTCUSDT)"), - isIsolated: z.enum(["TRUE", "FALSE"]).optional().describe("For isolated margin or not"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Query all open margin orders. If symbol is provided, only orders for that symbol are returned.", + inputSchema: { + symbol: z.string().optional().describe("Trading pair symbol (e.g., BTCUSDT)"), + isIsolated: z.enum(["TRUE", "FALSE"]).optional().describe("For isolated margin or not"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginPairs.ts b/src/tools/binance-margin/cross-margin-api/crossMarginPairs.ts index 176cf8d6..9716b451 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginPairs.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginPairs.ts @@ -6,11 +6,14 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginPairs(server: McpServer) { - server.tool( + server.registerTool( "BinanceCrossMarginPairs", - "Get all cross margin trading pairs. Returns information about all available cross margin pairs including base/quote assets and margin ratio.", { - symbol: z.string().optional().describe("Filter by specific trading pair symbol"), + description: + "Get all cross margin trading pairs. Returns information about all available cross margin pairs including base/quote assets and margin ratio.", + inputSchema: { + symbol: z.string().optional().describe("Filter by specific trading pair symbol"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginPriceIndex.ts b/src/tools/binance-margin/cross-margin-api/crossMarginPriceIndex.ts index 8a018fd6..76434bcb 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginPriceIndex.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginPriceIndex.ts @@ -6,11 +6,14 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginPriceIndex(server: McpServer) { - server.tool( + server.registerTool( "BinanceCrossMarginPriceIndex", - "Query margin price index for a specific trading pair. Returns the current price index used for margin calculations.", { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), + description: + "Query margin price index for a specific trading pair. Returns the current price index used for margin calculations.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSDT)"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginRepay.ts b/src/tools/binance-margin/cross-margin-api/crossMarginRepay.ts index d1a812d5..1270b6ff 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginRepay.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginRepay.ts @@ -6,18 +6,21 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginRepay(server: McpServer) { - server.tool( + server.registerTool( "BinanceCrossMarginRepay", - "Repay loan for Cross Margin account. Repay the borrowed asset with the specified amount.", { - asset: z.string().describe("Asset to repay (e.g., BTC, USDT)"), - amount: z.string().describe("Amount to repay"), - isIsolated: z - .enum(["TRUE", "FALSE"]) - .optional() - .describe("For isolated margin or not, default FALSE"), - symbol: z.string().optional().describe("Isolated symbol, required when isIsolated=TRUE"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Repay loan for Cross Margin account. Repay the borrowed asset with the specified amount.", + inputSchema: { + asset: z.string().describe("Asset to repay (e.g., BTC, USDT)"), + amount: z.string().describe("Amount to repay"), + isIsolated: z + .enum(["TRUE", "FALSE"]) + .optional() + .describe("For isolated margin or not, default FALSE"), + symbol: z.string().optional().describe("Isolated symbol, required when isIsolated=TRUE"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginRepayRecord.ts b/src/tools/binance-margin/cross-margin-api/crossMarginRepayRecord.ts index e436b400..1a66cf43 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginRepayRecord.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginRepayRecord.ts @@ -6,19 +6,21 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginRepayRecord(server: McpServer) { - server.tool( + server.registerTool( "BinanceCrossMarginRepayRecord", - "Query repay record for Cross Margin account.", { - asset: z.string().describe("Asset (e.g., BTC, USDT)"), - isolatedSymbol: z.string().optional().describe("Isolated symbol"), - txId: z.number().int().optional().describe("Transaction ID"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - current: z.number().int().optional().describe("Current page, default 1"), - size: z.number().int().optional().describe("Page size, default 10, max 100"), - archived: z.boolean().optional().describe("Query archived data, default false"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Query repay record for Cross Margin account.", + inputSchema: { + asset: z.string().describe("Asset (e.g., BTC, USDT)"), + isolatedSymbol: z.string().optional().describe("Isolated symbol"), + txId: z.number().int().optional().describe("Transaction ID"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + current: z.number().int().optional().describe("Current page, default 1"), + size: z.number().int().optional().describe("Page size, default 10, max 100"), + archived: z.boolean().optional().describe("Query archived data, default false"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginSmallLiabilityExchange.ts b/src/tools/binance-margin/cross-margin-api/crossMarginSmallLiabilityExchange.ts index bd660b2f..5c1af40c 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginSmallLiabilityExchange.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginSmallLiabilityExchange.ts @@ -6,14 +6,17 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginSmallLiabilityExchange(server: McpServer) { - server.tool( + server.registerTool( "BinanceCrossMarginSmallLiabilityExchange", - "Cross margin small liability exchange. Converts small liabilities to a single asset.", { - assetNames: z - .array(z.string()) - .describe("Array of asset names to exchange (e.g., ['BTC', 'ETH'])"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Cross margin small liability exchange. Converts small liabilities to a single asset.", + inputSchema: { + assetNames: z + .array(z.string()) + .describe("Array of asset names to exchange (e.g., ['BTC', 'ETH'])"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginSmallLiabilityExchangeHistory.ts b/src/tools/binance-margin/cross-margin-api/crossMarginSmallLiabilityExchangeHistory.ts index a36f7b0a..bc202acd 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginSmallLiabilityExchangeHistory.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginSmallLiabilityExchangeHistory.ts @@ -6,15 +6,17 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginSmallLiabilityExchangeHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceCrossMarginSmallLiabilityExchangeHistory", - "Get cross margin small liability exchange history.", { - current: z.number().int().optional().describe("Current page (default 1)"), - size: z.number().int().optional().describe("Page size (default 10, max 100)"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Get cross margin small liability exchange history.", + inputSchema: { + current: z.number().int().optional().describe("Current page (default 1)"), + size: z.number().int().optional().describe("Page size (default 10, max 100)"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginTransfer.ts b/src/tools/binance-margin/cross-margin-api/crossMarginTransfer.ts index b63dc852..ed8f1829 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginTransfer.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginTransfer.ts @@ -6,14 +6,17 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceCrossMarginTransfer(server: McpServer) { - server.tool( + server.registerTool( "BinanceCrossMarginTransfer", - "Execute a cross margin account transfer. Transfer between spot and cross margin accounts.", { - asset: z.string().describe("Asset to transfer (e.g., BTC, USDT)"), - amount: z.string().describe("Amount to transfer"), - type: z.enum(["1", "2"]).describe("1: Spot to Margin, 2: Margin to Spot"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Execute a cross margin account transfer. Transfer between spot and cross margin accounts.", + inputSchema: { + asset: z.string().describe("Asset to transfer (e.g., BTC, USDT)"), + amount: z.string().describe("Amount to transfer"), + type: z.enum(["1", "2"]).describe("1: Spot to Margin, 2: Margin to Spot"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/isolated-margin-api/disableIsolatedMarginAccount.ts b/src/tools/binance-margin/isolated-margin-api/disableIsolatedMarginAccount.ts index 5f24242a..dd69983b 100644 --- a/src/tools/binance-margin/isolated-margin-api/disableIsolatedMarginAccount.ts +++ b/src/tools/binance-margin/isolated-margin-api/disableIsolatedMarginAccount.ts @@ -12,12 +12,15 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceDisableIsolatedMarginAccount(server: McpServer) { - server.tool( + server.registerTool( "BinanceDisableIsolatedMarginAccount", - "Disable isolated margin account for a specific symbol. All assets must be transferred out first.", { - symbol: z.string().describe("Symbol to disable isolated margin for (e.g., BTCUSDT)"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Disable isolated margin account for a specific symbol. All assets must be transferred out first.", + inputSchema: { + symbol: z.string().describe("Symbol to disable isolated margin for (e.g., BTCUSDT)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/isolated-margin-api/enableIsolatedMarginAccount.ts b/src/tools/binance-margin/isolated-margin-api/enableIsolatedMarginAccount.ts index c0a231f0..307e9164 100644 --- a/src/tools/binance-margin/isolated-margin-api/enableIsolatedMarginAccount.ts +++ b/src/tools/binance-margin/isolated-margin-api/enableIsolatedMarginAccount.ts @@ -12,12 +12,14 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceEnableIsolatedMarginAccount(server: McpServer) { - server.tool( + server.registerTool( "BinanceEnableIsolatedMarginAccount", - "Enable isolated margin account for a specific symbol.", { - symbol: z.string().describe("Symbol to enable isolated margin for (e.g., BTCUSDT)"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Enable isolated margin account for a specific symbol.", + inputSchema: { + symbol: z.string().describe("Symbol to enable isolated margin for (e.g., BTCUSDT)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/isolated-margin-api/getBnbBurnStatus.ts b/src/tools/binance-margin/isolated-margin-api/getBnbBurnStatus.ts index ce195598..14302956 100644 --- a/src/tools/binance-margin/isolated-margin-api/getBnbBurnStatus.ts +++ b/src/tools/binance-margin/isolated-margin-api/getBnbBurnStatus.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceGetBnbBurnStatus(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetBnbBurnStatus", - "Get current BNB burn status for spot trading fees and margin interest.", { - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Get current BNB burn status for spot trading fees and margin interest.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAccount.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAccount.ts index ec440fa7..079921c5 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAccount.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAccount.ts @@ -6,15 +6,18 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginAccount(server: McpServer) { - server.tool( + server.registerTool( "BinanceIsolatedMarginAccount", - "Query isolated margin account info including balances, margin level, and liquidation price for all symbols or a specific symbol.", { - symbols: z - .string() - .optional() - .describe("Comma-separated symbol list (e.g., BTCUSDT,ETHUSDT), max 5 symbols"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Query isolated margin account info including balances, margin level, and liquidation price for all symbols or a specific symbol.", + inputSchema: { + symbols: z + .string() + .optional() + .describe("Comma-separated symbol list (e.g., BTCUSDT,ETHUSDT), max 5 symbols"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAccountLimit.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAccountLimit.ts index 1a3a5c62..d55ef173 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAccountLimit.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAccountLimit.ts @@ -6,11 +6,14 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginAccountLimit(server: McpServer) { - server.tool( + server.registerTool( "BinanceIsolatedMarginAccountLimit", - "Query the maximum number of isolated margin accounts allowed and currently enabled.", { - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Query the maximum number of isolated margin accounts allowed and currently enabled.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllOrders.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllOrders.ts index b7a185fc..968b11e0 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllOrders.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllOrders.ts @@ -6,16 +6,19 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginAllOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceIsolatedMarginAllOrders", - "Query all orders (open and filled/cancelled) in isolated margin account for a specific symbol.", { - symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), - orderId: z.number().int().optional().describe("Order ID to start from"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z.number().int().optional().describe("Number of results (default 500, max 500)"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Query all orders (open and filled/cancelled) in isolated margin account for a specific symbol.", + inputSchema: { + symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), + orderId: z.number().int().optional().describe("Order ID to start from"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z.number().int().optional().describe("Number of results (default 500, max 500)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllPairs.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllPairs.ts index e50f4152..c304ed8b 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllPairs.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllPairs.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginAllPairs(server: McpServer) { - server.tool( + server.registerTool( "BinanceIsolatedMarginAllPairs", - "Get all isolated margin trading pairs with their information.", { - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Get all isolated margin trading pairs with their information.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllSymbols.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllSymbols.ts index 93a6f84f..fb214eef 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllSymbols.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllSymbols.ts @@ -12,11 +12,13 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginAllSymbols(server: McpServer) { - server.tool( + server.registerTool( "BinanceIsolatedMarginAllSymbols", - "Query all isolated margin symbols available for trading.", { - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Query all isolated margin symbols available for trading.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginBorrow.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginBorrow.ts index 86279f39..ec6c9e2e 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginBorrow.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginBorrow.ts @@ -12,14 +12,16 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginBorrow(server: McpServer) { - server.tool( + server.registerTool( "BinanceIsolatedMarginBorrow", - "Borrow assets in isolated margin account for a specific symbol.", { - asset: z.string().describe("Asset to borrow (e.g., BTC, USDT)"), - symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), - amount: z.string().describe("Amount to borrow"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Borrow assets in isolated margin account for a specific symbol.", + inputSchema: { + asset: z.string().describe("Asset to borrow (e.g., BTC, USDT)"), + symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), + amount: z.string().describe("Amount to borrow"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginCancelOrder.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginCancelOrder.ts index f0d1fb41..cdc2a505 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginCancelOrder.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginCancelOrder.ts @@ -6,18 +6,21 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginCancelOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceIsolatedMarginCancelOrder", - "Cancel an active isolated margin order. Either orderId or origClientOrderId must be provided.", { - symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), - orderId: z.number().int().optional().describe("Order ID to cancel"), - origClientOrderId: z.string().optional().describe("Original client order ID to cancel"), - newClientOrderId: z - .string() - .optional() - .describe("New client order ID for the cancel request"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Cancel an active isolated margin order. Either orderId or origClientOrderId must be provided.", + inputSchema: { + symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), + orderId: z.number().int().optional().describe("Order ID to cancel"), + origClientOrderId: z.string().optional().describe("Original client order ID to cancel"), + newClientOrderId: z + .string() + .optional() + .describe("New client order ID for the cancel request"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginFee.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginFee.ts index 5ae0f011..c00cee49 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginFee.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginFee.ts @@ -6,17 +6,19 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginFee(server: McpServer) { - server.tool( + server.registerTool( "BinanceIsolatedMarginFee", - "Query isolated margin fee data including interest rates for borrowing.", { - symbol: z.string().optional().describe("Isolated margin symbol (e.g., BTCUSDT)"), - vipLevel: z - .number() - .int() - .optional() - .describe("VIP level (default uses current account VIP level)"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Query isolated margin fee data including interest rates for borrowing.", + inputSchema: { + symbol: z.string().optional().describe("Isolated margin symbol (e.g., BTCUSDT)"), + vipLevel: z + .number() + .int() + .optional() + .describe("VIP level (default uses current account VIP level)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginMyTrades.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginMyTrades.ts index 166b7d1a..479af567 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginMyTrades.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginMyTrades.ts @@ -6,17 +6,19 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginMyTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceIsolatedMarginMyTrades", - "Query trade history in isolated margin account for a specific symbol.", { - symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), - orderId: z.number().int().optional().describe("Filter by order ID"), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - fromId: z.number().int().optional().describe("Trade ID to start from"), - limit: z.number().int().optional().describe("Number of results (default 500, max 1000)"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Query trade history in isolated margin account for a specific symbol.", + inputSchema: { + symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), + orderId: z.number().int().optional().describe("Filter by order ID"), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + fromId: z.number().int().optional().describe("Trade ID to start from"), + limit: z.number().int().optional().describe("Number of results (default 500, max 1000)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginNewOrder.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginNewOrder.ts index 328f3008..42659f1c 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginNewOrder.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginNewOrder.ts @@ -6,44 +6,50 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginNewOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceIsolatedMarginNewOrder", - "Post a new order in isolated margin account. Supports various order types including LIMIT, MARKET, STOP_LOSS, etc.", { - symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Order side"), - type: z - .enum([ - "LIMIT", - "MARKET", - "STOP_LOSS", - "STOP_LOSS_LIMIT", - "TAKE_PROFIT", - "TAKE_PROFIT_LIMIT", - "LIMIT_MAKER", - ]) - .describe("Order type"), - quantity: z.string().optional().describe("Order quantity"), - quoteOrderQty: z.string().optional().describe("Quote order quantity for MARKET orders"), - price: z.string().optional().describe("Order price (required for LIMIT orders)"), - stopPrice: z.string().optional().describe("Stop price for STOP_LOSS and TAKE_PROFIT orders"), - newClientOrderId: z.string().optional().describe("Unique client order ID"), - icebergQty: z.string().optional().describe("Iceberg quantity"), - newOrderRespType: z.enum(["ACK", "RESULT", "FULL"]).optional().describe("Response type"), - sideEffectType: z - .enum(["NO_SIDE_EFFECT", "MARGIN_BUY", "AUTO_REPAY", "AUTO_BORROW_REPAY"]) - .optional() - .describe("Side effect type for margin orders"), - timeInForce: z.enum(["GTC", "IOC", "FOK"]).optional().describe("Time in force"), - selfTradePreventionMode: z - .enum(["EXPIRE_TAKER", "EXPIRE_MAKER", "EXPIRE_BOTH", "NONE"]) - .optional() - .describe("Self-trade prevention mode"), - autoRepayAtCancel: z - .boolean() - .optional() - .describe("Auto repay at cancel, only for AUTO_BORROW_REPAY"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Post a new order in isolated margin account. Supports various order types including LIMIT, MARKET, STOP_LOSS, etc.", + inputSchema: { + symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Order side"), + type: z + .enum([ + "LIMIT", + "MARKET", + "STOP_LOSS", + "STOP_LOSS_LIMIT", + "TAKE_PROFIT", + "TAKE_PROFIT_LIMIT", + "LIMIT_MAKER", + ]) + .describe("Order type"), + quantity: z.string().optional().describe("Order quantity"), + quoteOrderQty: z.string().optional().describe("Quote order quantity for MARKET orders"), + price: z.string().optional().describe("Order price (required for LIMIT orders)"), + stopPrice: z + .string() + .optional() + .describe("Stop price for STOP_LOSS and TAKE_PROFIT orders"), + newClientOrderId: z.string().optional().describe("Unique client order ID"), + icebergQty: z.string().optional().describe("Iceberg quantity"), + newOrderRespType: z.enum(["ACK", "RESULT", "FULL"]).optional().describe("Response type"), + sideEffectType: z + .enum(["NO_SIDE_EFFECT", "MARGIN_BUY", "AUTO_REPAY", "AUTO_BORROW_REPAY"]) + .optional() + .describe("Side effect type for margin orders"), + timeInForce: z.enum(["GTC", "IOC", "FOK"]).optional().describe("Time in force"), + selfTradePreventionMode: z + .enum(["EXPIRE_TAKER", "EXPIRE_MAKER", "EXPIRE_BOTH", "NONE"]) + .optional() + .describe("Self-trade prevention mode"), + autoRepayAtCancel: z + .boolean() + .optional() + .describe("Auto repay at cancel, only for AUTO_BORROW_REPAY"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginOpenOrders.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginOpenOrders.ts index 4a02020f..ade3bdd1 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginOpenOrders.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginOpenOrders.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginOpenOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceIsolatedMarginOpenOrders", - "Query all open orders in isolated margin account for a specific symbol.", { - symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Query all open orders in isolated margin account for a specific symbol.", + inputSchema: { + symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginPair.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginPair.ts index d4dca427..d0a3a66f 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginPair.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginPair.ts @@ -6,12 +6,15 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginPair(server: McpServer) { - server.tool( + server.registerTool( "BinanceIsolatedMarginPair", - "Query isolated margin symbol info including margin ratio, base/quote assets, and status.", { - symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Query isolated margin symbol info including margin ratio, base/quote assets, and status.", + inputSchema: { + symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginRepay.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginRepay.ts index fb8ae43b..3cee5e14 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginRepay.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginRepay.ts @@ -12,14 +12,16 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginRepay(server: McpServer) { - server.tool( + server.registerTool( "BinanceIsolatedMarginRepay", - "Repay borrowed assets in isolated margin account.", { - asset: z.string().describe("Asset to repay (e.g., BTC, USDT)"), - symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), - amount: z.string().describe("Amount to repay"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Repay borrowed assets in isolated margin account.", + inputSchema: { + asset: z.string().describe("Asset to repay (e.g., BTC, USDT)"), + symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), + amount: z.string().describe("Amount to repay"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginSymbol.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginSymbol.ts index 72c73561..8c60a1cd 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginSymbol.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginSymbol.ts @@ -12,12 +12,14 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginSymbol(server: McpServer) { - server.tool( + server.registerTool( "BinanceIsolatedMarginSymbol", - "Query isolated margin symbol information for a specific trading pair.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Query isolated margin symbol information for a specific trading pair.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginTierData.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginTierData.ts index 3f0af2d2..e0cc31d6 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginTierData.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginTierData.ts @@ -6,13 +6,16 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginTierData(server: McpServer) { - server.tool( + server.registerTool( "BinanceIsolatedMarginTierData", - "Query isolated margin tier data showing leverage tiers and maintenance margin ratios for a symbol.", { - symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), - tier: z.number().int().optional().describe("Specific tier to query"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Query isolated margin tier data showing leverage tiers and maintenance margin ratios for a symbol.", + inputSchema: { + symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), + tier: z.number().int().optional().describe("Specific tier to query"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginTransfer.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginTransfer.ts index e692c931..242d488a 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginTransfer.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginTransfer.ts @@ -6,16 +6,19 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginTransfer(server: McpServer) { - server.tool( + server.registerTool( "BinanceIsolatedMarginTransfer", - "Transfer assets between spot wallet and isolated margin account for a specific symbol.", { - asset: z.string().describe("Asset to transfer (e.g., BTC, USDT)"), - symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), - amount: z.string().describe("Amount to transfer"), - transFrom: z.enum(["SPOT", "ISOLATED_MARGIN"]).describe("Transfer from account type"), - transTo: z.enum(["SPOT", "ISOLATED_MARGIN"]).describe("Transfer to account type"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Transfer assets between spot wallet and isolated margin account for a specific symbol.", + inputSchema: { + asset: z.string().describe("Asset to transfer (e.g., BTC, USDT)"), + symbol: z.string().describe("Isolated margin symbol (e.g., BTCUSDT)"), + amount: z.string().describe("Amount to transfer"), + transFrom: z.enum(["SPOT", "ISOLATED_MARGIN"]).describe("Transfer from account type"), + transTo: z.enum(["SPOT", "ISOLATED_MARGIN"]).describe("Transfer to account type"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginTransferHistory.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginTransferHistory.ts index efd07c6f..8087671a 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginTransferHistory.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginTransferHistory.ts @@ -12,20 +12,22 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceIsolatedMarginTransferHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceIsolatedMarginTransferHistory", - "Query isolated margin transfer history.", { - symbol: z.string().optional().describe("Isolated margin symbol"), - asset: z.string().optional().describe("Asset"), - transFrom: z.enum(["SPOT", "ISOLATED_MARGIN"]).optional().describe("Transfer from"), - transTo: z.enum(["SPOT", "ISOLATED_MARGIN"]).optional().describe("Transfer to"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - current: z.number().int().optional().describe("Current page, default 1"), - size: z.number().int().optional().describe("Page size, default 10, max 100"), - archived: z.boolean().optional().describe("Query archived data"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Query isolated margin transfer history.", + inputSchema: { + symbol: z.string().optional().describe("Isolated margin symbol"), + asset: z.string().optional().describe("Asset"), + transFrom: z.enum(["SPOT", "ISOLATED_MARGIN"]).optional().describe("Transfer from"), + transTo: z.enum(["SPOT", "ISOLATED_MARGIN"]).optional().describe("Transfer to"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + current: z.number().int().optional().describe("Current page, default 1"), + size: z.number().int().optional().describe("Page size, default 10, max 100"), + archived: z.boolean().optional().describe("Query archived data"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/isolated-margin-api/toggleBnbBurn.ts b/src/tools/binance-margin/isolated-margin-api/toggleBnbBurn.ts index e9950793..6bd698fc 100644 --- a/src/tools/binance-margin/isolated-margin-api/toggleBnbBurn.ts +++ b/src/tools/binance-margin/isolated-margin-api/toggleBnbBurn.ts @@ -6,19 +6,22 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceToggleBnbBurn(server: McpServer) { - server.tool( + server.registerTool( "BinanceToggleBnbBurn", - "Toggle BNB burn on spot trade and margin interest. When enabled, uses BNB to pay for trading fees and margin interest at a discount.", { - spotBNBBurn: z - .enum(["true", "false"]) - .optional() - .describe("Enable/disable BNB burn for spot trading fees"), - interestBNBBurn: z - .enum(["true", "false"]) - .optional() - .describe("Enable/disable BNB burn for margin interest"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Toggle BNB burn on spot trade and margin interest. When enabled, uses BNB to pay for trading fees and margin interest at a discount.", + inputSchema: { + spotBNBBurn: z + .enum(["true", "false"]) + .optional() + .describe("Enable/disable BNB burn for spot trading fees"), + interestBNBBurn: z + .enum(["true", "false"]) + .optional() + .describe("Enable/disable BNB burn for margin interest"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/margin-order-api/marginCancelOco.ts b/src/tools/binance-margin/margin-order-api/marginCancelOco.ts index 87368408..05ed4903 100644 --- a/src/tools/binance-margin/margin-order-api/marginCancelOco.ts +++ b/src/tools/binance-margin/margin-order-api/marginCancelOco.ts @@ -12,22 +12,25 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceMarginCancelOco(server: McpServer) { - server.tool( + server.registerTool( "BinanceMarginCancelOco", - "Cancel an entire OCO (One-Cancels-the-Other) order in Margin account. Both legs will be cancelled.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - orderListId: z.number().int().optional().describe("Order list ID"), - listClientOrderId: z.string().optional().describe("Client order list ID"), - newClientOrderId: z - .string() - .optional() - .describe("New client order ID for this cancel request"), - isIsolated: z - .enum(["TRUE", "FALSE"]) - .optional() - .describe("For isolated margin, default FALSE"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Cancel an entire OCO (One-Cancels-the-Other) order in Margin account. Both legs will be cancelled.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + orderListId: z.number().int().optional().describe("Order list ID"), + listClientOrderId: z.string().optional().describe("Client order list ID"), + newClientOrderId: z + .string() + .optional() + .describe("New client order ID for this cancel request"), + isIsolated: z + .enum(["TRUE", "FALSE"]) + .optional() + .describe("For isolated margin, default FALSE"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/margin-order-api/marginGetAllOco.ts b/src/tools/binance-margin/margin-order-api/marginGetAllOco.ts index 67d5c833..35eb1954 100644 --- a/src/tools/binance-margin/margin-order-api/marginGetAllOco.ts +++ b/src/tools/binance-margin/margin-order-api/marginGetAllOco.ts @@ -12,23 +12,26 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceMarginGetAllOco(server: McpServer) { - server.tool( + server.registerTool( "BinanceMarginGetAllOco", - "Query all OCO (One-Cancels-the-Other) orders in Margin account, both open and closed.", { - symbol: z - .string() - .optional() - .describe("Symbol of the trading pair (mandatory for isolated margin)"), - fromId: z.number().int().optional().describe("Order list ID to start from"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - limit: z.number().int().optional().describe("Number of results, default 500, max 1000"), - isIsolated: z - .enum(["TRUE", "FALSE"]) - .optional() - .describe("For isolated margin, default FALSE"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Query all OCO (One-Cancels-the-Other) orders in Margin account, both open and closed.", + inputSchema: { + symbol: z + .string() + .optional() + .describe("Symbol of the trading pair (mandatory for isolated margin)"), + fromId: z.number().int().optional().describe("Order list ID to start from"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + limit: z.number().int().optional().describe("Number of results, default 500, max 1000"), + isIsolated: z + .enum(["TRUE", "FALSE"]) + .optional() + .describe("For isolated margin, default FALSE"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/margin-order-api/marginGetOco.ts b/src/tools/binance-margin/margin-order-api/marginGetOco.ts index dc46d2e0..100cd2b8 100644 --- a/src/tools/binance-margin/margin-order-api/marginGetOco.ts +++ b/src/tools/binance-margin/margin-order-api/marginGetOco.ts @@ -12,21 +12,24 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceMarginGetOco(server: McpServer) { - server.tool( + server.registerTool( "BinanceMarginGetOco", - "Query a specific OCO (One-Cancels-the-Other) order in Margin account by orderListId or listClientOrderId.", { - symbol: z - .string() - .optional() - .describe("Symbol of the trading pair (mandatory for isolated margin)"), - orderListId: z.number().int().optional().describe("Order list ID"), - origClientOrderId: z.string().optional().describe("Original client order list ID"), - isIsolated: z - .enum(["TRUE", "FALSE"]) - .optional() - .describe("For isolated margin, default FALSE"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Query a specific OCO (One-Cancels-the-Other) order in Margin account by orderListId or listClientOrderId.", + inputSchema: { + symbol: z + .string() + .optional() + .describe("Symbol of the trading pair (mandatory for isolated margin)"), + orderListId: z.number().int().optional().describe("Order list ID"), + origClientOrderId: z.string().optional().describe("Original client order list ID"), + isIsolated: z + .enum(["TRUE", "FALSE"]) + .optional() + .describe("For isolated margin, default FALSE"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/margin-order-api/marginGetOpenOco.ts b/src/tools/binance-margin/margin-order-api/marginGetOpenOco.ts index cfa173d1..534e9d69 100644 --- a/src/tools/binance-margin/margin-order-api/marginGetOpenOco.ts +++ b/src/tools/binance-margin/margin-order-api/marginGetOpenOco.ts @@ -12,19 +12,21 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceMarginGetOpenOco(server: McpServer) { - server.tool( + server.registerTool( "BinanceMarginGetOpenOco", - "Query all open OCO (One-Cancels-the-Other) orders in Margin account.", { - symbol: z - .string() - .optional() - .describe("Symbol of the trading pair (mandatory for isolated margin)"), - isIsolated: z - .enum(["TRUE", "FALSE"]) - .optional() - .describe("For isolated margin, default FALSE"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: "Query all open OCO (One-Cancels-the-Other) orders in Margin account.", + inputSchema: { + symbol: z + .string() + .optional() + .describe("Symbol of the trading pair (mandatory for isolated margin)"), + isIsolated: z + .enum(["TRUE", "FALSE"]) + .optional() + .describe("For isolated margin, default FALSE"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-margin/margin-order-api/marginNewOco.ts b/src/tools/binance-margin/margin-order-api/marginNewOco.ts index f6cd3795..f0e381d2 100644 --- a/src/tools/binance-margin/margin-order-api/marginNewOco.ts +++ b/src/tools/binance-margin/margin-order-api/marginNewOco.ts @@ -12,43 +12,46 @@ import { z } from "zod"; import { marginClient } from "../../../config/binanceClient.js"; export function registerBinanceMarginNewOco(server: McpServer) { - server.tool( + server.registerTool( "BinanceMarginNewOco", - "Place a new OCO (One-Cancels-the-Other) order in Margin account. Creates both a stop-loss and take-profit order simultaneously. ⚠️ WARNING: OCO orders involve leverage and carry liquidation risk.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Order side"), - quantity: z.number().describe("Order quantity"), - price: z.number().describe("Limit order price"), - stopPrice: z.number().describe("Stop loss trigger price"), - stopLimitPrice: z - .number() - .optional() - .describe("Stop limit order price (if stop limit order)"), - stopLimitTimeInForce: z - .enum(["GTC", "FOK", "IOC"]) - .optional() - .describe("Time in force for stop limit leg"), - listClientOrderId: z.string().optional().describe("Unique ID for the order list"), - limitClientOrderId: z.string().optional().describe("Unique ID for the limit order"), - stopClientOrderId: z.string().optional().describe("Unique ID for the stop order"), - limitIcebergQty: z.number().optional().describe("Iceberg quantity for limit leg"), - stopIcebergQty: z.number().optional().describe("Iceberg quantity for stop leg"), - newOrderRespType: z.enum(["ACK", "RESULT", "FULL"]).optional().describe("Response type"), - sideEffectType: z - .enum(["NO_SIDE_EFFECT", "MARGIN_BUY", "AUTO_REPAY", "AUTO_BORROW_REPAY"]) - .optional() - .describe("Side effect type for margin orders"), - isIsolated: z - .enum(["TRUE", "FALSE"]) - .optional() - .describe("For isolated margin, default FALSE"), - selfTradePreventionMode: z - .enum(["EXPIRE_TAKER", "EXPIRE_MAKER", "EXPIRE_BOTH", "NONE"]) - .optional() - .describe("Self-trade prevention mode"), - autoRepayAtCancel: z.boolean().optional().describe("Auto repay when order is canceled"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Place a new OCO (One-Cancels-the-Other) order in Margin account. Creates both a stop-loss and take-profit order simultaneously. ⚠️ WARNING: OCO orders involve leverage and carry liquidation risk.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Order side"), + quantity: z.number().describe("Order quantity"), + price: z.number().describe("Limit order price"), + stopPrice: z.number().describe("Stop loss trigger price"), + stopLimitPrice: z + .number() + .optional() + .describe("Stop limit order price (if stop limit order)"), + stopLimitTimeInForce: z + .enum(["GTC", "FOK", "IOC"]) + .optional() + .describe("Time in force for stop limit leg"), + listClientOrderId: z.string().optional().describe("Unique ID for the order list"), + limitClientOrderId: z.string().optional().describe("Unique ID for the limit order"), + stopClientOrderId: z.string().optional().describe("Unique ID for the stop order"), + limitIcebergQty: z.number().optional().describe("Iceberg quantity for limit leg"), + stopIcebergQty: z.number().optional().describe("Iceberg quantity for stop leg"), + newOrderRespType: z.enum(["ACK", "RESULT", "FULL"]).optional().describe("Response type"), + sideEffectType: z + .enum(["NO_SIDE_EFFECT", "MARGIN_BUY", "AUTO_REPAY", "AUTO_BORROW_REPAY"]) + .optional() + .describe("Side effect type for margin orders"), + isIsolated: z + .enum(["TRUE", "FALSE"]) + .optional() + .describe("For isolated margin, default FALSE"), + selfTradePreventionMode: z + .enum(["EXPIRE_TAKER", "EXPIRE_MAKER", "EXPIRE_BOTH", "NONE"]) + .optional() + .describe("Self-trade prevention mode"), + autoRepayAtCancel: z.boolean().optional().describe("Auto repay when order is canceled"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-mining/mining-api/accountList.ts b/src/tools/binance-mining/mining-api/accountList.ts index 5d43881a..cff3381d 100644 --- a/src/tools/binance-mining/mining-api/accountList.ts +++ b/src/tools/binance-mining/mining-api/accountList.ts @@ -6,13 +6,20 @@ import { z } from "zod"; import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceAccountList(server: McpServer) { - server.tool( + server.registerTool( "BinanceAccountList", - "Retrieve hashrate statistics for a mining account. It returns both hourly (H_hashrate) and daily (D_hashrate) data, including timestamps, hashrate values, and rejection rates.", { - algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), - userName: z.string().min(1).describe("Mining account"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Retrieve hashrate statistics for a mining account. It returns both hourly (H_hashrate) and daily (D_hashrate) data, including timestamps, hashrate values, and rejection rates.", + inputSchema: { + algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), + userName: z.string().min(1).describe("Mining account"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-mining/mining-api/acquiringAlgorithm.ts b/src/tools/binance-mining/mining-api/acquiringAlgorithm.ts index c02d7f3a..df7ed419 100644 --- a/src/tools/binance-mining/mining-api/acquiringAlgorithm.ts +++ b/src/tools/binance-mining/mining-api/acquiringAlgorithm.ts @@ -4,10 +4,12 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceAcquiringAlgorithm(server: McpServer) { - server.tool( + server.registerTool( "BinanceAcquiringAlgorithm", - "Retrieve a list of available mining algorithms, including their name, ID, sequence, and unit.", - {}, + { + description: + "Retrieve a list of available mining algorithms, including their name, ID, sequence, and unit.", + }, async () => { try { const response = await miningClient.restAPI.acquiringAlgorithm(); diff --git a/src/tools/binance-mining/mining-api/acquiringCoinname.ts b/src/tools/binance-mining/mining-api/acquiringCoinname.ts index f5ff7b69..852f5276 100644 --- a/src/tools/binance-mining/mining-api/acquiringCoinname.ts +++ b/src/tools/binance-mining/mining-api/acquiringCoinname.ts @@ -4,10 +4,12 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceAcquiringCoinName(server: McpServer) { - server.tool( + server.registerTool( "BinanceAcquiringCoinName", - "Fetch supported mining coins with details like coin name, ID, algorithm name, and associated algorithm ID.", - {}, + { + description: + "Fetch supported mining coins with details like coin name, ID, algorithm name, and associated algorithm ID.", + }, async () => { try { const response = await miningClient.restAPI.acquiringCoinname(); diff --git a/src/tools/binance-mining/mining-api/cancelHashrateResaleConfiguration.ts b/src/tools/binance-mining/mining-api/cancelHashrateResaleConfiguration.ts index 7ec167a4..0db4a335 100644 --- a/src/tools/binance-mining/mining-api/cancelHashrateResaleConfiguration.ts +++ b/src/tools/binance-mining/mining-api/cancelHashrateResaleConfiguration.ts @@ -6,13 +6,16 @@ import { z } from "zod"; import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceCancelHashRateResaleConfiguration(server: McpServer) { - server.tool( + server.registerTool( "BinanceCancelHashRateResaleConfiguration", - "Cancel an existing hashrate resale configuration using the mining ID and account details.", { - configId: z.number().int().describe("Mining ID").min(1), - userName: z.string().min(1).describe("Mining Account"), - recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + description: + "Cancel an existing hashrate resale configuration using the mining ID and account details.", + inputSchema: { + configId: z.number().int().describe("Mining ID").min(1), + userName: z.string().min(1).describe("Mining Account"), + recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + }, }, async (params) => { try { diff --git a/src/tools/binance-mining/mining-api/earningsList.ts b/src/tools/binance-mining/mining-api/earningsList.ts index 2e768d70..5067ff6c 100644 --- a/src/tools/binance-mining/mining-api/earningsList.ts +++ b/src/tools/binance-mining/mining-api/earningsList.ts @@ -6,32 +6,38 @@ import { z } from "zod"; import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceEarningsList(server: McpServer) { - server.tool( + server.registerTool( "BinanceEarningsList", - "Retrieves list of earnings related to mining activities, including transferred hashrate, daily hashrate, profit amount, and the status of the payment (unpaid, paying, or paid).", { - algo: z.string().min(1).describe("Transfer algorithm (e.g., sha256)"), - userName: z.string().min(1).describe("Mining account username"), - coin: z.string().optional().describe("Coin name (optional)"), - startDate: z - .number() - .optional() - .describe("Search start date (milliseconds timestamp, optional)"), - endDate: z.number().optional().describe("Search end date (milliseconds timestamp, optional)"), - pageIndex: z - .number() - .int() - .min(1) - .optional() - .describe("Page number, default is the first page starting from 1"), - pageSize: z - .number() - .int() - .min(10) - .max(200) - .optional() - .describe("Number of pages, minimum 10, maximum 200"), - recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + description: + "Retrieves list of earnings related to mining activities, including transferred hashrate, daily hashrate, profit amount, and the status of the payment (unpaid, paying, or paid).", + inputSchema: { + algo: z.string().min(1).describe("Transfer algorithm (e.g., sha256)"), + userName: z.string().min(1).describe("Mining account username"), + coin: z.string().optional().describe("Coin name (optional)"), + startDate: z + .number() + .optional() + .describe("Search start date (milliseconds timestamp, optional)"), + endDate: z + .number() + .optional() + .describe("Search end date (milliseconds timestamp, optional)"), + pageIndex: z + .number() + .int() + .min(1) + .optional() + .describe("Page number, default is the first page starting from 1"), + pageSize: z + .number() + .int() + .min(10) + .max(200) + .optional() + .describe("Number of pages, minimum 10, maximum 200"), + recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + }, }, async (params) => { try { diff --git a/src/tools/binance-mining/mining-api/extraBonusList.ts b/src/tools/binance-mining/mining-api/extraBonusList.ts index a8a2c38c..fa6c330d 100644 --- a/src/tools/binance-mining/mining-api/extraBonusList.ts +++ b/src/tools/binance-mining/mining-api/extraBonusList.ts @@ -6,27 +6,33 @@ import { z } from "zod"; import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceExtraBonusList(server: McpServer) { - server.tool( + server.registerTool( "BinanceExtraBonusList", - "Retrieves extra bonuses related to mining activities, including merged mining, activity bonuses, rebates, smart pool bonuses, income transfers, and pool savings.", { - algo: z.string().min(1).describe("Transfer algorithm (e.g., sha256)"), - userName: z.string().min(1).describe("Mining account username"), - coin: z.string().optional().describe("Coin name (optional)"), - startDate: z - .number() - .optional() - .describe("Search start date (milliseconds timestamp, optional)"), - endDate: z.number().optional().describe("Search end date (milliseconds timestamp, optional)"), - pageIndex: z.number().int().min(1).optional().describe("Page number, default is 1"), - pageSize: z - .number() - .int() - .min(10) - .max(200) - .optional() - .describe("Number of pages, minimum 10, maximum 200"), - recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + description: + "Retrieves extra bonuses related to mining activities, including merged mining, activity bonuses, rebates, smart pool bonuses, income transfers, and pool savings.", + inputSchema: { + algo: z.string().min(1).describe("Transfer algorithm (e.g., sha256)"), + userName: z.string().min(1).describe("Mining account username"), + coin: z.string().optional().describe("Coin name (optional)"), + startDate: z + .number() + .optional() + .describe("Search start date (milliseconds timestamp, optional)"), + endDate: z + .number() + .optional() + .describe("Search end date (milliseconds timestamp, optional)"), + pageIndex: z.number().int().min(1).optional().describe("Page number, default is 1"), + pageSize: z + .number() + .int() + .min(10) + .max(200) + .optional() + .describe("Number of pages, minimum 10, maximum 200"), + recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + }, }, async (params) => { try { diff --git a/src/tools/binance-mining/mining-api/hashrateResaleDetail.ts b/src/tools/binance-mining/mining-api/hashrateResaleDetail.ts index b5b37a68..481f2138 100644 --- a/src/tools/binance-mining/mining-api/hashrateResaleDetail.ts +++ b/src/tools/binance-mining/mining-api/hashrateResaleDetail.ts @@ -6,26 +6,29 @@ import { z } from "zod"; import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceHashRateResaleDetail(server: McpServer) { - server.tool( + server.registerTool( "BinanceHashRateResaleDetail", - "Retrieves details of hashrate resale transactions, including the transferring and receiving subaccounts, algorithm, hash rate, transfer date, and associated income.", { - configId: z.number().int().min(1).describe("Mining ID"), - userName: z.string().min(1).describe("Mining Account"), - pageIndex: z - .number() - .int() - .min(1) - .optional() - .describe("Page number, default is the first page starting from 1"), - pageSize: z - .number() - .int() - .min(10) - .max(200) - .optional() - .describe("Number of pages, minimum 10, maximum 200"), - recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + description: + "Retrieves details of hashrate resale transactions, including the transferring and receiving subaccounts, algorithm, hash rate, transfer date, and associated income.", + inputSchema: { + configId: z.number().int().min(1).describe("Mining ID"), + userName: z.string().min(1).describe("Mining Account"), + pageIndex: z + .number() + .int() + .min(1) + .optional() + .describe("Page number, default is the first page starting from 1"), + pageSize: z + .number() + .int() + .min(10) + .max(200) + .optional() + .describe("Number of pages, minimum 10, maximum 200"), + recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + }, }, async (params) => { try { diff --git a/src/tools/binance-mining/mining-api/hashrateResaleList.ts b/src/tools/binance-mining/mining-api/hashrateResaleList.ts index 7c91d0bc..328fd0de 100644 --- a/src/tools/binance-mining/mining-api/hashrateResaleList.ts +++ b/src/tools/binance-mining/mining-api/hashrateResaleList.ts @@ -6,24 +6,31 @@ import { z } from "zod"; import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceHashRateResaleList(server: McpServer) { - server.tool( + server.registerTool( "BinanceHashRateResaleList", - "Returns the list of hashRate resale configurations including transfer details such as algorithm, hashrate amount, sender and receiver pool usernames, start and end dates, and status of the transfer.", { - pageIndex: z - .number() - .int() - .min(1) - .optional() - .describe("Page number, default is the first page starting from 1"), - pageSize: z - .number() - .int() - .min(10) - .max(200) - .optional() - .describe("Number of records per page, min 10, max 200"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Returns the list of hashRate resale configurations including transfer details such as algorithm, hashrate amount, sender and receiver pool usernames, start and end dates, and status of the transfer.", + inputSchema: { + pageIndex: z + .number() + .int() + .min(1) + .optional() + .describe("Page number, default is the first page starting from 1"), + pageSize: z + .number() + .int() + .min(10) + .max(200) + .optional() + .describe("Number of records per page, min 10, max 200"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-mining/mining-api/hashrateResaleRequest.ts b/src/tools/binance-mining/mining-api/hashrateResaleRequest.ts index e8029938..6f81a5b4 100644 --- a/src/tools/binance-mining/mining-api/hashrateResaleRequest.ts +++ b/src/tools/binance-mining/mining-api/hashrateResaleRequest.ts @@ -6,24 +6,27 @@ import { z } from "zod"; import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceHashRateResaleRequest(server: McpServer) { - server.tool( + server.registerTool( "BinanceHashRateResaleRequest", - "Retrieve a request for setting up a hashrate resale, specifying the mining account, algorithm, start and end times, target mining account for resale, and the amount of hashrate to transfer", { - userName: z.string().min(1).describe("Mining Account"), - algo: z.string().min(1).describe("Transfer algorithm (e.g., sha256)"), - endDate: z.number().int().describe("Resale End Time (Millisecond timestamp)"), - startDate: z.number().int().describe("Resale Start Time (Millisecond timestamp)"), - toPoolUser: z.string().min(1).describe("Mining Account of the recipient pool user"), - hashRate: z - .number() - .int() - .describe("Resale hashrate h/s must be transferred (BTC > 500000000000, ETH > 500000)"), - recvWindow: z - .number() - .int() - .optional() - .describe("Optional: Time window for request validity"), + description: + "Retrieve a request for setting up a hashrate resale, specifying the mining account, algorithm, start and end times, target mining account for resale, and the amount of hashrate to transfer", + inputSchema: { + userName: z.string().min(1).describe("Mining Account"), + algo: z.string().min(1).describe("Transfer algorithm (e.g., sha256)"), + endDate: z.number().int().describe("Resale End Time (Millisecond timestamp)"), + startDate: z.number().int().describe("Resale Start Time (Millisecond timestamp)"), + toPoolUser: z.string().min(1).describe("Mining Account of the recipient pool user"), + hashRate: z + .number() + .int() + .describe("Resale hashrate h/s must be transferred (BTC > 500000000000, ETH > 500000)"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional: Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-mining/mining-api/miningAccountEarning.ts b/src/tools/binance-mining/mining-api/miningAccountEarning.ts index 5b1d4e86..0bd262c0 100644 --- a/src/tools/binance-mining/mining-api/miningAccountEarning.ts +++ b/src/tools/binance-mining/mining-api/miningAccountEarning.ts @@ -6,22 +6,25 @@ import { z } from "zod"; import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceMiningAccountEarning(server: McpServer) { - server.tool( + server.registerTool( "BinanceMiningAccountEarning", - "Retrieves the earnings associated with a mining account, including the type of earnings (e.g., rebate, referral, refund), sub-account ID, the mining account name, and the amount earned. It also supports pagination for large data sets.", { - algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), - startDate: z.number().int().optional().describe("Millisecond timestamp for the start date"), - endDate: z.number().int().optional().describe("Millisecond timestamp for the end date"), - pageIndex: z.number().int().min(1).optional().describe("Page number, default is 1"), - pageSize: z - .number() - .int() - .min(10) - .max(200) - .optional() - .describe("Number of records per page, min 10, max 200"), - recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + description: + "Retrieves the earnings associated with a mining account, including the type of earnings (e.g., rebate, referral, refund), sub-account ID, the mining account name, and the amount earned. It also supports pagination for large data sets.", + inputSchema: { + algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), + startDate: z.number().int().optional().describe("Millisecond timestamp for the start date"), + endDate: z.number().int().optional().describe("Millisecond timestamp for the end date"), + pageIndex: z.number().int().min(1).optional().describe("Page number, default is 1"), + pageSize: z + .number() + .int() + .min(10) + .max(200) + .optional() + .describe("Number of records per page, min 10, max 200"), + recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + }, }, async (params) => { try { diff --git a/src/tools/binance-mining/mining-api/requestForDetailMinerList.ts b/src/tools/binance-mining/mining-api/requestForDetailMinerList.ts index 5302c9aa..3e2fde8b 100644 --- a/src/tools/binance-mining/mining-api/requestForDetailMinerList.ts +++ b/src/tools/binance-mining/mining-api/requestForDetailMinerList.ts @@ -6,14 +6,17 @@ import { z } from "zod"; import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceRequestForDetailMinerList(server: McpServer) { - server.tool( + server.registerTool( "BinanceRequestForDetailMinerList", - "Retrieves detailed hashrate data for a specific miner, including both hourly (H_hashrate) and daily (D_hashrate) metrics such as time, hashrate, and rejection rate.", { - algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), - userName: z.string().min(1).describe("Mining account username"), - workerName: z.string().min(1).describe("Miner’s name (required), e.g., bhdc1.16A10404B"), - recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + description: + "Retrieves detailed hashrate data for a specific miner, including both hourly (H_hashrate) and daily (D_hashrate) metrics such as time, hashrate, and rejection rate.", + inputSchema: { + algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), + userName: z.string().min(1).describe("Mining account username"), + workerName: z.string().min(1).describe("Miner’s name (required), e.g., bhdc1.16A10404B"), + recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + }, }, async (params) => { try { diff --git a/src/tools/binance-mining/mining-api/requestForMinerList.ts b/src/tools/binance-mining/mining-api/requestForMinerList.ts index b344712a..8385bacb 100644 --- a/src/tools/binance-mining/mining-api/requestForMinerList.ts +++ b/src/tools/binance-mining/mining-api/requestForMinerList.ts @@ -6,42 +6,45 @@ import { z } from "zod"; import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceRequestForMinerList(server: McpServer) { - server.tool( + server.registerTool( "BinanceRequestForMinerList", - "Retrieves a list of miners (workers) associated with a mining account, including details such as miner name, status, real-time hashrate, 24H hashrate, rejection rate, and last submission time.", { - algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), - userName: z.string().min(1).describe("Mining account username"), - pageIndex: z - .number() - .int() - .min(1) - .optional() - .describe("Page number, default is first page, starting from 1"), - sort: z - .number() - .int() - .min(0) - .max(1) - .optional() - .describe("Sort sequence: 0 = ascending (default), 1 = descending"), - sortColumn: z - .number() - .int() - .min(1) - .max(5) - .optional() - .describe( - `Sort by (default = 1): 1: miner name, 2: real-time computing power, 3: daily average computing power, 4: real-time rejection rate, 5: last submission time`, - ), - workerStatus: z - .number() - .int() - .min(0) - .max(3) - .optional() - .describe("Miner status (default = 0): 0 = all, 1 = valid, 2 = invalid, 3 = failure"), - recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + description: + "Retrieves a list of miners (workers) associated with a mining account, including details such as miner name, status, real-time hashrate, 24H hashrate, rejection rate, and last submission time.", + inputSchema: { + algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), + userName: z.string().min(1).describe("Mining account username"), + pageIndex: z + .number() + .int() + .min(1) + .optional() + .describe("Page number, default is first page, starting from 1"), + sort: z + .number() + .int() + .min(0) + .max(1) + .optional() + .describe("Sort sequence: 0 = ascending (default), 1 = descending"), + sortColumn: z + .number() + .int() + .min(1) + .max(5) + .optional() + .describe( + `Sort by (default = 1): 1: miner name, 2: real-time computing power, 3: daily average computing power, 4: real-time rejection rate, 5: last submission time`, + ), + workerStatus: z + .number() + .int() + .min(0) + .max(3) + .optional() + .describe("Miner status (default = 0): 0 = all, 1 = valid, 2 = invalid, 3 = failure"), + recvWindow: z.number().int().optional().describe("Optional: cannot be greater than 60000"), + }, }, async (params) => { try { diff --git a/src/tools/binance-mining/mining-api/statisticList.ts b/src/tools/binance-mining/mining-api/statisticList.ts index 6957833f..187bbde7 100644 --- a/src/tools/binance-mining/mining-api/statisticList.ts +++ b/src/tools/binance-mining/mining-api/statisticList.ts @@ -6,17 +6,20 @@ import { z } from "zod"; import { miningClient } from "../../../config/binanceClient.js"; export function registerBinanceStatisticList(server: McpServer) { - server.tool( + server.registerTool( "BinanceStatisticList", - "Retrieve mining statistics for a specific account, including hash rates for the past 15 minutes and 24 hours, the number of valid and invalid mining units, and the estimated profit for today and yesterday in various cryptocurrencies.", { - algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), - userName: z.string().min(1).describe("Mining account username"), - recvWindow: z - .number() - .int() - .optional() - .describe("Optional: Time window for request validity"), + description: + "Retrieve mining statistics for a specific account, including hash rates for the past 15 minutes and 24 hours, the number of valid and invalid mining units, and the estimated profit for today and yesterday in various cryptocurrencies.", + inputSchema: { + algo: z.string().min(1).describe("Algorithm (e.g., sha256)"), + userName: z.string().min(1).describe("Mining account username"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional: Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-nft/nft-api/getNFTAsset.ts b/src/tools/binance-nft/nft-api/getNFTAsset.ts index 335bc2c3..028b6474 100644 --- a/src/tools/binance-nft/nft-api/getNFTAsset.ts +++ b/src/tools/binance-nft/nft-api/getNFTAsset.ts @@ -6,18 +6,25 @@ import { z } from "zod"; import { nftClient } from "../../../config/binanceClient.js"; export function registerBinanceGetNFTAsset(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetNFTAsset", - "Retrieve NFT assets associated with a user's account. It returns details about the network, contract address, and token IDs for each NFT asset.", { - limit: z - .number() - .int() - .max(50, "Limit cannot be greater than 50") - .default(50) - .describe("Number of records to return, default 50, max 50"), - page: z.number().int().default(1).describe("Page number, default is 1"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Retrieve NFT assets associated with a user's account. It returns details about the network, contract address, and token IDs for each NFT asset.", + inputSchema: { + limit: z + .number() + .int() + .max(50, "Limit cannot be greater than 50") + .default(50) + .describe("Number of records to return, default 50, max 50"), + page: z.number().int().default(1).describe("Page number, default is 1"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-nft/nft-api/getNFTDepositHistory.ts b/src/tools/binance-nft/nft-api/getNFTDepositHistory.ts index 57fec721..41a7ab5a 100644 --- a/src/tools/binance-nft/nft-api/getNFTDepositHistory.ts +++ b/src/tools/binance-nft/nft-api/getNFTDepositHistory.ts @@ -6,20 +6,27 @@ import { z } from "zod"; import { nftClient } from "../../../config/binanceClient.js"; export function registerBinanceGetNFTDepositHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetNFTDepositHistory", - "Retrieves NFT deposit history, including network, contract address, token ID, transaction ID (if available), and timestamps.", { - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .max(50, "Limit cannot be greater than 50") - .optional() - .describe("Number of records to return, default 50, max 50"), - page: z.number().int().optional().describe("Page number, default is 1"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Retrieves NFT deposit history, including network, contract address, token ID, transaction ID (if available), and timestamps.", + inputSchema: { + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(50, "Limit cannot be greater than 50") + .optional() + .describe("Number of records to return, default 50, max 50"), + page: z.number().int().optional().describe("Page number, default is 1"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-nft/nft-api/getNFTTransactionHistory.ts b/src/tools/binance-nft/nft-api/getNFTTransactionHistory.ts index 0320072f..ecbbc676 100644 --- a/src/tools/binance-nft/nft-api/getNFTTransactionHistory.ts +++ b/src/tools/binance-nft/nft-api/getNFTTransactionHistory.ts @@ -6,25 +6,32 @@ import { z } from "zod"; import { nftClient } from "../../../config/binanceClient.js"; export function registerBinanceGetNFTTransactionHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetNFTTransactionHistory", - "Retrieves NFT transaction history, including purchase orders, sale orders, royalty income, primary market orders, and mint fees. It returns details about the NFT network, token IDs, contract addresses, transaction times, trade amounts, and the currencies used in the transactions.", { - orderType: z - .number() - .describe( - "Order type: 0 for purchase order, 1 for sell order, 2 for royalty income, 3 for primary market order, 4 for mint fee", - ), - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .max(50, "Limit cannot be greater than 50") - .default(50) - .describe("Number of records to return, default 50, max 50"), - page: z.number().int().default(1).describe("Page number, default is 1"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Retrieves NFT transaction history, including purchase orders, sale orders, royalty income, primary market orders, and mint fees. It returns details about the NFT network, token IDs, contract addresses, transaction times, trade amounts, and the currencies used in the transactions.", + inputSchema: { + orderType: z + .number() + .describe( + "Order type: 0 for purchase order, 1 for sell order, 2 for royalty income, 3 for primary market order, 4 for mint fee", + ), + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(50, "Limit cannot be greater than 50") + .default(50) + .describe("Number of records to return, default 50, max 50"), + page: z.number().int().default(1).describe("Page number, default is 1"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-nft/nft-api/getNFTWithdrawHistory.ts b/src/tools/binance-nft/nft-api/getNFTWithdrawHistory.ts index b14b3cd9..924599a8 100644 --- a/src/tools/binance-nft/nft-api/getNFTWithdrawHistory.ts +++ b/src/tools/binance-nft/nft-api/getNFTWithdrawHistory.ts @@ -6,20 +6,27 @@ import { z } from "zod"; import { nftClient } from "../../../config/binanceClient.js"; export function registerBinanceGetNFTWithdrawHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetNFTWithdrawHistory", - "Retrieves NFT withdraw history, including network, transaction ID, contract address, token ID, withdrawal fee, fee asset, and timestamps.", { - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .max(50, "Limit cannot be greater than 50") - .default(50) - .describe("Number of records to return, default 50, max 50"), - page: z.number().int().default(1).describe("Page number, default is 1"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Retrieves NFT withdraw history, including network, transaction ID, contract address, token ID, withdrawal fee, fee asset, and timestamps.", + inputSchema: { + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(50, "Limit cannot be greater than 50") + .default(50) + .describe("Number of records to return, default 50, max 50"), + page: z.number().int().default(1).describe("Page number, default is 1"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-options/account.ts b/src/tools/binance-options/account.ts index 71786369..78297ad1 100644 --- a/src/tools/binance-options/account.ts +++ b/src/tools/binance-options/account.ts @@ -4,25 +4,29 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsAccount(server: McpServer) { - server.tool("BinanceOptionsAccount", "Get current options account information.", {}, async () => { - try { - const data = await optionsClient.account(); + server.registerTool( + "BinanceOptionsAccount", + { description: "Get current options account information." }, + async () => { + try { + const data = await optionsClient.account(); - return { - content: [ - { - type: "text", - text: `Options account information retrieved. Response: ${JSON.stringify(data)}`, - }, - ], - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); + return { + content: [ + { + type: "text", + text: `Options account information retrieved. Response: ${JSON.stringify(data)}`, + }, + ], + }; + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to get account info: ${errorMessage}` }], - isError: true, - }; - } - }); + return { + content: [{ type: "text", text: `Failed to get account info: ${errorMessage}` }], + isError: true, + }; + } + }, + ); } diff --git a/src/tools/binance-options/batchOrders.ts b/src/tools/binance-options/batchOrders.ts index 748e67e3..4455673f 100644 --- a/src/tools/binance-options/batchOrders.ts +++ b/src/tools/binance-options/batchOrders.ts @@ -6,15 +6,17 @@ import { z } from "zod"; import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsBatchOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsBatchOrders", - "Place multiple options orders in batch.", { - orders: z - .string() - .describe( - "JSON array of orders, each containing symbol, side, type, quantity, and optionally price, timeInForce, reduceOnly, postOnly, clientOrderId", - ), + description: "Place multiple options orders in batch.", + inputSchema: { + orders: z + .string() + .describe( + "JSON array of orders, each containing symbol, side, type, quantity, and optionally price, timeInForce, reduceOnly, postOnly, clientOrderId", + ), + }, }, async ({ orders }) => { try { diff --git a/src/tools/binance-options/bill.ts b/src/tools/binance-options/bill.ts index 47fd6417..2df98868 100644 --- a/src/tools/binance-options/bill.ts +++ b/src/tools/binance-options/bill.ts @@ -6,15 +6,20 @@ import { z } from "zod"; import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsBill(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsBill", - "Get options account funding flow (bill history).", { - currency: z.string().optional().describe("Currency (e.g., USDT)"), - recordId: z.number().optional().describe("Record ID to fetch from"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Number of records to return. Default 100; max 1000."), + description: "Get options account funding flow (bill history).", + inputSchema: { + currency: z.string().optional().describe("Currency (e.g., USDT)"), + recordId: z.number().optional().describe("Record ID to fetch from"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z + .number() + .optional() + .describe("Number of records to return. Default 100; max 1000."), + }, }, async ({ currency, recordId, startTime, endTime, limit }) => { try { diff --git a/src/tools/binance-options/cancelAllOrders.ts b/src/tools/binance-options/cancelAllOrders.ts index 8ea9617b..2326b036 100644 --- a/src/tools/binance-options/cancelAllOrders.ts +++ b/src/tools/binance-options/cancelAllOrders.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsCancelAllOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsCancelAllOrders", - "Cancel all open options orders for a symbol.", { - symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + description: "Cancel all open options orders for a symbol.", + inputSchema: { + symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + }, }, async ({ symbol }) => { try { diff --git a/src/tools/binance-options/cancelBatchOrders.ts b/src/tools/binance-options/cancelBatchOrders.ts index 187a47ed..16a27b91 100644 --- a/src/tools/binance-options/cancelBatchOrders.ts +++ b/src/tools/binance-options/cancelBatchOrders.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsCancelBatchOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsCancelBatchOrders", - "Cancel multiple options orders in batch.", { - symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), - orderIds: z.string().optional().describe("Comma-separated list of order IDs to cancel"), - clientOrderIds: z - .string() - .optional() - .describe("Comma-separated list of client order IDs to cancel"), + description: "Cancel multiple options orders in batch.", + inputSchema: { + symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + orderIds: z.string().optional().describe("Comma-separated list of order IDs to cancel"), + clientOrderIds: z + .string() + .optional() + .describe("Comma-separated list of client order IDs to cancel"), + }, }, async ({ symbol, orderIds, clientOrderIds }) => { try { diff --git a/src/tools/binance-options/cancelOrder.ts b/src/tools/binance-options/cancelOrder.ts index 8cddd46d..d80e4035 100644 --- a/src/tools/binance-options/cancelOrder.ts +++ b/src/tools/binance-options/cancelOrder.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsCancelOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsCancelOrder", - "Cancel an existing options order.", { - symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), - orderId: z.number().optional().describe("Order ID"), - clientOrderId: z.string().optional().describe("Client order ID"), + description: "Cancel an existing options order.", + inputSchema: { + symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + orderId: z.number().optional().describe("Order ID"), + clientOrderId: z.string().optional().describe("Client order ID"), + }, }, async ({ symbol, orderId, clientOrderId }) => { try { diff --git a/src/tools/binance-options/depth.ts b/src/tools/binance-options/depth.ts index 2bc7a310..9c43f888 100644 --- a/src/tools/binance-options/depth.ts +++ b/src/tools/binance-options/depth.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsDepth(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsDepth", - "Get order book depth for an option symbol.", { - symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), - limit: z.number().optional().describe("Depth limit. Default 100; max 1000."), + description: "Get order book depth for an option symbol.", + inputSchema: { + symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + limit: z.number().optional().describe("Depth limit. Default 100; max 1000."), + }, }, async ({ symbol, limit }) => { try { diff --git a/src/tools/binance-options/exchangeInfo.ts b/src/tools/binance-options/exchangeInfo.ts index 0d4bc262..35547041 100644 --- a/src/tools/binance-options/exchangeInfo.ts +++ b/src/tools/binance-options/exchangeInfo.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsExchangeInfo(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsExchangeInfo", - "Get current exchange trading rules and symbol information for options.", { - symbol: z.string().optional().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + description: "Get current exchange trading rules and symbol information for options.", + inputSchema: { + symbol: z.string().optional().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + }, }, async ({ symbol }) => { try { diff --git a/src/tools/binance-options/exerciseHistory.ts b/src/tools/binance-options/exerciseHistory.ts index 1b59edc5..ff1ae4e3 100644 --- a/src/tools/binance-options/exerciseHistory.ts +++ b/src/tools/binance-options/exerciseHistory.ts @@ -6,14 +6,16 @@ import { z } from "zod"; import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsExerciseHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsExerciseHistory", - "Get historical exercise records for options.", { - underlying: z.string().optional().describe("Underlying asset (e.g., BTCUSDT)"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Number of records to return. Default 100; max 100."), + description: "Get historical exercise records for options.", + inputSchema: { + underlying: z.string().optional().describe("Underlying asset (e.g., BTCUSDT)"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Number of records to return. Default 100; max 100."), + }, }, async ({ underlying, startTime, endTime, limit }) => { try { diff --git a/src/tools/binance-options/exerciseRecord.ts b/src/tools/binance-options/exerciseRecord.ts index f8edc4d8..31daa0e5 100644 --- a/src/tools/binance-options/exerciseRecord.ts +++ b/src/tools/binance-options/exerciseRecord.ts @@ -6,14 +6,19 @@ import { z } from "zod"; import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsExerciseRecord(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsExerciseRecord", - "Get user's options exercise records.", { - symbol: z.string().optional().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Number of records to return. Default 100; max 1000."), + description: "Get user's options exercise records.", + inputSchema: { + symbol: z.string().optional().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z + .number() + .optional() + .describe("Number of records to return. Default 100; max 1000."), + }, }, async ({ symbol, startTime, endTime, limit }) => { try { diff --git a/src/tools/binance-options/getOrder.ts b/src/tools/binance-options/getOrder.ts index 80dbdcd0..2b187b4e 100644 --- a/src/tools/binance-options/getOrder.ts +++ b/src/tools/binance-options/getOrder.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsGetOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsGetOrder", - "Query an options order by order ID or client order ID.", { - symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), - orderId: z.number().optional().describe("Order ID"), - clientOrderId: z.string().optional().describe("Client order ID"), + description: "Query an options order by order ID or client order ID.", + inputSchema: { + symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + orderId: z.number().optional().describe("Order ID"), + clientOrderId: z.string().optional().describe("Client order ID"), + }, }, async ({ symbol, orderId, clientOrderId }) => { try { diff --git a/src/tools/binance-options/historicalTrades.ts b/src/tools/binance-options/historicalTrades.ts index 78b2fe14..d924a543 100644 --- a/src/tools/binance-options/historicalTrades.ts +++ b/src/tools/binance-options/historicalTrades.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsHistoricalTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsHistoricalTrades", - "Get historical trades for an option symbol.", { - symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), - fromId: z.number().optional().describe("Trade ID to fetch from"), - limit: z.number().optional().describe("Number of trades to return. Default 100; max 500."), + description: "Get historical trades for an option symbol.", + inputSchema: { + symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + fromId: z.number().optional().describe("Trade ID to fetch from"), + limit: z.number().optional().describe("Number of trades to return. Default 100; max 500."), + }, }, async ({ symbol, fromId, limit }) => { try { diff --git a/src/tools/binance-options/historyOrders.ts b/src/tools/binance-options/historyOrders.ts index 37fff98b..1e8b5f28 100644 --- a/src/tools/binance-options/historyOrders.ts +++ b/src/tools/binance-options/historyOrders.ts @@ -6,15 +6,17 @@ import { z } from "zod"; import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsHistoryOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsHistoryOrders", - "Get historical options orders.", { - symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), - orderId: z.number().optional().describe("Order ID to fetch from"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Number of orders to return. Default 100; max 1000."), + description: "Get historical options orders.", + inputSchema: { + symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + orderId: z.number().optional().describe("Order ID to fetch from"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Number of orders to return. Default 100; max 1000."), + }, }, async ({ symbol, orderId, startTime, endTime, limit }) => { try { diff --git a/src/tools/binance-options/indexPrice.ts b/src/tools/binance-options/indexPrice.ts index 56c0f18e..f760ec08 100644 --- a/src/tools/binance-options/indexPrice.ts +++ b/src/tools/binance-options/indexPrice.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsIndexPrice(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsIndexPrice", - "Get the underlying index price for options.", { - underlying: z.string().describe("Underlying asset (e.g., BTCUSDT)"), + description: "Get the underlying index price for options.", + inputSchema: { + underlying: z.string().describe("Underlying asset (e.g., BTCUSDT)"), + }, }, async ({ underlying }) => { try { diff --git a/src/tools/binance-options/klines.ts b/src/tools/binance-options/klines.ts index 2aba9cee..d0026117 100644 --- a/src/tools/binance-options/klines.ts +++ b/src/tools/binance-options/klines.ts @@ -6,17 +6,19 @@ import { z } from "zod"; import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsKlines(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsKlines", - "Get kline/candlestick data for an option symbol.", { - symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), - interval: z - .enum(["1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d", "3d", "1w"]) - .describe("Kline interval"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Number of klines to return. Default 500; max 1500."), + description: "Get kline/candlestick data for an option symbol.", + inputSchema: { + symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + interval: z + .enum(["1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d", "3d", "1w"]) + .describe("Kline interval"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Number of klines to return. Default 500; max 1500."), + }, }, async ({ symbol, interval, startTime, endTime, limit }) => { try { diff --git a/src/tools/binance-options/listenKey.ts b/src/tools/binance-options/listenKey.ts index 2c56bf30..2153ebe2 100644 --- a/src/tools/binance-options/listenKey.ts +++ b/src/tools/binance-options/listenKey.ts @@ -6,10 +6,9 @@ import { z } from "zod"; import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsCreateListenKey(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsCreateListenKey", - "Create a new listen key for options user data stream.", - {}, + { description: "Create a new listen key for options user data stream." }, async () => { try { const data = await optionsClient.createListenKey(); @@ -35,11 +34,13 @@ export function registerBinanceOptionsCreateListenKey(server: McpServer) { } export function registerBinanceOptionsKeepAliveListenKey(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsKeepAliveListenKey", - "Keep alive an existing listen key for options user data stream.", { - listenKey: z.string().describe("The listen key to keep alive"), + description: "Keep alive an existing listen key for options user data stream.", + inputSchema: { + listenKey: z.string().describe("The listen key to keep alive"), + }, }, async ({ listenKey: _listenKey }) => { try { @@ -66,11 +67,13 @@ export function registerBinanceOptionsKeepAliveListenKey(server: McpServer) { } export function registerBinanceOptionsDeleteListenKey(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsDeleteListenKey", - "Delete an existing listen key for options user data stream.", { - listenKey: z.string().describe("The listen key to delete"), + description: "Delete an existing listen key for options user data stream.", + inputSchema: { + listenKey: z.string().describe("The listen key to delete"), + }, }, async ({ listenKey: _listenKey }) => { try { diff --git a/src/tools/binance-options/mark.ts b/src/tools/binance-options/mark.ts index 370e673d..e3c654da 100644 --- a/src/tools/binance-options/mark.ts +++ b/src/tools/binance-options/mark.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsMark(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsMark", - "Get option mark price for a symbol or all symbols.", { - symbol: z.string().optional().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + description: "Get option mark price for a symbol or all symbols.", + inputSchema: { + symbol: z.string().optional().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + }, }, async ({ symbol }) => { try { diff --git a/src/tools/binance-options/newOrder.ts b/src/tools/binance-options/newOrder.ts index 56f41118..0499aa2b 100644 --- a/src/tools/binance-options/newOrder.ts +++ b/src/tools/binance-options/newOrder.ts @@ -6,20 +6,22 @@ import { z } from "zod"; import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsNewOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsNewOrder", - "Create a new options order.", { - symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), - side: z.enum(["BUY", "SELL"]).describe("Order side: BUY or SELL"), - type: z.enum(["LIMIT", "MARKET"]).describe("Order type"), - quantity: z.number().describe("Order quantity"), - price: z.number().optional().describe("Order price (required for LIMIT orders)"), - timeInForce: z.enum(["GTC", "IOC", "FOK"]).optional().describe("Time in force"), - reduceOnly: z.boolean().optional().describe("Reduce only flag"), - postOnly: z.boolean().optional().describe("Post only flag"), - newOrderRespType: z.enum(["ACK", "RESULT"]).optional().describe("Response type"), - clientOrderId: z.string().optional().describe("Client order ID"), + description: "Create a new options order.", + inputSchema: { + symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + side: z.enum(["BUY", "SELL"]).describe("Order side: BUY or SELL"), + type: z.enum(["LIMIT", "MARKET"]).describe("Order type"), + quantity: z.number().describe("Order quantity"), + price: z.number().optional().describe("Order price (required for LIMIT orders)"), + timeInForce: z.enum(["GTC", "IOC", "FOK"]).optional().describe("Time in force"), + reduceOnly: z.boolean().optional().describe("Reduce only flag"), + postOnly: z.boolean().optional().describe("Post only flag"), + newOrderRespType: z.enum(["ACK", "RESULT"]).optional().describe("Response type"), + clientOrderId: z.string().optional().describe("Client order ID"), + }, }, async ({ symbol, diff --git a/src/tools/binance-options/openInterest.ts b/src/tools/binance-options/openInterest.ts index e63d9560..f1307baf 100644 --- a/src/tools/binance-options/openInterest.ts +++ b/src/tools/binance-options/openInterest.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsOpenInterest(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsOpenInterest", - "Get open interest for an option symbol.", { - underlyingAsset: z.string().describe("Underlying asset (e.g., BTC)"), - expiration: z.string().describe("Expiration date (e.g., 240126)"), + description: "Get open interest for an option symbol.", + inputSchema: { + underlyingAsset: z.string().describe("Underlying asset (e.g., BTC)"), + expiration: z.string().describe("Expiration date (e.g., 240126)"), + }, }, async ({ underlyingAsset, expiration }) => { try { diff --git a/src/tools/binance-options/openOrders.ts b/src/tools/binance-options/openOrders.ts index ed489a0d..ff937238 100644 --- a/src/tools/binance-options/openOrders.ts +++ b/src/tools/binance-options/openOrders.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsOpenOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsOpenOrders", - "Get all open options orders.", { - symbol: z.string().optional().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + description: "Get all open options orders.", + inputSchema: { + symbol: z.string().optional().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + }, }, async ({ symbol }) => { try { diff --git a/src/tools/binance-options/ping.ts b/src/tools/binance-options/ping.ts index 435a4f9f..1182152a 100644 --- a/src/tools/binance-options/ping.ts +++ b/src/tools/binance-options/ping.ts @@ -4,10 +4,9 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsPing(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsPing", - "Test connectivity to the Binance Options API.", - {}, + { description: "Test connectivity to the Binance Options API." }, async () => { try { const data = await optionsClient.ping(); diff --git a/src/tools/binance-options/position.ts b/src/tools/binance-options/position.ts index d4b68995..d9824bc2 100644 --- a/src/tools/binance-options/position.ts +++ b/src/tools/binance-options/position.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsPosition(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsPosition", - "Get current options position information.", { - symbol: z.string().optional().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + description: "Get current options position information.", + inputSchema: { + symbol: z.string().optional().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + }, }, async ({ symbol }) => { try { diff --git a/src/tools/binance-options/ticker.ts b/src/tools/binance-options/ticker.ts index 29a2254a..fe016183 100644 --- a/src/tools/binance-options/ticker.ts +++ b/src/tools/binance-options/ticker.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsTicker(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsTicker", - "Get 24hr ticker price change statistics for an option symbol.", { - symbol: z.string().optional().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + description: "Get 24hr ticker price change statistics for an option symbol.", + inputSchema: { + symbol: z.string().optional().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + }, }, async ({ symbol }) => { try { diff --git a/src/tools/binance-options/time.ts b/src/tools/binance-options/time.ts index 5807400a..0211957b 100644 --- a/src/tools/binance-options/time.ts +++ b/src/tools/binance-options/time.ts @@ -4,10 +4,9 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsTime(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsTime", - "Get the current server time from Binance Options API.", - {}, + { description: "Get the current server time from Binance Options API." }, async () => { try { const data = await optionsClient.time(); diff --git a/src/tools/binance-options/trades.ts b/src/tools/binance-options/trades.ts index f2cdead4..fe4cde98 100644 --- a/src/tools/binance-options/trades.ts +++ b/src/tools/binance-options/trades.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsTrades", - "Get recent trades for an option symbol.", { - symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), - limit: z.number().optional().describe("Number of trades to return. Default 100; max 500."), + description: "Get recent trades for an option symbol.", + inputSchema: { + symbol: z.string().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + limit: z.number().optional().describe("Number of trades to return. Default 100; max 500."), + }, }, async ({ symbol, limit }) => { try { diff --git a/src/tools/binance-options/userTrades.ts b/src/tools/binance-options/userTrades.ts index 6f93f4f9..7906eb63 100644 --- a/src/tools/binance-options/userTrades.ts +++ b/src/tools/binance-options/userTrades.ts @@ -6,15 +6,17 @@ import { z } from "zod"; import { optionsClient } from "../../config/binanceClient.js"; export function registerBinanceOptionsUserTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceOptionsUserTrades", - "Get options account trade list.", { - symbol: z.string().optional().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), - fromId: z.number().optional().describe("Trade ID to fetch from"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Number of trades to return. Default 100; max 1000."), + description: "Get options account trade list.", + inputSchema: { + symbol: z.string().optional().describe("Option trading symbol (e.g., BTC-240126-42000-C)"), + fromId: z.number().optional().describe("Trade ID to fetch from"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Number of trades to return. Default 100; max 1000."), + }, }, async ({ symbol, fromId, startTime, endTime, limit }) => { try { diff --git a/src/tools/binance-pay/pay-api/getPayTradeHistory.ts b/src/tools/binance-pay/pay-api/getPayTradeHistory.ts index 479cd14d..ac62322d 100644 --- a/src/tools/binance-pay/pay-api/getPayTradeHistory.ts +++ b/src/tools/binance-pay/pay-api/getPayTradeHistory.ts @@ -6,19 +6,26 @@ import { z } from "zod"; import { payClient } from "../../../config/binanceClient.js"; export function registerBinanceGetPayTradeHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetPayTradeHistory", - "Retrieve Binance Pay trade history using GET to fetch transaction records such as C2C transfers, merchant payments, crypto box activity, refunds, payouts, and remittance details.", { - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - limit: z - .number() - .int() - .max(100, "Limit cannot be greater than 100") - .default(100) - .describe("Number of records to return, default 100, max 100"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Retrieve Binance Pay trade history using GET to fetch transaction records such as C2C transfers, merchant payments, crypto box activity, refunds, payouts, and remittance details.", + inputSchema: { + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + limit: z + .number() + .int() + .max(100, "Limit cannot be greater than 100") + .default(100) + .describe("Number of records to return, default 100, max 100"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-portfolio-margin/bnbTransfer.ts b/src/tools/binance-portfolio-margin/bnbTransfer.ts index f7c950d5..139f09ff 100644 --- a/src/tools/binance-portfolio-margin/bnbTransfer.ts +++ b/src/tools/binance-portfolio-margin/bnbTransfer.ts @@ -6,15 +6,17 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../config/binanceClient.js"; export function registerBinancePortfolioMarginBnbTransfer(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginBnbTransfer", - "Transfer BNB in/out of portfolio margin account.", { - amount: z.number().describe("Amount of BNB to transfer"), - transferSide: z - .enum(["TO_UM", "FROM_UM"]) - .describe("Transfer direction: TO_UM (to UM account) or FROM_UM (from UM account)"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Transfer BNB in/out of portfolio margin account.", + inputSchema: { + amount: z.number().describe("Amount of BNB to transfer"), + transferSide: z + .enum(["TO_UM", "FROM_UM"]) + .describe("Transfer direction: TO_UM (to UM account) or FROM_UM (from UM account)"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ amount, transferSide, recvWindow }) => { try { diff --git a/src/tools/binance-portfolio-margin/changeAutoRepayFutures.ts b/src/tools/binance-portfolio-margin/changeAutoRepayFutures.ts index cf462c5a..497bdb44 100644 --- a/src/tools/binance-portfolio-margin/changeAutoRepayFutures.ts +++ b/src/tools/binance-portfolio-margin/changeAutoRepayFutures.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../config/binanceClient.js"; export function registerBinancePortfolioMarginChangeAutoRepayFutures(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginChangeAutoRepayFutures", - "Change the auto-repay-futures status for portfolio margin account.", { - autoRepay: z.boolean().describe("Enable or disable auto-repay for futures"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Change the auto-repay-futures status for portfolio margin account.", + inputSchema: { + autoRepay: z.boolean().describe("Enable or disable auto-repay for futures"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ autoRepay, recvWindow }) => { try { diff --git a/src/tools/binance-portfolio-margin/fundAutoCollection.ts b/src/tools/binance-portfolio-margin/fundAutoCollection.ts index be602097..c9047523 100644 --- a/src/tools/binance-portfolio-margin/fundAutoCollection.ts +++ b/src/tools/binance-portfolio-margin/fundAutoCollection.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../config/binanceClient.js"; export function registerBinancePortfolioMarginFundAutoCollection(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginFundAutoCollection", - "Enable or configure fund auto-collection for portfolio margin account.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Enable or configure fund auto-collection for portfolio margin account.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/tools/binance-portfolio-margin/fundCollection.ts b/src/tools/binance-portfolio-margin/fundCollection.ts index a28cfd85..c4ee1039 100644 --- a/src/tools/binance-portfolio-margin/fundCollection.ts +++ b/src/tools/binance-portfolio-margin/fundCollection.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../config/binanceClient.js"; export function registerBinancePortfolioMarginFundCollection(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginFundCollection", - "Trigger fund collection by asset for portfolio margin account.", { - asset: z.string().describe("Asset symbol to collect (e.g., BTC, USDT)"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Trigger fund collection by asset for portfolio margin account.", + inputSchema: { + asset: z.string().describe("Asset symbol to collect (e.g., BTC, USDT)"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ asset, recvWindow }) => { try { diff --git a/src/tools/binance-portfolio-margin/getAccountBalance.ts b/src/tools/binance-portfolio-margin/getAccountBalance.ts index b29aa5b3..a192bc7c 100644 --- a/src/tools/binance-portfolio-margin/getAccountBalance.ts +++ b/src/tools/binance-portfolio-margin/getAccountBalance.ts @@ -6,15 +6,17 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../config/binanceClient.js"; export function registerBinancePortfolioMarginGetAccountBalance(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginGetAccountBalance", - "Query portfolio margin account balance.", { - asset: z - .string() - .optional() - .describe("Asset symbol (e.g., BTC, USDT). If not provided, returns all assets"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Query portfolio margin account balance.", + inputSchema: { + asset: z + .string() + .optional() + .describe("Asset symbol (e.g., BTC, USDT). If not provided, returns all assets"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ asset, recvWindow }) => { try { diff --git a/src/tools/binance-portfolio-margin/getAutoRepayFuturesStatus.ts b/src/tools/binance-portfolio-margin/getAutoRepayFuturesStatus.ts index 850c3022..f14c372e 100644 --- a/src/tools/binance-portfolio-margin/getAutoRepayFuturesStatus.ts +++ b/src/tools/binance-portfolio-margin/getAutoRepayFuturesStatus.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../config/binanceClient.js"; export function registerBinancePortfolioMarginGetAutoRepayFuturesStatus(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginGetAutoRepayFuturesStatus", - "Get the current auto-repay-futures status for portfolio margin account.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get the current auto-repay-futures status for portfolio margin account.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/tools/binance-portfolio-margin/getCollateralRate.ts b/src/tools/binance-portfolio-margin/getCollateralRate.ts index fcb77511..021c6c5a 100644 --- a/src/tools/binance-portfolio-margin/getCollateralRate.ts +++ b/src/tools/binance-portfolio-margin/getCollateralRate.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../config/binanceClient.js"; export function registerBinancePortfolioMarginGetCollateralRate(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginGetCollateralRate", - "Query portfolio margin collateral rate for assets.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Query portfolio margin collateral rate for assets.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/tools/binance-portfolio-margin/getPortfolioMarginAccount.ts b/src/tools/binance-portfolio-margin/getPortfolioMarginAccount.ts index e1a4defa..d5d9c8d0 100644 --- a/src/tools/binance-portfolio-margin/getPortfolioMarginAccount.ts +++ b/src/tools/binance-portfolio-margin/getPortfolioMarginAccount.ts @@ -6,11 +6,14 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../config/binanceClient.js"; export function registerBinancePortfolioMarginGetAccount(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginGetAccount", - "Get portfolio margin account information including account status, balances, and positions.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: + "Get portfolio margin account information including account status, balances, and positions.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/tools/binance-portfolio-margin/getPortfolioMarginAssetIndexPrice.ts b/src/tools/binance-portfolio-margin/getPortfolioMarginAssetIndexPrice.ts index 74fbaca6..31704f99 100644 --- a/src/tools/binance-portfolio-margin/getPortfolioMarginAssetIndexPrice.ts +++ b/src/tools/binance-portfolio-margin/getPortfolioMarginAssetIndexPrice.ts @@ -6,15 +6,17 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../config/binanceClient.js"; export function registerBinancePortfolioMarginGetAssetIndexPrice(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginGetAssetIndexPrice", - "Query portfolio margin asset index price.", { - asset: z - .string() - .optional() - .describe("Asset symbol (e.g., BTC, ETH). If not provided, returns all assets"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Query portfolio margin asset index price.", + inputSchema: { + asset: z + .string() + .optional() + .describe("Asset symbol (e.g., BTC, ETH). If not provided, returns all assets"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ asset, recvWindow }) => { try { diff --git a/src/tools/binance-portfolio-margin/getPortfolioMarginAssetLeverage.ts b/src/tools/binance-portfolio-margin/getPortfolioMarginAssetLeverage.ts index da53d339..d1d32b4c 100644 --- a/src/tools/binance-portfolio-margin/getPortfolioMarginAssetLeverage.ts +++ b/src/tools/binance-portfolio-margin/getPortfolioMarginAssetLeverage.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../config/binanceClient.js"; export function registerBinancePortfolioMarginGetAssetLeverage(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginGetAssetLeverage", - "Query portfolio margin asset leverage information.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Query portfolio margin asset leverage information.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/tools/binance-portfolio-margin/getPortfolioMarginBankruptcyLoanAmount.ts b/src/tools/binance-portfolio-margin/getPortfolioMarginBankruptcyLoanAmount.ts index 90356a51..602e8b4e 100644 --- a/src/tools/binance-portfolio-margin/getPortfolioMarginBankruptcyLoanAmount.ts +++ b/src/tools/binance-portfolio-margin/getPortfolioMarginBankruptcyLoanAmount.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../config/binanceClient.js"; export function registerBinancePortfolioMarginGetBankruptcyLoanAmount(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginGetBankruptcyLoanAmount", - "Query portfolio margin bankruptcy loan amount.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Query portfolio margin bankruptcy loan amount.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/tools/binance-portfolio-margin/getPortfolioMarginInterestHistory.ts b/src/tools/binance-portfolio-margin/getPortfolioMarginInterestHistory.ts index 57d8c48b..2995c77c 100644 --- a/src/tools/binance-portfolio-margin/getPortfolioMarginInterestHistory.ts +++ b/src/tools/binance-portfolio-margin/getPortfolioMarginInterestHistory.ts @@ -6,15 +6,17 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../config/binanceClient.js"; export function registerBinancePortfolioMarginGetInterestHistory(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginGetInterestHistory", - "Query portfolio margin interest history.", { - asset: z.string().optional().describe("Asset symbol (e.g., BTC, USDT)"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - size: z.number().optional().describe("Number of results to return, default 10, max 100"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Query portfolio margin interest history.", + inputSchema: { + asset: z.string().optional().describe("Asset symbol (e.g., BTC, USDT)"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + size: z.number().optional().describe("Number of results to return, default 10, max 100"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ asset, startTime, endTime, size, recvWindow }) => { try { diff --git a/src/tools/binance-portfolio-margin/repayFuturesNegativeBalance.ts b/src/tools/binance-portfolio-margin/repayFuturesNegativeBalance.ts index fbdc34e5..1937098d 100644 --- a/src/tools/binance-portfolio-margin/repayFuturesNegativeBalance.ts +++ b/src/tools/binance-portfolio-margin/repayFuturesNegativeBalance.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../config/binanceClient.js"; export function registerBinancePortfolioMarginRepayFuturesNegativeBalance(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginRepayFuturesNegativeBalance", - "Repay futures negative balance for portfolio margin account.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Repay futures negative balance for portfolio margin account.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/tools/binance-portfolio-margin/repayPortfolioMarginBankruptcyLoan.ts b/src/tools/binance-portfolio-margin/repayPortfolioMarginBankruptcyLoan.ts index b06c3970..72fed32c 100644 --- a/src/tools/binance-portfolio-margin/repayPortfolioMarginBankruptcyLoan.ts +++ b/src/tools/binance-portfolio-margin/repayPortfolioMarginBankruptcyLoan.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { portfolioMarginClient } from "../../config/binanceClient.js"; export function registerBinancePortfolioMarginRepayBankruptcyLoan(server: McpServer) { - server.tool( + server.registerTool( "BinancePortfolioMarginRepayBankruptcyLoan", - "Repay portfolio margin bankruptcy loan.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Repay portfolio margin bankruptcy loan.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/tools/binance-rebate/rebate-api/getSpotRebateHistoryRecords.ts b/src/tools/binance-rebate/rebate-api/getSpotRebateHistoryRecords.ts index e0855594..cc36b657 100644 --- a/src/tools/binance-rebate/rebate-api/getSpotRebateHistoryRecords.ts +++ b/src/tools/binance-rebate/rebate-api/getSpotRebateHistoryRecords.ts @@ -6,14 +6,21 @@ import { z } from "zod"; import { rebateClient } from "../../../config/binanceClient.js"; export function registerBinanceGetSpotRebateHistoryRecords(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetSpotRebateHistoryRecords", - "Retrieve the history of spot rebate records, including commission rebates and referral kickbacks, for the past 7 days or a custom date range (within 30 days).", { - startTime: z.number().int().optional().describe("Start time in milliseconds"), - endTime: z.number().int().optional().describe("End time in milliseconds"), - page: z.number().int().default(1).describe("Page number, default is 1"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Retrieve the history of spot rebate records, including commission rebates and referral kickbacks, for the past 7 days or a custom date range (within 30 days).", + inputSchema: { + startTime: z.number().int().optional().describe("Start time in milliseconds"), + endTime: z.number().int().optional().describe("End time in milliseconds"), + page: z.number().int().default(1).describe("Page number, default is 1"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-simple-earn/account-api/getFlexibleProductPosition.ts b/src/tools/binance-simple-earn/account-api/getFlexibleProductPosition.ts index 3b657330..6be31cea 100644 --- a/src/tools/binance-simple-earn/account-api/getFlexibleProductPosition.ts +++ b/src/tools/binance-simple-earn/account-api/getFlexibleProductPosition.ts @@ -6,28 +6,31 @@ import { z } from "zod"; import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerBinanceGetFlexibleProductPosition(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetFlexibleProductPosition", - "Fetch your current holdings in Simple Earn Flexible Products, including total amount, reward rates, and redeem status.", { - asset: z.string().optional().describe("Asset symbol (optional)"), - productId: z.string().optional().describe("Product ID (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying the page. Starts from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Page size. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Fetch your current holdings in Simple Earn Flexible Products, including total amount, reward rates, and redeem status.", + inputSchema: { + asset: z.string().optional().describe("Asset symbol (optional)"), + productId: z.string().optional().describe("Product ID (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying the page. Starts from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Page size. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-simple-earn/account-api/simpleEarnFlexibleProductList.ts b/src/tools/binance-simple-earn/account-api/simpleEarnFlexibleProductList.ts index 0ad34c15..0219d0d1 100644 --- a/src/tools/binance-simple-earn/account-api/simpleEarnFlexibleProductList.ts +++ b/src/tools/binance-simple-earn/account-api/simpleEarnFlexibleProductList.ts @@ -6,27 +6,30 @@ import { z } from "zod"; import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerBinanceSimpleEarnFlexibleProductList(server: McpServer) { - server.tool( + server.registerTool( "BinanceSimpleEarnFlexibleProductList", - "Retrieve a list of available Simple Earn Flexible Products, including details like APR, purchase status, and subscription limits.", { - asset: z.string().optional().describe("Asset symbol (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Starts from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Page size. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Retrieve a list of available Simple Earn Flexible Products, including details like APR, purchase status, and subscription limits.", + inputSchema: { + asset: z.string().optional().describe("Asset symbol (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Starts from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Page size. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-simple-earn/earn-api/redeemFlexibleProduct.ts b/src/tools/binance-simple-earn/earn-api/redeemFlexibleProduct.ts index 0ffd3e25..d8029896 100644 --- a/src/tools/binance-simple-earn/earn-api/redeemFlexibleProduct.ts +++ b/src/tools/binance-simple-earn/earn-api/redeemFlexibleProduct.ts @@ -6,22 +6,25 @@ import { z } from "zod"; import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerBinanceRedeemFlexibleProduct(server: McpServer) { - server.tool( + server.registerTool( "BinanceRedeemFlexibleProduct", - "Allows users to redeem their funds from a Flexible Earn investment product using a programmatic HTTP POST request.", { - productId: z.string().describe("Product ID"), - redeemAll: z.boolean().optional().describe("true or false, default to false"), - amount: z - .number() - .positive() - .optional() - .describe("If redeemAll is false, amount is mandatory"), - destAccount: z - .enum(["SPOT", "FUND"]) - .optional() - .describe("Destination account: SPOT or FUND; default is SPOT"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Allows users to redeem their funds from a Flexible Earn investment product using a programmatic HTTP POST request.", + inputSchema: { + productId: z.string().describe("Product ID"), + redeemAll: z.boolean().optional().describe("true or false, default to false"), + amount: z + .number() + .positive() + .optional() + .describe("If redeemAll is false, amount is mandatory"), + destAccount: z + .enum(["SPOT", "FUND"]) + .optional() + .describe("Destination account: SPOT or FUND; default is SPOT"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-simple-earn/earn-api/subscribeFlexibleProduct.ts b/src/tools/binance-simple-earn/earn-api/subscribeFlexibleProduct.ts index 7d269ed4..08742103 100644 --- a/src/tools/binance-simple-earn/earn-api/subscribeFlexibleProduct.ts +++ b/src/tools/binance-simple-earn/earn-api/subscribeFlexibleProduct.ts @@ -6,18 +6,21 @@ import { z } from "zod"; import { simpleEarnClient } from "../../../config/binanceClient.js"; export function registerBinanceSubscribeFlexibleProduct(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubscribeFlexibleProduct", - "Subscribe to a Simple Earn Flexible Product by specifying the product ID and amount. Optional parameters include auto-subscribe and source account. ", { - productId: z.string().describe("Product ID"), - amount: z.number().positive().describe("Amount to purchase"), - autoSubscribe: z.boolean().optional().describe("true or false, default is true"), - sourceAccount: z - .enum(["SPOT", "FUND", "ALL"]) - .optional() - .describe("Source account: SPOT, FUND, or ALL; default is SPOT"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Subscribe to a Simple Earn Flexible Product by specifying the product ID and amount. Optional parameters include auto-subscribe and source account. ", + inputSchema: { + productId: z.string().describe("Product ID"), + amount: z.number().positive().describe("Amount to purchase"), + autoSubscribe: z.boolean().optional().describe("true or false, default is true"), + sourceAccount: z + .enum(["SPOT", "FUND", "ALL"]) + .optional() + .describe("Source account: SPOT, FUND, or ALL; default is SPOT"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-spot/account-api/accountCommission.ts b/src/tools/binance-spot/account-api/accountCommission.ts index b0603a78..b176b579 100644 --- a/src/tools/binance-spot/account-api/accountCommission.ts +++ b/src/tools/binance-spot/account-api/accountCommission.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceAccountCommission(server: McpServer) { - server.tool( + server.registerTool( "BinanceAccountCommission", - "Get account commission rates for a specific symbol.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get account commission rates for a specific symbol.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ symbol, recvWindow }) => { try { diff --git a/src/tools/binance-spot/account-api/getAccount.ts b/src/tools/binance-spot/account-api/getAccount.ts index 5fb3ba53..995b0bb2 100644 --- a/src/tools/binance-spot/account-api/getAccount.ts +++ b/src/tools/binance-spot/account-api/getAccount.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceGetAccount(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetAccount", - "Get current account information.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get current account information.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/tools/binance-spot/account-api/myAllocations.ts b/src/tools/binance-spot/account-api/myAllocations.ts index 2d1668a3..a000150c 100644 --- a/src/tools/binance-spot/account-api/myAllocations.ts +++ b/src/tools/binance-spot/account-api/myAllocations.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceMyAllocations(server: McpServer) { - server.tool( + server.registerTool( "BinanceMyAllocations", - "Get SOR allocations for Self-Trade Prevention.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - allocationId: z.number().optional().describe("Allocation ID"), - orderId: z.number().optional().describe("Order ID"), - fromAllocationId: z.number().optional().describe("Allocation ID to fetch from"), - limit: z.number().optional().describe("Default 500; max 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get SOR allocations for Self-Trade Prevention.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + allocationId: z.number().optional().describe("Allocation ID"), + orderId: z.number().optional().describe("Order ID"), + fromAllocationId: z.number().optional().describe("Allocation ID to fetch from"), + limit: z.number().optional().describe("Default 500; max 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ symbol, allocationId, orderId, fromAllocationId, limit, recvWindow }) => { try { diff --git a/src/tools/binance-spot/account-api/myPreventedMatches.ts b/src/tools/binance-spot/account-api/myPreventedMatches.ts index 0181e33e..cff226cb 100644 --- a/src/tools/binance-spot/account-api/myPreventedMatches.ts +++ b/src/tools/binance-spot/account-api/myPreventedMatches.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceMyPreventedMatches(server: McpServer) { - server.tool( + server.registerTool( "BinanceMyPreventedMatches", - "Get prevented matches for Self-Trade Prevention.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - preventedMatchId: z.number().optional().describe("Prevented match ID"), - orderId: z.number().optional().describe("Order ID"), - fromPreventedMatchId: z.number().optional().describe("Prevented match ID to fetch from"), - limit: z.number().optional().describe("Default 500; max 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get prevented matches for Self-Trade Prevention.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + preventedMatchId: z.number().optional().describe("Prevented match ID"), + orderId: z.number().optional().describe("Order ID"), + fromPreventedMatchId: z.number().optional().describe("Prevented match ID to fetch from"), + limit: z.number().optional().describe("Default 500; max 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ symbol, preventedMatchId, orderId, fromPreventedMatchId, limit, recvWindow }) => { try { diff --git a/src/tools/binance-spot/account-api/myTrades.ts b/src/tools/binance-spot/account-api/myTrades.ts index 81e110b9..c7576641 100644 --- a/src/tools/binance-spot/account-api/myTrades.ts +++ b/src/tools/binance-spot/account-api/myTrades.ts @@ -6,17 +6,19 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceMyTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceMyTrades", - "Get trades for a specific account and symbol.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - orderId: z.number().optional().describe("Order ID"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - fromId: z.number().optional().describe("Trade ID to fetch from"), - limit: z.number().optional().describe("Default 500; max 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get trades for a specific account and symbol.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + orderId: z.number().optional().describe("Order ID"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + fromId: z.number().optional().describe("Trade ID to fetch from"), + limit: z.number().optional().describe("Default 500; max 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ symbol, orderId, startTime, endTime, fromId, limit, recvWindow }) => { try { diff --git a/src/tools/binance-spot/account-api/rateLimitOrder.ts b/src/tools/binance-spot/account-api/rateLimitOrder.ts index 83fe3be2..a8956267 100644 --- a/src/tools/binance-spot/account-api/rateLimitOrder.ts +++ b/src/tools/binance-spot/account-api/rateLimitOrder.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceRateLimitOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceRateLimitOrder", - "Get current order count usage for each rate limit.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get current order count usage for each rate limit.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/tools/binance-spot/general-api/exchangeInfo.ts b/src/tools/binance-spot/general-api/exchangeInfo.ts index a54a5222..19912582 100644 --- a/src/tools/binance-spot/general-api/exchangeInfo.ts +++ b/src/tools/binance-spot/general-api/exchangeInfo.ts @@ -6,23 +6,25 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceExchangeInfo(server: McpServer) { - server.tool( + server.registerTool( "BinanceExchangeInfo", - "Get exchange information including rate limits, symbol configs, etc.", { - symbol: z - .string() - .optional() - .describe( - "Single trading pair in UPPERCASE, no separators (e.g. BTCUSDT, SOLUSDT). Use this for one pair; do not use both symbol and symbols.", - ), - symbols: z - .array(z.string()) - .optional() - .describe( - 'Multiple pairs as array; each symbol UPPERCASE (e.g. ["BTCUSDT","ETHUSDT"]). Do not use with symbol.', - ), - permissions: z.array(z.string()).optional().describe("Array of permissions to filter by"), + description: "Get exchange information including rate limits, symbol configs, etc.", + inputSchema: { + symbol: z + .string() + .optional() + .describe( + "Single trading pair in UPPERCASE, no separators (e.g. BTCUSDT, SOLUSDT). Use this for one pair; do not use both symbol and symbols.", + ), + symbols: z + .array(z.string()) + .optional() + .describe( + 'Multiple pairs as array; each symbol UPPERCASE (e.g. ["BTCUSDT","ETHUSDT"]). Do not use with symbol.', + ), + permissions: z.array(z.string()).optional().describe("Array of permissions to filter by"), + }, }, async ({ symbol, symbols, permissions }) => { try { diff --git a/src/tools/binance-spot/general-api/ping.ts b/src/tools/binance-spot/general-api/ping.ts index ebce997e..bddc02d5 100644 --- a/src/tools/binance-spot/general-api/ping.ts +++ b/src/tools/binance-spot/general-api/ping.ts @@ -4,27 +4,31 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinancePing(server: McpServer) { - server.tool("BinancePing", "Test connectivity to the Binance API.", {}, async () => { - try { - const response = await spotClient.restAPI.ping(); + server.registerTool( + "BinancePing", + { description: "Test connectivity to the Binance API." }, + async () => { + try { + const response = await spotClient.restAPI.ping(); - const data = await response.data(); + const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Successfully pinged Binance API. Response: ${JSON.stringify(data)}`, - }, - ], - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); + return { + content: [ + { + type: "text", + text: `Successfully pinged Binance API. Response: ${JSON.stringify(data)}`, + }, + ], + }; + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to ping Binance API: ${errorMessage}` }], - isError: true, - }; - } - }); + return { + content: [{ type: "text", text: `Failed to ping Binance API: ${errorMessage}` }], + isError: true, + }; + } + }, + ); } diff --git a/src/tools/binance-spot/general-api/time.ts b/src/tools/binance-spot/general-api/time.ts index 01df870a..601054ff 100644 --- a/src/tools/binance-spot/general-api/time.ts +++ b/src/tools/binance-spot/general-api/time.ts @@ -4,32 +4,36 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceTime(server: McpServer) { - server.tool("BinanceTime", "Get the current server time from Binance API.", {}, async () => { - try { - const response = await spotClient.restAPI.time(); + server.registerTool( + "BinanceTime", + { description: "Get the current server time from Binance API." }, + async () => { + try { + const response = await spotClient.restAPI.time(); - const data = await response.data(); + const data = await response.data(); - // @ts-expect-error - serverTime not in generated type definition - const serverTime = new Date(data.serverTime).toISOString(); + // @ts-expect-error - serverTime not in generated type definition + const serverTime = new Date(data.serverTime).toISOString(); - return { - content: [ - { - type: "text", - text: `Current Binance server time: ${serverTime} (${ - data.serverTime - }). Response: ${JSON.stringify(data)}`, - }, - ], - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); + return { + content: [ + { + type: "text", + text: `Current Binance server time: ${serverTime} (${ + data.serverTime + }). Response: ${JSON.stringify(data)}`, + }, + ], + }; + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to retrieve server time: ${errorMessage}` }], - isError: true, - }; - } - }); + return { + content: [{ type: "text", text: `Failed to retrieve server time: ${errorMessage}` }], + isError: true, + }; + } + }, + ); } diff --git a/src/tools/binance-spot/market-api/aggTrades.ts b/src/tools/binance-spot/market-api/aggTrades.ts index 378358ef..0f4e8f65 100644 --- a/src/tools/binance-spot/market-api/aggTrades.ts +++ b/src/tools/binance-spot/market-api/aggTrades.ts @@ -6,15 +6,17 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceAggTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceAggTrades", - "Get compressed, aggregate trades for a specific trading pair.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - fromId: z.number().optional().describe("ID to get aggregate trades from"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1000"), + description: "Get compressed, aggregate trades for a specific trading pair.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + fromId: z.number().optional().describe("ID to get aggregate trades from"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1000"), + }, }, async ({ symbol, fromId, startTime, endTime, limit }) => { try { diff --git a/src/tools/binance-spot/market-api/avgPrice.ts b/src/tools/binance-spot/market-api/avgPrice.ts index 6603c81b..299e44d8 100644 --- a/src/tools/binance-spot/market-api/avgPrice.ts +++ b/src/tools/binance-spot/market-api/avgPrice.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceAvgPrice(server: McpServer) { - server.tool( + server.registerTool( "BinanceAvgPrice", - "Get current average price for a trading pair.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + description: "Get current average price for a trading pair.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, }, async ({ symbol }) => { try { diff --git a/src/tools/binance-spot/market-api/depth.ts b/src/tools/binance-spot/market-api/depth.ts index 31b78959..106c39d7 100644 --- a/src/tools/binance-spot/market-api/depth.ts +++ b/src/tools/binance-spot/market-api/depth.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceDepth(server: McpServer) { - server.tool( + server.registerTool( "BinanceDepth", - "Get order book depth data for a specific trading pair.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - limit: z.number().optional().describe("Depth of the order book. Default 100; max 5000."), + description: "Get order book depth data for a specific trading pair.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + limit: z.number().optional().describe("Depth of the order book. Default 100; max 5000."), + }, }, async ({ symbol, limit }) => { try { diff --git a/src/tools/binance-spot/market-api/getTrades.ts b/src/tools/binance-spot/market-api/getTrades.ts index 2e1ed4c1..1d0dace1 100644 --- a/src/tools/binance-spot/market-api/getTrades.ts +++ b/src/tools/binance-spot/market-api/getTrades.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceGetTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetTrades", - "Get recent trades for a specific trading pair.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - limit: z.number().optional().describe("Default 500; max 1000"), + description: "Get recent trades for a specific trading pair.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + limit: z.number().optional().describe("Default 500; max 1000"), + }, }, async ({ symbol, limit }) => { try { diff --git a/src/tools/binance-spot/market-api/historicalTrades.ts b/src/tools/binance-spot/market-api/historicalTrades.ts index 07a7b27d..85299c2a 100644 --- a/src/tools/binance-spot/market-api/historicalTrades.ts +++ b/src/tools/binance-spot/market-api/historicalTrades.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceHistoricalTrades(server: McpServer) { - server.tool( + server.registerTool( "BinanceHistoricalTrades", - "Get older historical trades for a specific trading pair.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - limit: z.number().optional().describe("Default 500; max 1000"), - fromId: z.number().optional().describe("Trade ID to fetch from"), + description: "Get older historical trades for a specific trading pair.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + limit: z.number().optional().describe("Default 500; max 1000"), + fromId: z.number().optional().describe("Trade ID to fetch from"), + }, }, async ({ symbol, limit, fromId }) => { try { diff --git a/src/tools/binance-spot/market-api/klines.ts b/src/tools/binance-spot/market-api/klines.ts index 8ab84f65..12d97fea 100644 --- a/src/tools/binance-spot/market-api/klines.ts +++ b/src/tools/binance-spot/market-api/klines.ts @@ -6,33 +6,35 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceKlines(server: McpServer) { - server.tool( + server.registerTool( "BinanceKlines", - "Get candlestick data (klines) for a specific trading pair and interval.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - interval: z - .enum([ - "1m", - "3m", - "5m", - "15m", - "30m", - "1h", - "2h", - "4h", - "6h", - "8h", - "12h", - "1d", - "3d", - "1w", - "1M", - ]) - .describe("Kline interval"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1000"), + description: "Get candlestick data (klines) for a specific trading pair and interval.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1000"), + }, }, async ({ symbol, interval, startTime, endTime, limit }) => { try { diff --git a/src/tools/binance-spot/market-api/ticker.ts b/src/tools/binance-spot/market-api/ticker.ts index fca26210..dc71f02d 100644 --- a/src/tools/binance-spot/market-api/ticker.ts +++ b/src/tools/binance-spot/market-api/ticker.ts @@ -6,15 +6,18 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceTicker(server: McpServer) { - server.tool( + server.registerTool( "BinanceTicker", - "Get 24-hour rolling window price change statistics for a symbol or all symbols.", { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - windowSize: z - .string() - .optional() - .describe("Defaults to 1d. Valid values: 1d, 2d, 3d, 4d, 5d, 6d, 7d"), + description: + "Get 24-hour rolling window price change statistics for a symbol or all symbols.", + inputSchema: { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + windowSize: z + .string() + .optional() + .describe("Defaults to 1d. Valid values: 1d, 2d, 3d, 4d, 5d, 6d, 7d"), + }, }, async ({ symbol, windowSize }) => { try { diff --git a/src/tools/binance-spot/market-api/ticker24hr.ts b/src/tools/binance-spot/market-api/ticker24hr.ts index bb9cf669..06fb1f9b 100644 --- a/src/tools/binance-spot/market-api/ticker24hr.ts +++ b/src/tools/binance-spot/market-api/ticker24hr.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceTicker24hr(server: McpServer) { - server.tool( + server.registerTool( "BinanceTicker24hr", - "Get 24-hour price change statistics for a symbol or all symbols.", { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + description: "Get 24-hour price change statistics for a symbol or all symbols.", + inputSchema: { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, }, async ({ symbol }) => { try { diff --git a/src/tools/binance-spot/market-api/tickerBookTicker.ts b/src/tools/binance-spot/market-api/tickerBookTicker.ts index 0c59dc80..ab275052 100644 --- a/src/tools/binance-spot/market-api/tickerBookTicker.ts +++ b/src/tools/binance-spot/market-api/tickerBookTicker.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceTickerBookTicker(server: McpServer) { - server.tool( + server.registerTool( "BinanceTickerBookTicker", - "Get best price/quantity on the order book for a symbol or all symbols.", { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + description: "Get best price/quantity on the order book for a symbol or all symbols.", + inputSchema: { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, }, async ({ symbol }) => { try { diff --git a/src/tools/binance-spot/market-api/tickerPrice.ts b/src/tools/binance-spot/market-api/tickerPrice.ts index 1480cdcb..f1da8d7c 100644 --- a/src/tools/binance-spot/market-api/tickerPrice.ts +++ b/src/tools/binance-spot/market-api/tickerPrice.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceTickerPrice(server: McpServer) { - server.tool( + server.registerTool( "BinanceTickerPrice", - "Get latest price for a symbol or all symbols.", { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + description: "Get latest price for a symbol or all symbols.", + inputSchema: { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, }, async ({ symbol }) => { try { diff --git a/src/tools/binance-spot/market-api/tickerTradingDay.ts b/src/tools/binance-spot/market-api/tickerTradingDay.ts index 8ec97804..1fcedc0f 100644 --- a/src/tools/binance-spot/market-api/tickerTradingDay.ts +++ b/src/tools/binance-spot/market-api/tickerTradingDay.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceTickerTradingDay(server: McpServer) { - server.tool( + server.registerTool( "BinanceTickerTradingDay", - "Get statistics for the current trading day for a symbol or all symbols.", { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + description: "Get statistics for the current trading day for a symbol or all symbols.", + inputSchema: { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, }, async ({ symbol }) => { try { diff --git a/src/tools/binance-spot/market-api/uiKlines.ts b/src/tools/binance-spot/market-api/uiKlines.ts index 10cc184e..697bf896 100644 --- a/src/tools/binance-spot/market-api/uiKlines.ts +++ b/src/tools/binance-spot/market-api/uiKlines.ts @@ -6,33 +6,35 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceUiKlines(server: McpServer) { - server.tool( + server.registerTool( "BinanceUiKlines", - "Get UI-optimized candlestick data for a specific trading pair and interval.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - interval: z - .enum([ - "1m", - "3m", - "5m", - "15m", - "30m", - "1h", - "2h", - "4h", - "6h", - "8h", - "12h", - "1d", - "3d", - "1w", - "1M", - ]) - .describe("Kline interval"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500; max 1000"), + description: "Get UI-optimized candlestick data for a specific trading pair and interval.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + interval: z + .enum([ + "1m", + "3m", + "5m", + "15m", + "30m", + "1h", + "2h", + "4h", + "6h", + "8h", + "12h", + "1d", + "3d", + "1w", + "1M", + ]) + .describe("Kline interval"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500; max 1000"), + }, }, async ({ symbol, interval, startTime, endTime, limit }) => { try { diff --git a/src/tools/binance-spot/trade-api/allOrders.ts b/src/tools/binance-spot/trade-api/allOrders.ts index 939a32f8..d8ab32d9 100644 --- a/src/tools/binance-spot/trade-api/allOrders.ts +++ b/src/tools/binance-spot/trade-api/allOrders.ts @@ -6,18 +6,20 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceAllOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceAllOrders", - "Get all account orders for a specific symbol; active, canceled, or filled.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - orderId: z.number().optional().describe("Order ID to start from"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z - .number() - .optional() - .describe("Maximum number of orders to return (default 500, max 1000)"), + description: "Get all account orders for a specific symbol; active, canceled, or filled.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + orderId: z.number().optional().describe("Order ID to start from"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z + .number() + .optional() + .describe("Maximum number of orders to return (default 500, max 1000)"), + }, }, async ({ symbol, orderId, startTime, endTime, limit }) => { try { diff --git a/src/tools/binance-spot/trade-api/deleteOpenOrders.ts b/src/tools/binance-spot/trade-api/deleteOpenOrders.ts index 1d37e077..22d06c31 100644 --- a/src/tools/binance-spot/trade-api/deleteOpenOrders.ts +++ b/src/tools/binance-spot/trade-api/deleteOpenOrders.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceDeleteOpenOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeleteOpenOrders", - "Cancel all open orders on Binance for a specific symbol.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + description: "Cancel all open orders on Binance for a specific symbol.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, }, async ({ symbol }) => { try { diff --git a/src/tools/binance-spot/trade-api/deleteOrder.ts b/src/tools/binance-spot/trade-api/deleteOrder.ts index 8bbe0e5f..9768877b 100644 --- a/src/tools/binance-spot/trade-api/deleteOrder.ts +++ b/src/tools/binance-spot/trade-api/deleteOrder.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceDeleteOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeleteOrder", - "Cancel an active order on Binance for a specific trading pair.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - orderId: z.string().optional().describe("The order ID to cancel"), - origClientOrderId: z.string().optional().describe("Original client order ID"), + description: "Cancel an active order on Binance for a specific trading pair.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + orderId: z.string().optional().describe("The order ID to cancel"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + }, }, async ({ symbol, orderId, origClientOrderId }) => { try { diff --git a/src/tools/binance-spot/trade-api/getOpenOrders.ts b/src/tools/binance-spot/trade-api/getOpenOrders.ts index 5d30259d..4abe2229 100644 --- a/src/tools/binance-spot/trade-api/getOpenOrders.ts +++ b/src/tools/binance-spot/trade-api/getOpenOrders.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceGetOpenOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetOpenOrders", - "Get all open orders on Binance for a specific symbol or all symbols.", { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + description: "Get all open orders on Binance for a specific symbol or all symbols.", + inputSchema: { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, }, async ({ symbol }) => { try { diff --git a/src/tools/binance-spot/trade-api/getOrder.ts b/src/tools/binance-spot/trade-api/getOrder.ts index e76b7bf5..b3e2afa9 100644 --- a/src/tools/binance-spot/trade-api/getOrder.ts +++ b/src/tools/binance-spot/trade-api/getOrder.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceGetOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetOrder", - "Check an order's status on Binance for a specific trading pair.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - orderId: z.string().optional().describe("The order ID to query"), - origClientOrderId: z.string().optional().describe("Original client order ID"), + description: "Check an order's status on Binance for a specific trading pair.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + orderId: z.string().optional().describe("The order ID to query"), + origClientOrderId: z.string().optional().describe("Original client order ID"), + }, }, async ({ symbol, orderId, origClientOrderId }) => { try { diff --git a/src/tools/binance-spot/trade-api/newOrder.ts b/src/tools/binance-spot/trade-api/newOrder.ts index 4e5ccca9..00773a80 100644 --- a/src/tools/binance-spot/trade-api/newOrder.ts +++ b/src/tools/binance-spot/trade-api/newOrder.ts @@ -11,34 +11,36 @@ function sanitizeNewClientOrderId(value: string): string { } export function registerBinanceNewOrder(server: McpServer) { - server.tool( + server.registerTool( "BinanceNewOrder", - "Create a new order on Binance for a specific trading pair.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Order side: BUY or SELL"), - type: z - .enum([ - "LIMIT", - "MARKET", - "STOP_LOSS", - "STOP_LOSS_LIMIT", - "TAKE_PROFIT", - "TAKE_PROFIT_LIMIT", - "LIMIT_MAKER", - ]) - .describe("Order type"), - timeInForce: z.enum(["GTC", "IOC", "FOK"]).optional().describe("Time in force"), - quantity: z.number().describe("Order quantity"), - quoteOrderQty: z.number().optional().describe("Quote order quantity"), - price: z.number().optional().describe("Order price"), - newClientOrderId: z - .string() - .optional() - .describe("Client order ID: only a-zA-Z0-9-_ allowed, max 36 chars"), - stopPrice: z.number().optional().describe("Stop price"), - icebergQty: z.number().optional().describe("Iceberg quantity"), - newOrderRespType: z.enum(["ACK", "RESULT", "FULL"]).optional().describe("Response type"), + description: "Create a new order on Binance for a specific trading pair.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Order side: BUY or SELL"), + type: z + .enum([ + "LIMIT", + "MARKET", + "STOP_LOSS", + "STOP_LOSS_LIMIT", + "TAKE_PROFIT", + "TAKE_PROFIT_LIMIT", + "LIMIT_MAKER", + ]) + .describe("Order type"), + timeInForce: z.enum(["GTC", "IOC", "FOK"]).optional().describe("Time in force"), + quantity: z.number().describe("Order quantity"), + quoteOrderQty: z.number().optional().describe("Quote order quantity"), + price: z.number().optional().describe("Order price"), + newClientOrderId: z + .string() + .optional() + .describe("Client order ID: only a-zA-Z0-9-_ allowed, max 36 chars"), + stopPrice: z.number().optional().describe("Stop price"), + icebergQty: z.number().optional().describe("Iceberg quantity"), + newOrderRespType: z.enum(["ACK", "RESULT", "FULL"]).optional().describe("Response type"), + }, }, async ({ symbol, diff --git a/src/tools/binance-spot/trade-api/openOrderList.ts b/src/tools/binance-spot/trade-api/openOrderList.ts index 2a8c3ee9..12c9a3a4 100644 --- a/src/tools/binance-spot/trade-api/openOrderList.ts +++ b/src/tools/binance-spot/trade-api/openOrderList.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceOpenOrderList(server: McpServer) { - server.tool( + server.registerTool( "BinanceOpenOrderList", - "Query open OCO orders for a specific account or symbol.", { - symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + description: "Query open OCO orders for a specific account or symbol.", + inputSchema: { + symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + }, }, async ({ symbol }) => { try { diff --git a/src/tools/binance-spot/trade-api/orderOco.ts b/src/tools/binance-spot/trade-api/orderOco.ts index 42803c26..33348c6d 100644 --- a/src/tools/binance-spot/trade-api/orderOco.ts +++ b/src/tools/binance-spot/trade-api/orderOco.ts @@ -6,24 +6,26 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceOrderOco(server: McpServer) { - server.tool( + server.registerTool( "BinanceOrderOco", - "Send a new OCO (One-Cancels-the-Other) order on Binance.", { - symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), - side: z.enum(["BUY", "SELL"]).describe("Order side: BUY or SELL"), - quantity: z.number().describe("Order quantity"), - price: z.number().describe("Order price"), - stopPrice: z.number().describe("Stop price"), - stopLimitPrice: z.number().optional().describe("Stop limit price"), - stopLimitTimeInForce: z - .enum(["GTC", "IOC", "FOK"]) - .optional() - .describe("Stop limit time in force"), - newClientOrderId: z.string().optional().describe("Client order ID for the limit order"), - stopClientOrderId: z.string().optional().describe("Client order ID for the stop order"), - limitIcebergQty: z.number().optional().describe("Limit iceberg quantity"), - stopIcebergQty: z.number().optional().describe("Stop iceberg quantity"), + description: "Send a new OCO (One-Cancels-the-Other) order on Binance.", + inputSchema: { + symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"), + side: z.enum(["BUY", "SELL"]).describe("Order side: BUY or SELL"), + quantity: z.number().describe("Order quantity"), + price: z.number().describe("Order price"), + stopPrice: z.number().describe("Stop price"), + stopLimitPrice: z.number().optional().describe("Stop limit price"), + stopLimitTimeInForce: z + .enum(["GTC", "IOC", "FOK"]) + .optional() + .describe("Stop limit time in force"), + newClientOrderId: z.string().optional().describe("Client order ID for the limit order"), + stopClientOrderId: z.string().optional().describe("Client order ID for the stop order"), + limitIcebergQty: z.number().optional().describe("Limit iceberg quantity"), + stopIcebergQty: z.number().optional().describe("Stop iceberg quantity"), + }, }, async ({ symbol, diff --git a/src/tools/binance-spot/userdatastream-api/deleteUserDataStream.ts b/src/tools/binance-spot/userdatastream-api/deleteUserDataStream.ts index 823a10cd..47eb16f3 100644 --- a/src/tools/binance-spot/userdatastream-api/deleteUserDataStream.ts +++ b/src/tools/binance-spot/userdatastream-api/deleteUserDataStream.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceDeleteUserDataStream(server: McpServer) { - server.tool( + server.registerTool( "BinanceDeleteUserDataStream", - "Close a user data stream by invalidating the listen key.", { - listenKey: z.string().describe("Listen key to close"), + description: "Close a user data stream by invalidating the listen key.", + inputSchema: { + listenKey: z.string().describe("Listen key to close"), + }, }, async ({ listenKey }) => { try { diff --git a/src/tools/binance-spot/userdatastream-api/newUserDataStream.ts b/src/tools/binance-spot/userdatastream-api/newUserDataStream.ts index 053ed45c..e7bd9d50 100644 --- a/src/tools/binance-spot/userdatastream-api/newUserDataStream.ts +++ b/src/tools/binance-spot/userdatastream-api/newUserDataStream.ts @@ -4,10 +4,9 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceNewUserDataStream(server: McpServer) { - server.tool( + server.registerTool( "BinanceNewUserDataStream", - "Create a new user data stream to receive account updates via WebSocket.", - {}, + { description: "Create a new user data stream to receive account updates via WebSocket." }, async () => { try { const response = await spotClient.restAPI.newUserDataStream(); diff --git a/src/tools/binance-spot/userdatastream-api/putUserDataStream.ts b/src/tools/binance-spot/userdatastream-api/putUserDataStream.ts index 3579e98d..73d4783e 100644 --- a/src/tools/binance-spot/userdatastream-api/putUserDataStream.ts +++ b/src/tools/binance-spot/userdatastream-api/putUserDataStream.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinancePutUserDataStream(server: McpServer) { - server.tool( + server.registerTool( "BinancePutUserDataStream", - "Extend the validity of a user data stream listen key.", { - listenKey: z.string().describe("Listen key to keep alive"), + description: "Extend the validity of a user data stream listen key.", + inputSchema: { + listenKey: z.string().describe("Listen key to keep alive"), + }, }, async ({ listenKey }) => { try { diff --git a/src/tools/binance-staking/ETH-staking-api/ethStakingAccount.ts b/src/tools/binance-staking/ETH-staking-api/ethStakingAccount.ts index b6b73263..cad0c72b 100644 --- a/src/tools/binance-staking/ETH-staking-api/ethStakingAccount.ts +++ b/src/tools/binance-staking/ETH-staking-api/ethStakingAccount.ts @@ -6,11 +6,14 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceEthStakingAccount(server: McpServer) { - server.tool( + server.registerTool( "BinanceEthStakingAccount", - "ETH Staking Account API allows users to retrieve their current ETH staking holdings and 30-day profit details, including amounts from WBETH and BETH", { - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "ETH Staking Account API allows users to retrieve their current ETH staking holdings and 30-day profit details, including amounts from WBETH and BETH", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-staking/ETH-staking-api/getCurrentEthStakingQuota.ts b/src/tools/binance-staking/ETH-staking-api/getCurrentEthStakingQuota.ts index cb23363b..7275a607 100644 --- a/src/tools/binance-staking/ETH-staking-api/getCurrentEthStakingQuota.ts +++ b/src/tools/binance-staking/ETH-staking-api/getCurrentEthStakingQuota.ts @@ -6,11 +6,14 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetCurrentEthStakingQuota(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetCurrentEthStakingQuota", - "Get Current ETH Staking Quota API allows users to retrieve their available ETH staking and redemption quotas, reflecting personal and daily limits.", { - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Get Current ETH Staking Quota API allows users to retrieve their available ETH staking and redemption quotas, reflecting personal and daily limits.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-staking/ETH-staking-api/getEthRedemptionHistory.ts b/src/tools/binance-staking/ETH-staking-api/getEthRedemptionHistory.ts index 4ca27d3d..98eeae75 100644 --- a/src/tools/binance-staking/ETH-staking-api/getEthRedemptionHistory.ts +++ b/src/tools/binance-staking/ETH-staking-api/getEthRedemptionHistory.ts @@ -6,36 +6,39 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetEthRedemptionHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetEthRedemptionHistory", - "Get ETH Redemption History API allows users to retrieve their historical ETH staking redemption records, including details like asset type, amount, status, and time of redemption.", { - startTime: z - .number() - .int() - .optional() - .describe("Start time in milliseconds (e.g., 1641522717552)"), - endTime: z - .number() - .int() - .optional() - .describe("End time in milliseconds (e.g., 1641522526562)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page, start from 1. Default is 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page, Default is 10, Max is 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Get ETH Redemption History API allows users to retrieve their historical ETH staking redemption records, including details like asset type, amount, status, and time of redemption.", + inputSchema: { + startTime: z + .number() + .int() + .optional() + .describe("Start time in milliseconds (e.g., 1641522717552)"), + endTime: z + .number() + .int() + .optional() + .describe("End time in milliseconds (e.g., 1641522526562)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page, start from 1. Default is 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page, Default is 10, Max is 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-staking/ETH-staking-api/getEthStakingHistory.ts b/src/tools/binance-staking/ETH-staking-api/getEthStakingHistory.ts index 6f2405f4..e41ef5ac 100644 --- a/src/tools/binance-staking/ETH-staking-api/getEthStakingHistory.ts +++ b/src/tools/binance-staking/ETH-staking-api/getEthStakingHistory.ts @@ -6,36 +6,39 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetEthStakingHistory(server: McpServer) { - server.tool( + server.registerTool( "registerBinanceGetEthStakingHistory", - "Get ETH Staking History API allows users to retrieve their historical ETH staking records, including details like asset type, amount, status, and time of staking", { - startTime: z - .number() - .int() - .optional() - .describe("Start time in milliseconds (e.g., 1641522717552)"), - endTime: z - .number() - .int() - .optional() - .describe("End time in milliseconds (e.g., 1641522526562)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default is 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default is 10, Max is 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Get ETH Staking History API allows users to retrieve their historical ETH staking records, including details like asset type, amount, status, and time of staking", + inputSchema: { + startTime: z + .number() + .int() + .optional() + .describe("Start time in milliseconds (e.g., 1641522717552)"), + endTime: z + .number() + .int() + .optional() + .describe("End time in milliseconds (e.g., 1641522526562)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default is 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default is 10, Max is 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-staking/ETH-staking-api/getWbethRateHistory.ts b/src/tools/binance-staking/ETH-staking-api/getWbethRateHistory.ts index 4f354623..e2c1056e 100644 --- a/src/tools/binance-staking/ETH-staking-api/getWbethRateHistory.ts +++ b/src/tools/binance-staking/ETH-staking-api/getWbethRateHistory.ts @@ -6,33 +6,36 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetWbethRateHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetWbethRateHistory", - "Get WBETH Rate History API allows users to retrieve historical WBETH exchange rates and BETH annual percentage rates (APR) within a specified time range.", { - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Starts from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), + description: + "Get WBETH Rate History API allows users to retrieve historical WBETH exchange rates and BETH annual percentage rates (APR) within a specified time range.", + inputSchema: { + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Starts from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z - .number() - .int() - .optional() - .describe("Time window for request validity (in milliseconds)"), + recvWindow: z + .number() + .int() + .optional() + .describe("Time window for request validity (in milliseconds)"), + }, }, async (params) => { try { diff --git a/src/tools/binance-staking/ETH-staking-api/getWbethRewardsHistory.ts b/src/tools/binance-staking/ETH-staking-api/getWbethRewardsHistory.ts index 697014e7..a02a08ff 100644 --- a/src/tools/binance-staking/ETH-staking-api/getWbethRewardsHistory.ts +++ b/src/tools/binance-staking/ETH-staking-api/getWbethRewardsHistory.ts @@ -6,36 +6,39 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetWbethRewardsHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetWbethRewardsHistory", - "Get WBETH Rewards History API allows users to retrieve historical reward data earned from WBETH holdings, including estimated rewards in ETH, holding amounts, and APR details.", { - startTime: z - .number() - .int() - .optional() - .describe("Start time in milliseconds (e.g., 1641522717552)"), - endTime: z - .number() - .int() - .optional() - .describe("End time in milliseconds (e.g., 1641522720000)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Get WBETH Rewards History API allows users to retrieve historical reward data earned from WBETH holdings, including estimated rewards in ETH, holding amounts, and APR details.", + inputSchema: { + startTime: z + .number() + .int() + .optional() + .describe("Start time in milliseconds (e.g., 1641522717552)"), + endTime: z + .number() + .int() + .optional() + .describe("End time in milliseconds (e.g., 1641522720000)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-staking/ETH-staking-api/getWbethUnwrapHistory.ts b/src/tools/binance-staking/ETH-staking-api/getWbethUnwrapHistory.ts index d36db1e5..12fcdb90 100644 --- a/src/tools/binance-staking/ETH-staking-api/getWbethUnwrapHistory.ts +++ b/src/tools/binance-staking/ETH-staking-api/getWbethUnwrapHistory.ts @@ -6,32 +6,35 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetWbethUnwrapHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetWbethUnwrapHistory", - "Get WBETH Unwrap History API allows users to retrieve historical records of WBETH unwrap operations, including asset conversion details, exchange rates, and transaction status.", { - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z - .number() - .int() - .optional() - .describe("Time window for request validity (in milliseconds)"), + description: + "Get WBETH Unwrap History API allows users to retrieve historical records of WBETH unwrap operations, including asset conversion details, exchange rates, and transaction status.", + inputSchema: { + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z + .number() + .int() + .optional() + .describe("Time window for request validity (in milliseconds)"), + }, }, async (params) => { try { diff --git a/src/tools/binance-staking/ETH-staking-api/getWbethWrapHistory.ts b/src/tools/binance-staking/ETH-staking-api/getWbethWrapHistory.ts index 29d4e678..5b69ef1d 100644 --- a/src/tools/binance-staking/ETH-staking-api/getWbethWrapHistory.ts +++ b/src/tools/binance-staking/ETH-staking-api/getWbethWrapHistory.ts @@ -6,28 +6,31 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetWbethWrapHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetWbethWrapHistory", - "Get WBETH Wrap History API allows users to retrieve historical records of WBETH wrap operations, including asset conversion details, exchange rates, and transaction status.", { - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Get WBETH Wrap History API allows users to retrieve historical records of WBETH wrap operations, including asset conversion details, exchange rates, and transaction status.", + inputSchema: { + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-staking/ETH-staking-api/redeemEth.ts b/src/tools/binance-staking/ETH-staking-api/redeemEth.ts index 53d22e97..ba81b6fb 100644 --- a/src/tools/binance-staking/ETH-staking-api/redeemEth.ts +++ b/src/tools/binance-staking/ETH-staking-api/redeemEth.ts @@ -6,17 +6,20 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceRedeemEth(server: McpServer) { - server.tool( + server.registerTool( "BinanceRedeemEth", - "Redeem ETH API allows users to redeem WBETH or BETH for ETH, providing the amount, conversion ratio, and arrival time details.", { - amount: z.number().min(0).describe("Amount in BETH, limit 8 decimals (mandatory)"), - asset: z - .string() - .optional() - .default("BETH") - .describe("Asset type, either WBETH or BETH. Default: BETH"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Redeem ETH API allows users to redeem WBETH or BETH for ETH, providing the amount, conversion ratio, and arrival time details.", + inputSchema: { + amount: z.number().min(0).describe("Amount in BETH, limit 8 decimals (mandatory)"), + asset: z + .string() + .optional() + .default("BETH") + .describe("Asset type, either WBETH or BETH. Default: BETH"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-staking/ETH-staking-api/subscribeEthStaking.ts b/src/tools/binance-staking/ETH-staking-api/subscribeEthStaking.ts index b9c9272d..ef4108b9 100644 --- a/src/tools/binance-staking/ETH-staking-api/subscribeEthStaking.ts +++ b/src/tools/binance-staking/ETH-staking-api/subscribeEthStaking.ts @@ -6,12 +6,15 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceSubscribeEthStaking(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubscribeEthStaking", - "Subscribe ETH Staking API allows users to stake ETH and receive WBETH, providing the staked amount and the conversion ratio for ETH to WBETH.", { - amount: z.number().min(0).describe("Amount in BETH, limit 4 decimals (mandatory)"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Subscribe ETH Staking API allows users to stake ETH and receive WBETH, providing the staked amount and the conversion ratio for ETH to WBETH.", + inputSchema: { + amount: z.number().min(0).describe("Amount in BETH, limit 4 decimals (mandatory)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-staking/ETH-staking-api/wrapBeth.ts b/src/tools/binance-staking/ETH-staking-api/wrapBeth.ts index 596c5486..2d64825f 100644 --- a/src/tools/binance-staking/ETH-staking-api/wrapBeth.ts +++ b/src/tools/binance-staking/ETH-staking-api/wrapBeth.ts @@ -6,12 +6,15 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceWrapBeth(server: McpServer) { - server.tool( + server.registerTool( "BinanceWrapBeth", - "Wrap BETH API allows users to convert BETH into WBETH, providing the wrapped WBETH amount and the exchange rate from BETH to WBETH.", { - amount: z.number().min(0).describe("Amount in BETH, limit 4 decimals (mandatory)"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Wrap BETH API allows users to convert BETH into WBETH, providing the wrapped WBETH amount and the exchange rate from BETH to WBETH.", + inputSchema: { + amount: z.number().min(0).describe("Amount in BETH, limit 4 decimals (mandatory)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-staking/SOL-staking-api/claimBoostRewards.ts b/src/tools/binance-staking/SOL-staking-api/claimBoostRewards.ts index f79e096c..dfb6a7f6 100644 --- a/src/tools/binance-staking/SOL-staking-api/claimBoostRewards.ts +++ b/src/tools/binance-staking/SOL-staking-api/claimBoostRewards.ts @@ -6,11 +6,14 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceClaimBoostRewards(server: McpServer) { - server.tool( + server.registerTool( "BinanceClaimBoostRewards", - "Claim Boost Rewards API allows users to claim their Boost APR airdrop rewards for staking.", { - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Claim Boost Rewards API allows users to claim their Boost APR airdrop rewards for staking.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-staking/SOL-staking-api/getBnsolRateHistory.ts b/src/tools/binance-staking/SOL-staking-api/getBnsolRateHistory.ts index 12381dac..613f8029 100644 --- a/src/tools/binance-staking/SOL-staking-api/getBnsolRateHistory.ts +++ b/src/tools/binance-staking/SOL-staking-api/getBnsolRateHistory.ts @@ -6,28 +6,31 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetBnsolRateHistory(server: McpServer) { - server.tool( + server.registerTool( "registerBinanceGetBnsolRateHistory", - " Get BNSOL Rate History API allows users to retrieve the historical data of the BNSOL staking rate, including APR and exchange rates for SOL to BNSOL.", { - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + " Get BNSOL Rate History API allows users to retrieve the historical data of the BNSOL staking rate, including APR and exchange rates for SOL to BNSOL.", + inputSchema: { + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-staking/SOL-staking-api/getBnsolRewardsHistory.ts b/src/tools/binance-staking/SOL-staking-api/getBnsolRewardsHistory.ts index a11cfcab..a74c3c10 100644 --- a/src/tools/binance-staking/SOL-staking-api/getBnsolRewardsHistory.ts +++ b/src/tools/binance-staking/SOL-staking-api/getBnsolRewardsHistory.ts @@ -6,32 +6,35 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetBnsolRewardsHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetBnsolRewardsHistory", - "Get Boost Rewards History API allows users to retrieve their historical boost rewards data for staking, including the amount of rewards, token type (e.g., SOL), and status of the rewards (e.g., CLAIM, DISTRIBUTE).", { - type: z - .enum(["CLAIM", "DISTRIBUTE"]) - .default("CLAIM") - .describe('Type of action. Must be "CLAIM" or "DISTRIBUTE". Default: "CLAIM"'), - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Get Boost Rewards History API allows users to retrieve their historical boost rewards data for staking, including the amount of rewards, token type (e.g., SOL), and status of the rewards (e.g., CLAIM, DISTRIBUTE).", + inputSchema: { + type: z + .enum(["CLAIM", "DISTRIBUTE"]) + .default("CLAIM") + .describe('Type of action. Must be "CLAIM" or "DISTRIBUTE". Default: "CLAIM"'), + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-staking/SOL-staking-api/getBoostRewardsHistory.ts b/src/tools/binance-staking/SOL-staking-api/getBoostRewardsHistory.ts index 674bcca5..f0d856f9 100644 --- a/src/tools/binance-staking/SOL-staking-api/getBoostRewardsHistory.ts +++ b/src/tools/binance-staking/SOL-staking-api/getBoostRewardsHistory.ts @@ -6,32 +6,35 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetBoostRewardsHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetBoostRewardsHistory", - "Get Boost Rewards History API allows users to retrieve their boost rewards history for staking activities. This includes the amount of rewards received, the token type (e.g., SOL), and the status of the rewards (e.g., CLAIM or DISTRIBUTE).", { - type: z - .enum(["CLAIM", "DISTRIBUTE"]) - .default("CLAIM") - .describe('Type of action. Must be "CLAIM" or "DISTRIBUTE". Default: "CLAIM"'), - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Get Boost Rewards History API allows users to retrieve their boost rewards history for staking activities. This includes the amount of rewards received, the token type (e.g., SOL), and the status of the rewards (e.g., CLAIM or DISTRIBUTE).", + inputSchema: { + type: z + .enum(["CLAIM", "DISTRIBUTE"]) + .default("CLAIM") + .describe('Type of action. Must be "CLAIM" or "DISTRIBUTE". Default: "CLAIM"'), + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-staking/SOL-staking-api/getSolRedemptionHistory.ts b/src/tools/binance-staking/SOL-staking-api/getSolRedemptionHistory.ts index de4997af..678447ab 100644 --- a/src/tools/binance-staking/SOL-staking-api/getSolRedemptionHistory.ts +++ b/src/tools/binance-staking/SOL-staking-api/getSolRedemptionHistory.ts @@ -6,28 +6,31 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetSolRedemptionHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetSolRedemptionHistory", - "Get SOL Redemption History API allows users to retrieve their SOL redemption history, detailing the amount of BNSOL redeemed for SOL and the exchange rate.", { - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Get SOL Redemption History API allows users to retrieve their SOL redemption history, detailing the amount of BNSOL redeemed for SOL and the exchange rate.", + inputSchema: { + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-staking/SOL-staking-api/getSolStakingHistory.ts b/src/tools/binance-staking/SOL-staking-api/getSolStakingHistory.ts index 4ebfba7b..5e059682 100644 --- a/src/tools/binance-staking/SOL-staking-api/getSolStakingHistory.ts +++ b/src/tools/binance-staking/SOL-staking-api/getSolStakingHistory.ts @@ -6,28 +6,31 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetSolStakingHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetSolStakingHistory", - "Get SOL Staking History API allows users to retrieve their SOL staking history, including details about the amount of SOL staked, the equivalent BNSOL amount distributed, the exchange rate, and the status of each staking.", { - startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), - endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), - current: z - .number() - .int() - .min(1) - .default(1) - .optional() - .describe("Currently querying page. Start from 1. Default: 1"), - size: z - .number() - .int() - .min(1) - .max(100) - .default(10) - .optional() - .describe("Number of results per page. Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Get SOL Staking History API allows users to retrieve their SOL staking history, including details about the amount of SOL staked, the equivalent BNSOL amount distributed, the exchange rate, and the status of each staking.", + inputSchema: { + startTime: z.number().int().optional().describe("Start time in milliseconds (optional)"), + endTime: z.number().int().optional().describe("End time in milliseconds (optional)"), + current: z + .number() + .int() + .min(1) + .default(1) + .optional() + .describe("Currently querying page. Start from 1. Default: 1"), + size: z + .number() + .int() + .min(1) + .max(100) + .default(10) + .optional() + .describe("Number of results per page. Default: 10, Max: 100"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-staking/SOL-staking-api/getSolStakingQuotaDetails.ts b/src/tools/binance-staking/SOL-staking-api/getSolStakingQuotaDetails.ts index d2757f96..0caf796c 100644 --- a/src/tools/binance-staking/SOL-staking-api/getSolStakingQuotaDetails.ts +++ b/src/tools/binance-staking/SOL-staking-api/getSolStakingQuotaDetails.ts @@ -6,11 +6,14 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetSolStakingQuotaDetails(server: McpServer) { - server.tool( + server.registerTool( "getSolStakingQuotaDetails", - "Get SOL Staking Quota API allows users to retrieve their current SOL staking quota, including information such as the remaining staking and redemption limits, minimum staking and redeem amounts, commission fees, and the status of staking and redemption availability.", { - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Get SOL Staking Quota API allows users to retrieve their current SOL staking quota, including information such as the remaining staking and redemption limits, minimum staking and redeem amounts, commission fees, and the status of staking and redemption availability.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-staking/SOL-staking-api/getUnclaimedRewards.ts b/src/tools/binance-staking/SOL-staking-api/getUnclaimedRewards.ts index 8d022775..ae1c5241 100644 --- a/src/tools/binance-staking/SOL-staking-api/getUnclaimedRewards.ts +++ b/src/tools/binance-staking/SOL-staking-api/getUnclaimedRewards.ts @@ -6,11 +6,14 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceGetUnclaimedRewards(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetUnclaimedRewards", - "Get Unclaimed Rewards API allows users to retrieve information about unclaimed rewards from their SOL staking activities.", { - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Get Unclaimed Rewards API allows users to retrieve information about unclaimed rewards from their SOL staking activities.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-staking/SOL-staking-api/redeemSol.ts b/src/tools/binance-staking/SOL-staking-api/redeemSol.ts index 9121ac3c..49b98bb8 100644 --- a/src/tools/binance-staking/SOL-staking-api/redeemSol.ts +++ b/src/tools/binance-staking/SOL-staking-api/redeemSol.ts @@ -6,16 +6,19 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceRedeemSol(server: McpServer) { - server.tool( + server.registerTool( "registerBinanceRedeemSol", - " Redeem SOL API allows users to redeem BNSOL and receive SOL in exchange. It enables the conversion of BNSOL tokens into SOL based on the specified amount", { - amount: z - .number() - .min(0) - .max(99999999) - .describe("Amount in BNSOL, limit to 8 decimals (mandatory)"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + " Redeem SOL API allows users to redeem BNSOL and receive SOL in exchange. It enables the conversion of BNSOL tokens into SOL based on the specified amount", + inputSchema: { + amount: z + .number() + .min(0) + .max(99999999) + .describe("Amount in BNSOL, limit to 8 decimals (mandatory)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-staking/SOL-staking-api/solStakingAccount.ts b/src/tools/binance-staking/SOL-staking-api/solStakingAccount.ts index 65e2d89b..54f9a305 100644 --- a/src/tools/binance-staking/SOL-staking-api/solStakingAccount.ts +++ b/src/tools/binance-staking/SOL-staking-api/solStakingAccount.ts @@ -6,11 +6,14 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceSolStakingAccount(server: McpServer) { - server.tool( + server.registerTool( "registerBinanceSolStakingAccount", - "SOL Staking Account API allows users to view their SOL staking account details, including their current BNSOL holdings, equivalent SOL balance, and the profit in SOL over the past 30 days.", { - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "SOL Staking Account API allows users to view their SOL staking account details, including their current BNSOL holdings, equivalent SOL balance, and the profit in SOL over the past 30 days.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-staking/SOL-staking-api/subscribeSolStaking.ts b/src/tools/binance-staking/SOL-staking-api/subscribeSolStaking.ts index 6ac11d78..853b3a46 100644 --- a/src/tools/binance-staking/SOL-staking-api/subscribeSolStaking.ts +++ b/src/tools/binance-staking/SOL-staking-api/subscribeSolStaking.ts @@ -6,12 +6,15 @@ import { z } from "zod"; import { stakingClient } from "../../../config/binanceClient.js"; export function registerBinanceSubscribeSolStaking(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubscribeSolStaking", - "Subscribe SOL Staking API allows users to stake SOL and receive BNSOL in return. This endpoint requires specifying the amount of SOL to stake, and the response includes the equivalent BNSOL amount and exchange rate for SOL to BNSOL.", { - amount: z.number().min(0).describe("Amount in SOL (mandatory)"), - recvWindow: z.number().int().optional().describe("Time window for request validity"), + description: + "Subscribe SOL Staking API allows users to stake SOL and receive BNSOL in return. This endpoint requires specifying the amount of SOL to stake, and the response includes the equivalent BNSOL amount and exchange rate for SOL to BNSOL.", + inputSchema: { + amount: z.number().min(0).describe("Amount in SOL (mandatory)"), + recvWindow: z.number().int().optional().describe("Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-sub-account/assets-api/getFuturesAssetsSummary.ts b/src/tools/binance-sub-account/assets-api/getFuturesAssetsSummary.ts index a65be43e..79c7e55e 100644 --- a/src/tools/binance-sub-account/assets-api/getFuturesAssetsSummary.ts +++ b/src/tools/binance-sub-account/assets-api/getFuturesAssetsSummary.ts @@ -12,15 +12,18 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountFuturesSummary(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountFuturesSummary", - "Get futures account summary for all sub-accounts. Returns total initial margin, maintenance margin, and unrealized PnL.", { - futuresType: z - .enum(["1", "2"]) - .optional() - .describe("Futures type: 1 for USD-M, 2 for COIN-M"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Get futures account summary for all sub-accounts. Returns total initial margin, maintenance margin, and unrealized PnL.", + inputSchema: { + futuresType: z + .enum(["1", "2"]) + .optional() + .describe("Futures type: 1 for USD-M, 2 for COIN-M"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-sub-account/assets-api/getFuturesPositionRisk.ts b/src/tools/binance-sub-account/assets-api/getFuturesPositionRisk.ts index 10eab6ad..39ceb937 100644 --- a/src/tools/binance-sub-account/assets-api/getFuturesPositionRisk.ts +++ b/src/tools/binance-sub-account/assets-api/getFuturesPositionRisk.ts @@ -12,16 +12,19 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountFuturesPositionRisk(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountFuturesPositionRisk", - "Get futures position risk for a sub-account. Shows all open positions with entry price, leverage, unrealized PnL, and liquidation price.", { - email: z.string().email().describe("Sub-account email to query position risk for"), - futuresType: z - .enum(["1", "2"]) - .optional() - .describe("Futures type: 1 for USD-M, 2 for COIN-M"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Get futures position risk for a sub-account. Shows all open positions with entry price, leverage, unrealized PnL, and liquidation price.", + inputSchema: { + email: z.string().email().describe("Sub-account email to query position risk for"), + futuresType: z + .enum(["1", "2"]) + .optional() + .describe("Futures type: 1 for USD-M, 2 for COIN-M"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-sub-account/assets-api/getMarginAssetsSummary.ts b/src/tools/binance-sub-account/assets-api/getMarginAssetsSummary.ts index ea36cc95..d011118b 100644 --- a/src/tools/binance-sub-account/assets-api/getMarginAssetsSummary.ts +++ b/src/tools/binance-sub-account/assets-api/getMarginAssetsSummary.ts @@ -12,11 +12,14 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountMarginSummary(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountMarginSummary", - "Get margin account summary for all sub-accounts. Returns margin level, total assets, and liability information.", { - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Get margin account summary for all sub-accounts. Returns margin level, total assets, and liability information.", + inputSchema: { + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-sub-account/assets-api/getSpotAssetsSummary.ts b/src/tools/binance-sub-account/assets-api/getSpotAssetsSummary.ts index 10bd64e7..959e1eef 100644 --- a/src/tools/binance-sub-account/assets-api/getSpotAssetsSummary.ts +++ b/src/tools/binance-sub-account/assets-api/getSpotAssetsSummary.ts @@ -12,20 +12,23 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountSpotSummary(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountSpotSummary", - "Get spot account summary for all sub-accounts. Returns aggregated BTC value of all sub-account spot wallets.", { - email: z.string().email().optional().describe("Filter by specific sub-account email"), - page: z.number().int().min(1).optional().describe("Page number (starts from 1)"), - size: z - .number() - .int() - .min(1) - .max(20) - .optional() - .describe("Number of results per page (max 20)"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Get spot account summary for all sub-accounts. Returns aggregated BTC value of all sub-account spot wallets.", + inputSchema: { + email: z.string().email().optional().describe("Filter by specific sub-account email"), + page: z.number().int().min(1).optional().describe("Page number (starts from 1)"), + size: z + .number() + .int() + .min(1) + .max(20) + .optional() + .describe("Number of results per page (max 20)"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-sub-account/assets-api/getSubAccountAssets.ts b/src/tools/binance-sub-account/assets-api/getSubAccountAssets.ts index c4e3a561..c2b1a9a4 100644 --- a/src/tools/binance-sub-account/assets-api/getSubAccountAssets.ts +++ b/src/tools/binance-sub-account/assets-api/getSubAccountAssets.ts @@ -12,12 +12,15 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountAssets(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountAssets", - "Get detailed asset balances for a specific sub-account. Shows all tokens and their free/locked amounts.", { - email: z.string().email().describe("Sub-account email to query assets for"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Get detailed asset balances for a specific sub-account. Shows all tokens and their free/locked amounts.", + inputSchema: { + email: z.string().email().describe("Sub-account email to query assets for"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-sub-account/createApiKey.ts b/src/tools/binance-sub-account/createApiKey.ts index d658a8a6..ef533aa4 100644 --- a/src/tools/binance-sub-account/createApiKey.ts +++ b/src/tools/binance-sub-account/createApiKey.ts @@ -6,15 +6,17 @@ import { z } from "zod"; import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountCreateApiKey(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountCreateApiKey", - "Create API key for a sub-account.", { - subAccountId: z.string().describe("Sub-account ID"), - canTrade: z.boolean().describe("Enable spot and margin trading"), - marginTrade: z.boolean().optional().describe("Enable margin loan, repay and transfer"), - futuresTrade: z.boolean().optional().describe("Enable futures trading"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Create API key for a sub-account.", + inputSchema: { + subAccountId: z.string().describe("Sub-account ID"), + canTrade: z.boolean().describe("Enable spot and margin trading"), + marginTrade: z.boolean().optional().describe("Enable margin loan, repay and transfer"), + futuresTrade: z.boolean().optional().describe("Enable futures trading"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ subAccountId, canTrade, marginTrade, futuresTrade, recvWindow }) => { try { diff --git a/src/tools/binance-sub-account/createVirtualSubAccount.ts b/src/tools/binance-sub-account/createVirtualSubAccount.ts index 252c33df..8b7938f7 100644 --- a/src/tools/binance-sub-account/createVirtualSubAccount.ts +++ b/src/tools/binance-sub-account/createVirtualSubAccount.ts @@ -6,12 +6,15 @@ import { z } from "zod"; import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountCreateVirtual(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountCreateVirtual", - "Create a virtual sub-account under the master account. Requires master account API key.", { - subAccountString: z.string().describe("The email address for the virtual sub-account"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: + "Create a virtual sub-account under the master account. Requires master account API key.", + inputSchema: { + subAccountString: z.string().describe("The email address for the virtual sub-account"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ subAccountString, recvWindow }) => { try { diff --git a/src/tools/binance-sub-account/deleteApiKey.ts b/src/tools/binance-sub-account/deleteApiKey.ts index be04c9f9..80674457 100644 --- a/src/tools/binance-sub-account/deleteApiKey.ts +++ b/src/tools/binance-sub-account/deleteApiKey.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountDeleteApiKey(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountDeleteApiKey", - "Delete API key for a sub-account.", { - subAccountId: z.string().describe("Sub-account ID"), - subAccountApiKey: z.string().describe("API key to delete"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Delete API key for a sub-account.", + inputSchema: { + subAccountId: z.string().describe("Sub-account ID"), + subAccountApiKey: z.string().describe("API key to delete"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ subAccountId, subAccountApiKey, recvWindow }) => { try { diff --git a/src/tools/binance-sub-account/deposit-api/getDepositAddress.ts b/src/tools/binance-sub-account/deposit-api/getDepositAddress.ts index 9be5dde0..9ba5d4e7 100644 --- a/src/tools/binance-sub-account/deposit-api/getDepositAddress.ts +++ b/src/tools/binance-sub-account/deposit-api/getDepositAddress.ts @@ -12,14 +12,17 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountDepositAddress(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountDepositAddress", - "Get deposit address for a sub-account. Returns the address and tag/memo if required for the specified asset and network.", { - email: z.string().email().describe("Sub-account email to get deposit address for"), - coin: z.string().describe("Coin/asset to get deposit address for (e.g., 'BTC', 'ETH')"), - network: z.string().optional().describe("Network (e.g., 'BTC', 'ETH', 'TRX', 'BSC')"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Get deposit address for a sub-account. Returns the address and tag/memo if required for the specified asset and network.", + inputSchema: { + email: z.string().email().describe("Sub-account email to get deposit address for"), + coin: z.string().describe("Coin/asset to get deposit address for (e.g., 'BTC', 'ETH')"), + network: z.string().optional().describe("Network (e.g., 'BTC', 'ETH', 'TRX', 'BSC')"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-sub-account/deposit-api/getDepositHistory.ts b/src/tools/binance-sub-account/deposit-api/getDepositHistory.ts index 4c8f02a4..c464729c 100644 --- a/src/tools/binance-sub-account/deposit-api/getDepositHistory.ts +++ b/src/tools/binance-sub-account/deposit-api/getDepositHistory.ts @@ -12,21 +12,30 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountDepositHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountDepositHistory", - "Get deposit history for a sub-account. Shows all incoming deposits with status, txid, and confirmation details.", { - email: z.string().email().describe("Sub-account email to get deposit history for"), - coin: z.string().optional().describe("Filter by specific coin"), - status: z - .enum(["0", "1", "6"]) - .optional() - .describe("Filter by status: 0 = pending, 1 = success, 6 = credited but cannot withdraw"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - limit: z.number().int().min(1).max(1000).optional().describe("Number of results (max 1000)"), - offset: z.number().int().optional().describe("Offset for pagination"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Get deposit history for a sub-account. Shows all incoming deposits with status, txid, and confirmation details.", + inputSchema: { + email: z.string().email().describe("Sub-account email to get deposit history for"), + coin: z.string().optional().describe("Filter by specific coin"), + status: z + .enum(["0", "1", "6"]) + .optional() + .describe("Filter by status: 0 = pending, 1 = success, 6 = credited but cannot withdraw"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + limit: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .describe("Number of results (max 1000)"), + offset: z.number().int().optional().describe("Offset for pagination"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-sub-account/enableFutures.ts b/src/tools/binance-sub-account/enableFutures.ts index 978ce66e..4d283701 100644 --- a/src/tools/binance-sub-account/enableFutures.ts +++ b/src/tools/binance-sub-account/enableFutures.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountEnableFutures(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountEnableFutures", - "Enable futures trading for a sub-account.", { - email: z.string().describe("Sub-account email"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Enable futures trading for a sub-account.", + inputSchema: { + email: z.string().describe("Sub-account email"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ email, recvWindow }) => { try { diff --git a/src/tools/binance-sub-account/enableMargin.ts b/src/tools/binance-sub-account/enableMargin.ts index 124fc4bb..9747f3c2 100644 --- a/src/tools/binance-sub-account/enableMargin.ts +++ b/src/tools/binance-sub-account/enableMargin.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountEnableMargin(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountEnableMargin", - "Enable margin trading for a sub-account.", { - email: z.string().describe("Sub-account email"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Enable margin trading for a sub-account.", + inputSchema: { + email: z.string().describe("Sub-account email"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ email, recvWindow }) => { try { diff --git a/src/tools/binance-sub-account/getApiKeyIpRestriction.ts b/src/tools/binance-sub-account/getApiKeyIpRestriction.ts index c082df43..e39fce1d 100644 --- a/src/tools/binance-sub-account/getApiKeyIpRestriction.ts +++ b/src/tools/binance-sub-account/getApiKeyIpRestriction.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountGetApiKeyIpRestriction(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountGetApiKeyIpRestriction", - "Get IP restriction for a sub-account API key.", { - subAccountId: z.string().describe("Sub-account ID"), - subAccountApiKey: z.string().describe("Sub-account API key"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get IP restriction for a sub-account API key.", + inputSchema: { + subAccountId: z.string().describe("Sub-account ID"), + subAccountApiKey: z.string().describe("Sub-account API key"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ subAccountId, subAccountApiKey, recvWindow }) => { try { diff --git a/src/tools/binance-sub-account/getSubAccountAssets.ts b/src/tools/binance-sub-account/getSubAccountAssets.ts index 91cb988a..1b16d3f4 100644 --- a/src/tools/binance-sub-account/getSubAccountAssets.ts +++ b/src/tools/binance-sub-account/getSubAccountAssets.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountGetAssets(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountGetAssets", - "Query sub-account assets (balances).", { - email: z.string().describe("Sub-account email"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Query sub-account assets (balances).", + inputSchema: { + email: z.string().describe("Sub-account email"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ email, recvWindow }) => { try { diff --git a/src/tools/binance-sub-account/getSubAccountDepositAddress.ts b/src/tools/binance-sub-account/getSubAccountDepositAddress.ts index 2c90f5d5..7a6a6f35 100644 --- a/src/tools/binance-sub-account/getSubAccountDepositAddress.ts +++ b/src/tools/binance-sub-account/getSubAccountDepositAddress.ts @@ -6,14 +6,16 @@ import { z } from "zod"; import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountGetDepositAddress(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountGetDepositAddress", - "Get sub-account deposit address for a specific coin.", { - email: z.string().describe("Sub-account email"), - coin: z.string().describe("Coin to get deposit address for (e.g., BTC, ETH)"), - network: z.string().optional().describe("Network to use (e.g., BTC, ETH, BSC)"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get sub-account deposit address for a specific coin.", + inputSchema: { + email: z.string().describe("Sub-account email"), + coin: z.string().describe("Coin to get deposit address for (e.g., BTC, ETH)"), + network: z.string().optional().describe("Network to use (e.g., BTC, ETH, BSC)"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ email, coin, network, recvWindow }) => { try { diff --git a/src/tools/binance-sub-account/getSubAccountDepositHistory.ts b/src/tools/binance-sub-account/getSubAccountDepositHistory.ts index 250653f5..cfbb2903 100644 --- a/src/tools/binance-sub-account/getSubAccountDepositHistory.ts +++ b/src/tools/binance-sub-account/getSubAccountDepositHistory.ts @@ -6,21 +6,23 @@ import { z } from "zod"; import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountGetDepositHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountGetDepositHistory", - "Query sub-account deposit history.", { - email: z.string().describe("Sub-account email"), - coin: z.string().optional().describe("Coin to filter by"), - status: z - .number() - .optional() - .describe("0: pending, 6: credited but cannot withdraw, 1: success"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500, max 500"), - offset: z.number().optional().describe("Default 0"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Query sub-account deposit history.", + inputSchema: { + email: z.string().describe("Sub-account email"), + coin: z.string().optional().describe("Coin to filter by"), + status: z + .number() + .optional() + .describe("0: pending, 6: credited but cannot withdraw, 1: success"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500, max 500"), + offset: z.number().optional().describe("Default 0"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ email, coin, status, startTime, endTime, limit, offset, recvWindow }) => { try { diff --git a/src/tools/binance-sub-account/getSubAccountFuturesPositionRisk.ts b/src/tools/binance-sub-account/getSubAccountFuturesPositionRisk.ts index 126807e3..105312bb 100644 --- a/src/tools/binance-sub-account/getSubAccountFuturesPositionRisk.ts +++ b/src/tools/binance-sub-account/getSubAccountFuturesPositionRisk.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountGetFuturesPositionRisk(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountGetFuturesPositionRisk", - "Query sub-account futures position risk.", { - email: z.string().describe("Sub-account email"), - futuresType: z - .number() - .optional() - .describe("1: USDT Margined Futures, 2: COIN Margined Futures"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Query sub-account futures position risk.", + inputSchema: { + email: z.string().describe("Sub-account email"), + futuresType: z + .number() + .optional() + .describe("1: USDT Margined Futures, 2: COIN Margined Futures"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ email, futuresType, recvWindow }) => { try { diff --git a/src/tools/binance-sub-account/getSubAccountFuturesSummary.ts b/src/tools/binance-sub-account/getSubAccountFuturesSummary.ts index e10638b4..e372c430 100644 --- a/src/tools/binance-sub-account/getSubAccountFuturesSummary.ts +++ b/src/tools/binance-sub-account/getSubAccountFuturesSummary.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountGetFuturesSummary(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountGetFuturesSummary", - "Query sub-account futures account summary.", { - email: z.string().optional().describe("Sub-account email (optional)"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Query sub-account futures account summary.", + inputSchema: { + email: z.string().optional().describe("Sub-account email (optional)"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ email, recvWindow }) => { try { diff --git a/src/tools/binance-sub-account/getSubAccountList.ts b/src/tools/binance-sub-account/getSubAccountList.ts index aa55a038..c2cf3c2e 100644 --- a/src/tools/binance-sub-account/getSubAccountList.ts +++ b/src/tools/binance-sub-account/getSubAccountList.ts @@ -6,15 +6,17 @@ import { z } from "zod"; import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountGetList(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountGetList", - "Query the list of sub-accounts under the master account.", { - email: z.string().optional().describe("Sub-account email to filter"), - isFreeze: z.string().optional().describe("Filter by freeze status: 'true' or 'false'"), - page: z.number().optional().describe("Page number, default 1"), - limit: z.number().optional().describe("Results per page, default 1, max 200"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Query the list of sub-accounts under the master account.", + inputSchema: { + email: z.string().optional().describe("Sub-account email to filter"), + isFreeze: z.string().optional().describe("Filter by freeze status: 'true' or 'false'"), + page: z.number().optional().describe("Page number, default 1"), + limit: z.number().optional().describe("Results per page, default 1, max 200"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ email, isFreeze, page, limit, recvWindow }) => { try { diff --git a/src/tools/binance-sub-account/getSubAccountMarginSummary.ts b/src/tools/binance-sub-account/getSubAccountMarginSummary.ts index f3e303ce..a00e307b 100644 --- a/src/tools/binance-sub-account/getSubAccountMarginSummary.ts +++ b/src/tools/binance-sub-account/getSubAccountMarginSummary.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountGetMarginSummary(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountGetMarginSummary", - "Query sub-account margin account summary.", { - email: z.string().optional().describe("Sub-account email (optional)"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Query sub-account margin account summary.", + inputSchema: { + email: z.string().optional().describe("Sub-account email (optional)"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ email, recvWindow }) => { try { diff --git a/src/tools/binance-sub-account/getSubAccountSpotSummary.ts b/src/tools/binance-sub-account/getSubAccountSpotSummary.ts index e99e97e8..ca6399a8 100644 --- a/src/tools/binance-sub-account/getSubAccountSpotSummary.ts +++ b/src/tools/binance-sub-account/getSubAccountSpotSummary.ts @@ -6,17 +6,19 @@ import { z } from "zod"; import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountGetSpotSummary(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountGetSpotSummary", - "Query sub-account spot assets summary for master account.", { - email: z - .string() - .optional() - .describe("Sub-account email (optional, returns all if not provided)"), - page: z.number().optional().describe("Page number, default 1"), - size: z.number().optional().describe("Results per page, default 10, max 20"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Query sub-account spot assets summary for master account.", + inputSchema: { + email: z + .string() + .optional() + .describe("Sub-account email (optional, returns all if not provided)"), + page: z.number().optional().describe("Page number, default 1"), + size: z.number().optional().describe("Results per page, default 10, max 20"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ email, page, size, recvWindow }) => { try { diff --git a/src/tools/binance-sub-account/getSubAccountStatus.ts b/src/tools/binance-sub-account/getSubAccountStatus.ts index bd04800d..55108b8f 100644 --- a/src/tools/binance-sub-account/getSubAccountStatus.ts +++ b/src/tools/binance-sub-account/getSubAccountStatus.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountGetStatus(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountGetStatus", - "Get sub-account status including enable/disable status for margin and futures.", { - email: z.string().optional().describe("Sub-account email (optional)"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get sub-account status including enable/disable status for margin and futures.", + inputSchema: { + email: z.string().optional().describe("Sub-account email (optional)"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ email, recvWindow }) => { try { diff --git a/src/tools/binance-sub-account/getSubAccountTransferHistory.ts b/src/tools/binance-sub-account/getSubAccountTransferHistory.ts index 186934a2..4477fefa 100644 --- a/src/tools/binance-sub-account/getSubAccountTransferHistory.ts +++ b/src/tools/binance-sub-account/getSubAccountTransferHistory.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountGetTransferHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountGetTransferHistory", - "Query sub-account transfer history.", { - asset: z.string().optional().describe("Asset to filter by"), - type: z.number().optional().describe("1: transfer in, 2: transfer out"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 500, max 500"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Query sub-account transfer history.", + inputSchema: { + asset: z.string().optional().describe("Asset to filter by"), + type: z.number().optional().describe("1: transfer in, 2: transfer out"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 500, max 500"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ asset, type, startTime, endTime, limit, recvWindow }) => { try { diff --git a/src/tools/binance-sub-account/getUniversalTransferHistory.ts b/src/tools/binance-sub-account/getUniversalTransferHistory.ts index b9200bc3..7fc1bfd7 100644 --- a/src/tools/binance-sub-account/getUniversalTransferHistory.ts +++ b/src/tools/binance-sub-account/getUniversalTransferHistory.ts @@ -6,17 +6,19 @@ import { z } from "zod"; import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountGetUniversalTransferHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountGetUniversalTransferHistory", - "Query universal transfer history for sub-accounts.", { - fromEmail: z.string().optional().describe("Sender email"), - toEmail: z.string().optional().describe("Recipient email"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - page: z.number().optional().describe("Page number, default 1"), - limit: z.number().optional().describe("Results per page, default 500, max 500"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Query universal transfer history for sub-accounts.", + inputSchema: { + fromEmail: z.string().optional().describe("Sender email"), + toEmail: z.string().optional().describe("Recipient email"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + page: z.number().optional().describe("Page number, default 1"), + limit: z.number().optional().describe("Results per page, default 500, max 500"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ fromEmail, toEmail, startTime, endTime, page, limit, recvWindow }) => { try { diff --git a/src/tools/binance-sub-account/management-api/createSubAccount.ts b/src/tools/binance-sub-account/management-api/createSubAccount.ts index f29b6dd3..4e7755ef 100644 --- a/src/tools/binance-sub-account/management-api/createSubAccount.ts +++ b/src/tools/binance-sub-account/management-api/createSubAccount.ts @@ -12,16 +12,19 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountCreate(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountCreate", - "Create a new virtual sub-account under your master account. Sub-accounts are useful for separating trading strategies or managing funds for different purposes. ⚠️ Requires master account permissions.", { - subAccountString: z - .string() - .min(1) - .max(20) - .describe("Sub-account name/label (1-20 characters, alphanumeric)"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Create a new virtual sub-account under your master account. Sub-accounts are useful for separating trading strategies or managing funds for different purposes. ⚠️ Requires master account permissions.", + inputSchema: { + subAccountString: z + .string() + .min(1) + .max(20) + .describe("Sub-account name/label (1-20 characters, alphanumeric)"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-sub-account/management-api/enableFutures.ts b/src/tools/binance-sub-account/management-api/enableFutures.ts index 439c2ae4..2f3c79c5 100644 --- a/src/tools/binance-sub-account/management-api/enableFutures.ts +++ b/src/tools/binance-sub-account/management-api/enableFutures.ts @@ -12,12 +12,15 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountEnableFutures(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountEnableFutures", - "Enable futures trading for a sub-account. ⚠️ WARNING: Futures trading involves leverage and carries significant risk of total loss. Only enable if you understand the risks.", { - email: z.string().email().describe("Sub-account email to enable futures for"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Enable futures trading for a sub-account. ⚠️ WARNING: Futures trading involves leverage and carries significant risk of total loss. Only enable if you understand the risks.", + inputSchema: { + email: z.string().email().describe("Sub-account email to enable futures for"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-sub-account/management-api/enableMargin.ts b/src/tools/binance-sub-account/management-api/enableMargin.ts index b4acc9a0..eb993d9e 100644 --- a/src/tools/binance-sub-account/management-api/enableMargin.ts +++ b/src/tools/binance-sub-account/management-api/enableMargin.ts @@ -12,12 +12,15 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountEnableMargin(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountEnableMargin", - "Enable margin trading for a sub-account. ⚠️ WARNING: Margin trading involves leverage and carries significant risk of loss. Only enable if you understand the risks.", { - email: z.string().email().describe("Sub-account email to enable margin for"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Enable margin trading for a sub-account. ⚠️ WARNING: Margin trading involves leverage and carries significant risk of loss. Only enable if you understand the risks.", + inputSchema: { + email: z.string().email().describe("Sub-account email to enable margin for"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-sub-account/management-api/getSubAccountApiPermission.ts b/src/tools/binance-sub-account/management-api/getSubAccountApiPermission.ts index a0445829..4d018a0d 100644 --- a/src/tools/binance-sub-account/management-api/getSubAccountApiPermission.ts +++ b/src/tools/binance-sub-account/management-api/getSubAccountApiPermission.ts @@ -12,13 +12,16 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountApiPermission(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountApiPermission", - "Get API key permissions for a sub-account. Shows what operations the API key is allowed to perform.", { - email: z.string().email().describe("Sub-account email to query API permissions for"), - subAccountApiKey: z.string().describe("Sub-account API key to check permissions for"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Get API key permissions for a sub-account. Shows what operations the API key is allowed to perform.", + inputSchema: { + email: z.string().email().describe("Sub-account email to query API permissions for"), + subAccountApiKey: z.string().describe("Sub-account API key to check permissions for"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-sub-account/management-api/getSubAccountList.ts b/src/tools/binance-sub-account/management-api/getSubAccountList.ts index bf73bbb6..161f18ca 100644 --- a/src/tools/binance-sub-account/management-api/getSubAccountList.ts +++ b/src/tools/binance-sub-account/management-api/getSubAccountList.ts @@ -12,21 +12,24 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountList(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountList", - "Get a list of all sub-accounts under your master account. Returns email, status, and creation time for each sub-account.", { - email: z.string().email().optional().describe("Filter by specific sub-account email"), - isFreeze: z.enum(["true", "false"]).optional().describe("Filter by freeze status"), - page: z.number().int().min(1).optional().describe("Page number (starts from 1)"), - limit: z - .number() - .int() - .min(1) - .max(200) - .optional() - .describe("Number of results per page (max 200)"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Get a list of all sub-accounts under your master account. Returns email, status, and creation time for each sub-account.", + inputSchema: { + email: z.string().email().optional().describe("Filter by specific sub-account email"), + isFreeze: z.enum(["true", "false"]).optional().describe("Filter by freeze status"), + page: z.number().int().min(1).optional().describe("Page number (starts from 1)"), + limit: z + .number() + .int() + .min(1) + .max(200) + .optional() + .describe("Number of results per page (max 200)"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-sub-account/management-api/getSubAccountStatus.ts b/src/tools/binance-sub-account/management-api/getSubAccountStatus.ts index c8bf7663..4ae86218 100644 --- a/src/tools/binance-sub-account/management-api/getSubAccountStatus.ts +++ b/src/tools/binance-sub-account/management-api/getSubAccountStatus.ts @@ -12,12 +12,15 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountStatus(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountStatus", - "Get the status of a sub-account including enabled features (margin, futures, etc.) and trading permissions.", { - email: z.string().email().optional().describe("Sub-account email to query"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Get the status of a sub-account including enabled features (margin, futures, etc.) and trading permissions.", + inputSchema: { + email: z.string().email().optional().describe("Sub-account email to query"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-sub-account/transfer-api/futuresTransfer.ts b/src/tools/binance-sub-account/transfer-api/futuresTransfer.ts index d10a66bf..359961ec 100644 --- a/src/tools/binance-sub-account/transfer-api/futuresTransfer.ts +++ b/src/tools/binance-sub-account/transfer-api/futuresTransfer.ts @@ -12,16 +12,19 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountFuturesTransfer(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountFuturesTransfer", - "Internal transfer between sub-account futures accounts. Move assets between different sub-account futures wallets.", { - fromEmail: z.string().email().describe("Sender sub-account email"), - toEmail: z.string().email().describe("Recipient sub-account email"), - futuresType: z.enum(["1", "2"]).describe("Futures type: 1 for USD-M, 2 for COIN-M"), - asset: z.string().describe("Asset to transfer (e.g., 'USDT', 'BTC')"), - amount: z.number().positive().describe("Amount to transfer"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Internal transfer between sub-account futures accounts. Move assets between different sub-account futures wallets.", + inputSchema: { + fromEmail: z.string().email().describe("Sender sub-account email"), + toEmail: z.string().email().describe("Recipient sub-account email"), + futuresType: z.enum(["1", "2"]).describe("Futures type: 1 for USD-M, 2 for COIN-M"), + asset: z.string().describe("Asset to transfer (e.g., 'USDT', 'BTC')"), + amount: z.number().positive().describe("Amount to transfer"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-sub-account/transfer-api/getTransferHistory.ts b/src/tools/binance-sub-account/transfer-api/getTransferHistory.ts index fdfb6df8..d24af063 100644 --- a/src/tools/binance-sub-account/transfer-api/getTransferHistory.ts +++ b/src/tools/binance-sub-account/transfer-api/getTransferHistory.ts @@ -12,19 +12,22 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountTransferHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountTransferHistory", - "Get transfer history for sub-accounts. Shows all internal transfers between master and sub-accounts.", { - asset: z.string().optional().describe("Filter by specific asset"), - type: z - .enum(["1", "2"]) - .optional() - .describe("Transfer type: 1 = transfer in, 2 = transfer out"), - startTime: z.number().int().optional().describe("Start timestamp in ms"), - endTime: z.number().int().optional().describe("End timestamp in ms"), - limit: z.number().int().min(1).max(500).optional().describe("Number of results (max 500)"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Get transfer history for sub-accounts. Shows all internal transfers between master and sub-accounts.", + inputSchema: { + asset: z.string().optional().describe("Filter by specific asset"), + type: z + .enum(["1", "2"]) + .optional() + .describe("Transfer type: 1 = transfer in, 2 = transfer out"), + startTime: z.number().int().optional().describe("Start timestamp in ms"), + endTime: z.number().int().optional().describe("End timestamp in ms"), + limit: z.number().int().min(1).max(500).optional().describe("Number of results (max 500)"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-sub-account/transfer-api/transferToMaster.ts b/src/tools/binance-sub-account/transfer-api/transferToMaster.ts index 543c4cc0..3ea3d0e6 100644 --- a/src/tools/binance-sub-account/transfer-api/transferToMaster.ts +++ b/src/tools/binance-sub-account/transfer-api/transferToMaster.ts @@ -12,13 +12,15 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountTransferToMaster(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountTransferToMaster", - "Transfer assets from a sub-account back to the master account.", { - asset: z.string().describe("Asset to transfer (e.g., 'BTC', 'USDT')"), - amount: z.number().positive().describe("Amount to transfer"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: "Transfer assets from a sub-account back to the master account.", + inputSchema: { + asset: z.string().describe("Asset to transfer (e.g., 'BTC', 'USDT')"), + amount: z.number().positive().describe("Amount to transfer"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-sub-account/transfer-api/transferToSubAccount.ts b/src/tools/binance-sub-account/transfer-api/transferToSubAccount.ts index 6e2791ac..e0838b8b 100644 --- a/src/tools/binance-sub-account/transfer-api/transferToSubAccount.ts +++ b/src/tools/binance-sub-account/transfer-api/transferToSubAccount.ts @@ -12,14 +12,17 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountTransferToSub(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountTransferToSub", - "Transfer assets from one sub-account to another sub-account. Both accounts must belong to the same master account.", { - toEmail: z.string().email().describe("Recipient sub-account email"), - asset: z.string().describe("Asset to transfer (e.g., 'BTC', 'USDT')"), - amount: z.number().positive().describe("Amount to transfer"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Transfer assets from one sub-account to another sub-account. Both accounts must belong to the same master account.", + inputSchema: { + toEmail: z.string().email().describe("Recipient sub-account email"), + asset: z.string().describe("Asset to transfer (e.g., 'BTC', 'USDT')"), + amount: z.number().positive().describe("Amount to transfer"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-sub-account/transfer-api/universalTransfer.ts b/src/tools/binance-sub-account/transfer-api/universalTransfer.ts index acb3e719..af835961 100644 --- a/src/tools/binance-sub-account/transfer-api/universalTransfer.ts +++ b/src/tools/binance-sub-account/transfer-api/universalTransfer.ts @@ -12,31 +12,34 @@ import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceSubAccountUniversalTransfer(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountUniversalTransfer", - "Universal transfer between master account and sub-accounts, supporting various account types (spot, margin, futures, etc.).", { - fromEmail: z - .string() - .email() - .optional() - .describe("Sender email (leave empty for master account)"), - toEmail: z - .string() - .email() - .optional() - .describe("Recipient email (leave empty for master account)"), - fromAccountType: z - .enum(["SPOT", "USDT_FUTURE", "COIN_FUTURE", "MARGIN", "ISOLATED_MARGIN"]) - .describe("Source account type"), - toAccountType: z - .enum(["SPOT", "USDT_FUTURE", "COIN_FUTURE", "MARGIN", "ISOLATED_MARGIN"]) - .describe("Destination account type"), - clientTranId: z.string().optional().describe("Client transfer ID for idempotency"), - symbol: z.string().optional().describe("Required for isolated margin transfers"), - asset: z.string().describe("Asset to transfer (e.g., 'BTC', 'USDT')"), - amount: z.number().positive().describe("Amount to transfer"), - recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + description: + "Universal transfer between master account and sub-accounts, supporting various account types (spot, margin, futures, etc.).", + inputSchema: { + fromEmail: z + .string() + .email() + .optional() + .describe("Sender email (leave empty for master account)"), + toEmail: z + .string() + .email() + .optional() + .describe("Recipient email (leave empty for master account)"), + fromAccountType: z + .enum(["SPOT", "USDT_FUTURE", "COIN_FUTURE", "MARGIN", "ISOLATED_MARGIN"]) + .describe("Source account type"), + toAccountType: z + .enum(["SPOT", "USDT_FUTURE", "COIN_FUTURE", "MARGIN", "ISOLATED_MARGIN"]) + .describe("Destination account type"), + clientTranId: z.string().optional().describe("Client transfer ID for idempotency"), + symbol: z.string().optional().describe("Required for isolated margin transfers"), + asset: z.string().describe("Asset to transfer (e.g., 'BTC', 'USDT')"), + amount: z.number().positive().describe("Amount to transfer"), + recvWindow: z.number().int().optional().describe("Time window for request validity in ms"), + }, }, async (params) => { try { diff --git a/src/tools/binance-sub-account/transferToMaster.ts b/src/tools/binance-sub-account/transferToMaster.ts index 71c48e31..20c3ab8e 100644 --- a/src/tools/binance-sub-account/transferToMaster.ts +++ b/src/tools/binance-sub-account/transferToMaster.ts @@ -6,13 +6,16 @@ import { z } from "zod"; import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountTransferToMaster(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountTransferToMaster", - "Transfer assets from sub-account to master account (SPOT). Must be called from sub-account API key.", { - asset: z.string().describe("Asset to transfer (e.g., BTC, USDT)"), - amount: z.number().describe("Amount to transfer"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: + "Transfer assets from sub-account to master account (SPOT). Must be called from sub-account API key.", + inputSchema: { + asset: z.string().describe("Asset to transfer (e.g., BTC, USDT)"), + amount: z.number().describe("Amount to transfer"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ asset, amount, recvWindow }) => { try { diff --git a/src/tools/binance-sub-account/transferToSubAccount.ts b/src/tools/binance-sub-account/transferToSubAccount.ts index 92becfec..863fa984 100644 --- a/src/tools/binance-sub-account/transferToSubAccount.ts +++ b/src/tools/binance-sub-account/transferToSubAccount.ts @@ -6,14 +6,16 @@ import { z } from "zod"; import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountTransferToSub(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountTransferToSub", - "Transfer assets from master account to sub-account (SPOT).", { - toEmail: z.string().describe("Sub-account email to transfer to"), - asset: z.string().describe("Asset to transfer (e.g., BTC, USDT)"), - amount: z.number().describe("Amount to transfer"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Transfer assets from master account to sub-account (SPOT).", + inputSchema: { + toEmail: z.string().describe("Sub-account email to transfer to"), + asset: z.string().describe("Asset to transfer (e.g., BTC, USDT)"), + amount: z.number().describe("Amount to transfer"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ toEmail, asset, amount, recvWindow }) => { try { diff --git a/src/tools/binance-sub-account/universalTransfer.ts b/src/tools/binance-sub-account/universalTransfer.ts index 9ef25a44..c3aff19b 100644 --- a/src/tools/binance-sub-account/universalTransfer.ts +++ b/src/tools/binance-sub-account/universalTransfer.ts @@ -6,27 +6,29 @@ import { z } from "zod"; import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountUniversalTransfer(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountUniversalTransfer", - "Universal transfer between sub-accounts or between master and sub-accounts.", { - fromEmail: z.string().optional().describe("Sender email (leave empty for master account)"), - toEmail: z.string().optional().describe("Recipient email (leave empty for master account)"), - fromAccountType: z - .string() - .describe("Sender account type: SPOT, USDT_FUTURE, COIN_FUTURE, MARGIN, ISOLATED_MARGIN"), - toAccountType: z - .string() - .describe( - "Recipient account type: SPOT, USDT_FUTURE, COIN_FUTURE, MARGIN, ISOLATED_MARGIN", - ), - asset: z.string().describe("Asset to transfer"), - amount: z.number().describe("Amount to transfer"), - symbol: z - .string() - .optional() - .describe("Required when fromAccountType or toAccountType is ISOLATED_MARGIN"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Universal transfer between sub-accounts or between master and sub-accounts.", + inputSchema: { + fromEmail: z.string().optional().describe("Sender email (leave empty for master account)"), + toEmail: z.string().optional().describe("Recipient email (leave empty for master account)"), + fromAccountType: z + .string() + .describe("Sender account type: SPOT, USDT_FUTURE, COIN_FUTURE, MARGIN, ISOLATED_MARGIN"), + toAccountType: z + .string() + .describe( + "Recipient account type: SPOT, USDT_FUTURE, COIN_FUTURE, MARGIN, ISOLATED_MARGIN", + ), + asset: z.string().describe("Asset to transfer"), + amount: z.number().describe("Amount to transfer"), + symbol: z + .string() + .optional() + .describe("Required when fromAccountType or toAccountType is ISOLATED_MARGIN"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ fromEmail, diff --git a/src/tools/binance-sub-account/updateIpRestriction.ts b/src/tools/binance-sub-account/updateIpRestriction.ts index a2226bc5..227fc350 100644 --- a/src/tools/binance-sub-account/updateIpRestriction.ts +++ b/src/tools/binance-sub-account/updateIpRestriction.ts @@ -6,15 +6,17 @@ import { z } from "zod"; import { subAccountApiClient } from "../../config/binanceClient.js"; export function registerBinanceSubAccountUpdateIpRestriction(server: McpServer) { - server.tool( + server.registerTool( "BinanceSubAccountUpdateIpRestriction", - "Update IP restriction for a sub-account API key.", { - subAccountId: z.string().describe("Sub-account ID"), - subAccountApiKey: z.string().describe("Sub-account API key"), - status: z.string().describe("IP restriction status: 1 - Restrict by IP, 2 - Unrestrict"), - ipAddress: z.string().optional().describe("IP address (comma-separated for multiple)"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Update IP restriction for a sub-account API key.", + inputSchema: { + subAccountId: z.string().describe("Sub-account ID"), + subAccountApiKey: z.string().describe("Sub-account API key"), + status: z.string().describe("IP restriction status: 1 - Restrict by IP, 2 - Unrestrict"), + ipAddress: z.string().optional().describe("IP address (comma-separated for multiple)"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ subAccountId, subAccountApiKey, status, ipAddress, recvWindow }) => { try { diff --git a/src/tools/binance-vip-loan/market-api/getBorrowInterestRate.ts b/src/tools/binance-vip-loan/market-api/getBorrowInterestRate.ts index d4c0a1c7..44d6f45d 100644 --- a/src/tools/binance-vip-loan/market-api/getBorrowInterestRate.ts +++ b/src/tools/binance-vip-loan/market-api/getBorrowInterestRate.ts @@ -6,12 +6,19 @@ import { z } from "zod"; import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceGetBorrowInterestRate(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetBorrowInterestRate", - "Retrieves the interest rates for borrowing assets. It provides both daily and yearly interest rates for multiple assets (e.g., BUSD, BTC). You can specify the assets by using a comma-separated list.", { - loanCoin: z.string().min(1).describe("Max 10 assets, multiple split by ','"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Retrieves the interest rates for borrowing assets. It provides both daily and yearly interest rates for multiple assets (e.g., BUSD, BTC). You can specify the assets by using a comma-separated list.", + inputSchema: { + loanCoin: z.string().min(1).describe("Max 10 assets, multiple split by ','"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-vip-loan/market-api/getCollateralAssetData.ts b/src/tools/binance-vip-loan/market-api/getCollateralAssetData.ts index 012f657a..2c87c84c 100644 --- a/src/tools/binance-vip-loan/market-api/getCollateralAssetData.ts +++ b/src/tools/binance-vip-loan/market-api/getCollateralAssetData.ts @@ -6,12 +6,19 @@ import { z } from "zod"; import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceGetCollateralAssetData(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetCollateralAssetData", - "Retrieves information about collateral assets, including collateral ratios and range values for different tiers of collateral. The ratios are used to determine the collateral requirement for various levels of borrowing.", { - collateralCoin: z.string().optional().describe("Optional: Coin used as collateral"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Retrieves information about collateral assets, including collateral ratios and range values for different tiers of collateral. The ratios are used to determine the collateral requirement for various levels of borrowing.", + inputSchema: { + collateralCoin: z.string().optional().describe("Optional: Coin used as collateral"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-vip-loan/market-api/getLoanableAssetsData.ts b/src/tools/binance-vip-loan/market-api/getLoanableAssetsData.ts index f5a7c1c5..8c448656 100644 --- a/src/tools/binance-vip-loan/market-api/getLoanableAssetsData.ts +++ b/src/tools/binance-vip-loan/market-api/getLoanableAssetsData.ts @@ -6,17 +6,24 @@ import { z } from "zod"; import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceGetLoanableAssetsData(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetLoanableAssetsData", - "Retrieves interest rates and borrowing limits for loanable assets. The borrow limit is expressed in USD. You can request information for specific assets or leave it empty to query all available assets.", { - loanCoin: z.string().optional().describe("Optional: Coin for the loan"), - vipLevel: z - .number() - .int() - .optional() - .describe("Optional: User's VIP level (default is user's vip level)"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Retrieves interest rates and borrowing limits for loanable assets. The borrow limit is expressed in USD. You can request information for specific assets or leave it empty to query all available assets.", + inputSchema: { + loanCoin: z.string().optional().describe("Optional: Coin for the loan"), + vipLevel: z + .number() + .int() + .optional() + .describe("Optional: User's VIP level (default is user's vip level)"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-vip-loan/trade-api/vipLoanBorrow.ts b/src/tools/binance-vip-loan/trade-api/vipLoanBorrow.ts index d47f03de..e69a71e2 100644 --- a/src/tools/binance-vip-loan/trade-api/vipLoanBorrow.ts +++ b/src/tools/binance-vip-loan/trade-api/vipLoanBorrow.ts @@ -6,25 +6,34 @@ import { z } from "zod"; import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceVipLoanBorrow(server: McpServer) { - server.tool( + server.registerTool( "BinanceVipLoanBorrow", - "Allow users (master account only) to apply for a loan by pledging collateral. Users specify the coin they want to borrow, the amount, and the collateral details.", { - loanAccountId: z.number().int().describe("Loan account ID"), - loanCoin: z.string().min(1).describe("Loan coin (e.g., BTC, ETH)"), - loanAmount: z.number().describe("Loan amount as decimal"), - collateralAccountId: z - .string() - .min(1) - .describe("Collateral account IDs, separated by commas"), - collateralCoin: z.string().min(1).describe("Collateral coins, separated by commas"), - isFlexibleRate: z.boolean().describe("TRUE: flexible rate, FALSE: fixed rate. Default: TRUE"), - loanTerm: z - .number() - .int() - .optional() - .describe("Loan term (only required if fixed rate, e.g., 30/60 days)"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Allow users (master account only) to apply for a loan by pledging collateral. Users specify the coin they want to borrow, the amount, and the collateral details.", + inputSchema: { + loanAccountId: z.number().int().describe("Loan account ID"), + loanCoin: z.string().min(1).describe("Loan coin (e.g., BTC, ETH)"), + loanAmount: z.number().describe("Loan amount as decimal"), + collateralAccountId: z + .string() + .min(1) + .describe("Collateral account IDs, separated by commas"), + collateralCoin: z.string().min(1).describe("Collateral coins, separated by commas"), + isFlexibleRate: z + .boolean() + .describe("TRUE: flexible rate, FALSE: fixed rate. Default: TRUE"), + loanTerm: z + .number() + .int() + .optional() + .describe("Loan term (only required if fixed rate, e.g., 30/60 days)"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-vip-loan/trade-api/vipLoanRenew.ts b/src/tools/binance-vip-loan/trade-api/vipLoanRenew.ts index 7ffcc0ad..a05a1d43 100644 --- a/src/tools/binance-vip-loan/trade-api/vipLoanRenew.ts +++ b/src/tools/binance-vip-loan/trade-api/vipLoanRenew.ts @@ -6,19 +6,22 @@ import { z } from "zod"; import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceVipLoanRenew(server: McpServer) { - server.tool( + server.registerTool( "BinanceVipLoanRenew", - "Allow VIP users to renew an existing VIP loan for a specified term, either 30 or 60 days.", { - orderId: z.number().int().describe("The order ID for the loan request"), - loanTerm: z - .union([z.literal(30), z.literal(60)]) - .describe("Loan term in days, either 30 or 60"), - recvWindow: z - .number() - .int() - .optional() - .describe("Optional: Time window for request validity"), + description: + "Allow VIP users to renew an existing VIP loan for a specified term, either 30 or 60 days.", + inputSchema: { + orderId: z.number().int().describe("The order ID for the loan request"), + loanTerm: z + .union([z.literal(30), z.literal(60)]) + .describe("Loan term in days, either 30 or 60"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional: Time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-vip-loan/trade-api/vipLoanRepay.ts b/src/tools/binance-vip-loan/trade-api/vipLoanRepay.ts index 11fa3f64..3b8c2e71 100644 --- a/src/tools/binance-vip-loan/trade-api/vipLoanRepay.ts +++ b/src/tools/binance-vip-loan/trade-api/vipLoanRepay.ts @@ -6,13 +6,20 @@ import { z } from "zod"; import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceVipLoanRepay(server: McpServer) { - server.tool( + server.registerTool( "BinanceVipLoanRepay", - "Allow VIP users to repay a specified amount of their active loan, partially or fully. It updates the remaining principal and interest, and provides the repayment status.", { - orderId: z.number().int().describe("Order ID of the loan request"), - amount: z.number().describe("Amount to be processed (decimal allowed)"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Allow VIP users to repay a specified amount of their active loan, partially or fully. It updates the remaining principal and interest, and provides the repayment status.", + inputSchema: { + orderId: z.number().int().describe("Order ID of the loan request"), + amount: z.number().describe("Amount to be processed (decimal allowed)"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-vip-loan/userInformation-api/checkVIPLoanCollateralAccount.ts b/src/tools/binance-vip-loan/userInformation-api/checkVIPLoanCollateralAccount.ts index 4d3b2b01..c7cea037 100644 --- a/src/tools/binance-vip-loan/userInformation-api/checkVIPLoanCollateralAccount.ts +++ b/src/tools/binance-vip-loan/userInformation-api/checkVIPLoanCollateralAccount.ts @@ -6,13 +6,20 @@ import { z } from "zod"; import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceCheckVIPLoanCollateralAccount(server: McpServer) { - server.tool( + server.registerTool( "BinanceCheckVIPLoanCollateralAccount", - "Allow users to check their collateral accounts and the coins held as collateral. If the logged-in account is a loan account, it will return all associated collateral accounts. If it's a collateral account, it returns details of the current account only.", { - orderId: z.number().int().optional().describe("Optional order ID"), - collateralAccountId: z.number().int().optional().describe("Optional collateral account ID"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Allow users to check their collateral accounts and the coins held as collateral. If the logged-in account is a loan account, it will return all associated collateral accounts. If it's a collateral account, it returns details of the current account only.", + inputSchema: { + orderId: z.number().int().optional().describe("Optional order ID"), + collateralAccountId: z.number().int().optional().describe("Optional collateral account ID"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-vip-loan/userInformation-api/getVIPLoanOngoingOrders.ts b/src/tools/binance-vip-loan/userInformation-api/getVIPLoanOngoingOrders.ts index 6f984328..f1edc4b2 100644 --- a/src/tools/binance-vip-loan/userInformation-api/getVIPLoanOngoingOrders.ts +++ b/src/tools/binance-vip-loan/userInformation-api/getVIPLoanOngoingOrders.ts @@ -6,29 +6,36 @@ import { z } from "zod"; import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceGetVIPLoanOngoingOrders(server: McpServer) { - server.tool( + server.registerTool( "BinanceGetVIPLoanOngoingOrders", - "Allows VIP users to retrieve a list of their current active loan orders. Users can filter results by loan coin, collateral coin, order ID, or collateral account ID.", { - orderId: z.number().int().optional().describe("Optional order ID"), - collateralAccountId: z.number().int().optional().describe("Optional collateral account ID"), - loanCoin: z.string().optional().describe("Optional loan coin"), - collateralCoin: z.string().optional().describe("Optional collateral coin"), - current: z - .number() - .int() - .min(1) - .max(1000) - .optional() - .describe("Current page, start from 1, max 1000"), - limit: z - .number() - .int() - .min(1) - .max(100) - .optional() - .describe("Results per page, default 10, max 100"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Allows VIP users to retrieve a list of their current active loan orders. Users can filter results by loan coin, collateral coin, order ID, or collateral account ID.", + inputSchema: { + orderId: z.number().int().optional().describe("Optional order ID"), + collateralAccountId: z.number().int().optional().describe("Optional collateral account ID"), + loanCoin: z.string().optional().describe("Optional loan coin"), + collateralCoin: z.string().optional().describe("Optional collateral coin"), + current: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .describe("Current page, start from 1, max 1000"), + limit: z + .number() + .int() + .min(1) + .max(100) + .optional() + .describe("Results per page, default 10, max 100"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-vip-loan/userInformation-api/queryApplicationStatus.ts b/src/tools/binance-vip-loan/userInformation-api/queryApplicationStatus.ts index 9288868f..8d7d1b96 100644 --- a/src/tools/binance-vip-loan/userInformation-api/queryApplicationStatus.ts +++ b/src/tools/binance-vip-loan/userInformation-api/queryApplicationStatus.ts @@ -6,19 +6,26 @@ import { z } from "zod"; import { vipLoanClient } from "../../../config/binanceClient.js"; export function registerBinanceQueryApplicationStatus(server: McpServer) { - server.tool( + server.registerTool( "BinanceQueryApplicationStatus", - "Allows VIP users to check the status of their loan applications. It returns a list of loan requests with details such as loan coin, amount, term, collateral details, and current application status", { - current: z - .number() - .int() - .min(1) - .max(1000) - .optional() - .describe("Currently querying page. Start from 1, default 1, max 1000"), - limit: z.number().int().min(1).max(100).optional().describe("Default: 10, Max: 100"), - recvWindow: z.number().int().optional().describe("Optional time window for request validity"), + description: + "Allows VIP users to check the status of their loan applications. It returns a list of loan requests with details such as loan coin, amount, term, collateral details, and current application status", + inputSchema: { + current: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .describe("Currently querying page. Start from 1, default 1, max 1000"), + limit: z.number().int().min(1).max(100).optional().describe("Default: 10, Max: 100"), + recvWindow: z + .number() + .int() + .optional() + .describe("Optional time window for request validity"), + }, }, async (params) => { try { diff --git a/src/tools/binance-wallet/account-api/accountApiTradingStatus.ts b/src/tools/binance-wallet/account-api/accountApiTradingStatus.ts index d677bf15..798d26c2 100644 --- a/src/tools/binance-wallet/account-api/accountApiTradingStatus.ts +++ b/src/tools/binance-wallet/account-api/accountApiTradingStatus.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletAccountApiTradingStatus(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletAccountApiTradingStatus", - "Get account API trading status.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get account API trading status.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/tools/binance-wallet/account-api/accountInfo.ts b/src/tools/binance-wallet/account-api/accountInfo.ts index ce607633..16e6c3d8 100644 --- a/src/tools/binance-wallet/account-api/accountInfo.ts +++ b/src/tools/binance-wallet/account-api/accountInfo.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletAccountInfo(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletAccountInfo", - "Get Binance Wallet account information.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get Binance Wallet account information.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/tools/binance-wallet/account-api/accountStatus.ts b/src/tools/binance-wallet/account-api/accountStatus.ts index fd202436..e07e0734 100644 --- a/src/tools/binance-wallet/account-api/accountStatus.ts +++ b/src/tools/binance-wallet/account-api/accountStatus.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletAccountStatus(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletAccountStatus", - "Get Binance Wallet account status.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get Binance Wallet account status.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/tools/binance-wallet/account-api/dailyAccountSnapshot.ts b/src/tools/binance-wallet/account-api/dailyAccountSnapshot.ts index 39fe678f..6b14d247 100644 --- a/src/tools/binance-wallet/account-api/dailyAccountSnapshot.ts +++ b/src/tools/binance-wallet/account-api/dailyAccountSnapshot.ts @@ -6,15 +6,17 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletDailyAccountSnapshot(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletDailyAccountSnapshot", - "Get daily account snapshot.", { - type: z.string().describe("The account type (e.g., SPOT, MARGIN, FUTURES)"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 7, max 30"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get daily account snapshot.", + inputSchema: { + type: z.string().describe("The account type (e.g., SPOT, MARGIN, FUTURES)"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 7, max 30"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ type, startTime, endTime, limit, recvWindow }) => { try { diff --git a/src/tools/binance-wallet/account-api/disableFastWithdrawSwitch.ts b/src/tools/binance-wallet/account-api/disableFastWithdrawSwitch.ts index 66915d9a..3c3a86ab 100644 --- a/src/tools/binance-wallet/account-api/disableFastWithdrawSwitch.ts +++ b/src/tools/binance-wallet/account-api/disableFastWithdrawSwitch.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletDisableFastWithdrawSwitch(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletDisableFastWithdrawSwitch", - "Disable fast withdraw switch.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Disable fast withdraw switch.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/tools/binance-wallet/account-api/enableFastWithdrawSwitch.ts b/src/tools/binance-wallet/account-api/enableFastWithdrawSwitch.ts index 657cf9ee..e9e163ff 100644 --- a/src/tools/binance-wallet/account-api/enableFastWithdrawSwitch.ts +++ b/src/tools/binance-wallet/account-api/enableFastWithdrawSwitch.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletEnableFastWithdrawSwitch(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletEnableFastWithdrawSwitch", - "Enable fast withdraw switch.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Enable fast withdraw switch.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/tools/binance-wallet/account-api/getApiKeyPermission.ts b/src/tools/binance-wallet/account-api/getApiKeyPermission.ts index bda72cb5..fa9634a7 100644 --- a/src/tools/binance-wallet/account-api/getApiKeyPermission.ts +++ b/src/tools/binance-wallet/account-api/getApiKeyPermission.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletGetApiKeyPermission(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletGetApiKeyPermission", - "Get API key permission.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get API key permission.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/tools/binance-wallet/asset-api/assetDetail.ts b/src/tools/binance-wallet/asset-api/assetDetail.ts index c49f28fa..515bb0c6 100644 --- a/src/tools/binance-wallet/asset-api/assetDetail.ts +++ b/src/tools/binance-wallet/asset-api/assetDetail.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletAssetDetail(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletAssetDetail", - "Get asset details.", { - asset: z.string().optional().describe("Asset symbol"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get asset details.", + inputSchema: { + asset: z.string().optional().describe("Asset symbol"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ asset, recvWindow }) => { try { diff --git a/src/tools/binance-wallet/asset-api/assetDividendRecord.ts b/src/tools/binance-wallet/asset-api/assetDividendRecord.ts index 6944e01b..1edbc26d 100644 --- a/src/tools/binance-wallet/asset-api/assetDividendRecord.ts +++ b/src/tools/binance-wallet/asset-api/assetDividendRecord.ts @@ -6,15 +6,17 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletAssetDividendRecord(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletAssetDividendRecord", - "Get asset dividend record.", { - asset: z.string().optional().describe("Asset symbol"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Default 20, max 500"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get asset dividend record.", + inputSchema: { + asset: z.string().optional().describe("Asset symbol"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Default 20, max 500"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ asset, startTime, endTime, limit, recvWindow }) => { try { diff --git a/src/tools/binance-wallet/asset-api/dustTransfer.ts b/src/tools/binance-wallet/asset-api/dustTransfer.ts index 965f940e..0f04581a 100644 --- a/src/tools/binance-wallet/asset-api/dustTransfer.ts +++ b/src/tools/binance-wallet/asset-api/dustTransfer.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletDustTransfer(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletDustTransfer", - "Convert dust assets to BNB.", { - asset: z.array(z.string()).describe("Array of asset symbols to convert"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Convert dust assets to BNB.", + inputSchema: { + asset: z.array(z.string()).describe("Array of asset symbols to convert"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ asset, recvWindow }) => { try { diff --git a/src/tools/binance-wallet/asset-api/dustlog.ts b/src/tools/binance-wallet/asset-api/dustlog.ts index 62ede583..c42e419f 100644 --- a/src/tools/binance-wallet/asset-api/dustlog.ts +++ b/src/tools/binance-wallet/asset-api/dustlog.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletDustlog(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletDustlog", - "Get dust log (history of dust transfers).", { - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get dust log (history of dust transfers).", + inputSchema: { + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ startTime, endTime, recvWindow }) => { try { diff --git a/src/tools/binance-wallet/asset-api/fundingWallet.ts b/src/tools/binance-wallet/asset-api/fundingWallet.ts index 0a11d347..8403e5ae 100644 --- a/src/tools/binance-wallet/asset-api/fundingWallet.ts +++ b/src/tools/binance-wallet/asset-api/fundingWallet.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletFundingWallet(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletFundingWallet", - "Get funding wallet balance.", { - asset: z.string().optional().describe("Asset symbol"), - needBtcValuation: z.boolean().optional().describe("Whether to include BTC valuation"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get funding wallet balance.", + inputSchema: { + asset: z.string().optional().describe("Asset symbol"), + needBtcValuation: z.boolean().optional().describe("Whether to include BTC valuation"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ asset, needBtcValuation, recvWindow }) => { try { diff --git a/src/tools/binance-wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts b/src/tools/binance-wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts index 41a83029..4476777a 100644 --- a/src/tools/binance-wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts +++ b/src/tools/binance-wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletGetAssetsThatCanBeConvertedIntoBnb(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletGetAssetsThatCanBeConvertedIntoBnb", - "Get assets that can be converted to BNB.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get assets that can be converted to BNB.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/tools/binance-wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts b/src/tools/binance-wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts index 90b98913..4aaf8156 100644 --- a/src/tools/binance-wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts +++ b/src/tools/binance-wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts @@ -6,15 +6,17 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletGetCloudMiningPaymentAndRefundHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletGetCloudMiningPaymentAndRefundHistory", - "Get cloud mining payment and refund history.", { - startTime: z.number().describe("Start time in milliseconds"), - endTime: z.number().describe("End time in milliseconds"), - page: z.number().optional().describe("Page number"), - pageSize: z.number().optional().describe("Page size"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get cloud mining payment and refund history.", + inputSchema: { + startTime: z.number().describe("Start time in milliseconds"), + endTime: z.number().describe("End time in milliseconds"), + page: z.number().optional().describe("Page number"), + pageSize: z.number().optional().describe("Page size"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ startTime, endTime, page, pageSize, recvWindow }) => { try { diff --git a/src/tools/binance-wallet/asset-api/getOpenSymbolList.ts b/src/tools/binance-wallet/asset-api/getOpenSymbolList.ts index 0e112d72..1e575b53 100644 --- a/src/tools/binance-wallet/asset-api/getOpenSymbolList.ts +++ b/src/tools/binance-wallet/asset-api/getOpenSymbolList.ts @@ -4,26 +4,30 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletGetOpenSymbolList(server: McpServer) { - server.tool("BinanceWalletGetOpenSymbolList", "Get open symbol list.", {}, async () => { - try { - const response = await walletClient.restAPI.getOpenSymbolList(); - const data = await response.data(); + server.registerTool( + "BinanceWalletGetOpenSymbolList", + { description: "Get open symbol list." }, + async () => { + try { + const response = await walletClient.restAPI.getOpenSymbolList(); + const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Retrieved open symbol list. Response: ${JSON.stringify(data)}`, - }, - ], - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); + return { + content: [ + { + type: "text", + text: `Retrieved open symbol list. Response: ${JSON.stringify(data)}`, + }, + ], + }; + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to retrieve open symbol list: ${errorMessage}` }], - isError: true, - }; - } - }); + return { + content: [{ type: "text", text: `Failed to retrieve open symbol list: ${errorMessage}` }], + isError: true, + }; + } + }, + ); } diff --git a/src/tools/binance-wallet/asset-api/queryUserDelegationHistory.ts b/src/tools/binance-wallet/asset-api/queryUserDelegationHistory.ts index 58d0767d..679e40ff 100644 --- a/src/tools/binance-wallet/asset-api/queryUserDelegationHistory.ts +++ b/src/tools/binance-wallet/asset-api/queryUserDelegationHistory.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletQueryUserDelegationHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletQueryUserDelegationHistory", - "Query user delegation history.", { - email: z.string().describe("Email address"), - startTime: z.number().describe("Start time in milliseconds"), - endTime: z.number().describe("End time in milliseconds"), - page: z.number().optional().describe("Page number"), - limit: z.number().optional().describe("Results per page"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Query user delegation history.", + inputSchema: { + email: z.string().describe("Email address"), + startTime: z.number().describe("Start time in milliseconds"), + endTime: z.number().describe("End time in milliseconds"), + page: z.number().optional().describe("Page number"), + limit: z.number().optional().describe("Results per page"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ email, startTime, endTime, page, limit, recvWindow }) => { try { diff --git a/src/tools/binance-wallet/asset-api/queryUserUniversalTransferHistory.ts b/src/tools/binance-wallet/asset-api/queryUserUniversalTransferHistory.ts index f5c23c09..32c1f6f8 100644 --- a/src/tools/binance-wallet/asset-api/queryUserUniversalTransferHistory.ts +++ b/src/tools/binance-wallet/asset-api/queryUserUniversalTransferHistory.ts @@ -6,18 +6,20 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletQueryUserUniversalTransferHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletQueryUserUniversalTransferHistory", - "Query universal transfer history.", { - type: z.string().describe("Transfer type"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - current: z.number().optional().describe("Current page"), - size: z.number().optional().describe("Page size"), - fromSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), - toSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Query universal transfer history.", + inputSchema: { + type: z.string().describe("Transfer type"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + current: z.number().optional().describe("Current page"), + size: z.number().optional().describe("Page size"), + fromSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), + toSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ type, startTime, endTime, current, size, fromSymbol, toSymbol, recvWindow }) => { try { diff --git a/src/tools/binance-wallet/asset-api/queryUserWalletBalance.ts b/src/tools/binance-wallet/asset-api/queryUserWalletBalance.ts index 78ac08c1..a56c9a84 100644 --- a/src/tools/binance-wallet/asset-api/queryUserWalletBalance.ts +++ b/src/tools/binance-wallet/asset-api/queryUserWalletBalance.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletQueryUserWalletBalance(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletQueryUserWalletBalance", - "Query user wallet balance.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Query user wallet balance.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/tools/binance-wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts b/src/tools/binance-wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts index 7407c66e..6cd869d0 100644 --- a/src/tools/binance-wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts +++ b/src/tools/binance-wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest", - "Toggle BNB burn on spot trade and margin interest.", { - spotBNBBurn: z.string().optional().describe("'true' or 'false' for spot trade"), - interestBNBBurn: z.string().optional().describe("'true' or 'false' for margin interest"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Toggle BNB burn on spot trade and margin interest.", + inputSchema: { + spotBNBBurn: z.string().optional().describe("'true' or 'false' for spot trade"), + interestBNBBurn: z.string().optional().describe("'true' or 'false' for margin interest"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ spotBNBBurn, interestBNBBurn, recvWindow }) => { try { diff --git a/src/tools/binance-wallet/asset-api/tradeFee.ts b/src/tools/binance-wallet/asset-api/tradeFee.ts index 7eae5189..6cb90d45 100644 --- a/src/tools/binance-wallet/asset-api/tradeFee.ts +++ b/src/tools/binance-wallet/asset-api/tradeFee.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletTradeFee(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletTradeFee", - "Get trade fee.", { - symbol: z.string().optional().describe("Trading pair symbol"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get trade fee.", + inputSchema: { + symbol: z.string().optional().describe("Trading pair symbol"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ symbol, recvWindow }) => { try { diff --git a/src/tools/binance-wallet/asset-api/userAsset.ts b/src/tools/binance-wallet/asset-api/userAsset.ts index 8de08a7f..ee4207a6 100644 --- a/src/tools/binance-wallet/asset-api/userAsset.ts +++ b/src/tools/binance-wallet/asset-api/userAsset.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletUserAsset(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletUserAsset", - "Get user assets.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), - needBtcValuation: z.boolean().optional().describe("Whether to include BTC valuation"), + description: "Get user assets.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + needBtcValuation: z.boolean().optional().describe("Whether to include BTC valuation"), + }, }, async ({ recvWindow, needBtcValuation }) => { try { diff --git a/src/tools/binance-wallet/asset-api/userUniversalTransfer.ts b/src/tools/binance-wallet/asset-api/userUniversalTransfer.ts index 2edd3eb8..d59f97c8 100644 --- a/src/tools/binance-wallet/asset-api/userUniversalTransfer.ts +++ b/src/tools/binance-wallet/asset-api/userUniversalTransfer.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletUserUniversalTransfer(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletUserUniversalTransfer", - "Make universal transfer between different accounts.", { - type: z.string().describe("Transfer type"), - asset: z.string().describe("Asset symbol"), - amount: z.number().describe("Transfer amount"), - fromSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), - toSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Make universal transfer between different accounts.", + inputSchema: { + type: z.string().describe("Transfer type"), + asset: z.string().describe("Asset symbol"), + amount: z.number().describe("Transfer amount"), + fromSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), + toSymbol: z.string().optional().describe("Symbol for spot/margin trade pair"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ type, asset, amount, fromSymbol, toSymbol, recvWindow }) => { try { diff --git a/src/tools/binance-wallet/capital-api/allCoinsInformation.ts b/src/tools/binance-wallet/capital-api/allCoinsInformation.ts index 98915cd0..661a3983 100644 --- a/src/tools/binance-wallet/capital-api/allCoinsInformation.ts +++ b/src/tools/binance-wallet/capital-api/allCoinsInformation.ts @@ -6,11 +6,13 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletAllCoinsInformation(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletAllCoinsInformation", - "Get information for all coins.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get information for all coins.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { diff --git a/src/tools/binance-wallet/capital-api/depositAddress.ts b/src/tools/binance-wallet/capital-api/depositAddress.ts index 2ba1261c..49dc9a1d 100644 --- a/src/tools/binance-wallet/capital-api/depositAddress.ts +++ b/src/tools/binance-wallet/capital-api/depositAddress.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletDepositAddress(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletDepositAddress", - "Get deposit address for a specific coin.", { - coin: z.string().describe("Coin symbol"), - network: z.string().optional().describe("Network"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get deposit address for a specific coin.", + inputSchema: { + coin: z.string().describe("Coin symbol"), + network: z.string().optional().describe("Network"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ coin, network, recvWindow }) => { try { diff --git a/src/tools/binance-wallet/capital-api/depositHistory.ts b/src/tools/binance-wallet/capital-api/depositHistory.ts index 4d8d2a00..f654bcc8 100644 --- a/src/tools/binance-wallet/capital-api/depositHistory.ts +++ b/src/tools/binance-wallet/capital-api/depositHistory.ts @@ -6,17 +6,19 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletDepositHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletDepositHistory", - "Get deposit history.", { - coin: z.string().optional().describe("Coin symbol"), - status: z.number().optional().describe("Deposit status"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - offset: z.number().optional().describe("Pagination offset"), - limit: z.number().optional().describe("Number of records to return"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get deposit history.", + inputSchema: { + coin: z.string().optional().describe("Coin symbol"), + status: z.number().optional().describe("Deposit status"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + offset: z.number().optional().describe("Pagination offset"), + limit: z.number().optional().describe("Number of records to return"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { try { diff --git a/src/tools/binance-wallet/capital-api/fetchDepositAddressListWithNetwork.ts b/src/tools/binance-wallet/capital-api/fetchDepositAddressListWithNetwork.ts index d3b67cd8..2b3c1d58 100644 --- a/src/tools/binance-wallet/capital-api/fetchDepositAddressListWithNetwork.ts +++ b/src/tools/binance-wallet/capital-api/fetchDepositAddressListWithNetwork.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletFetchDepositAddressListWithNetwork(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletFetchDepositAddressListWithNetwork", - "Fetch deposit address with network.", { - coin: z.string().describe("Coin symbol"), - network: z.string().optional().describe("Network"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Fetch deposit address with network.", + inputSchema: { + coin: z.string().describe("Coin symbol"), + network: z.string().optional().describe("Network"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ coin, network, recvWindow }) => { try { diff --git a/src/tools/binance-wallet/capital-api/fetchWithdrawAddressList.ts b/src/tools/binance-wallet/capital-api/fetchWithdrawAddressList.ts index 81b1e60b..954e3bb9 100644 --- a/src/tools/binance-wallet/capital-api/fetchWithdrawAddressList.ts +++ b/src/tools/binance-wallet/capital-api/fetchWithdrawAddressList.ts @@ -4,10 +4,9 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletFetchWithdrawAddressList(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletFetchWithdrawAddressList", - "Fetch withdraw address list.", - {}, + { description: "Fetch withdraw address list." }, async () => { try { const response = await walletClient.restAPI.fetchWithdrawAddressList(); diff --git a/src/tools/binance-wallet/capital-api/oneClickArrivalDepositApply.ts b/src/tools/binance-wallet/capital-api/oneClickArrivalDepositApply.ts index 0d064983..7d9b28f8 100644 --- a/src/tools/binance-wallet/capital-api/oneClickArrivalDepositApply.ts +++ b/src/tools/binance-wallet/capital-api/oneClickArrivalDepositApply.ts @@ -6,12 +6,14 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletOneClickArrivalDepositApply(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletOneClickArrivalDepositApply", - "Apply for one-click arrival deposit.", { - subAccountId: z.string().optional().describe("Sub-account ID"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Apply for one-click arrival deposit.", + inputSchema: { + subAccountId: z.string().optional().describe("Sub-account ID"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ subAccountId, recvWindow }) => { try { diff --git a/src/tools/binance-wallet/capital-api/withdraw.ts b/src/tools/binance-wallet/capital-api/withdraw.ts index 5e7570d7..a0779f6f 100644 --- a/src/tools/binance-wallet/capital-api/withdraw.ts +++ b/src/tools/binance-wallet/capital-api/withdraw.ts @@ -6,20 +6,22 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletWithdraw(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletWithdraw", - "Submit a withdraw request.", { - coin: z.string().describe("Coin symbol"), - address: z.string().describe("Withdrawal address"), - amount: z.number().describe("Withdrawal amount"), - withdrawOrderId: z.string().optional().describe("Client order id"), - network: z.string().optional().describe("Network"), - addressTag: z.string().optional().describe("Secondary address identifier (tag/memo)"), - name: z.string().optional().describe("Address name"), - walletType: z.number().optional().describe("Wallet type"), - transactionFeeFlag: z.boolean().optional().describe("Pay fee with BNB"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Submit a withdraw request.", + inputSchema: { + coin: z.string().describe("Coin symbol"), + address: z.string().describe("Withdrawal address"), + amount: z.number().describe("Withdrawal amount"), + withdrawOrderId: z.string().optional().describe("Client order id"), + network: z.string().optional().describe("Network"), + addressTag: z.string().optional().describe("Secondary address identifier (tag/memo)"), + name: z.string().optional().describe("Address name"), + walletType: z.number().optional().describe("Wallet type"), + transactionFeeFlag: z.boolean().optional().describe("Pay fee with BNB"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ coin, diff --git a/src/tools/binance-wallet/capital-api/withdrawHistory.ts b/src/tools/binance-wallet/capital-api/withdrawHistory.ts index 98354666..3f1387b4 100644 --- a/src/tools/binance-wallet/capital-api/withdrawHistory.ts +++ b/src/tools/binance-wallet/capital-api/withdrawHistory.ts @@ -6,18 +6,20 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletWithdrawHistory(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletWithdrawHistory", - "Get withdraw history.", { - coin: z.string().optional().describe("Coin symbol"), - withdrawOrderId: z.string().optional().describe("Withdraw order ID"), - status: z.number().optional().describe("Withdraw status"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - offset: z.number().optional().describe("Pagination offset"), - limit: z.number().optional().describe("Number of records to return"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get withdraw history.", + inputSchema: { + coin: z.string().optional().describe("Coin symbol"), + withdrawOrderId: z.string().optional().describe("Withdraw order ID"), + status: z.number().optional().describe("Withdraw status"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + offset: z.number().optional().describe("Pagination offset"), + limit: z.number().optional().describe("Number of records to return"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ coin, withdrawOrderId, status, startTime, endTime, offset, limit, recvWindow }) => { try { diff --git a/src/tools/binance-wallet/others-api/getSymbolsDelistScheduleForSpot.ts b/src/tools/binance-wallet/others-api/getSymbolsDelistScheduleForSpot.ts index f549aac9..1e61100b 100644 --- a/src/tools/binance-wallet/others-api/getSymbolsDelistScheduleForSpot.ts +++ b/src/tools/binance-wallet/others-api/getSymbolsDelistScheduleForSpot.ts @@ -4,10 +4,9 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletGetSymbolsDelistScheduleForSpot(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletGetSymbolsDelistScheduleForSpot", - "Get delist schedule for spot symbols.", - {}, + { description: "Get delist schedule for spot symbols." }, async () => { try { const response = await walletClient.restAPI.getSymbolsDelistScheduleForSpot(); diff --git a/src/tools/binance-wallet/others-api/systemStatus.ts b/src/tools/binance-wallet/others-api/systemStatus.ts index 5121f4a9..59a2d1fa 100644 --- a/src/tools/binance-wallet/others-api/systemStatus.ts +++ b/src/tools/binance-wallet/others-api/systemStatus.ts @@ -4,26 +4,30 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletSystemStatus(server: McpServer) { - server.tool("BinanceWalletSystemStatus", "Get Binance Wallet system status.", {}, async () => { - try { - const response = await walletClient.restAPI.systemStatus(); - const data = await response.data(); + server.registerTool( + "BinanceWalletSystemStatus", + { description: "Get Binance Wallet system status." }, + async () => { + try { + const response = await walletClient.restAPI.systemStatus(); + const data = await response.data(); - return { - content: [ - { - type: "text", - text: `Retrieved system status. Response: ${JSON.stringify(data)}`, - }, - ], - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); + return { + content: [ + { + type: "text", + text: `Retrieved system status. Response: ${JSON.stringify(data)}`, + }, + ], + }; + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Failed to retrieve system status: ${errorMessage}` }], - isError: true, - }; - } - }); + return { + content: [{ type: "text", text: `Failed to retrieve system status: ${errorMessage}` }], + isError: true, + }; + } + }, + ); } diff --git a/src/tools/binance-wallet/travel-rule-api/brokerWithdraw.ts b/src/tools/binance-wallet/travel-rule-api/brokerWithdraw.ts index 369ff418..bd2e8553 100644 --- a/src/tools/binance-wallet/travel-rule-api/brokerWithdraw.ts +++ b/src/tools/binance-wallet/travel-rule-api/brokerWithdraw.ts @@ -6,22 +6,24 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletBrokerWithdraw(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletBrokerWithdraw", - "Initiate broker withdrawal with travel rule compliance.", { - subAccountId: z.string().describe("Sub-account ID"), - address: z.string().describe("Withdrawal address"), - coin: z.string().describe("Coin symbol"), - amount: z.number().describe("Withdrawal amount"), - withdrawOrderId: z.string().describe("Client order id"), - questionnaire: z.string().describe("Travel rule questionnaire"), - originatorPii: z.string().describe("Originator PII information"), - signature: z.string().describe("Signature"), - network: z.string().optional().describe("Network"), - addressTag: z.string().optional().describe("Secondary address identifier"), - name: z.string().optional().describe("Address name"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Initiate broker withdrawal with travel rule compliance.", + inputSchema: { + subAccountId: z.string().describe("Sub-account ID"), + address: z.string().describe("Withdrawal address"), + coin: z.string().describe("Coin symbol"), + amount: z.number().describe("Withdrawal amount"), + withdrawOrderId: z.string().describe("Client order id"), + questionnaire: z.string().describe("Travel rule questionnaire"), + originatorPii: z.string().describe("Originator PII information"), + signature: z.string().describe("Signature"), + network: z.string().optional().describe("Network"), + addressTag: z.string().optional().describe("Secondary address identifier"), + name: z.string().optional().describe("Address name"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ subAccountId, diff --git a/src/tools/binance-wallet/travel-rule-api/depositHistoryTravelRule.ts b/src/tools/binance-wallet/travel-rule-api/depositHistoryTravelRule.ts index 90060bfd..c2c76658 100644 --- a/src/tools/binance-wallet/travel-rule-api/depositHistoryTravelRule.ts +++ b/src/tools/binance-wallet/travel-rule-api/depositHistoryTravelRule.ts @@ -6,17 +6,19 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletDepositHistoryTravelRule(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletDepositHistoryTravelRule", - "Get deposit history for travel rule.", { - coin: z.string().optional().describe("Coin symbol"), - status: z.number().optional().describe("Deposit status"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - offset: z.number().optional().describe("Default 0"), - limit: z.number().optional().describe("Default 1000, max 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get deposit history for travel rule.", + inputSchema: { + coin: z.string().optional().describe("Coin symbol"), + status: z.number().optional().describe("Deposit status"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + offset: z.number().optional().describe("Default 0"), + limit: z.number().optional().describe("Default 1000, max 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { try { diff --git a/src/tools/binance-wallet/travel-rule-api/onboardedVaspList.ts b/src/tools/binance-wallet/travel-rule-api/onboardedVaspList.ts index a0f4e7b1..98e0ff33 100644 --- a/src/tools/binance-wallet/travel-rule-api/onboardedVaspList.ts +++ b/src/tools/binance-wallet/travel-rule-api/onboardedVaspList.ts @@ -4,10 +4,9 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletOnboardedVaspList(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletOnboardedVaspList", - "Get list of onboarded VASPs (Virtual Asset Service Providers).", - {}, + { description: "Get list of onboarded VASPs (Virtual Asset Service Providers)." }, async () => { try { const response = await walletClient.restAPI.onboardedVaspList(); diff --git a/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaire.ts b/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaire.ts index 90fa2b14..588322ed 100644 --- a/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaire.ts +++ b/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaire.ts @@ -6,16 +6,18 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletSubmitDepositQuestionnaire(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletSubmitDepositQuestionnaire", - "Submit deposit questionnaire for broker deposit.", { - subAccountId: z.string().describe("Sub-account ID"), - depositId: z.string().describe("Deposit ID"), - questionnaire: z.string().describe("Travel rule questionnaire"), - beneficiaryPii: z.string().describe("Beneficiary PII information"), - signature: z.string().describe("Signature"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Submit deposit questionnaire for broker deposit.", + inputSchema: { + subAccountId: z.string().describe("Sub-account ID"), + depositId: z.string().describe("Deposit ID"), + questionnaire: z.string().describe("Travel rule questionnaire"), + beneficiaryPii: z.string().describe("Beneficiary PII information"), + signature: z.string().describe("Signature"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ subAccountId, depositId, questionnaire, beneficiaryPii, signature, recvWindow }) => { try { diff --git a/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts b/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts index 10614549..674df61b 100644 --- a/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts +++ b/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts @@ -6,13 +6,15 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletSubmitDepositQuestionnaireTravelRule(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletSubmitDepositQuestionnaireTravelRule", - "Submit deposit questionnaire for travel rule.", { - tranId: z.number().describe("Transaction ID"), - questionnaire: z.string().describe("Travel rule questionnaire"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Submit deposit questionnaire for travel rule.", + inputSchema: { + tranId: z.number().describe("Transaction ID"), + questionnaire: z.string().describe("Travel rule questionnaire"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ tranId, questionnaire, recvWindow }) => { try { diff --git a/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV1.ts b/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV1.ts index 7787b949..fe55168a 100644 --- a/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV1.ts +++ b/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV1.ts @@ -6,17 +6,19 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletWithdrawHistoryV1(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletWithdrawHistoryV1", - "Get withdraw history (v1).", { - coin: z.string().optional().describe("Coin symbol"), - status: z.number().optional().describe("Withdraw status"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - offset: z.number().optional().describe("Default 0"), - limit: z.number().optional().describe("Default 1000, max 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get withdraw history (v1).", + inputSchema: { + coin: z.string().optional().describe("Coin symbol"), + status: z.number().optional().describe("Withdraw status"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + offset: z.number().optional().describe("Default 0"), + limit: z.number().optional().describe("Default 1000, max 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { try { diff --git a/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV2.ts b/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV2.ts index 5370bb7d..d61d6dc9 100644 --- a/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV2.ts +++ b/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV2.ts @@ -6,17 +6,19 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletWithdrawHistoryV2(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletWithdrawHistoryV2", - "Get withdraw history (v2).", { - coin: z.string().optional().describe("Coin symbol"), - status: z.number().optional().describe("Withdraw status"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - offset: z.number().optional().describe("Default 0"), - limit: z.number().optional().describe("Default 1000, max 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get withdraw history (v2).", + inputSchema: { + coin: z.string().optional().describe("Coin symbol"), + status: z.number().optional().describe("Withdraw status"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + offset: z.number().optional().describe("Default 0"), + limit: z.number().optional().describe("Default 1000, max 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { try { diff --git a/src/tools/binance-wallet/travel-rule-api/withdrawTravelRule.ts b/src/tools/binance-wallet/travel-rule-api/withdrawTravelRule.ts index 3c13a06f..279066f1 100644 --- a/src/tools/binance-wallet/travel-rule-api/withdrawTravelRule.ts +++ b/src/tools/binance-wallet/travel-rule-api/withdrawTravelRule.ts @@ -6,19 +6,21 @@ import { z } from "zod"; import { walletClient } from "../../../config/binanceClient.js"; export function registerBinanceWalletWithdrawTravelRule(server: McpServer) { - server.tool( + server.registerTool( "BinanceWalletWithdrawTravelRule", - "Withdraw with travel rule compliance.", { - coin: z.string().describe("Coin symbol"), - address: z.string().describe("Withdrawal address"), - amount: z.number().describe("Withdrawal amount"), - withdrawOrderId: z.string().optional().describe("Client order id"), - network: z.string().optional().describe("Network"), - addressTag: z.string().optional().describe("Secondary address identifier"), - name: z.string().optional().describe("Address name"), - questionnaire: z.string().describe("Travel rule questionnaire"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Withdraw with travel rule compliance.", + inputSchema: { + coin: z.string().describe("Coin symbol"), + address: z.string().describe("Withdrawal address"), + amount: z.number().describe("Withdrawal amount"), + withdrawOrderId: z.string().optional().describe("Client order id"), + network: z.string().optional().describe("Network"), + addressTag: z.string().optional().describe("Secondary address identifier"), + name: z.string().optional().describe("Address name"), + questionnaire: z.string().describe("Travel rule questionnaire"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ coin, diff --git a/src/tools/binanceAccountInfo.ts b/src/tools/binanceAccountInfo.ts index 0bd86526..af9f9a5c 100644 --- a/src/tools/binanceAccountInfo.ts +++ b/src/tools/binanceAccountInfo.ts @@ -4,61 +4,65 @@ import { AccountSnapshotType } from "@binance/connector-typescript"; import { spotClient } from "../config/client.js"; export function registerBinanceAccountInfo(server: McpServer) { - server.tool("binanceAccountInfo", "check binance account info", {}, async (_params) => { - try { - const accountInfo = await spotClient.accountInformation(); - const accountSnapshot = await spotClient.dailyAccountSnapshot(AccountSnapshotType.SPOT, { - limit: 7, - }); - const userAsset = await spotClient.userAsset({ - needBtcValuation: true, - }); - if (userAsset) { - const balances = userAsset.map((item) => ({ - asset: item.asset, - free: item.free, - locked: item.locked, - })); - const totalAssetOfBtc = userAsset - .reduce((sum, item) => sum + parseFloat(item.btcValuation || "0"), 0) - .toFixed(20) - .replace(/\.?0+$/, ""); - accountSnapshot.snapshotVos.push({ - type: "spot", - updateTime: Date.now(), - data: { - totalAssetOfBtc, - balances, - }, + server.registerTool( + "binanceAccountInfo", + { description: "check binance account info" }, + async (_params) => { + try { + const accountInfo = await spotClient.accountInformation(); + const accountSnapshot = await spotClient.dailyAccountSnapshot(AccountSnapshotType.SPOT, { + limit: 7, + }); + const userAsset = await spotClient.userAsset({ + needBtcValuation: true, + }); + if (userAsset) { + const balances = userAsset.map((item) => ({ + asset: item.asset, + free: item.free, + locked: item.locked, + })); + const totalAssetOfBtc = userAsset + .reduce((sum, item) => sum + parseFloat(item.btcValuation || "0"), 0) + .toFixed(20) + .replace(/\.?0+$/, ""); + accountSnapshot.snapshotVos.push({ + type: "spot", + updateTime: Date.now(), + data: { + totalAssetOfBtc, + balances, + }, + }); + } + const btcPrice = await spotClient.symbolPriceTicker({ + symbol: "BTCUSDT", }); - } - const btcPrice = await spotClient.symbolPriceTicker({ - symbol: "BTCUSDT", - }); - return { - content: [ - { - type: "text", - text: `Get binance account info successfully. data: ${JSON.stringify(accountInfo)}`, - }, - { - type: "text", - text: `Get binance balance history info successfully. data: ${JSON.stringify(accountSnapshot)}`, - }, - { - type: "text", - text: `Get BTC price successfully. data: ${JSON.stringify(btcPrice)}`, - }, - ], - }; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); + return { + content: [ + { + type: "text", + text: `Get binance account info successfully. data: ${JSON.stringify(accountInfo)}`, + }, + { + type: "text", + text: `Get binance balance history info successfully. data: ${JSON.stringify(accountSnapshot)}`, + }, + { + type: "text", + text: `Get BTC price successfully. data: ${JSON.stringify(btcPrice)}`, + }, + ], + }; + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error); - return { - content: [{ type: "text", text: `Server failed: ${errorMessage}` }], - isError: true, - }; - } - }); + return { + content: [{ type: "text", text: `Server failed: ${errorMessage}` }], + isError: true, + }; + } + }, + ); } diff --git a/src/tools/binanceOrderBook.ts b/src/tools/binanceOrderBook.ts index 6472a243..0f24ae55 100644 --- a/src/tools/binanceOrderBook.ts +++ b/src/tools/binanceOrderBook.ts @@ -5,11 +5,13 @@ import { z } from "zod"; import { spotClient } from "../config/client.js"; export function registerBinanceOrderBook(server: McpServer) { - server.tool( + server.registerTool( "binanceOrderBook", - "check binance order book", { - symbol: z.string().describe("symbol: exemple: BTCUSDT"), + description: "check binance order book", + inputSchema: { + symbol: z.string().describe("symbol: exemple: BTCUSDT"), + }, }, async ({ symbol }) => { try { diff --git a/src/tools/binanceSpotPlaceOrder.ts b/src/tools/binanceSpotPlaceOrder.ts index 4fd896e5..a46cb86f 100644 --- a/src/tools/binanceSpotPlaceOrder.ts +++ b/src/tools/binanceSpotPlaceOrder.ts @@ -7,8 +7,9 @@ import { z } from "zod"; import { spotClient } from "../config/client.js"; export function registerBinanceSpotPlaceOrder(server: McpServer) { - server.tool( + server.registerTool( "binanceSpotPlaceOrder", + {}, `Trading for small orders will not generate significant selling pressure on the market`, { symbol: z.string().describe("symbol: exemple: BTCUSDT"), diff --git a/src/tools/binanceTimeWeightedAveragePriceFutureAlgo.ts b/src/tools/binanceTimeWeightedAveragePriceFutureAlgo.ts index 776bd5a9..450ef1b8 100644 --- a/src/tools/binanceTimeWeightedAveragePriceFutureAlgo.ts +++ b/src/tools/binanceTimeWeightedAveragePriceFutureAlgo.ts @@ -5,8 +5,9 @@ import { z } from "zod"; import { algoClient } from "../config/client.js"; export function registerBinanceTimeWeightedAveragePriceFutureAlgo(server: McpServer) { - server.tool( + server.registerTool( "binanceTimeWeightedAveragePriceFutureAlgo", + {}, `Place a new spot TWAP order with Algo service. Trading for large orders can generate significant selling pressure on the market`, { symbol: z.string().describe("symbol: exemple: BTCUSDT"), diff --git a/src/tools/credit-line/index.ts b/src/tools/credit-line/index.ts index 1c6950b0..e8ac95e9 100644 --- a/src/tools/credit-line/index.ts +++ b/src/tools/credit-line/index.ts @@ -28,8 +28,9 @@ export function registerCreditLineTools(server: McpServer) { // ===================================================================== // GET /sapi/v2/cl/account - Get Credit Line Account Information // ===================================================================== - server.tool( + server.registerTool( "binance_us_cl_account", + {}, `Get current credit line account information including LTV ratios, balances, and loan details. ⚠️ REQUIRES CREDIT LINE API KEY - Standard API keys will not work. @@ -108,8 +109,9 @@ Available to Withdraw: ${response.availableAmountToTransferOut}`; // ===================================================================== // GET /sapi/v1/cl/alert/history - Get Alert History (Margin Calls/Liquidations) // ===================================================================== - server.tool( + server.registerTool( "binance_us_cl_alert_history", + {}, `Get margin call and liquidation alert history for your credit line account. ⚠️ REQUIRES CREDIT LINE API KEY - Standard API keys will not work. @@ -182,8 +184,9 @@ when margin calls or liquidation warnings have occurred.`, // ===================================================================== // GET /sapi/v1/cl/transferHistory - Get Transfer History // ===================================================================== - server.tool( + server.registerTool( "binance_us_cl_transfer_history", + {}, `Get transfer history for your credit line account. ⚠️ REQUIRES CREDIT LINE API KEY - Standard API keys will not work. @@ -261,8 +264,9 @@ Use this to track deposits and withdrawals from your credit line account.`, // ===================================================================== // POST /sapi/v1/cl/transfer - Execute Transfer // ===================================================================== - server.tool( + server.registerTool( "binance_us_cl_transfer", + {}, `Transfer assets in or out of your credit line account. ⚠️ REQUIRES CREDIT LINE API KEY - Standard API keys will not work. diff --git a/src/tools/creditline/index.ts b/src/tools/creditline/index.ts index a8b32315..7418a04a 100644 --- a/src/tools/creditline/index.ts +++ b/src/tools/creditline/index.ts @@ -23,8 +23,9 @@ export function registerCreditLineTools(server: McpServer) { // ===================================================================== // GET /sapi/v2/cl/account - Get Credit Line Account Information // ===================================================================== - server.tool( + server.registerTool( "binance_us_cl_account", + {}, `Get comprehensive credit line account information. ⚠️ REQUIRES INSTITUTIONAL CREDIT LINE AGREEMENT @@ -118,8 +119,9 @@ Full Response: ${JSON.stringify(response, null, 2)}`, // ===================================================================== // GET /sapi/v1/cl/alert/history - Get Alert History (Margin Call & Liquidation) // ===================================================================== - server.tool( + server.registerTool( "binance_us_cl_alert_history", + {}, `Get margin call and liquidation alert history for credit line account. ⚠️ REQUIRES INSTITUTIONAL CREDIT LINE AGREEMENT @@ -207,8 +209,9 @@ Full Response: ${JSON.stringify(response, null, 2)}`, // ===================================================================== // GET /sapi/v1/cl/transferHistory - Get Transfer History // ===================================================================== - server.tool( + server.registerTool( "binance_us_cl_transfer_history", + {}, `Get transfer history for credit line account. ⚠️ REQUIRES INSTITUTIONAL CREDIT LINE AGREEMENT @@ -295,8 +298,9 @@ Full Response: ${JSON.stringify(response, null, 2)}`, // ===================================================================== // POST /sapi/v1/cl/transfer - Execute Transfer // ===================================================================== - server.tool( + server.registerTool( "binance_us_cl_transfer", + {}, `Execute a transfer in or out of the credit line account. ⚠️ REQUIRES INSTITUTIONAL CREDIT LINE AGREEMENT @@ -372,8 +376,9 @@ Full Response: ${JSON.stringify(response, null, 2)}`, // ===================================================================== // GET /sapi/v1/cl/liquidation/history - Get Liquidation History // ===================================================================== - server.tool( + server.registerTool( "binance_us_cl_liquidation_history", + {}, `Get liquidation history for credit line account. ⚠️ REQUIRES INSTITUTIONAL CREDIT LINE AGREEMENT diff --git a/src/tools/custodial-solution/index.ts b/src/tools/custodial-solution/index.ts index 4bd10f9b..1caa862c 100644 --- a/src/tools/custodial-solution/index.ts +++ b/src/tools/custodial-solution/index.ts @@ -27,8 +27,9 @@ export function registerCustodialSolutionTools(server: McpServer) { // ===================================================================== // GET /sapi/v1/custodian/balance - Get Account Balance // ===================================================================== - server.tool( + server.registerTool( "binance_us_custodial_balance", + {}, `Get balance information for Binance.US exchange wallet and custodial sub-account. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY - Regular API keys will not work. @@ -74,8 +75,9 @@ Each balance includes: // ===================================================================== // GET /sapi/v1/custodian/supportedAssetList - Get Supported Assets // ===================================================================== - server.tool( + server.registerTool( "binance_us_custodial_supported_assets", + {}, `Get list of assets supported for custodial transfers and settlements. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -119,8 +121,9 @@ Each asset includes: // ===================================================================== // POST /sapi/v1/custodian/walletTransfer - Transfer From Exchange Wallet // ===================================================================== - server.tool( + server.registerTool( "binance_us_custodial_wallet_transfer", + {}, `Transfer assets from your Binance.US exchange wallet to your custodial sub-account. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -174,8 +177,9 @@ which can then be traded or settled to your custodial partner.`, // ===================================================================== // POST /sapi/v1/custodian/custodianTransfer - Transfer From Custodian // ===================================================================== - server.tool( + server.registerTool( "binance_us_custodial_custodian_transfer", + {}, `Request asset transfer from a custodial partner account to Binance.US custodial sub-account. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -231,8 +235,9 @@ The actual transfer is executed by the custody partner.`, // ===================================================================== // POST /sapi/v1/custodian/undoTransfer - Undo Transfer // ===================================================================== - server.tool( + server.registerTool( "binance_us_custodial_undo_transfer", + {}, `Undo a previous transfer from your custodial partner. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -272,8 +277,9 @@ This reverses a previous custodian transfer by its transfer ID.`, // ===================================================================== // GET /sapi/v1/custodian/walletTransferHistory - Wallet Transfer History // ===================================================================== - server.tool( + server.registerTool( "binance_us_custodial_wallet_transfer_history", + {}, `Get history of transfers from Binance.US exchange wallet to custodial sub-account. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -333,8 +339,9 @@ Returns transfer history with status, amounts, and timestamps.`, // ===================================================================== // GET /sapi/v1/custodian/custodianTransferHistory - Custodian Transfer History // ===================================================================== - server.tool( + server.registerTool( "binance_us_custodial_custodian_transfer_history", + {}, `Get history of transfers from custodial partner, including ExpressTrade and Undo transfers. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -406,8 +413,9 @@ Returns transfer history with status, amounts, and timestamps.`, // ===================================================================== // POST /sapi/v1/custodian/settlement - Request Settlement // ===================================================================== - server.tool( + server.registerTool( "binance_us_custodial_settlement", + {}, `Request settlement of assets from custodial sub-account to custodial partner. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -457,8 +465,9 @@ to your custody partner's vault.`, // ===================================================================== // GET /sapi/v1/custodian/settlementHistory - Settlement History // ===================================================================== - server.tool( + server.registerTool( "binance_us_custodial_settlement_history", + {}, `Get history of settlements from custodial sub-account to custodial partner. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY diff --git a/src/tools/custodial/index.ts b/src/tools/custodial/index.ts index 7eec11fa..f3d79fa8 100644 --- a/src/tools/custodial/index.ts +++ b/src/tools/custodial/index.ts @@ -44,8 +44,9 @@ export function registerCustodialTools(server: McpServer) { // ===================================================================== // GET /sapi/v1/custodian/balance - Get Custodial Account Balance // ===================================================================== - server.tool( + server.registerTool( "binance_us_cust_balance", + {}, `Get balance information for Binance.US exchange wallet and custodial sub-account. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY - Standard API keys will not work. @@ -93,8 +94,9 @@ Each balance entry contains: // ===================================================================== // GET /sapi/v1/custodian/supportedAssetList - Get Supported Assets // ===================================================================== - server.tool( + server.registerTool( "binance_us_cust_supported_assets", + {}, `Get list of assets supported for custodial solution transfers and settlements. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -138,8 +140,9 @@ Each asset entry contains: // ===================================================================== // POST /sapi/v1/custodian/walletTransfer - Transfer from Exchange Wallet // ===================================================================== - server.tool( + server.registerTool( "binance_us_cust_wallet_transfer", + {}, `Transfer assets from Binance.US exchange wallet to custodial sub-account. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -194,8 +197,9 @@ Response includes: // ===================================================================== // POST /sapi/v1/custodian/custodianTransfer - Transfer from Custodian // ===================================================================== - server.tool( + server.registerTool( "binance_us_cust_transfer", + {}, `Transfer assets from custodial partner account to Binance.US custodial sub-account. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -252,8 +256,9 @@ Response includes: // ===================================================================== // POST /sapi/v1/custodian/undoTransfer - Undo Transfer // ===================================================================== - server.tool( + server.registerTool( "binance_us_cust_undo_transfer", + {}, `Undo a previous transfer from your custodial partner. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -297,8 +302,9 @@ Response includes: // ===================================================================== // GET /sapi/v1/custodian/walletTransferHistory - Wallet Transfer History // ===================================================================== - server.tool( + server.registerTool( "binance_us_cust_wallet_transfer_history", + {}, `Get history of transfers from Binance.US exchange wallet to custodial sub-account. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -367,8 +373,9 @@ status, createTime, updateTime`, // ===================================================================== // GET /sapi/v1/custodian/custodianTransferHistory - Custodian Transfer History // ===================================================================== - server.tool( + server.registerTool( "binance_us_cust_transfer_history", + {}, `Get history of transfers from custodial partner to Binance.US custodial sub-account. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -447,8 +454,9 @@ expressTrade flag, createTime, updateTime`, // ===================================================================== // GET /sapi/v1/custodian/availableBalance - Get Available Balance // ===================================================================== - server.tool( + server.registerTool( "binance_us_cust_available_balance", + {}, `Get available balance in the custodial sub-account for trading. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -487,8 +495,9 @@ Returns the balance available for placing new orders.`, // ===================================================================== // POST /sapi/v1/custodian/order - Place Custodial Order // ===================================================================== - server.tool( + server.registerTool( "binance_us_cust_new_order", + {}, `Place a new trade order through the custodial solution. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -573,8 +582,9 @@ executedQty, and expressTradeFlag`, // ===================================================================== // POST /sapi/v1/custodian/ocoOrder - Place Custodial OCO Order // ===================================================================== - server.tool( + server.registerTool( "binance_us_cust_oco_order", + {}, `Place a new OCO (One-Cancels-the-Other) order through the custodial solution. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -650,8 +660,9 @@ Response includes orderListId, orders array, and orderReports with details.`, // ===================================================================== // GET /sapi/v1/custodian/openOrders - Get Open Orders // ===================================================================== - server.tool( + server.registerTool( "binance_us_cust_open_orders", + {}, `Get all open custodial trade orders. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -697,8 +708,9 @@ expressTradeFlag`, // ===================================================================== // GET /sapi/v1/custodian/order - Get Order // ===================================================================== - server.tool( + server.registerTool( "binance_us_cust_get_order", + {}, `Get details of a specific custodial trade order. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -741,8 +753,9 @@ icebergQty, time, updateTime, isWorking, expressTradeFlag`, // ===================================================================== // GET /sapi/v1/custodian/orderHistory - Get Order History // ===================================================================== - server.tool( + server.registerTool( "binance_us_cust_order_history", + {}, `Get historical custodial trade orders. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -802,8 +815,9 @@ executedQty, and expressTradeFlag.`, // ===================================================================== // GET /sapi/v1/custodian/tradeHistory - Get Trade History // ===================================================================== - server.tool( + server.registerTool( "binance_us_cust_trade_history", + {}, `Get historical custodial trades (filled orders). ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -862,8 +876,9 @@ isBuyer, isMaker, isBestMatch, orderId, commission, commissionAsset`, // ===================================================================== // DELETE /sapi/v1/custodian/cancelOrder - Cancel Order // ===================================================================== - server.tool( + server.registerTool( "binance_us_cust_cancel_order", + {}, `Cancel an active custodial trade order. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -917,8 +932,9 @@ Response includes the canceled order details with status: CANCELED`, // ===================================================================== // DELETE /sapi/v1/custodian/cancelOrdersBySymbol - Cancel All Orders for Symbol // ===================================================================== - server.tool( + server.registerTool( "binance_us_cust_cancel_orders_symbol", + {}, `Cancel all active custodial orders for a specific trading pair. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -963,8 +979,9 @@ Response is an array of all canceled orders.`, // ===================================================================== // DELETE /sapi/v1/custodian/cancelOcoOrder - Cancel OCO Order // ===================================================================== - server.tool( + server.registerTool( "binance_us_cust_cancel_oco", + {}, `Cancel an entire OCO (One-Cancels-the-Other) order list. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -1012,8 +1029,9 @@ canceled order details.`, // ===================================================================== // GET /sapi/v1/custodian/settlementSetting - Get Settlement Settings // ===================================================================== - server.tool( + server.registerTool( "binance_us_cust_settlement_settings", + {}, `Get current settlement settings for custodial solution. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -1055,8 +1073,9 @@ Response includes: // ===================================================================== // GET /sapi/v1/custodian/settlementHistory - Get Settlement History // ===================================================================== - server.tool( + server.registerTool( "binance_us_cust_settlement_history", + {}, `Get historical settlement records for custodial solution. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY diff --git a/src/tools/general/index.ts b/src/tools/general/index.ts index 49d3bebd..89d3776a 100644 --- a/src/tools/general/index.ts +++ b/src/tools/general/index.ts @@ -7,10 +7,9 @@ import { binanceUsRequest } from "../../config/binanceUsClient.js"; export function registerGeneralTools(server: McpServer) { // binance_us_ping - Test connectivity to Binance.US - server.tool( + server.registerTool( "binance_us_ping", - "Test connectivity to the Binance.US API. Returns empty object if successful.", - {}, + { description: "Test connectivity to the Binance.US API. Returns empty object if successful." }, async () => { try { const result = await binanceUsRequest("GET", "/api/v3/ping", {}, false); @@ -35,10 +34,9 @@ export function registerGeneralTools(server: McpServer) { ); // binance_us_server_time - Get server time - server.tool( + server.registerTool( "binance_us_server_time", - "Get the current server time from Binance.US exchange.", - {}, + { description: "Get the current server time from Binance.US exchange." }, async () => { try { const result = await binanceUsRequest("GET", "/api/v3/time", {}, false); @@ -64,10 +62,12 @@ export function registerGeneralTools(server: McpServer) { ); // binance_us_system_status - Get system maintenance status (SIGNED) - server.tool( + server.registerTool( "binance_us_system_status", - "Check if Binance.US system is under maintenance. Status 0 = normal, 1 = system maintenance. Requires API key authentication.", - {}, + { + description: + "Check if Binance.US system is under maintenance. Status 0 = normal, 1 = system maintenance. Requires API key authentication.", + }, async () => { try { const result = await binanceUsRequest("GET", "/sapi/v1/system/status", {}, true); @@ -93,26 +93,29 @@ export function registerGeneralTools(server: McpServer) { ); // binance_us_exchange_info - Get exchange information - server.tool( + server.registerTool( "binance_us_exchange_info", - "Get current exchange trading rules and trading pair information from Binance.US. Can filter by specific symbol(s) or permissions.", { - symbol: z - .string() - .optional() - .describe( - "Single trading pair symbol to filter (e.g., BTCUSD). Cannot be used with 'symbols' parameter.", - ), - symbols: z - .array(z.string()) - .optional() - .describe( - "Array of trading pair symbols to filter (e.g., ['BTCUSD', 'ETHUSD']). Cannot be used with 'symbol' parameter.", - ), - permissions: z - .array(z.string()) - .optional() - .describe("Filter by trading permissions. Default is ['SPOT']."), + description: + "Get current exchange trading rules and trading pair information from Binance.US. Can filter by specific symbol(s) or permissions.", + inputSchema: { + symbol: z + .string() + .optional() + .describe( + "Single trading pair symbol to filter (e.g., BTCUSD). Cannot be used with 'symbols' parameter.", + ), + symbols: z + .array(z.string()) + .optional() + .describe( + "Array of trading pair symbols to filter (e.g., ['BTCUSD', 'ETHUSD']). Cannot be used with 'symbol' parameter.", + ), + permissions: z + .array(z.string()) + .optional() + .describe("Filter by trading permissions. Default is ['SPOT']."), + }, }, async ({ symbol, symbols, permissions }) => { try { diff --git a/src/tools/market/index.ts b/src/tools/market/index.ts index 6b9b0b7b..3700b1b9 100644 --- a/src/tools/market/index.ts +++ b/src/tools/market/index.ts @@ -72,20 +72,23 @@ function formatError(error: unknown): { content: { type: "text"; text: string }[ */ export function registerMarketTools(server: McpServer) { // binance_us_order_book - Get order book depth - server.tool( + server.registerTool( "binance_us_order_book", - "Get order book depth (bids and asks) for a trading pair on Binance.US. Returns price levels with quantities. Weight varies based on limit (1-100: weight 1, 101-500: weight 5, 501-1000: weight 10, 1001-5000: weight 50).", { - symbol: z.string().toUpperCase().describe("Trading pair symbol, e.g., BTCUSD"), - limit: z - .number() - .int() - .min(1) - .max(5000) - .optional() - .describe( - `Number of price levels. Valid values: ${ORDER_BOOK_VALID_LIMITS.join(", ")}. Default 100, max 5000.`, - ), + description: + "Get order book depth (bids and asks) for a trading pair on Binance.US. Returns price levels with quantities. Weight varies based on limit (1-100: weight 1, 101-500: weight 5, 501-1000: weight 10, 1001-5000: weight 50).", + inputSchema: { + symbol: z.string().toUpperCase().describe("Trading pair symbol, e.g., BTCUSD"), + limit: z + .number() + .int() + .min(1) + .max(5000) + .optional() + .describe( + `Number of price levels. Valid values: ${ORDER_BOOK_VALID_LIMITS.join(", ")}. Default 100, max 5000.`, + ), + }, }, async ({ symbol, limit }) => { try { @@ -124,18 +127,21 @@ export function registerMarketTools(server: McpServer) { ); // binance_us_recent_trades - Get recent trades - server.tool( + server.registerTool( "binance_us_recent_trades", - "Get recent trades for a trading pair on Binance.US. Returns trade ID, price, quantity, time, and maker/taker info.", { - symbol: z.string().toUpperCase().describe("Trading pair symbol, e.g., BTCUSD"), - limit: z - .number() - .int() - .min(1) - .max(MAX_TRADES_LIMIT) - .optional() - .describe(`Number of trades to return. Default 500, max ${MAX_TRADES_LIMIT}.`), + description: + "Get recent trades for a trading pair on Binance.US. Returns trade ID, price, quantity, time, and maker/taker info.", + inputSchema: { + symbol: z.string().toUpperCase().describe("Trading pair symbol, e.g., BTCUSD"), + limit: z + .number() + .int() + .min(1) + .max(MAX_TRADES_LIMIT) + .optional() + .describe(`Number of trades to return. Default 500, max ${MAX_TRADES_LIMIT}.`), + }, }, async ({ symbol, limit }) => { try { @@ -168,24 +174,27 @@ export function registerMarketTools(server: McpServer) { ); // binance_us_historical_trades - Get older trades (MARKET_DATA) - server.tool( + server.registerTool( "binance_us_historical_trades", - "Get older historical trades for a trading pair. Requires API key with MARKET_DATA permission.", { - symbol: z.string().toUpperCase().describe("Trading pair symbol, e.g., BTCUSD"), - limit: z - .number() - .int() - .min(1) - .max(MAX_TRADES_LIMIT) - .optional() - .describe(`Number of trades. Default 500, max ${MAX_TRADES_LIMIT}.`), - fromId: z - .number() - .int() - .positive() - .optional() - .describe("Trade ID to fetch from (inclusive)."), + description: + "Get older historical trades for a trading pair. Requires API key with MARKET_DATA permission.", + inputSchema: { + symbol: z.string().toUpperCase().describe("Trading pair symbol, e.g., BTCUSD"), + limit: z + .number() + .int() + .min(1) + .max(MAX_TRADES_LIMIT) + .optional() + .describe(`Number of trades. Default 500, max ${MAX_TRADES_LIMIT}.`), + fromId: z + .number() + .int() + .positive() + .optional() + .describe("Trade ID to fetch from (inclusive)."), + }, }, async ({ symbol, limit, fromId }) => { try { @@ -225,21 +234,24 @@ export function registerMarketTools(server: McpServer) { ); // binance_us_agg_trades - Get aggregate trades - server.tool( + server.registerTool( "binance_us_agg_trades", - "Get compressed aggregate trades. Trades with same time, order, and price are aggregated.", { - symbol: z.string().toUpperCase().describe("Trading pair symbol, e.g., BTCUSD"), - fromId: z.number().int().positive().optional().describe("Agg trade ID to start from."), - startTime: z.number().int().positive().optional().describe("Start time in ms."), - endTime: z.number().int().positive().optional().describe("End time in ms."), - limit: z - .number() - .int() - .min(1) - .max(MAX_TRADES_LIMIT) - .optional() - .describe(`Number of trades. Default 500, max ${MAX_TRADES_LIMIT}.`), + description: + "Get compressed aggregate trades. Trades with same time, order, and price are aggregated.", + inputSchema: { + symbol: z.string().toUpperCase().describe("Trading pair symbol, e.g., BTCUSD"), + fromId: z.number().int().positive().optional().describe("Agg trade ID to start from."), + startTime: z.number().int().positive().optional().describe("Start time in ms."), + endTime: z.number().int().positive().optional().describe("End time in ms."), + limit: z + .number() + .int() + .min(1) + .max(MAX_TRADES_LIMIT) + .optional() + .describe(`Number of trades. Default 500, max ${MAX_TRADES_LIMIT}.`), + }, }, async ({ symbol, fromId, startTime, endTime, limit }) => { try { @@ -294,21 +306,23 @@ export function registerMarketTools(server: McpServer) { ); // binance_us_klines - Get candlestick data - server.tool( + server.registerTool( "binance_us_klines", - "Get Kline/candlestick data for a trading pair. Returns OHLCV data.", { - symbol: z.string().toUpperCase().describe("Trading pair symbol, e.g., BTCUSD"), - interval: z.enum(KLINE_INTERVALS).describe(`Kline interval: ${KLINE_INTERVALS.join(", ")}`), - startTime: z.number().int().positive().optional().describe("Start time in ms"), - endTime: z.number().int().positive().optional().describe("End time in ms"), - limit: z - .number() - .int() - .min(1) - .max(MAX_KLINES_LIMIT) - .optional() - .describe(`Number of klines. Default 500, max ${MAX_KLINES_LIMIT}.`), + description: "Get Kline/candlestick data for a trading pair. Returns OHLCV data.", + inputSchema: { + symbol: z.string().toUpperCase().describe("Trading pair symbol, e.g., BTCUSD"), + interval: z.enum(KLINE_INTERVALS).describe(`Kline interval: ${KLINE_INTERVALS.join(", ")}`), + startTime: z.number().int().positive().optional().describe("Start time in ms"), + endTime: z.number().int().positive().optional().describe("End time in ms"), + limit: z + .number() + .int() + .min(1) + .max(MAX_KLINES_LIMIT) + .optional() + .describe(`Number of klines. Default 500, max ${MAX_KLINES_LIMIT}.`), + }, }, async ({ symbol, interval, startTime, endTime, limit }) => { try { @@ -358,11 +372,13 @@ export function registerMarketTools(server: McpServer) { ); // binance_us_avg_price - Get average price - server.tool( + server.registerTool( "binance_us_avg_price", - "Get current 5-minute rolling weighted average price.", { - symbol: z.string().toUpperCase().describe("Trading pair symbol, e.g., BTCUSD"), + description: "Get current 5-minute rolling weighted average price.", + inputSchema: { + symbol: z.string().toUpperCase().describe("Trading pair symbol, e.g., BTCUSD"), + }, }, async ({ symbol }) => { try { @@ -388,20 +404,25 @@ export function registerMarketTools(server: McpServer) { ); // binance_us_ticker_24hr - Get 24hr statistics - server.tool( + server.registerTool( "binance_us_ticker_24hr", - "Get 24-hour rolling window price change statistics.", { - symbol: z - .string() - .toUpperCase() - .optional() - .describe("Symbol (e.g., BTCUSD). Cannot use with 'symbols'."), - symbols: z - .array(z.string()) - .optional() - .describe("Array of symbols. Cannot use with 'symbol'."), - type: z.enum(["FULL", "MINI"]).optional().describe("FULL (default) or MINI (fewer fields)."), + description: "Get 24-hour rolling window price change statistics.", + inputSchema: { + symbol: z + .string() + .toUpperCase() + .optional() + .describe("Symbol (e.g., BTCUSD). Cannot use with 'symbols'."), + symbols: z + .array(z.string()) + .optional() + .describe("Array of symbols. Cannot use with 'symbol'."), + type: z + .enum(["FULL", "MINI"]) + .optional() + .describe("FULL (default) or MINI (fewer fields)."), + }, }, async ({ symbol, symbols, type }) => { try { @@ -457,19 +478,21 @@ export function registerMarketTools(server: McpServer) { ); // binance_us_ticker_price - Get latest price - server.tool( + server.registerTool( "binance_us_ticker_price", - "Get latest price for symbol(s).", { - symbol: z - .string() - .toUpperCase() - .optional() - .describe("Symbol (e.g., BTCUSD). Cannot use with 'symbols'."), - symbols: z - .array(z.string()) - .optional() - .describe("Array of symbols. Cannot use with 'symbol'."), + description: "Get latest price for symbol(s).", + inputSchema: { + symbol: z + .string() + .toUpperCase() + .optional() + .describe("Symbol (e.g., BTCUSD). Cannot use with 'symbols'."), + symbols: z + .array(z.string()) + .optional() + .describe("Array of symbols. Cannot use with 'symbol'."), + }, }, async ({ symbol, symbols }) => { try { @@ -510,19 +533,21 @@ export function registerMarketTools(server: McpServer) { ); // binance_us_ticker_book - Get book ticker - server.tool( + server.registerTool( "binance_us_ticker_book", - "Get best bid/ask prices and quantities (top of book).", { - symbol: z - .string() - .toUpperCase() - .optional() - .describe("Symbol (e.g., BTCUSD). Cannot use with 'symbols'."), - symbols: z - .array(z.string()) - .optional() - .describe("Array of symbols. Cannot use with 'symbol'."), + description: "Get best bid/ask prices and quantities (top of book).", + inputSchema: { + symbol: z + .string() + .toUpperCase() + .optional() + .describe("Symbol (e.g., BTCUSD). Cannot use with 'symbols'."), + symbols: z + .array(z.string()) + .optional() + .describe("Array of symbols. Cannot use with 'symbol'."), + }, }, async ({ symbol, symbols }) => { try { @@ -576,24 +601,27 @@ export function registerMarketTools(server: McpServer) { ); // binance_us_rolling_window - Get rolling window stats - server.tool( + server.registerTool( "binance_us_rolling_window", - "Get rolling window price change statistics with custom window sizes (1m to 7d).", { - symbol: z - .string() - .toUpperCase() - .optional() - .describe("Symbol (required if 'symbols' not provided)."), - symbols: z - .array(z.string()) - .optional() - .describe("Array of symbols (required if 'symbol' not provided)."), - windowSize: z - .enum(ROLLING_WINDOW_SIZES) - .optional() - .describe(`Window size. Default 1d. Options: ${ROLLING_WINDOW_SIZES.join(", ")}`), - type: z.enum(["FULL", "MINI"]).optional().describe("FULL (default) or MINI."), + description: + "Get rolling window price change statistics with custom window sizes (1m to 7d).", + inputSchema: { + symbol: z + .string() + .toUpperCase() + .optional() + .describe("Symbol (required if 'symbols' not provided)."), + symbols: z + .array(z.string()) + .optional() + .describe("Array of symbols (required if 'symbol' not provided)."), + windowSize: z + .enum(ROLLING_WINDOW_SIZES) + .optional() + .describe(`Window size. Default 1d. Options: ${ROLLING_WINDOW_SIZES.join(", ")}`), + type: z.enum(["FULL", "MINI"]).optional().describe("FULL (default) or MINI."), + }, }, async ({ symbol, symbols, windowSize, type }) => { try { diff --git a/src/tools/otc/index.ts b/src/tools/otc/index.ts index 583695de..da089d9e 100644 --- a/src/tools/otc/index.ts +++ b/src/tools/otc/index.ts @@ -18,8 +18,9 @@ export function registerOtcTools(server: McpServer) { // ===================================================================== // GET /sapi/v1/otc/coinPairs - Get Supported OTC Coin Pairs // ===================================================================== - server.tool( + server.registerTool( "binance_us_otc_coin_pairs", + {}, `Get a list of supported OTC (Over-The-Counter) trading pairs on Binance.US. OTC trading allows large block trades to be executed outside the regular order book, @@ -65,8 +66,9 @@ Example: Convert large amounts of BTC to USDT without affecting market price.`, // ===================================================================== // POST /sapi/v1/otc/quotes - Request Quote for OTC Trade // ===================================================================== - server.tool( + server.registerTool( "binance_us_otc_quote", + {}, `Request a quote for an OTC (Over-The-Counter) trade on Binance.US. This endpoint requests a price quote for converting one coin to another via OTC. @@ -125,8 +127,9 @@ Response includes: // ===================================================================== // POST /sapi/v1/otc/orders - Place OTC Trade Order // ===================================================================== - server.tool( + server.registerTool( "binance_us_otc_place_order", + {}, `Place an OTC (Over-The-Counter) trade order using a previously acquired quote. ⚠️ IMPORTANT: You must first call binance_us_otc_quote to get a quoteId before placing an order. @@ -177,8 +180,9 @@ Response includes: // ===================================================================== // GET /sapi/v1/otc/orders/{orderId} - Get OTC Order Details // ===================================================================== - server.tool( + server.registerTool( "binance_us_otc_get_order", + {}, `Get detailed information about a specific OTC (Over-The-Counter) trade order. Use this to check the status and details of a previously placed OTC order. @@ -220,8 +224,9 @@ Response includes: // ===================================================================== // GET /sapi/v1/otc/orders - Get All OTC Trade Orders // ===================================================================== - server.tool( + server.registerTool( "binance_us_otc_all_orders", + {}, `Query all OTC (Over-The-Counter) trade orders with optional filters. Use this to retrieve your OTC trading history with various filtering options. @@ -281,8 +286,9 @@ toCoin, toAmount, ratio, inverseRatio, createTime`, // ===================================================================== // GET /sapi/v1/ocbs/orders - Get All OCBS (Fiat) Orders // ===================================================================== - server.tool( + server.registerTool( "binance_us_ocbs_orders", + {}, `Query all OCBS (One-Click-Buy-Sell) fiat orders on Binance.US. OCBS allows direct fiat-to-crypto conversions. This endpoint retrieves your diff --git a/src/tools/staking/index.ts b/src/tools/staking/index.ts index e5268841..ff34541c 100644 --- a/src/tools/staking/index.ts +++ b/src/tools/staking/index.ts @@ -18,8 +18,9 @@ export function registerStakingTools(server: McpServer) { // ===================================================================== // GET /sapi/v1/staking/asset - Get Staking Asset Information // ===================================================================== - server.tool( + server.registerTool( "binance_us_staking_asset_info", + {}, `Get staking information for supported assets on Binance.US. Returns details about staking options including APR, APY, and staking limits. @@ -69,8 +70,9 @@ If no asset is specified, returns information for all staking assets.`, // ===================================================================== // POST /sapi/v1/staking/stake - Stake Asset // ===================================================================== - server.tool( + server.registerTool( "binance_us_staking_stake", + {}, `Stake a supported asset on Binance.US to earn staking rewards. ⚠️ IMPORTANT: @@ -126,8 +128,9 @@ Response includes: // ===================================================================== // POST /sapi/v1/staking/unstake - Unstake Asset // ===================================================================== - server.tool( + server.registerTool( "binance_us_staking_unstake", + {}, `Unstake a previously staked asset on Binance.US. ⚠️ IMPORTANT: @@ -174,8 +177,9 @@ Response includes: // ===================================================================== // GET /sapi/v1/staking/stakingBalance - Get Staking Balance // ===================================================================== - server.tool( + server.registerTool( "binance_us_staking_balance", + {}, `Get current staking balance for assets on Binance.US. Returns your current staking positions and their details. @@ -223,8 +227,9 @@ If no asset is specified, returns balances for all staked assets.`, // ===================================================================== // GET /sapi/v1/staking/history - Get Staking History // ===================================================================== - server.tool( + server.registerTool( "binance_us_staking_history", + {}, `Get staking transaction history for assets on Binance.US. Returns a history of staking and unstaking transactions. @@ -286,8 +291,9 @@ If no asset is specified, returns history for all assets.`, // ===================================================================== // GET /sapi/v1/staking/stakingRewardsHistory - Get Staking Rewards History // ===================================================================== - server.tool( + server.registerTool( "binance_us_staking_rewards", + {}, `Get staking rewards history for assets on Binance.US. Returns a history of staking rewards earned over time. diff --git a/src/tools/subaccount/index.ts b/src/tools/subaccount/index.ts index 3988a6d2..1275257f 100644 --- a/src/tools/subaccount/index.ts +++ b/src/tools/subaccount/index.ts @@ -21,15 +21,17 @@ export function registerSubaccountTools(server: McpServer) { // binance_us_subaccount_list // GET /sapi/v3/sub-account/list // ===================================================== - server.tool( + server.registerTool( "binance_us_subaccount_list", - "Get a list of all sub-accounts. Filter by email or status (enabled/disabled).", { - email: z.string().optional().describe("Filter by sub-account email"), - status: z.string().optional().describe("Filter by status: 'enabled' or 'disabled'"), - page: z.number().optional().describe("Page number. Default: 1"), - limit: z.number().optional().describe("Results per page. Default: 500"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get a list of all sub-accounts. Filter by email or status (enabled/disabled).", + inputSchema: { + email: z.string().optional().describe("Filter by sub-account email"), + status: z.string().optional().describe("Filter by status: 'enabled' or 'disabled'"), + page: z.number().optional().describe("Page number. Default: 1"), + limit: z.number().optional().describe("Results per page. Default: 500"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ email, status, page, limit, recvWindow }) => { try { @@ -65,16 +67,18 @@ export function registerSubaccountTools(server: McpServer) { // binance_us_subaccount_transfer_history // GET /sapi/v3/sub-account/transfer/history // ===================================================== - server.tool( + server.registerTool( "binance_us_subaccount_transfer_history", - "Get transfer history between master and sub-accounts.", { - email: z.string().optional().describe("Sub-account email to filter by"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - page: z.number().optional().describe("Page number. Each page contains up to 500 records"), - limit: z.number().optional().describe("Results per page. Default: 500"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get transfer history between master and sub-accounts.", + inputSchema: { + email: z.string().optional().describe("Sub-account email to filter by"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + page: z.number().optional().describe("Page number. Each page contains up to 500 records"), + limit: z.number().optional().describe("Results per page. Default: 500"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ email, startTime, endTime, page, limit, recvWindow }) => { try { @@ -115,15 +119,18 @@ export function registerSubaccountTools(server: McpServer) { // binance_us_subaccount_transfer // POST /sapi/v3/sub-account/transfer // ===================================================== - server.tool( + server.registerTool( "binance_us_subaccount_transfer", - "Execute an asset transfer between master account and a sub-account. ⚠️ This moves funds between accounts!", { - fromEmail: z.string().email().describe("Sender email address"), - toEmail: z.string().email().describe("Recipient email address"), - asset: z.string().describe("Asset symbol to transfer, e.g., BTC, ETH"), - amount: z.number().describe("Amount to transfer"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: + "Execute an asset transfer between master account and a sub-account. ⚠️ This moves funds between accounts!", + inputSchema: { + fromEmail: z.string().email().describe("Sender email address"), + toEmail: z.string().email().describe("Recipient email address"), + asset: z.string().describe("Asset symbol to transfer, e.g., BTC, ETH"), + amount: z.number().describe("Amount to transfer"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ fromEmail, toEmail, asset, amount, recvWindow }) => { try { @@ -160,12 +167,14 @@ export function registerSubaccountTools(server: McpServer) { // binance_us_subaccount_assets // GET /sapi/v3/sub-account/assets // ===================================================== - server.tool( + server.registerTool( "binance_us_subaccount_assets", - "Get asset balances for a specific sub-account.", { - email: z.string().email().describe("Sub-account email address"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get asset balances for a specific sub-account.", + inputSchema: { + email: z.string().email().describe("Sub-account email address"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ email, recvWindow }) => { try { @@ -204,14 +213,16 @@ export function registerSubaccountTools(server: McpServer) { // binance_us_subaccount_summary // GET /sapi/v1/sub-account/spotSummary // ===================================================== - server.tool( + server.registerTool( "binance_us_subaccount_summary", - "Get the total USD value of assets in the master account and all sub-accounts.", { - email: z.string().optional().describe("Filter by specific sub-account email"), - page: z.number().optional().describe("Page number"), - size: z.number().optional().describe("Results per page"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get the total USD value of assets in the master account and all sub-accounts.", + inputSchema: { + email: z.string().optional().describe("Filter by specific sub-account email"), + page: z.number().optional().describe("Page number"), + size: z.number().optional().describe("Results per page"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ email, page, size, recvWindow }) => { try { @@ -246,12 +257,15 @@ export function registerSubaccountTools(server: McpServer) { // binance_us_subaccount_status // GET /sapi/v1/sub-account/status // ===================================================== - server.tool( + server.registerTool( "binance_us_subaccount_status", - "Get status list of sub-accounts including activation status and enabled features.", { - email: z.string().optional().describe("Sub-account email to check status for"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: + "Get status list of sub-accounts including activation status and enabled features.", + inputSchema: { + email: z.string().optional().describe("Sub-account email to check status for"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ email, recvWindow }) => { try { diff --git a/src/tools/trade/oco.ts b/src/tools/trade/oco.ts index 280bb341..caf549fb 100644 --- a/src/tools/trade/oco.ts +++ b/src/tools/trade/oco.ts @@ -87,35 +87,41 @@ const SelfTradePreventionMode = z.enum(["EXPIRE_TAKER", "EXPIRE_MAKER", "EXPIRE_ * Register new OCO order tool */ export function registerBinanceUsNewOco(server: McpServer) { - server.tool( + server.registerTool( "binance_us_new_oco", - "Place a new OCO (One-Cancels-the-Other) order on Binance.US. OCO orders combine a limit order with a stop-loss order. When one triggers, the other is automatically cancelled. Note: For SELL OCOs, limit price > stop price. For BUY OCOs, limit price < stop price.", { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD, ETHUSD)"), - side: OrderSide.describe("Order side: BUY or SELL"), - quantity: z.number().describe("Order quantity for both legs of the OCO"), - price: z.number().describe("Limit order price"), - stopPrice: z.number().describe("Stop price that triggers the stop-loss order"), - stopLimitPrice: z - .number() - .optional() - .describe( - "Limit price for the stop-loss leg. If provided, stopLimitTimeInForce is required.", + description: + "Place a new OCO (One-Cancels-the-Other) order on Binance.US. OCO orders combine a limit order with a stop-loss order. When one triggers, the other is automatically cancelled. Note: For SELL OCOs, limit price > stop price. For BUY OCOs, limit price < stop price.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD, ETHUSD)"), + side: OrderSide.describe("Order side: BUY or SELL"), + quantity: z.number().describe("Order quantity for both legs of the OCO"), + price: z.number().describe("Limit order price"), + stopPrice: z.number().describe("Stop price that triggers the stop-loss order"), + stopLimitPrice: z + .number() + .optional() + .describe( + "Limit price for the stop-loss leg. If provided, stopLimitTimeInForce is required.", + ), + stopLimitTimeInForce: TimeInForce.optional().describe( + "Time in force for stop-limit order: GTC, IOC, or FOK. Required if stopLimitPrice is provided.", ), - stopLimitTimeInForce: TimeInForce.optional().describe( - "Time in force for stop-limit order: GTC, IOC, or FOK. Required if stopLimitPrice is provided.", - ), - listClientOrderId: z.string().optional().describe("Unique ID for the entire OCO order list"), - limitClientOrderId: z.string().optional().describe("Unique ID for the limit order leg"), - stopClientOrderId: z.string().optional().describe("Unique ID for the stop-loss leg"), - limitIcebergQty: z.number().optional().describe("Iceberg quantity for the limit leg"), - stopIcebergQty: z.number().optional().describe("Iceberg quantity for the stop-loss leg"), - trailingDelta: z.number().optional().describe("Trailing delta in BIPS for the stop leg"), - newOrderRespType: OrderRespType.optional().describe("Response type: ACK, RESULT, or FULL"), - selfTradePreventionMode: SelfTradePreventionMode.optional().describe( - "Self-trade prevention mode", - ), - recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + listClientOrderId: z + .string() + .optional() + .describe("Unique ID for the entire OCO order list"), + limitClientOrderId: z.string().optional().describe("Unique ID for the limit order leg"), + stopClientOrderId: z.string().optional().describe("Unique ID for the stop-loss leg"), + limitIcebergQty: z.number().optional().describe("Iceberg quantity for the limit leg"), + stopIcebergQty: z.number().optional().describe("Iceberg quantity for the stop-loss leg"), + trailingDelta: z.number().optional().describe("Trailing delta in BIPS for the stop leg"), + newOrderRespType: OrderRespType.optional().describe("Response type: ACK, RESULT, or FULL"), + selfTradePreventionMode: SelfTradePreventionMode.optional().describe( + "Self-trade prevention mode", + ), + recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + }, }, async (params) => { try { @@ -201,13 +207,16 @@ export function registerBinanceUsNewOco(server: McpServer) { * Register get OCO order tool */ export function registerBinanceUsGetOco(server: McpServer) { - server.tool( + server.registerTool( "binance_us_get_oco", - "Query a specific OCO order on Binance.US. Either orderListId or origClientOrderId must be provided.", { - orderListId: z.number().optional().describe("The order list ID to query"), - origClientOrderId: z.string().optional().describe("The original client order ID to query"), - recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + description: + "Query a specific OCO order on Binance.US. Either orderListId or origClientOrderId must be provided.", + inputSchema: { + orderListId: z.number().optional().describe("The order list ID to query"), + origClientOrderId: z.string().optional().describe("The original client order ID to query"), + recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + }, }, async (params) => { try { @@ -281,18 +290,21 @@ export function registerBinanceUsGetOco(server: McpServer) { * Register cancel OCO order tool */ export function registerBinanceUsCancelOco(server: McpServer) { - server.tool( + server.registerTool( "binance_us_cancel_oco", - "Cancel an entire OCO order on Binance.US. Cancelling any individual leg will cancel the entire OCO.", { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD)"), - orderListId: z.number().optional().describe("The order list ID to cancel"), - listClientOrderId: z.string().optional().describe("The list client order ID to cancel"), - newClientOrderId: z - .string() - .optional() - .describe("New client order ID for this cancel request"), - recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + description: + "Cancel an entire OCO order on Binance.US. Cancelling any individual leg will cancel the entire OCO.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD)"), + orderListId: z.number().optional().describe("The order list ID to cancel"), + listClientOrderId: z.string().optional().describe("The list client order ID to cancel"), + newClientOrderId: z + .string() + .optional() + .describe("New client order ID for this cancel request"), + recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + }, }, async (params) => { try { @@ -370,11 +382,13 @@ export function registerBinanceUsCancelOco(server: McpServer) { * Register open OCO orders tool */ export function registerBinanceUsOpenOco(server: McpServer) { - server.tool( + server.registerTool( "binance_us_open_oco", - "Get all open OCO orders on Binance.US.", { - recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + description: "Get all open OCO orders on Binance.US.", + inputSchema: { + recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + }, }, async (params) => { try { @@ -456,24 +470,26 @@ export function registerBinanceUsOpenOco(server: McpServer) { * Register all OCO orders history tool */ export function registerBinanceUsAllOcoOrders(server: McpServer) { - server.tool( + server.registerTool( "binance_us_all_oco_orders", - "Get all OCO orders (history) on Binance.US. Returns up to 1000 orders.", { - fromId: z - .number() - .optional() - .describe("Order list ID to start from. Cannot be used with startTime/endTime."), - startTime: z - .number() - .optional() - .describe("Start time in milliseconds. Cannot be used with fromId."), - endTime: z - .number() - .optional() - .describe("End time in milliseconds. Cannot be used with fromId."), - limit: z.number().optional().describe("Number of results (default 500, max 1000)"), - recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + description: "Get all OCO orders (history) on Binance.US. Returns up to 1000 orders.", + inputSchema: { + fromId: z + .number() + .optional() + .describe("Order list ID to start from. Cannot be used with startTime/endTime."), + startTime: z + .number() + .optional() + .describe("Start time in milliseconds. Cannot be used with fromId."), + endTime: z + .number() + .optional() + .describe("End time in milliseconds. Cannot be used with fromId."), + limit: z.number().optional().describe("Number of results (default 500, max 1000)"), + recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + }, }, async (params) => { try { diff --git a/src/tools/trade/orders.ts b/src/tools/trade/orders.ts index d3097960..e5b37717 100644 --- a/src/tools/trade/orders.ts +++ b/src/tools/trade/orders.ts @@ -136,55 +136,58 @@ const CancelRestrictions = z.enum(["ONLY_NEW", "ONLY_PARTIALLY_FILLED"]); * Register new order tool */ export function registerBinanceUsNewOrder(server: McpServer) { - server.tool( + server.registerTool( "binance_us_new_order", - "Place a new trade order on Binance.US. Supports LIMIT, MARKET, STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, TAKE_PROFIT_LIMIT, and LIMIT_MAKER order types.", { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD, ETHUSD)"), - side: OrderSide.describe("Order side: BUY or SELL"), - type: OrderType.describe( - "Order type: LIMIT, MARKET, STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, TAKE_PROFIT_LIMIT, LIMIT_MAKER", - ), - timeInForce: TimeInForce.optional().describe( - "Time in force: GTC (Good Till Cancel), IOC (Immediate Or Cancel), FOK (Fill Or Kill). Required for LIMIT orders.", - ), - quantity: z - .number() - .optional() - .describe("Order quantity in base asset. Required for most order types."), - quoteOrderQty: z - .number() - .optional() - .describe( - "Order quantity in quote asset. Can be used for MARKET orders instead of quantity.", + description: + "Place a new trade order on Binance.US. Supports LIMIT, MARKET, STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, TAKE_PROFIT_LIMIT, and LIMIT_MAKER order types.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD, ETHUSD)"), + side: OrderSide.describe("Order side: BUY or SELL"), + type: OrderType.describe( + "Order type: LIMIT, MARKET, STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, TAKE_PROFIT_LIMIT, LIMIT_MAKER", ), - price: z - .number() - .optional() - .describe("Order price. Required for LIMIT and LIMIT_MAKER orders."), - newClientOrderId: z - .string() - .optional() - .describe("Unique client order ID. Auto-generated if not provided."), - stopPrice: z - .number() - .optional() - .describe("Stop price. Required for STOP_LOSS_LIMIT and TAKE_PROFIT_LIMIT orders."), - trailingDelta: z - .number() - .optional() - .describe("Trailing delta for trailing stop orders in BIPS (1 BIP = 0.01%)."), - icebergQty: z - .number() - .optional() - .describe("Iceberg quantity for iceberg orders. timeInForce must be GTC."), - newOrderRespType: OrderRespType.optional().describe( - "Response type: ACK, RESULT, or FULL. MARKET/LIMIT default to FULL, others to ACK.", - ), - selfTradePreventionMode: SelfTradePreventionMode.optional().describe( - "Self-trade prevention mode: EXPIRE_TAKER, EXPIRE_MAKER, EXPIRE_BOTH, NONE.", - ), - recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)."), + timeInForce: TimeInForce.optional().describe( + "Time in force: GTC (Good Till Cancel), IOC (Immediate Or Cancel), FOK (Fill Or Kill). Required for LIMIT orders.", + ), + quantity: z + .number() + .optional() + .describe("Order quantity in base asset. Required for most order types."), + quoteOrderQty: z + .number() + .optional() + .describe( + "Order quantity in quote asset. Can be used for MARKET orders instead of quantity.", + ), + price: z + .number() + .optional() + .describe("Order price. Required for LIMIT and LIMIT_MAKER orders."), + newClientOrderId: z + .string() + .optional() + .describe("Unique client order ID. Auto-generated if not provided."), + stopPrice: z + .number() + .optional() + .describe("Stop price. Required for STOP_LOSS_LIMIT and TAKE_PROFIT_LIMIT orders."), + trailingDelta: z + .number() + .optional() + .describe("Trailing delta for trailing stop orders in BIPS (1 BIP = 0.01%)."), + icebergQty: z + .number() + .optional() + .describe("Iceberg quantity for iceberg orders. timeInForce must be GTC."), + newOrderRespType: OrderRespType.optional().describe( + "Response type: ACK, RESULT, or FULL. MARKET/LIMIT default to FULL, others to ACK.", + ), + selfTradePreventionMode: SelfTradePreventionMode.optional().describe( + "Self-trade prevention mode: EXPIRE_TAKER, EXPIRE_MAKER, EXPIRE_BOTH, NONE.", + ), + recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)."), + }, }, async (params) => { try { @@ -254,31 +257,34 @@ export function registerBinanceUsNewOrder(server: McpServer) { * Register test order tool */ export function registerBinanceUsTestOrder(server: McpServer) { - server.tool( + server.registerTool( "binance_us_test_order", - "Test a new order on Binance.US without actually placing it. Validates order parameters and signature without executing the trade.", { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD, ETHUSD)"), - side: OrderSide.describe("Order side: BUY or SELL"), - type: OrderType.describe( - "Order type: LIMIT, MARKET, STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, TAKE_PROFIT_LIMIT, LIMIT_MAKER", - ), - timeInForce: TimeInForce.optional().describe("Time in force: GTC, IOC, or FOK"), - quantity: z.number().optional().describe("Order quantity in base asset"), - quoteOrderQty: z - .number() - .optional() - .describe("Order quantity in quote asset (for MARKET orders)"), - price: z.number().optional().describe("Order price"), - newClientOrderId: z.string().optional().describe("Unique client order ID"), - stopPrice: z.number().optional().describe("Stop price for stop orders"), - trailingDelta: z.number().optional().describe("Trailing delta in BIPS"), - icebergQty: z.number().optional().describe("Iceberg quantity"), - newOrderRespType: OrderRespType.optional().describe("Response type"), - selfTradePreventionMode: SelfTradePreventionMode.optional().describe( - "Self-trade prevention mode", - ), - recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + description: + "Test a new order on Binance.US without actually placing it. Validates order parameters and signature without executing the trade.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD, ETHUSD)"), + side: OrderSide.describe("Order side: BUY or SELL"), + type: OrderType.describe( + "Order type: LIMIT, MARKET, STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, TAKE_PROFIT_LIMIT, LIMIT_MAKER", + ), + timeInForce: TimeInForce.optional().describe("Time in force: GTC, IOC, or FOK"), + quantity: z.number().optional().describe("Order quantity in base asset"), + quoteOrderQty: z + .number() + .optional() + .describe("Order quantity in quote asset (for MARKET orders)"), + price: z.number().optional().describe("Order price"), + newClientOrderId: z.string().optional().describe("Unique client order ID"), + stopPrice: z.number().optional().describe("Stop price for stop orders"), + trailingDelta: z.number().optional().describe("Trailing delta in BIPS"), + icebergQty: z.number().optional().describe("Iceberg quantity"), + newOrderRespType: OrderRespType.optional().describe("Response type"), + selfTradePreventionMode: SelfTradePreventionMode.optional().describe( + "Self-trade prevention mode", + ), + recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + }, }, async (params) => { try { @@ -344,14 +350,17 @@ export function registerBinanceUsTestOrder(server: McpServer) { * Register get order tool */ export function registerBinanceUsGetOrder(server: McpServer) { - server.tool( + server.registerTool( "binance_us_get_order", - "Query the status of a specific order on Binance.US. Either orderId or origClientOrderId must be provided.", { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD)"), - orderId: z.number().optional().describe("The order ID to query"), - origClientOrderId: z.string().optional().describe("The original client order ID to query"), - recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + description: + "Query the status of a specific order on Binance.US. Either orderId or origClientOrderId must be provided.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD)"), + orderId: z.number().optional().describe("The order ID to query"), + origClientOrderId: z.string().optional().describe("The original client order ID to query"), + recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + }, }, async (params) => { try { @@ -422,21 +431,24 @@ export function registerBinanceUsGetOrder(server: McpServer) { * Register cancel order tool */ export function registerBinanceUsCancelOrder(server: McpServer) { - server.tool( + server.registerTool( "binance_us_cancel_order", - "Cancel an active order on Binance.US. Either orderId or origClientOrderId must be provided.", { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD)"), - orderId: z.number().optional().describe("The order ID to cancel"), - origClientOrderId: z.string().optional().describe("The original client order ID to cancel"), - newClientOrderId: z - .string() - .optional() - .describe("New client order ID for this cancel request"), - cancelRestrictions: CancelRestrictions.optional().describe( - "Cancel restrictions: ONLY_NEW or ONLY_PARTIALLY_FILLED", - ), - recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + description: + "Cancel an active order on Binance.US. Either orderId or origClientOrderId must be provided.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD)"), + orderId: z.number().optional().describe("The order ID to cancel"), + origClientOrderId: z.string().optional().describe("The original client order ID to cancel"), + newClientOrderId: z + .string() + .optional() + .describe("New client order ID for this cancel request"), + cancelRestrictions: CancelRestrictions.optional().describe( + "Cancel restrictions: ONLY_NEW or ONLY_PARTIALLY_FILLED", + ), + recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + }, }, async (params) => { try { @@ -503,39 +515,42 @@ export function registerBinanceUsCancelOrder(server: McpServer) { * Register cancel and replace order tool */ export function registerBinanceUsCancelReplace(server: McpServer) { - server.tool( + server.registerTool( "binance_us_cancel_replace", - "Cancel an existing order and place a new order on the same symbol atomically. This is useful for modifying order parameters.", { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD)"), - side: OrderSide.describe("Order side: BUY or SELL"), - type: OrderType.describe("Order type for the new order"), - cancelReplaceMode: CancelReplaceMode.describe( - "STOP_ON_FAILURE: Don't place new order if cancel fails. ALLOW_FAILURE: Place new order even if cancel fails.", - ), - cancelOrderId: z - .number() - .optional() - .describe("Order ID to cancel. Either this or cancelOrigClientOrderId required."), - cancelOrigClientOrderId: z - .string() - .optional() - .describe("Client order ID to cancel. Either this or cancelOrderId required."), - timeInForce: TimeInForce.optional().describe("Time in force for new order"), - quantity: z.number().optional().describe("Quantity for new order"), - quoteOrderQty: z.number().optional().describe("Quote order quantity for new order"), - price: z.number().optional().describe("Price for new order"), - cancelNewClientOrderId: z.string().optional().describe("Client order ID for the cancel"), - newClientOrderId: z.string().optional().describe("Client order ID for the new order"), - stopPrice: z.number().optional().describe("Stop price for new order"), - trailingDelta: z.number().optional().describe("Trailing delta for new order"), - icebergQty: z.number().optional().describe("Iceberg quantity for new order"), - newOrderRespType: OrderRespType.optional().describe("Response type for new order"), - selfTradePreventionMode: SelfTradePreventionMode.optional().describe( - "Self-trade prevention mode", - ), - cancelRestrictions: CancelRestrictions.optional().describe("Cancel restrictions"), - recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + description: + "Cancel an existing order and place a new order on the same symbol atomically. This is useful for modifying order parameters.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD)"), + side: OrderSide.describe("Order side: BUY or SELL"), + type: OrderType.describe("Order type for the new order"), + cancelReplaceMode: CancelReplaceMode.describe( + "STOP_ON_FAILURE: Don't place new order if cancel fails. ALLOW_FAILURE: Place new order even if cancel fails.", + ), + cancelOrderId: z + .number() + .optional() + .describe("Order ID to cancel. Either this or cancelOrigClientOrderId required."), + cancelOrigClientOrderId: z + .string() + .optional() + .describe("Client order ID to cancel. Either this or cancelOrderId required."), + timeInForce: TimeInForce.optional().describe("Time in force for new order"), + quantity: z.number().optional().describe("Quantity for new order"), + quoteOrderQty: z.number().optional().describe("Quote order quantity for new order"), + price: z.number().optional().describe("Price for new order"), + cancelNewClientOrderId: z.string().optional().describe("Client order ID for the cancel"), + newClientOrderId: z.string().optional().describe("Client order ID for the new order"), + stopPrice: z.number().optional().describe("Stop price for new order"), + trailingDelta: z.number().optional().describe("Trailing delta for new order"), + icebergQty: z.number().optional().describe("Iceberg quantity for new order"), + newOrderRespType: OrderRespType.optional().describe("Response type for new order"), + selfTradePreventionMode: SelfTradePreventionMode.optional().describe( + "Self-trade prevention mode", + ), + cancelRestrictions: CancelRestrictions.optional().describe("Cancel restrictions"), + recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + }, }, async (params) => { try { @@ -614,17 +629,20 @@ export function registerBinanceUsCancelReplace(server: McpServer) { * Register open orders tool */ export function registerBinanceUsOpenOrders(server: McpServer) { - server.tool( + server.registerTool( "binance_us_open_orders", - "Get all open orders on Binance.US. Can be filtered by symbol. Warning: Querying without symbol is heavier on rate limits (weight 40 vs 3).", { - symbol: z - .string() - .optional() - .describe( - "Trading pair symbol to filter by (e.g., BTCUSD). If omitted, returns all open orders.", - ), - recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + description: + "Get all open orders on Binance.US. Can be filtered by symbol. Warning: Querying without symbol is heavier on rate limits (weight 40 vs 3).", + inputSchema: { + symbol: z + .string() + .optional() + .describe( + "Trading pair symbol to filter by (e.g., BTCUSD). If omitted, returns all open orders.", + ), + recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + }, }, async (params) => { try { @@ -703,19 +721,22 @@ export function registerBinanceUsOpenOrders(server: McpServer) { * Register all orders history tool */ export function registerBinanceUsAllOrders(server: McpServer) { - server.tool( + server.registerTool( "binance_us_all_orders", - "Get all orders (active, canceled, or filled) for a symbol on Binance.US. Returns order history.", { - symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD)"), - orderId: z - .number() - .optional() - .describe("Order ID to start from. Gets orders >= this orderId."), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Number of orders to return (default 500, max 1000)"), - recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + description: + "Get all orders (active, canceled, or filled) for a symbol on Binance.US. Returns order history.", + inputSchema: { + symbol: z.string().describe("Trading pair symbol (e.g., BTCUSD)"), + orderId: z + .number() + .optional() + .describe("Order ID to start from. Gets orders >= this orderId."), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Number of orders to return (default 500, max 1000)"), + recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + }, }, async (params) => { try { @@ -867,16 +888,19 @@ function validateOrderParams(params: any): string | null { * Register cancel all open orders for symbol tool */ export function registerBinanceUsCancelAllOpenOrders(server: McpServer) { - server.tool( + server.registerTool( "binance_us_cancel_all_open_orders", - "Cancel all active orders on a symbol on Binance.US. This includes OCO orders. Use with caution - this will cancel ALL open orders for the specified symbol.", { - symbol: z - .string() - .describe( - "Trading pair symbol (e.g., BTCUSD). Required - all open orders for this symbol will be cancelled.", - ), - recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + description: + "Cancel all active orders on a symbol on Binance.US. This includes OCO orders. Use with caution - this will cancel ALL open orders for the specified symbol.", + inputSchema: { + symbol: z + .string() + .describe( + "Trading pair symbol (e.g., BTCUSD). Required - all open orders for this symbol will be cancelled.", + ), + recvWindow: z.number().optional().describe("Receive window in milliseconds (max 60000)"), + }, }, async (params) => { try { diff --git a/src/tools/userdata-stream/index.ts b/src/tools/userdata-stream/index.ts index c5aa9815..b52d0892 100644 --- a/src/tools/userdata-stream/index.ts +++ b/src/tools/userdata-stream/index.ts @@ -28,8 +28,9 @@ export function registerUserDataStreamTools(server: McpServer) { // ===================================================================== // POST /api/v3/userDataStream - Create Listen Key // ===================================================================== - server.tool( + server.registerTool( "binance_us_create_listen_key", + {}, `Create a new listen key for User Data Stream WebSocket connection. The listen key is used to subscribe to real-time account updates via WebSocket. @@ -87,8 +88,9 @@ Response: ${JSON.stringify(response, null, 2)}`, // ===================================================================== // PUT /api/v3/userDataStream - Keep-alive Listen Key // ===================================================================== - server.tool( + server.registerTool( "binance_us_keepalive_listen_key", + {}, `Extend the validity of a listen key by 60 minutes. ⚠️ IMPORTANT: @@ -131,8 +133,9 @@ Remember to call this again in 30 minutes to maintain the connection.`, // ===================================================================== // DELETE /api/v3/userDataStream - Close Listen Key // ===================================================================== - server.tool( + server.registerTool( "binance_us_close_listen_key", + {}, `Close a User Data Stream by invalidating the listen key. Use this when you're done receiving real-time updates. @@ -173,8 +176,9 @@ To receive real-time updates again, create a new listen key.`, // ===================================================================== // Informational tool about WebSocket streams // ===================================================================== - server.tool( + server.registerTool( "binance_us_websocket_info", + {}, `Get information about available WebSocket streams on Binance.US. Returns details about: diff --git a/src/tools/wallet/index.ts b/src/tools/wallet/index.ts index 5e77cbe9..0ac2ebf4 100644 --- a/src/tools/wallet/index.ts +++ b/src/tools/wallet/index.ts @@ -21,11 +21,14 @@ export function registerWalletTools(server: McpServer) { // binance_us_asset_config // GET /sapi/v1/capital/config/getall // ===================================================== - server.tool( + server.registerTool( "binance_us_asset_config", - "Get details of all crypto assets including fees, withdrawal limits, and network status. Shows deposit/withdrawal enabled status per network.", { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: + "Get details of all crypto assets including fees, withdrawal limits, and network status. Shows deposit/withdrawal enabled status per network.", + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ recvWindow }) => { try { @@ -57,24 +60,27 @@ export function registerWalletTools(server: McpServer) { // binance_us_withdraw_crypto // POST /sapi/v1/capital/withdraw/apply // ===================================================== - server.tool( + server.registerTool( "binance_us_withdraw_crypto", - "Submit a crypto withdrawal request. Requires withdrawal permission on API key. ⚠️ This action transfers funds OUT of your account - verify address carefully!", { - coin: z.string().describe("Asset symbol, e.g., BTC, ETH, USDT"), - network: z - .string() - .describe( - "Withdrawal network, e.g., ERC20, BEP20, BTC. Ensure address type matches network!", - ), - address: z.string().describe("Withdrawal destination address"), - amount: z.number().describe("Withdrawal amount"), - addressTag: z.string().optional().describe("Memo/tag for coins like XRP, XMR, etc."), - withdrawOrderId: z - .string() - .optional() - .describe("Client ID for the withdrawal (for your reference)"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: + "Submit a crypto withdrawal request. Requires withdrawal permission on API key. ⚠️ This action transfers funds OUT of your account - verify address carefully!", + inputSchema: { + coin: z.string().describe("Asset symbol, e.g., BTC, ETH, USDT"), + network: z + .string() + .describe( + "Withdrawal network, e.g., ERC20, BEP20, BTC. Ensure address type matches network!", + ), + address: z.string().describe("Withdrawal destination address"), + amount: z.number().describe("Withdrawal amount"), + addressTag: z.string().optional().describe("Memo/tag for coins like XRP, XMR, etc."), + withdrawOrderId: z + .string() + .optional() + .describe("Client ID for the withdrawal (for your reference)"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ coin, network, address, amount, addressTag, withdrawOrderId, recvWindow }) => { try { @@ -113,18 +119,21 @@ export function registerWalletTools(server: McpServer) { // binance_us_withdraw_fiat // POST /sapi/v1/fiatpayment/withdraw/apply // ===================================================== - server.tool( + server.registerTool( "binance_us_withdraw_fiat", - "Submit a USD withdrawal request via BITGO. ⚠️ This action transfers USD OUT of your account!", { - paymentAccount: z.string().describe("The account to withdraw funds to"), - amount: z.number().describe("USD amount to withdraw"), - paymentMethod: z - .literal("BITGO") - .default("BITGO") - .describe("Payment method (default: BITGO)"), - fiatCurrency: z.literal("USD").default("USD").describe("Fiat currency (default: USD)"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: + "Submit a USD withdrawal request via BITGO. ⚠️ This action transfers USD OUT of your account!", + inputSchema: { + paymentAccount: z.string().describe("The account to withdraw funds to"), + amount: z.number().describe("USD amount to withdraw"), + paymentMethod: z + .literal("BITGO") + .default("BITGO") + .describe("Payment method (default: BITGO)"), + fiatCurrency: z.literal("USD").default("USD").describe("Fiat currency (default: USD)"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ paymentAccount, amount, paymentMethod, fiatCurrency, recvWindow }) => { try { @@ -161,23 +170,25 @@ export function registerWalletTools(server: McpServer) { // binance_us_withdraw_history // GET /sapi/v1/capital/withdraw/history // ===================================================== - server.tool( + server.registerTool( "binance_us_withdraw_history", - "Get crypto withdrawal history. Filter by coin, status, or time range.", { - coin: z.string().optional().describe("Filter by coin symbol"), - withdrawOrderId: z.string().optional().describe("Filter by client withdrawal ID"), - status: z - .number() - .optional() - .describe( - "Status filter: 0=email sent, 1=canceled, 2=awaiting approval, 3=rejected, 4=processing, 5=failure, 6=completed", - ), - startTime: z.number().optional().describe("Start time in ms. Default: 90 days ago"), - endTime: z.number().optional().describe("End time in ms. Default: now"), - offset: z.number().optional().describe("Pagination offset. Default: 0"), - limit: z.number().optional().describe("Number of results. Default: 1000, Max: 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get crypto withdrawal history. Filter by coin, status, or time range.", + inputSchema: { + coin: z.string().optional().describe("Filter by coin symbol"), + withdrawOrderId: z.string().optional().describe("Filter by client withdrawal ID"), + status: z + .number() + .optional() + .describe( + "Status filter: 0=email sent, 1=canceled, 2=awaiting approval, 3=rejected, 4=processing, 5=failure, 6=completed", + ), + startTime: z.number().optional().describe("Start time in ms. Default: 90 days ago"), + endTime: z.number().optional().describe("End time in ms. Default: now"), + offset: z.number().optional().describe("Pagination offset. Default: 0"), + limit: z.number().optional().describe("Number of results. Default: 1000, Max: 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ coin, withdrawOrderId, status, startTime, endTime, offset, limit, recvWindow }) => { try { @@ -216,20 +227,22 @@ export function registerWalletTools(server: McpServer) { // binance_us_deposit_history // GET /sapi/v1/capital/deposit/hisrec // ===================================================== - server.tool( + server.registerTool( "binance_us_deposit_history", - "Get crypto deposit history. Filter by coin, status, or time range.", { - coin: z.string().optional().describe("Filter by coin symbol"), - status: z - .number() - .optional() - .describe("Status filter: 0=pending, 1=success, 6=credited but cannot withdraw"), - startTime: z.number().optional().describe("Start time in ms. Default: 90 days ago"), - endTime: z.number().optional().describe("End time in ms. Default: now"), - offset: z.number().optional().describe("Pagination offset. Default: 0"), - limit: z.number().optional().describe("Number of results. Default: 1000, Max: 1000"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: "Get crypto deposit history. Filter by coin, status, or time range.", + inputSchema: { + coin: z.string().optional().describe("Filter by coin symbol"), + status: z + .number() + .optional() + .describe("Status filter: 0=pending, 1=success, 6=credited but cannot withdraw"), + startTime: z.number().optional().describe("Start time in ms. Default: 90 days ago"), + endTime: z.number().optional().describe("End time in ms. Default: now"), + offset: z.number().optional().describe("Pagination offset. Default: 0"), + limit: z.number().optional().describe("Number of results. Default: 1000, Max: 1000"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ coin, status, startTime, endTime, offset, limit, recvWindow }) => { try { @@ -267,16 +280,19 @@ export function registerWalletTools(server: McpServer) { // binance_us_deposit_address // GET /sapi/v1/capital/deposit/address // ===================================================== - server.tool( + server.registerTool( "binance_us_deposit_address", - "Get a deposit address for a specific crypto asset. Use this to receive funds into your Binance.US account.", { - coin: z.string().describe("Coin symbol to get deposit address for, e.g., BTC, ETH"), - network: z - .string() - .optional() - .describe("Specific network to get address for, e.g., ERC20, BEP20"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + description: + "Get a deposit address for a specific crypto asset. Use this to receive funds into your Binance.US account.", + inputSchema: { + coin: z.string().describe("Coin symbol to get deposit address for, e.g., BTC, ETH"), + network: z + .string() + .optional() + .describe("Specific network to get address for, e.g., ERC20, BEP20"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async ({ coin, network, recvWindow }) => { try { From bc2586a096571e7fec9da300a69b704bb0650ef4 Mon Sep 17 00:00:00 2001 From: netpoe Date: Tue, 17 Mar 2026 12:29:20 -0600 Subject: [PATCH 09/16] feat: add codemod script for updating server.registerTool calls and enhance Binance API with new request handling and error management --- scripts/codemod-register-tool-5-to-3.mjs | 207 ++++++++ src/config/binanceClient.ts | 342 ++++++++++++- src/config/binanceUsClient.ts | 31 +- src/config/testnet.ts | 4 +- src/modules/auto-invest/changePlanStatus.ts | 2 +- src/modules/auto-invest/createPlan.ts | 2 +- src/modules/auto-invest/editPlan.ts | 2 +- src/modules/auto-invest/getHistoryList.ts | 4 +- src/modules/auto-invest/getIndexInfo.ts | 2 +- .../getIndexLinkedPlanPositionDetails.ts | 4 +- .../auto-invest/getIndexUserSummary.ts | 2 +- src/modules/auto-invest/getPlanList.ts | 2 +- src/modules/auto-invest/getSourceAssetList.ts | 2 +- src/modules/auto-invest/getTargetAssetList.ts | 2 +- .../auto-invest/getTargetAssetRoiData.ts | 2 +- src/modules/auto-invest/oneTimeTransaction.ts | 2 +- src/modules/auto-invest/rebalanceHistory.ts | 2 +- src/modules/auto-invest/redemption.ts | 2 +- src/modules/c2c/C2C/getAds.ts | 2 +- .../FutureCopyTrading-api/followTrader.ts | 2 +- .../FutureCopyTrading-api/getCopyOrders.ts | 2 +- .../FutureCopyTrading-api/getCopyPositions.ts | 2 +- .../getFollowingTraders.ts | 2 +- .../getFuturesLeadTraderStatus.ts | 2 +- .../getFuturesLeadTradingSymbolWhitelist.ts | 4 +- .../FutureCopyTrading-api/getLeadTraders.ts | 2 +- .../getTraderPerformance.ts | 2 +- .../getTraderPositions.ts | 2 +- .../getTraderSymbolStats.ts | 2 +- .../FutureCopyTrading-api/unfollowTrader.ts | 2 +- .../crypto-loans/flexible/adjustLTV.ts | 2 +- src/modules/crypto-loans/flexible/borrow.ts | 2 +- .../crypto-loans/flexible/getBorrowHistory.ts | 2 +- .../flexible/getFlexibleCollateralAssets.ts | 4 +- .../flexible/getFlexibleLoanAssets.ts | 2 +- .../crypto-loans/flexible/getOngoingOrders.ts | 2 +- .../crypto-loans/flexible/getRepayHistory.ts | 2 +- src/modules/crypto-loans/flexible/repay.ts | 2 +- .../mining/mining-api/hashrateResaleDetail.ts | 15 +- src/modules/options/account-api/getAccount.ts | 4 +- .../options/account-api/getBillHistory.ts | 4 +- .../options/account-api/getIncomeAsyn.ts | 4 +- .../options/account-api/getIncomeAsynId.ts | 4 +- .../options/account-api/getPosition.ts | 4 +- src/modules/options/market-api/depth.ts | 4 +- .../options/market-api/exchangeInfo.ts | 3 +- .../options/market-api/exerciseHistory.ts | 4 +- .../options/market-api/historicalTrades.ts | 4 +- src/modules/options/market-api/indexPrice.ts | 4 +- src/modules/options/market-api/klines.ts | 4 +- src/modules/options/market-api/mark.ts | 4 +- src/modules/options/market-api/ping.ts | 3 +- src/modules/options/market-api/ticker.ts | 4 +- src/modules/options/market-api/time.ts | 3 +- src/modules/options/market-api/trades.ts | 4 +- src/modules/options/trade-api/batchOrders.ts | 4 +- .../options/trade-api/cancelAllOrders.ts | 4 +- .../options/trade-api/cancelBatchOrders.ts | 4 +- .../options/trade-api/cancelBySymbol.ts | 4 +- src/modules/options/trade-api/cancelOrder.ts | 4 +- .../options/trade-api/getHistoryOrders.ts | 4 +- .../options/trade-api/getOpenOrders.ts | 4 +- .../options/trade-api/getUserTrades.ts | 4 +- src/modules/options/trade-api/newOrder.ts | 4 +- .../options/userdata-api/createListenKey.ts | 3 +- .../options/userdata-api/deleteListenKey.ts | 7 +- .../options/userdata-api/renewListenKey.ts | 7 +- src/modules/pay/pay-api/createOrder.ts | 2 +- src/modules/pay/pay-api/getHistory.ts | 2 +- src/modules/pay/pay-api/getPayTradeHistory.ts | 2 +- src/modules/pay/pay-api/queryOrder.ts | 2 +- .../account-api/getFlexibleProductPosition.ts | 2 +- .../simpleEarnFlexibleProductList.ts | 2 +- src/modules/simple-earn/account/getAccount.ts | 2 +- .../account/getCollateralRecord.ts | 2 +- .../simple-earn/account/getRewardRecord.ts | 2 +- .../earn-api/redeemFlexibleProduct.ts | 2 +- .../earn-api/subscribeFlexibleProduct.ts | 2 +- .../flexible/getFlexiblePosition.ts | 2 +- .../flexible/getFlexibleProductList.ts | 2 +- .../getFlexibleSubscriptionPreview.ts | 2 +- .../simple-earn/flexible/getRateHistory.ts | 2 +- .../flexible/getRedemptionRecord.ts | 2 +- .../flexible/getSubscriptionRecord.ts | 2 +- .../simple-earn/flexible/redeemFlexible.ts | 2 +- .../simple-earn/flexible/subscribeFlexible.ts | 2 +- .../locked/getLockedPersonalQuota.ts | 2 +- .../simple-earn/locked/getLockedPosition.ts | 2 +- .../locked/getLockedProductList.ts | 2 +- .../locked/getLockedSubscriptionPreview.ts | 2 +- .../simple-earn/locked/getRedemptionRecord.ts | 2 +- .../locked/getSubscriptionRecord.ts | 2 +- .../simple-earn/locked/redeemLocked.ts | 2 +- .../simple-earn/locked/setAutoSubscribe.ts | 2 +- .../simple-earn/locked/subscribeLocked.ts | 2 +- .../spot/account-api/accountCommission.ts | 2 +- src/modules/spot/account-api/getAccount.ts | 2 +- src/modules/spot/account-api/myAllocations.ts | 2 +- .../spot/account-api/myPreventedMatches.ts | 2 +- src/modules/spot/account-api/myTrades.ts | 2 +- .../spot/account-api/rateLimitOrder.ts | 2 +- src/modules/spot/general-api/exchangeInfo.ts | 2 +- src/modules/spot/general-api/ping.ts | 2 +- src/modules/spot/general-api/time.ts | 3 +- src/modules/spot/market-api/aggTrades.ts | 2 +- src/modules/spot/market-api/avgPrice.ts | 2 +- src/modules/spot/market-api/depth.ts | 2 +- src/modules/spot/market-api/getTrades.ts | 2 +- .../spot/market-api/historicalTrades.ts | 2 +- src/modules/spot/market-api/klines.ts | 2 +- src/modules/spot/market-api/ticker.ts | 2 +- src/modules/spot/market-api/ticker24hr.ts | 2 +- .../spot/market-api/tickerBookTicker.ts | 2 +- src/modules/spot/market-api/tickerPrice.ts | 2 +- .../spot/market-api/tickerTradingDay.ts | 2 +- src/modules/spot/market-api/uiKlines.ts | 2 +- src/modules/spot/trade-api/allOrders.ts | 2 +- .../spot/trade-api/deleteOpenOrders.ts | 2 +- src/modules/spot/trade-api/deleteOrder.ts | 2 +- src/modules/spot/trade-api/getOpenOrders.ts | 2 +- src/modules/spot/trade-api/getOrder.ts | 2 +- src/modules/spot/trade-api/newOrder.ts | 2 +- src/modules/spot/trade-api/openOrderList.ts | 2 +- src/modules/spot/trade-api/orderOco.ts | 2 +- .../deleteUserDataStream.ts | 2 +- .../userdatastream-api/newUserDataStream.ts | 2 +- .../userdatastream-api/putUserDataStream.ts | 2 +- .../account-api/accountApiTradingStatus.ts | 2 +- src/modules/wallet/account-api/accountInfo.ts | 2 +- .../wallet/account-api/accountStatus.ts | 2 +- .../account-api/dailyAccountSnapshot.ts | 2 +- .../account-api/disableFastWithdrawSwitch.ts | 2 +- .../account-api/enableFastWithdrawSwitch.ts | 2 +- .../wallet/account-api/getApiKeyPermission.ts | 2 +- src/modules/wallet/asset-api/assetDetail.ts | 2 +- .../wallet/asset-api/assetDividendRecord.ts | 2 +- src/modules/wallet/asset-api/dustTransfer.ts | 2 +- src/modules/wallet/asset-api/dustlog.ts | 2 +- src/modules/wallet/asset-api/fundingWallet.ts | 2 +- .../getAssetsThatCanBeConvertedIntoBnb.ts | 4 +- .../getCloudMiningPaymentAndRefundHistory.ts | 4 +- .../wallet/asset-api/getOpenSymbolList.ts | 2 +- .../asset-api/queryUserDelegationHistory.ts | 2 +- .../queryUserUniversalTransferHistory.ts | 4 +- .../asset-api/queryUserWalletBalance.ts | 2 +- ...ggleBnbBurnOnSpotTradeAndMarginInterest.ts | 5 +- src/modules/wallet/asset-api/tradeFee.ts | 2 +- src/modules/wallet/asset-api/userAsset.ts | 2 +- .../wallet/asset-api/userUniversalTransfer.ts | 2 +- .../wallet/capital-api/allCoinsInformation.ts | 2 +- .../wallet/capital-api/depositAddress.ts | 2 +- .../wallet/capital-api/depositHistory.ts | 2 +- .../fetchDepositAddressListWithNetwork.ts | 4 +- .../capital-api/fetchWithdrawAddressList.ts | 2 +- .../oneClickArrivalDepositApply.ts | 2 +- src/modules/wallet/capital-api/withdraw.ts | 2 +- .../wallet/capital-api/withdrawHistory.ts | 2 +- .../getSymbolsDelistScheduleForSpot.ts | 2 +- src/modules/wallet/others-api/systemStatus.ts | 2 +- .../wallet/travel-rule-api/brokerWithdraw.ts | 2 +- .../depositHistoryTravelRule.ts | 2 +- .../travel-rule-api/onboardedVaspList.ts | 2 +- .../submitDepositQuestionnaire.ts | 2 +- .../submitDepositQuestionnaireTravelRule.ts | 4 +- .../travel-rule-api/withdrawHistoryV1.ts | 2 +- .../travel-rule-api/withdrawHistoryV2.ts | 2 +- .../travel-rule-api/withdrawTravelRule.ts | 2 +- .../changeIndexPlanStatus.ts | 2 +- .../binance-auto-invest/changePlanStatus.ts | 2 +- src/tools/binance-auto-invest/createPlan.ts | 2 +- src/tools/binance-auto-invest/editPlan.ts | 2 +- .../binance-auto-invest/getHistoryList.ts | 2 +- src/tools/binance-auto-invest/getIndexInfo.ts | 2 +- .../getIndexLinkedPlanPositionDetails.ts | 4 +- .../getIndexLinkedPlanPositionList.ts | 4 +- .../getIndexLinkedPlanRebalanceHistory.ts | 4 +- .../getIndexUserSummary.ts | 2 +- .../binance-auto-invest/getOneTimePlans.ts | 4 +- src/tools/binance-auto-invest/getPlanList.ts | 2 +- .../binance-auto-invest/getSourceAssetList.ts | 2 +- .../getSubscriptionHistory.ts | 4 +- .../binance-auto-invest/getTargetAssetList.ts | 2 +- .../binance-auto-invest/getTargetAssetROI.ts | 2 +- .../getTargetAssetRoiData.ts | 2 +- .../binance-auto-invest/oneTimeTransaction.ts | 2 +- .../binance-auto-invest/rebalanceHistory.ts | 2 +- .../redeemIndexLinkedPlan.ts | 2 +- src/tools/binance-auto-invest/redemption.ts | 2 +- .../FutureCopyTrading-api/followTrader.ts | 2 +- .../FutureCopyTrading-api/getCopyOrders.ts | 2 +- .../FutureCopyTrading-api/getCopyPositions.ts | 2 +- .../getFollowingTraders.ts | 2 +- .../getFuturesLeadTraderStatus.ts | 2 +- .../getFuturesLeadTradingSymbolWhitelist.ts | 4 +- .../FutureCopyTrading-api/getLeadTraders.ts | 2 +- .../getTraderPerformance.ts | 2 +- .../FutureCopyTrading-api/unfollowTrader.ts | 2 +- .../fixed-api/adjustLTV.ts | 2 +- .../binance-crypto-loans/fixed-api/borrow.ts | 2 +- .../fixed-api/checkCollateralRate.ts | 2 +- .../fixed-api/customizeMarginCall.ts | 2 +- .../fixed-api/getBorrowHistory.ts | 2 +- .../fixed-api/getFixedCollateralData.ts | 2 +- .../fixed-api/getFixedLoanData.ts | 2 +- .../fixed-api/getOngoingOrders.ts | 2 +- .../fixed-api/getRepayHistory.ts | 2 +- .../binance-crypto-loans/fixed-api/repay.ts | 2 +- .../flexible-api/adjustLTV.ts | 2 +- .../flexible-api/borrow.ts | 2 +- .../flexible-api/getBorrowHistory.ts | 2 +- .../getFlexibleCollateralAssets.ts | 4 +- .../flexible-api/getFlexibleLoanAssets.ts | 2 +- .../flexible-api/getOngoingOrders.ts | 2 +- .../flexible-api/getRepayHistory.ts | 2 +- .../flexible-api/repay.ts | 2 +- .../flexibleLoanAdjustLTV.ts | 2 +- .../flexibleLoanBorrow.ts | 2 +- .../flexibleLoanBorrowHistory.ts | 2 +- .../flexibleLoanCollateralAssets.ts | 4 +- .../flexibleLoanLTVAdjustmentHistory.ts | 4 +- .../flexibleLoanLoanableAssets.ts | 2 +- .../flexibleLoanOngoingOrders.ts | 2 +- .../binance-crypto-loans/flexibleLoanRepay.ts | 2 +- .../flexibleLoanRepayHistory.ts | 4 +- .../getCollateralAssetsData.ts | 4 +- .../getCollateralRepayRate.ts | 2 +- .../getLoanableAssetsData.ts | 2 +- src/tools/binance-futures-coinm/account.ts | 2 +- src/tools/binance-futures-coinm/balance.ts | 2 +- src/tools/binance-futures-coinm/bookTicker.ts | 2 +- src/tools/binance-futures-coinm/leverage.ts | 2 +- .../binance-futures-coinm/positionMode.ts | 2 +- .../binance-futures-coinm/positionRisk.ts | 2 +- .../userdatastream-api/createListenKey.ts | 4 +- .../trade-api/allOrders.ts | 3 +- .../trade-api/cancelAllOpenOrders.ts | 4 +- .../trade-api/openOrder.ts | 3 +- .../userdatastream-api/closeListenKey.ts | 5 +- .../userdatastream-api/createListenKey.ts | 4 +- .../userdatastream-api/keepAliveListenKey.ts | 5 +- .../cross-margin-api/crossMarginAllAssets.ts | 2 +- .../disableIsolatedMarginAccount.ts | 2 +- .../enableIsolatedMarginAccount.ts | 2 +- .../isolatedMarginAllSymbols.ts | 2 +- .../isolatedMarginBorrow.ts | 2 +- .../isolatedMarginRepay.ts | 2 +- .../isolatedMarginSymbol.ts | 2 +- .../isolatedMarginTransferHistory.ts | 2 +- .../margin-order-api/marginCancelOco.ts | 2 +- .../margin-order-api/marginGetAllOco.ts | 2 +- .../margin-order-api/marginGetOco.ts | 2 +- .../margin-order-api/marginGetOpenOco.ts | 2 +- .../margin-order-api/marginNewOco.ts | 2 +- .../mining-api/hashrateResaleDetail.ts | 4 +- src/tools/binance-options/exchangeInfo.ts | 5 +- src/tools/binance-options/exerciseHistory.ts | 2 +- .../binance-pay/pay-api/getPayTradeHistory.ts | 2 +- .../account-api/getFlexibleProductPosition.ts | 2 +- .../simpleEarnFlexibleProductList.ts | 2 +- .../earn-api/redeemFlexibleProduct.ts | 2 +- .../earn-api/subscribeFlexibleProduct.ts | 2 +- .../account-api/accountCommission.ts | 2 +- .../binance-spot/account-api/getAccount.ts | 2 +- .../binance-spot/account-api/myAllocations.ts | 2 +- .../account-api/myPreventedMatches.ts | 2 +- .../binance-spot/account-api/myTrades.ts | 2 +- .../account-api/rateLimitOrder.ts | 2 +- .../binance-spot/general-api/exchangeInfo.ts | 2 +- src/tools/binance-spot/general-api/ping.ts | 2 +- src/tools/binance-spot/general-api/time.ts | 3 +- .../binance-spot/market-api/aggTrades.ts | 2 +- src/tools/binance-spot/market-api/avgPrice.ts | 2 +- src/tools/binance-spot/market-api/depth.ts | 2 +- .../binance-spot/market-api/getTrades.ts | 2 +- .../market-api/historicalTrades.ts | 2 +- src/tools/binance-spot/market-api/klines.ts | 2 +- src/tools/binance-spot/market-api/ticker.ts | 2 +- .../binance-spot/market-api/ticker24hr.ts | 2 +- .../market-api/tickerBookTicker.ts | 2 +- .../binance-spot/market-api/tickerPrice.ts | 2 +- .../market-api/tickerTradingDay.ts | 2 +- src/tools/binance-spot/market-api/uiKlines.ts | 2 +- src/tools/binance-spot/trade-api/allOrders.ts | 2 +- .../trade-api/deleteOpenOrders.ts | 2 +- .../binance-spot/trade-api/deleteOrder.ts | 2 +- .../binance-spot/trade-api/getOpenOrders.ts | 2 +- src/tools/binance-spot/trade-api/getOrder.ts | 2 +- src/tools/binance-spot/trade-api/newOrder.ts | 2 +- .../binance-spot/trade-api/openOrderList.ts | 2 +- src/tools/binance-spot/trade-api/orderOco.ts | 2 +- .../deleteUserDataStream.ts | 2 +- .../userdatastream-api/newUserDataStream.ts | 2 +- .../userdatastream-api/putUserDataStream.ts | 2 +- .../assets-api/getFuturesAssetsSummary.ts | 2 +- .../assets-api/getFuturesPositionRisk.ts | 2 +- .../assets-api/getMarginAssetsSummary.ts | 2 +- .../assets-api/getSpotAssetsSummary.ts | 2 +- .../assets-api/getSubAccountAssets.ts | 2 +- .../deposit-api/getDepositAddress.ts | 2 +- .../deposit-api/getDepositHistory.ts | 2 +- .../management-api/createSubAccount.ts | 2 +- .../management-api/enableFutures.ts | 2 +- .../management-api/enableMargin.ts | 2 +- .../getSubAccountApiPermission.ts | 2 +- .../management-api/getSubAccountList.ts | 2 +- .../management-api/getSubAccountStatus.ts | 2 +- .../transfer-api/futuresTransfer.ts | 2 +- .../transfer-api/getTransferHistory.ts | 2 +- .../transfer-api/transferToMaster.ts | 2 +- .../transfer-api/transferToSubAccount.ts | 2 +- .../transfer-api/universalTransfer.ts | 2 +- .../account-api/accountApiTradingStatus.ts | 2 +- .../binance-wallet/account-api/accountInfo.ts | 2 +- .../account-api/accountStatus.ts | 2 +- .../account-api/dailyAccountSnapshot.ts | 2 +- .../account-api/disableFastWithdrawSwitch.ts | 2 +- .../account-api/enableFastWithdrawSwitch.ts | 2 +- .../account-api/getApiKeyPermission.ts | 2 +- .../binance-wallet/asset-api/assetDetail.ts | 2 +- .../asset-api/assetDividendRecord.ts | 2 +- .../binance-wallet/asset-api/dustTransfer.ts | 2 +- src/tools/binance-wallet/asset-api/dustlog.ts | 2 +- .../binance-wallet/asset-api/fundingWallet.ts | 2 +- .../getAssetsThatCanBeConvertedIntoBnb.ts | 4 +- .../getCloudMiningPaymentAndRefundHistory.ts | 4 +- .../asset-api/getOpenSymbolList.ts | 2 +- .../asset-api/queryUserDelegationHistory.ts | 2 +- .../queryUserUniversalTransferHistory.ts | 4 +- .../asset-api/queryUserWalletBalance.ts | 2 +- ...ggleBnbBurnOnSpotTradeAndMarginInterest.ts | 5 +- .../binance-wallet/asset-api/tradeFee.ts | 2 +- .../binance-wallet/asset-api/userAsset.ts | 2 +- .../asset-api/userUniversalTransfer.ts | 2 +- .../capital-api/allCoinsInformation.ts | 2 +- .../capital-api/depositAddress.ts | 2 +- .../capital-api/depositHistory.ts | 2 +- .../fetchDepositAddressListWithNetwork.ts | 4 +- .../capital-api/fetchWithdrawAddressList.ts | 2 +- .../oneClickArrivalDepositApply.ts | 2 +- .../binance-wallet/capital-api/withdraw.ts | 2 +- .../capital-api/withdrawHistory.ts | 2 +- .../getSymbolsDelistScheduleForSpot.ts | 2 +- .../binance-wallet/others-api/systemStatus.ts | 2 +- .../travel-rule-api/brokerWithdraw.ts | 2 +- .../depositHistoryTravelRule.ts | 2 +- .../travel-rule-api/onboardedVaspList.ts | 2 +- .../submitDepositQuestionnaire.ts | 2 +- .../submitDepositQuestionnaireTravelRule.ts | 4 +- .../travel-rule-api/withdrawHistoryV1.ts | 2 +- .../travel-rule-api/withdrawHistoryV2.ts | 2 +- .../travel-rule-api/withdrawTravelRule.ts | 2 +- src/tools/binanceSpotPlaceOrder.ts | 23 +- ...nanceTimeWeightedAveragePriceFutureAlgo.ts | 21 +- src/tools/credit-line/index.ts | 76 +-- src/tools/creditline/index.ts | 189 +++---- src/tools/custodial-solution/index.ts | 183 +++---- src/tools/custodial/index.ts | 476 ++++++++++-------- src/tools/otc/index.ts | 149 +++--- src/tools/staking/index.ts | 166 +++--- src/tools/userdata-stream/index.ts | 36 +- tsconfig.json | 1 + 361 files changed, 1703 insertions(+), 1043 deletions(-) create mode 100644 scripts/codemod-register-tool-5-to-3.mjs diff --git a/scripts/codemod-register-tool-5-to-3.mjs b/scripts/codemod-register-tool-5-to-3.mjs new file mode 100644 index 00000000..4228d575 --- /dev/null +++ b/scripts/codemod-register-tool-5-to-3.mjs @@ -0,0 +1,207 @@ +#!/usr/bin/env node +/** + * Codemod: Convert 5-arg server.registerTool(name, {}, description, inputSchema, cb) + * to 3-arg server.registerTool(name, { description, inputSchema }, cb) + * and add explicit param types to avoid implicit any. + */ +import fs from "fs"; +import path from "path"; +import { fileURLToPath } from "url"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const SRC = path.join(__dirname, "..", "src"); + +const FILES = [ + path.join(SRC, "tools/custodial/index.ts"), + path.join(SRC, "tools/custodial-solution/index.ts"), + path.join(SRC, "tools/creditline/index.ts"), +]; + +function findMatchingBrace(str, start, open = "{", close = "}") { + let depth = 0; + for (let i = start; i < str.length; i++) { + if (str[i] === open) depth++; + else if (str[i] === close) { + depth--; + if (depth === 0) return i; + } + } + return -1; +} + +function findMatchingParen(str, start) { + return findMatchingBrace(str, start, "(", ")"); +} + +function findTemplateLiteralEnd(str, start) { + let i = start; + if (str[i] !== "`") return -1; + i++; + while (i < str.length) { + if (str[i] === "\\") { + i += 2; + continue; + } + if (str[i] === "`") return i; + if (str[i] === "${") { + const end = findMatchingBrace(str, i + 1, "{", "}"); + if (end >= 0) i = end + 1; + else i++; + continue; + } + i++; + } + return -1; +} + +function transformFile(filePath) { + let content = fs.readFileSync(filePath, "utf8"); + const original = content; + let changed = false; + + while (true) { + const idx = content.indexOf("server.registerTool("); + if (idx < 0) break; + const openParen = idx + "server.registerTool".length; + const closeParen = findMatchingParen(content, openParen); + if (closeParen < 0) break; + + const argsStr = content.slice(openParen + 1, closeParen); + let i = 0; + while (i < argsStr.length && /\s/.test(argsStr[i])) i++; + if (i >= argsStr.length) break; + + const firstCh = argsStr[i]; + if (firstCh !== '"' && firstCh !== "'") break; + const q = firstCh; + let nameEnd = i + 1; + while (nameEnd < argsStr.length && argsStr[nameEnd] !== q) { + if (argsStr[nameEnd] === "\\") nameEnd++; + nameEnd++; + } + const name = argsStr.slice(i + 1, nameEnd).replace(/\\"/g, '"'); + i = nameEnd + 1; + while (i < argsStr.length && /[\s,]/.test(argsStr[i])) i++; + if (i >= argsStr.length) break; + if (argsStr[i] !== "{") break; + const emptyEnd = findMatchingBrace(argsStr, i); + if (emptyEnd < 0) break; + const emptyStr = argsStr.slice(i, emptyEnd + 1); + if (emptyStr.replace(/\s/g, "") !== "{}") break; + i = emptyEnd + 1; + while (i < argsStr.length && /[\s,]/.test(argsStr[i])) i++; + if (i >= argsStr.length) break; + if (argsStr[i] !== "`") break; + const descEnd = findTemplateLiteralEnd(argsStr, i); + if (descEnd < 0) break; + const description = argsStr.slice(i, descEnd + 1); + i = descEnd + 1; + while (i < argsStr.length && /[\s,]/.test(argsStr[i])) i++; + if (i >= argsStr.length || argsStr[i] !== "{") break; + const schemaEnd = findMatchingBrace(argsStr, i); + if (schemaEnd < 0) break; + const schemaStr = argsStr.slice(i, schemaEnd + 1); + i = schemaEnd + 1; + while (i < argsStr.length && /[\s,]/.test(argsStr[i])) i++; + const callbackStr = argsStr.slice(i).trim(); + if (!callbackStr.startsWith("async")) break; + + const configObj = `{\n description: ${description},\n inputSchema: ${schemaStr},\n }`; + let newCallback = callbackStr; + const paramsMatch = callbackStr.match(/async\s*\(\s*\{\s*([^}]*)\s*\}\s*\)\s*=>/); + if (paramsMatch) { + const keys = paramsMatch[1].split(",").map((k) => k.trim()); + const typeStr = keys.map((k) => `${k}?: unknown`).join("; "); + newCallback = callbackStr.replace( + /async\s*\(\s*\{\s*[^}]*\s*\}\s*\)\s*=>/, + `async (params: { ${typeStr} }) => { const { ${keys.join(", ")} } = params;` + ); + } else if (callbackStr.includes("async (params)")) { + newCallback = callbackStr.replace("async (params)", "async (params: Record)"); + } + + const newArgs = `"${name.replace(/"/g, '\\"')}",\n ${configObj},\n ${newCallback}`; + content = + content.slice(0, idx) + + "server.registerTool(" + + newArgs + + content.slice(closeParen); + changed = true; + } + + if (changed) { + fs.writeFileSync(filePath, content, "utf8"); + return true; + } + return false; +} + +for (const filePath of FILES) { + if (!fs.existsSync(filePath)) { + console.warn("Skip (not found):", filePath); + continue; + } + let count = 0; + while (true) { + const content = fs.readFileSync(filePath, "utf8"); + const idx = content.indexOf("server.registerTool("); + if (idx < 0) break; + const openParen = content.indexOf("(", idx); + const closeParen = findMatchingParen(content, openParen); + if (closeParen < 0) break; + const argsStr = content.slice(openParen + 1, closeParen); + let i = 0; + while (i < argsStr.length && /\s/.test(argsStr[i])) i++; + if (i >= argsStr.length || (argsStr[i] !== '"' && argsStr[i] !== "'")) break; + const q = argsStr[i]; + const nameStart = i + 1; + let nameEnd = nameStart; + while (nameEnd < argsStr.length && argsStr[nameEnd] !== q) { + if (argsStr[nameEnd] === "\\") nameEnd++; + nameEnd++; + } + const name = argsStr.slice(nameStart, nameEnd).replace(/\\"/g, '"'); + i = nameEnd + 1; + while (i < argsStr.length && /[\s,]/.test(argsStr[i])) i++; + if (i >= argsStr.length || argsStr[i] !== "{") break; + const emptyEnd = findMatchingBrace(argsStr, i); + if (emptyEnd < 0 || argsStr.slice(i, emptyEnd + 1).replace(/\s/g, "") !== "{}") break; + i = emptyEnd + 1; + while (i < argsStr.length && /[\s,]/.test(argsStr[i])) i++; + if (i >= argsStr.length || argsStr[i] !== "`") break; + const descEnd = findTemplateLiteralEnd(argsStr, i); + if (descEnd < 0) break; + const description = argsStr.slice(i, descEnd + 1); + i = descEnd + 1; + while (i < argsStr.length && /[\s,]/.test(argsStr[i])) i++; + if (i >= argsStr.length || argsStr[i] !== "{") break; + const schemaEnd = findMatchingBrace(argsStr, i); + if (schemaEnd < 0) break; + const schemaStr = argsStr.slice(i, schemaEnd + 1); + i = schemaEnd + 1; + while (i < argsStr.length && /[\s,]/.test(argsStr[i])) i++; + const callbackStr = argsStr.slice(i).trim(); + if (!callbackStr.startsWith("async")) break; + const configObj = `{\n description: ${description},\n inputSchema: ${schemaStr},\n }`; + let newCallback = callbackStr; + const paramsMatch = callbackStr.match(/async\s*\(\s*\{\s*([^}]*)\s*\}\s*\)\s*=>/); + if (paramsMatch) { + const keys = paramsMatch[1].split(",").map((k) => k.trim()); + const typeStr = keys.map((k) => `${k}?: unknown`).join("; "); + newCallback = callbackStr.replace( + /async\s*\(\s*\{\s*[^}]*\s*\}\s*\)\s*=>/, + `async (params: { ${typeStr} }) => { const { ${keys.join(", ")} } = params;` + ); + } else if (callbackStr.includes("async (params)")) { + newCallback = callbackStr.replace("async (params)", "async (params: Record)"); + } + const newArgs = `"${name.replace(/"/g, '\\"')}",\n ${configObj},\n ${newCallback}`; + const newContent = + content.slice(0, idx) + "server.registerTool(" + newArgs + content.slice(closeParen + 1); + fs.writeFileSync(filePath, newContent, "utf8"); + count++; + } + if (count > 0) console.log("Updated", count, "tool(s) in", path.relative(SRC, filePath)); +} + +console.log("Done."); diff --git a/src/config/binanceClient.ts b/src/config/binanceClient.ts index 931b9aa1..28448aeb 100644 --- a/src/config/binanceClient.ts +++ b/src/config/binanceClient.ts @@ -142,7 +142,43 @@ async function makePublicRequest(endpoint: string, params: Record = return response.json(); } -// Portfolio Margin client wrapper +// Portfolio Margin uses papi.binance.com for trade/account sub-endpoints +const PAPI_BASE_URL = URLS.PAPI_BASE_URL; + +async function makePapiSignedRequest( + method: "GET" | "POST" | "DELETE" | "PUT", + endpoint: string, + params: Record = {}, +): Promise { + const timestamp = Date.now(); + const queryParams = { ...params, timestamp }; + const queryString = new URLSearchParams( + Object.fromEntries(Object.entries(queryParams).map(([k, v]) => [k, String(v)])), + ).toString(); + const signature = generateSignature(queryString); + const url = `${PAPI_BASE_URL}${endpoint}?${queryString}&signature=${signature}`; + + const response = await fetch(url, { + method, + headers: { + "X-MBX-APIKEY": API_KEY, + "Content-Type": "application/json", + }, + }); + + if (!response.ok) { + const errorData = await response.json().catch(() => ({})); + throw new Error(`Binance API error: ${response.status} - ${JSON.stringify(errorData)}`); + } + + return response.json(); +} + +function wrapData(p: Promise): Promise<{ data: () => Promise }> { + return p.then((data) => ({ data: () => Promise.resolve(data) })); +} + +// Portfolio Margin client wrapper (includes restAPI for modules that expect .restAPI.method().then(r => r.data())) export const portfolioMarginClient = { getAccount: (params: Record = {}) => makeSignedRequest("GET", "/sapi/v1/portfolio/account", params), @@ -172,6 +208,85 @@ export const portfolioMarginClient = { makeSignedRequest("GET", "/sapi/v1/portfolio/margin-asset-leverage", params), getBalance: (params: Record = {}) => makeSignedRequest("GET", "/sapi/v1/portfolio/balance", params), + restAPI: { + account: (params: Record = {}) => + wrapData(makeSignedRequest("GET", "/sapi/v1/portfolio/account", params)), + balance: (params: Record = {}) => + wrapData(makeSignedRequest("GET", "/sapi/v1/portfolio/balance", params)), + umAccount: (params: Record = {}) => + wrapData(makePapiSignedRequest("GET", "/papi/v1/um/account", params)), + umPositionRisk: (params: Record = {}) => + wrapData(makePapiSignedRequest("GET", "/papi/v1/um/positionRisk", params)), + cmAccount: (params: Record = {}) => + wrapData(makePapiSignedRequest("GET", "/papi/v1/cm/account", params)), + cmPositionRisk: (params: Record = {}) => + wrapData(makePapiSignedRequest("GET", "/papi/v1/cm/positionRisk", params)), + marginAccount: (params: Record = {}) => + wrapData(makePapiSignedRequest("GET", "/papi/v1/marginAccount", params)), + marginMaxWithdraw: (params: Record) => + wrapData(makePapiSignedRequest("GET", "/papi/v1/marginMaxWithdraw", params)), + marginMaxBorrowable: (params: Record) => + wrapData(makePapiSignedRequest("GET", "/papi/v1/marginMaxBorrowable", params)), + umNewOrder: (params: Record) => + wrapData(makePapiSignedRequest("POST", "/papi/v1/um/order", params)), + umCancelOrder: (params: Record) => + wrapData(makePapiSignedRequest("DELETE", "/papi/v1/um/order", params)), + umOrder: (params: Record) => + wrapData(makePapiSignedRequest("GET", "/papi/v1/um/order", params)), + umOpenOrders: (params: Record = {}) => + wrapData(makePapiSignedRequest("GET", "/papi/v1/um/openOrders", params)), + umAllOrders: (params: Record) => + wrapData(makePapiSignedRequest("GET", "/papi/v1/um/allOrders", params)), + umUserTrades: (params: Record) => + wrapData(makePapiSignedRequest("GET", "/papi/v1/um/userTrades", params)), + umLeverage: (params: Record) => + wrapData(makePapiSignedRequest("POST", "/papi/v1/um/leverage", params)), + umMarginType: (params: Record) => + wrapData(makePapiSignedRequest("POST", "/papi/v1/um/marginType", params)), + umCancelAllOpenOrders: (params: Record) => + wrapData(makePapiSignedRequest("DELETE", "/papi/v1/um/allOpenOrders", params)), + cmNewOrder: (params: Record) => + wrapData(makePapiSignedRequest("POST", "/papi/v1/cm/order", params)), + cmCancelOrder: (params: Record) => + wrapData(makePapiSignedRequest("DELETE", "/papi/v1/cm/order", params)), + cmOrder: (params: Record) => + wrapData(makePapiSignedRequest("GET", "/papi/v1/cm/order", params)), + cmOpenOrders: (params: Record = {}) => + wrapData(makePapiSignedRequest("GET", "/papi/v1/cm/openOrders", params)), + cmAllOrders: (params: Record) => + wrapData(makePapiSignedRequest("GET", "/papi/v1/cm/allOrders", params)), + cmUserTrades: (params: Record) => + wrapData(makePapiSignedRequest("GET", "/papi/v1/cm/userTrades", params)), + cmLeverage: (params: Record) => + wrapData(makePapiSignedRequest("POST", "/papi/v1/cm/leverage", params)), + cmMarginType: (params: Record) => + wrapData(makePapiSignedRequest("POST", "/papi/v1/cm/marginType", params)), + cmCancelAllOpenOrders: (params: Record) => + wrapData(makePapiSignedRequest("DELETE", "/papi/v1/cm/allOpenOrders", params)), + marginNewOrder: (params: Record) => + wrapData(makePapiSignedRequest("POST", "/papi/v1/margin/order", params)), + marginCancelOrder: (params: Record) => + wrapData(makePapiSignedRequest("DELETE", "/papi/v1/margin/order", params)), + marginOrder: (params: Record) => + wrapData(makePapiSignedRequest("GET", "/papi/v1/margin/order", params)), + marginOpenOrders: (params: Record = {}) => + wrapData(makePapiSignedRequest("GET", "/papi/v1/margin/openOrders", params)), + marginAllOrders: (params: Record) => + wrapData(makePapiSignedRequest("GET", "/papi/v1/margin/allOrders", params)), + marginMyTrades: (params: Record) => + wrapData(makePapiSignedRequest("GET", "/papi/v1/margin/myTrades", params)), + marginLoan: (params: Record) => + wrapData(makePapiSignedRequest("POST", "/papi/v1/margin/loan", params)), + marginRepay: (params: Record) => + wrapData(makePapiSignedRequest("POST", "/papi/v1/margin/repay", params)), + marginCancelAllOpenOrders: (params: Record) => + wrapData(makePapiSignedRequest("DELETE", "/papi/v1/margin/allOpenOrders", params)), + createListenKey: () => wrapData(makePapiSignedRequest("POST", "/papi/v1/listenKey", {})), + deleteListenKey: (params: Record = {}) => + wrapData(makePapiSignedRequest("DELETE", "/papi/v1/listenKey", params)), + renewListenKey: (params: Record = {}) => + wrapData(makePapiSignedRequest("PUT", "/papi/v1/listenKey", params)), + }, }; // Gift Card client wrapper @@ -190,6 +305,15 @@ export const giftCardClient = { makeSignedRequest("POST", "/sapi/v1/giftcard/buyCode", params), getTokenLimit: (params: Record = {}) => makeSignedRequest("GET", "/sapi/v1/giftcard/buyCode/token-limit", params), + restAPI: { + createCode: (p: Record = {}) => wrapData(giftCardClient.createCode(p)), + createDualTokenCode: (p: Record = {}) => + wrapData(giftCardClient.createDualTokenCode(p)), + redeemCode: (p: Record = {}) => wrapData(giftCardClient.redeemCode(p)), + redeemDualTokenCode: (p: Record = {}) => wrapData(giftCardClient.redeemCode(p)), + verify: (p: Record = {}) => wrapData(giftCardClient.verify(p)), + tokenLimit: (p: Record = {}) => wrapData(giftCardClient.getTokenLimit(p)), + }, }; // Margin client wrapper @@ -357,6 +481,8 @@ export const futuresClient = { // Account/Trade newOrder: (params: Record) => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "POST", "/fapi/v1/order", params), + modifyOrder: (params: Record) => + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "PUT", "/fapi/v1/order", params), batchOrders: (params: Record) => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "POST", "/fapi/v1/batchOrders", params), getOrder: (params: Record) => @@ -397,6 +523,8 @@ export const futuresClient = { makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v1/positionSide/dual", params), changePositionMode: (params: Record) => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "POST", "/fapi/v1/positionSide/dual", params), + multiAssetsMargin: (params: Record) => + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "POST", "/fapi/v1/multiAssetsMargin", params), // User Data Stream createListenKey: () => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "POST", "/fapi/v1/listenKey", {}), @@ -404,6 +532,126 @@ export const futuresClient = { makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "PUT", "/fapi/v1/listenKey", {}), closeListenKey: () => makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "DELETE", "/fapi/v1/listenKey", {}), + restAPI: { + account: (p: Record = {}) => wrapData(futuresClient.account(p)), + balance: (p: Record = {}) => wrapData(futuresClient.balance(p)), + positionRisk: (p: Record = {}) => wrapData(futuresClient.positionRisk(p)), + ping: () => wrapData(futuresClient.ping()), + time: () => wrapData(futuresClient.time()), + exchangeInfo: () => wrapData(futuresClient.exchangeInfo()), + depth: (p: Record) => wrapData(futuresClient.depth(p)), + trades: (p: Record) => wrapData(futuresClient.trades(p)), + historicalTrades: (p: Record) => wrapData(futuresClient.historicalTrades(p)), + aggTrades: (p: Record) => wrapData(futuresClient.aggTrades(p)), + klines: (p: Record) => wrapData(futuresClient.klines(p)), + continuousKlines: (p: Record) => wrapData(futuresClient.continuousKlines(p)), + indexPriceKlines: (p: Record) => wrapData(futuresClient.indexPriceKlines(p)), + markPriceKlines: (p: Record) => wrapData(futuresClient.markPriceKlines(p)), + premiumIndex: (p: Record = {}) => wrapData(futuresClient.premiumIndex(p)), + fundingRate: (p: Record) => wrapData(futuresClient.fundingRate(p)), + ticker24hr: (p: Record = {}) => wrapData(futuresClient.ticker24hr(p)), + tickerPrice: (p: Record) => wrapData(futuresClient.tickerPrice(p)), + bookTicker: (p: Record = {}) => wrapData(futuresClient.bookTicker(p)), + openInterest: (p: Record) => wrapData(futuresClient.openInterest(p)), + newOrder: (p: Record) => wrapData(futuresClient.newOrder(p)), + modifyOrder: (p: Record) => wrapData(futuresClient.modifyOrder(p)), + getOrder: (p: Record) => wrapData(futuresClient.getOrder(p)), + queryOrder: (p: Record) => wrapData(futuresClient.getOrder(p)), + cancelOrder: (p: Record) => wrapData(futuresClient.cancelOrder(p)), + cancelAllOpenOrders: (p: Record = {}) => + wrapData(futuresClient.cancelAllOpenOrders(p)), + cancelBatchOrders: (p: Record) => wrapData(futuresClient.cancelBatchOrders(p)), + openOrders: (p: Record = {}) => wrapData(futuresClient.openOrders(p)), + allOrders: (p: Record) => wrapData(futuresClient.allOrders(p)), + userTrades: (p: Record) => wrapData(futuresClient.userTrades(p)), + income: (p: Record = {}) => wrapData(futuresClient.income(p)), + commissionRate: (p: Record) => wrapData(futuresClient.commissionRate(p)), + adlQuantile: (p: Record = {}) => wrapData(futuresClient.adlQuantile(p)), + forceOrders: (p: Record) => wrapData(futuresClient.forceOrders(p)), + positionMode: (p: Record = {}) => wrapData(futuresClient.positionMode(p)), + getPositionMode: (p: Record = {}) => wrapData(futuresClient.positionMode(p)), + changePositionMode: (p: Record) => wrapData(futuresClient.changePositionMode(p)), + leverage: (p: Record) => wrapData(futuresClient.leverage(p)), + changeInitialLeverage: (p: Record) => wrapData(futuresClient.leverage(p)), + marginType: (p: Record) => wrapData(futuresClient.marginType(p)), + changeMarginType: (p: Record) => wrapData(futuresClient.marginType(p)), + positionMargin: (p: Record) => wrapData(futuresClient.positionMargin(p)), + modifyIsolatedPositionMargin: (p: Record) => + wrapData(futuresClient.positionMargin(p)), + currentAllOpenOrders: (p: Record = {}) => wrapData(futuresClient.openOrders(p)), + createListenKey: () => wrapData(futuresClient.createListenKey()), + keepAliveListenKey: () => wrapData(futuresClient.keepAliveListenKey()), + closeListenKey: () => wrapData(futuresClient.closeListenKey()), + fundingInfo: () => + wrapData(makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/fundingRate", {})), + assetIndex: (p: Record = {}) => + wrapData(makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/assetIndex", p)), + // Aliases / additional endpoints for tool compatibility + apiTradingStatus: (p: Record = {}) => + wrapData( + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v1/apiTradingStatus", p), + ), + downloadIdForFuturesTransactionHistory: (p: Record = {}) => + wrapData(makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v1/income/asyn", p)), + leverageBracket: (p: Record = {}) => + wrapData(makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/leverageBracket", p)), + getMultiAssetsMode: (p: Record = {}) => + wrapData( + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v1/multiAssetsMargin", p), + ), + getPositionMarginChangeHistory: (p: Record = {}) => + wrapData( + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v1/positionMargin/history", p), + ), + getPositionMarginHistory: (p: Record = {}) => + wrapData( + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "GET", "/fapi/v1/positionMargin/history", p), + ), + globalLongShortAccountRatio: (p: Record) => + wrapData( + makeFuturesPublicRequest( + FUTURES_USD_BASE_URL, + "/futures/data/globalLongShortAccountRatio", + p, + ), + ), + indexInfo: (p: Record = {}) => + wrapData(makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/fapi/v1/indexInfo", p)), + lvtKlines: (p: Record) => + wrapData(makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/futures/data/lvtKlines", p)), + openInterestHist: (p: Record) => + wrapData(makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/futures/data/openInterestHist", p)), + takerlongshortRatio: (p: Record) => + wrapData( + makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/futures/data/takerlongshortRatio", p), + ), + tickerBookTicker: (p: Record = {}) => wrapData(futuresClient.bookTicker(p)), + topLongShortAccountRatio: (p: Record) => + wrapData( + makeFuturesPublicRequest(FUTURES_USD_BASE_URL, "/futures/data/topLongShortAccountRatio", p), + ), + topLongShortPositionRatio: (p: Record) => + wrapData( + makeFuturesPublicRequest( + FUTURES_USD_BASE_URL, + "/futures/data/topLongShortPositionRatio", + p, + ), + ), + placeMultipleOrders: (p: Record) => wrapData(futuresClient.batchOrders(p)), + cancelMultipleOrders: (p: Record) => wrapData(futuresClient.cancelBatchOrders(p)), + changeMultiAssetsMode: (p: Record) => + wrapData( + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "POST", "/fapi/v1/multiAssetsMargin", p), + ), + autoCancelAllOpenOrders: (p: Record) => + wrapData( + makeFuturesSignedRequest(FUTURES_USD_BASE_URL, "POST", "/fapi/v1/countdownCancelAll", p), + ), + queryCurrentOpenOrder: (p: Record) => wrapData(futuresClient.getOrder(p)), + currentOpenOrder: (p: Record = {}) => wrapData(futuresClient.openOrders(p)), + renewListenKey: () => wrapData(futuresClient.keepAliveListenKey()), + }, }; // Futures COIN-M client wrapper (delivery) @@ -440,6 +688,10 @@ export const deliveryClient = { makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/ticker/bookTicker", params), openInterest: (params: Record) => makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/openInterest", params), + openInterestHist: (params: Record) => + makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/openInterestHist", params), + leverageBracket: (params: Record = {}) => + makeFuturesPublicRequest(FUTURES_COIN_BASE_URL, "/dapi/v1/leverageBracket", params), // Account/Trade newOrder: (params: Record) => makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "POST", "/dapi/v1/order", params), @@ -486,10 +738,72 @@ export const deliveryClient = { // User Data Stream createListenKey: () => makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "POST", "/dapi/v1/listenKey", {}), - keepAliveListenKey: () => - makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "PUT", "/dapi/v1/listenKey", {}), - closeListenKey: () => - makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "DELETE", "/dapi/v1/listenKey", {}), + keepAliveListenKey: (params: Record = {}) => + makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "PUT", "/dapi/v1/listenKey", params), + closeListenKey: (params: Record = {}) => + makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "DELETE", "/dapi/v1/listenKey", params), + autoCancelAllOpenOrders: (params: Record) => + makeFuturesSignedRequest(FUTURES_COIN_BASE_URL, "POST", "/dapi/v1/countdownCancelAll", params), + restAPI: { + account: (p: Record = {}) => wrapData(deliveryClient.account(p)), + balance: (p: Record = {}) => wrapData(deliveryClient.balance(p)), + positionRisk: (p: Record = {}) => wrapData(deliveryClient.positionRisk(p)), + ping: () => wrapData(deliveryClient.ping()), + time: () => wrapData(deliveryClient.time()), + exchangeInfo: () => wrapData(deliveryClient.exchangeInfo()), + depth: (p: Record) => wrapData(deliveryClient.depth(p)), + trades: (p: Record) => wrapData(deliveryClient.trades(p)), + historicalTrades: (p: Record) => wrapData(deliveryClient.historicalTrades(p)), + aggTrades: (p: Record) => wrapData(deliveryClient.aggTrades(p)), + klines: (p: Record) => wrapData(deliveryClient.klines(p)), + continuousKlines: (p: Record) => wrapData(deliveryClient.continuousKlines(p)), + indexPriceKlines: (p: Record) => wrapData(deliveryClient.indexPriceKlines(p)), + markPriceKlines: (p: Record) => wrapData(deliveryClient.markPriceKlines(p)), + premiumIndex: (p: Record = {}) => wrapData(deliveryClient.premiumIndex(p)), + fundingRate: (p: Record) => wrapData(deliveryClient.fundingRate(p)), + ticker24hr: (p: Record = {}) => wrapData(deliveryClient.ticker24hr(p)), + tickerPrice: (p: Record) => wrapData(deliveryClient.tickerPrice(p)), + bookTicker: (p: Record = {}) => wrapData(deliveryClient.bookTicker(p)), + tickerBookTicker: (p: Record = {}) => wrapData(deliveryClient.bookTicker(p)), + openInterest: (p: Record) => wrapData(deliveryClient.openInterest(p)), + openInterestHist: (p: Record) => wrapData(deliveryClient.openInterestHist(p)), + leverageBracket: (p: Record = {}) => wrapData(deliveryClient.leverageBracket(p)), + newOrder: (p: Record) => wrapData(deliveryClient.newOrder(p)), + getOrder: (p: Record) => wrapData(deliveryClient.getOrder(p)), + queryOrder: (p: Record) => wrapData(deliveryClient.getOrder(p)), + cancelOrder: (p: Record) => wrapData(deliveryClient.cancelOrder(p)), + cancelAllOpenOrders: (p: Record = {}) => + wrapData(deliveryClient.cancelAllOpenOrders(p)), + cancelBatchOrders: (p: Record) => wrapData(deliveryClient.cancelBatchOrders(p)), + cancelMultipleOrders: (p: Record) => wrapData(deliveryClient.cancelBatchOrders(p)), + openOrders: (p: Record = {}) => wrapData(deliveryClient.openOrders(p)), + currentAllOpenOrders: (p: Record = {}) => wrapData(deliveryClient.openOrders(p)), + allOrders: (p: Record) => wrapData(deliveryClient.allOrders(p)), + currentOpenOrder: (p: Record) => wrapData(deliveryClient.getOrder(p)), + userTrades: (p: Record) => wrapData(deliveryClient.userTrades(p)), + income: (p: Record = {}) => wrapData(deliveryClient.income(p)), + commissionRate: (p: Record) => wrapData(deliveryClient.commissionRate(p)), + adlQuantile: (p: Record = {}) => wrapData(deliveryClient.adlQuantile(p)), + forceOrders: (p: Record) => wrapData(deliveryClient.forceOrders(p)), + positionMode: (p: Record = {}) => wrapData(deliveryClient.positionMode(p)), + getPositionMode: (p: Record = {}) => wrapData(deliveryClient.positionMode(p)), + changePositionMode: (p: Record) => wrapData(deliveryClient.changePositionMode(p)), + leverage: (p: Record) => wrapData(deliveryClient.leverage(p)), + changeInitialLeverage: (p: Record) => wrapData(deliveryClient.leverage(p)), + marginType: (p: Record) => wrapData(deliveryClient.marginType(p)), + changeMarginType: (p: Record) => wrapData(deliveryClient.marginType(p)), + positionMargin: (p: Record) => wrapData(deliveryClient.positionMargin(p)), + modifyIsolatedPositionMargin: (p: Record) => + wrapData(deliveryClient.positionMargin(p)), + batchOrders: (p: Record) => wrapData(deliveryClient.batchOrders(p)), + placeMultipleOrders: (p: Record) => wrapData(deliveryClient.batchOrders(p)), + autoCancelAllOpenOrders: (p: Record) => + wrapData(deliveryClient.autoCancelAllOpenOrders(p)), + createListenKey: () => wrapData(deliveryClient.createListenKey()), + keepAliveListenKey: () => wrapData(deliveryClient.keepAliveListenKey()), + renewListenKey: (p: Record = {}) => wrapData(deliveryClient.keepAliveListenKey(p)), + closeListenKey: (p: Record = {}) => wrapData(deliveryClient.closeListenKey(p)), + }, }; // Sub-Account client wrapper (using REST API) @@ -582,13 +896,23 @@ export const optionsClient = { makeFuturesSignedRequest(OPTIONS_BASE_URL, "GET", "/eapi/v1/account", params), exerciseRecord: (params: Record = {}) => makeFuturesSignedRequest(OPTIONS_BASE_URL, "GET", "/eapi/v1/exerciseRecord", params), + openInterest: (params: Record = {}) => + makeFuturesPublicRequest(OPTIONS_BASE_URL, "/eapi/v1/openInterest", params), bill: (params: Record = {}) => makeFuturesSignedRequest(OPTIONS_BASE_URL, "GET", "/eapi/v1/bill", params), + incomeAsyn: (params: Record = {}) => + makeFuturesSignedRequest(OPTIONS_BASE_URL, "GET", "/eapi/v1/incomeAsyn", params), + incomeAsynId: (params: Record) => + makeFuturesSignedRequest(OPTIONS_BASE_URL, "GET", "/eapi/v1/incomeAsynId", params), + historicalTrades: (params: Record) => + makeFuturesPublicRequest(OPTIONS_BASE_URL, "/eapi/v1/historicalTrades", params), + cancelAllOpenOrdersByUnderlying: (params: Record) => + makeFuturesSignedRequest(OPTIONS_BASE_URL, "DELETE", "/eapi/v1/allOpenOrders", params), // User Data Stream createListenKey: () => makeFuturesSignedRequest(OPTIONS_BASE_URL, "POST", "/eapi/v1/listenKey", {}), - keepAliveListenKey: () => - makeFuturesSignedRequest(OPTIONS_BASE_URL, "PUT", "/eapi/v1/listenKey", {}), - closeListenKey: () => - makeFuturesSignedRequest(OPTIONS_BASE_URL, "DELETE", "/eapi/v1/listenKey", {}), + keepAliveListenKey: (params: Record = {}) => + makeFuturesSignedRequest(OPTIONS_BASE_URL, "PUT", "/eapi/v1/listenKey", params), + closeListenKey: (params: Record = {}) => + makeFuturesSignedRequest(OPTIONS_BASE_URL, "DELETE", "/eapi/v1/listenKey", params), }; diff --git a/src/config/binanceUsClient.ts b/src/config/binanceUsClient.ts index 6b145703..0be12dfa 100644 --- a/src/config/binanceUsClient.ts +++ b/src/config/binanceUsClient.ts @@ -430,7 +430,7 @@ export async function makeSignedRequest( ? `${BASE_URL}${endpoint}?${signedQueryString}` : `${BASE_URL}${endpoint}`; - const headers: HeadersInit = { + const headers: Record = { "X-MBX-APIKEY": API_KEY, "Content-Type": "application/x-www-form-urlencoded", }; @@ -469,10 +469,13 @@ export async function makeSignedRequest( } if (!response.ok) { - const errorData = await response.json().catch(() => ({ msg: response.statusText })); + const errorData = (await response.json().catch(() => ({ msg: response.statusText }))) as { + code?: number; + msg?: string; + }; throw new BinanceUsApiError( - errorData.code || response.status, - errorData.msg || response.statusText, + errorData.code ?? response.status, + errorData.msg ?? response.statusText, response.status, rateLimitInfo, ); @@ -516,10 +519,13 @@ export async function makePublicRequest( } if (!response.ok) { - const errorData = await response.json().catch(() => ({ msg: response.statusText })); + const errorData = (await response.json().catch(() => ({ msg: response.statusText }))) as { + code?: number; + msg?: string; + }; throw new BinanceUsApiError( - errorData.code || response.status, - errorData.msg || response.statusText, + errorData.code ?? response.status, + errorData.msg ?? response.statusText, response.status, rateLimitInfo, ); @@ -555,7 +561,7 @@ export async function makeMarketDataRequest( const queryString = buildQueryString(params); const url = queryString ? `${BASE_URL}${endpoint}?${queryString}` : `${BASE_URL}${endpoint}`; - const headers: HeadersInit = { + const headers: Record = { "X-MBX-APIKEY": API_KEY, }; @@ -583,10 +589,13 @@ export async function makeMarketDataRequest( } if (!response.ok) { - const errorData = await response.json().catch(() => ({ msg: response.statusText })); + const errorData = (await response.json().catch(() => ({ msg: response.statusText }))) as { + code?: number; + msg?: string; + }; throw new BinanceUsApiError( - errorData.code || response.status, - errorData.msg || response.statusText, + errorData.code ?? response.status, + errorData.msg ?? response.statusText, response.status, rateLimitInfo, ); diff --git a/src/config/testnet.ts b/src/config/testnet.ts index 4784e747..ad53a0ba 100644 --- a/src/config/testnet.ts +++ b/src/config/testnet.ts @@ -21,6 +21,7 @@ const PROD_SPOT_WS_STREAM_URL = "wss://stream.binance.com"; const PROD_FUTURES_USD_BASE_URL = "https://fapi.binance.com"; const PROD_FUTURES_COIN_BASE_URL = "https://dapi.binance.com"; const PROD_OPTIONS_BASE_URL = "https://eapi.binance.com"; +const PROD_PAPI_BASE_URL = "https://papi.binance.com"; export const URLS = { SPOT_BASE_URL: IS_TESTNET ? TESTNET_SPOT_BASE_URL : PROD_SPOT_BASE_URL, @@ -28,8 +29,9 @@ export const URLS = { SPOT_WS_STREAM_URL: IS_TESTNET ? TESTNET_SPOT_WS_STREAM_URL : PROD_SPOT_WS_STREAM_URL, FUTURES_USD_BASE_URL: IS_TESTNET ? TESTNET_FUTURES_BASE_URL : PROD_FUTURES_USD_BASE_URL, FUTURES_COIN_BASE_URL: IS_TESTNET ? TESTNET_FUTURES_BASE_URL : PROD_FUTURES_COIN_BASE_URL, - // No testnet for options — always production + // No testnet for options / portfolio margin — always production OPTIONS_BASE_URL: PROD_OPTIONS_BASE_URL, + PAPI_BASE_URL: PROD_PAPI_BASE_URL, } as const; /** diff --git a/src/modules/auto-invest/changePlanStatus.ts b/src/modules/auto-invest/changePlanStatus.ts index 2eddef03..bf15658d 100644 --- a/src/modules/auto-invest/changePlanStatus.ts +++ b/src/modules/auto-invest/changePlanStatus.ts @@ -26,7 +26,7 @@ export function registerAutoInvestChangePlanStatus(server: McpServer) { }, async (params) => { try { - const response = await autoInvestClient.restAPI.planEditStatus({ + const response = await (autoInvestClient as any).restAPI.changePlanStatus({ planId: params.planId, status: params.status, ...(params.recvWindow && { recvWindow: params.recvWindow }), diff --git a/src/modules/auto-invest/createPlan.ts b/src/modules/auto-invest/createPlan.ts index 97782ab4..9765cd07 100644 --- a/src/modules/auto-invest/createPlan.ts +++ b/src/modules/auto-invest/createPlan.ts @@ -48,7 +48,7 @@ export function registerAutoInvestCreatePlan(server: McpServer) { }, async (params) => { try { - const response = await autoInvestClient.restAPI.planAdd({ + const response = await (autoInvestClient as any).restAPI.investmentPlanCreation({ sourceType: params.sourceType, planType: params.planType, subscriptionAmount: params.subscriptionAmount, diff --git a/src/modules/auto-invest/editPlan.ts b/src/modules/auto-invest/editPlan.ts index 552e84d5..0b4f98d6 100644 --- a/src/modules/auto-invest/editPlan.ts +++ b/src/modules/auto-invest/editPlan.ts @@ -47,7 +47,7 @@ export function registerAutoInvestEditPlan(server: McpServer) { }, async (params) => { try { - const response = await autoInvestClient.restAPI.planEdit({ + const response = await (autoInvestClient as any).restAPI.investmentPlanAdjustment({ planId: params.planId, subscriptionAmount: params.subscriptionAmount, subscriptionCycle: params.subscriptionCycle, diff --git a/src/modules/auto-invest/getHistoryList.ts b/src/modules/auto-invest/getHistoryList.ts index 4f458d9c..c7eae4fe 100644 --- a/src/modules/auto-invest/getHistoryList.ts +++ b/src/modules/auto-invest/getHistoryList.ts @@ -38,7 +38,9 @@ export function registerAutoInvestGetHistoryList(server: McpServer) { }, async (params) => { try { - const response = await autoInvestClient.restAPI.historyList({ + const response = await ( + autoInvestClient as any + ).restAPI.querySubscriptionTransactionHistory({ ...(params.planId && { planId: params.planId }), ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), diff --git a/src/modules/auto-invest/getIndexInfo.ts b/src/modules/auto-invest/getIndexInfo.ts index 292cdb36..7e7e6847 100644 --- a/src/modules/auto-invest/getIndexInfo.ts +++ b/src/modules/auto-invest/getIndexInfo.ts @@ -24,7 +24,7 @@ export function registerAutoInvestGetIndexInfo(server: McpServer) { }, async (params) => { try { - const response = await autoInvestClient.restAPI.indexInfo({ + const response = await (autoInvestClient as any).restAPI.queryIndexDetails({ ...(params.indexId && { indexId: params.indexId }), ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/modules/auto-invest/getIndexLinkedPlanPositionDetails.ts b/src/modules/auto-invest/getIndexLinkedPlanPositionDetails.ts index 6e43198f..f6f08e54 100644 --- a/src/modules/auto-invest/getIndexLinkedPlanPositionDetails.ts +++ b/src/modules/auto-invest/getIndexLinkedPlanPositionDetails.ts @@ -24,7 +24,9 @@ export function registerAutoInvestGetIndexLinkedPlanPositionDetails(server: McpS }, async (params) => { try { - const response = await autoInvestClient.restAPI.planId({ + const response = await ( + autoInvestClient as any + ).restAPI.queryIndexLinkedPlanPositionDetails({ planId: params.planId, ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/modules/auto-invest/getIndexUserSummary.ts b/src/modules/auto-invest/getIndexUserSummary.ts index 557e8219..068dbe54 100644 --- a/src/modules/auto-invest/getIndexUserSummary.ts +++ b/src/modules/auto-invest/getIndexUserSummary.ts @@ -23,7 +23,7 @@ export function registerAutoInvestGetIndexUserSummary(server: McpServer) { }, async (params) => { try { - const response = await autoInvestClient.restAPI.indexUserSummary({ + const response = await (autoInvestClient as any).restAPI.queryIndexDetails({ indexId: params.indexId, ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/modules/auto-invest/getPlanList.ts b/src/modules/auto-invest/getPlanList.ts index e7b04dc9..08f89568 100644 --- a/src/modules/auto-invest/getPlanList.ts +++ b/src/modules/auto-invest/getPlanList.ts @@ -26,7 +26,7 @@ export function registerAutoInvestGetPlanList(server: McpServer) { }, async (params) => { try { - const response = await autoInvestClient.restAPI.planList({ + const response = await (autoInvestClient as any).restAPI.getListOfPlans({ ...(params.planType && { planType: params.planType }), ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/modules/auto-invest/getSourceAssetList.ts b/src/modules/auto-invest/getSourceAssetList.ts index 53d32955..1471132d 100644 --- a/src/modules/auto-invest/getSourceAssetList.ts +++ b/src/modules/auto-invest/getSourceAssetList.ts @@ -30,7 +30,7 @@ export function registerAutoInvestGetSourceAssetList(server: McpServer) { }, async (params) => { try { - const response = await autoInvestClient.restAPI.sourceAssetList({ + const response = await (autoInvestClient as any).restAPI.querySourceAssetList({ ...(params.usageType && { usageType: params.usageType }), ...(params.targetAsset && { targetAsset: params.targetAsset }), ...(params.indexId && { indexId: params.indexId }), diff --git a/src/modules/auto-invest/getTargetAssetList.ts b/src/modules/auto-invest/getTargetAssetList.ts index 99e22db0..d80eafa6 100644 --- a/src/modules/auto-invest/getTargetAssetList.ts +++ b/src/modules/auto-invest/getTargetAssetList.ts @@ -35,7 +35,7 @@ export function registerAutoInvestGetTargetAssetList(server: McpServer) { }, async (params) => { try { - const response = await autoInvestClient.restAPI.targetAssetList({ + const response = await (autoInvestClient as any).restAPI.getTargetAssetList({ ...(params.targetAsset && { targetAsset: params.targetAsset }), ...(params.size && { size: params.size }), ...(params.current && { current: params.current }), diff --git a/src/modules/auto-invest/getTargetAssetRoiData.ts b/src/modules/auto-invest/getTargetAssetRoiData.ts index e371e0c9..8e1fef77 100644 --- a/src/modules/auto-invest/getTargetAssetRoiData.ts +++ b/src/modules/auto-invest/getTargetAssetRoiData.ts @@ -27,7 +27,7 @@ export function registerAutoInvestGetTargetAssetRoiData(server: McpServer) { }, async (params) => { try { - const response = await autoInvestClient.restAPI.targetAssetRoiList({ + const response = await (autoInvestClient as any).restAPI.getTargetAssetRoiData({ targetAsset: params.targetAsset, hisRoiType: params.hisRoiType, ...(params.recvWindow && { recvWindow: params.recvWindow }), diff --git a/src/modules/auto-invest/oneTimeTransaction.ts b/src/modules/auto-invest/oneTimeTransaction.ts index 2610bb66..80b9f9ab 100644 --- a/src/modules/auto-invest/oneTimeTransaction.ts +++ b/src/modules/auto-invest/oneTimeTransaction.ts @@ -54,7 +54,7 @@ export function registerAutoInvestOneTimeTransaction(server: McpServer) { ...(params.recvWindow && { recvWindow: params.recvWindow }), }; - const response = await autoInvestClient.restAPI.oneOff(requestParams); + const response = await (autoInvestClient as any).restAPI.oneTimeTransaction(requestParams); const data = await response.data(); return { diff --git a/src/modules/auto-invest/rebalanceHistory.ts b/src/modules/auto-invest/rebalanceHistory.ts index 15321c9d..b73f1861 100644 --- a/src/modules/auto-invest/rebalanceHistory.ts +++ b/src/modules/auto-invest/rebalanceHistory.ts @@ -33,7 +33,7 @@ export function registerAutoInvestRebalanceHistory(server: McpServer) { }, async (params) => { try { - const response = await autoInvestClient.restAPI.rebalanceHistory({ + const response = await (autoInvestClient as any).restAPI.indexLinkedPlanRebalanceDetails({ ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.size && { size: params.size }), diff --git a/src/modules/auto-invest/redemption.ts b/src/modules/auto-invest/redemption.ts index 5cf886be..66271120 100644 --- a/src/modules/auto-invest/redemption.ts +++ b/src/modules/auto-invest/redemption.ts @@ -24,7 +24,7 @@ export function registerAutoInvestRedemption(server: McpServer) { }, async (params) => { try { - const response = await autoInvestClient.restAPI.redeem({ + const response = await (autoInvestClient as any).restAPI.indexLinkedPlanRedemption({ indexId: params.indexId, redemptionPercentage: params.redemptionPercentage, ...(params.recvWindow && { recvWindow: params.recvWindow }), diff --git a/src/modules/c2c/C2C/getAds.ts b/src/modules/c2c/C2C/getAds.ts index 2b0cf5b1..d66dcc81 100644 --- a/src/modules/c2c/C2C/getAds.ts +++ b/src/modules/c2c/C2C/getAds.ts @@ -28,7 +28,7 @@ export function registerBinanceC2CGetAds(server: McpServer) { }, async (params) => { try { - const response = await c2cClient.restAPI.getAds({ + const response = await (c2cClient as any).restAPI.getAds({ ...(params.asset && { asset: params.asset }), ...(params.fiat && { fiat: params.fiat }), ...(params.tradeType && { tradeType: params.tradeType }), diff --git a/src/modules/copy-trading/FutureCopyTrading-api/followTrader.ts b/src/modules/copy-trading/FutureCopyTrading-api/followTrader.ts index 53d10e44..68573a44 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/followTrader.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/followTrader.ts @@ -40,7 +40,7 @@ export function registerBinanceCopyTradingFollowTrader(server: McpServer) { }, async (params) => { try { - const response = await copyTradingClient.restAPI.followTrader({ + const response = await (copyTradingClient as any).restAPI.followTrader({ leadPortfolioId: params.leadPortfolioId, copyRatio: params.copyRatio, ...(params.fixedAmount && { fixedAmount: params.fixedAmount }), diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getCopyOrders.ts b/src/modules/copy-trading/FutureCopyTrading-api/getCopyOrders.ts index 20442f99..33d1dd38 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getCopyOrders.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getCopyOrders.ts @@ -27,7 +27,7 @@ export function registerBinanceCopyTradingGetCopyOrders(server: McpServer) { }, async (params) => { try { - const response = await copyTradingClient.restAPI.getCopyOrders({ + const response = await (copyTradingClient as any).restAPI.getCopyOrders({ ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.pageNumber && { pageNumber: params.pageNumber }), diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getCopyPositions.ts b/src/modules/copy-trading/FutureCopyTrading-api/getCopyPositions.ts index 7bd22969..04df359d 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getCopyPositions.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getCopyPositions.ts @@ -23,7 +23,7 @@ export function registerBinanceCopyTradingGetCopyPositions(server: McpServer) { }, async (params) => { try { - const response = await copyTradingClient.restAPI.getCopyPositions({ + const response = await (copyTradingClient as any).restAPI.getCopyPositions({ ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getFollowingTraders.ts b/src/modules/copy-trading/FutureCopyTrading-api/getFollowingTraders.ts index 4c7d452c..ebe1619a 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getFollowingTraders.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getFollowingTraders.ts @@ -23,7 +23,7 @@ export function registerBinanceCopyTradingGetFollowingTraders(server: McpServer) }, async (params) => { try { - const response = await copyTradingClient.restAPI.getFollowingTraders({ + const response = await (copyTradingClient as any).restAPI.getFollowingTraders({ ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts b/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts index 1241044c..5c58fabe 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts @@ -21,7 +21,7 @@ export function registerBinanceGetFuturesLeadTraderStatus(server: McpServer) { }, async (params) => { try { - const response = await copyTradingClient.restAPI.getFuturesLeadTraderStatus({ + const response = await (copyTradingClient as any).restAPI.getFuturesLeadTraderStatus({ ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts b/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts index b86d8cc0..9c9be5f6 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts @@ -21,7 +21,9 @@ export function registerBinanceGetFuturesLeadTradingSymbolWhitelist(server: McpS }, async (params) => { try { - const response = await copyTradingClient.restAPI.getFuturesLeadTradingSymbolWhitelist({ + const response = await ( + copyTradingClient as any + ).restAPI.getFuturesLeadTradingSymbolWhitelist({ ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getLeadTraders.ts b/src/modules/copy-trading/FutureCopyTrading-api/getLeadTraders.ts index 70917a21..4b313d06 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getLeadTraders.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getLeadTraders.ts @@ -27,7 +27,7 @@ export function registerBinanceGetLeadTraders(server: McpServer) { }, async (params) => { try { - const response = await copyTradingClient.restAPI.getLeadTraders({ + const response = await (copyTradingClient as any).restAPI.getLeadTraders({ ...(params.isShared !== undefined && { isShared: params.isShared }), ...(params.tradeType && { tradeType: params.tradeType }), ...(params.pageNumber && { pageNumber: params.pageNumber }), diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getTraderPerformance.ts b/src/modules/copy-trading/FutureCopyTrading-api/getTraderPerformance.ts index 044e0b5e..183f33ea 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getTraderPerformance.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getTraderPerformance.ts @@ -25,7 +25,7 @@ export function registerBinanceGetTraderPerformance(server: McpServer) { }, async (params) => { try { - const response = await copyTradingClient.restAPI.getTraderPerformance({ + const response = await (copyTradingClient as any).restAPI.getTraderPerformance({ leadPortfolioId: params.leadPortfolioId, ...(params.tradeType && { tradeType: params.tradeType }), ...(params.recvWindow && { recvWindow: params.recvWindow }), diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getTraderPositions.ts b/src/modules/copy-trading/FutureCopyTrading-api/getTraderPositions.ts index 3b042d45..f4f20e12 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getTraderPositions.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getTraderPositions.ts @@ -25,7 +25,7 @@ export function registerBinanceGetTraderPositions(server: McpServer) { }, async (params) => { try { - const response = await copyTradingClient.restAPI.getTraderPositions({ + const response = await (copyTradingClient as any).restAPI.getTraderPositions({ leadPortfolioId: params.leadPortfolioId, ...(params.tradeType && { tradeType: params.tradeType }), ...(params.recvWindow && { recvWindow: params.recvWindow }), diff --git a/src/modules/copy-trading/FutureCopyTrading-api/getTraderSymbolStats.ts b/src/modules/copy-trading/FutureCopyTrading-api/getTraderSymbolStats.ts index 841efa9d..e3a5bc20 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/getTraderSymbolStats.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/getTraderSymbolStats.ts @@ -25,7 +25,7 @@ export function registerBinanceGetTraderSymbolStats(server: McpServer) { }, async (params) => { try { - const response = await copyTradingClient.restAPI.getTraderSymbolStats({ + const response = await (copyTradingClient as any).restAPI.getTraderSymbolStats({ leadPortfolioId: params.leadPortfolioId, ...(params.tradeType && { tradeType: params.tradeType }), ...(params.recvWindow && { recvWindow: params.recvWindow }), diff --git a/src/modules/copy-trading/FutureCopyTrading-api/unfollowTrader.ts b/src/modules/copy-trading/FutureCopyTrading-api/unfollowTrader.ts index f52408b1..16fd2edd 100644 --- a/src/modules/copy-trading/FutureCopyTrading-api/unfollowTrader.ts +++ b/src/modules/copy-trading/FutureCopyTrading-api/unfollowTrader.ts @@ -24,7 +24,7 @@ export function registerBinanceCopyTradingUnfollowTrader(server: McpServer) { }, async (params) => { try { - const response = await copyTradingClient.restAPI.unfollowTrader({ + const response = await (copyTradingClient as any).restAPI.unfollowTrader({ leadPortfolioId: params.leadPortfolioId, ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/modules/crypto-loans/flexible/adjustLTV.ts b/src/modules/crypto-loans/flexible/adjustLTV.ts index b9291807..31361aba 100644 --- a/src/modules/crypto-loans/flexible/adjustLTV.ts +++ b/src/modules/crypto-loans/flexible/adjustLTV.ts @@ -29,7 +29,7 @@ export function registerFlexibleLoanAdjustLTV(server: McpServer) { }, async (params) => { try { - const response = await cryptoLoanClient.restAPI.flexibleLoanAdjustLTV({ + const response = await (cryptoLoanClient as any).restAPI.flexibleLoanAdjustLtv({ loanCoin: params.loanCoin, collateralCoin: params.collateralCoin, adjustmentAmount: params.adjustmentAmount, diff --git a/src/modules/crypto-loans/flexible/borrow.ts b/src/modules/crypto-loans/flexible/borrow.ts index 5edff76f..efc0da96 100644 --- a/src/modules/crypto-loans/flexible/borrow.ts +++ b/src/modules/crypto-loans/flexible/borrow.ts @@ -33,7 +33,7 @@ export function registerFlexibleLoanBorrow(server: McpServer) { }, async (params) => { try { - const response = await cryptoLoanClient.restAPI.flexibleLoanBorrow({ + const response = await (cryptoLoanClient as any).restAPI.flexibleLoanBorrow({ loanCoin: params.loanCoin, collateralCoin: params.collateralCoin, ...(params.loanAmount && { loanAmount: params.loanAmount }), diff --git a/src/modules/crypto-loans/flexible/getBorrowHistory.ts b/src/modules/crypto-loans/flexible/getBorrowHistory.ts index cdd85eec..c2d78b47 100644 --- a/src/modules/crypto-loans/flexible/getBorrowHistory.ts +++ b/src/modules/crypto-loans/flexible/getBorrowHistory.ts @@ -28,7 +28,7 @@ export function registerFlexibleLoanBorrowHistory(server: McpServer) { }, async (params) => { try { - const response = await cryptoLoanClient.restAPI.getFlexibleLoanBorrowHistory({ + const response = await (cryptoLoanClient as any).restAPI.getFlexibleLoanBorrowHistory({ ...(params.loanCoin && { loanCoin: params.loanCoin }), ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), ...(params.startTime && { startTime: params.startTime }), diff --git a/src/modules/crypto-loans/flexible/getFlexibleCollateralAssets.ts b/src/modules/crypto-loans/flexible/getFlexibleCollateralAssets.ts index 2e4262c4..1dc9b362 100644 --- a/src/modules/crypto-loans/flexible/getFlexibleCollateralAssets.ts +++ b/src/modules/crypto-loans/flexible/getFlexibleCollateralAssets.ts @@ -24,7 +24,9 @@ export function registerFlexibleCollateralAssets(server: McpServer) { }, async (params) => { try { - const response = await cryptoLoanClient.restAPI.getFlexibleCollateralAssets({ + const response = await ( + cryptoLoanClient as any + ).restAPI.getFlexibleLoanCollateralAssetsData({ ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/modules/crypto-loans/flexible/getFlexibleLoanAssets.ts b/src/modules/crypto-loans/flexible/getFlexibleLoanAssets.ts index ecebe941..13ad31c7 100644 --- a/src/modules/crypto-loans/flexible/getFlexibleLoanAssets.ts +++ b/src/modules/crypto-loans/flexible/getFlexibleLoanAssets.ts @@ -24,7 +24,7 @@ export function registerFlexibleLoanAssets(server: McpServer) { }, async (params) => { try { - const response = await cryptoLoanClient.restAPI.getFlexibleLoanAssets({ + const response = await (cryptoLoanClient as any).restAPI.getFlexibleLoanAssetsData({ ...(params.loanCoin && { loanCoin: params.loanCoin }), ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/modules/crypto-loans/flexible/getOngoingOrders.ts b/src/modules/crypto-loans/flexible/getOngoingOrders.ts index a0369b61..11a685d9 100644 --- a/src/modules/crypto-loans/flexible/getOngoingOrders.ts +++ b/src/modules/crypto-loans/flexible/getOngoingOrders.ts @@ -27,7 +27,7 @@ export function registerFlexibleLoanOngoingOrders(server: McpServer) { }, async (params) => { try { - const response = await cryptoLoanClient.restAPI.getFlexibleLoanOngoingOrders({ + const response = await (cryptoLoanClient as any).restAPI.getFlexibleLoanOngoingOrders({ ...(params.loanCoin && { loanCoin: params.loanCoin }), ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), ...(params.current && { current: params.current }), diff --git a/src/modules/crypto-loans/flexible/getRepayHistory.ts b/src/modules/crypto-loans/flexible/getRepayHistory.ts index 62ed6275..6d658ac6 100644 --- a/src/modules/crypto-loans/flexible/getRepayHistory.ts +++ b/src/modules/crypto-loans/flexible/getRepayHistory.ts @@ -28,7 +28,7 @@ export function registerFlexibleLoanRepayHistory(server: McpServer) { }, async (params) => { try { - const response = await cryptoLoanClient.restAPI.getFlexibleLoanRepayHistory({ + const response = await (cryptoLoanClient as any).restAPI.getFlexibleLoanRepaymentHistory({ ...(params.loanCoin && { loanCoin: params.loanCoin }), ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), ...(params.startTime && { startTime: params.startTime }), diff --git a/src/modules/crypto-loans/flexible/repay.ts b/src/modules/crypto-loans/flexible/repay.ts index 8d0cd81c..ba977bd2 100644 --- a/src/modules/crypto-loans/flexible/repay.ts +++ b/src/modules/crypto-loans/flexible/repay.ts @@ -28,7 +28,7 @@ export function registerFlexibleLoanRepay(server: McpServer) { }, async (params) => { try { - const response = await cryptoLoanClient.restAPI.flexibleLoanRepay({ + const response = await (cryptoLoanClient as any).restAPI.flexibleLoanRepay({ loanCoin: params.loanCoin, collateralCoin: params.collateralCoin, repayAmount: params.repayAmount, diff --git a/src/modules/mining/mining-api/hashrateResaleDetail.ts b/src/modules/mining/mining-api/hashrateResaleDetail.ts index 481f2138..b83b271f 100644 --- a/src/modules/mining/mining-api/hashrateResaleDetail.ts +++ b/src/modules/mining/mining-api/hashrateResaleDetail.ts @@ -32,13 +32,18 @@ export function registerBinanceHashRateResaleDetail(server: McpServer) { }, async (params) => { try { - const response = await miningClient.restAPI.hashrateResaleDetail({ + const requestParams = { configId: params.configId, userName: params.userName, - ...(params.pageIndex && { pageIndex: params.pageIndex }), - ...(params.pageSize && { pageSize: params.pageSize }), - ...(params.recvWindow && { recvWindow: params.recvWindow }), - }); + ...(params.pageIndex != null && { pageIndex: params.pageIndex }), + ...(params.pageSize != null && { pageSize: params.pageSize }), + ...(params.recvWindow != null && { recvWindow: params.recvWindow }), + }; + const response = await ( + (miningClient as any).restAPI as { + hashrateResaleDetail: (p: any) => Promise<{ data: () => Promise }>; + } + ).hashrateResaleDetail(requestParams); const data = await response.data(); diff --git a/src/modules/options/account-api/getAccount.ts b/src/modules/options/account-api/getAccount.ts index b309833f..504c6095 100644 --- a/src/modules/options/account-api/getAccount.ts +++ b/src/modules/options/account-api/getAccount.ts @@ -22,12 +22,10 @@ export function registerOptionsGetAccount(server: McpServer) { }, async (params) => { try { - const response = await optionsClient.restAPI.account({ + const data = await optionsClient.account({ ...(params.recvWindow && { recvWindow: params.recvWindow }), }); - const data = await response.data(); - let result = `✅ Options Account Information\n\n`; if (data) { diff --git a/src/modules/options/account-api/getBillHistory.ts b/src/modules/options/account-api/getBillHistory.ts index 43855e27..7c6b9722 100644 --- a/src/modules/options/account-api/getBillHistory.ts +++ b/src/modules/options/account-api/getBillHistory.ts @@ -34,7 +34,7 @@ export function registerOptionsGetBillHistory(server: McpServer) { }, async (params) => { try { - const response = await optionsClient.restAPI.bill({ + const data = await optionsClient.bill({ currency: params.currency, ...(params.recordId && { recordId: params.recordId }), ...(params.startTime && { startTime: params.startTime }), @@ -43,8 +43,6 @@ export function registerOptionsGetBillHistory(server: McpServer) { ...(params.recvWindow && { recvWindow: params.recvWindow }), }); - const data = await response.data(); - let result = `✅ Options Bill History\n\n`; if (Array.isArray(data) && data.length > 0) { diff --git a/src/modules/options/account-api/getIncomeAsyn.ts b/src/modules/options/account-api/getIncomeAsyn.ts index eb7a213e..3c9eef90 100644 --- a/src/modules/options/account-api/getIncomeAsyn.ts +++ b/src/modules/options/account-api/getIncomeAsyn.ts @@ -25,14 +25,12 @@ export function registerOptionsGetIncomeAsyn(server: McpServer) { }, async (params) => { try { - const response = await optionsClient.restAPI.incomeAsyn({ + const data = await optionsClient.incomeAsyn({ startTime: params.startTime, endTime: params.endTime, ...(params.recvWindow && { recvWindow: params.recvWindow }), }); - const data = await response.data(); - return { content: [ { diff --git a/src/modules/options/account-api/getIncomeAsynId.ts b/src/modules/options/account-api/getIncomeAsynId.ts index 63894c37..5d0ff07e 100644 --- a/src/modules/options/account-api/getIncomeAsynId.ts +++ b/src/modules/options/account-api/getIncomeAsynId.ts @@ -24,13 +24,11 @@ export function registerOptionsGetIncomeAsynId(server: McpServer) { }, async (params) => { try { - const response = await optionsClient.restAPI.incomeAsynId({ + const data = await optionsClient.incomeAsynId({ downloadId: params.downloadId, ...(params.recvWindow && { recvWindow: params.recvWindow }), }); - const data = await response.data(); - let result = `✅ Options Income Download Status\n\n`; result += `Download ID: ${params.downloadId}\n`; result += `Status: ${data.status}\n`; diff --git a/src/modules/options/account-api/getPosition.ts b/src/modules/options/account-api/getPosition.ts index 065c4311..4c61b4b1 100644 --- a/src/modules/options/account-api/getPosition.ts +++ b/src/modules/options/account-api/getPosition.ts @@ -27,14 +27,12 @@ export function registerOptionsGetPosition(server: McpServer) { }, async (params) => { try { - const response = await optionsClient.restAPI.position({ + const data = await optionsClient.position({ ...(params.symbol && { symbol: params.symbol }), ...(params.underlying && { underlying: params.underlying }), ...(params.recvWindow && { recvWindow: params.recvWindow }), }); - const data = await response.data(); - let result = `✅ Options Positions\n\n`; if (Array.isArray(data) && data.length > 0) { diff --git a/src/modules/options/market-api/depth.ts b/src/modules/options/market-api/depth.ts index 426b4001..31da2b9a 100644 --- a/src/modules/options/market-api/depth.ts +++ b/src/modules/options/market-api/depth.ts @@ -30,13 +30,11 @@ export function registerOptionsMarketDepth(server: McpServer) { }, async (params) => { try { - const response = await optionsClient.restAPI.depth({ + const data = await optionsClient.depth({ symbol: params.symbol, ...(params.limit && { limit: params.limit }), }); - const data = await response.data(); - let result = `✅ Options Order Book - ${params.symbol}\n\n`; // Format asks (sell orders) diff --git a/src/modules/options/market-api/exchangeInfo.ts b/src/modules/options/market-api/exchangeInfo.ts index 5a5e02c0..d64b66d5 100644 --- a/src/modules/options/market-api/exchangeInfo.ts +++ b/src/modules/options/market-api/exchangeInfo.ts @@ -18,8 +18,7 @@ export function registerOptionsMarketExchangeInfo(server: McpServer) { }, async () => { try { - const response = await optionsClient.restAPI.exchangeInfo(); - const data = await response.data(); + const data = await optionsClient.exchangeInfo(); // Summarize the response const optionSymbols = data.optionSymbols || []; diff --git a/src/modules/options/market-api/exerciseHistory.ts b/src/modules/options/market-api/exerciseHistory.ts index 77de9d59..abf4475c 100644 --- a/src/modules/options/market-api/exerciseHistory.ts +++ b/src/modules/options/market-api/exerciseHistory.ts @@ -32,15 +32,13 @@ export function registerOptionsMarketExerciseHistory(server: McpServer) { }, async (params) => { try { - const response = await optionsClient.restAPI.exerciseHistory({ + const data = await optionsClient.exerciseRecord({ ...(params.underlying && { underlying: params.underlying }), ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), }); - const data = await response.data(); - let result = `✅ Options Exercise History\n\n`; if (Array.isArray(data) && data.length > 0) { diff --git a/src/modules/options/market-api/historicalTrades.ts b/src/modules/options/market-api/historicalTrades.ts index c4c2574d..aa9ffc5c 100644 --- a/src/modules/options/market-api/historicalTrades.ts +++ b/src/modules/options/market-api/historicalTrades.ts @@ -34,14 +34,12 @@ export function registerOptionsMarketHistoricalTrades(server: McpServer) { }, async (params) => { try { - const response = await optionsClient.restAPI.historicalTrades({ + const data = await optionsClient.historicalTrades({ symbol: params.symbol, ...(params.limit && { limit: params.limit }), ...(params.fromId && { fromId: params.fromId }), }); - const data = await response.data(); - let result = `✅ Historical Trades - ${params.symbol}\n\n`; if (Array.isArray(data) && data.length > 0) { diff --git a/src/modules/options/market-api/indexPrice.ts b/src/modules/options/market-api/indexPrice.ts index c6da2667..39d1e38c 100644 --- a/src/modules/options/market-api/indexPrice.ts +++ b/src/modules/options/market-api/indexPrice.ts @@ -23,12 +23,10 @@ export function registerOptionsMarketIndex(server: McpServer) { }, async (params) => { try { - const response = await optionsClient.restAPI.index({ + const data = await optionsClient.index({ underlying: params.underlying, }); - const data = await response.data(); - let result = `✅ Options Index Price\n\n`; if (Array.isArray(data)) { diff --git a/src/modules/options/market-api/klines.ts b/src/modules/options/market-api/klines.ts index 69172df3..f3a590aa 100644 --- a/src/modules/options/market-api/klines.ts +++ b/src/modules/options/market-api/klines.ts @@ -35,7 +35,7 @@ export function registerOptionsMarketKlines(server: McpServer) { }, async (params) => { try { - const response = await optionsClient.restAPI.klines({ + const data = await optionsClient.klines({ symbol: params.symbol, interval: params.interval, ...(params.startTime && { startTime: params.startTime }), @@ -43,8 +43,6 @@ export function registerOptionsMarketKlines(server: McpServer) { ...(params.limit && { limit: params.limit }), }); - const data = await response.data(); - let result = `✅ Klines - ${params.symbol} (${params.interval})\n\n`; if (Array.isArray(data) && data.length > 0) { diff --git a/src/modules/options/market-api/mark.ts b/src/modules/options/market-api/mark.ts index 40160cb9..2822bf85 100644 --- a/src/modules/options/market-api/mark.ts +++ b/src/modules/options/market-api/mark.ts @@ -28,12 +28,10 @@ export function registerOptionsMarketMark(server: McpServer) { }, async (params) => { try { - const response = await optionsClient.restAPI.mark({ + const data = await optionsClient.mark({ ...(params.symbol && { symbol: params.symbol }), }); - const data = await response.data(); - let result = `✅ Options Mark Prices\n\n`; if (Array.isArray(data)) { diff --git a/src/modules/options/market-api/ping.ts b/src/modules/options/market-api/ping.ts index 54e28546..dcd5152b 100644 --- a/src/modules/options/market-api/ping.ts +++ b/src/modules/options/market-api/ping.ts @@ -15,8 +15,7 @@ export function registerOptionsMarketPing(server: McpServer) { { description: "Test connectivity to the Options API. Returns empty object if successful." }, async () => { try { - const response = await optionsClient.restAPI.ping(); - const data = await response.data(); + const data = await optionsClient.ping(); return { content: [ diff --git a/src/modules/options/market-api/ticker.ts b/src/modules/options/market-api/ticker.ts index a753f62c..00c05546 100644 --- a/src/modules/options/market-api/ticker.ts +++ b/src/modules/options/market-api/ticker.ts @@ -28,12 +28,10 @@ export function registerOptionsMarketTicker(server: McpServer) { }, async (params) => { try { - const response = await optionsClient.restAPI.ticker({ + const data = await optionsClient.ticker({ ...(params.symbol && { symbol: params.symbol }), }); - const data = await response.data(); - let result = `✅ Options 24hr Ticker Statistics\n\n`; const formatTicker = (ticker: any) => { diff --git a/src/modules/options/market-api/time.ts b/src/modules/options/market-api/time.ts index 440ea170..b0dfaef6 100644 --- a/src/modules/options/market-api/time.ts +++ b/src/modules/options/market-api/time.ts @@ -15,8 +15,7 @@ export function registerOptionsMarketTime(server: McpServer) { { description: "Get the current server time from the Options API." }, async () => { try { - const response = await optionsClient.restAPI.time(); - const data = await response.data(); + const data = await optionsClient.time(); const serverTime = new Date(data.serverTime).toISOString(); diff --git a/src/modules/options/market-api/trades.ts b/src/modules/options/market-api/trades.ts index 0cb9f2af..5a0fd84b 100644 --- a/src/modules/options/market-api/trades.ts +++ b/src/modules/options/market-api/trades.ts @@ -30,13 +30,11 @@ export function registerOptionsMarketTrades(server: McpServer) { }, async (params) => { try { - const response = await optionsClient.restAPI.trades({ + const data = await optionsClient.trades({ symbol: params.symbol, ...(params.limit && { limit: params.limit }), }); - const data = await response.data(); - let result = `✅ Recent Trades - ${params.symbol}\n\n`; if (Array.isArray(data) && data.length > 0) { diff --git a/src/modules/options/trade-api/batchOrders.ts b/src/modules/options/trade-api/batchOrders.ts index 255274f4..d03bd70a 100644 --- a/src/modules/options/trade-api/batchOrders.ts +++ b/src/modules/options/trade-api/batchOrders.ts @@ -40,13 +40,11 @@ export function registerOptionsBatchOrders(server: McpServer) { }, async (params) => { try { - const response = await optionsClient.restAPI.batchOrders({ + const data = await optionsClient.batchOrders({ orders: JSON.stringify(params.orders), ...(params.recvWindow && { recvWindow: params.recvWindow }), }); - const data = await response.data(); - let result = `✅ Batch Options Orders Placed\n\n`; if (Array.isArray(data)) { diff --git a/src/modules/options/trade-api/cancelAllOrders.ts b/src/modules/options/trade-api/cancelAllOrders.ts index 70ad7dbb..9e9c1afc 100644 --- a/src/modules/options/trade-api/cancelAllOrders.ts +++ b/src/modules/options/trade-api/cancelAllOrders.ts @@ -24,13 +24,11 @@ export function registerOptionsCancelAllOrders(server: McpServer) { }, async (params) => { try { - const response = await optionsClient.restAPI.cancelAllOpenOrders({ + const data = await optionsClient.cancelAllOrders({ symbol: params.symbol, ...(params.recvWindow && { recvWindow: params.recvWindow }), }); - const data = await response.data(); - return { content: [ { diff --git a/src/modules/options/trade-api/cancelBatchOrders.ts b/src/modules/options/trade-api/cancelBatchOrders.ts index 1bab4df2..51efc84e 100644 --- a/src/modules/options/trade-api/cancelBatchOrders.ts +++ b/src/modules/options/trade-api/cancelBatchOrders.ts @@ -44,15 +44,13 @@ export function registerOptionsCancelBatchOrders(server: McpServer) { }; } - const response = await optionsClient.restAPI.cancelBatchOrders({ + const data = await optionsClient.cancelBatchOrders({ symbol: params.symbol, ...(params.orderIds && { orderIds: JSON.stringify(params.orderIds) }), ...(params.clientOrderIds && { clientOrderIds: JSON.stringify(params.clientOrderIds) }), ...(params.recvWindow && { recvWindow: params.recvWindow }), }); - const data = await response.data(); - let result = `✅ Batch Options Orders Cancelled\n\n`; if (Array.isArray(data)) { diff --git a/src/modules/options/trade-api/cancelBySymbol.ts b/src/modules/options/trade-api/cancelBySymbol.ts index 3cbedfe2..9741c740 100644 --- a/src/modules/options/trade-api/cancelBySymbol.ts +++ b/src/modules/options/trade-api/cancelBySymbol.ts @@ -24,13 +24,11 @@ export function registerOptionsCancelBySymbol(server: McpServer) { }, async (params) => { try { - const response = await optionsClient.restAPI.cancelAllOpenOrdersByUnderlying({ + const data = await optionsClient.cancelAllOpenOrdersByUnderlying({ underlying: params.underlying, ...(params.recvWindow && { recvWindow: params.recvWindow }), }); - const data = await response.data(); - return { content: [ { diff --git a/src/modules/options/trade-api/cancelOrder.ts b/src/modules/options/trade-api/cancelOrder.ts index b7dee3a8..c154759c 100644 --- a/src/modules/options/trade-api/cancelOrder.ts +++ b/src/modules/options/trade-api/cancelOrder.ts @@ -37,15 +37,13 @@ export function registerOptionsCancelOrder(server: McpServer) { }; } - const response = await optionsClient.restAPI.cancelOrder({ + const data = await optionsClient.cancelOrder({ symbol: params.symbol, ...(params.orderId && { orderId: params.orderId }), ...(params.clientOrderId && { clientOrderId: params.clientOrderId }), ...(params.recvWindow && { recvWindow: params.recvWindow }), }); - const data = await response.data(); - return { content: [ { diff --git a/src/modules/options/trade-api/getHistoryOrders.ts b/src/modules/options/trade-api/getHistoryOrders.ts index c08ae742..ae057d20 100644 --- a/src/modules/options/trade-api/getHistoryOrders.ts +++ b/src/modules/options/trade-api/getHistoryOrders.ts @@ -33,7 +33,7 @@ export function registerOptionsGetHistoryOrders(server: McpServer) { }, async (params) => { try { - const response = await optionsClient.restAPI.historyOrders({ + const data = await optionsClient.historyOrders({ symbol: params.symbol, ...(params.orderId && { orderId: params.orderId }), ...(params.startTime && { startTime: params.startTime }), @@ -42,8 +42,6 @@ export function registerOptionsGetHistoryOrders(server: McpServer) { ...(params.recvWindow && { recvWindow: params.recvWindow }), }); - const data = await response.data(); - let result = `✅ Options Order History - ${params.symbol}\n\n`; if (Array.isArray(data) && data.length > 0) { diff --git a/src/modules/options/trade-api/getOpenOrders.ts b/src/modules/options/trade-api/getOpenOrders.ts index 99bdb69f..3ace9da4 100644 --- a/src/modules/options/trade-api/getOpenOrders.ts +++ b/src/modules/options/trade-api/getOpenOrders.ts @@ -27,14 +27,12 @@ export function registerOptionsGetOpenOrders(server: McpServer) { }, async (params) => { try { - const response = await optionsClient.restAPI.openOrders({ + const data = await optionsClient.openOrders({ ...(params.symbol && { symbol: params.symbol }), ...(params.underlying && { underlying: params.underlying }), ...(params.recvWindow && { recvWindow: params.recvWindow }), }); - const data = await response.data(); - let result = `✅ Open Options Orders\n\n`; if (Array.isArray(data) && data.length > 0) { diff --git a/src/modules/options/trade-api/getUserTrades.ts b/src/modules/options/trade-api/getUserTrades.ts index 78d74a4b..dea4518c 100644 --- a/src/modules/options/trade-api/getUserTrades.ts +++ b/src/modules/options/trade-api/getUserTrades.ts @@ -38,7 +38,7 @@ export function registerOptionsGetUserTrades(server: McpServer) { }, async (params) => { try { - const response = await optionsClient.restAPI.userTrades({ + const data = await optionsClient.userTrades({ ...(params.symbol && { symbol: params.symbol }), ...(params.underlying && { underlying: params.underlying }), ...(params.fromId && { fromId: params.fromId }), @@ -48,8 +48,6 @@ export function registerOptionsGetUserTrades(server: McpServer) { ...(params.recvWindow && { recvWindow: params.recvWindow }), }); - const data = await response.data(); - let result = `✅ Options Trade History\n\n`; if (Array.isArray(data) && data.length > 0) { diff --git a/src/modules/options/trade-api/newOrder.ts b/src/modules/options/trade-api/newOrder.ts index df7362ca..bbcf8797 100644 --- a/src/modules/options/trade-api/newOrder.ts +++ b/src/modules/options/trade-api/newOrder.ts @@ -36,7 +36,7 @@ export function registerOptionsNewOrder(server: McpServer) { }, async (params) => { try { - const response = await optionsClient.restAPI.newOrder({ + const data = await optionsClient.newOrder({ symbol: params.symbol, side: params.side, type: params.type, @@ -50,8 +50,6 @@ export function registerOptionsNewOrder(server: McpServer) { ...(params.recvWindow && { recvWindow: params.recvWindow }), }); - const data = await response.data(); - return { content: [ { diff --git a/src/modules/options/userdata-api/createListenKey.ts b/src/modules/options/userdata-api/createListenKey.ts index 74116287..e9c9ad71 100644 --- a/src/modules/options/userdata-api/createListenKey.ts +++ b/src/modules/options/userdata-api/createListenKey.ts @@ -18,8 +18,7 @@ export function registerOptionsCreateListenKey(server: McpServer) { }, async () => { try { - const response = await optionsClient.restAPI.createListenKey(); - const data = await response.data(); + const data = await optionsClient.createListenKey(); return { content: [ diff --git a/src/modules/options/userdata-api/deleteListenKey.ts b/src/modules/options/userdata-api/deleteListenKey.ts index 14da4084..1abc8027 100644 --- a/src/modules/options/userdata-api/deleteListenKey.ts +++ b/src/modules/options/userdata-api/deleteListenKey.ts @@ -26,10 +26,9 @@ export function registerOptionsDeleteListenKey(server: McpServer) { }, async (params) => { try { - const response = await optionsClient.restAPI.deleteListenKey({ - ...(params.listenKey && { listenKey: params.listenKey }), - }); - const data = await response.data(); + const data = await optionsClient.closeListenKey( + params.listenKey ? { listenKey: params.listenKey } : {}, + ); return { content: [ diff --git a/src/modules/options/userdata-api/renewListenKey.ts b/src/modules/options/userdata-api/renewListenKey.ts index 87cc6389..da797bdb 100644 --- a/src/modules/options/userdata-api/renewListenKey.ts +++ b/src/modules/options/userdata-api/renewListenKey.ts @@ -26,10 +26,9 @@ export function registerOptionsRenewListenKey(server: McpServer) { }, async (params) => { try { - const response = await optionsClient.restAPI.renewListenKey({ - ...(params.listenKey && { listenKey: params.listenKey }), - }); - const data = await response.data(); + const data = await optionsClient.keepAliveListenKey( + params.listenKey ? { listenKey: params.listenKey } : {}, + ); return { content: [ diff --git a/src/modules/pay/pay-api/createOrder.ts b/src/modules/pay/pay-api/createOrder.ts index 685119f4..8ce884ac 100644 --- a/src/modules/pay/pay-api/createOrder.ts +++ b/src/modules/pay/pay-api/createOrder.ts @@ -30,7 +30,7 @@ export function registerBinancePayCreateOrder(server: McpServer) { }, async (params) => { try { - const response = await payClient.restAPI.createOrder({ + const response = await (payClient as any).restAPI.createOrder({ orderId: params.orderId, currency: params.currency, totalAmount: params.totalAmount, diff --git a/src/modules/pay/pay-api/getHistory.ts b/src/modules/pay/pay-api/getHistory.ts index 8199df23..90aef64e 100644 --- a/src/modules/pay/pay-api/getHistory.ts +++ b/src/modules/pay/pay-api/getHistory.ts @@ -32,7 +32,7 @@ export function registerBinancePayGetHistory(server: McpServer) { }, async (params) => { try { - const response = await payClient.restAPI.getPayTradeHistory({ + const response = await (payClient as any).restAPI.getPayTradeHistory({ ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), diff --git a/src/modules/pay/pay-api/getPayTradeHistory.ts b/src/modules/pay/pay-api/getPayTradeHistory.ts index ac62322d..4c059bf1 100644 --- a/src/modules/pay/pay-api/getPayTradeHistory.ts +++ b/src/modules/pay/pay-api/getPayTradeHistory.ts @@ -29,7 +29,7 @@ export function registerBinanceGetPayTradeHistory(server: McpServer) { }, async (params) => { try { - const response = await payClient.restAPI.getPayTradeHistory({ + const response = await (payClient as any).restAPI.getPayTradeHistory({ ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), diff --git a/src/modules/pay/pay-api/queryOrder.ts b/src/modules/pay/pay-api/queryOrder.ts index 932deab7..1df479b4 100644 --- a/src/modules/pay/pay-api/queryOrder.ts +++ b/src/modules/pay/pay-api/queryOrder.ts @@ -25,7 +25,7 @@ export function registerBinancePayQueryOrder(server: McpServer) { }, async (params) => { try { - const response = await payClient.restAPI.queryOrder({ + const response = await (payClient as any).restAPI.queryOrder({ ...(params.merchantId && { merchantId: params.merchantId }), ...(params.prepayId && { prepayId: params.prepayId }), ...(params.merchantTradeNo && { merchantTradeNo: params.merchantTradeNo }), diff --git a/src/modules/simple-earn/account-api/getFlexibleProductPosition.ts b/src/modules/simple-earn/account-api/getFlexibleProductPosition.ts index 6be31cea..86d13d83 100644 --- a/src/modules/simple-earn/account-api/getFlexibleProductPosition.ts +++ b/src/modules/simple-earn/account-api/getFlexibleProductPosition.ts @@ -34,7 +34,7 @@ export function registerBinanceGetFlexibleProductPosition(server: McpServer) { }, async (params) => { try { - const response = await simpleEarnClient.restAPI.getFlexibleProductPosition({ + const response = await (simpleEarnClient as any).restAPI.getFlexibleProductPosition({ ...(params.asset && { asset: params.asset }), ...(params.productId && { productId: params.productId }), ...(params.current && { current: params.current }), diff --git a/src/modules/simple-earn/account-api/simpleEarnFlexibleProductList.ts b/src/modules/simple-earn/account-api/simpleEarnFlexibleProductList.ts index 0219d0d1..eef70a29 100644 --- a/src/modules/simple-earn/account-api/simpleEarnFlexibleProductList.ts +++ b/src/modules/simple-earn/account-api/simpleEarnFlexibleProductList.ts @@ -33,7 +33,7 @@ export function registerBinanceSimpleEarnFlexibleProductList(server: McpServer) }, async (params) => { try { - const response = await simpleEarnClient.restAPI.getSimpleEarnFlexibleProductList({ + const response = await (simpleEarnClient as any).restAPI.getSimpleEarnFlexibleProductList({ ...(params.asset && { asset: params.asset }), ...(params.current && { current: params.current }), ...(params.size && { size: params.size }), diff --git a/src/modules/simple-earn/account/getAccount.ts b/src/modules/simple-earn/account/getAccount.ts index a3e0d930..5b2634de 100644 --- a/src/modules/simple-earn/account/getAccount.ts +++ b/src/modules/simple-earn/account/getAccount.ts @@ -23,7 +23,7 @@ export function registerSimpleEarnAccount(server: McpServer) { }, async (params) => { try { - const response = await simpleEarnClient.restAPI.getSimpleEarnAccount({ + const response = await (simpleEarnClient as any).restAPI.getSimpleEarnAccount({ ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/modules/simple-earn/account/getCollateralRecord.ts b/src/modules/simple-earn/account/getCollateralRecord.ts index f1dad3b3..8530432a 100644 --- a/src/modules/simple-earn/account/getCollateralRecord.ts +++ b/src/modules/simple-earn/account/getCollateralRecord.ts @@ -28,7 +28,7 @@ export function registerSimpleEarnCollateralRecord(server: McpServer) { }, async (params) => { try { - const response = await simpleEarnClient.restAPI.getFlexibleCollateralRecord({ + const response = await (simpleEarnClient as any).restAPI.getCollateralRecord({ ...(params.productId && { productId: params.productId }), ...(params.asset && { asset: params.asset }), ...(params.startTime && { startTime: params.startTime }), diff --git a/src/modules/simple-earn/account/getRewardRecord.ts b/src/modules/simple-earn/account/getRewardRecord.ts index 4687924d..f96ae5b2 100644 --- a/src/modules/simple-earn/account/getRewardRecord.ts +++ b/src/modules/simple-earn/account/getRewardRecord.ts @@ -30,7 +30,7 @@ export function registerSimpleEarnRewardRecord(server: McpServer) { }, async (params) => { try { - const response = await simpleEarnClient.restAPI.getFlexibleRewardsRecord({ + const response = await (simpleEarnClient as any).restAPI.getFlexibleRewardsHistory({ ...(params.productId && { productId: params.productId }), ...(params.asset && { asset: params.asset }), ...(params.type && { type: params.type }), diff --git a/src/modules/simple-earn/earn-api/redeemFlexibleProduct.ts b/src/modules/simple-earn/earn-api/redeemFlexibleProduct.ts index d8029896..ba5f2754 100644 --- a/src/modules/simple-earn/earn-api/redeemFlexibleProduct.ts +++ b/src/modules/simple-earn/earn-api/redeemFlexibleProduct.ts @@ -43,7 +43,7 @@ export function registerBinanceRedeemFlexibleProduct(server: McpServer) { }; } - const response = await simpleEarnClient.restAPI.redeemFlexibleProduct({ + const response = await (simpleEarnClient as any).restAPI.redeemFlexibleProduct({ productId, ...(redeemAll !== undefined && { redeemAll }), ...(amount !== undefined && { amount }), diff --git a/src/modules/simple-earn/earn-api/subscribeFlexibleProduct.ts b/src/modules/simple-earn/earn-api/subscribeFlexibleProduct.ts index 08742103..eb961569 100644 --- a/src/modules/simple-earn/earn-api/subscribeFlexibleProduct.ts +++ b/src/modules/simple-earn/earn-api/subscribeFlexibleProduct.ts @@ -24,7 +24,7 @@ export function registerBinanceSubscribeFlexibleProduct(server: McpServer) { }, async (params) => { try { - const response = await simpleEarnClient.restAPI.subscribeFlexibleProduct({ + const response = await (simpleEarnClient as any).restAPI.subscribeFlexibleProduct({ productId: params.productId, amount: params.amount, ...(params.autoSubscribe !== undefined && { autoSubscribe: params.autoSubscribe }), diff --git a/src/modules/simple-earn/flexible/getFlexiblePosition.ts b/src/modules/simple-earn/flexible/getFlexiblePosition.ts index a9705655..c658d35b 100644 --- a/src/modules/simple-earn/flexible/getFlexiblePosition.ts +++ b/src/modules/simple-earn/flexible/getFlexiblePosition.ts @@ -27,7 +27,7 @@ export function registerSimpleEarnFlexiblePosition(server: McpServer) { }, async (params) => { try { - const response = await simpleEarnClient.restAPI.getFlexibleProductPosition({ + const response = await (simpleEarnClient as any).restAPI.getFlexibleProductPosition({ ...(params.asset && { asset: params.asset }), ...(params.productId && { productId: params.productId }), ...(params.current && { current: params.current }), diff --git a/src/modules/simple-earn/flexible/getFlexibleProductList.ts b/src/modules/simple-earn/flexible/getFlexibleProductList.ts index f9287999..1f6199c5 100644 --- a/src/modules/simple-earn/flexible/getFlexibleProductList.ts +++ b/src/modules/simple-earn/flexible/getFlexibleProductList.ts @@ -32,7 +32,7 @@ export function registerSimpleEarnFlexibleProductList(server: McpServer) { }, async (params) => { try { - const response = await simpleEarnClient.restAPI.getSimpleEarnFlexibleProductList({ + const response = await (simpleEarnClient as any).restAPI.getSimpleEarnFlexibleProductList({ ...(params.asset && { asset: params.asset }), ...(params.current && { current: params.current }), ...(params.size && { size: params.size }), diff --git a/src/modules/simple-earn/flexible/getFlexibleSubscriptionPreview.ts b/src/modules/simple-earn/flexible/getFlexibleSubscriptionPreview.ts index 9cd9f46c..96746406 100644 --- a/src/modules/simple-earn/flexible/getFlexibleSubscriptionPreview.ts +++ b/src/modules/simple-earn/flexible/getFlexibleSubscriptionPreview.ts @@ -25,7 +25,7 @@ export function registerSimpleEarnFlexibleSubscriptionPreview(server: McpServer) }, async (params) => { try { - const response = await simpleEarnClient.restAPI.getFlexibleSubscriptionPreview({ + const response = await (simpleEarnClient as any).restAPI.getFlexibleSubscriptionPreview({ productId: params.productId, amount: params.amount, ...(params.recvWindow && { recvWindow: params.recvWindow }), diff --git a/src/modules/simple-earn/flexible/getRateHistory.ts b/src/modules/simple-earn/flexible/getRateHistory.ts index db0313bb..9c6f7b14 100644 --- a/src/modules/simple-earn/flexible/getRateHistory.ts +++ b/src/modules/simple-earn/flexible/getRateHistory.ts @@ -28,7 +28,7 @@ export function registerSimpleEarnFlexibleRateHistory(server: McpServer) { }, async (params) => { try { - const response = await simpleEarnClient.restAPI.getFlexibleRateHistory({ + const response = await (simpleEarnClient as any).restAPI.getFlexibleRewardsHistory({ productId: params.productId, ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), diff --git a/src/modules/simple-earn/flexible/getRedemptionRecord.ts b/src/modules/simple-earn/flexible/getRedemptionRecord.ts index fc84d459..ba28b63d 100644 --- a/src/modules/simple-earn/flexible/getRedemptionRecord.ts +++ b/src/modules/simple-earn/flexible/getRedemptionRecord.ts @@ -30,7 +30,7 @@ export function registerSimpleEarnFlexibleRedemptionRecord(server: McpServer) { }, async (params) => { try { - const response = await simpleEarnClient.restAPI.getFlexibleRedemptionRecord({ + const response = await (simpleEarnClient as any).restAPI.getFlexibleRedemptionRecord({ ...(params.productId && { productId: params.productId }), ...(params.redeemId && { redeemId: params.redeemId }), ...(params.asset && { asset: params.asset }), diff --git a/src/modules/simple-earn/flexible/getSubscriptionRecord.ts b/src/modules/simple-earn/flexible/getSubscriptionRecord.ts index b5223cd6..e5266f69 100644 --- a/src/modules/simple-earn/flexible/getSubscriptionRecord.ts +++ b/src/modules/simple-earn/flexible/getSubscriptionRecord.ts @@ -30,7 +30,7 @@ export function registerSimpleEarnFlexibleSubscriptionRecord(server: McpServer) }, async (params) => { try { - const response = await simpleEarnClient.restAPI.getFlexibleSubscriptionRecord({ + const response = await (simpleEarnClient as any).restAPI.getFlexibleSubscriptionRecord({ ...(params.productId && { productId: params.productId }), ...(params.purchaseId && { purchaseId: params.purchaseId }), ...(params.asset && { asset: params.asset }), diff --git a/src/modules/simple-earn/flexible/redeemFlexible.ts b/src/modules/simple-earn/flexible/redeemFlexible.ts index 8411aac5..feaef3c6 100644 --- a/src/modules/simple-earn/flexible/redeemFlexible.ts +++ b/src/modules/simple-earn/flexible/redeemFlexible.ts @@ -34,7 +34,7 @@ export function registerSimpleEarnRedeemFlexible(server: McpServer) { }, async (params) => { try { - const response = await simpleEarnClient.restAPI.redeemFlexibleProduct({ + const response = await (simpleEarnClient as any).restAPI.redeemFlexibleProduct({ productId: params.productId, ...(params.redeemAll !== undefined && { redeemAll: params.redeemAll }), ...(params.amount && { amount: params.amount }), diff --git a/src/modules/simple-earn/flexible/subscribeFlexible.ts b/src/modules/simple-earn/flexible/subscribeFlexible.ts index ce6b7b85..91c38bd3 100644 --- a/src/modules/simple-earn/flexible/subscribeFlexible.ts +++ b/src/modules/simple-earn/flexible/subscribeFlexible.ts @@ -33,7 +33,7 @@ export function registerSimpleEarnSubscribeFlexible(server: McpServer) { }, async (params) => { try { - const response = await simpleEarnClient.restAPI.subscribeFlexibleProduct({ + const response = await (simpleEarnClient as any).restAPI.subscribeFlexibleProduct({ productId: params.productId, amount: params.amount, ...(params.autoSubscribe !== undefined && { autoSubscribe: params.autoSubscribe }), diff --git a/src/modules/simple-earn/locked/getLockedPersonalQuota.ts b/src/modules/simple-earn/locked/getLockedPersonalQuota.ts index fccc619c..2e9479a0 100644 --- a/src/modules/simple-earn/locked/getLockedPersonalQuota.ts +++ b/src/modules/simple-earn/locked/getLockedPersonalQuota.ts @@ -24,7 +24,7 @@ export function registerSimpleEarnLockedPersonalQuota(server: McpServer) { }, async (params) => { try { - const response = await simpleEarnClient.restAPI.getLockedPersonalLeftQuota({ + const response = await (simpleEarnClient as any).restAPI.getLockedPersonalLeftQuota({ projectId: params.projectId, ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/modules/simple-earn/locked/getLockedPosition.ts b/src/modules/simple-earn/locked/getLockedPosition.ts index b85672ad..2cf19049 100644 --- a/src/modules/simple-earn/locked/getLockedPosition.ts +++ b/src/modules/simple-earn/locked/getLockedPosition.ts @@ -28,7 +28,7 @@ export function registerSimpleEarnLockedPosition(server: McpServer) { }, async (params) => { try { - const response = await simpleEarnClient.restAPI.getLockedProductPosition({ + const response = await (simpleEarnClient as any).restAPI.getLockedProductPosition({ ...(params.asset && { asset: params.asset }), ...(params.positionId && { positionId: params.positionId }), ...(params.projectId && { projectId: params.projectId }), diff --git a/src/modules/simple-earn/locked/getLockedProductList.ts b/src/modules/simple-earn/locked/getLockedProductList.ts index b2d28631..d29983ed 100644 --- a/src/modules/simple-earn/locked/getLockedProductList.ts +++ b/src/modules/simple-earn/locked/getLockedProductList.ts @@ -32,7 +32,7 @@ export function registerSimpleEarnLockedProductList(server: McpServer) { }, async (params) => { try { - const response = await simpleEarnClient.restAPI.getSimpleEarnLockedProductList({ + const response = await (simpleEarnClient as any).restAPI.getSimpleEarnLockedProductList({ ...(params.asset && { asset: params.asset }), ...(params.current && { current: params.current }), ...(params.size && { size: params.size }), diff --git a/src/modules/simple-earn/locked/getLockedSubscriptionPreview.ts b/src/modules/simple-earn/locked/getLockedSubscriptionPreview.ts index c279f4d3..bc55f8c0 100644 --- a/src/modules/simple-earn/locked/getLockedSubscriptionPreview.ts +++ b/src/modules/simple-earn/locked/getLockedSubscriptionPreview.ts @@ -26,7 +26,7 @@ export function registerSimpleEarnLockedSubscriptionPreview(server: McpServer) { }, async (params) => { try { - const response = await simpleEarnClient.restAPI.getLockedSubscriptionPreview({ + const response = await (simpleEarnClient as any).restAPI.getLockedSubscriptionPreview({ projectId: params.projectId, amount: params.amount, ...(params.autoSubscribe !== undefined && { autoSubscribe: params.autoSubscribe }), diff --git a/src/modules/simple-earn/locked/getRedemptionRecord.ts b/src/modules/simple-earn/locked/getRedemptionRecord.ts index 11755a40..fe4e4b63 100644 --- a/src/modules/simple-earn/locked/getRedemptionRecord.ts +++ b/src/modules/simple-earn/locked/getRedemptionRecord.ts @@ -30,7 +30,7 @@ export function registerSimpleEarnLockedRedemptionRecord(server: McpServer) { }, async (params) => { try { - const response = await simpleEarnClient.restAPI.getLockedRedemptionRecord({ + const response = await (simpleEarnClient as any).restAPI.getLockedRedemptionRecord({ ...(params.positionId && { positionId: params.positionId }), ...(params.redeemId && { redeemId: params.redeemId }), ...(params.asset && { asset: params.asset }), diff --git a/src/modules/simple-earn/locked/getSubscriptionRecord.ts b/src/modules/simple-earn/locked/getSubscriptionRecord.ts index 19dcf949..85faf2fa 100644 --- a/src/modules/simple-earn/locked/getSubscriptionRecord.ts +++ b/src/modules/simple-earn/locked/getSubscriptionRecord.ts @@ -29,7 +29,7 @@ export function registerSimpleEarnLockedSubscriptionRecord(server: McpServer) { }, async (params) => { try { - const response = await simpleEarnClient.restAPI.getLockedSubscriptionRecord({ + const response = await (simpleEarnClient as any).restAPI.getLockedSubscriptionRecord({ ...(params.purchaseId && { purchaseId: params.purchaseId }), ...(params.asset && { asset: params.asset }), ...(params.startTime && { startTime: params.startTime }), diff --git a/src/modules/simple-earn/locked/redeemLocked.ts b/src/modules/simple-earn/locked/redeemLocked.ts index 141e403c..1e434770 100644 --- a/src/modules/simple-earn/locked/redeemLocked.ts +++ b/src/modules/simple-earn/locked/redeemLocked.ts @@ -24,7 +24,7 @@ export function registerSimpleEarnRedeemLocked(server: McpServer) { }, async (params) => { try { - const response = await simpleEarnClient.restAPI.redeemLockedProduct({ + const response = await (simpleEarnClient as any).restAPI.redeemLockedProduct({ positionId: params.positionId, ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/modules/simple-earn/locked/setAutoSubscribe.ts b/src/modules/simple-earn/locked/setAutoSubscribe.ts index fdac0fe7..10fc3f68 100644 --- a/src/modules/simple-earn/locked/setAutoSubscribe.ts +++ b/src/modules/simple-earn/locked/setAutoSubscribe.ts @@ -25,7 +25,7 @@ export function registerSimpleEarnSetAutoSubscribe(server: McpServer) { }, async (params) => { try { - const response = await simpleEarnClient.restAPI.setLockedAutoSubscribe({ + const response = await (simpleEarnClient as any).restAPI.setLockedAutoSubscribe({ positionId: params.positionId, autoSubscribe: params.autoSubscribe, ...(params.recvWindow && { recvWindow: params.recvWindow }), diff --git a/src/modules/simple-earn/locked/subscribeLocked.ts b/src/modules/simple-earn/locked/subscribeLocked.ts index 4e3f0048..2da5c588 100644 --- a/src/modules/simple-earn/locked/subscribeLocked.ts +++ b/src/modules/simple-earn/locked/subscribeLocked.ts @@ -30,7 +30,7 @@ export function registerSimpleEarnSubscribeLocked(server: McpServer) { }, async (params) => { try { - const response = await simpleEarnClient.restAPI.subscribeLockedProduct({ + const response = await (simpleEarnClient as any).restAPI.subscribeLockedProduct({ projectId: params.projectId, amount: params.amount, ...(params.autoSubscribe !== undefined && { autoSubscribe: params.autoSubscribe }), diff --git a/src/modules/spot/account-api/accountCommission.ts b/src/modules/spot/account-api/accountCommission.ts index b176b579..174c56f7 100644 --- a/src/modules/spot/account-api/accountCommission.ts +++ b/src/modules/spot/account-api/accountCommission.ts @@ -20,7 +20,7 @@ export function registerBinanceAccountCommission(server: McpServer) { const params: any = { symbol }; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await spotClient.restAPI.accountCommission(params); + const response = await (spotClient as any).restAPI.accountCommission(params); const data = await response.data(); diff --git a/src/modules/spot/account-api/getAccount.ts b/src/modules/spot/account-api/getAccount.ts index 40b9ab14..f791492d 100644 --- a/src/modules/spot/account-api/getAccount.ts +++ b/src/modules/spot/account-api/getAccount.ts @@ -19,7 +19,7 @@ export function registerBinanceGetAccount(server: McpServer) { const params: any = {}; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await spotClient.restAPI.getAccount(params); + const response = await (spotClient as any).restAPI.getAccount(params); const data = await response.data(); diff --git a/src/modules/spot/account-api/myAllocations.ts b/src/modules/spot/account-api/myAllocations.ts index a000150c..672f5b92 100644 --- a/src/modules/spot/account-api/myAllocations.ts +++ b/src/modules/spot/account-api/myAllocations.ts @@ -29,7 +29,7 @@ export function registerBinanceMyAllocations(server: McpServer) { if (limit !== undefined) params.limit = limit; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await spotClient.restAPI.myAllocations(params); + const response = await (spotClient as any).restAPI.myAllocations(params); const data = await response.data(); diff --git a/src/modules/spot/account-api/myPreventedMatches.ts b/src/modules/spot/account-api/myPreventedMatches.ts index cff226cb..cb6e5e41 100644 --- a/src/modules/spot/account-api/myPreventedMatches.ts +++ b/src/modules/spot/account-api/myPreventedMatches.ts @@ -29,7 +29,7 @@ export function registerBinanceMyPreventedMatches(server: McpServer) { if (limit !== undefined) params.limit = limit; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await spotClient.restAPI.myPreventedMatches(params); + const response = await (spotClient as any).restAPI.myPreventedMatches(params); const data = await response.data(); diff --git a/src/modules/spot/account-api/myTrades.ts b/src/modules/spot/account-api/myTrades.ts index c7576641..9965ad2d 100644 --- a/src/modules/spot/account-api/myTrades.ts +++ b/src/modules/spot/account-api/myTrades.ts @@ -31,7 +31,7 @@ export function registerBinanceMyTrades(server: McpServer) { if (limit !== undefined) params.limit = limit; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await spotClient.restAPI.myTrades(params); + const response = await (spotClient as any).restAPI.myTrades(params); const data = await response.data(); diff --git a/src/modules/spot/account-api/rateLimitOrder.ts b/src/modules/spot/account-api/rateLimitOrder.ts index a8956267..7eabceb3 100644 --- a/src/modules/spot/account-api/rateLimitOrder.ts +++ b/src/modules/spot/account-api/rateLimitOrder.ts @@ -19,7 +19,7 @@ export function registerBinanceRateLimitOrder(server: McpServer) { const params: any = {}; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await spotClient.restAPI.rateLimitOrder(params); + const response = await (spotClient as any).restAPI.rateLimitOrder(params); const data = await response.data(); diff --git a/src/modules/spot/general-api/exchangeInfo.ts b/src/modules/spot/general-api/exchangeInfo.ts index befab108..26b16df6 100644 --- a/src/modules/spot/general-api/exchangeInfo.ts +++ b/src/modules/spot/general-api/exchangeInfo.ts @@ -37,7 +37,7 @@ export function registerBinanceExchangeInfo(server: McpServer) { if (permissions?.length && !params.symbol && !params.symbols) params.permissions = permissions; - const response = await spotClient.restAPI.exchangeInfo(params); + const response = await (spotClient as any).restAPI.exchangeInfo(params); const data = await response.data(); diff --git a/src/modules/spot/general-api/ping.ts b/src/modules/spot/general-api/ping.ts index bddc02d5..18939f88 100644 --- a/src/modules/spot/general-api/ping.ts +++ b/src/modules/spot/general-api/ping.ts @@ -9,7 +9,7 @@ export function registerBinancePing(server: McpServer) { { description: "Test connectivity to the Binance API." }, async () => { try { - const response = await spotClient.restAPI.ping(); + const response = await (spotClient as any).restAPI.ping(); const data = await response.data(); diff --git a/src/modules/spot/general-api/time.ts b/src/modules/spot/general-api/time.ts index 601054ff..bef51db8 100644 --- a/src/modules/spot/general-api/time.ts +++ b/src/modules/spot/general-api/time.ts @@ -9,11 +9,10 @@ export function registerBinanceTime(server: McpServer) { { description: "Get the current server time from Binance API." }, async () => { try { - const response = await spotClient.restAPI.time(); + const response = await (spotClient as any).restAPI.time(); const data = await response.data(); - // @ts-expect-error - serverTime not in generated type definition const serverTime = new Date(data.serverTime).toISOString(); return { diff --git a/src/modules/spot/market-api/aggTrades.ts b/src/modules/spot/market-api/aggTrades.ts index 0f4e8f65..1d1ef133 100644 --- a/src/modules/spot/market-api/aggTrades.ts +++ b/src/modules/spot/market-api/aggTrades.ts @@ -27,7 +27,7 @@ export function registerBinanceAggTrades(server: McpServer) { if (endTime !== undefined) params.endTime = endTime; if (limit !== undefined) params.limit = limit; - const response = await spotClient.restAPI.aggTrades(params); + const response = await (spotClient as any).restAPI.aggTrades(params); const data = await response.data(); diff --git a/src/modules/spot/market-api/avgPrice.ts b/src/modules/spot/market-api/avgPrice.ts index 299e44d8..4ccb304c 100644 --- a/src/modules/spot/market-api/avgPrice.ts +++ b/src/modules/spot/market-api/avgPrice.ts @@ -16,7 +16,7 @@ export function registerBinanceAvgPrice(server: McpServer) { }, async ({ symbol }) => { try { - const response = await spotClient.restAPI.avgPrice({ + const response = await (spotClient as any).restAPI.avgPrice({ symbol: symbol, }); diff --git a/src/modules/spot/market-api/depth.ts b/src/modules/spot/market-api/depth.ts index 106c39d7..2ce263f5 100644 --- a/src/modules/spot/market-api/depth.ts +++ b/src/modules/spot/market-api/depth.ts @@ -20,7 +20,7 @@ export function registerBinanceDepth(server: McpServer) { const params: any = { symbol }; if (limit !== undefined) params.limit = limit; - const response = await spotClient.restAPI.depth(params); + const response = await (spotClient as any).restAPI.depth(params); const data = await response.data(); diff --git a/src/modules/spot/market-api/getTrades.ts b/src/modules/spot/market-api/getTrades.ts index 1d0dace1..2ecffd7e 100644 --- a/src/modules/spot/market-api/getTrades.ts +++ b/src/modules/spot/market-api/getTrades.ts @@ -21,7 +21,7 @@ export function registerBinanceGetTrades(server: McpServer) { if (limit !== undefined) params.limit = limit; - const response = await spotClient.restAPI.getTrades(params); + const response = await (spotClient as any).restAPI.getTrades(params); const data = await response.data(); diff --git a/src/modules/spot/market-api/historicalTrades.ts b/src/modules/spot/market-api/historicalTrades.ts index 85299c2a..4ac08777 100644 --- a/src/modules/spot/market-api/historicalTrades.ts +++ b/src/modules/spot/market-api/historicalTrades.ts @@ -23,7 +23,7 @@ export function registerBinanceHistoricalTrades(server: McpServer) { if (limit !== undefined) params.limit = limit; if (fromId !== undefined) params.fromId = fromId; - const response = await spotClient.restAPI.historicalTrades(params); + const response = await (spotClient as any).restAPI.historicalTrades(params); const data = await response.data(); diff --git a/src/modules/spot/market-api/klines.ts b/src/modules/spot/market-api/klines.ts index 12d97fea..69ee69df 100644 --- a/src/modules/spot/market-api/klines.ts +++ b/src/modules/spot/market-api/klines.ts @@ -47,7 +47,7 @@ export function registerBinanceKlines(server: McpServer) { if (endTime !== undefined) params.endTime = endTime; if (limit !== undefined) params.limit = limit; - const response = await spotClient.restAPI.klines(params); + const response = await (spotClient as any).restAPI.klines(params); const data = await response.data(); diff --git a/src/modules/spot/market-api/ticker.ts b/src/modules/spot/market-api/ticker.ts index dc71f02d..085fb0a9 100644 --- a/src/modules/spot/market-api/ticker.ts +++ b/src/modules/spot/market-api/ticker.ts @@ -25,7 +25,7 @@ export function registerBinanceTicker(server: McpServer) { if (symbol) params.symbol = symbol; if (windowSize) params.windowSize = windowSize; - const response = await spotClient.restAPI.ticker(params); + const response = await (spotClient as any).restAPI.ticker(params); const data = await response.data(); diff --git a/src/modules/spot/market-api/ticker24hr.ts b/src/modules/spot/market-api/ticker24hr.ts index 06fb1f9b..35d607fb 100644 --- a/src/modules/spot/market-api/ticker24hr.ts +++ b/src/modules/spot/market-api/ticker24hr.ts @@ -19,7 +19,7 @@ export function registerBinanceTicker24hr(server: McpServer) { const params: any = {}; if (symbol) params.symbol = symbol; - const response = await spotClient.restAPI.ticker24hr(params); + const response = await (spotClient as any).restAPI.ticker24hr(params); const data = await response.data(); diff --git a/src/modules/spot/market-api/tickerBookTicker.ts b/src/modules/spot/market-api/tickerBookTicker.ts index ab275052..103c86fb 100644 --- a/src/modules/spot/market-api/tickerBookTicker.ts +++ b/src/modules/spot/market-api/tickerBookTicker.ts @@ -19,7 +19,7 @@ export function registerBinanceTickerBookTicker(server: McpServer) { const params: any = {}; if (symbol) params.symbol = symbol; - const response = await spotClient.restAPI.tickerBookTicker(params); + const response = await (spotClient as any).restAPI.tickerBookTicker(params); const data = await response.data(); diff --git a/src/modules/spot/market-api/tickerPrice.ts b/src/modules/spot/market-api/tickerPrice.ts index f1da8d7c..7a4ee56f 100644 --- a/src/modules/spot/market-api/tickerPrice.ts +++ b/src/modules/spot/market-api/tickerPrice.ts @@ -19,7 +19,7 @@ export function registerBinanceTickerPrice(server: McpServer) { const params: any = {}; if (symbol) params.symbol = symbol; - const response = await spotClient.restAPI.tickerPrice(params); + const response = await (spotClient as any).restAPI.tickerPrice(params); const data = await response.data(); diff --git a/src/modules/spot/market-api/tickerTradingDay.ts b/src/modules/spot/market-api/tickerTradingDay.ts index 1fcedc0f..0f43c545 100644 --- a/src/modules/spot/market-api/tickerTradingDay.ts +++ b/src/modules/spot/market-api/tickerTradingDay.ts @@ -19,7 +19,7 @@ export function registerBinanceTickerTradingDay(server: McpServer) { const params: any = {}; if (symbol) params.symbol = symbol; - const response = await spotClient.restAPI.tickerTradingDay(params); + const response = await (spotClient as any).restAPI.tickerTradingDay(params); const data = await response.data(); diff --git a/src/modules/spot/market-api/uiKlines.ts b/src/modules/spot/market-api/uiKlines.ts index 697bf896..9a767f00 100644 --- a/src/modules/spot/market-api/uiKlines.ts +++ b/src/modules/spot/market-api/uiKlines.ts @@ -47,7 +47,7 @@ export function registerBinanceUiKlines(server: McpServer) { if (endTime !== undefined) params.endTime = endTime; if (limit !== undefined) params.limit = limit; - const response = await spotClient.restAPI.uiKlines(params); + const response = await (spotClient as any).restAPI.uiKlines(params); const data = await response.data(); diff --git a/src/modules/spot/trade-api/allOrders.ts b/src/modules/spot/trade-api/allOrders.ts index d8ab32d9..41dcc20d 100644 --- a/src/modules/spot/trade-api/allOrders.ts +++ b/src/modules/spot/trade-api/allOrders.ts @@ -30,7 +30,7 @@ export function registerBinanceAllOrders(server: McpServer) { if (endTime !== undefined) params.endTime = endTime; if (limit !== undefined) params.limit = limit; - const response = await spotClient.restAPI.allOrders(params); + const response = await (spotClient as any).restAPI.allOrders(params); const data = await response.data(); diff --git a/src/modules/spot/trade-api/deleteOpenOrders.ts b/src/modules/spot/trade-api/deleteOpenOrders.ts index 22d06c31..541b9de6 100644 --- a/src/modules/spot/trade-api/deleteOpenOrders.ts +++ b/src/modules/spot/trade-api/deleteOpenOrders.ts @@ -16,7 +16,7 @@ export function registerBinanceDeleteOpenOrders(server: McpServer) { }, async ({ symbol }) => { try { - const response = await spotClient.restAPI.deleteOpenOrders({ + const response = await (spotClient as any).restAPI.deleteOpenOrders({ symbol: symbol, }); diff --git a/src/modules/spot/trade-api/deleteOrder.ts b/src/modules/spot/trade-api/deleteOrder.ts index 9768877b..ac8036f0 100644 --- a/src/modules/spot/trade-api/deleteOrder.ts +++ b/src/modules/spot/trade-api/deleteOrder.ts @@ -23,7 +23,7 @@ export function registerBinanceDeleteOrder(server: McpServer) { if (orderId) params.orderId = orderId; if (origClientOrderId) params.origClientOrderId = origClientOrderId; - const response = await spotClient.restAPI.deleteOrder(params); + const response = await (spotClient as any).restAPI.deleteOrder(params); const data = await response.data(); diff --git a/src/modules/spot/trade-api/getOpenOrders.ts b/src/modules/spot/trade-api/getOpenOrders.ts index 4abe2229..9d36a0ad 100644 --- a/src/modules/spot/trade-api/getOpenOrders.ts +++ b/src/modules/spot/trade-api/getOpenOrders.ts @@ -19,7 +19,7 @@ export function registerBinanceGetOpenOrders(server: McpServer) { const params: any = {}; if (symbol) params.symbol = symbol; - const response = await spotClient.restAPI.getOpenOrders(params); + const response = await (spotClient as any).restAPI.getOpenOrders(params); const data = await response.data(); diff --git a/src/modules/spot/trade-api/getOrder.ts b/src/modules/spot/trade-api/getOrder.ts index b3e2afa9..3357bf2b 100644 --- a/src/modules/spot/trade-api/getOrder.ts +++ b/src/modules/spot/trade-api/getOrder.ts @@ -23,7 +23,7 @@ export function registerBinanceGetOrder(server: McpServer) { if (orderId) params.orderId = orderId; if (origClientOrderId) params.origClientOrderId = origClientOrderId; - const response = await spotClient.restAPI.getOrder(params); + const response = await (spotClient as any).restAPI.getOrder(params); const data = await response.data(); diff --git a/src/modules/spot/trade-api/newOrder.ts b/src/modules/spot/trade-api/newOrder.ts index 00773a80..e62eb377 100644 --- a/src/modules/spot/trade-api/newOrder.ts +++ b/src/modules/spot/trade-api/newOrder.ts @@ -77,7 +77,7 @@ export function registerBinanceNewOrder(server: McpServer) { if (icebergQty !== undefined) params.icebergQty = icebergQty; if (newOrderRespType) params.newOrderRespType = newOrderRespType; - const response = await spotClient.restAPI.newOrder(params); + const response = await (spotClient as any).restAPI.newOrder(params); const data = await response.data(); diff --git a/src/modules/spot/trade-api/openOrderList.ts b/src/modules/spot/trade-api/openOrderList.ts index 12c9a3a4..02ae7c12 100644 --- a/src/modules/spot/trade-api/openOrderList.ts +++ b/src/modules/spot/trade-api/openOrderList.ts @@ -19,7 +19,7 @@ export function registerBinanceOpenOrderList(server: McpServer) { const params: any = {}; if (symbol) params.symbol = symbol; - const response = await spotClient.restAPI.openOrderList(params); + const response = await (spotClient as any).restAPI.openOrderList(params); const data = await response.data(); diff --git a/src/modules/spot/trade-api/orderOco.ts b/src/modules/spot/trade-api/orderOco.ts index 33348c6d..b3e09c8e 100644 --- a/src/modules/spot/trade-api/orderOco.ts +++ b/src/modules/spot/trade-api/orderOco.ts @@ -56,7 +56,7 @@ export function registerBinanceOrderOco(server: McpServer) { if (limitIcebergQty !== undefined) params.limitIcebergQty = limitIcebergQty; if (stopIcebergQty !== undefined) params.stopIcebergQty = stopIcebergQty; - const response = await spotClient.restAPI.orderOco(params); + const response = await (spotClient as any).restAPI.orderOco(params); const data = await response.data(); diff --git a/src/modules/spot/userdatastream-api/deleteUserDataStream.ts b/src/modules/spot/userdatastream-api/deleteUserDataStream.ts index 47eb16f3..5dfa7052 100644 --- a/src/modules/spot/userdatastream-api/deleteUserDataStream.ts +++ b/src/modules/spot/userdatastream-api/deleteUserDataStream.ts @@ -16,7 +16,7 @@ export function registerBinanceDeleteUserDataStream(server: McpServer) { }, async ({ listenKey }) => { try { - const response = await spotClient.restAPI.deleteUserDataStream({ + const response = await (spotClient as any).restAPI.deleteUserDataStream({ listenKey: listenKey, }); diff --git a/src/modules/spot/userdatastream-api/newUserDataStream.ts b/src/modules/spot/userdatastream-api/newUserDataStream.ts index e7bd9d50..74dd45f0 100644 --- a/src/modules/spot/userdatastream-api/newUserDataStream.ts +++ b/src/modules/spot/userdatastream-api/newUserDataStream.ts @@ -9,7 +9,7 @@ export function registerBinanceNewUserDataStream(server: McpServer) { { description: "Create a new user data stream to receive account updates via WebSocket." }, async () => { try { - const response = await spotClient.restAPI.newUserDataStream(); + const response = await (spotClient as any).restAPI.newUserDataStream(); const data = await response.data(); diff --git a/src/modules/spot/userdatastream-api/putUserDataStream.ts b/src/modules/spot/userdatastream-api/putUserDataStream.ts index 73d4783e..63568ebe 100644 --- a/src/modules/spot/userdatastream-api/putUserDataStream.ts +++ b/src/modules/spot/userdatastream-api/putUserDataStream.ts @@ -16,7 +16,7 @@ export function registerBinancePutUserDataStream(server: McpServer) { }, async ({ listenKey }) => { try { - const response = await spotClient.restAPI.putUserDataStream({ + const response = await (spotClient as any).restAPI.putUserDataStream({ listenKey: listenKey, }); diff --git a/src/modules/wallet/account-api/accountApiTradingStatus.ts b/src/modules/wallet/account-api/accountApiTradingStatus.ts index 798d26c2..99e08066 100644 --- a/src/modules/wallet/account-api/accountApiTradingStatus.ts +++ b/src/modules/wallet/account-api/accountApiTradingStatus.ts @@ -19,7 +19,7 @@ export function registerBinanceWalletAccountApiTradingStatus(server: McpServer) const params: any = {}; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.accountApiTradingStatus(params); + const response = await (walletClient as any).restAPI.accountApiTradingStatus(params); const data = await response.data(); return { diff --git a/src/modules/wallet/account-api/accountInfo.ts b/src/modules/wallet/account-api/accountInfo.ts index 16e6c3d8..74e27c16 100644 --- a/src/modules/wallet/account-api/accountInfo.ts +++ b/src/modules/wallet/account-api/accountInfo.ts @@ -19,7 +19,7 @@ export function registerBinanceWalletAccountInfo(server: McpServer) { const params: any = {}; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.accountInfo(params); + const response = await (walletClient as any).restAPI.accountInfo(params); const data = await response.data(); return { diff --git a/src/modules/wallet/account-api/accountStatus.ts b/src/modules/wallet/account-api/accountStatus.ts index e07e0734..e76fb3b2 100644 --- a/src/modules/wallet/account-api/accountStatus.ts +++ b/src/modules/wallet/account-api/accountStatus.ts @@ -19,7 +19,7 @@ export function registerBinanceWalletAccountStatus(server: McpServer) { const params: any = {}; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.accountStatus(params); + const response = await (walletClient as any).restAPI.accountStatus(params); const data = await response.data(); return { diff --git a/src/modules/wallet/account-api/dailyAccountSnapshot.ts b/src/modules/wallet/account-api/dailyAccountSnapshot.ts index 6b14d247..388a6906 100644 --- a/src/modules/wallet/account-api/dailyAccountSnapshot.ts +++ b/src/modules/wallet/account-api/dailyAccountSnapshot.ts @@ -26,7 +26,7 @@ export function registerBinanceWalletDailyAccountSnapshot(server: McpServer) { if (limit !== undefined) params.limit = limit; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.dailyAccountSnapshot(params); + const response = await (walletClient as any).restAPI.dailyAccountSnapshot(params); const data = await response.data(); return { diff --git a/src/modules/wallet/account-api/disableFastWithdrawSwitch.ts b/src/modules/wallet/account-api/disableFastWithdrawSwitch.ts index 3c3a86ab..46b33792 100644 --- a/src/modules/wallet/account-api/disableFastWithdrawSwitch.ts +++ b/src/modules/wallet/account-api/disableFastWithdrawSwitch.ts @@ -19,7 +19,7 @@ export function registerBinanceWalletDisableFastWithdrawSwitch(server: McpServer const params: any = {}; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.disableFastWithdrawSwitch(params); + const response = await (walletClient as any).restAPI.disableFastWithdrawSwitch(params); const data = await response.data(); return { diff --git a/src/modules/wallet/account-api/enableFastWithdrawSwitch.ts b/src/modules/wallet/account-api/enableFastWithdrawSwitch.ts index e9e163ff..b4d54e4b 100644 --- a/src/modules/wallet/account-api/enableFastWithdrawSwitch.ts +++ b/src/modules/wallet/account-api/enableFastWithdrawSwitch.ts @@ -19,7 +19,7 @@ export function registerBinanceWalletEnableFastWithdrawSwitch(server: McpServer) const params: any = {}; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.enableFastWithdrawSwitch(params); + const response = await (walletClient as any).restAPI.enableFastWithdrawSwitch(params); const data = await response.data(); return { diff --git a/src/modules/wallet/account-api/getApiKeyPermission.ts b/src/modules/wallet/account-api/getApiKeyPermission.ts index fa9634a7..cab47335 100644 --- a/src/modules/wallet/account-api/getApiKeyPermission.ts +++ b/src/modules/wallet/account-api/getApiKeyPermission.ts @@ -19,7 +19,7 @@ export function registerBinanceWalletGetApiKeyPermission(server: McpServer) { const params: any = {}; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.getApiKeyPermission(params); + const response = await (walletClient as any).restAPI.getApiKeyPermission(params); const data = await response.data(); return { diff --git a/src/modules/wallet/asset-api/assetDetail.ts b/src/modules/wallet/asset-api/assetDetail.ts index 515bb0c6..c4f5a55b 100644 --- a/src/modules/wallet/asset-api/assetDetail.ts +++ b/src/modules/wallet/asset-api/assetDetail.ts @@ -21,7 +21,7 @@ export function registerBinanceWalletAssetDetail(server: McpServer) { if (asset !== undefined) params.asset = asset; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.assetDetail(params); + const response = await (walletClient as any).restAPI.assetDetail(params); const data = await response.data(); return { diff --git a/src/modules/wallet/asset-api/assetDividendRecord.ts b/src/modules/wallet/asset-api/assetDividendRecord.ts index 1edbc26d..29dbba85 100644 --- a/src/modules/wallet/asset-api/assetDividendRecord.ts +++ b/src/modules/wallet/asset-api/assetDividendRecord.ts @@ -27,7 +27,7 @@ export function registerBinanceWalletAssetDividendRecord(server: McpServer) { if (limit !== undefined) params.limit = limit; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.assetDividendRecord(params); + const response = await (walletClient as any).restAPI.assetDividendRecord(params); const data = await response.data(); return { diff --git a/src/modules/wallet/asset-api/dustTransfer.ts b/src/modules/wallet/asset-api/dustTransfer.ts index 0f04581a..0be0bdb5 100644 --- a/src/modules/wallet/asset-api/dustTransfer.ts +++ b/src/modules/wallet/asset-api/dustTransfer.ts @@ -20,7 +20,7 @@ export function registerBinanceWalletDustTransfer(server: McpServer) { const params: any = { asset }; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.dustTransfer(params); + const response = await (walletClient as any).restAPI.dustTransfer(params); const data = await response.data(); return { diff --git a/src/modules/wallet/asset-api/dustlog.ts b/src/modules/wallet/asset-api/dustlog.ts index c42e419f..c1ccd2d6 100644 --- a/src/modules/wallet/asset-api/dustlog.ts +++ b/src/modules/wallet/asset-api/dustlog.ts @@ -23,7 +23,7 @@ export function registerBinanceWalletDustlog(server: McpServer) { if (endTime !== undefined) params.endTime = endTime; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.dustlog(params); + const response = await (walletClient as any).restAPI.dustlog(params); const data = await response.data(); return { diff --git a/src/modules/wallet/asset-api/fundingWallet.ts b/src/modules/wallet/asset-api/fundingWallet.ts index 8403e5ae..226a7bc6 100644 --- a/src/modules/wallet/asset-api/fundingWallet.ts +++ b/src/modules/wallet/asset-api/fundingWallet.ts @@ -23,7 +23,7 @@ export function registerBinanceWalletFundingWallet(server: McpServer) { if (needBtcValuation !== undefined) params.needBtcValuation = needBtcValuation; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.fundingWallet(params); + const response = await (walletClient as any).restAPI.fundingWallet(params); const data = await response.data(); return { diff --git a/src/modules/wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts b/src/modules/wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts index 4476777a..f969e0c5 100644 --- a/src/modules/wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts +++ b/src/modules/wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts @@ -19,7 +19,9 @@ export function registerBinanceWalletGetAssetsThatCanBeConvertedIntoBnb(server: const params: any = {}; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.getAssetsThatCanBeConvertedIntoBnb(params); + const response = await (walletClient as any).restAPI.getAssetsThatCanBeConvertedIntoBnb( + params, + ); const data = await response.data(); return { diff --git a/src/modules/wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts b/src/modules/wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts index 4aaf8156..4953b9e6 100644 --- a/src/modules/wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts +++ b/src/modules/wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts @@ -28,7 +28,9 @@ export function registerBinanceWalletGetCloudMiningPaymentAndRefundHistory(serve if (pageSize !== undefined) params.pageSize = pageSize; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.getCloudMiningPaymentAndRefundHistory(params); + const response = await (walletClient as any).restAPI.getCloudMiningPaymentAndRefundHistory( + params, + ); const data = await response.data(); return { diff --git a/src/modules/wallet/asset-api/getOpenSymbolList.ts b/src/modules/wallet/asset-api/getOpenSymbolList.ts index 1e575b53..ce26b78e 100644 --- a/src/modules/wallet/asset-api/getOpenSymbolList.ts +++ b/src/modules/wallet/asset-api/getOpenSymbolList.ts @@ -9,7 +9,7 @@ export function registerBinanceWalletGetOpenSymbolList(server: McpServer) { { description: "Get open symbol list." }, async () => { try { - const response = await walletClient.restAPI.getOpenSymbolList(); + const response = await (walletClient as any).restAPI.getOpenSymbolList(); const data = await response.data(); return { diff --git a/src/modules/wallet/asset-api/queryUserDelegationHistory.ts b/src/modules/wallet/asset-api/queryUserDelegationHistory.ts index 679e40ff..b2e75a0f 100644 --- a/src/modules/wallet/asset-api/queryUserDelegationHistory.ts +++ b/src/modules/wallet/asset-api/queryUserDelegationHistory.ts @@ -30,7 +30,7 @@ export function registerBinanceWalletQueryUserDelegationHistory(server: McpServe if (limit !== undefined) params.limit = limit; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.queryUserDelegationHistory(params); + const response = await (walletClient as any).restAPI.queryUserDelegationHistory(params); const data = await response.data(); return { diff --git a/src/modules/wallet/asset-api/queryUserUniversalTransferHistory.ts b/src/modules/wallet/asset-api/queryUserUniversalTransferHistory.ts index 32c1f6f8..edfa2703 100644 --- a/src/modules/wallet/asset-api/queryUserUniversalTransferHistory.ts +++ b/src/modules/wallet/asset-api/queryUserUniversalTransferHistory.ts @@ -32,7 +32,9 @@ export function registerBinanceWalletQueryUserUniversalTransferHistory(server: M if (toSymbol !== undefined) params.toSymbol = toSymbol; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.queryUserUniversalTransferHistory(params); + const response = await (walletClient as any).restAPI.queryUserUniversalTransferHistory( + params, + ); const data = await response.data(); return { diff --git a/src/modules/wallet/asset-api/queryUserWalletBalance.ts b/src/modules/wallet/asset-api/queryUserWalletBalance.ts index a56c9a84..2a1520fb 100644 --- a/src/modules/wallet/asset-api/queryUserWalletBalance.ts +++ b/src/modules/wallet/asset-api/queryUserWalletBalance.ts @@ -19,7 +19,7 @@ export function registerBinanceWalletQueryUserWalletBalance(server: McpServer) { const params: any = {}; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.queryUserWalletBalance(params); + const response = await (walletClient as any).restAPI.queryUserWalletBalance(params); const data = await response.data(); return { diff --git a/src/modules/wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts b/src/modules/wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts index 6cd869d0..688fcb5b 100644 --- a/src/modules/wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts +++ b/src/modules/wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts @@ -23,8 +23,9 @@ export function registerBinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest(s if (interestBNBBurn !== undefined) params.interestBNBBurn = interestBNBBurn; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = - await walletClient.restAPI.toggleBnbBurnOnSpotTradeAndMarginInterest(params); + const response = await ( + walletClient as any + ).restAPI.toggleBnbBurnOnSpotTradeAndMarginInterest(params); const data = await response.data(); return { diff --git a/src/modules/wallet/asset-api/tradeFee.ts b/src/modules/wallet/asset-api/tradeFee.ts index 6cb90d45..6861de41 100644 --- a/src/modules/wallet/asset-api/tradeFee.ts +++ b/src/modules/wallet/asset-api/tradeFee.ts @@ -21,7 +21,7 @@ export function registerBinanceWalletTradeFee(server: McpServer) { if (symbol !== undefined) params.symbol = symbol; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.tradeFee(params); + const response = await (walletClient as any).restAPI.tradeFee(params); const data = await response.data(); return { diff --git a/src/modules/wallet/asset-api/userAsset.ts b/src/modules/wallet/asset-api/userAsset.ts index ee4207a6..b9122d07 100644 --- a/src/modules/wallet/asset-api/userAsset.ts +++ b/src/modules/wallet/asset-api/userAsset.ts @@ -21,7 +21,7 @@ export function registerBinanceWalletUserAsset(server: McpServer) { if (recvWindow !== undefined) params.recvWindow = recvWindow; if (needBtcValuation !== undefined) params.needBtcValuation = needBtcValuation; - const response = await walletClient.restAPI.userAsset(params); + const response = await (walletClient as any).restAPI.userAsset(params); const data = await response.data(); return { diff --git a/src/modules/wallet/asset-api/userUniversalTransfer.ts b/src/modules/wallet/asset-api/userUniversalTransfer.ts index d59f97c8..0f9527e2 100644 --- a/src/modules/wallet/asset-api/userUniversalTransfer.ts +++ b/src/modules/wallet/asset-api/userUniversalTransfer.ts @@ -30,7 +30,7 @@ export function registerBinanceWalletUserUniversalTransfer(server: McpServer) { if (toSymbol !== undefined) params.toSymbol = toSymbol; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.userUniversalTransfer(params); + const response = await (walletClient as any).restAPI.userUniversalTransfer(params); const data = await response.data(); return { diff --git a/src/modules/wallet/capital-api/allCoinsInformation.ts b/src/modules/wallet/capital-api/allCoinsInformation.ts index 661a3983..5d998209 100644 --- a/src/modules/wallet/capital-api/allCoinsInformation.ts +++ b/src/modules/wallet/capital-api/allCoinsInformation.ts @@ -19,7 +19,7 @@ export function registerBinanceWalletAllCoinsInformation(server: McpServer) { const params: any = {}; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.allCoinsInformation(params); + const response = await (walletClient as any).restAPI.allCoinsInformation(params); const data = await response.data(); return { diff --git a/src/modules/wallet/capital-api/depositAddress.ts b/src/modules/wallet/capital-api/depositAddress.ts index 49dc9a1d..0ecb0015 100644 --- a/src/modules/wallet/capital-api/depositAddress.ts +++ b/src/modules/wallet/capital-api/depositAddress.ts @@ -22,7 +22,7 @@ export function registerBinanceWalletDepositAddress(server: McpServer) { if (network !== undefined) params.network = network; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.depositAddress(params); + const response = await (walletClient as any).restAPI.depositAddress(params); const data = await response.data(); return { diff --git a/src/modules/wallet/capital-api/depositHistory.ts b/src/modules/wallet/capital-api/depositHistory.ts index f654bcc8..67729320 100644 --- a/src/modules/wallet/capital-api/depositHistory.ts +++ b/src/modules/wallet/capital-api/depositHistory.ts @@ -31,7 +31,7 @@ export function registerBinanceWalletDepositHistory(server: McpServer) { if (limit !== undefined) params.limit = limit; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.depositHistory(params); + const response = await (walletClient as any).restAPI.depositHistory(params); const data = await response.data(); return { diff --git a/src/modules/wallet/capital-api/fetchDepositAddressListWithNetwork.ts b/src/modules/wallet/capital-api/fetchDepositAddressListWithNetwork.ts index 2b3c1d58..684fa6c5 100644 --- a/src/modules/wallet/capital-api/fetchDepositAddressListWithNetwork.ts +++ b/src/modules/wallet/capital-api/fetchDepositAddressListWithNetwork.ts @@ -22,7 +22,9 @@ export function registerBinanceWalletFetchDepositAddressListWithNetwork(server: if (network !== undefined) params.network = network; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.fetchDepositAddressListWithNetwork(params); + const response = await (walletClient as any).restAPI.fetchDepositAddressListWithNetwork( + params, + ); const data = await response.data(); return { diff --git a/src/modules/wallet/capital-api/fetchWithdrawAddressList.ts b/src/modules/wallet/capital-api/fetchWithdrawAddressList.ts index 954e3bb9..10f899eb 100644 --- a/src/modules/wallet/capital-api/fetchWithdrawAddressList.ts +++ b/src/modules/wallet/capital-api/fetchWithdrawAddressList.ts @@ -9,7 +9,7 @@ export function registerBinanceWalletFetchWithdrawAddressList(server: McpServer) { description: "Fetch withdraw address list." }, async () => { try { - const response = await walletClient.restAPI.fetchWithdrawAddressList(); + const response = await (walletClient as any).restAPI.fetchWithdrawAddressList(); const data = await response.data(); return { diff --git a/src/modules/wallet/capital-api/oneClickArrivalDepositApply.ts b/src/modules/wallet/capital-api/oneClickArrivalDepositApply.ts index 7d9b28f8..794acc72 100644 --- a/src/modules/wallet/capital-api/oneClickArrivalDepositApply.ts +++ b/src/modules/wallet/capital-api/oneClickArrivalDepositApply.ts @@ -21,7 +21,7 @@ export function registerBinanceWalletOneClickArrivalDepositApply(server: McpServ if (subAccountId !== undefined) params.subAccountId = subAccountId; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.oneClickArrivalDepositApply(params); + const response = await (walletClient as any).restAPI.oneClickArrivalDepositApply(params); const data = await response.data(); return { diff --git a/src/modules/wallet/capital-api/withdraw.ts b/src/modules/wallet/capital-api/withdraw.ts index a0779f6f..c759c25a 100644 --- a/src/modules/wallet/capital-api/withdraw.ts +++ b/src/modules/wallet/capital-api/withdraw.ts @@ -49,7 +49,7 @@ export function registerBinanceWalletWithdraw(server: McpServer) { if (transactionFeeFlag !== undefined) params.transactionFeeFlag = transactionFeeFlag; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.withdraw(params); + const response = await (walletClient as any).restAPI.withdraw(params); const data = await response.data(); return { diff --git a/src/modules/wallet/capital-api/withdrawHistory.ts b/src/modules/wallet/capital-api/withdrawHistory.ts index 3f1387b4..e9c7cec7 100644 --- a/src/modules/wallet/capital-api/withdrawHistory.ts +++ b/src/modules/wallet/capital-api/withdrawHistory.ts @@ -33,7 +33,7 @@ export function registerBinanceWalletWithdrawHistory(server: McpServer) { if (limit !== undefined) params.limit = limit; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.withdrawHistory(params); + const response = await (walletClient as any).restAPI.withdrawHistory(params); const data = await response.data(); return { diff --git a/src/modules/wallet/others-api/getSymbolsDelistScheduleForSpot.ts b/src/modules/wallet/others-api/getSymbolsDelistScheduleForSpot.ts index 1e61100b..3ef67fe7 100644 --- a/src/modules/wallet/others-api/getSymbolsDelistScheduleForSpot.ts +++ b/src/modules/wallet/others-api/getSymbolsDelistScheduleForSpot.ts @@ -9,7 +9,7 @@ export function registerBinanceWalletGetSymbolsDelistScheduleForSpot(server: Mcp { description: "Get delist schedule for spot symbols." }, async () => { try { - const response = await walletClient.restAPI.getSymbolsDelistScheduleForSpot(); + const response = await (walletClient as any).restAPI.getSymbolsDelistScheduleForSpot(); const data = await response.data(); return { diff --git a/src/modules/wallet/others-api/systemStatus.ts b/src/modules/wallet/others-api/systemStatus.ts index 59a2d1fa..f218dcdd 100644 --- a/src/modules/wallet/others-api/systemStatus.ts +++ b/src/modules/wallet/others-api/systemStatus.ts @@ -9,7 +9,7 @@ export function registerBinanceWalletSystemStatus(server: McpServer) { { description: "Get Binance Wallet system status." }, async () => { try { - const response = await walletClient.restAPI.systemStatus(); + const response = await (walletClient as any).restAPI.systemStatus(); const data = await response.data(); return { diff --git a/src/modules/wallet/travel-rule-api/brokerWithdraw.ts b/src/modules/wallet/travel-rule-api/brokerWithdraw.ts index bd2e8553..e2a34782 100644 --- a/src/modules/wallet/travel-rule-api/brokerWithdraw.ts +++ b/src/modules/wallet/travel-rule-api/brokerWithdraw.ts @@ -55,7 +55,7 @@ export function registerBinanceWalletBrokerWithdraw(server: McpServer) { if (name !== undefined) params.name = name; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.brokerWithdraw(params); + const response = await (walletClient as any).restAPI.brokerWithdraw(params); const data = await response.data(); return { diff --git a/src/modules/wallet/travel-rule-api/depositHistoryTravelRule.ts b/src/modules/wallet/travel-rule-api/depositHistoryTravelRule.ts index c2c76658..4ef383c4 100644 --- a/src/modules/wallet/travel-rule-api/depositHistoryTravelRule.ts +++ b/src/modules/wallet/travel-rule-api/depositHistoryTravelRule.ts @@ -31,7 +31,7 @@ export function registerBinanceWalletDepositHistoryTravelRule(server: McpServer) if (limit !== undefined) params.limit = limit; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.depositHistoryTravelRule(params); + const response = await (walletClient as any).restAPI.depositHistoryTravelRule(params); const data = await response.data(); return { diff --git a/src/modules/wallet/travel-rule-api/onboardedVaspList.ts b/src/modules/wallet/travel-rule-api/onboardedVaspList.ts index 98e0ff33..8b063cf5 100644 --- a/src/modules/wallet/travel-rule-api/onboardedVaspList.ts +++ b/src/modules/wallet/travel-rule-api/onboardedVaspList.ts @@ -9,7 +9,7 @@ export function registerBinanceWalletOnboardedVaspList(server: McpServer) { { description: "Get list of onboarded VASPs (Virtual Asset Service Providers)." }, async () => { try { - const response = await walletClient.restAPI.onboardedVaspList(); + const response = await (walletClient as any).restAPI.onboardedVaspList(); const data = await response.data(); return { diff --git a/src/modules/wallet/travel-rule-api/submitDepositQuestionnaire.ts b/src/modules/wallet/travel-rule-api/submitDepositQuestionnaire.ts index 588322ed..350be6f0 100644 --- a/src/modules/wallet/travel-rule-api/submitDepositQuestionnaire.ts +++ b/src/modules/wallet/travel-rule-api/submitDepositQuestionnaire.ts @@ -30,7 +30,7 @@ export function registerBinanceWalletSubmitDepositQuestionnaire(server: McpServe }; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.submitDepositQuestionnaire(params); + const response = await (walletClient as any).restAPI.submitDepositQuestionnaire(params); const data = await response.data(); return { diff --git a/src/modules/wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts b/src/modules/wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts index 674df61b..95aadcf7 100644 --- a/src/modules/wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts +++ b/src/modules/wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts @@ -24,7 +24,9 @@ export function registerBinanceWalletSubmitDepositQuestionnaireTravelRule(server }; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.submitDepositQuestionnaireTravelRule(params); + const response = await (walletClient as any).restAPI.submitDepositQuestionnaireTravelRule( + params, + ); const data = await response.data(); return { diff --git a/src/modules/wallet/travel-rule-api/withdrawHistoryV1.ts b/src/modules/wallet/travel-rule-api/withdrawHistoryV1.ts index fe55168a..9cdee180 100644 --- a/src/modules/wallet/travel-rule-api/withdrawHistoryV1.ts +++ b/src/modules/wallet/travel-rule-api/withdrawHistoryV1.ts @@ -31,7 +31,7 @@ export function registerBinanceWalletWithdrawHistoryV1(server: McpServer) { if (limit !== undefined) params.limit = limit; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.withdrawHistoryV1(params); + const response = await (walletClient as any).restAPI.withdrawHistoryV1(params); const data = await response.data(); return { diff --git a/src/modules/wallet/travel-rule-api/withdrawHistoryV2.ts b/src/modules/wallet/travel-rule-api/withdrawHistoryV2.ts index d61d6dc9..596e4d97 100644 --- a/src/modules/wallet/travel-rule-api/withdrawHistoryV2.ts +++ b/src/modules/wallet/travel-rule-api/withdrawHistoryV2.ts @@ -31,7 +31,7 @@ export function registerBinanceWalletWithdrawHistoryV2(server: McpServer) { if (limit !== undefined) params.limit = limit; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.withdrawHistoryV2(params); + const response = await (walletClient as any).restAPI.withdrawHistoryV2(params); const data = await response.data(); return { diff --git a/src/modules/wallet/travel-rule-api/withdrawTravelRule.ts b/src/modules/wallet/travel-rule-api/withdrawTravelRule.ts index 279066f1..e0c08765 100644 --- a/src/modules/wallet/travel-rule-api/withdrawTravelRule.ts +++ b/src/modules/wallet/travel-rule-api/withdrawTravelRule.ts @@ -46,7 +46,7 @@ export function registerBinanceWalletWithdrawTravelRule(server: McpServer) { if (name !== undefined) params.name = name; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.withdrawTravelRule(params); + const response = await (walletClient as any).restAPI.withdrawTravelRule(params); const data = await response.data(); return { diff --git a/src/tools/binance-auto-invest/changeIndexPlanStatus.ts b/src/tools/binance-auto-invest/changeIndexPlanStatus.ts index fc5ee01c..5ed93a81 100644 --- a/src/tools/binance-auto-invest/changeIndexPlanStatus.ts +++ b/src/tools/binance-auto-invest/changeIndexPlanStatus.ts @@ -24,7 +24,7 @@ export function registerBinanceAutoInvestChangeIndexPlanStatus(server: McpServer }, async (params) => { try { - const response = await autoInvestClient.restAPI.changeIndexPlanStatus({ + const response = await (autoInvestClient as any).restAPI.changePlanStatus({ indexId: params.indexId, status: params.status, ...(params.recvWindow && { recvWindow: params.recvWindow }), diff --git a/src/tools/binance-auto-invest/changePlanStatus.ts b/src/tools/binance-auto-invest/changePlanStatus.ts index c1df225b..59875493 100644 --- a/src/tools/binance-auto-invest/changePlanStatus.ts +++ b/src/tools/binance-auto-invest/changePlanStatus.ts @@ -19,7 +19,7 @@ export function registerBinanceAutoInvestChangePlanStatus(server: McpServer) { try { const params: any = { planId, status }; - const response = await autoInvestClient.restAPI.changePlanStatus(params); + const response = await (autoInvestClient as any).restAPI.changePlanStatus(params); const data = await response.data(); return { diff --git a/src/tools/binance-auto-invest/createPlan.ts b/src/tools/binance-auto-invest/createPlan.ts index b4aea6c2..b55afa5f 100644 --- a/src/tools/binance-auto-invest/createPlan.ts +++ b/src/tools/binance-auto-invest/createPlan.ts @@ -50,7 +50,7 @@ export function registerBinanceAutoInvestCreatePlan(server: McpServer) { }; if (flexibleAllowedToUse !== undefined) params.flexibleAllowedToUse = flexibleAllowedToUse; - const response = await autoInvestClient.restAPI.investmentPlanCreation(params); + const response = await (autoInvestClient as any).restAPI.investmentPlanCreation(params); const data = await response.data(); return { diff --git a/src/tools/binance-auto-invest/editPlan.ts b/src/tools/binance-auto-invest/editPlan.ts index 4d6911db..6b2af370 100644 --- a/src/tools/binance-auto-invest/editPlan.ts +++ b/src/tools/binance-auto-invest/editPlan.ts @@ -47,7 +47,7 @@ export function registerBinanceAutoInvestEditPlan(server: McpServer) { if (flexibleAllowedToUse !== undefined) params.flexibleAllowedToUse = flexibleAllowedToUse; if (details) params.details = details; - const response = await autoInvestClient.restAPI.investmentPlanAdjustment(params); + const response = await (autoInvestClient as any).restAPI.investmentPlanAdjustment(params); const data = await response.data(); return { diff --git a/src/tools/binance-auto-invest/getHistoryList.ts b/src/tools/binance-auto-invest/getHistoryList.ts index 27b7ad8e..b8e125b4 100644 --- a/src/tools/binance-auto-invest/getHistoryList.ts +++ b/src/tools/binance-auto-invest/getHistoryList.ts @@ -37,7 +37,7 @@ export function registerBinanceAutoInvestGetHistoryList(server: McpServer) { }, async (params) => { try { - const response = await autoInvestClient.restAPI.getHistoryList({ + const response = await (autoInvestClient as any).restAPI.getHistoryList({ ...(params.planId && { planId: params.planId }), ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), diff --git a/src/tools/binance-auto-invest/getIndexInfo.ts b/src/tools/binance-auto-invest/getIndexInfo.ts index 505d000a..997cb517 100644 --- a/src/tools/binance-auto-invest/getIndexInfo.ts +++ b/src/tools/binance-auto-invest/getIndexInfo.ts @@ -24,7 +24,7 @@ export function registerBinanceAutoInvestGetIndexInfo(server: McpServer) { }, async (params) => { try { - const response = await autoInvestClient.restAPI.getIndexInfo({ + const response = await (autoInvestClient as any).restAPI.getIndexInfo({ ...(params.indexId && { indexId: params.indexId }), ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/tools/binance-auto-invest/getIndexLinkedPlanPositionDetails.ts b/src/tools/binance-auto-invest/getIndexLinkedPlanPositionDetails.ts index b4d68360..ff91c1d6 100644 --- a/src/tools/binance-auto-invest/getIndexLinkedPlanPositionDetails.ts +++ b/src/tools/binance-auto-invest/getIndexLinkedPlanPositionDetails.ts @@ -23,7 +23,9 @@ export function registerBinanceAutoInvestGetIndexLinkedPlanPositionDetails(serve }, async (params) => { try { - const response = await autoInvestClient.restAPI.getIndexLinkedPlanPositionDetails({ + const response = await ( + autoInvestClient as any + ).restAPI.queryIndexLinkedPlanPositionDetails({ indexId: params.indexId, ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/tools/binance-auto-invest/getIndexLinkedPlanPositionList.ts b/src/tools/binance-auto-invest/getIndexLinkedPlanPositionList.ts index c4236ac0..b99a48a0 100644 --- a/src/tools/binance-auto-invest/getIndexLinkedPlanPositionList.ts +++ b/src/tools/binance-auto-invest/getIndexLinkedPlanPositionList.ts @@ -18,7 +18,9 @@ export function registerBinanceAutoInvestGetIndexLinkedPlanPositionList(server: try { const params: any = { indexId }; - const response = await autoInvestClient.restAPI.queryIndexLinkedPlanPositionDetails(params); + const response = await ( + autoInvestClient as any + ).restAPI.queryIndexLinkedPlanPositionDetails(params); const data = await response.data(); return { diff --git a/src/tools/binance-auto-invest/getIndexLinkedPlanRebalanceHistory.ts b/src/tools/binance-auto-invest/getIndexLinkedPlanRebalanceHistory.ts index 551c111a..46c94660 100644 --- a/src/tools/binance-auto-invest/getIndexLinkedPlanRebalanceHistory.ts +++ b/src/tools/binance-auto-invest/getIndexLinkedPlanRebalanceHistory.ts @@ -26,7 +26,9 @@ export function registerBinanceAutoInvestGetIndexLinkedPlanRebalanceHistory(serv if (current !== undefined) params.current = current; if (size !== undefined) params.size = size; - const response = await autoInvestClient.restAPI.indexLinkedPlanRebalanceDetails(params); + const response = await (autoInvestClient as any).restAPI.indexLinkedPlanRebalanceDetails( + params, + ); const data = await response.data(); return { diff --git a/src/tools/binance-auto-invest/getIndexUserSummary.ts b/src/tools/binance-auto-invest/getIndexUserSummary.ts index 97989f4b..85e6f9b4 100644 --- a/src/tools/binance-auto-invest/getIndexUserSummary.ts +++ b/src/tools/binance-auto-invest/getIndexUserSummary.ts @@ -24,7 +24,7 @@ export function registerBinanceAutoInvestGetIndexUserSummary(server: McpServer) }, async (params) => { try { - const response = await autoInvestClient.restAPI.getIndexUserSummary({ + const response = await (autoInvestClient as any).restAPI.getIndexUserSummary({ indexId: params.indexId, ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/tools/binance-auto-invest/getOneTimePlans.ts b/src/tools/binance-auto-invest/getOneTimePlans.ts index 52ddb5d2..03a227e2 100644 --- a/src/tools/binance-auto-invest/getOneTimePlans.ts +++ b/src/tools/binance-auto-invest/getOneTimePlans.ts @@ -20,7 +20,9 @@ export function registerBinanceAutoInvestGetOneTimePlans(server: McpServer) { const params: any = { planId }; if (requestId) params.requestId = requestId; - const response = await autoInvestClient.restAPI.queryOneTimeTransactionStatus(params); + const response = await (autoInvestClient as any).restAPI.queryOneTimeTransactionStatus( + params, + ); const data = await response.data(); return { diff --git a/src/tools/binance-auto-invest/getPlanList.ts b/src/tools/binance-auto-invest/getPlanList.ts index 1202892a..43ac0401 100644 --- a/src/tools/binance-auto-invest/getPlanList.ts +++ b/src/tools/binance-auto-invest/getPlanList.ts @@ -19,7 +19,7 @@ export function registerBinanceAutoInvestGetPlanList(server: McpServer) { const params: any = {}; if (planType) params.planType = planType; - const response = await autoInvestClient.restAPI.getListOfPlans(params); + const response = await (autoInvestClient as any).restAPI.getListOfPlans(params); const data = await response.data(); return { diff --git a/src/tools/binance-auto-invest/getSourceAssetList.ts b/src/tools/binance-auto-invest/getSourceAssetList.ts index b9d3ef85..30a2a9c9 100644 --- a/src/tools/binance-auto-invest/getSourceAssetList.ts +++ b/src/tools/binance-auto-invest/getSourceAssetList.ts @@ -28,7 +28,7 @@ export function registerBinanceAutoInvestGetSourceAssetList(server: McpServer) { if (indexId !== undefined) params.indexId = indexId; if (flexibleAllowedToUse !== undefined) params.flexibleAllowedToUse = flexibleAllowedToUse; - const response = await autoInvestClient.restAPI.querySourceAssetList(params); + const response = await (autoInvestClient as any).restAPI.querySourceAssetList(params); const data = await response.data(); return { diff --git a/src/tools/binance-auto-invest/getSubscriptionHistory.ts b/src/tools/binance-auto-invest/getSubscriptionHistory.ts index 9a4f2455..6540e606 100644 --- a/src/tools/binance-auto-invest/getSubscriptionHistory.ts +++ b/src/tools/binance-auto-invest/getSubscriptionHistory.ts @@ -31,7 +31,9 @@ export function registerBinanceAutoInvestGetSubscriptionHistory(server: McpServe if (current !== undefined) params.current = current; if (size !== undefined) params.size = size; - const response = await autoInvestClient.restAPI.querySubscriptionTransactionHistory(params); + const response = await ( + autoInvestClient as any + ).restAPI.querySubscriptionTransactionHistory(params); const data = await response.data(); return { diff --git a/src/tools/binance-auto-invest/getTargetAssetList.ts b/src/tools/binance-auto-invest/getTargetAssetList.ts index 7ce93b5e..bae9314c 100644 --- a/src/tools/binance-auto-invest/getTargetAssetList.ts +++ b/src/tools/binance-auto-invest/getTargetAssetList.ts @@ -23,7 +23,7 @@ export function registerBinanceAutoInvestGetTargetAssetList(server: McpServer) { if (size !== undefined) params.size = size; if (current !== undefined) params.current = current; - const response = await autoInvestClient.restAPI.getTargetAssetList(params); + const response = await (autoInvestClient as any).restAPI.getTargetAssetList(params); const data = await response.data(); return { diff --git a/src/tools/binance-auto-invest/getTargetAssetROI.ts b/src/tools/binance-auto-invest/getTargetAssetROI.ts index 99884d0c..3c2bba5f 100644 --- a/src/tools/binance-auto-invest/getTargetAssetROI.ts +++ b/src/tools/binance-auto-invest/getTargetAssetROI.ts @@ -21,7 +21,7 @@ export function registerBinanceAutoInvestGetTargetAssetROI(server: McpServer) { try { const params: any = { targetAsset, hisRoiType }; - const response = await autoInvestClient.restAPI.getTargetAssetRoiData(params); + const response = await (autoInvestClient as any).restAPI.getTargetAssetRoiData(params); const data = await response.data(); return { diff --git a/src/tools/binance-auto-invest/getTargetAssetRoiData.ts b/src/tools/binance-auto-invest/getTargetAssetRoiData.ts index 200ef1c4..db4fa7b4 100644 --- a/src/tools/binance-auto-invest/getTargetAssetRoiData.ts +++ b/src/tools/binance-auto-invest/getTargetAssetRoiData.ts @@ -27,7 +27,7 @@ export function registerBinanceAutoInvestGetTargetAssetRoiData(server: McpServer }, async (params) => { try { - const response = await autoInvestClient.restAPI.getTargetAssetRoiData({ + const response = await (autoInvestClient as any).restAPI.getTargetAssetRoiData({ targetAsset: params.targetAsset, hisRoiType: params.hisRoiType, ...(params.recvWindow && { recvWindow: params.recvWindow }), diff --git a/src/tools/binance-auto-invest/oneTimeTransaction.ts b/src/tools/binance-auto-invest/oneTimeTransaction.ts index 42f71d04..6c97f15a 100644 --- a/src/tools/binance-auto-invest/oneTimeTransaction.ts +++ b/src/tools/binance-auto-invest/oneTimeTransaction.ts @@ -41,7 +41,7 @@ export function registerBinanceAutoInvestOneTimeTransaction(server: McpServer) { }, async (params) => { try { - const response = await autoInvestClient.restAPI.oneTimeTransaction({ + const response = await (autoInvestClient as any).restAPI.oneTimeTransaction({ sourceType: params.sourceType, subscriptionAmount: params.subscriptionAmount, sourceAsset: params.sourceAsset, diff --git a/src/tools/binance-auto-invest/rebalanceHistory.ts b/src/tools/binance-auto-invest/rebalanceHistory.ts index 855de9d6..4821e41b 100644 --- a/src/tools/binance-auto-invest/rebalanceHistory.ts +++ b/src/tools/binance-auto-invest/rebalanceHistory.ts @@ -32,7 +32,7 @@ export function registerBinanceAutoInvestRebalanceHistory(server: McpServer) { }, async (params) => { try { - const response = await autoInvestClient.restAPI.getRebalanceHistory({ + const response = await (autoInvestClient as any).restAPI.getRebalanceHistory({ ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.size && { size: params.size }), diff --git a/src/tools/binance-auto-invest/redeemIndexLinkedPlan.ts b/src/tools/binance-auto-invest/redeemIndexLinkedPlan.ts index 8d902a95..cf5648c3 100644 --- a/src/tools/binance-auto-invest/redeemIndexLinkedPlan.ts +++ b/src/tools/binance-auto-invest/redeemIndexLinkedPlan.ts @@ -21,7 +21,7 @@ export function registerBinanceAutoInvestRedeemIndexLinkedPlan(server: McpServer const params: any = { indexId, redemptionPercentage }; if (requestId) params.requestId = requestId; - const response = await autoInvestClient.restAPI.indexLinkedPlanRedemption(params); + const response = await (autoInvestClient as any).restAPI.indexLinkedPlanRedemption(params); const data = await response.data(); return { diff --git a/src/tools/binance-auto-invest/redemption.ts b/src/tools/binance-auto-invest/redemption.ts index 85311547..5a7bba23 100644 --- a/src/tools/binance-auto-invest/redemption.ts +++ b/src/tools/binance-auto-invest/redemption.ts @@ -28,7 +28,7 @@ export function registerBinanceAutoInvestRedemption(server: McpServer) { }, async (params) => { try { - const response = await autoInvestClient.restAPI.redemption({ + const response = await (autoInvestClient as any).restAPI.redemption({ indexId: params.indexId, redemptionPercentage: params.redemptionPercentage, ...(params.recvWindow && { recvWindow: params.recvWindow }), diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/followTrader.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/followTrader.ts index 256a3621..a6fae0f4 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/followTrader.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/followTrader.ts @@ -36,7 +36,7 @@ export function registerBinanceCopyTradingFollow(server: McpServer) { }, async (params) => { try { - const response = await copyTradingClient.restAPI.followLeadTrader({ + const response = await (copyTradingClient as any).restAPI.followLeadTrader({ portfolioId: params.portfolioId, ...(params.copyRatio && { copyRatio: params.copyRatio }), ...(params.stopLossRatio && { stopLossRatio: params.stopLossRatio }), diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyOrders.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyOrders.ts index 4c1a31d6..6f769b0a 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyOrders.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyOrders.ts @@ -23,7 +23,7 @@ export function registerBinanceCopyTradingGetOrders(server: McpServer) { }, async (params) => { try { - const response = await copyTradingClient.restAPI.getCopyTradingOrders({ + const response = await (copyTradingClient as any).restAPI.getCopyTradingOrders({ ...(params.portfolioId && { portfolioId: params.portfolioId }), ...(params.symbol && { symbol: params.symbol }), ...(params.startTime && { startTime: params.startTime }), diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyPositions.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyPositions.ts index 2150940d..33f9deda 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyPositions.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/getCopyPositions.ts @@ -19,7 +19,7 @@ export function registerBinanceCopyTradingGetPositions(server: McpServer) { }, async (params) => { try { - const response = await copyTradingClient.restAPI.getCopyTradingPositions({ + const response = await (copyTradingClient as any).restAPI.getCopyTradingPositions({ ...(params.portfolioId && { portfolioId: params.portfolioId }), ...(params.symbol && { symbol: params.symbol }), ...(params.recvWindow && { recvWindow: params.recvWindow }), diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/getFollowingTraders.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/getFollowingTraders.ts index e1fe7c16..8697a59d 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/getFollowingTraders.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/getFollowingTraders.ts @@ -16,7 +16,7 @@ export function registerBinanceCopyTradingGetFollowing(server: McpServer) { }, async (params) => { try { - const response = await copyTradingClient.restAPI.getFollowingTraders({ + const response = await (copyTradingClient as any).restAPI.getFollowingTraders({ ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts index 1241044c..5c58fabe 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTraderStatus.ts @@ -21,7 +21,7 @@ export function registerBinanceGetFuturesLeadTraderStatus(server: McpServer) { }, async (params) => { try { - const response = await copyTradingClient.restAPI.getFuturesLeadTraderStatus({ + const response = await (copyTradingClient as any).restAPI.getFuturesLeadTraderStatus({ ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts index b86d8cc0..9c9be5f6 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/getFuturesLeadTradingSymbolWhitelist.ts @@ -21,7 +21,9 @@ export function registerBinanceGetFuturesLeadTradingSymbolWhitelist(server: McpS }, async (params) => { try { - const response = await copyTradingClient.restAPI.getFuturesLeadTradingSymbolWhitelist({ + const response = await ( + copyTradingClient as any + ).restAPI.getFuturesLeadTradingSymbolWhitelist({ ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/getLeadTraders.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/getLeadTraders.ts index b5a38373..d2f9b498 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/getLeadTraders.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/getLeadTraders.ts @@ -31,7 +31,7 @@ export function registerBinanceCopyTradingGetLeaders(server: McpServer) { }, async (params) => { try { - const response = await copyTradingClient.restAPI.getLeadTraders({ + const response = await (copyTradingClient as any).restAPI.getLeadTraders({ ...(params.pageNumber && { pageNumber: params.pageNumber }), ...(params.pageSize && { pageSize: params.pageSize }), ...(params.recvWindow && { recvWindow: params.recvWindow }), diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/getTraderPerformance.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/getTraderPerformance.ts index 3de63338..3f5c18f3 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/getTraderPerformance.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/getTraderPerformance.ts @@ -18,7 +18,7 @@ export function registerBinanceCopyTradingGetPerformance(server: McpServer) { }, async (params) => { try { - const response = await copyTradingClient.restAPI.getLeadTraderPerformance({ + const response = await (copyTradingClient as any).restAPI.getLeadTraderPerformance({ portfolioId: params.portfolioId, ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/tools/binance-copy-trading/FutureCopyTrading-api/unfollowTrader.ts b/src/tools/binance-copy-trading/FutureCopyTrading-api/unfollowTrader.ts index 6769e956..2aa1e164 100644 --- a/src/tools/binance-copy-trading/FutureCopyTrading-api/unfollowTrader.ts +++ b/src/tools/binance-copy-trading/FutureCopyTrading-api/unfollowTrader.ts @@ -18,7 +18,7 @@ export function registerBinanceCopyTradingUnfollow(server: McpServer) { }, async (params) => { try { - const response = await copyTradingClient.restAPI.unfollowLeadTrader({ + const response = await (copyTradingClient as any).restAPI.unfollowLeadTrader({ portfolioId: params.portfolioId, ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/tools/binance-crypto-loans/fixed-api/adjustLTV.ts b/src/tools/binance-crypto-loans/fixed-api/adjustLTV.ts index 27707343..e9ed28fd 100644 --- a/src/tools/binance-crypto-loans/fixed-api/adjustLTV.ts +++ b/src/tools/binance-crypto-loans/fixed-api/adjustLTV.ts @@ -27,7 +27,7 @@ export function registerBinanceCryptoLoansFixedAdjustLTV(server: McpServer) { }, async (params) => { try { - const response = await cryptoLoanClient.restAPI.cryptoLoanAdjustLtv({ + const response = await (cryptoLoanClient as any).restAPI.cryptoLoanAdjustLtv({ orderId: params.orderId, amount: params.amount, direction: params.direction, diff --git a/src/tools/binance-crypto-loans/fixed-api/borrow.ts b/src/tools/binance-crypto-loans/fixed-api/borrow.ts index 0acef4ef..aa16b9a0 100644 --- a/src/tools/binance-crypto-loans/fixed-api/borrow.ts +++ b/src/tools/binance-crypto-loans/fixed-api/borrow.ts @@ -43,7 +43,7 @@ export function registerBinanceCryptoLoansFixedBorrow(server: McpServer) { }; } - const response = await cryptoLoanClient.restAPI.cryptoLoanBorrow({ + const response = await (cryptoLoanClient as any).restAPI.cryptoLoanBorrow({ loanCoin: params.loanCoin, collateralCoin: params.collateralCoin, loanTerm: params.loanTerm, diff --git a/src/tools/binance-crypto-loans/fixed-api/checkCollateralRate.ts b/src/tools/binance-crypto-loans/fixed-api/checkCollateralRate.ts index b173f23b..4969bbff 100644 --- a/src/tools/binance-crypto-loans/fixed-api/checkCollateralRate.ts +++ b/src/tools/binance-crypto-loans/fixed-api/checkCollateralRate.ts @@ -26,7 +26,7 @@ export function registerBinanceCryptoLoansFixedCollateralRate(server: McpServer) }, async (params) => { try { - const response = await cryptoLoanClient.restAPI.checkCollateralRepayRate({ + const response = await (cryptoLoanClient as any).restAPI.checkCollateralRepayRate({ loanCoin: params.loanCoin, collateralCoin: params.collateralCoin, repayAmount: params.repayAmount, diff --git a/src/tools/binance-crypto-loans/fixed-api/customizeMarginCall.ts b/src/tools/binance-crypto-loans/fixed-api/customizeMarginCall.ts index 56d5d7fc..57fb64c4 100644 --- a/src/tools/binance-crypto-loans/fixed-api/customizeMarginCall.ts +++ b/src/tools/binance-crypto-loans/fixed-api/customizeMarginCall.ts @@ -25,7 +25,7 @@ export function registerBinanceCryptoLoansFixedMarginCall(server: McpServer) { }, async (params) => { try { - const response = await cryptoLoanClient.restAPI.customizeMarginCall({ + const response = await (cryptoLoanClient as any).restAPI.customizeMarginCall({ orderId: params.orderId, marginCall: params.marginCall, ...(params.recvWindow && { recvWindow: params.recvWindow }), diff --git a/src/tools/binance-crypto-loans/fixed-api/getBorrowHistory.ts b/src/tools/binance-crypto-loans/fixed-api/getBorrowHistory.ts index 420466e3..fa7eb4fe 100644 --- a/src/tools/binance-crypto-loans/fixed-api/getBorrowHistory.ts +++ b/src/tools/binance-crypto-loans/fixed-api/getBorrowHistory.ts @@ -29,7 +29,7 @@ export function registerBinanceCryptoLoansFixedBorrowHistory(server: McpServer) }, async (params) => { try { - const response = await cryptoLoanClient.restAPI.getLoanBorrowHistory({ + const response = await (cryptoLoanClient as any).restAPI.getLoanBorrowHistory({ ...(params.orderId && { orderId: params.orderId }), ...(params.loanCoin && { loanCoin: params.loanCoin }), ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), diff --git a/src/tools/binance-crypto-loans/fixed-api/getFixedCollateralData.ts b/src/tools/binance-crypto-loans/fixed-api/getFixedCollateralData.ts index 9adc596f..1a7b973b 100644 --- a/src/tools/binance-crypto-loans/fixed-api/getFixedCollateralData.ts +++ b/src/tools/binance-crypto-loans/fixed-api/getFixedCollateralData.ts @@ -25,7 +25,7 @@ export function registerBinanceCryptoLoansFixedCollateral(server: McpServer) { }, async (params) => { try { - const response = await cryptoLoanClient.restAPI.getCollateralAssetsData({ + const response = await (cryptoLoanClient as any).restAPI.getCollateralAssetsData({ ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), ...(params.vipLevel !== undefined && { vipLevel: params.vipLevel }), ...(params.recvWindow && { recvWindow: params.recvWindow }), diff --git a/src/tools/binance-crypto-loans/fixed-api/getFixedLoanData.ts b/src/tools/binance-crypto-loans/fixed-api/getFixedLoanData.ts index b85cb474..646ba23c 100644 --- a/src/tools/binance-crypto-loans/fixed-api/getFixedLoanData.ts +++ b/src/tools/binance-crypto-loans/fixed-api/getFixedLoanData.ts @@ -31,7 +31,7 @@ export function registerBinanceCryptoLoansFixedAssets(server: McpServer) { }, async (params) => { try { - const response = await cryptoLoanClient.restAPI.getLoanableAssetsData({ + const response = await (cryptoLoanClient as any).restAPI.getLoanableAssetsData({ ...(params.loanCoin && { loanCoin: params.loanCoin }), ...(params.vipLevel !== undefined && { vipLevel: params.vipLevel }), ...(params.recvWindow && { recvWindow: params.recvWindow }), diff --git a/src/tools/binance-crypto-loans/fixed-api/getOngoingOrders.ts b/src/tools/binance-crypto-loans/fixed-api/getOngoingOrders.ts index 5c73da43..df654fe2 100644 --- a/src/tools/binance-crypto-loans/fixed-api/getOngoingOrders.ts +++ b/src/tools/binance-crypto-loans/fixed-api/getOngoingOrders.ts @@ -28,7 +28,7 @@ export function registerBinanceCryptoLoansFixedOngoing(server: McpServer) { }, async (params) => { try { - const response = await cryptoLoanClient.restAPI.getLoanOngoingOrders({ + const response = await (cryptoLoanClient as any).restAPI.getLoanOngoingOrders({ ...(params.orderId && { orderId: params.orderId }), ...(params.loanCoin && { loanCoin: params.loanCoin }), ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), diff --git a/src/tools/binance-crypto-loans/fixed-api/getRepayHistory.ts b/src/tools/binance-crypto-loans/fixed-api/getRepayHistory.ts index 36d3745e..dd6bc5d1 100644 --- a/src/tools/binance-crypto-loans/fixed-api/getRepayHistory.ts +++ b/src/tools/binance-crypto-loans/fixed-api/getRepayHistory.ts @@ -29,7 +29,7 @@ export function registerBinanceCryptoLoansFixedRepayHistory(server: McpServer) { }, async (params) => { try { - const response = await cryptoLoanClient.restAPI.getLoanRepaymentHistory({ + const response = await (cryptoLoanClient as any).restAPI.getLoanRepaymentHistory({ ...(params.orderId && { orderId: params.orderId }), ...(params.loanCoin && { loanCoin: params.loanCoin }), ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), diff --git a/src/tools/binance-crypto-loans/fixed-api/repay.ts b/src/tools/binance-crypto-loans/fixed-api/repay.ts index bccd0cac..23bf1003 100644 --- a/src/tools/binance-crypto-loans/fixed-api/repay.ts +++ b/src/tools/binance-crypto-loans/fixed-api/repay.ts @@ -32,7 +32,7 @@ export function registerBinanceCryptoLoansFixedRepay(server: McpServer) { }, async (params) => { try { - const response = await cryptoLoanClient.restAPI.cryptoLoanRepay({ + const response = await (cryptoLoanClient as any).restAPI.cryptoLoanRepay({ orderId: params.orderId, amount: params.amount, ...(params.type && { type: params.type }), diff --git a/src/tools/binance-crypto-loans/flexible-api/adjustLTV.ts b/src/tools/binance-crypto-loans/flexible-api/adjustLTV.ts index 193cd80c..c638864a 100644 --- a/src/tools/binance-crypto-loans/flexible-api/adjustLTV.ts +++ b/src/tools/binance-crypto-loans/flexible-api/adjustLTV.ts @@ -31,7 +31,7 @@ export function registerBinanceCryptoLoansFlexibleAdjustLTV(server: McpServer) { }, async (params) => { try { - const response = await cryptoLoanClient.restAPI.flexibleLoanAdjustLtv({ + const response = await (cryptoLoanClient as any).restAPI.flexibleLoanAdjustLtv({ loanCoin: params.loanCoin, collateralCoin: params.collateralCoin, adjustmentAmount: params.adjustmentAmount, diff --git a/src/tools/binance-crypto-loans/flexible-api/borrow.ts b/src/tools/binance-crypto-loans/flexible-api/borrow.ts index 8e4179e6..6ec6f609 100644 --- a/src/tools/binance-crypto-loans/flexible-api/borrow.ts +++ b/src/tools/binance-crypto-loans/flexible-api/borrow.ts @@ -43,7 +43,7 @@ export function registerBinanceCryptoLoansFlexibleBorrow(server: McpServer) { }; } - const response = await cryptoLoanClient.restAPI.flexibleLoanBorrow({ + const response = await (cryptoLoanClient as any).restAPI.flexibleLoanBorrow({ loanCoin: params.loanCoin, collateralCoin: params.collateralCoin, ...(params.loanAmount && { loanAmount: params.loanAmount }), diff --git a/src/tools/binance-crypto-loans/flexible-api/getBorrowHistory.ts b/src/tools/binance-crypto-loans/flexible-api/getBorrowHistory.ts index b83dcf6b..28f507b8 100644 --- a/src/tools/binance-crypto-loans/flexible-api/getBorrowHistory.ts +++ b/src/tools/binance-crypto-loans/flexible-api/getBorrowHistory.ts @@ -29,7 +29,7 @@ export function registerBinanceCryptoLoansFlexibleBorrowHistory(server: McpServe }, async (params) => { try { - const response = await cryptoLoanClient.restAPI.getFlexibleLoanBorrowHistory({ + const response = await (cryptoLoanClient as any).restAPI.getFlexibleLoanBorrowHistory({ ...(params.loanCoin && { loanCoin: params.loanCoin }), ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), ...(params.startTime && { startTime: params.startTime }), diff --git a/src/tools/binance-crypto-loans/flexible-api/getFlexibleCollateralAssets.ts b/src/tools/binance-crypto-loans/flexible-api/getFlexibleCollateralAssets.ts index 5a8c3dfd..3ec506d7 100644 --- a/src/tools/binance-crypto-loans/flexible-api/getFlexibleCollateralAssets.ts +++ b/src/tools/binance-crypto-loans/flexible-api/getFlexibleCollateralAssets.ts @@ -27,7 +27,9 @@ export function registerBinanceCryptoLoansFlexibleCollateral(server: McpServer) }, async (params) => { try { - const response = await cryptoLoanClient.restAPI.getFlexibleLoanCollateralAssetsData({ + const response = await ( + cryptoLoanClient as any + ).restAPI.getFlexibleLoanCollateralAssetsData({ ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/tools/binance-crypto-loans/flexible-api/getFlexibleLoanAssets.ts b/src/tools/binance-crypto-loans/flexible-api/getFlexibleLoanAssets.ts index dc697410..8f162c75 100644 --- a/src/tools/binance-crypto-loans/flexible-api/getFlexibleLoanAssets.ts +++ b/src/tools/binance-crypto-loans/flexible-api/getFlexibleLoanAssets.ts @@ -27,7 +27,7 @@ export function registerBinanceCryptoLoansFlexibleAssets(server: McpServer) { }, async (params) => { try { - const response = await cryptoLoanClient.restAPI.getFlexibleLoanAssetsData({ + const response = await (cryptoLoanClient as any).restAPI.getFlexibleLoanAssetsData({ ...(params.loanCoin && { loanCoin: params.loanCoin }), ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/tools/binance-crypto-loans/flexible-api/getOngoingOrders.ts b/src/tools/binance-crypto-loans/flexible-api/getOngoingOrders.ts index 8a4f3122..7345fe48 100644 --- a/src/tools/binance-crypto-loans/flexible-api/getOngoingOrders.ts +++ b/src/tools/binance-crypto-loans/flexible-api/getOngoingOrders.ts @@ -27,7 +27,7 @@ export function registerBinanceCryptoLoansFlexibleOngoing(server: McpServer) { }, async (params) => { try { - const response = await cryptoLoanClient.restAPI.getFlexibleLoanOngoingOrders({ + const response = await (cryptoLoanClient as any).restAPI.getFlexibleLoanOngoingOrders({ ...(params.loanCoin && { loanCoin: params.loanCoin }), ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), ...(params.current && { current: params.current }), diff --git a/src/tools/binance-crypto-loans/flexible-api/getRepayHistory.ts b/src/tools/binance-crypto-loans/flexible-api/getRepayHistory.ts index a8b888d2..bc04ee3d 100644 --- a/src/tools/binance-crypto-loans/flexible-api/getRepayHistory.ts +++ b/src/tools/binance-crypto-loans/flexible-api/getRepayHistory.ts @@ -29,7 +29,7 @@ export function registerBinanceCryptoLoansFlexibleRepayHistory(server: McpServer }, async (params) => { try { - const response = await cryptoLoanClient.restAPI.getFlexibleLoanRepaymentHistory({ + const response = await (cryptoLoanClient as any).restAPI.getFlexibleLoanRepaymentHistory({ ...(params.loanCoin && { loanCoin: params.loanCoin }), ...(params.collateralCoin && { collateralCoin: params.collateralCoin }), ...(params.startTime && { startTime: params.startTime }), diff --git a/src/tools/binance-crypto-loans/flexible-api/repay.ts b/src/tools/binance-crypto-loans/flexible-api/repay.ts index bb51e60a..b152f98b 100644 --- a/src/tools/binance-crypto-loans/flexible-api/repay.ts +++ b/src/tools/binance-crypto-loans/flexible-api/repay.ts @@ -31,7 +31,7 @@ export function registerBinanceCryptoLoansFlexibleRepay(server: McpServer) { }, async (params) => { try { - const response = await cryptoLoanClient.restAPI.flexibleLoanRepay({ + const response = await (cryptoLoanClient as any).restAPI.flexibleLoanRepay({ loanCoin: params.loanCoin, collateralCoin: params.collateralCoin, repayAmount: params.repayAmount, diff --git a/src/tools/binance-crypto-loans/flexibleLoanAdjustLTV.ts b/src/tools/binance-crypto-loans/flexibleLoanAdjustLTV.ts index 7d092b06..ceddfaf1 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanAdjustLTV.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanAdjustLTV.ts @@ -23,7 +23,7 @@ export function registerBinanceCryptoLoanFlexibleLoanAdjustLTV(server: McpServer try { const params: any = { loanCoin, collateralCoin, adjustmentAmount, direction }; - const response = await cryptoLoanClient.restAPI.flexibleLoanAdjustLtv(params); + const response = await (cryptoLoanClient as any).restAPI.flexibleLoanAdjustLtv(params); const data = await response.data(); return { diff --git a/src/tools/binance-crypto-loans/flexibleLoanBorrow.ts b/src/tools/binance-crypto-loans/flexibleLoanBorrow.ts index f798c1b0..32d06543 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanBorrow.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanBorrow.ts @@ -23,7 +23,7 @@ export function registerBinanceCryptoLoanFlexibleLoanBorrow(server: McpServer) { if (loanAmount !== undefined) params.loanAmount = loanAmount; if (collateralAmount !== undefined) params.collateralAmount = collateralAmount; - const response = await cryptoLoanClient.restAPI.flexibleLoanBorrow(params); + const response = await (cryptoLoanClient as any).restAPI.flexibleLoanBorrow(params); const data = await response.data(); return { diff --git a/src/tools/binance-crypto-loans/flexibleLoanBorrowHistory.ts b/src/tools/binance-crypto-loans/flexibleLoanBorrowHistory.ts index 4c5d5a38..ac7d04b3 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanBorrowHistory.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanBorrowHistory.ts @@ -29,7 +29,7 @@ export function registerBinanceCryptoLoanFlexibleLoanBorrowHistory(server: McpSe if (current !== undefined) params.current = current; if (limit !== undefined) params.limit = limit; - const response = await cryptoLoanClient.restAPI.flexibleLoanBorrowHistory(params); + const response = await (cryptoLoanClient as any).restAPI.flexibleLoanBorrowHistory(params); const data = await response.data(); return { diff --git a/src/tools/binance-crypto-loans/flexibleLoanCollateralAssets.ts b/src/tools/binance-crypto-loans/flexibleLoanCollateralAssets.ts index 654e9bab..273c4c5f 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanCollateralAssets.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanCollateralAssets.ts @@ -19,7 +19,9 @@ export function registerBinanceCryptoLoanFlexibleLoanCollateralAssets(server: Mc const params: any = {}; if (collateralCoin) params.collateralCoin = collateralCoin; - const response = await cryptoLoanClient.restAPI.getFlexibleLoanCollateralAssetsData(params); + const response = await ( + cryptoLoanClient as any + ).restAPI.getFlexibleLoanCollateralAssetsData(params); const data = await response.data(); return { diff --git a/src/tools/binance-crypto-loans/flexibleLoanLTVAdjustmentHistory.ts b/src/tools/binance-crypto-loans/flexibleLoanLTVAdjustmentHistory.ts index 8064ea68..76319d6a 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanLTVAdjustmentHistory.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanLTVAdjustmentHistory.ts @@ -29,7 +29,9 @@ export function registerBinanceCryptoLoanFlexibleLoanLTVAdjustmentHistory(server if (current !== undefined) params.current = current; if (limit !== undefined) params.limit = limit; - const response = await cryptoLoanClient.restAPI.getFlexibleLoanLtvAdjustmentHistory(params); + const response = await ( + cryptoLoanClient as any + ).restAPI.getFlexibleLoanLtvAdjustmentHistory(params); const data = await response.data(); return { diff --git a/src/tools/binance-crypto-loans/flexibleLoanLoanableAssets.ts b/src/tools/binance-crypto-loans/flexibleLoanLoanableAssets.ts index 9e24f0bf..77694287 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanLoanableAssets.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanLoanableAssets.ts @@ -17,7 +17,7 @@ export function registerBinanceCryptoLoanFlexibleLoanableAssets(server: McpServe }, async (params) => { try { - const response = await cryptoLoanClient.restAPI.getFlexibleLoanAssets({ + const response = await (cryptoLoanClient as any).restAPI.getFlexibleLoanAssets({ ...(params.loanCoin && { loanCoin: params.loanCoin }), ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/tools/binance-crypto-loans/flexibleLoanOngoingOrders.ts b/src/tools/binance-crypto-loans/flexibleLoanOngoingOrders.ts index 04ae6576..12e471f8 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanOngoingOrders.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanOngoingOrders.ts @@ -25,7 +25,7 @@ export function registerBinanceCryptoLoanFlexibleLoanOngoingOrders(server: McpSe if (current !== undefined) params.current = current; if (limit !== undefined) params.limit = limit; - const response = await cryptoLoanClient.restAPI.flexibleLoanOngoingOrders(params); + const response = await (cryptoLoanClient as any).restAPI.flexibleLoanOngoingOrders(params); const data = await response.data(); return { diff --git a/src/tools/binance-crypto-loans/flexibleLoanRepay.ts b/src/tools/binance-crypto-loans/flexibleLoanRepay.ts index 2f46d92c..5554e9f5 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanRepay.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanRepay.ts @@ -24,7 +24,7 @@ export function registerBinanceCryptoLoanFlexibleLoanRepay(server: McpServer) { if (collateralReturn !== undefined) params.collateralReturn = collateralReturn; if (fullRepayment !== undefined) params.fullRepayment = fullRepayment; - const response = await cryptoLoanClient.restAPI.flexibleLoanRepay(params); + const response = await (cryptoLoanClient as any).restAPI.flexibleLoanRepay(params); const data = await response.data(); return { diff --git a/src/tools/binance-crypto-loans/flexibleLoanRepayHistory.ts b/src/tools/binance-crypto-loans/flexibleLoanRepayHistory.ts index 5f3a209f..ad7f48c2 100644 --- a/src/tools/binance-crypto-loans/flexibleLoanRepayHistory.ts +++ b/src/tools/binance-crypto-loans/flexibleLoanRepayHistory.ts @@ -29,7 +29,9 @@ export function registerBinanceCryptoLoanFlexibleLoanRepayHistory(server: McpSer if (current !== undefined) params.current = current; if (limit !== undefined) params.limit = limit; - const response = await cryptoLoanClient.restAPI.flexibleLoanRepaymentHistory(params); + const response = await (cryptoLoanClient as any).restAPI.flexibleLoanRepaymentHistory( + params, + ); const data = await response.data(); return { diff --git a/src/tools/binance-crypto-loans/getCollateralAssetsData.ts b/src/tools/binance-crypto-loans/getCollateralAssetsData.ts index 78051e62..d0d9d7e7 100644 --- a/src/tools/binance-crypto-loans/getCollateralAssetsData.ts +++ b/src/tools/binance-crypto-loans/getCollateralAssetsData.ts @@ -21,7 +21,9 @@ export function registerBinanceCryptoLoanGetCollateralAssetsDataV2(server: McpSe if (collateralCoin) params.collateralCoin = collateralCoin; if (vipLevel !== undefined) params.vipLevel = vipLevel; - const response = await cryptoLoanClient.restAPI.getFlexibleLoanCollateralAssetsData(params); + const response = await ( + cryptoLoanClient as any + ).restAPI.getFlexibleLoanCollateralAssetsData(params); const data = await response.data(); return { diff --git a/src/tools/binance-crypto-loans/getCollateralRepayRate.ts b/src/tools/binance-crypto-loans/getCollateralRepayRate.ts index 57c52810..5579376c 100644 --- a/src/tools/binance-crypto-loans/getCollateralRepayRate.ts +++ b/src/tools/binance-crypto-loans/getCollateralRepayRate.ts @@ -20,7 +20,7 @@ export function registerBinanceCryptoLoanGetCollateralRepayRate(server: McpServe try { const params: any = { loanCoin, collateralCoin, repayAmount }; - const response = await cryptoLoanClient.restAPI.checkCollateralRepayRate(params); + const response = await (cryptoLoanClient as any).restAPI.checkCollateralRepayRate(params); const data = await response.data(); return { diff --git a/src/tools/binance-crypto-loans/getLoanableAssetsData.ts b/src/tools/binance-crypto-loans/getLoanableAssetsData.ts index f8bbb8fd..261d8872 100644 --- a/src/tools/binance-crypto-loans/getLoanableAssetsData.ts +++ b/src/tools/binance-crypto-loans/getLoanableAssetsData.ts @@ -21,7 +21,7 @@ export function registerBinanceCryptoLoanGetLoanableAssetsDataV2(server: McpServ if (loanCoin) params.loanCoin = loanCoin; if (vipLevel !== undefined) params.vipLevel = vipLevel; - const response = await cryptoLoanClient.restAPI.getFlexibleLoanAssetsData(params); + const response = await (cryptoLoanClient as any).restAPI.getFlexibleLoanAssetsData(params); const data = await response.data(); return { diff --git a/src/tools/binance-futures-coinm/account.ts b/src/tools/binance-futures-coinm/account.ts index 06cb9e21..aad98f27 100644 --- a/src/tools/binance-futures-coinm/account.ts +++ b/src/tools/binance-futures-coinm/account.ts @@ -16,7 +16,7 @@ export function registerBinanceFuturesCOINMAccount(server: McpServer) { }, async (params) => { try { - const data = await deliveryClient.getAccount({ + const data = await deliveryClient.account({ ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/tools/binance-futures-coinm/balance.ts b/src/tools/binance-futures-coinm/balance.ts index 3bba3204..7e9f12a4 100644 --- a/src/tools/binance-futures-coinm/balance.ts +++ b/src/tools/binance-futures-coinm/balance.ts @@ -16,7 +16,7 @@ export function registerBinanceFuturesCOINMBalance(server: McpServer) { }, async (params) => { try { - const data = await deliveryClient.getBalance({ + const data = await deliveryClient.balance({ ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/tools/binance-futures-coinm/bookTicker.ts b/src/tools/binance-futures-coinm/bookTicker.ts index c37b4847..d4eebbd3 100644 --- a/src/tools/binance-futures-coinm/bookTicker.ts +++ b/src/tools/binance-futures-coinm/bookTicker.ts @@ -27,7 +27,7 @@ export function registerBinanceFuturesCOINMBookTicker(server: McpServer) { if (symbol) params.symbol = symbol; if (pair) params.pair = pair; - const data = await deliveryClient.tickerBookTicker(params); + const data = await deliveryClient.bookTicker(params); return { content: [ diff --git a/src/tools/binance-futures-coinm/leverage.ts b/src/tools/binance-futures-coinm/leverage.ts index a008c58a..e03928c7 100644 --- a/src/tools/binance-futures-coinm/leverage.ts +++ b/src/tools/binance-futures-coinm/leverage.ts @@ -18,7 +18,7 @@ export function registerBinanceFuturesCOINMLeverage(server: McpServer) { }, async (params) => { try { - const data = await deliveryClient.changeInitialLeverage({ + const data = await deliveryClient.leverage({ symbol: params.symbol, leverage: params.leverage, ...(params.recvWindow && { recvWindow: params.recvWindow }), diff --git a/src/tools/binance-futures-coinm/positionMode.ts b/src/tools/binance-futures-coinm/positionMode.ts index ab19607a..73a64457 100644 --- a/src/tools/binance-futures-coinm/positionMode.ts +++ b/src/tools/binance-futures-coinm/positionMode.ts @@ -16,7 +16,7 @@ export function registerBinanceFuturesCOINMPositionMode(server: McpServer) { }, async ({ dualSidePosition }) => { try { - const data = await deliveryClient.positionSideDual({ + const data = await deliveryClient.positionMode({ dualSidePosition: dualSidePosition ? "true" : "false", }); diff --git a/src/tools/binance-futures-coinm/positionRisk.ts b/src/tools/binance-futures-coinm/positionRisk.ts index 6a41cdb5..629c27e0 100644 --- a/src/tools/binance-futures-coinm/positionRisk.ts +++ b/src/tools/binance-futures-coinm/positionRisk.ts @@ -18,7 +18,7 @@ export function registerBinanceFuturesCOINMPositionRisk(server: McpServer) { }, async (params) => { try { - const data = await deliveryClient.getPositionRisk({ + const data = await deliveryClient.positionRisk({ ...(params.marginAsset && { marginAsset: params.marginAsset }), ...(params.pair && { pair: params.pair }), ...(params.recvWindow && { recvWindow: params.recvWindow }), diff --git a/src/tools/binance-futures-coinm/userdatastream-api/createListenKey.ts b/src/tools/binance-futures-coinm/userdatastream-api/createListenKey.ts index 771e683a..07819f89 100644 --- a/src/tools/binance-futures-coinm/userdatastream-api/createListenKey.ts +++ b/src/tools/binance-futures-coinm/userdatastream-api/createListenKey.ts @@ -23,9 +23,7 @@ export function registerBinanceDeliveryCreateListenKey(server: McpServer) { }, async (params) => { try { - const response = await deliveryClient.restAPI.createListenKey({ - ...(params.recvWindow && { recvWindow: params.recvWindow }), - }); + const response = await deliveryClient.restAPI.createListenKey(); const data = await response.data(); diff --git a/src/tools/binance-futures-usdm/trade-api/allOrders.ts b/src/tools/binance-futures-usdm/trade-api/allOrders.ts index d84fb3c7..9dc2fe97 100644 --- a/src/tools/binance-futures-usdm/trade-api/allOrders.ts +++ b/src/tools/binance-futures-usdm/trade-api/allOrders.ts @@ -27,7 +27,8 @@ export function registerBinanceFuturesAllOrders(server: McpServer) { }, async (params) => { try { - const response = await futuresClient.restAPI.allOrders(params.symbol, { + const response = await futuresClient.restAPI.allOrders({ + symbol: params.symbol, orderId: params.orderId, startTime: params.startTime, endTime: params.endTime, diff --git a/src/tools/binance-futures-usdm/trade-api/cancelAllOpenOrders.ts b/src/tools/binance-futures-usdm/trade-api/cancelAllOpenOrders.ts index 5ec1b34b..d43babf5 100644 --- a/src/tools/binance-futures-usdm/trade-api/cancelAllOpenOrders.ts +++ b/src/tools/binance-futures-usdm/trade-api/cancelAllOpenOrders.ts @@ -23,7 +23,9 @@ export function registerBinanceFuturesCancelAllOpenOrders(server: McpServer) { }, async (params) => { try { - const response = await futuresClient.restAPI.cancelAllOpenOrders(params.symbol); + const response = await futuresClient.restAPI.cancelAllOpenOrders({ + symbol: params.symbol, + }); return { content: [ diff --git a/src/tools/binance-futures-usdm/trade-api/openOrder.ts b/src/tools/binance-futures-usdm/trade-api/openOrder.ts index 2d40146d..552806a3 100644 --- a/src/tools/binance-futures-usdm/trade-api/openOrder.ts +++ b/src/tools/binance-futures-usdm/trade-api/openOrder.ts @@ -37,7 +37,8 @@ export function registerBinanceFuturesOpenOrder(server: McpServer) { }; } - const response = await futuresClient.restAPI.currentOpenOrder(params.symbol, { + const response = await futuresClient.restAPI.currentOpenOrder({ + symbol: params.symbol, orderId: params.orderId, origClientOrderId: params.origClientOrderId, }); diff --git a/src/tools/binance-futures-usdm/userdatastream-api/closeListenKey.ts b/src/tools/binance-futures-usdm/userdatastream-api/closeListenKey.ts index 98ae03bf..65f895f1 100644 --- a/src/tools/binance-futures-usdm/userdatastream-api/closeListenKey.ts +++ b/src/tools/binance-futures-usdm/userdatastream-api/closeListenKey.ts @@ -27,10 +27,7 @@ export function registerBinanceFuturesCloseListenKey(server: McpServer) { }, async (params) => { try { - const response = await futuresClient.restAPI.closeListenKey({ - ...(params.listenKey && { listenKey: params.listenKey }), - ...(params.recvWindow && { recvWindow: params.recvWindow }), - }); + const response = await futuresClient.restAPI.closeListenKey(); const data = await response.data(); diff --git a/src/tools/binance-futures-usdm/userdatastream-api/createListenKey.ts b/src/tools/binance-futures-usdm/userdatastream-api/createListenKey.ts index 67674320..1ccd4f5a 100644 --- a/src/tools/binance-futures-usdm/userdatastream-api/createListenKey.ts +++ b/src/tools/binance-futures-usdm/userdatastream-api/createListenKey.ts @@ -23,9 +23,7 @@ export function registerBinanceFuturesCreateListenKey(server: McpServer) { }, async (params) => { try { - const response = await futuresClient.restAPI.createListenKey({ - ...(params.recvWindow && { recvWindow: params.recvWindow }), - }); + const response = await futuresClient.restAPI.createListenKey(); const data = await response.data(); diff --git a/src/tools/binance-futures-usdm/userdatastream-api/keepAliveListenKey.ts b/src/tools/binance-futures-usdm/userdatastream-api/keepAliveListenKey.ts index 409d3832..ab499333 100644 --- a/src/tools/binance-futures-usdm/userdatastream-api/keepAliveListenKey.ts +++ b/src/tools/binance-futures-usdm/userdatastream-api/keepAliveListenKey.ts @@ -27,10 +27,7 @@ export function registerBinanceFuturesKeepAliveListenKey(server: McpServer) { }, async (params) => { try { - const response = await futuresClient.restAPI.renewListenKey({ - ...(params.listenKey && { listenKey: params.listenKey }), - ...(params.recvWindow && { recvWindow: params.recvWindow }), - }); + const response = await futuresClient.restAPI.renewListenKey(); const data = await response.data(); diff --git a/src/tools/binance-margin/cross-margin-api/crossMarginAllAssets.ts b/src/tools/binance-margin/cross-margin-api/crossMarginAllAssets.ts index 69d56a35..625115ef 100644 --- a/src/tools/binance-margin/cross-margin-api/crossMarginAllAssets.ts +++ b/src/tools/binance-margin/cross-margin-api/crossMarginAllAssets.ts @@ -29,7 +29,7 @@ export function registerBinanceCrossMarginAllAssets(server: McpServer) { }, async (params) => { try { - const response = await marginClient.restAPI.getAllCrossMarginPairs({ + const response = await (marginClient as any).restAPI.getAllCrossMarginPairs({ ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/tools/binance-margin/isolated-margin-api/disableIsolatedMarginAccount.ts b/src/tools/binance-margin/isolated-margin-api/disableIsolatedMarginAccount.ts index dd69983b..f862c03e 100644 --- a/src/tools/binance-margin/isolated-margin-api/disableIsolatedMarginAccount.ts +++ b/src/tools/binance-margin/isolated-margin-api/disableIsolatedMarginAccount.ts @@ -24,7 +24,7 @@ export function registerBinanceDisableIsolatedMarginAccount(server: McpServer) { }, async (params) => { try { - const response = await marginClient.restAPI.disableIsolatedMarginAccount({ + const response = await (marginClient as any).restAPI.disableIsolatedMarginAccount({ symbol: params.symbol, ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/tools/binance-margin/isolated-margin-api/enableIsolatedMarginAccount.ts b/src/tools/binance-margin/isolated-margin-api/enableIsolatedMarginAccount.ts index 307e9164..4e36f773 100644 --- a/src/tools/binance-margin/isolated-margin-api/enableIsolatedMarginAccount.ts +++ b/src/tools/binance-margin/isolated-margin-api/enableIsolatedMarginAccount.ts @@ -23,7 +23,7 @@ export function registerBinanceEnableIsolatedMarginAccount(server: McpServer) { }, async (params) => { try { - const response = await marginClient.restAPI.enableIsolatedMarginAccount({ + const response = await (marginClient as any).restAPI.enableIsolatedMarginAccount({ symbol: params.symbol, ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllSymbols.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllSymbols.ts index fb214eef..57751c39 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllSymbols.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginAllSymbols.ts @@ -22,7 +22,7 @@ export function registerBinanceIsolatedMarginAllSymbols(server: McpServer) { }, async (params) => { try { - const response = await marginClient.restAPI.getAllIsolatedMarginSymbol({ + const response = await (marginClient as any).restAPI.getAllIsolatedMarginSymbol({ ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginBorrow.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginBorrow.ts index ec6c9e2e..9fe794c3 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginBorrow.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginBorrow.ts @@ -25,7 +25,7 @@ export function registerBinanceIsolatedMarginBorrow(server: McpServer) { }, async (params) => { try { - const response = await marginClient.restAPI.marginBorrowRepay({ + const response = await (marginClient as any).restAPI.marginBorrowRepay({ asset: params.asset, isIsolated: "TRUE", symbol: params.symbol, diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginRepay.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginRepay.ts index 3cee5e14..2b235335 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginRepay.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginRepay.ts @@ -25,7 +25,7 @@ export function registerBinanceIsolatedMarginRepay(server: McpServer) { }, async (params) => { try { - const response = await marginClient.restAPI.marginBorrowRepay({ + const response = await (marginClient as any).restAPI.marginBorrowRepay({ asset: params.asset, isIsolated: "TRUE", symbol: params.symbol, diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginSymbol.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginSymbol.ts index 8c60a1cd..8bea1ba8 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginSymbol.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginSymbol.ts @@ -23,7 +23,7 @@ export function registerBinanceIsolatedMarginSymbol(server: McpServer) { }, async (params) => { try { - const response = await marginClient.restAPI.queryIsolatedMarginSymbol({ + const response = await (marginClient as any).restAPI.queryIsolatedMarginSymbol({ symbol: params.symbol, ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/tools/binance-margin/isolated-margin-api/isolatedMarginTransferHistory.ts b/src/tools/binance-margin/isolated-margin-api/isolatedMarginTransferHistory.ts index 8087671a..44197130 100644 --- a/src/tools/binance-margin/isolated-margin-api/isolatedMarginTransferHistory.ts +++ b/src/tools/binance-margin/isolated-margin-api/isolatedMarginTransferHistory.ts @@ -31,7 +31,7 @@ export function registerBinanceIsolatedMarginTransferHistory(server: McpServer) }, async (params) => { try { - const response = await marginClient.restAPI.getIsolatedMarginTransferHistory({ + const response = await (marginClient as any).restAPI.getIsolatedMarginTransferHistory({ ...(params.symbol && { symbol: params.symbol }), ...(params.asset && { asset: params.asset }), ...(params.transFrom && { transFrom: params.transFrom }), diff --git a/src/tools/binance-margin/margin-order-api/marginCancelOco.ts b/src/tools/binance-margin/margin-order-api/marginCancelOco.ts index 05ed4903..6ead884a 100644 --- a/src/tools/binance-margin/margin-order-api/marginCancelOco.ts +++ b/src/tools/binance-margin/margin-order-api/marginCancelOco.ts @@ -44,7 +44,7 @@ export function registerBinanceMarginCancelOco(server: McpServer) { }; } - const response = await marginClient.restAPI.marginAccountCancelOco({ + const response = await (marginClient as any).restAPI.marginAccountCancelOco({ symbol: params.symbol, ...(params.orderListId !== undefined && { orderListId: params.orderListId }), ...(params.listClientOrderId && { listClientOrderId: params.listClientOrderId }), diff --git a/src/tools/binance-margin/margin-order-api/marginGetAllOco.ts b/src/tools/binance-margin/margin-order-api/marginGetAllOco.ts index 35eb1954..19735ce7 100644 --- a/src/tools/binance-margin/margin-order-api/marginGetAllOco.ts +++ b/src/tools/binance-margin/margin-order-api/marginGetAllOco.ts @@ -35,7 +35,7 @@ export function registerBinanceMarginGetAllOco(server: McpServer) { }, async (params) => { try { - const response = await marginClient.restAPI.queryMarginAccountsAllOco({ + const response = await (marginClient as any).restAPI.queryMarginAccountsAllOco({ ...(params.symbol && { symbol: params.symbol }), ...(params.fromId !== undefined && { fromId: params.fromId }), ...(params.startTime && { startTime: params.startTime }), diff --git a/src/tools/binance-margin/margin-order-api/marginGetOco.ts b/src/tools/binance-margin/margin-order-api/marginGetOco.ts index 100cd2b8..00307a56 100644 --- a/src/tools/binance-margin/margin-order-api/marginGetOco.ts +++ b/src/tools/binance-margin/margin-order-api/marginGetOco.ts @@ -43,7 +43,7 @@ export function registerBinanceMarginGetOco(server: McpServer) { }; } - const response = await marginClient.restAPI.queryMarginAccountsOco({ + const response = await (marginClient as any).restAPI.queryMarginAccountsOco({ ...(params.symbol && { symbol: params.symbol }), ...(params.orderListId !== undefined && { orderListId: params.orderListId }), ...(params.origClientOrderId && { origClientOrderId: params.origClientOrderId }), diff --git a/src/tools/binance-margin/margin-order-api/marginGetOpenOco.ts b/src/tools/binance-margin/margin-order-api/marginGetOpenOco.ts index 534e9d69..9a99f15d 100644 --- a/src/tools/binance-margin/margin-order-api/marginGetOpenOco.ts +++ b/src/tools/binance-margin/margin-order-api/marginGetOpenOco.ts @@ -30,7 +30,7 @@ export function registerBinanceMarginGetOpenOco(server: McpServer) { }, async (params) => { try { - const response = await marginClient.restAPI.queryMarginAccountsOpenOco({ + const response = await (marginClient as any).restAPI.queryMarginAccountsOpenOco({ ...(params.symbol && { symbol: params.symbol }), ...(params.isIsolated && { isIsolated: params.isIsolated }), ...(params.recvWindow && { recvWindow: params.recvWindow }), diff --git a/src/tools/binance-margin/margin-order-api/marginNewOco.ts b/src/tools/binance-margin/margin-order-api/marginNewOco.ts index f0e381d2..9e9b3666 100644 --- a/src/tools/binance-margin/margin-order-api/marginNewOco.ts +++ b/src/tools/binance-margin/margin-order-api/marginNewOco.ts @@ -55,7 +55,7 @@ export function registerBinanceMarginNewOco(server: McpServer) { }, async (params) => { try { - const response = await marginClient.restAPI.marginAccountNewOco({ + const response = await (marginClient as any).restAPI.marginAccountNewOco({ symbol: params.symbol, side: params.side, quantity: params.quantity, diff --git a/src/tools/binance-mining/mining-api/hashrateResaleDetail.ts b/src/tools/binance-mining/mining-api/hashrateResaleDetail.ts index 481f2138..5af29edc 100644 --- a/src/tools/binance-mining/mining-api/hashrateResaleDetail.ts +++ b/src/tools/binance-mining/mining-api/hashrateResaleDetail.ts @@ -32,13 +32,13 @@ export function registerBinanceHashRateResaleDetail(server: McpServer) { }, async (params) => { try { - const response = await miningClient.restAPI.hashrateResaleDetail({ + const response = await (miningClient as any).restAPI.hashrateResaleDetail({ configId: params.configId, userName: params.userName, ...(params.pageIndex && { pageIndex: params.pageIndex }), ...(params.pageSize && { pageSize: params.pageSize }), ...(params.recvWindow && { recvWindow: params.recvWindow }), - }); + } as any); const data = await response.data(); diff --git a/src/tools/binance-options/exchangeInfo.ts b/src/tools/binance-options/exchangeInfo.ts index 35547041..179c3c20 100644 --- a/src/tools/binance-options/exchangeInfo.ts +++ b/src/tools/binance-options/exchangeInfo.ts @@ -16,10 +16,7 @@ export function registerBinanceOptionsExchangeInfo(server: McpServer) { }, async ({ symbol }) => { try { - const params: any = {}; - if (symbol) params.symbol = symbol; - - const data = await optionsClient.exchangeInfo(params); + const data = await optionsClient.exchangeInfo(); return { content: [ diff --git a/src/tools/binance-options/exerciseHistory.ts b/src/tools/binance-options/exerciseHistory.ts index ff1ae4e3..f4b40952 100644 --- a/src/tools/binance-options/exerciseHistory.ts +++ b/src/tools/binance-options/exerciseHistory.ts @@ -25,7 +25,7 @@ export function registerBinanceOptionsExerciseHistory(server: McpServer) { if (endTime !== undefined) params.endTime = endTime; if (limit !== undefined) params.limit = limit; - const data = await optionsClient.exerciseHistory(params); + const data = await optionsClient.exerciseRecord(params); return { content: [ diff --git a/src/tools/binance-pay/pay-api/getPayTradeHistory.ts b/src/tools/binance-pay/pay-api/getPayTradeHistory.ts index ac62322d..4c059bf1 100644 --- a/src/tools/binance-pay/pay-api/getPayTradeHistory.ts +++ b/src/tools/binance-pay/pay-api/getPayTradeHistory.ts @@ -29,7 +29,7 @@ export function registerBinanceGetPayTradeHistory(server: McpServer) { }, async (params) => { try { - const response = await payClient.restAPI.getPayTradeHistory({ + const response = await (payClient as any).restAPI.getPayTradeHistory({ ...(params.startTime && { startTime: params.startTime }), ...(params.endTime && { endTime: params.endTime }), ...(params.limit && { limit: params.limit }), diff --git a/src/tools/binance-simple-earn/account-api/getFlexibleProductPosition.ts b/src/tools/binance-simple-earn/account-api/getFlexibleProductPosition.ts index 6be31cea..86d13d83 100644 --- a/src/tools/binance-simple-earn/account-api/getFlexibleProductPosition.ts +++ b/src/tools/binance-simple-earn/account-api/getFlexibleProductPosition.ts @@ -34,7 +34,7 @@ export function registerBinanceGetFlexibleProductPosition(server: McpServer) { }, async (params) => { try { - const response = await simpleEarnClient.restAPI.getFlexibleProductPosition({ + const response = await (simpleEarnClient as any).restAPI.getFlexibleProductPosition({ ...(params.asset && { asset: params.asset }), ...(params.productId && { productId: params.productId }), ...(params.current && { current: params.current }), diff --git a/src/tools/binance-simple-earn/account-api/simpleEarnFlexibleProductList.ts b/src/tools/binance-simple-earn/account-api/simpleEarnFlexibleProductList.ts index 0219d0d1..eef70a29 100644 --- a/src/tools/binance-simple-earn/account-api/simpleEarnFlexibleProductList.ts +++ b/src/tools/binance-simple-earn/account-api/simpleEarnFlexibleProductList.ts @@ -33,7 +33,7 @@ export function registerBinanceSimpleEarnFlexibleProductList(server: McpServer) }, async (params) => { try { - const response = await simpleEarnClient.restAPI.getSimpleEarnFlexibleProductList({ + const response = await (simpleEarnClient as any).restAPI.getSimpleEarnFlexibleProductList({ ...(params.asset && { asset: params.asset }), ...(params.current && { current: params.current }), ...(params.size && { size: params.size }), diff --git a/src/tools/binance-simple-earn/earn-api/redeemFlexibleProduct.ts b/src/tools/binance-simple-earn/earn-api/redeemFlexibleProduct.ts index d8029896..ba5f2754 100644 --- a/src/tools/binance-simple-earn/earn-api/redeemFlexibleProduct.ts +++ b/src/tools/binance-simple-earn/earn-api/redeemFlexibleProduct.ts @@ -43,7 +43,7 @@ export function registerBinanceRedeemFlexibleProduct(server: McpServer) { }; } - const response = await simpleEarnClient.restAPI.redeemFlexibleProduct({ + const response = await (simpleEarnClient as any).restAPI.redeemFlexibleProduct({ productId, ...(redeemAll !== undefined && { redeemAll }), ...(amount !== undefined && { amount }), diff --git a/src/tools/binance-simple-earn/earn-api/subscribeFlexibleProduct.ts b/src/tools/binance-simple-earn/earn-api/subscribeFlexibleProduct.ts index 08742103..eb961569 100644 --- a/src/tools/binance-simple-earn/earn-api/subscribeFlexibleProduct.ts +++ b/src/tools/binance-simple-earn/earn-api/subscribeFlexibleProduct.ts @@ -24,7 +24,7 @@ export function registerBinanceSubscribeFlexibleProduct(server: McpServer) { }, async (params) => { try { - const response = await simpleEarnClient.restAPI.subscribeFlexibleProduct({ + const response = await (simpleEarnClient as any).restAPI.subscribeFlexibleProduct({ productId: params.productId, amount: params.amount, ...(params.autoSubscribe !== undefined && { autoSubscribe: params.autoSubscribe }), diff --git a/src/tools/binance-spot/account-api/accountCommission.ts b/src/tools/binance-spot/account-api/accountCommission.ts index b176b579..174c56f7 100644 --- a/src/tools/binance-spot/account-api/accountCommission.ts +++ b/src/tools/binance-spot/account-api/accountCommission.ts @@ -20,7 +20,7 @@ export function registerBinanceAccountCommission(server: McpServer) { const params: any = { symbol }; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await spotClient.restAPI.accountCommission(params); + const response = await (spotClient as any).restAPI.accountCommission(params); const data = await response.data(); diff --git a/src/tools/binance-spot/account-api/getAccount.ts b/src/tools/binance-spot/account-api/getAccount.ts index 995b0bb2..950a4704 100644 --- a/src/tools/binance-spot/account-api/getAccount.ts +++ b/src/tools/binance-spot/account-api/getAccount.ts @@ -19,7 +19,7 @@ export function registerBinanceGetAccount(server: McpServer) { const params: any = {}; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await spotClient.restAPI.getAccount(params); + const response = await (spotClient as any).restAPI.getAccount(params); const data = await response.data(); diff --git a/src/tools/binance-spot/account-api/myAllocations.ts b/src/tools/binance-spot/account-api/myAllocations.ts index a000150c..672f5b92 100644 --- a/src/tools/binance-spot/account-api/myAllocations.ts +++ b/src/tools/binance-spot/account-api/myAllocations.ts @@ -29,7 +29,7 @@ export function registerBinanceMyAllocations(server: McpServer) { if (limit !== undefined) params.limit = limit; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await spotClient.restAPI.myAllocations(params); + const response = await (spotClient as any).restAPI.myAllocations(params); const data = await response.data(); diff --git a/src/tools/binance-spot/account-api/myPreventedMatches.ts b/src/tools/binance-spot/account-api/myPreventedMatches.ts index cff226cb..cb6e5e41 100644 --- a/src/tools/binance-spot/account-api/myPreventedMatches.ts +++ b/src/tools/binance-spot/account-api/myPreventedMatches.ts @@ -29,7 +29,7 @@ export function registerBinanceMyPreventedMatches(server: McpServer) { if (limit !== undefined) params.limit = limit; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await spotClient.restAPI.myPreventedMatches(params); + const response = await (spotClient as any).restAPI.myPreventedMatches(params); const data = await response.data(); diff --git a/src/tools/binance-spot/account-api/myTrades.ts b/src/tools/binance-spot/account-api/myTrades.ts index c7576641..9965ad2d 100644 --- a/src/tools/binance-spot/account-api/myTrades.ts +++ b/src/tools/binance-spot/account-api/myTrades.ts @@ -31,7 +31,7 @@ export function registerBinanceMyTrades(server: McpServer) { if (limit !== undefined) params.limit = limit; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await spotClient.restAPI.myTrades(params); + const response = await (spotClient as any).restAPI.myTrades(params); const data = await response.data(); diff --git a/src/tools/binance-spot/account-api/rateLimitOrder.ts b/src/tools/binance-spot/account-api/rateLimitOrder.ts index a8956267..7eabceb3 100644 --- a/src/tools/binance-spot/account-api/rateLimitOrder.ts +++ b/src/tools/binance-spot/account-api/rateLimitOrder.ts @@ -19,7 +19,7 @@ export function registerBinanceRateLimitOrder(server: McpServer) { const params: any = {}; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await spotClient.restAPI.rateLimitOrder(params); + const response = await (spotClient as any).restAPI.rateLimitOrder(params); const data = await response.data(); diff --git a/src/tools/binance-spot/general-api/exchangeInfo.ts b/src/tools/binance-spot/general-api/exchangeInfo.ts index 19912582..2213fa1c 100644 --- a/src/tools/binance-spot/general-api/exchangeInfo.ts +++ b/src/tools/binance-spot/general-api/exchangeInfo.ts @@ -39,7 +39,7 @@ export function registerBinanceExchangeInfo(server: McpServer) { if (permissions?.length && !params.symbol && !params.symbols) params.permissions = permissions; - const response = await spotClient.restAPI.exchangeInfo(params); + const response = await (spotClient as any).restAPI.exchangeInfo(params); const data = await response.data(); diff --git a/src/tools/binance-spot/general-api/ping.ts b/src/tools/binance-spot/general-api/ping.ts index bddc02d5..18939f88 100644 --- a/src/tools/binance-spot/general-api/ping.ts +++ b/src/tools/binance-spot/general-api/ping.ts @@ -9,7 +9,7 @@ export function registerBinancePing(server: McpServer) { { description: "Test connectivity to the Binance API." }, async () => { try { - const response = await spotClient.restAPI.ping(); + const response = await (spotClient as any).restAPI.ping(); const data = await response.data(); diff --git a/src/tools/binance-spot/general-api/time.ts b/src/tools/binance-spot/general-api/time.ts index 601054ff..bef51db8 100644 --- a/src/tools/binance-spot/general-api/time.ts +++ b/src/tools/binance-spot/general-api/time.ts @@ -9,11 +9,10 @@ export function registerBinanceTime(server: McpServer) { { description: "Get the current server time from Binance API." }, async () => { try { - const response = await spotClient.restAPI.time(); + const response = await (spotClient as any).restAPI.time(); const data = await response.data(); - // @ts-expect-error - serverTime not in generated type definition const serverTime = new Date(data.serverTime).toISOString(); return { diff --git a/src/tools/binance-spot/market-api/aggTrades.ts b/src/tools/binance-spot/market-api/aggTrades.ts index 0f4e8f65..1d1ef133 100644 --- a/src/tools/binance-spot/market-api/aggTrades.ts +++ b/src/tools/binance-spot/market-api/aggTrades.ts @@ -27,7 +27,7 @@ export function registerBinanceAggTrades(server: McpServer) { if (endTime !== undefined) params.endTime = endTime; if (limit !== undefined) params.limit = limit; - const response = await spotClient.restAPI.aggTrades(params); + const response = await (spotClient as any).restAPI.aggTrades(params); const data = await response.data(); diff --git a/src/tools/binance-spot/market-api/avgPrice.ts b/src/tools/binance-spot/market-api/avgPrice.ts index 299e44d8..4ccb304c 100644 --- a/src/tools/binance-spot/market-api/avgPrice.ts +++ b/src/tools/binance-spot/market-api/avgPrice.ts @@ -16,7 +16,7 @@ export function registerBinanceAvgPrice(server: McpServer) { }, async ({ symbol }) => { try { - const response = await spotClient.restAPI.avgPrice({ + const response = await (spotClient as any).restAPI.avgPrice({ symbol: symbol, }); diff --git a/src/tools/binance-spot/market-api/depth.ts b/src/tools/binance-spot/market-api/depth.ts index 106c39d7..2ce263f5 100644 --- a/src/tools/binance-spot/market-api/depth.ts +++ b/src/tools/binance-spot/market-api/depth.ts @@ -20,7 +20,7 @@ export function registerBinanceDepth(server: McpServer) { const params: any = { symbol }; if (limit !== undefined) params.limit = limit; - const response = await spotClient.restAPI.depth(params); + const response = await (spotClient as any).restAPI.depth(params); const data = await response.data(); diff --git a/src/tools/binance-spot/market-api/getTrades.ts b/src/tools/binance-spot/market-api/getTrades.ts index 1d0dace1..2ecffd7e 100644 --- a/src/tools/binance-spot/market-api/getTrades.ts +++ b/src/tools/binance-spot/market-api/getTrades.ts @@ -21,7 +21,7 @@ export function registerBinanceGetTrades(server: McpServer) { if (limit !== undefined) params.limit = limit; - const response = await spotClient.restAPI.getTrades(params); + const response = await (spotClient as any).restAPI.getTrades(params); const data = await response.data(); diff --git a/src/tools/binance-spot/market-api/historicalTrades.ts b/src/tools/binance-spot/market-api/historicalTrades.ts index 85299c2a..4ac08777 100644 --- a/src/tools/binance-spot/market-api/historicalTrades.ts +++ b/src/tools/binance-spot/market-api/historicalTrades.ts @@ -23,7 +23,7 @@ export function registerBinanceHistoricalTrades(server: McpServer) { if (limit !== undefined) params.limit = limit; if (fromId !== undefined) params.fromId = fromId; - const response = await spotClient.restAPI.historicalTrades(params); + const response = await (spotClient as any).restAPI.historicalTrades(params); const data = await response.data(); diff --git a/src/tools/binance-spot/market-api/klines.ts b/src/tools/binance-spot/market-api/klines.ts index 12d97fea..69ee69df 100644 --- a/src/tools/binance-spot/market-api/klines.ts +++ b/src/tools/binance-spot/market-api/klines.ts @@ -47,7 +47,7 @@ export function registerBinanceKlines(server: McpServer) { if (endTime !== undefined) params.endTime = endTime; if (limit !== undefined) params.limit = limit; - const response = await spotClient.restAPI.klines(params); + const response = await (spotClient as any).restAPI.klines(params); const data = await response.data(); diff --git a/src/tools/binance-spot/market-api/ticker.ts b/src/tools/binance-spot/market-api/ticker.ts index dc71f02d..085fb0a9 100644 --- a/src/tools/binance-spot/market-api/ticker.ts +++ b/src/tools/binance-spot/market-api/ticker.ts @@ -25,7 +25,7 @@ export function registerBinanceTicker(server: McpServer) { if (symbol) params.symbol = symbol; if (windowSize) params.windowSize = windowSize; - const response = await spotClient.restAPI.ticker(params); + const response = await (spotClient as any).restAPI.ticker(params); const data = await response.data(); diff --git a/src/tools/binance-spot/market-api/ticker24hr.ts b/src/tools/binance-spot/market-api/ticker24hr.ts index 06fb1f9b..35d607fb 100644 --- a/src/tools/binance-spot/market-api/ticker24hr.ts +++ b/src/tools/binance-spot/market-api/ticker24hr.ts @@ -19,7 +19,7 @@ export function registerBinanceTicker24hr(server: McpServer) { const params: any = {}; if (symbol) params.symbol = symbol; - const response = await spotClient.restAPI.ticker24hr(params); + const response = await (spotClient as any).restAPI.ticker24hr(params); const data = await response.data(); diff --git a/src/tools/binance-spot/market-api/tickerBookTicker.ts b/src/tools/binance-spot/market-api/tickerBookTicker.ts index ab275052..103c86fb 100644 --- a/src/tools/binance-spot/market-api/tickerBookTicker.ts +++ b/src/tools/binance-spot/market-api/tickerBookTicker.ts @@ -19,7 +19,7 @@ export function registerBinanceTickerBookTicker(server: McpServer) { const params: any = {}; if (symbol) params.symbol = symbol; - const response = await spotClient.restAPI.tickerBookTicker(params); + const response = await (spotClient as any).restAPI.tickerBookTicker(params); const data = await response.data(); diff --git a/src/tools/binance-spot/market-api/tickerPrice.ts b/src/tools/binance-spot/market-api/tickerPrice.ts index f1da8d7c..7a4ee56f 100644 --- a/src/tools/binance-spot/market-api/tickerPrice.ts +++ b/src/tools/binance-spot/market-api/tickerPrice.ts @@ -19,7 +19,7 @@ export function registerBinanceTickerPrice(server: McpServer) { const params: any = {}; if (symbol) params.symbol = symbol; - const response = await spotClient.restAPI.tickerPrice(params); + const response = await (spotClient as any).restAPI.tickerPrice(params); const data = await response.data(); diff --git a/src/tools/binance-spot/market-api/tickerTradingDay.ts b/src/tools/binance-spot/market-api/tickerTradingDay.ts index 1fcedc0f..0f43c545 100644 --- a/src/tools/binance-spot/market-api/tickerTradingDay.ts +++ b/src/tools/binance-spot/market-api/tickerTradingDay.ts @@ -19,7 +19,7 @@ export function registerBinanceTickerTradingDay(server: McpServer) { const params: any = {}; if (symbol) params.symbol = symbol; - const response = await spotClient.restAPI.tickerTradingDay(params); + const response = await (spotClient as any).restAPI.tickerTradingDay(params); const data = await response.data(); diff --git a/src/tools/binance-spot/market-api/uiKlines.ts b/src/tools/binance-spot/market-api/uiKlines.ts index 697bf896..9a767f00 100644 --- a/src/tools/binance-spot/market-api/uiKlines.ts +++ b/src/tools/binance-spot/market-api/uiKlines.ts @@ -47,7 +47,7 @@ export function registerBinanceUiKlines(server: McpServer) { if (endTime !== undefined) params.endTime = endTime; if (limit !== undefined) params.limit = limit; - const response = await spotClient.restAPI.uiKlines(params); + const response = await (spotClient as any).restAPI.uiKlines(params); const data = await response.data(); diff --git a/src/tools/binance-spot/trade-api/allOrders.ts b/src/tools/binance-spot/trade-api/allOrders.ts index d8ab32d9..41dcc20d 100644 --- a/src/tools/binance-spot/trade-api/allOrders.ts +++ b/src/tools/binance-spot/trade-api/allOrders.ts @@ -30,7 +30,7 @@ export function registerBinanceAllOrders(server: McpServer) { if (endTime !== undefined) params.endTime = endTime; if (limit !== undefined) params.limit = limit; - const response = await spotClient.restAPI.allOrders(params); + const response = await (spotClient as any).restAPI.allOrders(params); const data = await response.data(); diff --git a/src/tools/binance-spot/trade-api/deleteOpenOrders.ts b/src/tools/binance-spot/trade-api/deleteOpenOrders.ts index 22d06c31..541b9de6 100644 --- a/src/tools/binance-spot/trade-api/deleteOpenOrders.ts +++ b/src/tools/binance-spot/trade-api/deleteOpenOrders.ts @@ -16,7 +16,7 @@ export function registerBinanceDeleteOpenOrders(server: McpServer) { }, async ({ symbol }) => { try { - const response = await spotClient.restAPI.deleteOpenOrders({ + const response = await (spotClient as any).restAPI.deleteOpenOrders({ symbol: symbol, }); diff --git a/src/tools/binance-spot/trade-api/deleteOrder.ts b/src/tools/binance-spot/trade-api/deleteOrder.ts index 9768877b..ac8036f0 100644 --- a/src/tools/binance-spot/trade-api/deleteOrder.ts +++ b/src/tools/binance-spot/trade-api/deleteOrder.ts @@ -23,7 +23,7 @@ export function registerBinanceDeleteOrder(server: McpServer) { if (orderId) params.orderId = orderId; if (origClientOrderId) params.origClientOrderId = origClientOrderId; - const response = await spotClient.restAPI.deleteOrder(params); + const response = await (spotClient as any).restAPI.deleteOrder(params); const data = await response.data(); diff --git a/src/tools/binance-spot/trade-api/getOpenOrders.ts b/src/tools/binance-spot/trade-api/getOpenOrders.ts index 4abe2229..9d36a0ad 100644 --- a/src/tools/binance-spot/trade-api/getOpenOrders.ts +++ b/src/tools/binance-spot/trade-api/getOpenOrders.ts @@ -19,7 +19,7 @@ export function registerBinanceGetOpenOrders(server: McpServer) { const params: any = {}; if (symbol) params.symbol = symbol; - const response = await spotClient.restAPI.getOpenOrders(params); + const response = await (spotClient as any).restAPI.getOpenOrders(params); const data = await response.data(); diff --git a/src/tools/binance-spot/trade-api/getOrder.ts b/src/tools/binance-spot/trade-api/getOrder.ts index b3e2afa9..3357bf2b 100644 --- a/src/tools/binance-spot/trade-api/getOrder.ts +++ b/src/tools/binance-spot/trade-api/getOrder.ts @@ -23,7 +23,7 @@ export function registerBinanceGetOrder(server: McpServer) { if (orderId) params.orderId = orderId; if (origClientOrderId) params.origClientOrderId = origClientOrderId; - const response = await spotClient.restAPI.getOrder(params); + const response = await (spotClient as any).restAPI.getOrder(params); const data = await response.data(); diff --git a/src/tools/binance-spot/trade-api/newOrder.ts b/src/tools/binance-spot/trade-api/newOrder.ts index 00773a80..e62eb377 100644 --- a/src/tools/binance-spot/trade-api/newOrder.ts +++ b/src/tools/binance-spot/trade-api/newOrder.ts @@ -77,7 +77,7 @@ export function registerBinanceNewOrder(server: McpServer) { if (icebergQty !== undefined) params.icebergQty = icebergQty; if (newOrderRespType) params.newOrderRespType = newOrderRespType; - const response = await spotClient.restAPI.newOrder(params); + const response = await (spotClient as any).restAPI.newOrder(params); const data = await response.data(); diff --git a/src/tools/binance-spot/trade-api/openOrderList.ts b/src/tools/binance-spot/trade-api/openOrderList.ts index 12c9a3a4..02ae7c12 100644 --- a/src/tools/binance-spot/trade-api/openOrderList.ts +++ b/src/tools/binance-spot/trade-api/openOrderList.ts @@ -19,7 +19,7 @@ export function registerBinanceOpenOrderList(server: McpServer) { const params: any = {}; if (symbol) params.symbol = symbol; - const response = await spotClient.restAPI.openOrderList(params); + const response = await (spotClient as any).restAPI.openOrderList(params); const data = await response.data(); diff --git a/src/tools/binance-spot/trade-api/orderOco.ts b/src/tools/binance-spot/trade-api/orderOco.ts index 33348c6d..b3e09c8e 100644 --- a/src/tools/binance-spot/trade-api/orderOco.ts +++ b/src/tools/binance-spot/trade-api/orderOco.ts @@ -56,7 +56,7 @@ export function registerBinanceOrderOco(server: McpServer) { if (limitIcebergQty !== undefined) params.limitIcebergQty = limitIcebergQty; if (stopIcebergQty !== undefined) params.stopIcebergQty = stopIcebergQty; - const response = await spotClient.restAPI.orderOco(params); + const response = await (spotClient as any).restAPI.orderOco(params); const data = await response.data(); diff --git a/src/tools/binance-spot/userdatastream-api/deleteUserDataStream.ts b/src/tools/binance-spot/userdatastream-api/deleteUserDataStream.ts index 47eb16f3..5dfa7052 100644 --- a/src/tools/binance-spot/userdatastream-api/deleteUserDataStream.ts +++ b/src/tools/binance-spot/userdatastream-api/deleteUserDataStream.ts @@ -16,7 +16,7 @@ export function registerBinanceDeleteUserDataStream(server: McpServer) { }, async ({ listenKey }) => { try { - const response = await spotClient.restAPI.deleteUserDataStream({ + const response = await (spotClient as any).restAPI.deleteUserDataStream({ listenKey: listenKey, }); diff --git a/src/tools/binance-spot/userdatastream-api/newUserDataStream.ts b/src/tools/binance-spot/userdatastream-api/newUserDataStream.ts index e7bd9d50..74dd45f0 100644 --- a/src/tools/binance-spot/userdatastream-api/newUserDataStream.ts +++ b/src/tools/binance-spot/userdatastream-api/newUserDataStream.ts @@ -9,7 +9,7 @@ export function registerBinanceNewUserDataStream(server: McpServer) { { description: "Create a new user data stream to receive account updates via WebSocket." }, async () => { try { - const response = await spotClient.restAPI.newUserDataStream(); + const response = await (spotClient as any).restAPI.newUserDataStream(); const data = await response.data(); diff --git a/src/tools/binance-spot/userdatastream-api/putUserDataStream.ts b/src/tools/binance-spot/userdatastream-api/putUserDataStream.ts index 73d4783e..63568ebe 100644 --- a/src/tools/binance-spot/userdatastream-api/putUserDataStream.ts +++ b/src/tools/binance-spot/userdatastream-api/putUserDataStream.ts @@ -16,7 +16,7 @@ export function registerBinancePutUserDataStream(server: McpServer) { }, async ({ listenKey }) => { try { - const response = await spotClient.restAPI.putUserDataStream({ + const response = await (spotClient as any).restAPI.putUserDataStream({ listenKey: listenKey, }); diff --git a/src/tools/binance-sub-account/assets-api/getFuturesAssetsSummary.ts b/src/tools/binance-sub-account/assets-api/getFuturesAssetsSummary.ts index 79c7e55e..934e3cd6 100644 --- a/src/tools/binance-sub-account/assets-api/getFuturesAssetsSummary.ts +++ b/src/tools/binance-sub-account/assets-api/getFuturesAssetsSummary.ts @@ -27,7 +27,7 @@ export function registerBinanceSubAccountFuturesSummary(server: McpServer) { }, async (params) => { try { - const response = await spotClient.restAPI.getSubAccountFuturesAccountSummaryV2({ + const response = await (spotClient as any).restAPI.getSubAccountFuturesAccountSummaryV2({ ...(params.futuresType && { futuresType: params.futuresType }), ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/tools/binance-sub-account/assets-api/getFuturesPositionRisk.ts b/src/tools/binance-sub-account/assets-api/getFuturesPositionRisk.ts index 39ceb937..aa1b6e19 100644 --- a/src/tools/binance-sub-account/assets-api/getFuturesPositionRisk.ts +++ b/src/tools/binance-sub-account/assets-api/getFuturesPositionRisk.ts @@ -28,7 +28,7 @@ export function registerBinanceSubAccountFuturesPositionRisk(server: McpServer) }, async (params) => { try { - const response = await spotClient.restAPI.getSubAccountFuturesPositionRiskV2({ + const response = await (spotClient as any).restAPI.getSubAccountFuturesPositionRiskV2({ email: params.email, ...(params.futuresType && { futuresType: params.futuresType }), ...(params.recvWindow && { recvWindow: params.recvWindow }), diff --git a/src/tools/binance-sub-account/assets-api/getMarginAssetsSummary.ts b/src/tools/binance-sub-account/assets-api/getMarginAssetsSummary.ts index d011118b..1e94228a 100644 --- a/src/tools/binance-sub-account/assets-api/getMarginAssetsSummary.ts +++ b/src/tools/binance-sub-account/assets-api/getMarginAssetsSummary.ts @@ -23,7 +23,7 @@ export function registerBinanceSubAccountMarginSummary(server: McpServer) { }, async (params) => { try { - const response = await spotClient.restAPI.getSubAccountMarginAccountSummary({ + const response = await (spotClient as any).restAPI.getSubAccountMarginAccountSummary({ ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/tools/binance-sub-account/assets-api/getSpotAssetsSummary.ts b/src/tools/binance-sub-account/assets-api/getSpotAssetsSummary.ts index 959e1eef..ec30df0c 100644 --- a/src/tools/binance-sub-account/assets-api/getSpotAssetsSummary.ts +++ b/src/tools/binance-sub-account/assets-api/getSpotAssetsSummary.ts @@ -32,7 +32,7 @@ export function registerBinanceSubAccountSpotSummary(server: McpServer) { }, async (params) => { try { - const response = await spotClient.restAPI.querySubAccountSpotAssetsSummary({ + const response = await (spotClient as any).restAPI.querySubAccountSpotAssetsSummary({ ...(params.email && { email: params.email }), ...(params.page && { page: params.page }), ...(params.size && { size: params.size }), diff --git a/src/tools/binance-sub-account/assets-api/getSubAccountAssets.ts b/src/tools/binance-sub-account/assets-api/getSubAccountAssets.ts index c2b1a9a4..e327c9a5 100644 --- a/src/tools/binance-sub-account/assets-api/getSubAccountAssets.ts +++ b/src/tools/binance-sub-account/assets-api/getSubAccountAssets.ts @@ -24,7 +24,7 @@ export function registerBinanceSubAccountAssets(server: McpServer) { }, async (params) => { try { - const response = await spotClient.restAPI.querySubAccountAssetsV4({ + const response = await (spotClient as any).restAPI.querySubAccountAssetsV4({ email: params.email, ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/tools/binance-sub-account/deposit-api/getDepositAddress.ts b/src/tools/binance-sub-account/deposit-api/getDepositAddress.ts index 9ba5d4e7..f676b331 100644 --- a/src/tools/binance-sub-account/deposit-api/getDepositAddress.ts +++ b/src/tools/binance-sub-account/deposit-api/getDepositAddress.ts @@ -26,7 +26,7 @@ export function registerBinanceSubAccountDepositAddress(server: McpServer) { }, async (params) => { try { - const response = await spotClient.restAPI.getSubAccountDepositAddress({ + const response = await (spotClient as any).restAPI.getSubAccountDepositAddress({ email: params.email, coin: params.coin, ...(params.network && { network: params.network }), diff --git a/src/tools/binance-sub-account/deposit-api/getDepositHistory.ts b/src/tools/binance-sub-account/deposit-api/getDepositHistory.ts index c464729c..8f6656a5 100644 --- a/src/tools/binance-sub-account/deposit-api/getDepositHistory.ts +++ b/src/tools/binance-sub-account/deposit-api/getDepositHistory.ts @@ -39,7 +39,7 @@ export function registerBinanceSubAccountDepositHistory(server: McpServer) { }, async (params) => { try { - const response = await spotClient.restAPI.getSubAccountDepositHistory({ + const response = await (spotClient as any).restAPI.getSubAccountDepositHistory({ email: params.email, ...(params.coin && { coin: params.coin }), ...(params.status && { status: params.status }), diff --git a/src/tools/binance-sub-account/management-api/createSubAccount.ts b/src/tools/binance-sub-account/management-api/createSubAccount.ts index 4e7755ef..21a2f090 100644 --- a/src/tools/binance-sub-account/management-api/createSubAccount.ts +++ b/src/tools/binance-sub-account/management-api/createSubAccount.ts @@ -28,7 +28,7 @@ export function registerBinanceSubAccountCreate(server: McpServer) { }, async (params) => { try { - const response = await spotClient.restAPI.createVirtualSubAccount({ + const response = await (spotClient as any).restAPI.createVirtualSubAccount({ subAccountString: params.subAccountString, ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/tools/binance-sub-account/management-api/enableFutures.ts b/src/tools/binance-sub-account/management-api/enableFutures.ts index 2f3c79c5..fab4fe95 100644 --- a/src/tools/binance-sub-account/management-api/enableFutures.ts +++ b/src/tools/binance-sub-account/management-api/enableFutures.ts @@ -24,7 +24,7 @@ export function registerBinanceSubAccountEnableFutures(server: McpServer) { }, async (params) => { try { - const response = await spotClient.restAPI.enableFuturesForSubAccount({ + const response = await (spotClient as any).restAPI.enableFuturesForSubAccount({ email: params.email, ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/tools/binance-sub-account/management-api/enableMargin.ts b/src/tools/binance-sub-account/management-api/enableMargin.ts index eb993d9e..bc62c185 100644 --- a/src/tools/binance-sub-account/management-api/enableMargin.ts +++ b/src/tools/binance-sub-account/management-api/enableMargin.ts @@ -24,7 +24,7 @@ export function registerBinanceSubAccountEnableMargin(server: McpServer) { }, async (params) => { try { - const response = await spotClient.restAPI.enableMarginForSubAccount({ + const response = await (spotClient as any).restAPI.enableMarginForSubAccount({ email: params.email, ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/tools/binance-sub-account/management-api/getSubAccountApiPermission.ts b/src/tools/binance-sub-account/management-api/getSubAccountApiPermission.ts index 4d018a0d..677b2246 100644 --- a/src/tools/binance-sub-account/management-api/getSubAccountApiPermission.ts +++ b/src/tools/binance-sub-account/management-api/getSubAccountApiPermission.ts @@ -25,7 +25,7 @@ export function registerBinanceSubAccountApiPermission(server: McpServer) { }, async (params) => { try { - const response = await spotClient.restAPI.getSubAccountApiIpRestriction({ + const response = await (spotClient as any).restAPI.getSubAccountApiIpRestriction({ email: params.email, subAccountApiKey: params.subAccountApiKey, ...(params.recvWindow && { recvWindow: params.recvWindow }), diff --git a/src/tools/binance-sub-account/management-api/getSubAccountList.ts b/src/tools/binance-sub-account/management-api/getSubAccountList.ts index 161f18ca..7a4bd347 100644 --- a/src/tools/binance-sub-account/management-api/getSubAccountList.ts +++ b/src/tools/binance-sub-account/management-api/getSubAccountList.ts @@ -33,7 +33,7 @@ export function registerBinanceSubAccountList(server: McpServer) { }, async (params) => { try { - const response = await spotClient.restAPI.querySubAccountList({ + const response = await (spotClient as any).restAPI.querySubAccountList({ ...(params.email && { email: params.email }), ...(params.isFreeze && { isFreeze: params.isFreeze }), ...(params.page && { page: params.page }), diff --git a/src/tools/binance-sub-account/management-api/getSubAccountStatus.ts b/src/tools/binance-sub-account/management-api/getSubAccountStatus.ts index 4ae86218..20da3f9e 100644 --- a/src/tools/binance-sub-account/management-api/getSubAccountStatus.ts +++ b/src/tools/binance-sub-account/management-api/getSubAccountStatus.ts @@ -24,7 +24,7 @@ export function registerBinanceSubAccountStatus(server: McpServer) { }, async (params) => { try { - const response = await spotClient.restAPI.getSubAccountStatus({ + const response = await (spotClient as any).restAPI.getSubAccountStatus({ ...(params.email && { email: params.email }), ...(params.recvWindow && { recvWindow: params.recvWindow }), }); diff --git a/src/tools/binance-sub-account/transfer-api/futuresTransfer.ts b/src/tools/binance-sub-account/transfer-api/futuresTransfer.ts index 359961ec..c97eb85b 100644 --- a/src/tools/binance-sub-account/transfer-api/futuresTransfer.ts +++ b/src/tools/binance-sub-account/transfer-api/futuresTransfer.ts @@ -28,7 +28,7 @@ export function registerBinanceSubAccountFuturesTransfer(server: McpServer) { }, async (params) => { try { - const response = await spotClient.restAPI.subAccountFuturesInternalTransfer({ + const response = await (spotClient as any).restAPI.subAccountFuturesInternalTransfer({ fromEmail: params.fromEmail, toEmail: params.toEmail, futuresType: params.futuresType, diff --git a/src/tools/binance-sub-account/transfer-api/getTransferHistory.ts b/src/tools/binance-sub-account/transfer-api/getTransferHistory.ts index d24af063..d07f9bd0 100644 --- a/src/tools/binance-sub-account/transfer-api/getTransferHistory.ts +++ b/src/tools/binance-sub-account/transfer-api/getTransferHistory.ts @@ -31,7 +31,7 @@ export function registerBinanceSubAccountTransferHistory(server: McpServer) { }, async (params) => { try { - const response = await spotClient.restAPI.querySubAccountTransferHistoryV1({ + const response = await (spotClient as any).restAPI.querySubAccountTransferHistoryV1({ ...(params.asset && { asset: params.asset }), ...(params.type && { type: params.type }), ...(params.startTime && { startTime: params.startTime }), diff --git a/src/tools/binance-sub-account/transfer-api/transferToMaster.ts b/src/tools/binance-sub-account/transfer-api/transferToMaster.ts index 3ea3d0e6..4e9e6999 100644 --- a/src/tools/binance-sub-account/transfer-api/transferToMaster.ts +++ b/src/tools/binance-sub-account/transfer-api/transferToMaster.ts @@ -24,7 +24,7 @@ export function registerBinanceSubAccountTransferToMaster(server: McpServer) { }, async (params) => { try { - const response = await spotClient.restAPI.subAccountTransferSubToMaster({ + const response = await (spotClient as any).restAPI.subAccountTransferSubToMaster({ asset: params.asset, amount: params.amount, ...(params.recvWindow && { recvWindow: params.recvWindow }), diff --git a/src/tools/binance-sub-account/transfer-api/transferToSubAccount.ts b/src/tools/binance-sub-account/transfer-api/transferToSubAccount.ts index e0838b8b..a3861a6d 100644 --- a/src/tools/binance-sub-account/transfer-api/transferToSubAccount.ts +++ b/src/tools/binance-sub-account/transfer-api/transferToSubAccount.ts @@ -26,7 +26,7 @@ export function registerBinanceSubAccountTransferToSub(server: McpServer) { }, async (params) => { try { - const response = await spotClient.restAPI.subAccountTransferSubToSub({ + const response = await (spotClient as any).restAPI.subAccountTransferSubToSub({ toEmail: params.toEmail, asset: params.asset, amount: params.amount, diff --git a/src/tools/binance-sub-account/transfer-api/universalTransfer.ts b/src/tools/binance-sub-account/transfer-api/universalTransfer.ts index af835961..3c082f16 100644 --- a/src/tools/binance-sub-account/transfer-api/universalTransfer.ts +++ b/src/tools/binance-sub-account/transfer-api/universalTransfer.ts @@ -43,7 +43,7 @@ export function registerBinanceSubAccountUniversalTransfer(server: McpServer) { }, async (params) => { try { - const response = await spotClient.restAPI.universalTransfer({ + const response = await (spotClient as any).restAPI.universalTransfer({ fromAccountType: params.fromAccountType, toAccountType: params.toAccountType, asset: params.asset, diff --git a/src/tools/binance-wallet/account-api/accountApiTradingStatus.ts b/src/tools/binance-wallet/account-api/accountApiTradingStatus.ts index 798d26c2..99e08066 100644 --- a/src/tools/binance-wallet/account-api/accountApiTradingStatus.ts +++ b/src/tools/binance-wallet/account-api/accountApiTradingStatus.ts @@ -19,7 +19,7 @@ export function registerBinanceWalletAccountApiTradingStatus(server: McpServer) const params: any = {}; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.accountApiTradingStatus(params); + const response = await (walletClient as any).restAPI.accountApiTradingStatus(params); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/account-api/accountInfo.ts b/src/tools/binance-wallet/account-api/accountInfo.ts index 16e6c3d8..74e27c16 100644 --- a/src/tools/binance-wallet/account-api/accountInfo.ts +++ b/src/tools/binance-wallet/account-api/accountInfo.ts @@ -19,7 +19,7 @@ export function registerBinanceWalletAccountInfo(server: McpServer) { const params: any = {}; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.accountInfo(params); + const response = await (walletClient as any).restAPI.accountInfo(params); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/account-api/accountStatus.ts b/src/tools/binance-wallet/account-api/accountStatus.ts index e07e0734..e76fb3b2 100644 --- a/src/tools/binance-wallet/account-api/accountStatus.ts +++ b/src/tools/binance-wallet/account-api/accountStatus.ts @@ -19,7 +19,7 @@ export function registerBinanceWalletAccountStatus(server: McpServer) { const params: any = {}; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.accountStatus(params); + const response = await (walletClient as any).restAPI.accountStatus(params); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/account-api/dailyAccountSnapshot.ts b/src/tools/binance-wallet/account-api/dailyAccountSnapshot.ts index 6b14d247..388a6906 100644 --- a/src/tools/binance-wallet/account-api/dailyAccountSnapshot.ts +++ b/src/tools/binance-wallet/account-api/dailyAccountSnapshot.ts @@ -26,7 +26,7 @@ export function registerBinanceWalletDailyAccountSnapshot(server: McpServer) { if (limit !== undefined) params.limit = limit; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.dailyAccountSnapshot(params); + const response = await (walletClient as any).restAPI.dailyAccountSnapshot(params); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/account-api/disableFastWithdrawSwitch.ts b/src/tools/binance-wallet/account-api/disableFastWithdrawSwitch.ts index 3c3a86ab..46b33792 100644 --- a/src/tools/binance-wallet/account-api/disableFastWithdrawSwitch.ts +++ b/src/tools/binance-wallet/account-api/disableFastWithdrawSwitch.ts @@ -19,7 +19,7 @@ export function registerBinanceWalletDisableFastWithdrawSwitch(server: McpServer const params: any = {}; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.disableFastWithdrawSwitch(params); + const response = await (walletClient as any).restAPI.disableFastWithdrawSwitch(params); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/account-api/enableFastWithdrawSwitch.ts b/src/tools/binance-wallet/account-api/enableFastWithdrawSwitch.ts index e9e163ff..b4d54e4b 100644 --- a/src/tools/binance-wallet/account-api/enableFastWithdrawSwitch.ts +++ b/src/tools/binance-wallet/account-api/enableFastWithdrawSwitch.ts @@ -19,7 +19,7 @@ export function registerBinanceWalletEnableFastWithdrawSwitch(server: McpServer) const params: any = {}; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.enableFastWithdrawSwitch(params); + const response = await (walletClient as any).restAPI.enableFastWithdrawSwitch(params); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/account-api/getApiKeyPermission.ts b/src/tools/binance-wallet/account-api/getApiKeyPermission.ts index fa9634a7..cab47335 100644 --- a/src/tools/binance-wallet/account-api/getApiKeyPermission.ts +++ b/src/tools/binance-wallet/account-api/getApiKeyPermission.ts @@ -19,7 +19,7 @@ export function registerBinanceWalletGetApiKeyPermission(server: McpServer) { const params: any = {}; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.getApiKeyPermission(params); + const response = await (walletClient as any).restAPI.getApiKeyPermission(params); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/asset-api/assetDetail.ts b/src/tools/binance-wallet/asset-api/assetDetail.ts index 515bb0c6..c4f5a55b 100644 --- a/src/tools/binance-wallet/asset-api/assetDetail.ts +++ b/src/tools/binance-wallet/asset-api/assetDetail.ts @@ -21,7 +21,7 @@ export function registerBinanceWalletAssetDetail(server: McpServer) { if (asset !== undefined) params.asset = asset; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.assetDetail(params); + const response = await (walletClient as any).restAPI.assetDetail(params); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/asset-api/assetDividendRecord.ts b/src/tools/binance-wallet/asset-api/assetDividendRecord.ts index 1edbc26d..29dbba85 100644 --- a/src/tools/binance-wallet/asset-api/assetDividendRecord.ts +++ b/src/tools/binance-wallet/asset-api/assetDividendRecord.ts @@ -27,7 +27,7 @@ export function registerBinanceWalletAssetDividendRecord(server: McpServer) { if (limit !== undefined) params.limit = limit; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.assetDividendRecord(params); + const response = await (walletClient as any).restAPI.assetDividendRecord(params); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/asset-api/dustTransfer.ts b/src/tools/binance-wallet/asset-api/dustTransfer.ts index 0f04581a..0be0bdb5 100644 --- a/src/tools/binance-wallet/asset-api/dustTransfer.ts +++ b/src/tools/binance-wallet/asset-api/dustTransfer.ts @@ -20,7 +20,7 @@ export function registerBinanceWalletDustTransfer(server: McpServer) { const params: any = { asset }; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.dustTransfer(params); + const response = await (walletClient as any).restAPI.dustTransfer(params); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/asset-api/dustlog.ts b/src/tools/binance-wallet/asset-api/dustlog.ts index c42e419f..c1ccd2d6 100644 --- a/src/tools/binance-wallet/asset-api/dustlog.ts +++ b/src/tools/binance-wallet/asset-api/dustlog.ts @@ -23,7 +23,7 @@ export function registerBinanceWalletDustlog(server: McpServer) { if (endTime !== undefined) params.endTime = endTime; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.dustlog(params); + const response = await (walletClient as any).restAPI.dustlog(params); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/asset-api/fundingWallet.ts b/src/tools/binance-wallet/asset-api/fundingWallet.ts index 8403e5ae..226a7bc6 100644 --- a/src/tools/binance-wallet/asset-api/fundingWallet.ts +++ b/src/tools/binance-wallet/asset-api/fundingWallet.ts @@ -23,7 +23,7 @@ export function registerBinanceWalletFundingWallet(server: McpServer) { if (needBtcValuation !== undefined) params.needBtcValuation = needBtcValuation; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.fundingWallet(params); + const response = await (walletClient as any).restAPI.fundingWallet(params); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts b/src/tools/binance-wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts index 4476777a..f969e0c5 100644 --- a/src/tools/binance-wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts +++ b/src/tools/binance-wallet/asset-api/getAssetsThatCanBeConvertedIntoBnb.ts @@ -19,7 +19,9 @@ export function registerBinanceWalletGetAssetsThatCanBeConvertedIntoBnb(server: const params: any = {}; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.getAssetsThatCanBeConvertedIntoBnb(params); + const response = await (walletClient as any).restAPI.getAssetsThatCanBeConvertedIntoBnb( + params, + ); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts b/src/tools/binance-wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts index 4aaf8156..4953b9e6 100644 --- a/src/tools/binance-wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts +++ b/src/tools/binance-wallet/asset-api/getCloudMiningPaymentAndRefundHistory.ts @@ -28,7 +28,9 @@ export function registerBinanceWalletGetCloudMiningPaymentAndRefundHistory(serve if (pageSize !== undefined) params.pageSize = pageSize; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.getCloudMiningPaymentAndRefundHistory(params); + const response = await (walletClient as any).restAPI.getCloudMiningPaymentAndRefundHistory( + params, + ); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/asset-api/getOpenSymbolList.ts b/src/tools/binance-wallet/asset-api/getOpenSymbolList.ts index 1e575b53..ce26b78e 100644 --- a/src/tools/binance-wallet/asset-api/getOpenSymbolList.ts +++ b/src/tools/binance-wallet/asset-api/getOpenSymbolList.ts @@ -9,7 +9,7 @@ export function registerBinanceWalletGetOpenSymbolList(server: McpServer) { { description: "Get open symbol list." }, async () => { try { - const response = await walletClient.restAPI.getOpenSymbolList(); + const response = await (walletClient as any).restAPI.getOpenSymbolList(); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/asset-api/queryUserDelegationHistory.ts b/src/tools/binance-wallet/asset-api/queryUserDelegationHistory.ts index 679e40ff..b2e75a0f 100644 --- a/src/tools/binance-wallet/asset-api/queryUserDelegationHistory.ts +++ b/src/tools/binance-wallet/asset-api/queryUserDelegationHistory.ts @@ -30,7 +30,7 @@ export function registerBinanceWalletQueryUserDelegationHistory(server: McpServe if (limit !== undefined) params.limit = limit; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.queryUserDelegationHistory(params); + const response = await (walletClient as any).restAPI.queryUserDelegationHistory(params); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/asset-api/queryUserUniversalTransferHistory.ts b/src/tools/binance-wallet/asset-api/queryUserUniversalTransferHistory.ts index 32c1f6f8..edfa2703 100644 --- a/src/tools/binance-wallet/asset-api/queryUserUniversalTransferHistory.ts +++ b/src/tools/binance-wallet/asset-api/queryUserUniversalTransferHistory.ts @@ -32,7 +32,9 @@ export function registerBinanceWalletQueryUserUniversalTransferHistory(server: M if (toSymbol !== undefined) params.toSymbol = toSymbol; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.queryUserUniversalTransferHistory(params); + const response = await (walletClient as any).restAPI.queryUserUniversalTransferHistory( + params, + ); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/asset-api/queryUserWalletBalance.ts b/src/tools/binance-wallet/asset-api/queryUserWalletBalance.ts index a56c9a84..2a1520fb 100644 --- a/src/tools/binance-wallet/asset-api/queryUserWalletBalance.ts +++ b/src/tools/binance-wallet/asset-api/queryUserWalletBalance.ts @@ -19,7 +19,7 @@ export function registerBinanceWalletQueryUserWalletBalance(server: McpServer) { const params: any = {}; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.queryUserWalletBalance(params); + const response = await (walletClient as any).restAPI.queryUserWalletBalance(params); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts b/src/tools/binance-wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts index 6cd869d0..688fcb5b 100644 --- a/src/tools/binance-wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts +++ b/src/tools/binance-wallet/asset-api/toggleBnbBurnOnSpotTradeAndMarginInterest.ts @@ -23,8 +23,9 @@ export function registerBinanceWalletToggleBnbBurnOnSpotTradeAndMarginInterest(s if (interestBNBBurn !== undefined) params.interestBNBBurn = interestBNBBurn; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = - await walletClient.restAPI.toggleBnbBurnOnSpotTradeAndMarginInterest(params); + const response = await ( + walletClient as any + ).restAPI.toggleBnbBurnOnSpotTradeAndMarginInterest(params); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/asset-api/tradeFee.ts b/src/tools/binance-wallet/asset-api/tradeFee.ts index 6cb90d45..6861de41 100644 --- a/src/tools/binance-wallet/asset-api/tradeFee.ts +++ b/src/tools/binance-wallet/asset-api/tradeFee.ts @@ -21,7 +21,7 @@ export function registerBinanceWalletTradeFee(server: McpServer) { if (symbol !== undefined) params.symbol = symbol; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.tradeFee(params); + const response = await (walletClient as any).restAPI.tradeFee(params); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/asset-api/userAsset.ts b/src/tools/binance-wallet/asset-api/userAsset.ts index ee4207a6..b9122d07 100644 --- a/src/tools/binance-wallet/asset-api/userAsset.ts +++ b/src/tools/binance-wallet/asset-api/userAsset.ts @@ -21,7 +21,7 @@ export function registerBinanceWalletUserAsset(server: McpServer) { if (recvWindow !== undefined) params.recvWindow = recvWindow; if (needBtcValuation !== undefined) params.needBtcValuation = needBtcValuation; - const response = await walletClient.restAPI.userAsset(params); + const response = await (walletClient as any).restAPI.userAsset(params); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/asset-api/userUniversalTransfer.ts b/src/tools/binance-wallet/asset-api/userUniversalTransfer.ts index d59f97c8..0f9527e2 100644 --- a/src/tools/binance-wallet/asset-api/userUniversalTransfer.ts +++ b/src/tools/binance-wallet/asset-api/userUniversalTransfer.ts @@ -30,7 +30,7 @@ export function registerBinanceWalletUserUniversalTransfer(server: McpServer) { if (toSymbol !== undefined) params.toSymbol = toSymbol; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.userUniversalTransfer(params); + const response = await (walletClient as any).restAPI.userUniversalTransfer(params); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/capital-api/allCoinsInformation.ts b/src/tools/binance-wallet/capital-api/allCoinsInformation.ts index 661a3983..5d998209 100644 --- a/src/tools/binance-wallet/capital-api/allCoinsInformation.ts +++ b/src/tools/binance-wallet/capital-api/allCoinsInformation.ts @@ -19,7 +19,7 @@ export function registerBinanceWalletAllCoinsInformation(server: McpServer) { const params: any = {}; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.allCoinsInformation(params); + const response = await (walletClient as any).restAPI.allCoinsInformation(params); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/capital-api/depositAddress.ts b/src/tools/binance-wallet/capital-api/depositAddress.ts index 49dc9a1d..0ecb0015 100644 --- a/src/tools/binance-wallet/capital-api/depositAddress.ts +++ b/src/tools/binance-wallet/capital-api/depositAddress.ts @@ -22,7 +22,7 @@ export function registerBinanceWalletDepositAddress(server: McpServer) { if (network !== undefined) params.network = network; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.depositAddress(params); + const response = await (walletClient as any).restAPI.depositAddress(params); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/capital-api/depositHistory.ts b/src/tools/binance-wallet/capital-api/depositHistory.ts index f654bcc8..67729320 100644 --- a/src/tools/binance-wallet/capital-api/depositHistory.ts +++ b/src/tools/binance-wallet/capital-api/depositHistory.ts @@ -31,7 +31,7 @@ export function registerBinanceWalletDepositHistory(server: McpServer) { if (limit !== undefined) params.limit = limit; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.depositHistory(params); + const response = await (walletClient as any).restAPI.depositHistory(params); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/capital-api/fetchDepositAddressListWithNetwork.ts b/src/tools/binance-wallet/capital-api/fetchDepositAddressListWithNetwork.ts index 2b3c1d58..684fa6c5 100644 --- a/src/tools/binance-wallet/capital-api/fetchDepositAddressListWithNetwork.ts +++ b/src/tools/binance-wallet/capital-api/fetchDepositAddressListWithNetwork.ts @@ -22,7 +22,9 @@ export function registerBinanceWalletFetchDepositAddressListWithNetwork(server: if (network !== undefined) params.network = network; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.fetchDepositAddressListWithNetwork(params); + const response = await (walletClient as any).restAPI.fetchDepositAddressListWithNetwork( + params, + ); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/capital-api/fetchWithdrawAddressList.ts b/src/tools/binance-wallet/capital-api/fetchWithdrawAddressList.ts index 954e3bb9..10f899eb 100644 --- a/src/tools/binance-wallet/capital-api/fetchWithdrawAddressList.ts +++ b/src/tools/binance-wallet/capital-api/fetchWithdrawAddressList.ts @@ -9,7 +9,7 @@ export function registerBinanceWalletFetchWithdrawAddressList(server: McpServer) { description: "Fetch withdraw address list." }, async () => { try { - const response = await walletClient.restAPI.fetchWithdrawAddressList(); + const response = await (walletClient as any).restAPI.fetchWithdrawAddressList(); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/capital-api/oneClickArrivalDepositApply.ts b/src/tools/binance-wallet/capital-api/oneClickArrivalDepositApply.ts index 7d9b28f8..794acc72 100644 --- a/src/tools/binance-wallet/capital-api/oneClickArrivalDepositApply.ts +++ b/src/tools/binance-wallet/capital-api/oneClickArrivalDepositApply.ts @@ -21,7 +21,7 @@ export function registerBinanceWalletOneClickArrivalDepositApply(server: McpServ if (subAccountId !== undefined) params.subAccountId = subAccountId; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.oneClickArrivalDepositApply(params); + const response = await (walletClient as any).restAPI.oneClickArrivalDepositApply(params); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/capital-api/withdraw.ts b/src/tools/binance-wallet/capital-api/withdraw.ts index a0779f6f..c759c25a 100644 --- a/src/tools/binance-wallet/capital-api/withdraw.ts +++ b/src/tools/binance-wallet/capital-api/withdraw.ts @@ -49,7 +49,7 @@ export function registerBinanceWalletWithdraw(server: McpServer) { if (transactionFeeFlag !== undefined) params.transactionFeeFlag = transactionFeeFlag; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.withdraw(params); + const response = await (walletClient as any).restAPI.withdraw(params); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/capital-api/withdrawHistory.ts b/src/tools/binance-wallet/capital-api/withdrawHistory.ts index 3f1387b4..e9c7cec7 100644 --- a/src/tools/binance-wallet/capital-api/withdrawHistory.ts +++ b/src/tools/binance-wallet/capital-api/withdrawHistory.ts @@ -33,7 +33,7 @@ export function registerBinanceWalletWithdrawHistory(server: McpServer) { if (limit !== undefined) params.limit = limit; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.withdrawHistory(params); + const response = await (walletClient as any).restAPI.withdrawHistory(params); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/others-api/getSymbolsDelistScheduleForSpot.ts b/src/tools/binance-wallet/others-api/getSymbolsDelistScheduleForSpot.ts index 1e61100b..3ef67fe7 100644 --- a/src/tools/binance-wallet/others-api/getSymbolsDelistScheduleForSpot.ts +++ b/src/tools/binance-wallet/others-api/getSymbolsDelistScheduleForSpot.ts @@ -9,7 +9,7 @@ export function registerBinanceWalletGetSymbolsDelistScheduleForSpot(server: Mcp { description: "Get delist schedule for spot symbols." }, async () => { try { - const response = await walletClient.restAPI.getSymbolsDelistScheduleForSpot(); + const response = await (walletClient as any).restAPI.getSymbolsDelistScheduleForSpot(); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/others-api/systemStatus.ts b/src/tools/binance-wallet/others-api/systemStatus.ts index 59a2d1fa..f218dcdd 100644 --- a/src/tools/binance-wallet/others-api/systemStatus.ts +++ b/src/tools/binance-wallet/others-api/systemStatus.ts @@ -9,7 +9,7 @@ export function registerBinanceWalletSystemStatus(server: McpServer) { { description: "Get Binance Wallet system status." }, async () => { try { - const response = await walletClient.restAPI.systemStatus(); + const response = await (walletClient as any).restAPI.systemStatus(); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/travel-rule-api/brokerWithdraw.ts b/src/tools/binance-wallet/travel-rule-api/brokerWithdraw.ts index bd2e8553..e2a34782 100644 --- a/src/tools/binance-wallet/travel-rule-api/brokerWithdraw.ts +++ b/src/tools/binance-wallet/travel-rule-api/brokerWithdraw.ts @@ -55,7 +55,7 @@ export function registerBinanceWalletBrokerWithdraw(server: McpServer) { if (name !== undefined) params.name = name; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.brokerWithdraw(params); + const response = await (walletClient as any).restAPI.brokerWithdraw(params); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/travel-rule-api/depositHistoryTravelRule.ts b/src/tools/binance-wallet/travel-rule-api/depositHistoryTravelRule.ts index c2c76658..4ef383c4 100644 --- a/src/tools/binance-wallet/travel-rule-api/depositHistoryTravelRule.ts +++ b/src/tools/binance-wallet/travel-rule-api/depositHistoryTravelRule.ts @@ -31,7 +31,7 @@ export function registerBinanceWalletDepositHistoryTravelRule(server: McpServer) if (limit !== undefined) params.limit = limit; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.depositHistoryTravelRule(params); + const response = await (walletClient as any).restAPI.depositHistoryTravelRule(params); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/travel-rule-api/onboardedVaspList.ts b/src/tools/binance-wallet/travel-rule-api/onboardedVaspList.ts index 98e0ff33..8b063cf5 100644 --- a/src/tools/binance-wallet/travel-rule-api/onboardedVaspList.ts +++ b/src/tools/binance-wallet/travel-rule-api/onboardedVaspList.ts @@ -9,7 +9,7 @@ export function registerBinanceWalletOnboardedVaspList(server: McpServer) { { description: "Get list of onboarded VASPs (Virtual Asset Service Providers)." }, async () => { try { - const response = await walletClient.restAPI.onboardedVaspList(); + const response = await (walletClient as any).restAPI.onboardedVaspList(); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaire.ts b/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaire.ts index 588322ed..350be6f0 100644 --- a/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaire.ts +++ b/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaire.ts @@ -30,7 +30,7 @@ export function registerBinanceWalletSubmitDepositQuestionnaire(server: McpServe }; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.submitDepositQuestionnaire(params); + const response = await (walletClient as any).restAPI.submitDepositQuestionnaire(params); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts b/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts index 674df61b..95aadcf7 100644 --- a/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts +++ b/src/tools/binance-wallet/travel-rule-api/submitDepositQuestionnaireTravelRule.ts @@ -24,7 +24,9 @@ export function registerBinanceWalletSubmitDepositQuestionnaireTravelRule(server }; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.submitDepositQuestionnaireTravelRule(params); + const response = await (walletClient as any).restAPI.submitDepositQuestionnaireTravelRule( + params, + ); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV1.ts b/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV1.ts index fe55168a..9cdee180 100644 --- a/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV1.ts +++ b/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV1.ts @@ -31,7 +31,7 @@ export function registerBinanceWalletWithdrawHistoryV1(server: McpServer) { if (limit !== undefined) params.limit = limit; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.withdrawHistoryV1(params); + const response = await (walletClient as any).restAPI.withdrawHistoryV1(params); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV2.ts b/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV2.ts index d61d6dc9..596e4d97 100644 --- a/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV2.ts +++ b/src/tools/binance-wallet/travel-rule-api/withdrawHistoryV2.ts @@ -31,7 +31,7 @@ export function registerBinanceWalletWithdrawHistoryV2(server: McpServer) { if (limit !== undefined) params.limit = limit; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.withdrawHistoryV2(params); + const response = await (walletClient as any).restAPI.withdrawHistoryV2(params); const data = await response.data(); return { diff --git a/src/tools/binance-wallet/travel-rule-api/withdrawTravelRule.ts b/src/tools/binance-wallet/travel-rule-api/withdrawTravelRule.ts index 279066f1..e0c08765 100644 --- a/src/tools/binance-wallet/travel-rule-api/withdrawTravelRule.ts +++ b/src/tools/binance-wallet/travel-rule-api/withdrawTravelRule.ts @@ -46,7 +46,7 @@ export function registerBinanceWalletWithdrawTravelRule(server: McpServer) { if (name !== undefined) params.name = name; if (recvWindow !== undefined) params.recvWindow = recvWindow; - const response = await walletClient.restAPI.withdrawTravelRule(params); + const response = await (walletClient as any).restAPI.withdrawTravelRule(params); const data = await response.data(); return { diff --git a/src/tools/binanceSpotPlaceOrder.ts b/src/tools/binanceSpotPlaceOrder.ts index a46cb86f..1aca1f9d 100644 --- a/src/tools/binanceSpotPlaceOrder.ts +++ b/src/tools/binanceSpotPlaceOrder.ts @@ -9,21 +9,22 @@ import { spotClient } from "../config/client.js"; export function registerBinanceSpotPlaceOrder(server: McpServer) { server.registerTool( "binanceSpotPlaceOrder", - {}, - `Trading for small orders will not generate significant selling pressure on the market`, { - symbol: z.string().describe("symbol: exemple: BTCUSDT"), - side: z.enum(["BUY", "SELL"]).describe("BUY or SELL"), - quantity: z.number().describe("quantity Quantity of base asset").optional(), - quoteOrderQty: z - .number() - .describe( - `MARKET orders using quoteOrderQty specifies the amount the user wants to spend (when buying) or receive (when selling) the quote asset; the correct quantity will be determined based on the market liquidity and quoteOrderQty. + description: `Trading for small orders will not generate significant selling pressure on the market`, + inputSchema: { + symbol: z.string().describe("symbol: exemple: BTCUSDT"), + side: z.enum(["BUY", "SELL"]).describe("BUY or SELL"), + quantity: z.number().describe("quantity Quantity of base asset").optional(), + quoteOrderQty: z + .number() + .describe( + `MARKET orders using quoteOrderQty specifies the amount the user wants to spend (when buying) or receive (when selling) the quote asset; the correct quantity will be determined based on the market liquidity and quoteOrderQty. E.g. Using the symbol BTCUSDT: BUY side, the order will buy as many BTC as quoteOrderQty USDT can. SELL side, the order will sell as much BTC needed to receive quoteOrderQty USDT.`, - ) - .optional(), + ) + .optional(), + }, }, async ({ symbol, side, quantity, quoteOrderQty }) => { try { diff --git a/src/tools/binanceTimeWeightedAveragePriceFutureAlgo.ts b/src/tools/binanceTimeWeightedAveragePriceFutureAlgo.ts index 450ef1b8..b717697d 100644 --- a/src/tools/binanceTimeWeightedAveragePriceFutureAlgo.ts +++ b/src/tools/binanceTimeWeightedAveragePriceFutureAlgo.ts @@ -7,17 +7,18 @@ import { algoClient } from "../config/client.js"; export function registerBinanceTimeWeightedAveragePriceFutureAlgo(server: McpServer) { server.registerTool( "binanceTimeWeightedAveragePriceFutureAlgo", - {}, - `Place a new spot TWAP order with Algo service. Trading for large orders can generate significant selling pressure on the market`, { - symbol: z.string().describe("symbol: exemple: BTCUSDT"), - side: z.enum(["BUY", "SELL"]).describe("BUY or SELL"), - quantity: z - .number() - .describe( - "quantity Quantity of base asset; Maximum notional per order is 200k, 2mm or 10mm, depending on symbol. Please reduce your size if you order is above the maximum notional per order.", - ), - duration: z.number().describe("duration Duration for TWAP orders in seconds. [300, 86400]"), + description: `Place a new spot TWAP order with Algo service. Trading for large orders can generate significant selling pressure on the market`, + inputSchema: { + symbol: z.string().describe("symbol: exemple: BTCUSDT"), + side: z.enum(["BUY", "SELL"]).describe("BUY or SELL"), + quantity: z + .number() + .describe( + "quantity Quantity of base asset; Maximum notional per order is 200k, 2mm or 10mm, depending on symbol. Please reduce your size if you order is above the maximum notional per order.", + ), + duration: z.number().describe("duration Duration for TWAP orders in seconds. [300, 86400]"), + }, }, async ({ symbol, side, quantity, duration }) => { try { diff --git a/src/tools/credit-line/index.ts b/src/tools/credit-line/index.ts index e8ac95e9..84479f7a 100644 --- a/src/tools/credit-line/index.ts +++ b/src/tools/credit-line/index.ts @@ -30,8 +30,8 @@ export function registerCreditLineTools(server: McpServer) { // ===================================================================== server.registerTool( "binance_us_cl_account", - {}, - `Get current credit line account information including LTV ratios, balances, and loan details. + { + description: `Get current credit line account information including LTV ratios, balances, and loan details. ⚠️ REQUIRES CREDIT LINE API KEY - Standard API keys will not work. ⚠️ Requires institutional credit line agreement with Binance.US. @@ -48,8 +48,9 @@ Returns comprehensive account information including: - availableAmountToTransferOut: How much can be withdrawn - loanAssets: Details of borrowed assets - balances: Current asset balances (collateral)`, - { - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + inputSchema: { + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async (params) => { try { @@ -111,8 +112,8 @@ Available to Withdraw: ${response.availableAmountToTransferOut}`; // ===================================================================== server.registerTool( "binance_us_cl_alert_history", - {}, - `Get margin call and liquidation alert history for your credit line account. + { + description: `Get margin call and liquidation alert history for your credit line account. ⚠️ REQUIRES CREDIT LINE API KEY - Standard API keys will not work. ⚠️ Requires institutional credit line agreement with Binance.US. @@ -128,15 +129,16 @@ Returns alert records including: Use this to monitor your account's health history and understand when margin calls or liquidation warnings have occurred.`, - { - alertType: z - .enum(["MARGIN_CALL", "LIQUIDATION_CALL"]) - .optional() - .describe("Filter by alert type"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Number of results. Default: 200"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + inputSchema: { + alertType: z + .enum(["MARGIN_CALL", "LIQUIDATION_CALL"]) + .optional() + .describe("Filter by alert type"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Number of results. Default: 200"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async (params) => { try { @@ -186,8 +188,8 @@ when margin calls or liquidation warnings have occurred.`, // ===================================================================== server.registerTool( "binance_us_cl_transfer_history", - {}, - `Get transfer history for your credit line account. + { + description: `Get transfer history for your credit line account. ⚠️ REQUIRES CREDIT LINE API KEY - Standard API keys will not work. ⚠️ Requires institutional credit line agreement with Binance.US. @@ -201,16 +203,17 @@ Returns transfer records including: - transferTime: When the transfer occurred Use this to track deposits and withdrawals from your credit line account.`, - { - transferType: z - .enum(["TRANSFER_IN", "TRANSFER_OUT"]) - .optional() - .describe("Filter by transfer type"), - asset: z.string().optional().describe("Filter by asset, e.g., BTC, USD"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - limit: z.number().optional().describe("Number of results. Default: 20, Max: 100"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + inputSchema: { + transferType: z + .enum(["TRANSFER_IN", "TRANSFER_OUT"]) + .optional() + .describe("Filter by transfer type"), + asset: z.string().optional().describe("Filter by asset, e.g., BTC, USD"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + limit: z.number().optional().describe("Number of results. Default: 20, Max: 100"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async (params) => { try { @@ -266,8 +269,8 @@ Use this to track deposits and withdrawals from your credit line account.`, // ===================================================================== server.registerTool( "binance_us_cl_transfer", - {}, - `Transfer assets in or out of your credit line account. + { + description: `Transfer assets in or out of your credit line account. ⚠️ REQUIRES CREDIT LINE API KEY - Standard API keys will not work. ⚠️ Requires institutional credit line agreement with Binance.US. @@ -279,13 +282,14 @@ Transfer types: Note: Transferring out may be restricted if it would cause LTV to exceed limits. Check availableAmountToTransferOut in binance_us_cl_account first.`, - { - transferType: z - .enum(["TRANSFER_IN", "TRANSFER_OUT"]) - .describe("Direction: TRANSFER_IN (deposit) or TRANSFER_OUT (withdraw)"), - transferAssetType: z.string().describe("Asset to transfer, e.g., BTC, USD"), - quantity: z.number().positive().describe("Amount to transfer"), - recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + inputSchema: { + transferType: z + .enum(["TRANSFER_IN", "TRANSFER_OUT"]) + .describe("Direction: TRANSFER_IN (deposit) or TRANSFER_OUT (withdraw)"), + transferAssetType: z.string().describe("Asset to transfer, e.g., BTC, USD"), + quantity: z.number().positive().describe("Amount to transfer"), + recvWindow: z.number().optional().describe("The value cannot be greater than 60000"), + }, }, async (params) => { try { diff --git a/src/tools/creditline/index.ts b/src/tools/creditline/index.ts index 7418a04a..3a3a0566 100644 --- a/src/tools/creditline/index.ts +++ b/src/tools/creditline/index.ts @@ -25,8 +25,8 @@ export function registerCreditLineTools(server: McpServer) { // ===================================================================== server.registerTool( "binance_us_cl_account", - {}, - `Get comprehensive credit line account information. + { + description: `Get comprehensive credit line account information. ⚠️ REQUIRES INSTITUTIONAL CREDIT LINE AGREEMENT This API is only available to institutional users with approved credit facilities. @@ -61,18 +61,21 @@ Loan Information: Balances: - balances: Array of asset balances (free, locked)`, - { - recvWindow: z - .number() - .int() - .max(60000) - .optional() - .describe("Request validity window in ms (max: 60000)"), + inputSchema: { + recvWindow: z + .number() + .int() + .max(60000) + .optional() + .describe("Request validity window in ms (max: 60000)"), + }, }, - async (params) => { + async (params: Record) => { try { const response = await makeSignedRequest("GET", "/sapi/v2/cl/account", { - ...(params.recvWindow && { recvWindow: params.recvWindow }), + ...(params.recvWindow != null && { + recvWindow: params.recvWindow as number, + }), }); // Calculate risk level based on LTV @@ -121,8 +124,8 @@ Full Response: ${JSON.stringify(response, null, 2)}`, // ===================================================================== server.registerTool( "binance_us_cl_alert_history", - {}, - `Get margin call and liquidation alert history for credit line account. + { + description: `Get margin call and liquidation alert history for credit line account. ⚠️ REQUIRES INSTITUTIONAL CREDIT LINE AGREEMENT @@ -143,27 +146,28 @@ Use this to: - Review past risk events - Understand account risk patterns - Audit margin call history`, - { - startTime: z.number().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().optional().describe("End timestamp in milliseconds"), - limit: z - .number() - .int() - .min(1) - .max(1000) - .optional() - .default(200) - .describe("Max records (default: 200)"), - alertType: z - .enum(["LIQUIDATION_CALL", "MARGIN_CALL"]) - .optional() - .describe("Filter by alert type"), - recvWindow: z - .number() - .int() - .max(60000) - .optional() - .describe("Request validity window (max: 60000)"), + inputSchema: { + startTime: z.number().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().optional().describe("End timestamp in milliseconds"), + limit: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .default(200) + .describe("Max records (default: 200)"), + alertType: z + .enum(["LIQUIDATION_CALL", "MARGIN_CALL"]) + .optional() + .describe("Filter by alert type"), + recvWindow: z + .number() + .int() + .max(60000) + .optional() + .describe("Request validity window (max: 60000)"), + }, }, async (params) => { try { @@ -211,8 +215,8 @@ Full Response: ${JSON.stringify(response, null, 2)}`, // ===================================================================== server.registerTool( "binance_us_cl_transfer_history", - {}, - `Get transfer history for credit line account. + { + description: `Get transfer history for credit line account. ⚠️ REQUIRES INSTITUTIONAL CREDIT LINE AGREEMENT @@ -232,28 +236,29 @@ Use this to: - Track collateral movements - Audit deposit/withdrawal history - Reconcile account activity`, - { - startTime: z.number().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().optional().describe("End timestamp in milliseconds"), - limit: z - .number() - .int() - .min(1) - .max(100) - .optional() - .default(20) - .describe("Max records (default: 20, max: 100)"), - transferType: z - .enum(["TRANSFER_IN", "TRANSFER_OUT"]) - .optional() - .describe("Filter by transfer direction"), - asset: z.string().optional().describe("Filter by asset (e.g., BTC, USD)"), - recvWindow: z - .number() - .int() - .max(60000) - .optional() - .describe("Request validity window (max: 60000)"), + inputSchema: { + startTime: z.number().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().optional().describe("End timestamp in milliseconds"), + limit: z + .number() + .int() + .min(1) + .max(100) + .optional() + .default(20) + .describe("Max records (default: 20, max: 100)"), + transferType: z + .enum(["TRANSFER_IN", "TRANSFER_OUT"]) + .optional() + .describe("Filter by transfer direction"), + asset: z.string().optional().describe("Filter by asset (e.g., BTC, USD)"), + recvWindow: z + .number() + .int() + .max(60000) + .optional() + .describe("Request validity window (max: 60000)"), + }, }, async (params) => { try { @@ -300,8 +305,8 @@ Full Response: ${JSON.stringify(response, null, 2)}`, // ===================================================================== server.registerTool( "binance_us_cl_transfer", - {}, - `Execute a transfer in or out of the credit line account. + { + description: `Execute a transfer in or out of the credit line account. ⚠️ REQUIRES INSTITUTIONAL CREDIT LINE AGREEMENT @@ -321,18 +326,19 @@ Transfer Types: Response includes: - transferId: Unique transfer identifier - status: SUCCESS, PENDING, or FAILED`, - { - transferType: z - .enum(["TRANSFER_IN", "TRANSFER_OUT"]) - .describe("Direction: TRANSFER_IN (deposit) or TRANSFER_OUT (withdraw)"), - transferAssetType: z.string().describe("Asset to transfer (e.g., BTC, USD)"), - quantity: z.number().positive().describe("Amount to transfer"), - recvWindow: z - .number() - .int() - .max(60000) - .optional() - .describe("Request validity window (max: 60000)"), + inputSchema: { + transferType: z + .enum(["TRANSFER_IN", "TRANSFER_OUT"]) + .describe("Direction: TRANSFER_IN (deposit) or TRANSFER_OUT (withdraw)"), + transferAssetType: z.string().describe("Asset to transfer (e.g., BTC, USD)"), + quantity: z.number().positive().describe("Amount to transfer"), + recvWindow: z + .number() + .int() + .max(60000) + .optional() + .describe("Request validity window (max: 60000)"), + }, }, async (params) => { try { @@ -378,8 +384,8 @@ Full Response: ${JSON.stringify(response, null, 2)}`, // ===================================================================== server.registerTool( "binance_us_cl_liquidation_history", - {}, - `Get liquidation history for credit line account. + { + description: `Get liquidation history for credit line account. ⚠️ REQUIRES INSTITUTIONAL CREDIT LINE AGREEMENT @@ -396,23 +402,24 @@ Use this to: - Review past liquidation events - Understand liquidation patterns - Audit risk management effectiveness`, - { - startTime: z.number().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().optional().describe("End timestamp in milliseconds"), - limit: z - .number() - .int() - .min(1) - .max(100) - .optional() - .default(20) - .describe("Max records (default: 20, max: 100)"), - recvWindow: z - .number() - .int() - .max(60000) - .optional() - .describe("Request validity window (max: 60000)"), + inputSchema: { + startTime: z.number().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().optional().describe("End timestamp in milliseconds"), + limit: z + .number() + .int() + .min(1) + .max(100) + .optional() + .default(20) + .describe("Max records (default: 20, max: 100)"), + recvWindow: z + .number() + .int() + .max(60000) + .optional() + .describe("Request validity window (max: 60000)"), + }, }, async (params) => { try { diff --git a/src/tools/custodial-solution/index.ts b/src/tools/custodial-solution/index.ts index 1caa862c..fa4dde93 100644 --- a/src/tools/custodial-solution/index.ts +++ b/src/tools/custodial-solution/index.ts @@ -29,8 +29,8 @@ export function registerCustodialSolutionTools(server: McpServer) { // ===================================================================== server.registerTool( "binance_us_custodial_balance", - {}, - `Get balance information for Binance.US exchange wallet and custodial sub-account. + { + description: `Get balance information for Binance.US exchange wallet and custodial sub-account. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY - Regular API keys will not work. @@ -44,10 +44,14 @@ Each balance includes: - locked: Locked balance (in orders, etc.) - inSettlement: Amount in settlement process (custodial only) - lastUpdatedTime: Last update timestamp`, - { - rail: z.string().describe("Custodial partner identifier (all uppercase, e.g., 'FIREBLOCKS')"), + inputSchema: { + rail: z + .string() + .describe("Custodial partner identifier (all uppercase, e.g., 'FIREBLOCKS')"), + }, }, - async ({ rail }) => { + async (params: { rail: string }) => { + const { rail } = params; try { const response = await makeSignedRequest("GET", "/sapi/v1/custodian/balance", { rail: rail.toUpperCase(), @@ -77,8 +81,8 @@ Each balance includes: // ===================================================================== server.registerTool( "binance_us_custodial_supported_assets", - {}, - `Get list of assets supported for custodial transfers and settlements. + { + description: `Get list of assets supported for custodial transfers and settlements. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -90,10 +94,12 @@ Each asset includes: - asset: Asset symbol - precision: Decimal precision - network: Supported networks for the asset`, - { - rail: z.string().describe("Custodial partner identifier (all uppercase)"), + inputSchema: { + rail: z.string().describe("Custodial partner identifier (all uppercase)"), + }, }, - async ({ rail }) => { + async (params: { rail: string }) => { + const { rail } = params; try { const response = await makeSignedRequest("GET", "/sapi/v1/custodian/supportedAssetList", { rail: rail.toUpperCase(), @@ -123,22 +129,23 @@ Each asset includes: // ===================================================================== server.registerTool( "binance_us_custodial_wallet_transfer", - {}, - `Transfer assets from your Binance.US exchange wallet to your custodial sub-account. + { + description: `Transfer assets from your Binance.US exchange wallet to your custodial sub-account. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY ⚠️ This moves funds - verify details carefully! This transfers from your main Binance.US account to your custodial sub-account, which can then be traded or settled to your custodial partner.`, - { - rail: z.string().describe("Custodial partner identifier (all uppercase)"), - asset: z.string().describe("Asset to transfer (e.g., BTC, ETH)"), - amount: z.number().positive().describe("Amount to transfer"), - clientOrderId: z - .string() - .optional() - .describe("Your reference ID (auto-generated if not provided)"), + inputSchema: { + rail: z.string().describe("Custodial partner identifier (all uppercase)"), + asset: z.string().describe("Asset to transfer (e.g., BTC, ETH)"), + amount: z.number().positive().describe("Amount to transfer"), + clientOrderId: z + .string() + .optional() + .describe("Your reference ID (auto-generated if not provided)"), + }, }, async ({ rail, asset, amount, clientOrderId }) => { try { @@ -179,22 +186,23 @@ which can then be traded or settled to your custodial partner.`, // ===================================================================== server.registerTool( "binance_us_custodial_custodian_transfer", - {}, - `Request asset transfer from a custodial partner account to Binance.US custodial sub-account. + { + description: `Request asset transfer from a custodial partner account to Binance.US custodial sub-account. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY ⚠️ This initiates a transfer request to your custody partner! This requests your custodial partner to transfer assets to your Binance.US account. The actual transfer is executed by the custody partner.`, - { - rail: z.string().describe("Custodial partner identifier (all uppercase)"), - asset: z.string().describe("Asset to transfer (e.g., BTC, ETH)"), - amount: z.number().positive().describe("Amount to transfer"), - clientOrderId: z - .string() - .optional() - .describe("Your reference ID (auto-generated if not provided)"), + inputSchema: { + rail: z.string().describe("Custodial partner identifier (all uppercase)"), + asset: z.string().describe("Asset to transfer (e.g., BTC, ETH)"), + amount: z.number().positive().describe("Amount to transfer"), + clientOrderId: z + .string() + .optional() + .describe("Your reference ID (auto-generated if not provided)"), + }, }, async ({ rail, asset, amount, clientOrderId }) => { try { @@ -237,16 +245,17 @@ The actual transfer is executed by the custody partner.`, // ===================================================================== server.registerTool( "binance_us_custodial_undo_transfer", - {}, - `Undo a previous transfer from your custodial partner. + { + description: `Undo a previous transfer from your custodial partner. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY ⚠️ Only certain transfers can be undone - check with your custodial partner. This reverses a previous custodian transfer by its transfer ID.`, - { - rail: z.string().describe("Custodial partner identifier (all uppercase)"), - originTransferId: z.string().describe("The transfer ID of the original transfer to undo"), + inputSchema: { + rail: z.string().describe("Custodial partner identifier (all uppercase)"), + originTransferId: z.string().describe("The transfer ID of the original transfer to undo"), + }, }, async ({ rail, originTransferId }) => { try { @@ -279,24 +288,25 @@ This reverses a previous custodian transfer by its transfer ID.`, // ===================================================================== server.registerTool( "binance_us_custodial_wallet_transfer_history", - {}, - `Get history of transfers from Binance.US exchange wallet to custodial sub-account. + { + description: `Get history of transfers from Binance.US exchange wallet to custodial sub-account. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY Returns transfer history with status, amounts, and timestamps.`, - { - rail: z.string().describe("Custodial partner identifier (all uppercase)"), - transferId: z.string().optional().describe("Filter by specific transfer ID"), - clientOrderId: z.string().optional().describe("Filter by your reference ID"), - asset: z.string().optional().describe("Filter by asset (e.g., BTC)"), - startTime: z - .number() - .optional() - .describe("Start time in milliseconds (default: 90 days ago)"), - endTime: z.number().optional().describe("End time in milliseconds (default: now)"), - page: z.number().optional().describe("Page number (default: 1)"), - limit: z.number().optional().describe("Results per page (default: 20, max: 100)"), + inputSchema: { + rail: z.string().describe("Custodial partner identifier (all uppercase)"), + transferId: z.string().optional().describe("Filter by specific transfer ID"), + clientOrderId: z.string().optional().describe("Filter by your reference ID"), + asset: z.string().optional().describe("Filter by asset (e.g., BTC)"), + startTime: z + .number() + .optional() + .describe("Start time in milliseconds (default: 90 days ago)"), + endTime: z.number().optional().describe("End time in milliseconds (default: now)"), + page: z.number().optional().describe("Page number (default: 1)"), + limit: z.number().optional().describe("Results per page (default: 20, max: 100)"), + }, }, async ({ rail, transferId, clientOrderId, asset, startTime, endTime, page, limit }) => { try { @@ -341,25 +351,26 @@ Returns transfer history with status, amounts, and timestamps.`, // ===================================================================== server.registerTool( "binance_us_custodial_custodian_transfer_history", - {}, - `Get history of transfers from custodial partner, including ExpressTrade and Undo transfers. + { + description: `Get history of transfers from custodial partner, including ExpressTrade and Undo transfers. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY Returns transfer history with status, amounts, and timestamps.`, - { - rail: z.string().describe("Custodial partner identifier (all uppercase)"), - transferId: z.string().optional().describe("Filter by specific transfer ID"), - clientOrderId: z.string().optional().describe("Filter by your reference ID"), - expressTradeTransfer: z - .boolean() - .optional() - .describe("Filter by ExpressTrade transfers only"), - asset: z.string().optional().describe("Filter by asset (e.g., BTC)"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - page: z.number().optional().describe("Page number (default: 1)"), - limit: z.number().optional().describe("Results per page (default: 20, max: 100)"), + inputSchema: { + rail: z.string().describe("Custodial partner identifier (all uppercase)"), + transferId: z.string().optional().describe("Filter by specific transfer ID"), + clientOrderId: z.string().optional().describe("Filter by your reference ID"), + expressTradeTransfer: z + .boolean() + .optional() + .describe("Filter by ExpressTrade transfers only"), + asset: z.string().optional().describe("Filter by asset (e.g., BTC)"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + page: z.number().optional().describe("Page number (default: 1)"), + limit: z.number().optional().describe("Results per page (default: 20, max: 100)"), + }, }, async ({ rail, @@ -415,22 +426,23 @@ Returns transfer history with status, amounts, and timestamps.`, // ===================================================================== server.registerTool( "binance_us_custodial_settlement", - {}, - `Request settlement of assets from custodial sub-account to custodial partner. + { + description: `Request settlement of assets from custodial sub-account to custodial partner. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY ⚠️ This sends funds to your custodial partner! This settles (withdraws) assets from your Binance.US custodial sub-account to your custody partner's vault.`, - { - rail: z.string().describe("Custodial partner identifier (all uppercase)"), - asset: z.string().describe("Asset to settle (e.g., BTC, ETH)"), - amount: z.number().positive().describe("Amount to settle"), - clientOrderId: z - .string() - .optional() - .describe("Your reference ID (auto-generated if not provided)"), + inputSchema: { + rail: z.string().describe("Custodial partner identifier (all uppercase)"), + asset: z.string().describe("Asset to settle (e.g., BTC, ETH)"), + amount: z.number().positive().describe("Amount to settle"), + clientOrderId: z + .string() + .optional() + .describe("Your reference ID (auto-generated if not provided)"), + }, }, async ({ rail, asset, amount, clientOrderId }) => { try { @@ -467,21 +479,22 @@ to your custody partner's vault.`, // ===================================================================== server.registerTool( "binance_us_custodial_settlement_history", - {}, - `Get history of settlements from custodial sub-account to custodial partner. + { + description: `Get history of settlements from custodial sub-account to custodial partner. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY Returns settlement history with status, amounts, and timestamps.`, - { - rail: z.string().describe("Custodial partner identifier (all uppercase)"), - settlementId: z.string().optional().describe("Filter by specific settlement ID"), - clientOrderId: z.string().optional().describe("Filter by your reference ID"), - asset: z.string().optional().describe("Filter by asset (e.g., BTC)"), - startTime: z.number().optional().describe("Start time in milliseconds"), - endTime: z.number().optional().describe("End time in milliseconds"), - page: z.number().optional().describe("Page number (default: 1)"), - limit: z.number().optional().describe("Results per page (default: 20, max: 100)"), + inputSchema: { + rail: z.string().describe("Custodial partner identifier (all uppercase)"), + settlementId: z.string().optional().describe("Filter by specific settlement ID"), + clientOrderId: z.string().optional().describe("Filter by your reference ID"), + asset: z.string().optional().describe("Filter by asset (e.g., BTC)"), + startTime: z.number().optional().describe("Start time in milliseconds"), + endTime: z.number().optional().describe("End time in milliseconds"), + page: z.number().optional().describe("Page number (default: 1)"), + limit: z.number().optional().describe("Results per page (default: 20, max: 100)"), + }, }, async ({ rail, settlementId, clientOrderId, asset, startTime, endTime, page, limit }) => { try { diff --git a/src/tools/custodial/index.ts b/src/tools/custodial/index.ts index f3d79fa8..f3f6db9c 100644 --- a/src/tools/custodial/index.ts +++ b/src/tools/custodial/index.ts @@ -46,8 +46,8 @@ export function registerCustodialTools(server: McpServer) { // ===================================================================== server.registerTool( "binance_us_cust_balance", - {}, - `Get balance information for Binance.US exchange wallet and custodial sub-account. + { + description: `Get balance information for Binance.US exchange wallet and custodial sub-account. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY - Standard API keys will not work. @@ -63,10 +63,11 @@ Each balance entry contains: - locked: Locked balance - inSettlement: Amount in settlement (custodial only) - lastUpdatedTime: Last update timestamp`, - { - rail: railSchema, + inputSchema: { + rail: railSchema, + }, }, - async (params) => { + async (params: { rail: string }) => { try { const response = await makeSignedRequest("GET", "/sapi/v1/custodian/balance", { rail: params.rail.toUpperCase(), @@ -96,8 +97,8 @@ Each balance entry contains: // ===================================================================== server.registerTool( "binance_us_cust_supported_assets", - {}, - `Get list of assets supported for custodial solution transfers and settlements. + { + description: `Get list of assets supported for custodial solution transfers and settlements. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -109,10 +110,11 @@ Each asset entry contains: - asset: Asset symbol - precision: Decimal precision - network: Supported blockchain networks`, - { - rail: railSchema, + inputSchema: { + rail: railSchema, + }, }, - async (params) => { + async (params: { rail: string }) => { try { const response = await makeSignedRequest("GET", "/sapi/v1/custodian/supportedAssetList", { rail: params.rail.toUpperCase(), @@ -142,8 +144,8 @@ Each asset entry contains: // ===================================================================== server.registerTool( "binance_us_cust_wallet_transfer", - {}, - `Transfer assets from Binance.US exchange wallet to custodial sub-account. + { + description: `Transfer assets from Binance.US exchange wallet to custodial sub-account. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -157,14 +159,15 @@ Response includes: - transferId: Unique transfer identifier - status: Transfer status (SUCCESS, PENDING, etc.) - createTime: Transfer creation timestamp`, - { - rail: railSchema, - asset: z.string().describe("Asset to transfer (e.g., BTC, ETH)"), - amount: z.number().positive().describe("Amount to transfer"), - clientOrderId: z - .string() - .optional() - .describe("Your unique reference ID (auto-generated if not provided)"), + inputSchema: { + rail: railSchema, + asset: z.string().describe("Asset to transfer (e.g., BTC, ETH)"), + amount: z.number().positive().describe("Amount to transfer"), + clientOrderId: z + .string() + .optional() + .describe("Your unique reference ID (auto-generated if not provided)"), + }, }, async (params) => { try { @@ -199,8 +202,8 @@ Response includes: // ===================================================================== server.registerTool( "binance_us_cust_transfer", - {}, - `Transfer assets from custodial partner account to Binance.US custodial sub-account. + { + description: `Transfer assets from custodial partner account to Binance.US custodial sub-account. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -214,16 +217,17 @@ Response includes: - custodyAccountId/custodyAccountName: Custodian account details - status: Transfer status - createTime: Transfer creation timestamp`, - { - rail: railSchema, - asset: z.string().describe("Asset to transfer (e.g., BTC, ETH)"), - amount: z.number().positive().describe("Amount to transfer"), - clientOrderId: z - .string() - .optional() - .describe("Your unique reference ID (auto-generated if not provided)"), + inputSchema: { + rail: railSchema, + asset: z.string().describe("Asset to transfer (e.g., BTC, ETH)"), + amount: z.number().positive().describe("Amount to transfer"), + clientOrderId: z + .string() + .optional() + .describe("Your unique reference ID (auto-generated if not provided)"), + }, }, - async (params) => { + async (params: { rail: string; asset: string; amount: number; clientOrderId?: string }) => { try { const response = await makeSignedRequest("POST", "/sapi/v1/custodian/custodianTransfer", { rail: params.rail.toUpperCase(), @@ -258,8 +262,8 @@ Response includes: // ===================================================================== server.registerTool( "binance_us_cust_undo_transfer", - {}, - `Undo a previous transfer from your custodial partner. + { + description: `Undo a previous transfer from your custodial partner. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -269,9 +273,10 @@ Response includes: - transferId: New transfer ID for the undo operation - asset: Asset being returned - amount: Amount being returned`, - { - rail: railSchema, - originTransferId: z.string().describe("Original transfer ID to undo"), + inputSchema: { + rail: railSchema, + originTransferId: z.string().describe("Original transfer ID to undo"), + }, }, async (params) => { try { @@ -304,8 +309,8 @@ Response includes: // ===================================================================== server.registerTool( "binance_us_cust_wallet_transfer_history", - {}, - `Get history of transfers from Binance.US exchange wallet to custodial sub-account. + { + description: `Get history of transfers from Binance.US exchange wallet to custodial sub-account. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -315,22 +320,29 @@ Response includes: Each transfer record contains: transferId, clientOrderId, asset, amount, status, createTime, updateTime`, - { - rail: railSchema, - transferId: z.string().optional().describe("Filter by specific transfer ID"), - clientOrderId: z.string().optional().describe("Filter by client order ID"), - asset: z.string().optional().describe("Filter by asset (e.g., BTC)"), - startTime: z.number().optional().describe("Start timestamp (default: 90 days ago)"), - endTime: z.number().optional().describe("End timestamp (default: now)"), - page: z.number().int().positive().optional().default(1).describe("Page number (default: 1)"), - limit: z - .number() - .int() - .min(1) - .max(100) - .optional() - .default(20) - .describe("Records per page (default: 20, max: 100)"), + inputSchema: { + rail: railSchema, + transferId: z.string().optional().describe("Filter by specific transfer ID"), + clientOrderId: z.string().optional().describe("Filter by client order ID"), + asset: z.string().optional().describe("Filter by asset (e.g., BTC)"), + startTime: z.number().optional().describe("Start timestamp (default: 90 days ago)"), + endTime: z.number().optional().describe("End timestamp (default: now)"), + page: z + .number() + .int() + .positive() + .optional() + .default(1) + .describe("Page number (default: 1)"), + limit: z + .number() + .int() + .min(1) + .max(100) + .optional() + .default(20) + .describe("Records per page (default: 20, max: 100)"), + }, }, async (params) => { try { @@ -375,8 +387,8 @@ status, createTime, updateTime`, // ===================================================================== server.registerTool( "binance_us_cust_transfer_history", - {}, - `Get history of transfers from custodial partner to Binance.US custodial sub-account. + { + description: `Get history of transfers from custodial partner to Binance.US custodial sub-account. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -388,27 +400,34 @@ Response includes: Each record contains: transferId, clientOrderId, asset, amount, status, expressTrade flag, createTime, updateTime`, - { - rail: railSchema, - transferId: z.string().optional().describe("Filter by specific transfer ID"), - clientOrderId: z.string().optional().describe("Filter by client order ID"), - expressTradeTransfer: z - .boolean() - .optional() - .default(false) - .describe("Filter ExpressTrade transfers only"), - asset: z.string().optional().describe("Filter by asset (e.g., BTC)"), - startTime: z.number().optional().describe("Start timestamp (default: 90 days ago)"), - endTime: z.number().optional().describe("End timestamp (default: now)"), - page: z.number().int().positive().optional().default(1).describe("Page number (default: 1)"), - limit: z - .number() - .int() - .min(1) - .max(100) - .optional() - .default(20) - .describe("Records per page (default: 20, max: 100)"), + inputSchema: { + rail: railSchema, + transferId: z.string().optional().describe("Filter by specific transfer ID"), + clientOrderId: z.string().optional().describe("Filter by client order ID"), + expressTradeTransfer: z + .boolean() + .optional() + .default(false) + .describe("Filter ExpressTrade transfers only"), + asset: z.string().optional().describe("Filter by asset (e.g., BTC)"), + startTime: z.number().optional().describe("Start timestamp (default: 90 days ago)"), + endTime: z.number().optional().describe("End timestamp (default: now)"), + page: z + .number() + .int() + .positive() + .optional() + .default(1) + .describe("Page number (default: 1)"), + limit: z + .number() + .int() + .min(1) + .max(100) + .optional() + .default(20) + .describe("Records per page (default: 20, max: 100)"), + }, }, async (params) => { try { @@ -456,15 +475,16 @@ expressTrade flag, createTime, updateTime`, // ===================================================================== server.registerTool( "binance_us_cust_available_balance", - {}, - `Get available balance in the custodial sub-account for trading. + { + description: `Get available balance in the custodial sub-account for trading. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY Returns the balance available for placing new orders.`, - { - rail: railSchema, - asset: z.string().optional().describe("Filter by specific asset"), + inputSchema: { + rail: railSchema, + asset: z.string().optional().describe("Filter by specific asset"), + }, }, async (params) => { try { @@ -497,8 +517,8 @@ Returns the balance available for placing new orders.`, // ===================================================================== server.registerTool( "binance_us_cust_new_order", - {}, - `Place a new trade order through the custodial solution. + { + description: `Place a new trade order through the custodial solution. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -517,29 +537,30 @@ the full amount will be automatically transferred from the custodial partner. Response includes: symbol, orderId, status, type, side, price, quantity, executedQty, and expressTradeFlag`, - { - rail: railSchema, - symbol: z.string().describe("Trading pair (e.g., BTCUSD, ETHUSD)"), - side: orderSideEnum.describe("Order side: BUY or SELL"), - type: orderTypeEnum.describe("Order type"), - timeInForce: timeInForceEnum - .optional() - .describe("GTC (Good Til Canceled), IOC (Immediate or Cancel), FOK (Fill or Kill)"), - quantity: z.number().positive().optional().describe("Order quantity in base asset"), - quoteOrderQty: z - .number() - .positive() - .optional() - .describe("Order quantity in quote asset (MARKET orders only)"), - price: z.number().positive().optional().describe("Order price (required for LIMIT orders)"), - stopPrice: z.number().positive().optional().describe("Stop/trigger price for stop orders"), - icebergQty: z.number().positive().optional().describe("Iceberg order quantity"), - asset: z.string().optional().describe("Asset for ExpressTrade (the asset being sold)"), - allowExpressTrade: z - .boolean() - .optional() - .default(false) - .describe("Enable ExpressTrade for auto-funding"), + inputSchema: { + rail: railSchema, + symbol: z.string().describe("Trading pair (e.g., BTCUSD, ETHUSD)"), + side: orderSideEnum.describe("Order side: BUY or SELL"), + type: orderTypeEnum.describe("Order type"), + timeInForce: timeInForceEnum + .optional() + .describe("GTC (Good Til Canceled), IOC (Immediate or Cancel), FOK (Fill or Kill)"), + quantity: z.number().positive().optional().describe("Order quantity in base asset"), + quoteOrderQty: z + .number() + .positive() + .optional() + .describe("Order quantity in quote asset (MARKET orders only)"), + price: z.number().positive().optional().describe("Order price (required for LIMIT orders)"), + stopPrice: z.number().positive().optional().describe("Stop/trigger price for stop orders"), + icebergQty: z.number().positive().optional().describe("Iceberg order quantity"), + asset: z.string().optional().describe("Asset for ExpressTrade (the asset being sold)"), + allowExpressTrade: z + .boolean() + .optional() + .default(false) + .describe("Enable ExpressTrade for auto-funding"), + }, }, async (params) => { try { @@ -584,8 +605,8 @@ executedQty, and expressTradeFlag`, // ===================================================================== server.registerTool( "binance_us_cust_oco_order", - {}, - `Place a new OCO (One-Cancels-the-Other) order through the custodial solution. + { + description: `Place a new OCO (One-Cancels-the-Other) order through the custodial solution. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -601,21 +622,24 @@ Quantity: Both legs must have the same quantity (iceberg qty can differ). Note: OCO counts as 2 orders against rate limits. Response includes orderListId, orders array, and orderReports with details.`, - { - rail: railSchema, - symbol: z.string().describe("Trading pair (e.g., BTCUSD, ETHUSD)"), - side: orderSideEnum.describe("Order side: BUY or SELL"), - quantity: z.number().positive().describe("Order quantity (same for both legs)"), - price: z.number().positive().describe("Limit order price"), - stopPrice: z.number().positive().describe("Stop trigger price"), - limitClientOrderId: z.string().optional().describe("Unique ID for the limit order"), - limitIcebergQty: z.number().positive().optional().describe("Iceberg qty for limit leg"), - stopClientOrderId: z.string().optional().describe("Unique ID for the stop leg"), - stopLimitPrice: z.number().positive().optional().describe("Limit price for stop-limit leg"), - stopIcebergQty: z.number().positive().optional().describe("Iceberg qty for stop leg"), - stopLimitTimeInForce: timeInForceEnum.optional().describe("Time in force for stop-limit leg"), - asset: z.string().optional().describe("Asset for ExpressTrade"), - allowExpressTrade: z.boolean().optional().default(false).describe("Enable ExpressTrade"), + inputSchema: { + rail: railSchema, + symbol: z.string().describe("Trading pair (e.g., BTCUSD, ETHUSD)"), + side: orderSideEnum.describe("Order side: BUY or SELL"), + quantity: z.number().positive().describe("Order quantity (same for both legs)"), + price: z.number().positive().describe("Limit order price"), + stopPrice: z.number().positive().describe("Stop trigger price"), + limitClientOrderId: z.string().optional().describe("Unique ID for the limit order"), + limitIcebergQty: z.number().positive().optional().describe("Iceberg qty for limit leg"), + stopClientOrderId: z.string().optional().describe("Unique ID for the stop leg"), + stopLimitPrice: z.number().positive().optional().describe("Limit price for stop-limit leg"), + stopIcebergQty: z.number().positive().optional().describe("Iceberg qty for stop leg"), + stopLimitTimeInForce: timeInForceEnum + .optional() + .describe("Time in force for stop-limit leg"), + asset: z.string().optional().describe("Asset for ExpressTrade"), + allowExpressTrade: z.boolean().optional().default(false).describe("Enable ExpressTrade"), + }, }, async (params) => { try { @@ -662,8 +686,8 @@ Response includes orderListId, orders array, and orderReports with details.`, // ===================================================================== server.registerTool( "binance_us_cust_open_orders", - {}, - `Get all open custodial trade orders. + { + description: `Get all open custodial trade orders. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -672,12 +696,13 @@ Response includes orderListId, orders array, and orderReports with details.`, Response is an array of open orders with: symbol, orderId, price, origQty, executedQty, status, type, side, stopPrice, time, updateTime, isWorking, expressTradeFlag`, - { - rail: railSchema, - symbol: z - .string() - .optional() - .describe("Trading pair (e.g., BTCUSD). Recommended to always specify."), + inputSchema: { + rail: railSchema, + symbol: z + .string() + .optional() + .describe("Trading pair (e.g., BTCUSD). Recommended to always specify."), + }, }, async (params) => { try { @@ -710,18 +735,19 @@ expressTradeFlag`, // ===================================================================== server.registerTool( "binance_us_cust_get_order", - {}, - `Get details of a specific custodial trade order. + { + description: `Get details of a specific custodial trade order. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY Response includes: symbol, orderId, price, origQty, executedQty, cummulativeQuoteQty, status, timeInForce, type, side, stopPrice, icebergQty, time, updateTime, isWorking, expressTradeFlag`, - { - rail: railSchema, - symbol: z.string().describe("Trading pair (e.g., BTCUSD)"), - orderId: z.number().int().describe("Order ID to query"), + inputSchema: { + rail: railSchema, + symbol: z.string().describe("Trading pair (e.g., BTCUSD)"), + orderId: z.number().int().describe("Order ID to query"), + }, }, async (params) => { try { @@ -755,8 +781,8 @@ icebergQty, time, updateTime, isWorking, expressTradeFlag`, // ===================================================================== server.registerTool( "binance_us_cust_order_history", - {}, - `Get historical custodial trade orders. + { + description: `Get historical custodial trade orders. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -764,23 +790,24 @@ If symbol is not sent, orders for all symbols will be returned. Response is an array of orders with full details including status, executedQty, and expressTradeFlag.`, - { - rail: railSchema, - symbol: z - .string() - .optional() - .describe("Trading pair (e.g., BTCUSD). If omitted, returns all symbols."), - startTime: z.number().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().optional().describe("End timestamp in milliseconds"), - fromId: z.number().int().optional().describe("Start from this order ID"), - limit: z - .number() - .int() - .min(1) - .max(1000) - .optional() - .default(200) - .describe("Max records (default: 200)"), + inputSchema: { + rail: railSchema, + symbol: z + .string() + .optional() + .describe("Trading pair (e.g., BTCUSD). If omitted, returns all symbols."), + startTime: z.number().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().optional().describe("End timestamp in milliseconds"), + fromId: z.number().int().optional().describe("Start from this order ID"), + limit: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .default(200) + .describe("Max records (default: 200)"), + }, }, async (params) => { try { @@ -817,8 +844,8 @@ executedQty, and expressTradeFlag.`, // ===================================================================== server.registerTool( "binance_us_cust_trade_history", - {}, - `Get historical custodial trades (filled orders). + { + description: `Get historical custodial trades (filled orders). ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -826,21 +853,22 @@ Returns actual executed trades with price, quantity, and commission details. Response includes for each trade: symbol, price, qty, quoteQty, time, isBuyer, isMaker, isBestMatch, orderId, commission, commissionAsset`, - { - rail: railSchema, - symbol: z.string().optional().describe("Trading pair (e.g., BTCUSD)"), - orderId: z.number().int().optional().describe("Filter by order ID"), - startTime: z.number().optional().describe("Start timestamp"), - endTime: z.number().optional().describe("End timestamp"), - fromId: z.number().int().optional().describe("Start from this trade ID"), - limit: z - .number() - .int() - .min(1) - .max(1000) - .optional() - .default(200) - .describe("Max records (default: 200)"), + inputSchema: { + rail: railSchema, + symbol: z.string().optional().describe("Trading pair (e.g., BTCUSD)"), + orderId: z.number().int().optional().describe("Filter by order ID"), + startTime: z.number().optional().describe("Start timestamp"), + endTime: z.number().optional().describe("End timestamp"), + fromId: z.number().int().optional().describe("Start from this trade ID"), + limit: z + .number() + .int() + .min(1) + .max(1000) + .optional() + .default(200) + .describe("Max records (default: 200)"), + }, }, async (params) => { try { @@ -878,23 +906,24 @@ isBuyer, isMaker, isBestMatch, orderId, commission, commissionAsset`, // ===================================================================== server.registerTool( "binance_us_cust_cancel_order", - {}, - `Cancel an active custodial trade order. + { + description: `Cancel an active custodial trade order. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY Either orderId or origClientOrderId must be provided. Response includes the canceled order details with status: CANCELED`, - { - rail: railSchema, - symbol: z.string().describe("Trading pair (e.g., BTCUSD)"), - orderId: z.number().int().optional().describe("Order ID to cancel"), - origClientOrderId: z.string().optional().describe("Original client order ID to cancel"), - newClientOrderId: z - .string() - .optional() - .describe("New client order ID for this cancel operation"), + inputSchema: { + rail: railSchema, + symbol: z.string().describe("Trading pair (e.g., BTCUSD)"), + orderId: z.number().int().optional().describe("Order ID to cancel"), + origClientOrderId: z.string().optional().describe("Original client order ID to cancel"), + newClientOrderId: z + .string() + .optional() + .describe("New client order ID for this cancel operation"), + }, }, async (params) => { try { @@ -934,17 +963,18 @@ Response includes the canceled order details with status: CANCELED`, // ===================================================================== server.registerTool( "binance_us_cust_cancel_orders_symbol", - {}, - `Cancel all active custodial orders for a specific trading pair. + { + description: `Cancel all active custodial orders for a specific trading pair. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY This includes OCO orders. Use with caution. Response is an array of all canceled orders.`, - { - rail: railSchema, - symbol: z.string().describe("Trading pair to cancel all orders for (e.g., BTCUSD)"), + inputSchema: { + rail: railSchema, + symbol: z.string().describe("Trading pair to cancel all orders for (e.g., BTCUSD)"), + }, }, async (params) => { try { @@ -981,8 +1011,8 @@ Response is an array of all canceled orders.`, // ===================================================================== server.registerTool( "binance_us_cust_cancel_oco", - {}, - `Cancel an entire OCO (One-Cancels-the-Other) order list. + { + description: `Cancel an entire OCO (One-Cancels-the-Other) order list. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -990,12 +1020,16 @@ This cancels both legs of the OCO order. Response includes orderListId, orders array, and orderReports with canceled order details.`, - { - rail: railSchema, - symbol: z.string().describe("Trading pair (e.g., BTCUSD)"), - orderListId: z.number().int().describe("OCO order list ID to cancel"), - listClientOrderId: z.string().optional().describe("List client order ID"), - newClientOrderId: z.string().optional().describe("New client order ID for cancel operation"), + inputSchema: { + rail: railSchema, + symbol: z.string().describe("Trading pair (e.g., BTCUSD)"), + orderListId: z.number().int().describe("OCO order list ID to cancel"), + listClientOrderId: z.string().optional().describe("List client order ID"), + newClientOrderId: z + .string() + .optional() + .describe("New client order ID for cancel operation"), + }, }, async (params) => { try { @@ -1031,8 +1065,8 @@ canceled order details.`, // ===================================================================== server.registerTool( "binance_us_cust_settlement_settings", - {}, - `Get current settlement settings for custodial solution. + { + description: `Get current settlement settings for custodial solution. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -1042,8 +1076,9 @@ Response includes: - settlementActive: Whether auto-settlement is enabled - frequencyInHours: Settlement frequency (e.g., 24 hours) - nextTriggerTime: Timestamp of next scheduled settlement`, - { - rail: railSchema, + inputSchema: { + rail: railSchema, + }, }, async (params) => { try { @@ -1075,8 +1110,8 @@ Response includes: // ===================================================================== server.registerTool( "binance_us_cust_settlement_history", - {}, - `Get historical settlement records for custodial solution. + { + description: `Get historical settlement records for custodial solution. ⚠️ REQUIRES CUSTODIAL SOLUTION API KEY @@ -1091,19 +1126,26 @@ Each record contains: - triggerTime: When settlement was triggered - settlementId: Unique settlement identifier - settlementAssets: Array of assets settled with amounts and addresses`, - { - rail: railSchema, - startTime: z.number().optional().describe("Start timestamp"), - endTime: z.number().optional().describe("End timestamp"), - limit: z - .number() - .int() - .min(1) - .max(100) - .optional() - .default(5) - .describe("Max records (default: 5, max: 100)"), - page: z.number().int().positive().optional().default(1).describe("Page number (default: 1)"), + inputSchema: { + rail: railSchema, + startTime: z.number().optional().describe("Start timestamp"), + endTime: z.number().optional().describe("End timestamp"), + limit: z + .number() + .int() + .min(1) + .max(100) + .optional() + .default(5) + .describe("Max records (default: 5, max: 100)"), + page: z + .number() + .int() + .positive() + .optional() + .default(1) + .describe("Page number (default: 1)"), + }, }, async (params) => { try { diff --git a/src/tools/otc/index.ts b/src/tools/otc/index.ts index da089d9e..78830a38 100644 --- a/src/tools/otc/index.ts +++ b/src/tools/otc/index.ts @@ -20,8 +20,8 @@ export function registerOtcTools(server: McpServer) { // ===================================================================== server.registerTool( "binance_us_otc_coin_pairs", - {}, - `Get a list of supported OTC (Over-The-Counter) trading pairs on Binance.US. + { + description: `Get a list of supported OTC (Over-The-Counter) trading pairs on Binance.US. OTC trading allows large block trades to be executed outside the regular order book, minimizing market impact. This endpoint returns available coin pairs with their @@ -33,11 +33,12 @@ Response includes: - toCoinMinAmount/toCoinMaxAmount: Min/max amounts for the buy coin Example: Convert large amounts of BTC to USDT without affecting market price.`, - { - fromCoin: z.string().optional().describe("Filter by source coin (e.g., BTC, SHIB)"), - toCoin: z.string().optional().describe("Filter by destination coin (e.g., USDT, KSHIB)"), + inputSchema: { + fromCoin: z.string().optional().describe("Filter by source coin (e.g., BTC, SHIB)"), + toCoin: z.string().optional().describe("Filter by destination coin (e.g., USDT, KSHIB)"), + }, }, - async (params) => { + async (params: { fromCoin?: string; toCoin?: string }) => { try { const response = await makeSignedRequest("GET", "/sapi/v1/otc/coinPairs", { ...(params.fromCoin && { fromCoin: params.fromCoin.toUpperCase() }), @@ -68,8 +69,8 @@ Example: Convert large amounts of BTC to USDT without affecting market price.`, // ===================================================================== server.registerTool( "binance_us_otc_quote", - {}, - `Request a quote for an OTC (Over-The-Counter) trade on Binance.US. + { + description: `Request a quote for an OTC (Over-The-Counter) trade on Binance.US. This endpoint requests a price quote for converting one coin to another via OTC. The quote is valid for a limited time (check validTimestamp in response). @@ -88,15 +89,21 @@ Response includes: - inverseRatio: Inverse conversion ratio - validTimestamp: Unix timestamp when quote expires - toAmount/fromAmount: Calculated amounts for the trade`, - { - fromCoin: z.string().describe("Coin to sell (e.g., BTC, SHIB)"), - toCoin: z.string().describe("Coin to buy (e.g., USDT, KSHIB)"), - requestCoin: z - .string() - .describe("Which coin's amount you're specifying (fromCoin or toCoin)"), - requestAmount: z.number().positive().describe("Amount of the request coin"), + inputSchema: { + fromCoin: z.string().describe("Coin to sell (e.g., BTC, SHIB)"), + toCoin: z.string().describe("Coin to buy (e.g., USDT, KSHIB)"), + requestCoin: z + .string() + .describe("Which coin's amount you're specifying (fromCoin or toCoin)"), + requestAmount: z.number().positive().describe("Amount of the request coin"), + }, }, - async (params) => { + async (params: { + fromCoin: string; + toCoin: string; + requestCoin: string; + requestAmount: number; + }) => { try { const response = await makeSignedRequest("POST", "/sapi/v1/otc/quotes", { fromCoin: params.fromCoin.toUpperCase(), @@ -129,8 +136,8 @@ Response includes: // ===================================================================== server.registerTool( "binance_us_otc_place_order", - {}, - `Place an OTC (Over-The-Counter) trade order using a previously acquired quote. + { + description: `Place an OTC (Over-The-Counter) trade order using a previously acquired quote. ⚠️ IMPORTANT: You must first call binance_us_otc_quote to get a quoteId before placing an order. The quote expires quickly, so place the order immediately after receiving the quote. @@ -145,14 +152,15 @@ Response includes: - orderId: Unique order identifier - createTime: Order creation timestamp - orderStatus: Current status of the order`, - { - quoteId: z - .string() - .describe( - "Quote ID received from binance_us_otc_quote (e.g., '4e5446f2cc6f44ab86ab02abf19a2fd2')", - ), + inputSchema: { + quoteId: z + .string() + .describe( + "Quote ID received from binance_us_otc_quote (e.g., '4e5446f2cc6f44ab86ab02abf19a2fd2')", + ), + }, }, - async (params) => { + async (params: { quoteId: string }) => { try { const response = await makeSignedRequest("POST", "/sapi/v1/otc/orders", { quoteId: params.quoteId, @@ -182,8 +190,8 @@ Response includes: // ===================================================================== server.registerTool( "binance_us_otc_get_order", - {}, - `Get detailed information about a specific OTC (Over-The-Counter) trade order. + { + description: `Get detailed information about a specific OTC (Over-The-Counter) trade order. Use this to check the status and details of a previously placed OTC order. @@ -195,10 +203,11 @@ Response includes: - toCoin/toAmount: Bought coin and amount - ratio/inverseRatio: Exchange rates - createTime: Order creation timestamp`, - { - orderId: z.string().describe("OTC order ID to query (e.g., '10002349')"), + inputSchema: { + orderId: z.string().describe("OTC order ID to query (e.g., '10002349')"), + }, }, - async (params) => { + async (params: { orderId: string }) => { try { const response = await makeSignedRequest("GET", `/sapi/v1/otc/orders/${params.orderId}`); @@ -226,8 +235,8 @@ Response includes: // ===================================================================== server.registerTool( "binance_us_otc_all_orders", - {}, - `Query all OTC (Over-The-Counter) trade orders with optional filters. + { + description: `Query all OTC (Over-The-Counter) trade orders with optional filters. Use this to retrieve your OTC trading history with various filtering options. @@ -237,22 +246,31 @@ Response includes: Each order contains: quoteId, orderId, orderStatus, fromCoin, fromAmount, toCoin, toAmount, ratio, inverseRatio, createTime`, - { - orderId: z.string().optional().describe("Filter by specific order ID"), - fromCoin: z.string().optional().describe("Filter by source coin (e.g., BTC, KSHIB)"), - toCoin: z.string().optional().describe("Filter by destination coin (e.g., USDT, SHIB)"), - startTime: z.number().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().optional().describe("End timestamp in milliseconds"), - page: z.number().int().positive().optional().describe("Page number (starts from 1)"), - limit: z - .number() - .int() - .min(1) - .max(100) - .optional() - .describe("Records per page (default: 10, max: 100)"), + inputSchema: { + orderId: z.string().optional().describe("Filter by specific order ID"), + fromCoin: z.string().optional().describe("Filter by source coin (e.g., BTC, KSHIB)"), + toCoin: z.string().optional().describe("Filter by destination coin (e.g., USDT, SHIB)"), + startTime: z.number().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().optional().describe("End timestamp in milliseconds"), + page: z.number().int().positive().optional().describe("Page number (starts from 1)"), + limit: z + .number() + .int() + .min(1) + .max(100) + .optional() + .describe("Records per page (default: 10, max: 100)"), + }, }, - async (params) => { + async (params: { + orderId?: string; + fromCoin?: string; + toCoin?: string; + startTime?: number; + endTime?: number; + page?: number; + limit?: number; + }) => { try { const response = await makeSignedRequest("GET", "/sapi/v1/otc/orders", { ...(params.orderId && { orderId: params.orderId }), @@ -288,8 +306,8 @@ toCoin, toAmount, ratio, inverseRatio, createTime`, // ===================================================================== server.registerTool( "binance_us_ocbs_orders", - {}, - `Query all OCBS (One-Click-Buy-Sell) fiat orders on Binance.US. + { + description: `Query all OCBS (One-Click-Buy-Sell) fiat orders on Binance.US. OCBS allows direct fiat-to-crypto conversions. This endpoint retrieves your OCBS order history for fiat transactions (e.g., USD to BTC). @@ -305,20 +323,27 @@ Each order contains: - feeCoin/feeAmount: Fee details - ratio: Exchange rate - createTime: Order timestamp`, - { - orderId: z.string().optional().describe("Filter by specific order ID"), - startTime: z.number().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().optional().describe("End timestamp in milliseconds"), - page: z.number().int().positive().optional().describe("Page number (starts from 1)"), - limit: z - .number() - .int() - .min(1) - .max(100) - .optional() - .describe("Records per page (default: 10, max: 100)"), + inputSchema: { + orderId: z.string().optional().describe("Filter by specific order ID"), + startTime: z.number().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().optional().describe("End timestamp in milliseconds"), + page: z.number().int().positive().optional().describe("Page number (starts from 1)"), + limit: z + .number() + .int() + .min(1) + .max(100) + .optional() + .describe("Records per page (default: 10, max: 100)"), + }, }, - async (params) => { + async (params: { + orderId?: string; + startTime?: number; + endTime?: number; + page?: number; + limit?: number; + }) => { try { const response = await makeSignedRequest("GET", "/sapi/v1/ocbs/orders", { ...(params.orderId && { orderId: params.orderId }), diff --git a/src/tools/staking/index.ts b/src/tools/staking/index.ts index ff34541c..e900be26 100644 --- a/src/tools/staking/index.ts +++ b/src/tools/staking/index.ts @@ -20,8 +20,8 @@ export function registerStakingTools(server: McpServer) { // ===================================================================== server.registerTool( "binance_us_staking_asset_info", - {}, - `Get staking information for supported assets on Binance.US. + { + description: `Get staking information for supported assets on Binance.US. Returns details about staking options including APR, APY, and staking limits. @@ -36,13 +36,14 @@ Response includes for each asset: - autoRestake: Whether rewards are automatically restaked If no asset is specified, returns information for all staking assets.`, - { - stakingAsset: z - .string() - .optional() - .describe("Asset symbol (e.g., BNB, ETH). If empty, returns all staking assets"), + inputSchema: { + stakingAsset: z + .string() + .optional() + .describe("Asset symbol (e.g., BNB, ETH). If empty, returns all staking assets"), + }, }, - async (params) => { + async (params: { stakingAsset?: string }) => { try { const response = await makeSignedRequest("GET", "/sapi/v1/staking/asset", { ...(params.stakingAsset && { stakingAsset: params.stakingAsset.toUpperCase() }), @@ -72,8 +73,8 @@ If no asset is specified, returns information for all staking assets.`, // ===================================================================== server.registerTool( "binance_us_staking_stake", - {}, - `Stake a supported asset on Binance.US to earn staking rewards. + { + description: `Stake a supported asset on Binance.US to earn staking rewards. ⚠️ IMPORTANT: - Staking locks your assets for a period of time @@ -89,16 +90,17 @@ Parameters: Response includes: - result: SUCCESS or failure status - purchaseRecordId: Record ID for the staking transaction`, - { - stakingAsset: z.string().describe("Asset symbol to stake (e.g., BNB, ETH)"), - amount: z.number().positive().describe("Amount to stake"), - autoRestake: z - .boolean() - .optional() - .default(true) - .describe("Automatically restake rewards (default: true)"), + inputSchema: { + stakingAsset: z.string().describe("Asset symbol to stake (e.g., BNB, ETH)"), + amount: z.number().positive().describe("Amount to stake"), + autoRestake: z + .boolean() + .optional() + .default(true) + .describe("Automatically restake rewards (default: true)"), + }, }, - async (params) => { + async (params: { stakingAsset: string; amount: number; autoRestake?: boolean }) => { try { const response = await makeSignedRequest("POST", "/sapi/v1/staking/stake", { stakingAsset: params.stakingAsset.toUpperCase(), @@ -130,8 +132,8 @@ Response includes: // ===================================================================== server.registerTool( "binance_us_staking_unstake", - {}, - `Unstake a previously staked asset on Binance.US. + { + description: `Unstake a previously staked asset on Binance.US. ⚠️ IMPORTANT: - Unstaking may take time (check unstakingPeriod in asset info) @@ -144,11 +146,12 @@ Parameters: Response includes: - result: SUCCESS or failure status`, - { - stakingAsset: z.string().describe("Asset symbol to unstake (e.g., BNB, ETH)"), - amount: z.number().positive().describe("Amount to unstake"), + inputSchema: { + stakingAsset: z.string().describe("Asset symbol to unstake (e.g., BNB, ETH)"), + amount: z.number().positive().describe("Amount to unstake"), + }, }, - async (params) => { + async (params: { stakingAsset: string; amount: number }) => { try { const response = await makeSignedRequest("POST", "/sapi/v1/staking/unstake", { stakingAsset: params.stakingAsset.toUpperCase(), @@ -179,8 +182,8 @@ Response includes: // ===================================================================== server.registerTool( "binance_us_staking_balance", - {}, - `Get current staking balance for assets on Binance.US. + { + description: `Get current staking balance for assets on Binance.US. Returns your current staking positions and their details. @@ -193,13 +196,14 @@ Response includes for each staked asset: - autoRestake: Whether auto-restaking is enabled If no asset is specified, returns balances for all staked assets.`, - { - asset: z - .string() - .optional() - .describe("Staked asset symbol. If empty, returns all assets with balances"), + inputSchema: { + asset: z + .string() + .optional() + .describe("Staked asset symbol. If empty, returns all assets with balances"), + }, }, - async (params) => { + async (params: { asset?: string }) => { try { const response = await makeSignedRequest("GET", "/sapi/v1/staking/stakingBalance", { ...(params.asset && { asset: params.asset.toUpperCase() }), @@ -229,8 +233,8 @@ If no asset is specified, returns balances for all staked assets.`, // ===================================================================== server.registerTool( "binance_us_staking_history", - {}, - `Get staking transaction history for assets on Binance.US. + { + description: `Get staking transaction history for assets on Binance.US. Returns a history of staking and unstaking transactions. @@ -242,24 +246,37 @@ Response includes for each transaction: - status: Transaction status (SUCCESS, PENDING, etc.) If no asset is specified, returns history for all assets.`, - { - asset: z - .string() - .optional() - .describe("Asset symbol. If empty, returns all assets with history"), - startTime: z.number().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().optional().describe("End timestamp in milliseconds"), - page: z.number().int().positive().optional().default(1).describe("Page number (default: 1)"), - limit: z - .number() - .int() - .min(1) - .max(500) - .optional() - .default(500) - .describe("Records per page (default: 500, max: 500)"), + inputSchema: { + asset: z + .string() + .optional() + .describe("Asset symbol. If empty, returns all assets with history"), + startTime: z.number().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().optional().describe("End timestamp in milliseconds"), + page: z + .number() + .int() + .positive() + .optional() + .default(1) + .describe("Page number (default: 1)"), + limit: z + .number() + .int() + .min(1) + .max(500) + .optional() + .default(500) + .describe("Records per page (default: 500, max: 500)"), + }, }, - async (params) => { + async (params: { + asset?: string; + startTime?: number; + endTime?: number; + page?: number; + limit?: number; + }) => { try { const response = await makeSignedRequest("GET", "/sapi/v1/staking/history", { ...(params.asset && { asset: params.asset.toUpperCase() }), @@ -293,8 +310,8 @@ If no asset is specified, returns history for all assets.`, // ===================================================================== server.registerTool( "binance_us_staking_rewards", - {}, - `Get staking rewards history for assets on Binance.US. + { + description: `Get staking rewards history for assets on Binance.US. Returns a history of staking rewards earned over time. @@ -311,24 +328,31 @@ Each reward record contains: - autoRestaked: Whether the reward was automatically restaked If no asset is specified, returns rewards for all staked assets.`, - { - asset: z - .string() - .optional() - .describe("Staked asset. If empty, returns all assets with rewards"), - startTime: z.number().optional().describe("Start timestamp in milliseconds"), - endTime: z.number().optional().describe("End timestamp in milliseconds"), - page: z.number().int().positive().optional().describe("Page/batch number"), - limit: z - .number() - .int() - .min(1) - .max(500) - .optional() - .default(500) - .describe("Records per batch (default: 500)"), + inputSchema: { + asset: z + .string() + .optional() + .describe("Staked asset. If empty, returns all assets with rewards"), + startTime: z.number().optional().describe("Start timestamp in milliseconds"), + endTime: z.number().optional().describe("End timestamp in milliseconds"), + page: z.number().int().positive().optional().describe("Page/batch number"), + limit: z + .number() + .int() + .min(1) + .max(500) + .optional() + .default(500) + .describe("Records per batch (default: 500)"), + }, }, - async (params) => { + async (params: { + asset?: string; + startTime?: number; + endTime?: number; + page?: number; + limit?: number; + }) => { try { const response = await makeSignedRequest("GET", "/sapi/v1/staking/stakingRewardsHistory", { ...(params.asset && { asset: params.asset.toUpperCase() }), diff --git a/src/tools/userdata-stream/index.ts b/src/tools/userdata-stream/index.ts index b52d0892..a016ba6c 100644 --- a/src/tools/userdata-stream/index.ts +++ b/src/tools/userdata-stream/index.ts @@ -30,8 +30,8 @@ export function registerUserDataStreamTools(server: McpServer) { // ===================================================================== server.registerTool( "binance_us_create_listen_key", - {}, - `Create a new listen key for User Data Stream WebSocket connection. + { + description: `Create a new listen key for User Data Stream WebSocket connection. The listen key is used to subscribe to real-time account updates via WebSocket. Connect to: ${BINANCE_US_CONFIG.WS_URL}/ws/ @@ -48,7 +48,7 @@ The stream sends updates for: - executionReport: Order/trade updates This endpoint requires API key but does NOT require signature.`, - {}, + }, async () => { try { // This endpoint only requires API key, not signature @@ -90,8 +90,8 @@ Response: ${JSON.stringify(response, null, 2)}`, // ===================================================================== server.registerTool( "binance_us_keepalive_listen_key", - {}, - `Extend the validity of a listen key by 60 minutes. + { + description: `Extend the validity of a listen key by 60 minutes. ⚠️ IMPORTANT: - Call this every 30 minutes to prevent the stream from closing @@ -99,10 +99,12 @@ Response: ${JSON.stringify(response, null, 2)}`, - This resets the 60-minute expiration timer This endpoint requires API key but does NOT require signature.`, - { - listenKey: z.string().describe("The listen key to keep alive"), + inputSchema: { + listenKey: z.string().describe("The listen key to keep alive"), + }, }, - async ({ listenKey }) => { + async (params: { listenKey: string }) => { + const { listenKey } = params; try { await makeSignedRequest("PUT", "/api/v3/userDataStream", { listenKey }); @@ -135,17 +137,19 @@ Remember to call this again in 30 minutes to maintain the connection.`, // ===================================================================== server.registerTool( "binance_us_close_listen_key", - {}, - `Close a User Data Stream by invalidating the listen key. + { + description: `Close a User Data Stream by invalidating the listen key. Use this when you're done receiving real-time updates. After closing, the WebSocket connection will be terminated. This endpoint requires API key but does NOT require signature.`, - { - listenKey: z.string().describe("The listen key to close/invalidate"), + inputSchema: { + listenKey: z.string().describe("The listen key to close/invalidate"), + }, }, - async ({ listenKey }) => { + async (params: { listenKey: string }) => { + const { listenKey } = params; try { await makeSignedRequest("DELETE", "/api/v3/userDataStream", { listenKey }); @@ -178,14 +182,14 @@ To receive real-time updates again, create a new listen key.`, // ===================================================================== server.registerTool( "binance_us_websocket_info", - {}, - `Get information about available WebSocket streams on Binance.US. + { + description: `Get information about available WebSocket streams on Binance.US. Returns details about: - Market data streams (public) - User data streams (requires listen key) - Connection URLs and limits`, - {}, + }, async () => { const info = { baseUrl: BINANCE_US_CONFIG.WS_URL, diff --git a/tsconfig.json b/tsconfig.json index 9eb59514..ae47488a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,6 +7,7 @@ "outDir": "./build", "rootDir": "./src", "strict": true, + "noImplicitAny": false, "esModuleInterop": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true, From e4aa869c24fad08bc1488733f4077a2cdab403c2 Mon Sep 17 00:00:00 2001 From: netpoe Date: Wed, 18 Mar 2026 11:51:31 -0600 Subject: [PATCH 10/16] feat: enhance Binance API integration with troubleshooting guidance, improved IP handling, and refined account retrieval parameters --- README.md | 23 ++++++++++++++ src/index.ts | 11 +++++++ src/modules/spot/account-api/getAccount.ts | 6 ++-- src/server/sse.ts | 31 ++++++++++++++++++- .../binance-spot/account-api/getAccount.ts | 4 ++- 5 files changed, 71 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a3c67cdf..45c637bd 100644 --- a/README.md +++ b/README.md @@ -158,6 +158,29 @@ npm run dev # STDIO npm run dev:sse # SSE ``` +### Troubleshooting: "Invalid API-key, IP, or permissions" + +If you use **IP whitelist** on Binance and see this error, Binance may be seeing a different IP than the one you whitelisted: + +- **Proxy** — The process can inherit `HTTP_PROXY` / `HTTPS_PROXY` (e.g. from Cursor or your shell). Outbound requests to Binance then go through the proxy, so Binance sees the proxy’s IP. +- **VPN** — System-wide VPN changes your exit IP. +- **IPv4 vs IPv6** — Your machine might reach Binance via IPv6 while you whitelisted an IPv4 address (or the reverse). + +**Fix (proxy):** Bypass the proxy for Binance by setting `NO_PROXY` when starting the server. In `.env`: + +```env +NO_PROXY=api.binance.com,api1.binance.com,api2.binance.com,api3.binance.com +``` + +Or in the shell before running: + +```bash +export NO_PROXY=api.binance.com,api1.binance.com,api2.binance.com,api3.binance.com +npm run dev:sse +``` + +If using Cursor’s MCP config, add `NO_PROXY` to the server’s `env` so the MCP process gets it. + --- ## 🖥️ Client Configuration diff --git a/src/index.ts b/src/index.ts index 046bdf94..0a12fcee 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,15 @@ #!/usr/bin/env node +import "dotenv/config"; + +// If Binance API is IP-restricted, ensure requests bypass any proxy (HTTP_PROXY/HTTPS_PROXY) +// so Binance sees your real IP. See README "Troubleshooting: Invalid API-key, IP, or permissions". +if (!process.env.NO_PROXY?.includes("binance.com")) { + const binanceNoProxy = "api.binance.com,api1.binance.com,api2.binance.com,api3.binance.com"; + process.env.NO_PROXY = process.env.NO_PROXY + ? `${process.env.NO_PROXY},${binanceNoProxy}` + : binanceNoProxy; +} + import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import type { Server } from "http"; diff --git a/src/modules/spot/account-api/getAccount.ts b/src/modules/spot/account-api/getAccount.ts index f791492d..3aa498c8 100644 --- a/src/modules/spot/account-api/getAccount.ts +++ b/src/modules/spot/account-api/getAccount.ts @@ -16,7 +16,9 @@ export function registerBinanceGetAccount(server: McpServer) { }, async ({ recvWindow }) => { try { - const params: any = {}; + const params: any = { + omitZeroBalances: true, + }; if (recvWindow !== undefined) params.recvWindow = recvWindow; const response = await (spotClient as any).restAPI.getAccount(params); @@ -36,7 +38,7 @@ export function registerBinanceGetAccount(server: McpServer) { return { content: [ - { type: "text", text: `Failedddd to retrieve account information: ${errorMessage}` }, + { type: "text", text: `Failed to retrieve account information: ${errorMessage}` }, ], isError: true, }; diff --git a/src/server/sse.ts b/src/server/sse.ts index 51e9c9dc..88cd7336 100644 --- a/src/server/sse.ts +++ b/src/server/sse.ts @@ -14,10 +14,37 @@ import Logger from "../utils/logger.js"; import { startServer } from "./base.js"; // src/server/sse.ts +// Credentials are not passed per-request here. They are loaded at process startup (see index.ts +// dotenv/config) and applied when config/binanceClient.ts is first required by tool handlers. import "dotenv/config"; const PORT = process.env.PORT || 3002; +function ensureBinanceEnv(): void { + const key = process.env.BINANCE_API_KEY; + const secret = process.env.BINANCE_API_SECRET; + if (!key?.trim() || !secret?.trim()) { + Logger.warn( + "[SSE] BINANCE_API_KEY or BINANCE_API_SECRET is missing or empty. Signed API calls will fail.", + ); + } +} + +/** Log the outbound IP this process uses (same as Binance would see). Helps debug IP whitelist / proxy issues. */ +async function logOutboundIp(): Promise { + try { + const res = await fetch("https://api.ipify.org?format=json"); + const data = (await res.json()) as { ip?: string }; + const ip = data?.ip ?? "(unknown)"; + Logger.info(`[SSE] Outbound IP (Binance will see this): ${ip}`); + } catch (err) { + Logger.warn( + "[SSE] Could not resolve outbound IP:", + err instanceof Error ? err.message : String(err), + ); + } +} + /** Transport + Streamable HTTP handleRequest for routing and logging. */ type StreamableTransportWithHandle = Transport & { handleRequest(req: IncomingMessage, res: ServerResponse, parsedBody?: unknown): Promise; @@ -164,9 +191,11 @@ export const startSSEServer = async (): Promise => { res.json({ status: "ok", mode: "streamable-http" }); }); - const httpServer = app.listen(PORT, () => { + const httpServer = app.listen(PORT, async () => { Logger.info(`Binance MCP Server running in Streamable HTTP mode at http://localhost:${PORT}`); Logger.info(`MCP endpoints: http://localhost:${PORT}/mcp and http://localhost:${PORT}/sse`); + ensureBinanceEnv(); + await logOutboundIp(); }); return httpServer; diff --git a/src/tools/binance-spot/account-api/getAccount.ts b/src/tools/binance-spot/account-api/getAccount.ts index 950a4704..4de06d52 100644 --- a/src/tools/binance-spot/account-api/getAccount.ts +++ b/src/tools/binance-spot/account-api/getAccount.ts @@ -16,7 +16,9 @@ export function registerBinanceGetAccount(server: McpServer) { }, async ({ recvWindow }) => { try { - const params: any = {}; + const params: any = { + omitZeroBalances: true, + }; if (recvWindow !== undefined) params.recvWindow = recvWindow; const response = await (spotClient as any).restAPI.getAccount(params); From e25ea9fb4d985073418476f5c512ed4714a0d8f3 Mon Sep 17 00:00:00 2001 From: netpoe Date: Mon, 30 Mar 2026 15:54:01 -0600 Subject: [PATCH 11/16] feat: update SSE server configuration to allow private URLs by setting host to 0.0.0.0 for improved accessibility --- src/server/sse.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/server/sse.ts b/src/server/sse.ts index 88cd7336..50e04659 100644 --- a/src/server/sse.ts +++ b/src/server/sse.ts @@ -138,7 +138,10 @@ interface SessionEntry { // Start the server in Streamable HTTP mode (replaces deprecated SSE transport) export const startSSEServer = async (): Promise => { try { - const app = createMcpExpressApp(); + // Default createMcpExpressApp() uses host 127.0.0.1 → localhostHostValidation() + // rejects any other Host (403). Private URLs like binance-mcp.railway.internal + // must be allowed when the process listens on 0.0.0.0 (Railway, Docker, LAN). + const app = createMcpExpressApp({ host: "0.0.0.0" }); app.use(cors()); const sessions = new Map(); From 2175080b1e1a3366466e3ef905a4e91bee47af57 Mon Sep 17 00:00:00 2001 From: netpoe Date: Wed, 8 Apr 2026 09:32:07 -0600 Subject: [PATCH 12/16] feat: add Dockerfile and docker-compose.yml for containerized Binance MCP application setup --- Dockerfile | 30 ++++++++++++++++++++++++++++++ docker-compose.yml | 15 +++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..9b499481 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +# syntax=docker/dockerfile:1 + +FROM oven/bun:1 AS builder +WORKDIR /app + +COPY package.json bun.lock ./ +RUN bun install --frozen-lockfile + +COPY tsconfig.json ./ +COPY src ./src +RUN bun run build + +FROM oven/bun:1-slim AS runner +WORKDIR /app + +ENV NODE_ENV=production +ENV PORT=3002 + +COPY package.json bun.lock ./ +RUN bun install --frozen-lockfile --production + +COPY --from=builder /app/build ./build + +EXPOSE 3002 + +# Streamable HTTP (SSE-compatible endpoints: /mcp, /sse, health: /health) +CMD ["bun", "run", "build/index.js", "--sse"] + +HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \ + CMD bun -e "fetch('http://127.0.0.1:'+(process.env.PORT||'3002')+'/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))" diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..cac0b5e9 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,15 @@ +services: + binance-mcp: + build: + context: . + dockerfile: Dockerfile + image: binance-mcp:latest + container_name: binance-mcp + restart: unless-stopped + # App listens on 3002 inside the container; host port 80 is the default (override with HOST_PORT). + ports: + - "${HOST_PORT:-80}:3002" + env_file: + - .env + environment: + PORT: "3002" From ad742a0b2c9a8d83ce2964089549dae36b9b4e84 Mon Sep 17 00:00:00 2001 From: Gus Date: Wed, 8 Apr 2026 17:27:45 +0000 Subject: [PATCH 13/16] refactor: update Dockerfile to simplify installation process by removing lockfile usage and adjusting COPY commands --- Dockerfile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9b499481..19286676 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,12 @@ # syntax=docker/dockerfile:1 +# oven/bun:1 tracks latest Bun 1.x (includes 1.2+ text lockfile default). No lockfile COPY: +# .gitignore uses *.lock and lockfiles are often absent in clones — install resolves from package.json. FROM oven/bun:1 AS builder WORKDIR /app -COPY package.json bun.lock ./ -RUN bun install --frozen-lockfile +COPY package.json ./ +RUN bun install COPY tsconfig.json ./ COPY src ./src @@ -16,8 +18,8 @@ WORKDIR /app ENV NODE_ENV=production ENV PORT=3002 -COPY package.json bun.lock ./ -RUN bun install --frozen-lockfile --production +COPY package.json ./ +RUN bun install --production COPY --from=builder /app/build ./build From 5ac3908c567d8cbe0bd5d024e8328909013d7aa1 Mon Sep 17 00:00:00 2001 From: Gus Date: Sat, 11 Apr 2026 04:02:39 +0000 Subject: [PATCH 14/16] feat: logs only whitelisted MCP tools --- src/server/sse.ts | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/server/sse.ts b/src/server/sse.ts index 50e04659..0b4e18ea 100644 --- a/src/server/sse.ts +++ b/src/server/sse.ts @@ -59,8 +59,17 @@ type StreamableTransportWithHandle = Transport & { * 4. Protocol (SDK) puts it in response.result and calls transport.send({ jsonrpc, id, result }). * 5. StreamableHTTPServerTransport.send() writes the JSON to the response/SSE stream. * - * This wrapper logs every tools/call request and every tool result content. + * This wrapper optionally logs tools/call requests and tool result content for selected tools + * (see {@link MCP_TOOLS_TO_LOG}). */ + +/** MCP tool names to log at console (request args + result content). Add names here as needed. */ +const MCP_TOOLS_TO_LOG = new Set(["BinanceNewOrder", "BinanceOrderOco", "BinanceGetOrder", "BinanceGetOpenOrders"]); + +function shouldLogMcpTool(name: unknown): name is string { + return typeof name === "string" && MCP_TOOLS_TO_LOG.has(name); +} + function wrapTransportWithToolLogging( transport: StreamableHTTPServerTransport, ): StreamableTransportWithHandle { @@ -101,12 +110,13 @@ function wrapTransportWithToolLogging( const msg = message as { id?: string | number; result?: { content?: unknown } }; if (msg?.result && msg.result.content !== undefined) { const toolName = pendingToolCalls.get(msg.id as string | number); - - console.log( - "[MCP Streamable HTTP] tool result content", - toolName !== undefined ? `(tool: ${toolName})` : "", - JSON.stringify(msg.result.content), - ); + if (toolName !== undefined) { + console.log( + "[MCP Streamable HTTP] tool result content", + `(tool: ${toolName})`, + JSON.stringify(msg.result.content), + ); + } if (msg.id !== undefined) pendingToolCalls.delete(msg.id); } @@ -116,7 +126,7 @@ function wrapTransportWithToolLogging( const body = parsedBody ?? (req as IncomingMessage & { body?: unknown }).body; const parsed = typeof body === "string" ? JSON.parse(body as string) : body; - if (parsed?.method === "tools/call" && parsed.params) { + if (parsed?.method === "tools/call" && parsed.params && shouldLogMcpTool(parsed.params.name)) { console.log( "[MCP Streamable HTTP] tools/call request", parsed.params.name, From 5cf122daec5f40bf9cfb7093bb0f2c928cb1da45 Mon Sep 17 00:00:00 2001 From: Gus Date: Sat, 11 Apr 2026 04:08:55 +0000 Subject: [PATCH 15/16] chore: remove unused cors package and its type definitions from package.json --- package.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/package.json b/package.json index b7f33993..f4bb6155 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,6 @@ "@binance/vip-loan": "^8.0.0", "@binance/wallet": "^15.0.0", "@modelcontextprotocol/sdk": "^1.11.0", - "cors": "^2.8.5", "dotenv": "^16.5.0", "express": "^4.18.2", "zod": "^3.22.4" @@ -77,7 +76,6 @@ "@eslint/js": "^10.0.1", "@stylistic/eslint-plugin": "^5.10.0", "@types/bun": "latest", - "@types/cors": "^2.8.17", "@types/express": "^4.17.21", "@types/figlet": "^1.5.8", "@types/fs-extra": "^11.0.4", From 7571c0b02601b45a2c087c4f24cee9add796974a Mon Sep 17 00:00:00 2001 From: Gus Date: Sat, 11 Apr 2026 04:36:22 +0000 Subject: [PATCH 16/16] refactor: improve logging for MCP tools by separating tool name and arguments handling --- src/server/sse.ts | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/server/sse.ts b/src/server/sse.ts index 0b4e18ea..6da61225 100644 --- a/src/server/sse.ts +++ b/src/server/sse.ts @@ -59,14 +59,14 @@ type StreamableTransportWithHandle = Transport & { * 4. Protocol (SDK) puts it in response.result and calls transport.send({ jsonrpc, id, result }). * 5. StreamableHTTPServerTransport.send() writes the JSON to the response/SSE stream. * - * This wrapper optionally logs tools/call requests and tool result content for selected tools - * (see {@link MCP_TOOLS_TO_LOG}). + * This wrapper logs every tools/call (tool name). Request arguments and tool result content are + * logged only for names in {@link MCP_TOOLS_TO_LOG}. */ -/** MCP tool names to log at console (request args + result content). Add names here as needed. */ +/** MCP tool names for which we log request arguments and result content. Add names here as needed. */ const MCP_TOOLS_TO_LOG = new Set(["BinanceNewOrder", "BinanceOrderOco", "BinanceGetOrder", "BinanceGetOpenOrders"]); -function shouldLogMcpTool(name: unknown): name is string { +function shouldLogMcpToolContent(name: unknown): name is string { return typeof name === "string" && MCP_TOOLS_TO_LOG.has(name); } @@ -126,13 +126,19 @@ function wrapTransportWithToolLogging( const body = parsedBody ?? (req as IncomingMessage & { body?: unknown }).body; const parsed = typeof body === "string" ? JSON.parse(body as string) : body; - if (parsed?.method === "tools/call" && parsed.params && shouldLogMcpTool(parsed.params.name)) { - console.log( - "[MCP Streamable HTTP] tools/call request", - parsed.params.name, - parsed.params.arguments, - ); - if (parsed.id !== undefined) pendingToolCalls.set(parsed.id, parsed.params.name); + if (parsed?.method === "tools/call" && parsed.params) { + const name = parsed.params.name; + if (typeof name === "string") { + console.log("[MCP Streamable HTTP] tools/call request", name); + if (shouldLogMcpToolContent(name)) { + console.log( + "[MCP Streamable HTTP] tools/call arguments", + name, + parsed.params.arguments, + ); + if (parsed.id !== undefined) pendingToolCalls.set(parsed.id, name); + } + } } return transport.handleRequest(req, res, parsedBody ?? body);