pub struct Client { /* private fields */ }
Expand description
MCP client state
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(
sender: UnboundedSender<Message>,
receiver: UnboundedReceiver<Message>,
) -> Self
pub fn new( sender: UnboundedSender<Message>, receiver: UnboundedReceiver<Message>, ) -> Self
Create a new MCP client
Sourcepub async fn initialize(
&self,
implementation: Implementation,
capabilities: Option<ClientCapabilities>,
) -> Result<ServerCapabilities, Error>
pub async fn initialize( &self, implementation: Implementation, capabilities: Option<ClientCapabilities>, ) -> Result<ServerCapabilities, Error>
Initialize the client
Sourcepub async fn request(
&self,
method: &str,
params: Option<Value>,
) -> Result<Value, Error>
pub async fn request( &self, method: &str, params: Option<Value>, ) -> Result<Value, Error>
Send a request to the server and wait for the response.
This method will block until a response is received from the server.
If the server returns an error, it will be propagated as an Error
.
pub async fn subscribe(&self, uri: &str) -> Result<(), Error>
pub async fn set_log_level(&self, level: LoggingLevel) -> Result<(), Error>
Sourcepub async fn notify(
&self,
method: &str,
params: Option<Value>,
) -> Result<(), Error>
pub async fn notify( &self, method: &str, params: Option<Value>, ) -> Result<(), Error>
Send a notification to the server
Sourcepub async fn capabilities(&self) -> Option<ServerCapabilities>
pub async fn capabilities(&self) -> Option<ServerCapabilities>
Get the server capabilities
Trait Implementations§
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