@@ -5,28 +5,36 @@ import {
55 ListToolsRequestSchema ,
66 type CallToolRequest ,
77} from "@modelcontextprotocol/sdk/types.js" ;
8+
89import {
910 GET_BALANCE_TOOL ,
1011 GET_LATEST_BLOCK_TOOL ,
1112 DEPLOY_CONTRACTS_TOOL ,
1213 SEND_FUNDS_TOOL ,
1314 GET_TRANSACTION_RECEIPT_TOOL ,
1415 GET_TOKEN_BALANCE_TOOL ,
16+ FETCH_TRANSACTIONS_TOOL ,
17+ GET_LOGS_TOOL ,
18+ CALL_CONTRACT_FUNCTION ,
1519 STAKE_TOOL ,
1620 UNSTAKE_TOOL ,
17- GET_LOGS_TOOL ,
1821 GET_HISTORICAL_ORDERS_TOOL ,
22+ TRACK_STAKED_TOKENS ,
1923} from "./tools/tools.js" ;
2024import { getBalance } from "./tools/hyper-evm/getBalance/index.js" ;
2125import { getLatestBlock } from "./tools/hyper-evm/getBlockNumber/index.js" ;
2226import { deployContracts } from "./tools/hyper-evm/deployContracts/index.js" ;
2327import type { DeployContractsInput } from "./tools/hyper-evm/deployContracts/schemas.js" ;
28+ import { callContracts } from "./tools/hyper-evm/callContracts/index.js" ;
29+ import { CallContractSchema } from "./tools/hyper-evm/callContracts/schema.js" ;
2430import { sendFunds } from "./tools/hyper-evm/sendFunds/index.js" ;
2531import { sendFundsInputSchema } from "./tools/hyper-evm/sendFunds/schemas.js" ;
2632import { getTransactionReceipt } from "./tools/hyper-evm/getTransactionReceipt/index.js" ;
2733import type { getTransactionReceiptInput } from "./tools/hyper-evm/getTransactionReceipt/schemas.js" ;
2834import { getTokenBalanceInputSchema } from "./tools/hyper-evm/getTokenBalance/schemas.js" ;
2935import { getTokenBalance } from "./tools/hyper-evm/getTokenBalance/index.js" ;
36+ import { fetchTransactions } from "./tools/hyper-evm/fetchTransactions/index.js" ;
37+ import type { FetchTransactionsInput } from "./tools/hyper-evm/fetchTransactions/schemas.js" ;
3038import {
3139 performStaking ,
3240 performUnstaking ,
@@ -37,9 +45,12 @@ import {
3745} from "./tools/hyper-evm/handleStake/schemas.js" ;
3846import { getLogs } from "./tools/hyper-evm/getLogs/index.js" ;
3947import { getHistoricalOrders } from "./tools/hypercore/getHistoricalOrders/index.js" ;
48+ import { getStakedtokens } from "./tools/hypercore/trackstakedtokens/index.js" ;
49+ import { StakedInputSchema } from "./tools/hypercore/trackstakedtokens/schema.js" ;
4050
4151async function main ( ) {
4252 console . error ( "Starting Hyperliquid MCP server..." ) ;
53+
4354 const server = new Server (
4455 {
4556 name : "hyperliquid" ,
@@ -68,6 +79,54 @@ async function main() {
6879 return balance ;
6980 }
7081
82+ case "call_contract_function" : {
83+ try {
84+ const { contractAddress, functionName, abi, functionArgs } =
85+ args as {
86+ contractAddress : string ;
87+ functionName : string ;
88+ abi : any ;
89+ functionArgs ?: any [ ] ;
90+ } ;
91+
92+ const validatedInput = CallContractSchema . parse ( {
93+ contractAddress,
94+ functionName,
95+ abi,
96+ functionArgs,
97+ } ) ;
98+
99+ const result = await callContracts ( validatedInput ) ;
100+
101+ return {
102+ content : [
103+ {
104+ type : "text" ,
105+ text : JSON . stringify (
106+ result ,
107+ ( _ , v ) => ( typeof v === "bigint" ? v . toString ( ) : v ) ,
108+ 2
109+ ) ,
110+ } ,
111+ ] ,
112+ } ;
113+ } catch ( validationError ) {
114+ console . error ( "Validation error:" , validationError ) ;
115+ return {
116+ content : [
117+ {
118+ type : "text" ,
119+ text : `Error: ${
120+ validationError instanceof Error
121+ ? validationError . message
122+ : String ( validationError )
123+ } `,
124+ } ,
125+ ] ,
126+ } ;
127+ }
128+ }
129+
71130 case "deploy_contracts" : {
72131 const input = args as DeployContractsInput ;
73132 const result = await deployContracts ( input ) ;
@@ -110,6 +169,12 @@ async function main() {
110169 return result ;
111170 }
112171
172+ case "fetch_transactions" : {
173+ const input = args as FetchTransactionsInput ;
174+ const result = await fetchTransactions ( input ) ;
175+ return result ;
176+ }
177+
113178 case "stake" : {
114179 const input = args as {
115180 amountToStake : string ;
@@ -151,9 +216,19 @@ async function main() {
151216 return result ;
152217 }
153218
219+ case "track_staked_tokens" : {
220+ const input = args as {
221+ userAddress : string ;
222+ isTestnet : boolean | string ;
223+ } ;
224+ const validatedInput = StakedInputSchema . parse ( input ) ;
225+ const result = await getStakedtokens ( validatedInput ) ;
226+ return result ;
227+ }
228+
154229 default : {
155230 throw new Error (
156- `Tool '${ name } ' not found. Available tools: get_latest_block, get_balance, deploy_contracts, send_funds, get_transaction_receipt, get_token_balance, stake, unstake`
231+ `Tool '${ name } ' not found. Available tools: get_latest_block, get_balance, deploy_contracts, send_funds, get_transaction_receipt, get_token_balance, stake, unstake, get_logs, call_contract_function, track_staked_tokens `
157232 ) ;
158233 }
159234 }
@@ -181,10 +256,13 @@ async function main() {
181256 SEND_FUNDS_TOOL ,
182257 GET_TRANSACTION_RECEIPT_TOOL ,
183258 GET_TOKEN_BALANCE_TOOL ,
259+ FETCH_TRANSACTIONS_TOOL ,
260+ CALL_CONTRACT_FUNCTION ,
184261 STAKE_TOOL ,
185262 UNSTAKE_TOOL ,
186263 GET_LOGS_TOOL ,
187264 GET_HISTORICAL_ORDERS_TOOL ,
265+ TRACK_STAKED_TOKENS ,
188266 ] ,
189267 } ;
190268 } ) ;
0 commit comments