Skip to content

Commit 1b846cb

Browse files
Copilotstephentoub
andauthored
Add missing exception documentation to public API surface (#1103)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: stephentoub <[email protected]> Co-authored-by: Stephen Toub <[email protected]>
1 parent 31fcc1e commit 1b846cb

File tree

12 files changed

+50
-0
lines changed

12 files changed

+50
-0
lines changed

src/ModelContextProtocol.AspNetCore/McpEndpointRouteBuilderExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public static class McpEndpointRouteBuilderExtensions
1919
/// <param name="endpoints">The web application to attach MCP HTTP endpoints.</param>
2020
/// <param name="pattern">The route pattern prefix to map to.</param>
2121
/// <returns>Returns a builder for configuring additional endpoint conventions like authorization policies.</returns>
22+
/// <exception cref="InvalidOperationException">The required MCP services have not been registered. Ensure <see cref="HttpMcpServerBuilderExtensions.WithHttpTransport"/> has been called during application startup.</exception>
2223
/// <remarks>
2324
/// For details about the Streamable HTTP transport, see the <see href="https://modelcontextprotocol.io/specification/2025-06-18/basic/transports#streamable-http">2025-06-18 protocol specification</see>.
2425
/// This method also maps legacy SSE endpoints for backward compatibility at the path "/sse" and "/message". For details about the HTTP with SSE transport, see the <see href="https://modelcontextprotocol.io/specification/2024-11-05/basic/transports#http-with-sse">2024-11-05 protocol specification</see>.

src/ModelContextProtocol.Core/Client/HttpClientTransportOptions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ public sealed class HttpClientTransportOptions
1010
/// <summary>
1111
/// Gets or sets the base address of the server for SSE connections.
1212
/// </summary>
13+
/// <exception cref="ArgumentNullException">The value is <see langword="null"/>.</exception>
14+
/// <exception cref="ArgumentException">The value is not an absolute URI, or does not use the HTTP or HTTPS scheme.</exception>
1315
public required Uri Endpoint
1416
{
1517
get;

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

Lines changed: 30 additions & 0 deletions
Large diffs are not rendered by default.

src/ModelContextProtocol.Core/Client/McpClientPrompt.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public McpClientPrompt(McpClient client, Prompt prompt)
7777
/// <param name="serializerOptions">The serialization options governing argument serialization.</param>
7878
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
7979
/// <returns>A <see cref="ValueTask"/> containing the prompt's result with content and messages.</returns>
80+
/// <exception cref="McpException">The request failed or the server returned an error response.</exception>
8081
/// <remarks>
8182
/// <para>
8283
/// This method sends a request to the MCP server to execute this prompt with the provided arguments.

src/ModelContextProtocol.Core/Client/McpClientResource.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public McpClientResource(McpClient client, Resource resource)
7676
/// </summary>
7777
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
7878
/// <returns>A <see cref="ValueTask{ReadResourceResult}"/> containing the resource's result with content and messages.</returns>
79+
/// <exception cref="McpException">The request failed or the server returned an error response.</exception>
7980
/// <remarks>
8081
/// <para>
8182
/// This is a convenience method that internally calls <see cref="McpClient.ReadResourceAsync(string, RequestOptions, CancellationToken)"/>.

src/ModelContextProtocol.Core/Client/McpClientResourceTemplate.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public McpClientResourceTemplate(McpClient client, ResourceTemplate resourceTemp
8080
/// </param>
8181
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
8282
/// <returns>A <see cref="ValueTask{ReadResourceResult}"/> containing the resource template's result with content and messages.</returns>
83+
/// <exception cref="McpException">The request failed or the server returned an error response.</exception>
8384
public ValueTask<ReadResourceResult> ReadAsync(
8485
IReadOnlyDictionary<string, object?> arguments,
8586
CancellationToken cancellationToken = default) =>

src/ModelContextProtocol.Core/Client/StdioClientTransportOptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public sealed class StdioClientTransportOptions
88
/// <summary>
99
/// Gets or sets the command to execute to start the server process.
1010
/// </summary>
11+
/// <exception cref="ArgumentException">The value is <see langword="null"/>, empty, or composed entirely of whitespace.</exception>
1112
public required string Command
1213
{
1314
get;

src/ModelContextProtocol.Core/McpSession.Methods.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ public abstract partial class McpSession : IAsyncDisposable
1818
/// <param name="serializerOptions">The options governing request serialization.</param>
1919
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
2020
/// <returns>A task that represents the asynchronous operation. The task result contains the deserialized result.</returns>
21+
/// <exception cref="ArgumentNullException"><paramref name="method"/> is <see langword="null"/>.</exception>
22+
/// <exception cref="ArgumentException"><paramref name="method"/> is empty or composed entirely of whitespace.</exception>
23+
/// <exception cref="McpException">The request failed or the server returned an error response.</exception>
2124
public ValueTask<TResult> SendRequestAsync<TParameters, TResult>(
2225
string method,
2326
TParameters parameters,

src/ModelContextProtocol.Core/McpSession.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ public abstract partial class McpSession : IAsyncDisposable
8686
/// <param name="method">The notification method.</param>
8787
/// <param name="handler">The handler to be invoked.</param>
8888
/// <returns>An <see cref="IDisposable"/> that will remove the registered handler when disposed.</returns>
89+
/// <exception cref="ArgumentNullException"><paramref name="method"/> or <paramref name="handler"/> is <see langword="null"/>.</exception>
90+
/// <exception cref="ArgumentException"><paramref name="method"/> is empty or composed entirely of whitespace.</exception>
8991
public abstract IAsyncDisposable RegisterNotificationHandler(string method, Func<JsonRpcNotification, CancellationToken, ValueTask> handler);
9092

9193
/// <inheritdoc/>

src/ModelContextProtocol.Core/Protocol/ElicitRequestParams.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public sealed class ElicitRequestParams : RequestParams
2020
/// <item><description><b>url</b>: Client navigates user to a URL for out-of-band interaction. Sensitive data is not exposed to the client.</description></item>
2121
/// </list>
2222
/// </remarks>
23+
/// <exception cref="ArgumentException">The value is not "form" or "url".</exception>
2324
[JsonPropertyName("mode")]
2425
[field: MaybeNull]
2526
public string Mode

0 commit comments

Comments
 (0)