Clean up namespaces (#410)

No meaningful code changes, just lots of namespace shuffling to have fewer namespaces and to put things in better namespaces.
This commit is contained in:
Stephen Toub 2025-05-14 14:50:26 -04:00 • committed by GitHub
commit 106ab8064f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -0,0 +1,65 @@
namespace ModelContextProtocol.Client;
/// <summary>
/// Provides options for configuring <see cref="SseClientTransport"/> instances.
/// </summary>
public record SseClientTransportOptions
{
/// <summary>
/// Gets or sets the base address of the server for SSE connections.
/// </summary>
public required Uri Endpoint
{
get;
init
{
if (value is null)
{
throw new ArgumentNullException(nameof(value), "Endpoint cannot be null.");
}
if (!value.IsAbsoluteUri)
{
throw new ArgumentException("Endpoint must be an absolute URI.", nameof(value));
}
if (value.Scheme != Uri.UriSchemeHttp && value.Scheme != Uri.UriSchemeHttps)
{
throw new ArgumentException("Endpoint must use HTTP or HTTPS scheme.", nameof(value));
}
field = value;
}
}
/// <summary>
/// Gets or sets a value indicating whether to use "Streamable HTTP" for the transport rather than "HTTP with SSE". Defaults to false.
/// <see href="https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http">Streamable HTTP transport specification</see>.
/// <see href="https://modelcontextprotocol.io/specification/2024-11-05/basic/transports#http-with-sse">HTTP with SSE transport specification</see>.
/// </summary>
public bool UseStreamableHttp { get; init; }
/// <summary>
/// Gets a transport identifier used for logging purposes.
/// </summary>
public string? Name { get; init; }
/// <summary>
/// Gets or sets a timeout used to establish the initial connection to the SSE server. Defaults to 30 seconds.
/// </summary>
/// <remarks>
/// This timeout controls how long the client waits for:
/// <list type="bullet">
/// <item><description>The initial HTTP connection to be established with the SSE server</description></item>
/// <item><description>The endpoint event to be received, which indicates the message endpoint URL</description></item>
/// </list>
/// If the timeout expires before the connection is established, a <see cref="TimeoutException"/> will be thrown.
/// </remarks>
public TimeSpan ConnectionTimeout { get; init; } = TimeSpan.FromSeconds(30);
/// <summary>
/// Gets custom HTTP headers to include in requests to the SSE server.
/// </summary>
/// <remarks>
/// Use this property to specify custom HTTP headers that should be sent with each request to the server.
/// </remarks>
public Dictionary<string, string>? AdditionalHeaders { get; init; }
}