Skip to content

Commit 534f2af

Browse files
committed
Migrate to use mcpgateway.translate and fix smoketest
Signed-off-by: Mihai Criveti <[email protected]>
1 parent bb59e47 commit 534f2af

File tree

1 file changed

+41
-66
lines changed

1 file changed

+41
-66
lines changed

smoketest.py

Lines changed: 41 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
This script verifies a full install + runtime setup of the MCP Gateway:
88
- Creates a virtual environment and installs dependencies.
99
- 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.
1111
- Verifies /health, /ready, /version before registering the gateway.
1212
- Federates the time server as a gateway, verifies its tool list.
1313
- Invokes the remote tool via /rpc and checks the result.
@@ -46,20 +46,20 @@
4646

4747
# ───────────────────────── Ports / constants ────────────────────────────
4848
PORT_GATEWAY = 4444 # HTTPS container
49-
PORT_TIME_SERVER = 8002 # supergateway
49+
PORT_TIME_SERVER = 8002 # mcpgateway.translate
5050
DOCKER_CONTAINER = "mcpgateway"
5151

5252
MAKE_VENV_CMD = ["make", "venv", "install", "install-dev"]
5353
MAKE_DOCKER_BUILD = ["make", "docker"]
5454
MAKE_DOCKER_RUN = ["make", "docker-run-ssl-host"]
5555
MAKE_DOCKER_STOP = ["make", "docker-stop"]
5656

57-
SUPERGW_CMD = [
58-
"npx",
59-
"-y",
60-
"supergateway",
57+
TRANSLATE_CMD = [
58+
"python3",
59+
"-m",
60+
"mcpgateway.translate",
6161
"--stdio",
62-
"\"uvx mcp-server-time --local-timezone=Europe/Dublin\"",
62+
"uvx mcp-server-time --local-timezone=Europe/Dublin",
6363
"--port",
6464
str(PORT_TIME_SERVER),
6565
]
@@ -222,30 +222,30 @@ def request(method: str, path: str, *, json_data=None, **kw):
222222

223223

224224
# ───────────────────────────── 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
227227

228228

229229
def cleanup():
230230
log_section("Cleanup", "🧹")
231-
global _supergw_proc, _supergw_log_file
231+
global _translate_proc, _translate_log_file
232232

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()
237237
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")
240240
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()
244244

245245
# 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
249249

250250
# Stop docker container
251251
logging.info("🐋 Stopping Docker container")
@@ -294,22 +294,7 @@ def step_4_docker_run():
294294

295295

296296
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
313298

314299
# Check if uvx is available
315300
try:
@@ -337,31 +322,22 @@ def step_5_start_time_server(restart=False):
337322

338323
if not port_open(PORT_TIME_SERVER):
339324
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))
341326

342327
# 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,
359336
stderr=subprocess.STDOUT,
360337
text=True,
361338
bufsize=1
362339
)
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)
365341

366342
# Wait for the server to start
367343
start_time = time.time()
@@ -370,10 +346,10 @@ def step_5_start_time_server(restart=False):
370346

371347
while time.time() - start_time < timeout:
372348
# Check if process is still running
373-
exit_code = _supergw_proc.poll()
349+
exit_code = _translate_proc.poll()
374350
if exit_code is not None:
375351
# Process exited, read the log file
376-
_supergw_log_file.close()
352+
_translate_log_file.close()
377353
with open(log_filename, "r") as f:
378354
output = f.read()
379355
logging.error("❌ Time-Server process exited with code %d", exit_code)
@@ -389,7 +365,7 @@ def step_5_start_time_server(restart=False):
389365
time.sleep(1)
390366

391367
# Double-check it's still running
392-
if _supergw_proc.poll() is None:
368+
if _translate_proc.poll() is None:
393369
return
394370
else:
395371
raise RuntimeError("Time-Server started but then immediately exited")
@@ -401,11 +377,11 @@ def step_5_start_time_server(restart=False):
401377
time.sleep(check_interval)
402378

403379
# 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()
407383

408-
_supergw_log_file.close()
384+
_translate_log_file.close()
409385
with open(log_filename, "r") as f:
410386
output = f.read()
411387
logging.error("📋 Process output:\n%s", output)
@@ -604,10 +580,9 @@ def main():
604580
failed = True
605581
logging.error("❌ Failure: %s", e, exc_info=args.verbose)
606582
logging.error("\n💡 Troubleshooting tips:")
607-
logging.error(" - Check if npx is installed: npx --version")
608583
logging.error(" - Check if uvx is installed: uvx --version")
609584
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")
611586
logging.error(" - Try running with -v for verbose output")
612587
finally:
613588
if not failed:

0 commit comments

Comments
 (0)