@@ -373,7 +373,9 @@ def test_tools_cache_after_update(test_client):
373
373
def test_stream_logs_notfound (test_client : tuple [TestClient , DiveHostAPI ]):
374
374
"""Test stream_logs function with not found server."""
375
375
client , _ = test_client
376
- response = client .get ("/api/tools/missing_server/logs/stream" )
376
+ response = client .get (
377
+ "/api/tools/logs/stream" , params = {"server_name" : "missing_server" }
378
+ )
377
379
for line in response .iter_lines ():
378
380
content = line .removeprefix ("data: " )
379
381
if content in ("[DONE]" , "" ):
@@ -413,8 +415,63 @@ def update_tools():
413
415
with ThreadPoolExecutor (1 ) as executor :
414
416
executor .submit (update_tools )
415
417
response = client .get (
416
- "/api/tools/missing_server/logs/stream" ,
418
+ "/api/tools/logs/stream" ,
419
+ params = {
420
+ "server_name" : "missing_server" ,
421
+ "stop_on_notfound" : False ,
422
+ "max_retries" : 5 ,
423
+ "stream_until" : "running" ,
424
+ },
425
+ )
426
+ responses : list [LogMsg ] = []
427
+ for line in response .iter_lines ():
428
+ content = line .removeprefix ("data: " )
429
+ if content in ("[DONE]" , "" ):
430
+ continue
431
+
432
+ data = LogMsg .model_validate_json (content )
433
+ responses .append (data )
434
+
435
+ assert len (responses ) >= 3
436
+ assert responses [- 3 ].event == LogEvent .STREAMING_ERROR
437
+
438
+ assert responses [- 2 ].event == LogEvent .STDERR
439
+ assert responses [- 2 ].client_state == ClientState .INIT
440
+
441
+ assert responses [- 1 ].event == LogEvent .STATUS_CHANGE
442
+ assert responses [- 1 ].client_state == ClientState .RUNNING
443
+
444
+
445
+ def test_stream_logs_name_with_slash (test_client : tuple [TestClient , DiveHostAPI ]):
446
+ """Test stream_logs before log buffer is registered."""
447
+ client , _ = test_client
448
+
449
+ def update_tools ():
450
+ _ = client .post (
451
+ "/api/config/mcpserver" ,
452
+ json = {
453
+ "mcpServers" : {
454
+ "name/with/slash" : {
455
+ "transport" : "stdio" ,
456
+ "enabled" : True ,
457
+ "command" : "python" ,
458
+ "args" : [
459
+ "-m" ,
460
+ "dive_mcp_host.host.tools.echo" ,
461
+ "--transport=stdio" ,
462
+ ],
463
+ }
464
+ }
465
+ },
466
+ )
467
+ assert response .status_code == status .HTTP_200_OK
468
+
469
+ with ThreadPoolExecutor (1 ) as executor :
470
+ executor .submit (update_tools )
471
+ response = client .get (
472
+ "/api/tools/logs/stream" ,
417
473
params = {
474
+ "server_name" : "name/with/slash" ,
418
475
"stop_on_notfound" : False ,
419
476
"max_retries" : 5 ,
420
477
"stream_until" : "running" ,
0 commit comments