Class McpClientOptions
- Namespace
- ModelContextProtocol.Client
- Assembly
- ModelContextProtocol.Core.dll
Provides configuration options for creating McpClient instances.
public sealed class McpClientOptions
- Inheritance
-
McpClientOptions
- Inherited Members
Remarks
These options are typically passed to CreateAsync(IClientTransport, McpClientOptions?, ILoggerFactory?, CancellationToken) when creating a client. They define client capabilities, protocol version, and other client-specific settings.
Properties
Capabilities
Gets or sets the client capabilities to advertise to the server.
public ClientCapabilities? Capabilities { get; set; }
Property Value
ClientInfo
Gets or sets information about this client implementation, including its name and version.
public Implementation? ClientInfo { get; set; }
Property Value
Remarks
This information is sent to the server during initialization to identify the client. It's often displayed in server logs and can be used for debugging and compatibility checks.
When not specified, information sourced from the current process is used.
DiscoverProbeTimeout
Gets or sets the timeout applied to the server/discover probe that the client issues
before falling back to the initialize handshake.
public TimeSpan DiscoverProbeTimeout { get; set; }
Property Value
- TimeSpan
The probe timeout. The default value is 5 seconds. Use InfiniteTimeSpan to disable the separate probe timeout and rely solely on InitializationTimeout.
Remarks
This timeout only has an effect when the client prefers the 2026-07-28 protocol revision, that is,
when ProtocolVersion is null (the default) or 2026-07-28.
In that mode the client first probes the server with a
server/discover request. A server that predates the 2026-07-28 revision may
silently drop the unknown method, so the probe is bounded by this timeout; when it elapses the
client concludes the server requires initialize and falls back to that handshake on the
same connection. When the caller pins an initialize-capable ProtocolVersion, no probe is issued
and this value has no effect.
The default is intentionally short so that dual-path clients fall back quickly against initialize-handshake servers. Increase it for high-latency environments (for example, cold-start serverless peers or satellite links) where a short probe could trigger the initialize fallback before a server on the per-request metadata revision has had a chance to respond. The probe is always also bounded by InitializationTimeout, which governs the overall connect budget: if this value is greater than or equal to InitializationTimeout, the probe is effectively bounded by InitializationTimeout alone.
Exceptions
- ArgumentOutOfRangeException
The value is not positive and is not InfiniteTimeSpan.
Handlers
Gets or sets the container of handlers used by the client for processing protocol messages.
public McpClientHandlers Handlers { get; set; }
Property Value
InitializationTimeout
Gets or sets a timeout for the client-server initialization handshake sequence.
public TimeSpan InitializationTimeout { get; set; }
Property Value
- TimeSpan
The timeout for the client-server initialization handshake sequence. The default value is 60 seconds.
Remarks
This timeout determines how long the client will wait for the server to respond during the initialization protocol handshake. If the server doesn't respond within this timeframe, an exception is thrown.
Setting an appropriate timeout prevents the client from hanging indefinitely when connecting to unresponsive servers.
InitializeMeta
Gets or sets the metadata to include in the _meta field of the Initialize request.
public JsonObject? InitializeMeta { get; set; }
Property Value
Remarks
When set, this value is sent as Meta on the InitializeRequestParams during the initialization handshake.
This allows passing implementation-specific data to the server alongside the standard initialize parameters,
such as authentication context a server validates before completing the handshake.
When null, no _meta field is sent.
ProtocolVersion
Gets or sets the protocol version to request from the server, using a date-based versioning scheme.
public string? ProtocolVersion { get; set; }
Property Value
Remarks
Supported values are 2024-11-05, 2025-03-26, 2025-06-18, 2025-11-25,
and 2026-07-28.
When null (the default), the client prefers the latest revision (2026-07-28),
which removed the initialize handshake and Streamable HTTP sessions. It probes with
server/discover and automatically falls back to the initialize handshake,
downgrading to an initialize-capable version the server advertises, when the server does not support that revision.
When non-null, this value is both the requested version and the minimum the client
will accept: the client requests exactly this version and refuses to downgrade below it, throwing an
McpException instead of falling back. Setting it to 2026-07-28 therefore disables
the automatic initialize-handshake server fallback, and setting it to a version that still supports Streamable HTTP
sessions, such as 2025-11-25, forces the initialize handshake and fails if the server
negotiates a different version. To try more than one version, leave this unset for automatic fallback
or retry the connection with a different value.