@@ -848,17 +848,18 @@ async def sse_endpoint(request: Request) -> Response:
848848
849849 # Create Starlette app with routes and middleware
850850 app = Starlette (debug = self .settings .debug , routes = routes , middleware = middleware )
851-
851+
852852 # Add CORS middleware for web frontend compatibility
853853 from starlette .middleware .cors import CORSMiddleware
854+
854855 app .add_middleware (
855856 CORSMiddleware ,
856857 allow_origins = ["http://localhost:*" , "http://127.0.0.1:*" , "https://localhost:*" , "https://127.0.0.1:*" ],
857858 allow_credentials = True ,
858859 allow_methods = ["GET" , "POST" , "OPTIONS" ],
859860 allow_headers = ["Content-Type" , "Authorization" , "X-Requested-With" , "Accept" ],
860861 )
861-
862+
862863 return app
863864
864865 def streamable_http_app (self ) -> Starlette :
@@ -968,17 +969,18 @@ def streamable_http_app(self) -> Starlette:
968969 middleware = middleware ,
969970 lifespan = lambda app : self .session_manager .run (),
970971 )
971-
972+
972973 # Add CORS middleware for web frontend compatibility
973974 from starlette .middleware .cors import CORSMiddleware
975+
974976 app .add_middleware (
975977 CORSMiddleware ,
976978 allow_origins = ["http://localhost:*" , "http://127.0.0.1:*" , "https://localhost:*" , "https://127.0.0.1:*" ],
977979 allow_credentials = True ,
978980 allow_methods = ["GET" , "POST" , "OPTIONS" ],
979981 allow_headers = ["Content-Type" , "Authorization" , "X-Requested-With" , "Accept" ],
980982 )
981-
983+
982984 return app
983985
984986 async def list_prompts (self ) -> list [MCPPrompt ]:
0 commit comments