@@ -84,6 +84,8 @@ class Settings(BaseSettings, Generic[LifespanResultT]):
8484 # HTTP settings
8585 host : str = "0.0.0.0"
8686 port : int = 8000
87+ sse_path : str = "/sse"
88+ message_path : str = "/messages/"
8789
8890 # resource settings
8991 warn_on_duplicate_resources : bool = True
@@ -478,7 +480,7 @@ async def run_sse_async(self) -> None:
478480 from starlette .applications import Starlette
479481 from starlette .routing import Mount , Route
480482
481- sse = SseServerTransport ("/messages/" )
483+ sse = SseServerTransport (self . settings . message_path )
482484
483485 async def handle_sse (request ):
484486 async with sse .connect_sse (
@@ -493,8 +495,8 @@ async def handle_sse(request):
493495 starlette_app = Starlette (
494496 debug = self .settings .debug ,
495497 routes = [
496- Route ("/sse" , endpoint = handle_sse ),
497- Mount ("/messages/" , app = sse .handle_post_message ),
498+ Route (self . settings . sse_path , endpoint = handle_sse ),
499+ Mount (self . settings . message_path , app = sse .handle_post_message ),
498500 ],
499501 )
500502
@@ -658,9 +660,9 @@ async def read_resource(self, uri: str | AnyUrl) -> Iterable[ReadResourceContent
658660 Returns:
659661 The resource content as either text or bytes
660662 """
661- assert (
662- self . _fastmcp is not None
663- ), "Context is not available outside of a request"
663+ assert self . _fastmcp is not None , (
664+ "Context is not available outside of a request"
665+ )
664666 return await self ._fastmcp .read_resource (uri )
665667
666668 async def log (
0 commit comments