Skip to content

Commit 654397b

Browse files
authored
Merge pull request #77 from samihamine/fix/sse-transport-mount
fix: use Mount instead of Route for SSE message handling
2 parents 80c328b + 505b861 commit 654397b

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/fastmcp/server.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,9 @@ async def run_stdio_async(self) -> None:
428428
async def run_sse_async(self) -> None:
429429
"""Run the server using SSE transport."""
430430
from starlette.applications import Starlette
431-
from starlette.routing import Route
431+
from starlette.routing import Route, Mount
432432

433-
sse = SseServerTransport("/messages")
433+
sse = SseServerTransport("/messages/")
434434

435435
async def handle_sse(request):
436436
async with sse.connect_sse(
@@ -442,14 +442,11 @@ async def handle_sse(request):
442442
self._mcp_server.create_initialization_options(),
443443
)
444444

445-
async def handle_messages(request):
446-
await sse.handle_post_message(request.scope, request.receive, request._send)
447-
448445
starlette_app = Starlette(
449446
debug=self.settings.debug,
450447
routes=[
451448
Route("/sse", endpoint=handle_sse),
452-
Route("/messages", endpoint=handle_messages, methods=["POST"]),
449+
Mount("/messages/", app=sse.handle_post_message),
453450
],
454451
)
455452

0 commit comments

Comments
 (0)