Skip to content

Commit a3c1f94

Browse files
committed
clean up
1 parent 7ef1e7f commit a3c1f94

File tree

11 files changed

+28
-37
lines changed

11 files changed

+28
-37
lines changed

src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::path::PathBuf;
22

3-
use clap::{arg, command, Parser, Subcommand, ValueEnum};
3+
use clap::{Parser, Subcommand, ValueEnum, arg, command};
44
use mcp_discovery::{DiscoveryCommand, LogLevel, PrintOptions, Template, WriteOptions};
55

66
#[derive(Debug, Clone, ValueEnum, PartialEq)]

src/handler.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use async_trait::async_trait;
22
use rust_mcp_sdk::schema::RpcError;
3-
use rust_mcp_sdk::{mcp_client::ClientHandler, McpClient};
3+
use rust_mcp_sdk::{McpClient, mcp_client::ClientHandler};
44

55
pub struct MyClientHandler;
66

@@ -12,7 +12,7 @@ impl ClientHandler for MyClientHandler {
1212
runtime: &dyn McpClient,
1313
) -> std::result::Result<(), RpcError> {
1414
if !runtime.is_shut_down().await {
15-
eprintln!("{}", error_message);
15+
eprintln!("{error_message}");
1616
}
1717
Ok(())
1818
}

src/lib.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl McpDiscovery {
9191
}
9292
_ => {
9393
let content = template.render_template(server_info)?;
94-
println!("{}", content);
94+
println!("{content}");
9595
}
9696
}
9797

