Skip to content

Commit dde95d4

Browse files
authored
chore: remove leftover prints for tracing statements - Fixes TUI apps using the SDK (#60)
* Test tracing instead of eprint * remove comments
1 parent 8817d3f commit dde95d4

File tree

6 files changed

+10
-8
lines changed

6 files changed

+10
-8
lines changed

crates/rust-mcp-sdk/src/mcp_handlers/mcp_client_handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ pub trait ClientHandler: Send + Sync + 'static {
144144
runtime: &dyn McpClient,
145145
) -> std::result::Result<(), RpcError> {
146146
if !runtime.is_shut_down().await {
147-
eprintln!("Process error: {}", error_message);
147+
tracing::error!("Process error: {}", error_message);
148148
}
149149
Ok(())
150150
}

crates/rust-mcp-sdk/src/mcp_handlers/mcp_client_handler_core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub trait ClientHandlerCore: Send + Sync + 'static {
4848
runtime: &dyn McpClient,
4949
) -> std::result::Result<(), RpcError> {
5050
if !runtime.is_shut_down().await {
51-
eprintln!("Process error: {}", error_message);
51+
tracing::error!("Process error: {}", error_message);
5252
}
5353
Ok(())
5454
}

crates/rust-mcp-sdk/src/mcp_runtimes/client_runtime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl McpClient for ClientRuntime {
118118
break;
119119
}
120120
Err(e) => {
121-
eprintln!("Error reading from std_err: {}", e);
121+
tracing::error!("Error reading from std_err: {}", e);
122122
break;
123123
}
124124
}

crates/rust-mcp-transport/src/client_sse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ where
258258
// trim the trailing \n before making a request
259259
let body = String::from_utf8_lossy(&data).trim().to_string();
260260
if let Err(e) = http_post(&client_clone, &post_url, body, &custom_headers).await {
261-
eprintln!("Failed to POST message: {:?}", e);
261+
tracing::error!("Failed to POST message: {:?}", e);
262262
}
263263
},
264264
None => break, // Exit if channel is closed

crates/rust-mcp-transport/src/mcp_stream.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ impl MCPStream {
123123
//An error that is unrelated to a request.
124124
tx.send(message).map_err(GenericSendError::new)?;
125125
} else {
126-
eprintln!(
127-
"Error: Received response does not correspond to any request. {:?}",
126+
tracing::warn!(
127+
"Received response or error without a matching request: {:?}",
128128
&message.is_response()
129129
);
130130
}

crates/rust-mcp-transport/src/utils/sse_stream.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl SseStream {
6767
{
6868
Ok(resp) => resp,
6969
Err(e) => {
70-
eprintln!("Failed to connect to SSE: {}", e);
70+
tracing::error!("Failed to connect to SSE: {}", e);
7171
if retry_count >= self.max_retries {
7272
tracing::error!("Max retries reached, giving up");
7373
if let Some(tx) = endpoint_event_tx.take() {
@@ -159,7 +159,9 @@ impl SseStream {
159159
if !content.is_empty() {
160160
let bytes = Bytes::copy_from_slice(content.as_bytes());
161161
if self.read_tx.send(bytes).await.is_err() {
162-
eprintln!("Readable stream closed, shutting down SSE task");
162+
tracing::error!(
163+
"Readable stream closed, shutting down SSE task"
164+
);
163165
if !endpoint_event_received {
164166
if let Some(tx) = endpoint_event_tx.take() {
165167
let _ = tx.send(None);

0 commit comments

Comments
 (0)