pub struct MCPClient { /* private fields */ }
Expand description
MCP client for connecting to and interacting with MCP servers.
Implementations§
Source§impl MCPClient
impl MCPClient
Sourcepub fn new(server_url: impl AsRef<str>) -> Result<Self>
pub fn new(server_url: impl AsRef<str>) -> Result<Self>
Create a new MCP client for the given server URL.
Sourcepub async fn initialize(
&self,
client_capabilities: ClientCapabilities,
) -> Result<ServerCapabilities>
pub async fn initialize( &self, client_capabilities: ClientCapabilities, ) -> Result<ServerCapabilities>
Initialize the connection to the MCP server.
Sourcepub async fn get_resource(
&self,
params: GetResourceParams,
) -> Result<ResourceResponse>
pub async fn get_resource( &self, params: GetResourceParams, ) -> Result<ResourceResponse>
Get a resource from the server.
Sourcepub async fn tool_call(
&self,
params: ToolCallParams,
) -> Result<ToolCallResponse>
pub async fn tool_call( &self, params: ToolCallParams, ) -> Result<ToolCallResponse>
Call a tool on the server.
Sourcepub async fn execute_prompt(
&self,
params: ExecutePromptParams,
) -> Result<ExecutePromptResponse>
pub async fn execute_prompt( &self, params: ExecutePromptParams, ) -> Result<ExecutePromptResponse>
Execute a prompt on the server.
Sourcepub async fn respond_to_sampling(
&self,
id: String,
result: SamplingResponse,
) -> Result<()>
pub async fn respond_to_sampling( &self, id: String, result: SamplingResponse, ) -> Result<()>
Send a sampling response to the server.
Sourcepub async fn capabilities(&self) -> Option<ServerCapabilities>
pub async fn capabilities(&self) -> Option<ServerCapabilities>
Get the server capabilities.
Auto Trait Implementations§
impl !Freeze for MCPClient
impl !RefUnwindSafe for MCPClient
impl Send for MCPClient
impl Sync for MCPClient
impl Unpin 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