namespace McpDotNet.Client;
using McpDotNet.Protocol.Types;
using McpDotNet.Protocol.Messages;
///
/// Represents an instance of the MCP client connecting to a specific server.
/// Use PingAsync, ListToolsAsync and CallToolAsync instead of SendRequestAsync for common operations.
/// SendRequestAsync is provided for custom request and those not yet covered explicitly by the client.
///
public interface IMcpClient : IAsyncDisposable
{
///
/// Gets a value indicating whether the client has been initialized.
///
bool IsInitialized { get; }
///
/// Gets the capabilities supported by the server.
///
ServerCapabilities? ServerCapabilities { get; }
///
/// Gets the version and implementation information of the server.
///
Implementation? ServerInfo { get; }
///
/// Instructions describing how to use the server and its features.
/// This can be used by clients to improve the LLM's understanding of available tools, resources, etc.
/// It can be thought of like a "hint" to the model. For example, this information MAY be added to the system prompt.
///
string? ServerInstructions { get; }
///
/// Gets or sets the handler for server sampling requests.
///
Func>? SamplingHandler { get; set; }
///
/// Gets or sets the handler for providing root URIs to servers.
///
Func>? RootsHandler { get; set; }
///
/// Establishes a connection to the server.
///
/// A token to cancel the operation.
/// A task representing the asynchronous operation.
Task ConnectAsync(CancellationToken cancellationToken = default);
///
/// Sends a ping request to verify server connectivity.
///
/// A token to cancel the operation.
/// A task that completes when the ping is successful.
Task PingAsync(CancellationToken cancellationToken = default);
///
/// Retrieves a list of available tools from the server.
///
/// An optional cursor to paginate the results.
/// A token to cancel the operation.
/// A task containing the server's response with tool information.
Task ListToolsAsync(string? cursor = null, CancellationToken cancellationToken = default);
///
/// Invokes a tool on the server with optional arguments.
///
/// The name of the tool to call.
/// Optional arguments for the tool.
/// A token to cancel the operation.
/// A task containing the tool's response.
Task CallToolAsync(string toolName, Dictionary? arguments = null, CancellationToken cancellationToken = default);
///
/// Retrieves a list of available prompts from the server.
///
/// An optional cursor to paginate the results.
/// A token to cancel the operation.
/// A task containing the server's response with prompt information.
Task ListPromptsAsync(string? cursor = null, CancellationToken cancellationToken = default);
///
/// Retrieves a specific prompt with optional arguments.
///
/// The name of the prompt to retrieve
/// Optional arguments for the prompt
/// A token to cancel the operation.
/// A task containing the prompt's content and messages.
Task GetPromptAsync(string name, Dictionary? arguments = null, CancellationToken cancellationToken = default);
///
/// Retrieves a list of available resources from the server.
///
/// An optional cursor to paginate the results.
/// A token to cancel the operation.
///
Task ListResourcesAsync(string? cursor = null, CancellationToken cancellationToken = default);
///
/// Reads a resource from the server.
///
/// The uri of the resource.
/// A token to cancel the operation.
///
Task ReadResourceAsync(string uri, CancellationToken cancellationToken = default);
///
/// Gets the completion options for a resource or prompt reference and (named) argument.
///
/// A resource (uri) or prompt (name) reference
/// Name of argument. Must be non-null and non-empty.
/// Value of argument. Must be non-null.
/// A token to cancel the operation.
///
Task GetCompletionAsync(Reference reference, string argumentName, string argumentValue, CancellationToken cancellationToken = default);
///
/// Subscribes to a resource on the server.
///
/// The uri of the resource.
/// A token to cancel the operation.
///
Task SubscribeToResourceAsync(string uri, CancellationToken cancellationToken = default);
///
/// Unsubscribes from a resource on the server.
///
/// The uri of the resource.
/// A token to cancel the operation.
///
Task UnsubscribeFromResourceAsync(string uri, CancellationToken cancellationToken = default);
///
/// Sends a generic JSON-RPC request to the server.
/// NB! This is a temporary method that is available to send not yet implemented feature messages.
/// Once all MCP features are implemented this will be made private, as it is purely a convenience for those who wish to implement features ahead of the library.
///
/// The expected response type.
/// The JSON-RPC request to send.
/// A token to cancel the operation.
/// A task containing the server's response.
Task SendRequestAsync(JsonRpcRequest request, CancellationToken cancellationToken) where T : class;
///
/// Registers a handler for server notifications of a specific method.
///
/// Constants for common notification methods
///
/// The notification method to handle.
/// The async handler function to process notifications.
void OnNotification(string method, Func handler);
///
/// Sends a notification to the server.
///
/// The notification method name.
/// A token to cancel the operation.
Task SendNotificationAsync(string method, CancellationToken cancellationToken = default);
///
/// Sends a notification to the server with parameters.
///
/// The notification method name.
/// The parameters to send with the notification.
/// A token to cancel the operation.
Task SendNotificationAsync(string method, T parameters, CancellationToken cancellationToken = default);
}