@@ -73,6 +73,8 @@ class Settings(BaseSettings, Generic[LifespanResultT]):
73
73
# HTTP settings
74
74
host : str = "0.0.0.0"
75
75
port : int = 8000
76
+ sse_path : str = "/sse"
77
+ message_path : str = "/messages/"
76
78
77
79
# resource settings
78
80
warn_on_duplicate_resources : bool = True
@@ -477,7 +479,7 @@ async def run_sse_async(self) -> None:
477
479
478
480
def sse_app (self ) -> Starlette :
479
481
"""Return an instance of the SSE server app."""
480
- sse = SseServerTransport ("/messages/" )
482
+ sse = SseServerTransport (self . settings . message_path )
481
483
482
484
async def handle_sse (request : Request ) -> None :
483
485
async with sse .connect_sse (
@@ -494,8 +496,8 @@ async def handle_sse(request: Request) -> None:
494
496
return Starlette (
495
497
debug = self .settings .debug ,
496
498
routes = [
497
- Route ("/sse" , endpoint = handle_sse ),
498
- Mount ("/messages/" , app = sse .handle_post_message ),
499
+ Route (self . settings . sse_path , endpoint = handle_sse ),
500
+ Mount (self . settings . message_path , app = sse .handle_post_message ),
499
501
],
500
502
)
501
503
@@ -650,9 +652,9 @@ async def read_resource(self, uri: str | AnyUrl) -> Iterable[ReadResourceContent
650
652
Returns:
651
653
The resource content as either text or bytes
652
654
"""
653
- assert (
654
- self . _fastmcp is not None
655
- ), "Context is not available outside of a request"
655
+ assert self . _fastmcp is not None , (
656
+ "Context is not available outside of a request"
657
+ )
656
658
return await self ._fastmcp .read_resource (uri )
657
659
658
660
async def log (
0 commit comments