@@ -70,15 +70,15 @@ public static IResourceBuilder<McpInspectorResource> AddMcpInspector(this IDistr
7070
7171                var  servers  =  inspectorResource . McpServers . ToDictionary ( s =>  s . Name ,  s =>  new 
7272                { 
73-                     transport  =  s . TransportType  switch 
73+                     type  =  s . TransportType  switch 
7474                    { 
7575                        McpTransportType . StreamableHttp  =>  "streamable-http" , 
7676#pragma warning disable CS0618 
7777                        McpTransportType . Sse  =>  "sse" , 
7878#pragma warning restore CS0618 
7979                        _ =>  throw  new  NotSupportedException ( $ "The transport type { s . TransportType }  is not supported.") 
8080                    } , 
81-                     endpoint  =  s . Endpoint . Url 
81+                     url  =  Combine ( s . Endpoint . Url ,   s . Path ) , 
8282                } ) ; 
8383
8484                var  config  =  new  {  mcpServers  =  servers  } ; 
@@ -183,18 +183,20 @@ public static IResourceBuilder<McpInspectorResource> AddMcpInspector(this IDistr
183183    /// <param name="mcpServer">The <see cref="IResourceBuilder{T}"/> for the MCP server resource.</param> 
184184    /// <param name="isDefault">Indicates whether this MCP server should be considered the default server for the MCP Inspector.</param> 
185185    /// <param name="transportType">The transport type to use for the MCP server. Defaults to <see cref="McpTransportType.StreamableHttp"/>.</param> 
186+     /// <param name="path">The path to use for MCP communication. Defaults to "/mcp".</param> 
186187    /// <returns>A reference to the <see cref="IResourceBuilder{McpInspectorResource}"/> for further configuration.</returns> 
187188    public  static IResourceBuilder < McpInspectorResource >  WithMcpServer < TResource > ( 
188189        this  IResourceBuilder < McpInspectorResource >  builder , 
189190        IResourceBuilder < TResource >  mcpServer , 
190191        bool  isDefault  =  true , 
191-         McpTransportType  transportType  =  McpTransportType . StreamableHttp ) 
192+         McpTransportType  transportType  =  McpTransportType . StreamableHttp , 
193+         string  path  =  "/mcp" ) 
192194        where  TResource  :  IResourceWithEndpoints 
193195    { 
194196        ArgumentNullException . ThrowIfNull ( mcpServer ) ; 
195197        ArgumentNullException . ThrowIfNull ( builder ) ; 
196198
197-         builder . Resource . AddMcpServer ( mcpServer . Resource ,  isDefault ,  transportType ) ; 
199+         builder . Resource . AddMcpServer ( mcpServer . Resource ,  isDefault ,  transportType ,   path ) ; 
198200        return  builder ; 
199201    } 
200202
@@ -222,4 +224,27 @@ private static IResourceBuilder<McpInspectorResource> WithDefaultArgs(this IReso
222224                ctx . Args . Add ( defaultMcpServer ? . Name  ??  throw  new  InvalidOperationException ( "The MCP Inspector resource must have a default MCP server defined." ) ) ; 
223225            } ) ; 
224226    } 
227+ 
228+     internal  static Uri  Combine ( string  baseUrl ,  params  string [ ]  segments ) 
229+     { 
230+         if  ( string . IsNullOrEmpty ( baseUrl ) ) 
231+             throw  new  ArgumentException ( "baseUrl required" ,  nameof ( baseUrl ) ) ; 
232+ 
233+         if  ( segments  ==  null  ||  segments . Length  ==  0 ) 
234+             return  new  Uri ( baseUrl ,  UriKind . RelativeOrAbsolute ) ; 
235+ 
236+         var  baseUri  =  new  Uri ( baseUrl ,  UriKind . Absolute ) ; 
237+ 
238+         // If first segment is absolute URI, return it 
239+         if  ( Uri . IsWellFormedUriString ( segments [ 0 ] ,  UriKind . Absolute ) ) 
240+             return  new  Uri ( segments [ 0 ] ,  UriKind . Absolute ) ; 
241+ 
242+         var  escaped  =  segments 
243+             . Where ( s =>  ! string . IsNullOrEmpty ( s ) ) 
244+             . Select ( s =>  Uri . EscapeDataString ( s . Trim ( '/' ) ) ) ; 
245+ 
246+         var  relative  =  string . Join ( "/" ,  escaped ) ; 
247+ 
248+         return  new  Uri ( baseUri ,  relative ) ; 
249+     } 
225250} 
0 commit comments