7
7
This script verifies a full install + runtime setup of the MCP Gateway:
8
8
- Creates a virtual environment and installs dependencies.
9
9
- Builds and runs the Docker HTTPS container.
10
- - Starts the MCP Time Server via npx supergateway .
10
+ - Starts the MCP Time Server via mcpgateway.translate .
11
11
- Verifies /health, /ready, /version before registering the gateway.
12
12
- Federates the time server as a gateway, verifies its tool list.
13
13
- Invokes the remote tool via /rpc and checks the result.
46
46
47
47
# ───────────────────────── Ports / constants ────────────────────────────
48
48
PORT_GATEWAY = 4444 # HTTPS container
49
- PORT_TIME_SERVER = 8002 # supergateway
49
+ PORT_TIME_SERVER = 8002 # mcpgateway.translate
50
50
DOCKER_CONTAINER = "mcpgateway"
51
51
52
52
MAKE_VENV_CMD = ["make" , "venv" , "install" , "install-dev" ]
53
53
MAKE_DOCKER_BUILD = ["make" , "docker" ]
54
54
MAKE_DOCKER_RUN = ["make" , "docker-run-ssl-host" ]
55
55
MAKE_DOCKER_STOP = ["make" , "docker-stop" ]
56
56
57
- SUPERGW_CMD = [
58
- "npx " ,
59
- "-y " ,
60
- "supergateway " ,
57
+ TRANSLATE_CMD = [
58
+ "python3 " ,
59
+ "-m " ,
60
+ "mcpgateway.translate " ,
61
61
"--stdio" ,
62
- "\" uvx mcp-server-time --local-timezone=Europe/Dublin\" " ,
62
+ "uvx mcp-server-time --local-timezone=Europe/Dublin" ,
63
63
"--port" ,
64
64
str (PORT_TIME_SERVER ),
65
65
]
@@ -222,30 +222,30 @@ def request(method: str, path: str, *, json_data=None, **kw):
222
222
223
223
224
224
# ───────────────────────────── Cleanup logic ─────────────────────────────
225
- _supergw_proc : subprocess .Popen | None = None
226
- _supergw_log_file = None
225
+ _translate_proc : subprocess .Popen | None = None
226
+ _translate_log_file = None
227
227
228
228
229
229
def cleanup ():
230
230
log_section ("Cleanup" , "🧹" )
231
- global _supergw_proc , _supergw_log_file
231
+ global _translate_proc , _translate_log_file
232
232
233
- # Clean up the supergateway process
234
- if _supergw_proc and _supergw_proc .poll () is None :
235
- logging .info ("🔄 Terminating supergateway process (PID: %d)" , _supergw_proc .pid )
236
- _supergw_proc .terminate ()
233
+ # Clean up the translate process
234
+ if _translate_proc and _translate_proc .poll () is None :
235
+ logging .info ("🔄 Terminating mcpgateway.translate process (PID: %d)" , _translate_proc .pid )
236
+ _translate_proc .terminate ()
237
237
try :
238
- _supergw_proc .wait (timeout = 5 )
239
- logging .info ("✅ Supergateway process terminated cleanly" )
238
+ _translate_proc .wait (timeout = 5 )
239
+ logging .info ("✅ mcpgateway.translate process terminated cleanly" )
240
240
except subprocess .TimeoutExpired :
241
- logging .warning ("⚠️ Supergateway didn't terminate in time, killing it" )
242
- _supergw_proc .kill ()
243
- _supergw_proc .wait ()
241
+ logging .warning ("⚠️ mcpgateway.translate didn't terminate in time, killing it" )
242
+ _translate_proc .kill ()
243
+ _translate_proc .wait ()
244
244
245
245
# Close log file if open
246
- if _supergw_log_file :
247
- _supergw_log_file .close ()
248
- _supergw_log_file = None
246
+ if _translate_log_file :
247
+ _translate_log_file .close ()
248
+ _translate_log_file = None
249
249
250
250
# Stop docker container
251
251
logging .info ("🐋 Stopping Docker container" )
@@ -294,22 +294,7 @@ def step_4_docker_run():
294
294
295
295
296
296
def step_5_start_time_server (restart = False ):
297
- global _supergw_proc , _supergw_log_file
298
-
299
- nvm_sh = os .path .expanduser ("~/.nvm/nvm.sh" )
300
- cmd = f'source "{ nvm_sh } " && nvm use default >/dev/null && npx --version'
301
-
302
- # Check if npx is available
303
- try :
304
- npx_version = subprocess .check_output (
305
- ["bash" , "-c" , cmd ],
306
- text = True ,
307
- stderr = subprocess .DEVNULL
308
- ).strip ()
309
-
310
- logging .info ("🔍 Found npx version: %s" , npx_version )
311
- except (subprocess .CalledProcessError , FileNotFoundError ):
312
- raise RuntimeError ("npx not found. Please install Node.js and npm." )
297
+ global _translate_proc , _translate_log_file
313
298
314
299
# Check if uvx is available
315
300
try :
@@ -337,31 +322,22 @@ def step_5_start_time_server(restart=False):
337
322
338
323
if not port_open (PORT_TIME_SERVER ):
339
324
log_section ("Launching MCP-Time-Server" , "⏰" )
340
- logging .info ("🚀 Command: %s" , " " .join (shlex .quote (c ) for c in SUPERGW_CMD ))
325
+ logging .info ("🚀 Command: %s" , " " .join (shlex .quote (c ) for c in TRANSLATE_CMD ))
341
326
342
327
# Create a log file for the time server output
343
- log_filename = f"supergateway_{ int (time .time ())} .log"
344
- _supergw_log_file = open (log_filename , "w" )
345
- logging .info ("📝 Logging supergateway output to: %s" , log_filename )
346
-
347
- # Start the process with output capture
348
- cmd_str = " " .join (SUPERGW_CMD )
349
- bash_cmd = f'''
350
- export NVM_DIR="$HOME/.nvm"
351
- source "{ nvm_sh } "
352
- nvm use default >/dev/null
353
- exec { cmd_str }
354
- '''
355
-
356
- _supergw_proc = subprocess .Popen (
357
- ["bash" , "-c" , bash_cmd ],
358
- stdout = _supergw_log_file ,
328
+ log_filename = f"translate_{ int (time .time ())} .log"
329
+ _translate_log_file = open (log_filename , "w" )
330
+ logging .info ("📝 Logging mcpgateway.translate output to: %s" , log_filename )
331
+
332
+ # Start the process directly
333
+ _translate_proc = subprocess .Popen (
334
+ TRANSLATE_CMD ,
335
+ stdout = _translate_log_file ,
359
336
stderr = subprocess .STDOUT ,
360
337
text = True ,
361
338
bufsize = 1
362
339
)
363
-
364
- logging .info ("🔍 Started supergateway process with PID: %d" , _supergw_proc .pid )
340
+ logging .info ("🔍 Started mcpgateway.translate process with PID: %d" , _translate_proc .pid )
365
341
366
342
# Wait for the server to start
367
343
start_time = time .time ()
@@ -370,10 +346,10 @@ def step_5_start_time_server(restart=False):
370
346
371
347
while time .time () - start_time < timeout :
372
348
# Check if process is still running
373
- exit_code = _supergw_proc .poll ()
349
+ exit_code = _translate_proc .poll ()
374
350
if exit_code is not None :
375
351
# Process exited, read the log file
376
- _supergw_log_file .close ()
352
+ _translate_log_file .close ()
377
353
with open (log_filename , "r" ) as f :
378
354
output = f .read ()
379
355
logging .error ("❌ Time-Server process exited with code %d" , exit_code )
@@ -389,7 +365,7 @@ def step_5_start_time_server(restart=False):
389
365
time .sleep (1 )
390
366
391
367
# Double-check it's still running
392
- if _supergw_proc .poll () is None :
368
+ if _translate_proc .poll () is None :
393
369
return
394
370
else :
395
371
raise RuntimeError ("Time-Server started but then immediately exited" )
@@ -401,11 +377,11 @@ def step_5_start_time_server(restart=False):
401
377
time .sleep (check_interval )
402
378
403
379
# Timeout reached
404
- if _supergw_proc .poll () is None :
405
- _supergw_proc .terminate ()
406
- _supergw_proc .wait ()
380
+ if _translate_proc .poll () is None :
381
+ _translate_proc .terminate ()
382
+ _translate_proc .wait ()
407
383
408
- _supergw_log_file .close ()
384
+ _translate_log_file .close ()
409
385
with open (log_filename , "r" ) as f :
410
386
output = f .read ()
411
387
logging .error ("📋 Process output:\n %s" , output )
@@ -604,10 +580,9 @@ def main():
604
580
failed = True
605
581
logging .error ("❌ Failure: %s" , e , exc_info = args .verbose )
606
582
logging .error ("\n 💡 Troubleshooting tips:" )
607
- logging .error (" - Check if npx is installed: npx --version" )
608
583
logging .error (" - Check if uvx is installed: uvx --version" )
609
584
logging .error (" - Check if port %d is already in use: lsof -i :%d" , PORT_TIME_SERVER , PORT_TIME_SERVER )
610
- logging .error (" - Look for supergateway_ *.log files for detailed output" )
585
+ logging .error (" - Look for translate_ *.log files for detailed output" )
611
586
logging .error (" - Try running with -v for verbose output" )
612
587
finally :
613
588
if not failed :
0 commit comments