@@ -603,7 +603,7 @@ async def run_sse_async(self, mount_path: str | None = None) -> None:
603603 import uvicorn
604604
605605 starlette_app = self .sse_app (mount_path )
606-
606+
607607 config = uvicorn .Config (
608608 starlette_app ,
609609 host = self .settings .host ,
@@ -618,7 +618,7 @@ async def run_streamable_http_async(self) -> None:
618618 import uvicorn
619619
620620 starlette_app = self .streamable_http_app ()
621-
621+ starlette_app . router . redirect_slashes = False
622622 config = uvicorn .Config (
623623 starlette_app ,
624624 host = self .settings .host ,
@@ -783,7 +783,9 @@ def streamable_http_app(self) -> Starlette:
783783
784784 # Create the ASGI handler
785785 async def handle_streamable_http (request : Request ) -> Response :
786- await self .session_manager .handle_request (request .scope , request .receive , request ._send )
786+ await self .session_manager .handle_request (
787+ request .scope , request .receive , request ._send
788+ )
787789 return Response ()
788790
789791 # Create routes
@@ -793,7 +795,7 @@ async def handle_streamable_http(request: Request) -> Response:
793795
794796 # Always register both /mcp and /mcp/ for full compatibility
795797 _main_path = self .settings .streamable_http_path .removesuffix ("/" )
796- _alt_path = _main_path + "/"
798+ _alt_path = _main_path + "/"
797799
798800 # Add auth endpoints if auth provider is configured
799801 if self ._auth_server_provider :
@@ -820,31 +822,39 @@ async def handle_streamable_http(request: Request) -> Response:
820822 revocation_options = self .settings .auth .revocation_options ,
821823 )
822824 )
823- routes .extend ([
824- Route (
825- _main_path ,
826- endpoint = RequireAuthMiddleware (handle_streamable_http , required_scopes ),
827- methods = ["GET" , "POST" , "OPTIONS" ]
828- ),
829- Route (
830- _alt_path ,
831- endpoint = RequireAuthMiddleware (handle_streamable_http , required_scopes ),
832- methods = ["GET" , "POST" , "OPTIONS" ]
833- )]
825+ routes .extend (
826+ [
827+ Route (
828+ _main_path ,
829+ endpoint = RequireAuthMiddleware (
830+ handle_streamable_http , required_scopes
831+ ),
832+ methods = ["GET" , "POST" , "OPTIONS" ],
833+ ),
834+ Route (
835+ _alt_path ,
836+ endpoint = RequireAuthMiddleware (
837+ handle_streamable_http , required_scopes
838+ ),
839+ methods = ["GET" , "POST" , "OPTIONS" ],
840+ ),
841+ ]
834842 )
835843 else :
836844 # Auth is disabled, no wrapper needed
837- routes .extend ([
838- Route (
839- _main_path ,
840- endpoint = handle_streamable_http ,
841- methods = ["GET" , "POST" , "OPTIONS" ]
842- ),
843- Route (
844- _alt_path ,
845- endpoint = handle_streamable_http ,
846- methods = ["GET" , "POST" , "OPTIONS" ]
847- )]
845+ routes .extend (
846+ [
847+ Route (
848+ _main_path ,
849+ endpoint = handle_streamable_http ,
850+ methods = ["GET" , "POST" , "OPTIONS" ],
851+ ),
852+ Route (
853+ _alt_path ,
854+ endpoint = handle_streamable_http ,
855+ methods = ["GET" , "POST" , "OPTIONS" ],
856+ ),
857+ ]
848858 )
849859
850860 routes .extend (self ._custom_starlette_routes )
0 commit comments