Table of Contents

Class HttpClientTransportOptions

Namespace
ModelContextProtocol.Client
Assembly
ModelContextProtocol.Core.dll

Provides options for configuring HttpClientTransport instances.

public sealed class HttpClientTransportOptions
Inheritance
HttpClientTransportOptions
Inherited Members

Properties

AdditionalHeaders

Gets or sets custom HTTP headers to include in requests to the SSE server.

public IDictionary<string, string>? AdditionalHeaders { get; set; }

Property Value

IDictionary<string, string>

Remarks

Use this property to specify custom HTTP headers that should be sent with each request to the server.

ConnectionTimeout

Gets or sets a timeout used to establish the initial connection to the SSE server.

public TimeSpan ConnectionTimeout { get; set; }

Property Value

TimeSpan

The timeout used to establish the initial connection to the SSE server. The default is 30 seconds.

Remarks

This timeout controls how long the client waits for:

  • The initial HTTP connection to be established with the SSE server.
  • The endpoint event to be received, which indicates the message endpoint URL.
If the timeout expires before the connection is established, a TimeoutException is thrown.

Endpoint

Gets or sets the base address of the server for SSE connections.

public required Uri Endpoint { get; set; }

Property Value

Uri

KnownSessionId

Gets or sets a session identifier that should be reused when connecting to a Streamable HTTP server.

public string? KnownSessionId { get; set; }

Property Value

string

Remarks

When non-null, the transport assumes the server already created the session and will include the specified session identifier in every HTTP request. This allows reconnecting to an existing session created in a previous process. This option is only supported by the Streamable HTTP transport mode.

Clients should pair this with ResumeSessionAsync(IClientTransport, ResumeClientSessionOptions, McpClientOptions?, ILoggerFactory?, CancellationToken) to skip the initialization handshake when rehydrating a previously negotiated session.

Name

Gets or sets a transport identifier used for logging purposes.

public string? Name { get; set; }

Property Value

string

OAuth

Gets sor sets the authorization provider to use for authentication.

public ClientOAuthOptions? OAuth { get; set; }

Property Value

ClientOAuthOptions

OwnsSession

Gets or sets a value indicating whether this transport endpoint is responsible for ending the session on dispose.

public bool OwnsSession { get; set; }

Property Value

bool

Remarks

When true (default), the transport sends a DELETE request that informs the server the session is complete. Set this to false when creating a transport used solely to bootstrap session information that will later be resumed elsewhere.

TransportMode

Gets or sets the transport mode to use for the connection.

public HttpTransportMode TransportMode { get; set; }

Property Value

HttpTransportMode

The transport mode to use for the connection. The default is AutoDetect.

Remarks

When set to AutoDetect (the default), the client will first attempt to use Streamable HTTP transport and automatically fall back to SSE transport if the server doesn't support it.

See Also