Class ClientTransportClosedException
- Namespace
- ModelContextProtocol.Client
- Assembly
- ModelContextProtocol.Core.dll
An IOException that indicates the client transport was closed, carrying structured ClientCompletionDetails about why the closure occurred.
public sealed class ClientTransportClosedException : IOException, ISerializable
- Inheritance
-
ClientTransportClosedException
- Implements
- Inherited Members
Remarks
This exception is thrown when an MCP transport closes, either during initialization (e.g., from CreateAsync(IClientTransport, McpClientOptions?, ILoggerFactory?, CancellationToken)) or during an active session. Callers can catch this exception to access the Details property for structured information about the closure.
For stdio-based transports, the Details will be a StdioClientCompletionDetails instance providing access to the server process exit code, process ID, and standard error output.
Custom ITransport implementations can provide their own ClientCompletionDetails-derived types by completing their ChannelWriter<T> with this exception.
Constructors
ClientTransportClosedException(ClientCompletionDetails)
An IOException that indicates the client transport was closed, carrying structured ClientCompletionDetails about why the closure occurred.
public ClientTransportClosedException(ClientCompletionDetails details)
Parameters
detailsClientCompletionDetails
Remarks
This exception is thrown when an MCP transport closes, either during initialization (e.g., from CreateAsync(IClientTransport, McpClientOptions?, ILoggerFactory?, CancellationToken)) or during an active session. Callers can catch this exception to access the Details property for structured information about the closure.
For stdio-based transports, the Details will be a StdioClientCompletionDetails instance providing access to the server process exit code, process ID, and standard error output.
Custom ITransport implementations can provide their own ClientCompletionDetails-derived types by completing their ChannelWriter<T> with this exception.
Properties
Details
Gets the structured details about why the transport was closed.
public ClientCompletionDetails Details { get; }
Property Value
Remarks
The concrete type of the returned ClientCompletionDetails depends on the transport that was used. For example, StdioClientCompletionDetails for stdio-based transports and HttpClientCompletionDetails for HTTP-based transports.