Skip to content

Commit 5b74ee2

Browse files
Copilotstephentoub
andauthored
Document HttpRequestException thrown by McpClient.CreateAsync (#1095)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: stephentoub <[email protected]>
1 parent c3910e9 commit 5b74ee2

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/ModelContextProtocol.Core/Client/McpClient.Methods.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@ public abstract partial class McpClient : McpSession
2121
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
2222
/// <returns>An <see cref="McpClient"/> that's connected to the specified server.</returns>
2323
/// <exception cref="ArgumentNullException"><paramref name="clientTransport"/> is <see langword="null"/>.</exception>
24+
/// <exception cref="HttpRequestException">An error occurred while connecting to the server over HTTP.</exception>
25+
/// <remarks>
26+
/// <para>
27+
/// When using an HTTP-based transport (such as <see cref="HttpClientTransport"/>), this method may throw
28+
/// <see cref="HttpRequestException"/> if there is a problem establishing the connection to the MCP server.
29+
/// </para>
30+
/// <para>
31+
/// If the server requires authentication and credentials are not provided or are invalid, an
32+
/// <see cref="HttpRequestException"/> with an HTTP 401 Unauthorized status code will be thrown.
33+
/// To authenticate with a protected server, configure the <see cref="HttpClientTransportOptions.OAuth"/>
34+
/// property of the transport with appropriate credentials before calling this method.
35+
/// </para>
36+
/// </remarks>
2437
public static async Task<McpClient> CreateAsync(
2538
IClientTransport clientTransport,
2639
McpClientOptions? clientOptions = null,

0 commit comments

Comments
 (0)