@@ -5,22 +5,27 @@ 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+ GET_LOGS_TOOL ,
17+ CALL_CONTRACT_FUNCTION ,
1518 STAKE_TOOL ,
1619 UNSTAKE_TOOL ,
17- GET_LOGS_TOOL ,
1820 GET_HISTORICAL_ORDERS_TOOL ,
21+ TRACK_STAKED_TOKENS ,
1922} from "./tools/tools.js" ;
2023import { getBalance } from "./tools/hyper-evm/getBalance/index.js" ;
2124import { getLatestBlock } from "./tools/hyper-evm/getBlockNumber/index.js" ;
2225import { deployContracts } from "./tools/hyper-evm/deployContracts/index.js" ;
2326import type { DeployContractsInput } from "./tools/hyper-evm/deployContracts/schemas.js" ;
27+ import { callContracts } from "./tools/hyper-evm/callContracts/index.js" ;
28+ import { CallContractSchema } from "./tools/hyper-evm/callContracts/schema.js" ;
2429import { sendFunds } from "./tools/hyper-evm/sendFunds/index.js" ;
2530import { sendFundsInputSchema } from "./tools/hyper-evm/sendFunds/schemas.js" ;
2631import { getTransactionReceipt } from "./tools/hyper-evm/getTransactionReceipt/index.js" ;
@@ -37,9 +42,12 @@ import {
3742} from "./tools/hyper-evm/handleStake/schemas.js" ;
3843import { getLogs } from "./tools/hyper-evm/getLogs/index.js" ;
3944import { getHistoricalOrders } from "./tools/hypercore/getHistoricalOrders/index.js" ;
45+ import { getStakedtokens } from "./tools/hypercore/trackstakedtokens/index.js" ;
46+ import { StakedInputSchema } from "./tools/hypercore/trackstakedtokens/schema.js" ;
4047
4148async function main ( ) {
4249 console . error ( "Starting Hyperliquid MCP server..." ) ;
50+
4351 const server = new Server (
4452 {
4553 name : "hyperliquid" ,
@@ -68,6 +76,54 @@ async function main() {
6876 return balance ;
6977 }
7078
79+ case "call_contract_function" : {
80+ try {
81+ const { contractAddress, functionName, abi, functionArgs } =
82+ args as {
83+ contractAddress : string ;
84+ functionName : string ;
85+ abi : any ;
86+ functionArgs ?: any [ ] ;
87+ } ;
88+
89+ const validatedInput = CallContractSchema . parse ( {
90+ contractAddress,
91+ functionName,
92+ abi,
93+ functionArgs,
94+ } ) ;
95+
96+ const result = await callContracts ( validatedInput ) ;
97+
98+ return {
99+ content : [
100+ {
101+ type : "text" ,
102+ text : JSON . stringify (
103+ result ,
104+ ( _ , v ) => ( typeof v === "bigint" ? v . toString ( ) : v ) ,
105+ 2
106+ ) ,
107+ } ,
108+ ] ,
109+ } ;
110+ } catch ( validationError ) {
111+ console . error ( "Validation error:" , validationError ) ;
112+ return {
113+ content : [
114+ {
115+ type : "text" ,
116+ text : `Error: ${
117+ validationError instanceof Error
118+ ? validationError . message
119+ : String ( validationError )
120+ } `,
121+ } ,
122+ ] ,
123+ } ;
124+ }
125+ }
126+
71127 case "deploy_contracts" : {
72128 const input = args as DeployContractsInput ;
73129 const result = await deployContracts ( input ) ;
@@ -151,9 +207,19 @@ async function main() {
151207 return result ;
152208 }
153209
210+ case "track_staked_tokens" : {
211+ const input = args as {
212+ userAddress : string ;
213+ isTestnet : boolean | string ;
214+ } ;
215+ const validatedInput = StakedInputSchema . parse ( input ) ;
216+ const result = await getStakedtokens ( validatedInput ) ;
217+ return result ;
218+ }
219+
154220 default : {
155221 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`
222+ `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 `
157223 ) ;
158224 }
159225 }
@@ -181,10 +247,12 @@ async function main() {
181247 SEND_FUNDS_TOOL ,
182248 GET_TRANSACTION_RECEIPT_TOOL ,
183249 GET_TOKEN_BALANCE_TOOL ,
250+ CALL_CONTRACT_FUNCTION ,
184251 STAKE_TOOL ,
185252 UNSTAKE_TOOL ,
186253 GET_LOGS_TOOL ,
187254 GET_HISTORICAL_ORDERS_TOOL ,
255+ TRACK_STAKED_TOKENS ,
188256 ] ,
189257 } ;
190258 } ) ;
0 commit comments