using ModelContextProtocol.Protocol; namespace ModelContextProtocol.Client; /// /// Represents a transport mechanism for Model Context Protocol (MCP) client-to-server communication. /// /// /// /// The interface abstracts the communication layer between MCP clients /// and servers, allowing different transport protocols to be used interchangeably. /// /// /// When creating an , is typically used, and is /// provided with the based on expected server configuration. /// /// public interface IClientTransport { /// /// Gets a transport identifier, used for logging purposes. /// string Name { get; } /// /// Asynchronously establishes a transport session with an MCP server and returns a transport for the duplex message stream. /// /// The to monitor for cancellation requests. The default is . /// Returns an interface for the duplex message stream. /// /// /// This method is responsible for initializing the connection to the server using the specific transport /// mechanism implemented by the derived class. The returned interface /// provides methods to send and receive messages over the established connection. /// /// /// The lifetime of the returned instance is typically managed by the /// that uses this transport. When the client is disposed, it will dispose /// the transport session as well. /// /// /// This method is used by to initialize the connection. /// /// /// The transport connection could not be established. Task ConnectAsync(CancellationToken cancellationToken = default); }