@@ -32,23 +32,34 @@ public async Task MapMcp_ThrowsInvalidOperationException_IfWithHttpTransportIsNo
3232 Assert . StartsWith ( "You must call WithHttpTransport()" , exception . Message ) ;
3333 }
3434
35- [ Fact ]
36- public async Task Allows_Customizing_Route ( )
35+ [ Theory ]
36+ [ InlineData ( "/mcp" ) ]
37+ [ InlineData ( "/mcp/secondary" ) ]
38+ public async Task Allows_Customizing_Route ( string pattern )
3739 {
3840 Builder . Services . AddMcpServer ( ) . WithHttpTransport ( ) ;
3941 await using var app = Builder . Build ( ) ;
4042
41- app . MapMcp ( "/mcp" ) ;
43+ app . MapMcp ( pattern ) ;
4244
4345 await app . StartAsync ( TestContext . Current . CancellationToken ) ;
4446
45- using var response = await HttpClient . GetAsync ( "http://localhost/mcp /sse" , HttpCompletionOption . ResponseHeadersRead , TestContext . Current . CancellationToken ) ;
47+ using var response = await HttpClient . GetAsync ( $ "http://localhost{ pattern } /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 ]
5060 [ InlineData ( "/a" , "/a/sse" ) ]
5161 [ InlineData ( "/a/" , "/a/sse" ) ]
62+ [ InlineData ( "/a/b" , "/a/b/sse" ) ]
5263 public async Task CanConnect_WithMcpClient_AfterCustomizingRoute ( string routePattern , string requestPath )
5364 {
5465 Builder . Services . AddMcpServer ( options =>
0 commit comments