pub struct McpClient { /* private fields */ }Expand description
MCP Client - Connect to MCP servers
Implementations§
Source§impl McpClient
impl McpClient
Sourcepub fn with_auth_handler<H: AuthHandler + 'static>(self, handler: H) -> Self
pub fn with_auth_handler<H: AuthHandler + 'static>(self, handler: H) -> Self
Configure authentication
Sourcepub fn with_streamable_http_server(self, endpoint: &str) -> Self
pub fn with_streamable_http_server(self, endpoint: &str) -> Self
Connect to MCP server via Streamable HTTP.
Sourcepub fn with_streamable_http_server_auth(
self,
endpoint: &str,
auth_token: &str,
) -> Self
pub fn with_streamable_http_server_auth( self, endpoint: &str, auth_token: &str, ) -> Self
Connect to MCP server via Streamable HTTP with bearer authentication.
Sourcepub fn with_streamable_http_headers(
self,
headers: HashMap<String, String>,
) -> Self
pub fn with_streamable_http_headers( self, headers: HashMap<String, String>, ) -> Self
Add extra HTTP headers to the Streamable HTTP transport.
Sourcepub fn with_streamable_http_client_info(self, client_info: ClientInfo) -> Self
pub fn with_streamable_http_client_info(self, client_info: ClientInfo) -> Self
Override the Streamable HTTP client identity used during initialize.
Sourcepub async fn list_tools_async(&self) -> Result<Vec<Tool>, ProtocolError>
pub async fn list_tools_async(&self) -> Result<Vec<Tool>, ProtocolError>
List tools from server.
Sourcepub async fn call_tool_async(
&self,
name: &str,
arguments: Option<Value>,
) -> Result<CallToolResult, ProtocolError>
pub async fn call_tool_async( &self, name: &str, arguments: Option<Value>, ) -> Result<CallToolResult, ProtocolError>
Call tool on server.
pub async fn call_tool_with_meta_async( &self, name: &str, arguments: Option<Value>, meta: Option<Value>, ) -> Result<CallToolResult, ProtocolError>
Sourcepub async fn initialize_async(&self) -> Result<(), ProtocolError>
pub async fn initialize_async(&self) -> Result<(), ProtocolError>
Initialize the current Streamable HTTP transport explicitly.
Sourcepub async fn health_check(&self) -> Result<(), ProtocolError>
pub async fn health_check(&self) -> Result<(), ProtocolError>
Check server health.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for McpClient
impl !RefUnwindSafe for McpClient
impl Send for McpClient
impl Sync for McpClient
impl Unpin for McpClient
impl UnsafeUnpin for McpClient
impl !UnwindSafe for McpClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more