Skip to content

Commit dcb37fe

Browse files
committed
Go back to non-root-relative SSE endpoint event
1 parent 009f37a commit dcb37fe

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

src/ModelContextProtocol.AspNetCore/SseHandler.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ public async Task HandleSseRequestAsync(HttpContext context)
3131

3232
StreamableHttpHandler.InitializeSseResponse(context);
3333

34-
var requestPath = (context.Request.PathBase + context.Request.Path).ToString();
35-
var endpointPattern = requestPath[..(requestPath.LastIndexOf('/') + 1)];
36-
await using var transport = new SseResponseStreamTransport(context.Response.Body, $"{endpointPattern}message?sessionId={sessionId}");
34+
await using var transport = new SseResponseStreamTransport(context.Response.Body, $"message?sessionId={sessionId}");
3735
await using var httpMcpSession = new HttpMcpSession<SseResponseStreamTransport>(sessionId, transport, context.User, httpMcpServerOptions.Value.TimeProvider);
3836
if (!_sessions.TryAdd(sessionId, httpMcpSession))
3937
{

tests/ModelContextProtocol.AspNetCore.Tests/MapMcpTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public async Task Allows_Customizing_Route(string pattern)
5353
Assert.NotNull(eventLine);
5454
Assert.Equal("event: endpoint", eventLine);
5555
Assert.NotNull(dataLine);
56-
Assert.Equal($"data: {pattern}/message", dataLine[..dataLine.IndexOf('?')]);
56+
Assert.Equal($"data: message", dataLine[..dataLine.IndexOf('?')]);
5757
}
5858

5959
[Theory]

0 commit comments

Comments
 (0)