@@ -576,6 +576,62 @@ async def run_as_server():
576576def run_standard_server ():
577577 mcp .run ()
578578
579+ def start_server ():
580+ """Entry point for 'poetry start' command - runs HTTP server"""
581+ try :
582+ config = get_config ()
583+ logger .info ("HyperLiquid MCP Server starting..." )
584+ network = "Testnet" if config .testnet else "Mainnet"
585+ logger .info (f"Network: { network } " )
586+ account_display = config .account_address or "Will be derived from private key"
587+ logger .info (f"Account: { account_display } " )
588+ log_path = os .path .join (os .path .dirname (os .path .abspath (__file__ )), 'hyperliquid_mcp.log' )
589+ logger .info (f"Logs will be written to: { log_path } " )
590+
591+ asyncio .run (run_as_server ())
592+ except Exception as e :
593+ logger .error (f"Failed to start server: { e } " )
594+ print (f"Failed to start server: { e } " )
595+ print ("\n To configure the server:" )
596+ print ("1. Set environment variables:" )
597+ print (" export HYPERLIQUID_PRIVATE_KEY='your_private_key'" )
598+ print (" export HYPERLIQUID_TESTNET='false' # or 'true' for testnet" )
599+ print (" export HYPERLIQUID_ACCOUNT_ADDRESS='your_address' # optional" )
600+ print ("\n 2. Or create a config.json file:" )
601+ print (' {"private_key": "your_private_key", "testnet": false, "account_address": "your_address"}' )
602+ print ("\n 3. Or create a .env file:" )
603+ print (" HYPERLIQUID_PRIVATE_KEY=your_private_key" )
604+ print (" HYPERLIQUID_TESTNET=false" )
605+ print (" HYPERLIQUID_ACCOUNT_ADDRESS=your_address" )
606+
607+ def stdio_server ():
608+ """Entry point for 'poetry stdio' command - runs stdio server"""
609+ try :
610+ config = get_config ()
611+ logger .info ("HyperLiquid MCP Server starting in stdio mode..." )
612+ network = "Testnet" if config .testnet else "Mainnet"
613+ logger .info (f"Network: { network } " )
614+ account_display = config .account_address or "Will be derived from private key"
615+ logger .info (f"Account: { account_display } " )
616+ log_path = os .path .join (os .path .dirname (os .path .abspath (__file__ )), 'hyperliquid_mcp.log' )
617+ logger .info (f"Logs will be written to: { log_path } " )
618+
619+ run_standard_server ()
620+ except Exception as e :
621+ logger .error (f"Failed to start stdio server: { e } " )
622+ print (f"Failed to start stdio server: { e } " )
623+ print ("\n To configure the server:" )
624+ print ("1. Set environment variables:" )
625+ print (" export HYPERLIQUID_PRIVATE_KEY='your_private_key'" )
626+ print (" export HYPERLIQUID_TESTNET='false' # or 'true' for testnet" )
627+ print (" export HYPERLIQUID_ACCOUNT_ADDRESS='your_address' # optional" )
628+ print ("\n 2. Or create a config.json file:" )
629+ print (' {"private_key": "your_private_key", "testnet": false, "account_address": "your_address"}' )
630+ print ("\n 3. Or create a .env file:" )
631+ print (" HYPERLIQUID_PRIVATE_KEY=your_private_key" )
632+ print (" HYPERLIQUID_TESTNET=false" )
633+ print (" HYPERLIQUID_ACCOUNT_ADDRESS=your_address" )
634+
579635if __name__ == "__main__" :
580636 try :
581637 config = get_config ()
0 commit comments