Skip to content

Commit e9dd16c

Browse files
committed
clippy fixes
1 parent 8817d3f commit e9dd16c

File tree

20 files changed

+29
-34
lines changed

20 files changed

+29
-34
lines changed

crates/rust-mcp-macros/src/utils.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,7 @@ mod tests {
460460
let ty: syn::Type = syn::parse_str(ty_str).unwrap();
461461
assert!(
462462
!might_be_struct(&ty),
463-
"Expected '{}' to be not a struct",
464-
ty_str
463+
"Expected '{ty_str}' to be not a struct"
465464
);
466465
}
467466
}

crates/rust-mcp-sdk/src/hyper_servers/routes/fallback_routes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ pub fn routes() -> Router {
1010
pub async fn not_found(uri: Uri) -> (StatusCode, String) {
1111
(
1212
StatusCode::INTERNAL_SERVER_ERROR,
13-
format!("Server Error!\r\n uri: {}", uri),
13+
format!("Server Error!\r\n uri: {uri}"),
1414
)
1515
}

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+
eprintln!("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+
eprintln!("Process error: {error_message}");
5252
}
5353
Ok(())
5454
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub trait ServerHandler: Send + Sync + 'static {
3333
) -> std::result::Result<InitializeResult, RpcError> {
3434
runtime
3535
.set_client_details(initialize_request.params.clone())
36-
.map_err(|err| RpcError::internal_error().with_message(format!("{}", err)))?;
36+
.map_err(|err| RpcError::internal_error().with_message(format!("{err}")))?;
3737

3838
let mut server_info = runtime.server_info().to_owned();
3939
// Provide compatibility for clients using older MCP protocol versions.

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+
eprintln!("Error reading from std_err: {e}");
122122
break;
123123
}
124124
}

crates/rust-mcp-sdk/src/mcp_runtimes/server_runtime/mcp_server_runtime_core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl McpServerHandler for RuntimeCoreInternalHandler<Box<dyn ServerHandlerCore>>
7070
// keep a copy of the InitializeRequestParams which includes client_info and capabilities
7171
runtime
7272
.set_client_details(initialize_request.params.clone())
73-
.map_err(|err| RpcError::internal_error().with_message(format!("{}", err)))?;
73+
.map_err(|err| RpcError::internal_error().with_message(format!("{err}")))?;
7474
}
7575

7676
// handle request and get the result

crates/rust-mcp-sdk/src/utils.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ use crate::error::{McpSdkError, SdkResult};
2121
/// assert_eq!(msg, "Server does not support resources (required for resources/list)");
2222
/// ```
2323
pub fn format_assertion_message(entity: &str, capability: &str, method_name: &str) -> String {
24-
format!(
25-
"{} does not support {} (required for {})",
26-
entity, capability, method_name
27-
)
24+
format!("{entity} does not support {capability} (required for {method_name})")
2825
}
2926

3027
/// Checks if the client and server protocol versions are compatible by ensuring they are equal.

