@@ -84,6 +84,8 @@ class Settings(BaseSettings, Generic[LifespanResultT]):
84
84
# HTTP settings
85
85
host : str = "0.0.0.0"
86
86
port : int = 8000
87
+ sse_path : str = "/sse"
88
+ message_path : str = "/messages/"
87
89
88
90
# resource settings
89
91
warn_on_duplicate_resources : bool = True
@@ -478,7 +480,7 @@ async def run_sse_async(self) -> None:
478
480
from starlette .applications import Starlette
479
481
from starlette .routing import Mount , Route
480
482
481
- sse = SseServerTransport ("/messages/" )
483
+ sse = SseServerTransport (self . settings . message_path )
482
484
483
485
async def handle_sse (request ):
484
486
async with sse .connect_sse (
@@ -493,8 +495,8 @@ async def handle_sse(request):
493
495
starlette_app = Starlette (
494
496
debug = self .settings .debug ,
495
497
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 ),
498
500
],
499
501
)
500
502
@@ -658,9 +660,9 @@ async def read_resource(self, uri: str | AnyUrl) -> Iterable[ReadResourceContent
658
660
Returns:
659
661
The resource content as either text or bytes
660
662
"""
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
+ )
664
666
return await self ._fastmcp .read_resource (uri )
665
667
666
668
async def log (
0 commit comments