pub struct Client { /* private fields */ }Expand description
MCP client session
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(
transport: Box<dyn Transport + Send + Sync>,
options: ClientOptions,
) -> (Self, Receiver<ClientEvent>)
pub fn new( transport: Box<dyn Transport + Send + Sync>, options: ClientOptions, ) -> (Self, Receiver<ClientEvent>)
Create a new client with the given transport and options
Sourcepub async fn disconnect(&self) -> Result<(), Error>
pub async fn disconnect(&self) -> Result<(), Error>
Disconnect from the server
Sourcepub async fn send_request(
&self,
request: JSONRPCRequest,
) -> Result<JSONRPCMessage, Error>
pub async fn send_request( &self, request: JSONRPCRequest, ) -> Result<JSONRPCMessage, Error>
Send a request to the server and wait for a response
Sourcepub async fn send_notification(
&self,
notification: JSONRPCNotification,
) -> Result<(), Error>
pub async fn send_notification( &self, notification: JSONRPCNotification, ) -> Result<(), Error>
Send a notification to the server
Sourcepub async fn list_resource_templates(
&self,
) -> Result<Vec<ResourceTemplate>, Error>
pub async fn list_resource_templates( &self, ) -> Result<Vec<ResourceTemplate>, Error>
List available resource templates
Sourcepub async fn read_resource(
&self,
uri: &str,
) -> Result<Vec<ResourceContent>, Error>
pub async fn read_resource( &self, uri: &str, ) -> Result<Vec<ResourceContent>, Error>
Read a resource
Sourcepub async fn subscribe_resource(&self, uri: &str) -> Result<(), Error>
pub async fn subscribe_resource(&self, uri: &str) -> Result<(), Error>
Subscribe to resource updates
Sourcepub async fn unsubscribe_resource(&self, uri: &str) -> Result<(), Error>
pub async fn unsubscribe_resource(&self, uri: &str) -> Result<(), Error>
Unsubscribe from resource updates
Sourcepub async fn get_prompt(
&self,
name: &str,
arguments: Option<HashMap<String, String>>,
) -> Result<Vec<PromptMessage>, Error>
pub async fn get_prompt( &self, name: &str, arguments: Option<HashMap<String, String>>, ) -> Result<Vec<PromptMessage>, Error>
Get a prompt
Sourcepub async fn call_tool(
&self,
name: &str,
arguments: Option<Value>,
) -> Result<CallToolResult, Error>
pub async fn call_tool( &self, name: &str, arguments: Option<Value>, ) -> Result<CallToolResult, Error>
Call a tool
Sourcepub async fn set_logging_level(&self, level: LoggingLevel) -> Result<(), Error>
pub async fn set_logging_level(&self, level: LoggingLevel) -> Result<(), Error>
Set the logging level
Sourcepub async fn get_completions(
&self,
reference_type: CompletionReferenceType,
reference_name: &str,
argument_name: &str,
argument_value: &str,
) -> Result<CompleteResult, Error>
pub async fn get_completions( &self, reference_type: CompletionReferenceType, reference_name: &str, argument_name: &str, argument_value: &str, ) -> Result<CompleteResult, Error>
Get completions for an argument
Sourcepub async fn list_roots(&self) -> Result<Vec<Root>, Error>
pub async fn list_roots(&self) -> Result<Vec<Root>, Error>
List available roots (from server to client)
Sourcepub async fn notify_roots_changed(&self) -> Result<(), Error>
pub async fn notify_roots_changed(&self) -> Result<(), Error>
Notify the server that the roots list has changed
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
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