Struct UltraFastClient

Source
pub struct UltraFastClient { /* private fields */ }
Expand description

UltraFast MCP Client

Implementations§

Source§

impl UltraFastClient

Source

pub fn new(info: ClientInfo, capabilities: ClientCapabilities) -> Self

Create a new MCP client

Source

pub fn new_with_timeout( info: ClientInfo, capabilities: ClientCapabilities, timeout: Duration, ) -> Self

Create a new MCP client with custom timeout

Source

pub fn with_timeout(self, timeout: Duration) -> Self

Set request timeout

Source

pub fn with_timeout_config(self, config: TimeoutConfig) -> Self

Set timeout configuration

Source

pub fn get_timeout_config(&self) -> TimeoutConfig

Get current timeout configuration

Source

pub fn with_high_performance_timeouts(self) -> Self

Set timeout configuration for high-performance scenarios

Source

pub fn with_long_running_timeouts(self) -> Self

Set timeout configuration for long-running operations

Source

pub fn get_operation_timeout(&self, operation: &str) -> Duration

Get operation-specific timeout

Source

pub fn with_auth(self, auth_method: AuthMethod) -> Self

Set authentication method

Source

pub fn with_bearer_auth(self, token: String) -> Self

Set Bearer token authentication

Source

pub fn with_bearer_auth_refresh<F, Fut>( self, token: String, refresh_fn: F, ) -> Self
where F: Fn() -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<String, AuthError>> + Send + 'static,

Set Bearer token authentication with auto-refresh

Source

pub fn with_oauth_auth(self, config: OAuthConfig) -> Self

Set OAuth authentication

Source

pub fn with_api_key_auth(self, api_key: String) -> Self

Set API key authentication

Source

pub fn with_api_key_auth_custom( self, api_key: String, header_name: String, ) -> Self

Set API key authentication with custom header name

Source

pub fn with_basic_auth(self, username: String, password: String) -> Self

Set Basic authentication

Source

pub fn with_custom_auth(self) -> Self

Set custom header authentication

Source

pub async fn get_auth_headers( &self, ) -> Result<HashMap<String, String>, AuthError>

Get authentication headers for requests

Source

pub fn with_elicitation_handler( self, handler: Arc<dyn ClientElicitationHandler>, ) -> Self

Set elicitation handler for handling server-initiated elicitation requests

Source

pub async fn connect(&self, transport: Box<dyn Transport>) -> MCPResult<()>

Connect to a server using the provided transport

Source

pub async fn connect_stdio(&self) -> MCPResult<()>

Connect to a server using STDIO transport

Source

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

Source

pub async fn connect_http_with_auth( &self, url: &str, auth_token: String, ) -> MCPResult<()>

Connect to a server using HTTP transport with authentication

Source

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

Source

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

Source

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

Source

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)

Source

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

Source

pub async fn connect_streamable_http_with_config( &self, config: StreamableHttpClientConfig, ) -> MCPResult<()>

Connect to a server using Streamable HTTP transport with custom configuration

Source

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

Source

pub async fn shutdown(&self, reason: Option<String>) -> MCPResult<()>

Shutdown the client

Source

pub async fn disconnect(&self) -> MCPResult<()>

Disconnect from the server

Source

pub async fn get_state(&self) -> ClientState

Get current client state

Source

pub async fn can_operate(&self) -> bool

Check if client can perform operations

Source

pub async fn get_server_info(&self) -> Option<ServerInfo>

Get server information

Source

pub async fn get_server_capabilities(&self) -> Option<ServerCapabilities>

Get server capabilities

Source

pub async fn get_negotiated_version(&self) -> Option<String>

Get negotiated protocol version

Source

pub fn info(&self) -> &ClientInfo

Get client information

Source

pub async fn check_server_capability(&self, capability: &str) -> MCPResult<bool>

Check if server supports a specific capability

Source

pub async fn check_server_feature( &self, capability: &str, feature: &str, ) -> MCPResult<bool>

Check if server supports a specific feature within a capability

Source

pub async fn list_tools( &self, request: ListToolsRequest, ) -> MCPResult<ListToolsResponse>

List available tools

Source

pub async fn list_tools_default(&self) -> MCPResult<ListToolsResponse>

List tools with default parameters

Source

pub async fn call_tool(&self, tool_call: ToolCall) -> MCPResult<ToolResult>

Call a tool

Source

pub async fn list_resources( &self, request: ListResourcesRequest, ) -> MCPResult<ListResourcesResponse>

List available resources

Source

pub async fn read_resource( &self, request: ReadResourceRequest, ) -> MCPResult<ReadResourceResponse>

Read a resource

Source

pub async fn subscribe_resource(&self, uri: String) -> MCPResult<()>

Subscribe to resource changes

Source

pub async fn list_prompts( &self, request: ListPromptsRequest, ) -> MCPResult<ListPromptsResponse>

List available prompts

Source

pub async fn get_prompt( &self, request: GetPromptRequest, ) -> MCPResult<GetPromptResponse>

Get a specific prompt

Source

pub async fn create_message( &self, request: CreateMessageRequest, ) -> MCPResult<CreateMessageResponse>

Create a message using sampling

Source

pub async fn complete( &self, request: CompleteRequest, ) -> MCPResult<CompleteResponse>

Complete a request

Source

pub async fn respond_to_elicitation( &self, response: ElicitationResponse, ) -> MCPResult<()>

Respond to elicitation request (called by client-side elicitation handler)

Source

pub async fn list_roots(&self) -> MCPResult<Vec<Root>>

List filesystem roots

Source

pub async fn set_log_level(&self, level: LogLevel) -> MCPResult<()>

Set log level

Source

pub async fn ping(&self, data: Option<Value>) -> MCPResult<PingResponse>

Send ping

Source

pub async fn start_ping_monitoring( &self, ping_interval: Duration, ) -> MCPResult<()>

Start periodic ping monitoring (optional, for connection health)

Source

pub async fn stop_ping_monitoring(&self) -> MCPResult<()>

Stop ping monitoring

Source

pub async fn notify_cancelled( &self, request_id: Value, reason: Option<String>, ) -> MCPResult<()>

Notify cancellation

Source

pub async fn notify_progress( &self, progress_token: Value, progress: f64, total: Option<f64>, message: Option<String>, ) -> MCPResult<()>

Notify progress

Source

pub fn should_send_progress(&self, last_progress: Instant) -> bool

Check if progress notification should be sent based on timeout configuration

Source

pub fn get_progress_interval(&self) -> Duration

Get progress interval from timeout configuration

Trait Implementations§

Source§

impl Debug for UltraFastClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,