pub struct UltraFastClient { /* private fields */ }
Expand description
UltraFast MCP Client
Implementations§
Source§impl UltraFastClient
impl UltraFastClient
Sourcepub fn new(info: ClientInfo, capabilities: ClientCapabilities) -> Self
pub fn new(info: ClientInfo, capabilities: ClientCapabilities) -> Self
Create a new MCP client
Sourcepub fn new_with_timeout(
info: ClientInfo,
capabilities: ClientCapabilities,
timeout: Duration,
) -> Self
pub fn new_with_timeout( info: ClientInfo, capabilities: ClientCapabilities, timeout: Duration, ) -> Self
Create a new MCP client with custom timeout
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Set request timeout
Sourcepub fn with_timeout_config(self, config: TimeoutConfig) -> Self
pub fn with_timeout_config(self, config: TimeoutConfig) -> Self
Set timeout configuration
Sourcepub fn get_timeout_config(&self) -> TimeoutConfig
pub fn get_timeout_config(&self) -> TimeoutConfig
Get current timeout configuration
Sourcepub fn with_high_performance_timeouts(self) -> Self
pub fn with_high_performance_timeouts(self) -> Self
Set timeout configuration for high-performance scenarios
Sourcepub fn with_long_running_timeouts(self) -> Self
pub fn with_long_running_timeouts(self) -> Self
Set timeout configuration for long-running operations
Sourcepub fn get_operation_timeout(&self, operation: &str) -> Duration
pub fn get_operation_timeout(&self, operation: &str) -> Duration
Get operation-specific timeout
Sourcepub fn with_auth(self, auth_method: AuthMethod) -> Self
pub fn with_auth(self, auth_method: AuthMethod) -> Self
Set authentication method
Sourcepub fn with_bearer_auth(self, token: String) -> Self
pub fn with_bearer_auth(self, token: String) -> Self
Set Bearer token authentication
Sourcepub fn with_bearer_auth_refresh<F, Fut>(
self,
token: String,
refresh_fn: F,
) -> Self
pub fn with_bearer_auth_refresh<F, Fut>( self, token: String, refresh_fn: F, ) -> Self
Set Bearer token authentication with auto-refresh
Sourcepub fn with_oauth_auth(self, config: OAuthConfig) -> Self
pub fn with_oauth_auth(self, config: OAuthConfig) -> Self
Set OAuth authentication
Sourcepub fn with_api_key_auth(self, api_key: String) -> Self
pub fn with_api_key_auth(self, api_key: String) -> Self
Set API key authentication
Sourcepub fn with_api_key_auth_custom(
self,
api_key: String,
header_name: String,
) -> Self
pub fn with_api_key_auth_custom( self, api_key: String, header_name: String, ) -> Self
Set API key authentication with custom header name
Sourcepub fn with_basic_auth(self, username: String, password: String) -> Self
pub fn with_basic_auth(self, username: String, password: String) -> Self
Set Basic authentication
Sourcepub fn with_custom_auth(self) -> Self
pub fn with_custom_auth(self) -> Self
Set custom header authentication
Sourcepub async fn get_auth_headers(
&self,
) -> Result<HashMap<String, String>, AuthError>
pub async fn get_auth_headers( &self, ) -> Result<HashMap<String, String>, AuthError>
Get authentication headers for requests
Sourcepub fn with_elicitation_handler(
self,
handler: Arc<dyn ClientElicitationHandler>,
) -> Self
pub fn with_elicitation_handler( self, handler: Arc<dyn ClientElicitationHandler>, ) -> Self
Set elicitation handler for handling server-initiated elicitation requests
Sourcepub async fn connect(&self, transport: Box<dyn Transport>) -> MCPResult<()>
pub async fn connect(&self, transport: Box<dyn Transport>) -> MCPResult<()>
Connect to a server using the provided transport
Sourcepub async fn connect_stdio(&self) -> MCPResult<()>
pub async fn connect_stdio(&self) -> MCPResult<()>
Connect to a server using STDIO transport
Sourcepub async fn connect_streamable_http(&self, url: &str) -> MCPResult<()>
pub async fn connect_streamable_http(&self, url: &str) -> MCPResult<()>
Connect to a server using Streamable HTTP transport This method will automatically use any client-level authentication configured
Sourcepub async fn connect_http_with_auth(
&self,
url: &str,
auth_token: String,
) -> MCPResult<()>
pub async fn connect_http_with_auth( &self, url: &str, auth_token: String, ) -> MCPResult<()>
Connect to a server using HTTP transport with authentication
Sourcepub async fn connect_streamable_http_with_bearer(
&self,
url: &str,
token: String,
) -> MCPResult<()>
pub async fn connect_streamable_http_with_bearer( &self, url: &str, token: String, ) -> MCPResult<()>
Connect to a server using Streamable HTTP transport with Bearer token authentication
Sourcepub async fn connect_streamable_http_with_oauth(
&self,
url: &str,
oauth_config: OAuthConfig,
) -> MCPResult<()>
pub async fn connect_streamable_http_with_oauth( &self, url: &str, oauth_config: OAuthConfig, ) -> MCPResult<()>
Connect to a server using Streamable HTTP transport with OAuth 2.1 authentication
Sourcepub async fn connect_streamable_http_with_api_key(
&self,
url: &str,
api_key: String,
) -> MCPResult<()>
pub async fn connect_streamable_http_with_api_key( &self, url: &str, api_key: String, ) -> MCPResult<()>
Connect to a server using Streamable HTTP transport with API key authentication
Sourcepub async fn connect_streamable_http_with_api_key_custom(
&self,
url: &str,
api_key: String,
header_name: String,
) -> MCPResult<()>
pub async fn connect_streamable_http_with_api_key_custom( &self, url: &str, api_key: String, header_name: String, ) -> MCPResult<()>
Connect to a server using Streamable HTTP transport with API key authentication (custom header)
Sourcepub async fn connect_streamable_http_with_basic(
&self,
url: &str,
username: String,
password: String,
) -> MCPResult<()>
pub async fn connect_streamable_http_with_basic( &self, url: &str, username: String, password: String, ) -> MCPResult<()>
Connect to a server using Streamable HTTP transport with Basic authentication
Sourcepub async fn connect_streamable_http_with_config(
&self,
config: StreamableHttpClientConfig,
) -> MCPResult<()>
pub async fn connect_streamable_http_with_config( &self, config: StreamableHttpClientConfig, ) -> MCPResult<()>
Connect to a server using Streamable HTTP transport with custom configuration
Sourcepub async fn initialize(&self) -> MCPResult<()>
pub async fn initialize(&self) -> MCPResult<()>
Initialize the connection with the server Initialize the client connection This method must be called after connecting to establish the MCP protocol
Sourcepub async fn disconnect(&self) -> MCPResult<()>
pub async fn disconnect(&self) -> MCPResult<()>
Disconnect from the server
Sourcepub async fn get_state(&self) -> ClientState
pub async fn get_state(&self) -> ClientState
Get current client state
Sourcepub async fn can_operate(&self) -> bool
pub async fn can_operate(&self) -> bool
Check if client can perform operations
Sourcepub async fn get_server_info(&self) -> Option<ServerInfo>
pub async fn get_server_info(&self) -> Option<ServerInfo>
Get server information
Sourcepub async fn get_server_capabilities(&self) -> Option<ServerCapabilities>
pub async fn get_server_capabilities(&self) -> Option<ServerCapabilities>
Get server capabilities
Sourcepub async fn get_negotiated_version(&self) -> Option<String>
pub async fn get_negotiated_version(&self) -> Option<String>
Get negotiated protocol version
Sourcepub fn info(&self) -> &ClientInfo
pub fn info(&self) -> &ClientInfo
Get client information
Sourcepub async fn check_server_capability(&self, capability: &str) -> MCPResult<bool>
pub async fn check_server_capability(&self, capability: &str) -> MCPResult<bool>
Check if server supports a specific capability
Sourcepub async fn check_server_feature(
&self,
capability: &str,
feature: &str,
) -> MCPResult<bool>
pub async fn check_server_feature( &self, capability: &str, feature: &str, ) -> MCPResult<bool>
Check if server supports a specific feature within a capability
Sourcepub async fn list_tools(
&self,
request: ListToolsRequest,
) -> MCPResult<ListToolsResponse>
pub async fn list_tools( &self, request: ListToolsRequest, ) -> MCPResult<ListToolsResponse>
List available tools
Sourcepub async fn list_tools_default(&self) -> MCPResult<ListToolsResponse>
pub async fn list_tools_default(&self) -> MCPResult<ListToolsResponse>
List tools with default parameters
Sourcepub async fn call_tool(&self, tool_call: ToolCall) -> MCPResult<ToolResult>
pub async fn call_tool(&self, tool_call: ToolCall) -> MCPResult<ToolResult>
Call a tool
Sourcepub async fn list_resources(
&self,
request: ListResourcesRequest,
) -> MCPResult<ListResourcesResponse>
pub async fn list_resources( &self, request: ListResourcesRequest, ) -> MCPResult<ListResourcesResponse>
List available resources
Sourcepub async fn read_resource(
&self,
request: ReadResourceRequest,
) -> MCPResult<ReadResourceResponse>
pub async fn read_resource( &self, request: ReadResourceRequest, ) -> MCPResult<ReadResourceResponse>
Read a resource
Sourcepub async fn subscribe_resource(&self, uri: String) -> MCPResult<()>
pub async fn subscribe_resource(&self, uri: String) -> MCPResult<()>
Subscribe to resource changes
Sourcepub async fn list_prompts(
&self,
request: ListPromptsRequest,
) -> MCPResult<ListPromptsResponse>
pub async fn list_prompts( &self, request: ListPromptsRequest, ) -> MCPResult<ListPromptsResponse>
List available prompts
Sourcepub async fn get_prompt(
&self,
request: GetPromptRequest,
) -> MCPResult<GetPromptResponse>
pub async fn get_prompt( &self, request: GetPromptRequest, ) -> MCPResult<GetPromptResponse>
Get a specific prompt
Sourcepub async fn create_message(
&self,
request: CreateMessageRequest,
) -> MCPResult<CreateMessageResponse>
pub async fn create_message( &self, request: CreateMessageRequest, ) -> MCPResult<CreateMessageResponse>
Create a message using sampling
Sourcepub async fn complete(
&self,
request: CompleteRequest,
) -> MCPResult<CompleteResponse>
pub async fn complete( &self, request: CompleteRequest, ) -> MCPResult<CompleteResponse>
Complete a request
Sourcepub async fn respond_to_elicitation(
&self,
response: ElicitationResponse,
) -> MCPResult<()>
pub async fn respond_to_elicitation( &self, response: ElicitationResponse, ) -> MCPResult<()>
Respond to elicitation request (called by client-side elicitation handler)
Sourcepub async fn list_roots(&self) -> MCPResult<Vec<Root>>
pub async fn list_roots(&self) -> MCPResult<Vec<Root>>
List filesystem roots
Sourcepub async fn set_log_level(&self, level: LogLevel) -> MCPResult<()>
pub async fn set_log_level(&self, level: LogLevel) -> MCPResult<()>
Set log level
Sourcepub async fn start_ping_monitoring(
&self,
ping_interval: Duration,
) -> MCPResult<()>
pub async fn start_ping_monitoring( &self, ping_interval: Duration, ) -> MCPResult<()>
Start periodic ping monitoring (optional, for connection health)
Sourcepub async fn stop_ping_monitoring(&self) -> MCPResult<()>
pub async fn stop_ping_monitoring(&self) -> MCPResult<()>
Stop ping monitoring
Sourcepub async fn notify_cancelled(
&self,
request_id: Value,
reason: Option<String>,
) -> MCPResult<()>
pub async fn notify_cancelled( &self, request_id: Value, reason: Option<String>, ) -> MCPResult<()>
Notify cancellation
Sourcepub async fn notify_progress(
&self,
progress_token: Value,
progress: f64,
total: Option<f64>,
message: Option<String>,
) -> MCPResult<()>
pub async fn notify_progress( &self, progress_token: Value, progress: f64, total: Option<f64>, message: Option<String>, ) -> MCPResult<()>
Notify progress
Sourcepub fn should_send_progress(&self, last_progress: Instant) -> bool
pub fn should_send_progress(&self, last_progress: Instant) -> bool
Check if progress notification should be sent based on timeout configuration
Sourcepub fn get_progress_interval(&self) -> Duration
pub fn get_progress_interval(&self) -> Duration
Get progress interval from timeout configuration