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); /// /// Adds a handler for server notifications of a specific method. /// /// The notification method to handle. /// The async handler function to process notifications. /// /// /// Each method may have multiple handlers. Adding a handler for a method that already has one /// will not replace the existing handler. /// /// /// provides constants for common notification methods. /// /// void AddNotificationHandler(string method, Func handler); }