@@ -467,6 +467,7 @@ async def run_stdio_async(self) -> None:
467
467
async def run_sse_async (self ) -> None :
468
468
"""Run the server using SSE transport."""
469
469
import uvicorn
470
+
470
471
starlette_app = self .sse_app ()
471
472
472
473
config = uvicorn .Config (
@@ -481,33 +482,35 @@ async def run_sse_async(self) -> None:
481
482
def _normalize_path (self , mount_path : str , endpoint : str ) -> str :
482
483
"""
483
484
Combine mount path and endpoint to return a normalized path.
484
-
485
+
485
486
Args:
486
487
mount_path: The mount path (e.g. "/github" or "/")
487
488
endpoint: The endpoint path (e.g. "/messages/")
488
-
489
+
489
490
Returns:
490
491
Normalized path (e.g. "/github/messages/")
491
492
"""
492
493
# Special case: root path
493
494
if mount_path == "/" :
494
495
return endpoint
495
-
496
+
496
497
# Remove trailing slash from mount path
497
498
if mount_path .endswith ("/" ):
498
499
mount_path = mount_path [:- 1 ]
499
-
500
+
500
501
# Ensure endpoint starts with slash
501
502
if not endpoint .startswith ("/" ):
502
503
endpoint = "/" + endpoint
503
-
504
+
504
505
# Combine paths
505
506
return mount_path + endpoint
506
-
507
+
507
508
def sse_app (self ) -> Starlette :
508
509
"""Return an instance of the SSE server app."""
509
510
# Create normalized endpoint considering the mount path
510
- normalized_endpoint = self ._normalize_path (self .settings .mount_path , self .settings .message_path )
511
+ normalized_endpoint = self ._normalize_path (
512
+ self .settings .mount_path , self .settings .message_path
513
+ )
511
514
sse = SseServerTransport (normalized_endpoint )
512
515
513
516
async def handle_sse (request : Request ) -> None :
0 commit comments