diff --git a/crates/rust-mcp-sdk/src/mcp_handlers/mcp_client_handler.rs b/crates/rust-mcp-sdk/src/mcp_handlers/mcp_client_handler.rs index c7e11bc..4f6f93b 100644 --- a/crates/rust-mcp-sdk/src/mcp_handlers/mcp_client_handler.rs +++ b/crates/rust-mcp-sdk/src/mcp_handlers/mcp_client_handler.rs @@ -144,7 +144,7 @@ pub trait ClientHandler: Send + Sync + 'static { runtime: &dyn McpClient, ) -> std::result::Result<(), RpcError> { if !runtime.is_shut_down().await { - eprintln!("Process error: {}", error_message); + tracing::error!("Process error: {}", error_message); } Ok(()) } diff --git a/crates/rust-mcp-sdk/src/mcp_handlers/mcp_client_handler_core.rs b/crates/rust-mcp-sdk/src/mcp_handlers/mcp_client_handler_core.rs index 0c29016..ee07028 100644 --- a/crates/rust-mcp-sdk/src/mcp_handlers/mcp_client_handler_core.rs +++ b/crates/rust-mcp-sdk/src/mcp_handlers/mcp_client_handler_core.rs @@ -48,7 +48,7 @@ pub trait ClientHandlerCore: Send + Sync + 'static { runtime: &dyn McpClient, ) -> std::result::Result<(), RpcError> { if !runtime.is_shut_down().await { - eprintln!("Process error: {}", error_message); + tracing::error!("Process error: {}", error_message); } Ok(()) } diff --git a/crates/rust-mcp-sdk/src/mcp_runtimes/client_runtime.rs b/crates/rust-mcp-sdk/src/mcp_runtimes/client_runtime.rs index d6e1e86..ff95e15 100644 --- a/crates/rust-mcp-sdk/src/mcp_runtimes/client_runtime.rs +++ b/crates/rust-mcp-sdk/src/mcp_runtimes/client_runtime.rs @@ -118,7 +118,7 @@ impl McpClient for ClientRuntime { break; } Err(e) => { - eprintln!("Error reading from std_err: {}", e); + tracing::error!("Error reading from std_err: {}", e); break; } } diff --git a/crates/rust-mcp-transport/src/client_sse.rs b/crates/rust-mcp-transport/src/client_sse.rs index cadf03a..b8e55eb 100644 --- a/crates/rust-mcp-transport/src/client_sse.rs +++ b/crates/rust-mcp-transport/src/client_sse.rs @@ -258,7 +258,7 @@ where // trim the trailing \n before making a request let body = String::from_utf8_lossy(&data).trim().to_string(); if let Err(e) = http_post(&client_clone, &post_url, body, &custom_headers).await { - eprintln!("Failed to POST message: {:?}", e); + tracing::error!("Failed to POST message: {:?}", e); } }, None => break, // Exit if channel is closed diff --git a/crates/rust-mcp-transport/src/mcp_stream.rs b/crates/rust-mcp-transport/src/mcp_stream.rs index f5ed223..0d3067f 100644 --- a/crates/rust-mcp-transport/src/mcp_stream.rs +++ b/crates/rust-mcp-transport/src/mcp_stream.rs @@ -123,8 +123,8 @@ impl MCPStream { //An error that is unrelated to a request. tx.send(message).map_err(GenericSendError::new)?; } else { - eprintln!( - "Error: Received response does not correspond to any request. {:?}", + tracing::warn!( + "Received response or error without a matching request: {:?}", &message.is_response() ); } diff --git a/crates/rust-mcp-transport/src/utils/sse_stream.rs b/crates/rust-mcp-transport/src/utils/sse_stream.rs index e71ff18..cad8791 100644 --- a/crates/rust-mcp-transport/src/utils/sse_stream.rs +++ b/crates/rust-mcp-transport/src/utils/sse_stream.rs @@ -67,7 +67,7 @@ impl SseStream { { Ok(resp) => resp, Err(e) => { - eprintln!("Failed to connect to SSE: {}", e); + tracing::error!("Failed to connect to SSE: {}", e); if retry_count >= self.max_retries { tracing::error!("Max retries reached, giving up"); if let Some(tx) = endpoint_event_tx.take() { @@ -159,7 +159,9 @@ impl SseStream { if !content.is_empty() { let bytes = Bytes::copy_from_slice(content.as_bytes()); if self.read_tx.send(bytes).await.is_err() { - eprintln!("Readable stream closed, shutting down SSE task"); + tracing::error!( + "Readable stream closed, shutting down SSE task" + ); if !endpoint_event_received { if let Some(tx) = endpoint_event_tx.take() { let _ = tx.send(None);