Skip to content

Commit c96970f

Browse files
committed
update test to verify routing pattern is included in /message endpoint modelcontextprotocol#280
currently expected to fail until fix is implemented
1 parent b0cd654 commit c96970f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tests/ModelContextProtocol.AspNetCore.Tests/MapMcpTests.cs

+11-1
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,22 @@ public async Task Allows_Customizing_Route()
3838
Builder.Services.AddMcpServer().WithHttpTransport();
3939
await using var app = Builder.Build();
4040

41-
app.MapMcp("/mcp");
41+
var pattern = "/mcp";
42+
43+
app.MapMcp(pattern);
4244

4345
await app.StartAsync(TestContext.Current.CancellationToken);
4446

4547
using var response = await HttpClient.GetAsync("http://localhost/mcp/sse", HttpCompletionOption.ResponseHeadersRead, TestContext.Current.CancellationToken);
4648
response.EnsureSuccessStatusCode();
49+
using var sseStream = await response.Content.ReadAsStreamAsync(TestContext.Current.CancellationToken);
50+
using var sseStreamReader = new StreamReader(sseStream, System.Text.Encoding.UTF8);
51+
var eventLine = await sseStreamReader.ReadLineAsync(TestContext.Current.CancellationToken);
52+
var dataLine = await sseStreamReader.ReadLineAsync(TestContext.Current.CancellationToken);
53+
Assert.NotNull(eventLine);
54+
Assert.Equal("event: endpoint", eventLine);
55+
Assert.NotNull(dataLine);
56+
Assert.Equal($"data: {pattern}/message", dataLine[..dataLine.IndexOf('?')]);
4757
}
4858

4959
[Theory]

0 commit comments

Comments
 (0)