using ModelContextProtocol.Protocol.Messages; namespace ModelContextProtocol; /// Represents a client or server MCP endpoint. public interface IMcpEndpoint : IAsyncDisposable { /// Sends a JSON-RPC request to the connected endpoint. /// The JSON-RPC request to send. /// The to monitor for cancellation requests. The default is . /// A task containing the client's response. Task SendRequestAsync(JsonRpcRequest request, CancellationToken cancellationToken = default); /// Sends a message to the connected endpoint. /// The message. /// The to monitor for cancellation requests. The default is . Task SendMessageAsync(IJsonRpcMessage message, CancellationToken cancellationToken = default); /// Registers a handler to be invoked when a notification for the specified method is received. /// The notification method. /// The handler to be invoked. /// An that will remove the registered handler when disposed. IAsyncDisposable RegisterNotificationHandler(string method, Func handler); }