crates/rust-mcp-sdk/tests/test_server_sse.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ mod tets_server_sse {
4242
sleep(Duration::from_millis(750)).await;
4343

4444
let client = Client::new();
45-
println!("connecting to : {}", server_endpoint);
45+
println!("connecting to : {server_endpoint}");
4646
// Act: Connect to the SSE endpoint and read the event stream
4747
let response = client
4848
.get(server_endpoint)
@@ -105,7 +105,7 @@ mod tets_server_sse {
105105
sleep(Duration::from_millis(750)).await;
106106

107107
let client = Client::new();
108-
println!("connecting to : {}", server_endpoint);
108+
println!("connecting to : {server_endpoint}");
109109
// Act: Connect to the SSE endpoint and read the event stream
110110
let response = client
111111
.get(server_endpoint)
@@ -171,7 +171,7 @@ mod tets_server_sse {
171171
sleep(Duration::from_millis(750)).await;
172172

173173
let client = Client::new();
174-
println!("connecting to : {}", server_endpoint);
174+
println!("connecting to : {server_endpoint}");
175175
// Act: Connect to the SSE endpoint and read the event stream
176176
let response = client
177177
.get(server_endpoint)

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@ impl ClientSseTransport {
125125
let mut header_map = HeaderMap::new();
126126

127127
for (key, value) in headers {
128-
let header_name = key.parse::<HeaderName>().map_err(|e| {
129-
TransportError::InvalidOptions(format!("Invalid header name: {}", e))
130-
})?;
128+
let header_name = key
129+
.parse::<HeaderName>()
130+
.map_err(|e| TransportError::InvalidOptions(format!("Invalid header name: {e}")))?;
131131
let header_value = HeaderValue::from_str(value).map_err(|e| {
132-
TransportError::InvalidOptions(format!("Invalid header value: {}", e))
132+
TransportError::InvalidOptions(format!("Invalid header value: {e}"))
133133
})?;
134134
header_map.insert(header_name, header_value);
135135
}
@@ -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+
eprintln!("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: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ impl MCPStream {
140140
Err(e) => {
141141
// Handle error in reading from readable_std
142142
return Err(TransportError::ProcessError(format!(
143-
"Error reading from readable_std: {}",
144-
e
143+
"Error reading from readable_std: {e}"
145144
)));
146145
}
147146
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ pub(crate) fn endpoint_with_session_id(endpoint: &str, session_id: &SessionId) -
6767

6868
// Build the query string
6969
let new_query = match query {
70-
Some(q) if !q.is_empty() => format!("{}&sessionId={}", q, session_id),
71-
_ => format!("sessionId={}", session_id),
70+
Some(q) if !q.is_empty() => format!("{q}&sessionId={session_id}"),
71+
_ => format!("sessionId={session_id}"),
7272
};
7373

7474
// Construct final URL
7575
match fragment {
76-
Some(f) => format!("{}?{}#{}", path, new_query, f),
77-
None => format!("{}?{}", path, new_query),
76+
Some(f) => format!("{path}?{new_query}#{f}"),
77+
None => format!("{path}?{new_query}"),
7878
}
7979
}
8080

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub fn extract_origin(url: &str) -> Option<String> {
4646
let host_port = &rest[..end];
4747

4848
// Reconstruct origin
49-
Some(format!("{}://{}", scheme, host_port))
49+
Some(format!("{scheme}://{host_port}"))
5050
}
5151

5252
#[cfg(test)]

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

Lines changed: 1 addition & 1 deletion
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+
eprintln!("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() {

examples/hello-world-mcp-server-core/src/handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl ServerHandlerCore for MyServerHandler {
7878

7979
// Return Method not found for any other requests
8080
_ => Err(RpcError::method_not_found()
81-
.with_message(format!("No handler is implemented for '{}'.", method_name,))),
81+
.with_message(format!("No handler is implemented for '{method_name}'.",))),
8282
},
8383
// Handle custom requests
8484
RequestFromClient::CustomRequest(_) => Err(RpcError::method_not_found()

examples/hello-world-server-core-sse/src/handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl ServerHandlerCore for MyServerHandler {
7777

7878
// Return Method not found for any other requests
7979
_ => Err(RpcError::method_not_found()
80-
.with_message(format!("No handler is implemented for '{}'.", method_name,))),
80+
.with_message(format!("No handler is implemented for '{method_name}'.",))),
8181
},
8282
// Handle custom requests
8383
RequestFromClient::CustomRequest(_) => Err(RpcError::method_not_found()

examples/simple-mcp-client-core-sse/src/inquiry_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ impl InquiryUtils {
202202
let max_pings = n;
203203
println!();
204204
for ping_index in 1..=max_pings {
205-
print!("Ping the server ({} out of {})...", ping_index, max_pings);
205+
print!("Ping the server ({ping_index} out of {max_pings})...");
206206
std::io::stdout().flush().unwrap();
207207
let ping_result = self.client.ping(None).await;
208208
print!(

examples/simple-mcp-client-core/src/inquiry_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ impl InquiryUtils {
202202
let max_pings = n;
203203
println!();
204204
for ping_index in 1..=max_pings {
205-
print!("Ping the server ({} out of {})...", ping_index, max_pings);
205+
print!("Ping the server ({ping_index} out of {max_pings})...");
206206
std::io::stdout().flush().unwrap();
207207
let ping_result = self.client.ping(None).await;
208208
print!(

examples/simple-mcp-client-sse/src/inquiry_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ impl InquiryUtils {
202202
let max_pings = n;
203203
println!();
204204
for ping_index in 1..=max_pings {
205-
print!("Ping the server ({} out of {})...", ping_index, max_pings);
205+
print!("Ping the server ({ping_index} out of {max_pings})...");
206206
std::io::stdout().flush().unwrap();
207207
let ping_result = self.client.ping(None).await;
208208
print!(

examples/simple-mcp-client/src/inquiry_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ impl InquiryUtils {
202202
let max_pings = n;
203203
println!();
204204
for ping_index in 1..=max_pings {
205-
print!("Ping the server ({} out of {})...", ping_index, max_pings);
205+
print!("Ping the server ({ping_index} out of {max_pings})...");
206206
std::io::stdout().flush().unwrap();
207207
let ping_result = self.client.ping(None).await;
208208
print!(

0 commit comments

Comments
 (0)