You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/fs_service.rs
+13-15Lines changed: 13 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -792,10 +792,10 @@ impl FileSystemService {
792
792
*current_count += 1;
793
793
794
794
// Check if we've exceeded max_files (if set)
795
-
ifletSome(max) = max_files{
796
-
if*current_count > max{
797
-
continue;// Skip this entry but continue processing others
798
-
}
795
+
ifletSome(max) = max_files
796
+
&&*current_count > max
797
+
{
798
+
continue;// Skip this entry but continue processing others
799
799
}
800
800
801
801
letmut json_entry = json!({
@@ -1463,10 +1463,8 @@ impl FileSystemService {
1463
1463
.filter_map(|e| e.ok())
1464
1464
.all(|e| !e.file_type().is_file() || is_system_metadata_file(e.file_name()));// Directory is empty if no files are found in it or subdirs, ".DS_Store" will be ignores on Mac
1465
1465
1466
-
if is_empty {
1467
-
ifletSome(path_str) = entry.path().to_str(){
1468
-
empty_dirs.push(path_str.to_string());
1469
-
}
1466
+
if is_empty && letSome(path_str) = entry.path().to_str(){
1467
+
empty_dirs.push(path_str.to_string());
1470
1468
}
1471
1469
}
1472
1470
@@ -1505,13 +1503,13 @@ impl FileSystemService {
1505
1503
.filter(|e| e.file_type().is_file());// Only files
let allowed_directories = self.fs_service.allowed_directories().await;
79
+
// if client does NOT support roots
75
80
if !runtime.client_supports_root_list().unwrap_or(false){
81
+
// use allowed directories from command line
76
82
if !allowed_directories.is_empty(){
77
-
let _ = runtime.stderr_message(format!("Client does not support MCP Roots, using allowed directories set from server args:\n{}", allowed_directories
78
-
.iter()
79
-
.map(|p| p.display().to_string())
80
-
.collect::<Vec<String>>()
81
-
.join(",\n"))).await;
83
+
// display message only if mcp_roots_support is enabled, otherwise this message will be redundant
84
+
ifself.mcp_roots_support{
85
+
let _ = runtime.stderr_message("Client does not support MCP Roots. Allowed directories passed from command-line will be used.".to_string()).await;
86
+
}
82
87
}else{
83
-
// let message = "Server cannot operate: No allowed directories available. Server was started without command-line directories and client either does not support MCP roots protocol or provided empty roots. Please either: 1) Start server with directory arguments, or 2) Use a client that supports MCP roots protocol and provides valid root directories.";
88
+
// root lists not supported AND allowed directories are empty
84
89
let message = "Server cannot operate: No allowed directories available. Server was started without command-line directories and client does not support MCP roots protocol. Please either: 1) Start server with directory arguments, or 2) Use a client that supports MCP roots protocol and provides valid root directories.";
85
90
let _ = runtime.stderr_message(message.to_string()).await;
91
+
std::process::exit(1);// exit the server
86
92
}
87
93
}else{
94
+
// client supports roots
88
95
let fs_service = self.fs_service.clone();
89
-
let mcp_roots_support = self.mcp_roots_support;
90
96
// retrieve roots from the client and update the allowed directories accordingly
91
97
let roots = match runtime.clone().list_roots(None).await{
92
98
Ok(roots_result) => roots_result.roots,
@@ -111,7 +117,7 @@ impl FileSystemHandler {
111
117
}
112
118
};
113
119
114
-
if valid_roots.is_empty()&& !mcp_roots_support {
120
+
if valid_roots.is_empty(){
115
121
let message = if allowed_directories.is_empty(){
116
122
"Server cannot operate: No allowed directories available. Server was started without command-line directories and client provided empty roots. Please either: 1) Start server with directory arguments, or 2) Use a client that supports MCP roots protocol and provides valid root directories."
117
123
}else{
@@ -120,7 +126,6 @@ impl FileSystemHandler {
120
126
let _ = runtime.stderr_message(message.to_string()).await;
0 commit comments