pub struct McpClient { /* private fields */ }Expand description
MCP client wrapper.
Implementations§
Source§impl McpClient
impl McpClient
Sourcepub fn new(transport: McpTransport) -> Self
pub fn new(transport: McpTransport) -> Self
Create a new MCP client.
Sourcepub fn builder() -> McpClientBuilder
pub fn builder() -> McpClientBuilder
Create a client builder.
Sourcepub async fn disconnect(&mut self) -> Result<()>
pub async fn disconnect(&mut self) -> Result<()>
Disconnect from the MCP server.
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Check if connected.
Sourcepub async fn list_tools(&mut self) -> Result<Vec<ToolDefinition>>
pub async fn list_tools(&mut self) -> Result<Vec<ToolDefinition>>
List available tools.
Sourcepub async fn get_tool(&mut self, name: &str) -> Result<Option<ToolDefinition>>
pub async fn get_tool(&mut self, name: &str) -> Result<Option<ToolDefinition>>
Get a specific tool definition.
Sourcepub async fn call_tool(
&self,
name: &str,
arguments: Value,
) -> Result<ToolResult>
pub async fn call_tool( &self, name: &str, arguments: Value, ) -> Result<ToolResult>
Execute a tool call.
Sourcepub fn session_id(&self) -> &str
pub fn session_id(&self) -> &str
Get the session ID.
Sourcepub fn clear_cache(&mut self)
pub fn clear_cache(&mut self)
Clear the tool cache.
Source§impl McpClient
Convenience functions for common connection patterns.
impl McpClient
Convenience functions for common connection patterns.
Sourcepub async fn list_resources(&self) -> Result<ResourceListResult>
pub async fn list_resources(&self) -> Result<ResourceListResult>
List resources from the connected MCP server.
Sourcepub async fn read_resource(&self, uri: &str) -> Result<ResourceContents>
pub async fn read_resource(&self, uri: &str) -> Result<ResourceContents>
Read a resource by URI from the connected MCP server.
Sourcepub async fn list_resource_templates(
&self,
) -> Result<ResourceTemplateListResult>
pub async fn list_resource_templates( &self, ) -> Result<ResourceTemplateListResult>
List resource templates from the connected MCP server.
Sourcepub async fn subscribe_resource(&self, uri: &str) -> Result<()>
pub async fn subscribe_resource(&self, uri: &str) -> Result<()>
Subscribe to resource change notifications.
Sourcepub async fn unsubscribe_resource(&self, uri: &str) -> Result<()>
pub async fn unsubscribe_resource(&self, uri: &str) -> Result<()>
Unsubscribe from resource change notifications.
Sourcepub async fn list_prompts(&self) -> Result<PromptListResult>
pub async fn list_prompts(&self) -> Result<PromptListResult>
List prompts from the connected MCP server.
Sourcepub async fn get_prompt(
&self,
name: &str,
arguments: HashMap<String, String>,
) -> Result<GetPromptResult>
pub async fn get_prompt( &self, name: &str, arguments: HashMap<String, String>, ) -> Result<GetPromptResult>
Get a rendered prompt by name with arguments.
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<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request