mcp_client_rust/
client.rs1use mcp_core_rs::protocol::message::{JsonRpcMessage, JsonRpcRequest};
2use mcp_error_rs::Result;
3use mcp_transport_rs::client::traits::ClientTransport;
4
5pub struct McpClient<T>
6where
7 T: ClientTransport + Send + Sync + 'static,
8{
9 pub transport: T,
10}
11
12impl<T> McpClient<T>
13where
14 T: ClientTransport + Send + Sync + 'static,
15{
16 pub fn new(transport: T) -> Self {
17 Self { transport }
18 }
19
20 pub async fn send(&self, message: JsonRpcMessage) -> Result<JsonRpcMessage> {
21 self.transport.send(message).await
22 }
23
24 pub async fn send_resquest(&self, request: JsonRpcRequest) -> Result<JsonRpcMessage> {
25 let message = JsonRpcMessage::Request(request);
26 self.transport.send(message).await
27 }
28}