Skip to content

Commit 74b5968

Browse files
committed
fix: use normalized path for sse message endpoint
1 parent d0443a1 commit 74b5968

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/mcp/server/fastmcp/server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ async def handle_sse(scope: Scope, receive: Receive, send: Send):
742742
)
743743
routes.append(
744744
Mount(
745-
self.settings.message_path,
745+
normalized_message_endpoint,
746746
app=RequireAuthMiddleware(sse.handle_post_message, required_scopes),
747747
)
748748
)
@@ -762,7 +762,7 @@ async def sse_endpoint(request: Request) -> Response:
762762
)
763763
routes.append(
764764
Mount(
765-
self.settings.message_path,
765+
normalized_message_endpoint,
766766
app=sse.handle_post_message,
767767
)
768768
)

tests/server/fastmcp/test_server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ async def test_starlette_routes_with_mount_path(self):
9999

100100
# Verify path values
101101
assert sse_routes[0].path == "/sse", "SSE route path should be /sse"
102-
assert mount_routes[0].path == "/messages", "Mount route path should be /messages"
102+
assert mount_routes[0].path == "/api/messages", "Mount route path should be /messages"
103103

104104
# Test with mount path as parameter
105105
mcp = FastMCP()
@@ -115,7 +115,7 @@ async def test_starlette_routes_with_mount_path(self):
115115

116116
# Verify path values
117117
assert sse_routes[0].path == "/sse", "SSE route path should be /sse"
118-
assert mount_routes[0].path == "/messages", "Mount route path should be /messages"
118+
assert mount_routes[0].path == "/param/messages", "Mount route path should be /messages"
119119

120120
@pytest.mark.anyio
121121
async def test_non_ascii_description(self):

0 commit comments

Comments
 (0)