@@ -251,8 +251,7 @@ impl McpDiscovery {
251251
item.mime_type
252252
.as_ref()
253253
.map_or("".to_string(), |mime_type| format!(
254-
" ({})",
255-
mime_type
254+
" ({mime_type})"
256255
))
257256
.dimmed(),
258257
item.description.as_ref().map_or(
@@ -291,8 +290,7 @@ impl McpDiscovery {
291290
item.mime_type
292291
.as_ref()
293292
.map_or("".to_string(), |mime_type| format!(
294-
" ({})",
295-
mime_type
293+
" ({mime_type})"
296294
))
297295
.dimmed(),
298296
item.description.as_ref().map_or(

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ async fn main() {
4444
let mut discovery_agent = McpDiscovery::new(command);
4545

4646
if let Err(error) = discovery_agent.start().await {
47-
eprintln!("Error: {}", error);
47+
eprintln!("Error: {error}");
4848
std::process::exit(1);
4949
}
5050
}

src/render_template.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub fn register_helpers(handlebar: &mut Handlebars) {
109109

110110
// Helper: Formats a capability tag with a boolean indicator and optional count.
111111
handlebars_helper!(capability_tag: |label:Value, supported: Value, count: Option<i64>| {
112-
let count_str = count.map_or("".to_string(), |count| if count>0 {format!(" ({})", count)} else{"".to_string()});
112+
let count_str = count.map_or("".to_string(), |count| if count>0 {format!(" ({count})")} else{"".to_string()});
113113
if supported.as_bool().unwrap_or(false) {
114114
format!("{} {}{}", boolean_indicator(true), label.as_str().unwrap(), count_str)
115115
}
@@ -139,8 +139,8 @@ pub fn register_helpers(handlebar: &mut Handlebars) {
139139
// Helper: Formats a capability title with optional count and underline.
140140
handlebars_helper!(capability_title: |label:Option<String>, count: Option<i64>, with_underline:Option<bool>| {
141141
let label = label.unwrap_or("".to_string());
142-
let count_str = count.map(|c| format!("({})", c)).unwrap_or("".to_string());
143-
let text = format!("{}{}", label, count_str);
142+
let count_str = count.map(|c| format!("({c})")).unwrap_or("".to_string());
143+
let text = format!("{label}{count_str}");
144144
let underline_str = with_underline.unwrap_or(false).then(|| format!("\n{}", "─".repeat(text.width())));
145145
format!("{}{}",text,underline_str.unwrap_or("".to_string()))
146146
});
@@ -150,7 +150,7 @@ pub fn register_helpers(handlebar: &mut Handlebars) {
150150
let label = label.unwrap_or("".to_string());
151151
let re = Regex::new(&regex.to_string()).unwrap();
152152
let result = re.replace_all(&label, replacer.to_string());
153-
format!("{}", result)
153+
format!("{result}")
154154
});
155155
// Helper: Converts a ParamTypes enum to its string representation.
156156
handlebars_helper!(tool_param_type: |param_type:ParamTypes| {
@@ -514,6 +514,7 @@ mod tests {
514514
resources: false,
515515
logging: false,
516516
experimental: false,
517+
completions: false,
517518
},
518519
tools: Default::default(),
519520
prompts: Default::default(),
@@ -574,7 +575,7 @@ mod tests {
574575

575576
// Test json helper (pretty)
576577
let result = handlebar
577-
.render_template("{{json true}}", &json!({"key": "value"}))
578+
.render_template("{{json this 'pretty'}}", &json!({"key": "value"}))
578579
.expect("Failed to render json");
579580
assert_eq!(result, "{\n \"key\": \"value\"\n}");
580581

src/schema.rs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,13 @@ fn resolve_ref<'a>(
1515
) -> DiscoveryResult<&'a Value> {
1616
if !ref_path.starts_with("#/") {
1717
return Err(DiscoveryError::InvalidSchema(format!(
18-
"$ref '{}' must start with '#/'",
19-
ref_path
18+
"$ref '{ref_path}' must start with '#/'"
2019
)));
2120
}
2221

2322
if !visited.insert(ref_path.to_string()) {
2423
return Err(DiscoveryError::InvalidSchema(format!(
25-
"Cycle detected in $ref path '{}'",
26-
ref_path
24+
"Cycle detected in $ref path '{ref_path}'"
2725
)));
2826
}
2927

@@ -33,15 +31,13 @@ fn resolve_ref<'a>(
3331
for segment in path {
3432
if segment.is_empty() {
3533
return Err(DiscoveryError::InvalidSchema(format!(
36-
"Invalid $ref path '{}': empty segment",
37-
ref_path
34+
"Invalid $ref path '{ref_path}': empty segment"
3835
)));
3936
}
4037
current = match current {
4138
Value::Object(obj) => obj.get(segment).ok_or_else(|| {
4239
DiscoveryError::InvalidSchema(format!(
43-
"Invalid $ref path '{}': segment '{}' not found",
44-
ref_path, segment
40+
"Invalid $ref path '{ref_path}': segment '{segment}' not found"
4541
))
4642
})?,
4743
Value::Array(arr) => segment
@@ -50,15 +46,13 @@ fn resolve_ref<'a>(
5046
.and_then(|i| arr.get(i))
5147
.ok_or_else(|| {
5248
DiscoveryError::InvalidSchema(format!(
53-
"Invalid $ref path '{}': segment '{}' not found in array",
54-
ref_path, segment
49+
"Invalid $ref path '{ref_path}': segment '{segment}' not found in array"
5550
))
5651
})?,
5752
_ => {
5853
return Err(DiscoveryError::InvalidSchema(format!(
59-
"Invalid $ref path '{}': cannot traverse into non-object/array",
60-
ref_path
61-
)))
54+
"Invalid $ref path '{ref_path}': cannot traverse into non-object/array"
55+
)));
6256
}
6357
};
6458
}
@@ -91,8 +85,7 @@ pub fn param_object(
9185
let param_value = param_value
9286
.as_object()
9387
.ok_or(DiscoveryError::InvalidSchema(format!(
94-
"Property '{}' is not an object",
95-
param_name
88+
"Property '{param_name}' is not an object"
9689
)))?;
9790
let param_type = param_type(param_value, root_schema, visited)?;
9891
let param_description = object_map
@@ -127,8 +120,7 @@ pub fn param_type(
127120
let ref_map = ref_value
128121
.as_object()
129122
.ok_or(DiscoveryError::InvalidSchema(format!(
130-
"$ref '{}' does not point to an object",
131-
ref_path_str
123+
"$ref '{ref_path_str}' does not point to an object"
132124
)))?;
133125
return param_type(ref_map, root_schema, visited);
134126
}
@@ -154,7 +146,7 @@ pub fn param_type(
154146
return Err(DiscoveryError::InvalidSchema(format!(
155147
"Unsupported enum value type: {}",
156148
serde_json::to_string(value).unwrap_or_default()
157-
)))
149+
)));
158150
}
159151
};
160152
param_types.push(param_type);

src/std_output.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use colored::Colorize;
22
use std::io::{self, Write};
33
use unicode_width::UnicodeWidthStr;
44

5-
use crate::{utils::boolean_indicator, McpServerInfo};
5+
use crate::{McpServerInfo, utils::boolean_indicator};
66

77
const SUMMARY_HEADER_SIZE: usize = 50;
88

src/templates.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use crate::{
2+
McpServerInfo,
23
error::DiscoveryResult,
34
render_template,
45
types::Template,
56
utils::{find_template_file, line_ending},
6-
McpServerInfo,
77
};
88
use std::{
99
borrow::Cow,

src/types/capabilities.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl Display for ParamTypes {
7575
.collect::<Vec<String>>()
7676
.join("|"),
7777
};
78-
write!(f, "{}", type_name)
78+
write!(f, "{type_name}")
7979
}
8080
}
8181

src/types/commands.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ use std::{
66
};
77

88
use crate::{
9+
OutputTemplate,
910
error::{DiscoveryError, DiscoveryResult},
1011
utils::match_template,
11-
OutputTemplate,
1212
};
1313

1414
/// Enum representing the main actions that can be performed for MCP discovery.

0 commit comments

Comments
 (0)