Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
273 changes: 145 additions & 128 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rust-mcp-filesystem"
version = "0.2.3"
edition = "2021"
edition = "2024"
repository = "https://github.com/rust-mcp-stack/rust-mcp-filesystem"
authors = ["Ali Hashemi"]
description = "Blazing-fast, asynchronous MCP server for seamless filesystem operations."
Expand All @@ -15,17 +15,17 @@ license = false
eula = false

[dependencies]
rust-mcp-sdk = { version = "0.6", default-features = false, features = [
rust-mcp-sdk = {version="0.7", default-features = false, features = [
"server",
"macros",
"stdio",
"2025_06_18",
] }

thiserror = { version = "2.0" }
dirs = "6.0"
glob = "0.3"
walkdir = "2.5"
derive_more = { version = "2.0", features = ["display", "from_str"] }
similar = "=2.7"
chrono = "0.4"
clap = { version = "4.5", features = ["derive"] }
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Rust MCP Filesystem

Rust MCP Filesystem is a blazingly fast, asynchronous, and lightweight MCP (Model Context Protocol) server designed for efficient handling of various filesystem operations.
Rust MCP Filesystem is a blazingly fast, asynchronous, and lightweight MCP (Model Context Protocol) server designed for efficient handling of various filesystem operations.
This project is a pure Rust rewrite of the JavaScript-based `@modelcontextprotocol/server-filesystem`, offering enhanced capabilities, improved performance, and a robust feature set tailored for modern filesystem interactions.

πŸš€ Refer to the [project documentation](https://rust-mcp-stack.github.io/rust-mcp-filesystem) for installation and configuration instructions.
Expand All @@ -14,8 +14,9 @@ This project is a pure Rust rewrite of the JavaScript-based `@modelcontextprotoc
- **⚑ High Performance**: Built in Rust for speed and efficiency, leveraging asynchronous I/O to handle filesystem operations seamlessly.
- **πŸ”’ Read-Only by Default**: Starts with no write access, ensuring safety until explicitly configured otherwise.
- **πŸ” Advanced Glob Search**: Supports full glob pattern matching allowing precise filtering of files and directories using standard glob syntax.For example, patterns like `*.rs`, `src/**/*.txt`, and `logs/error-???.log` are valid and can be used to match specific file types, recursive directory searches, or patterned filenames.
- **πŸ“ Nested Directories**: Improved directory creation, allowing the creation of nested directories.
- **πŸ“¦ Lightweight**: Standalone with no external dependencies (e.g., no Node.js, Python etc required), compiled to a single binary with a minimal resource footprint, ideal for both lightweight and extensive deployment scenarios.
- **πŸ”„ MCP Roots support**: enabling clients to dynamically modify the list of allowed directories (disabled by default).
- **πŸ“¦ ZIP Archive Support**: Tools to create ZIP archives from files or directories and extract ZIP files with ease.
- **πŸͺΆ Lightweight**: Standalone with no external dependencies (e.g., no Node.js, Python etc required), compiled to a single binary with a minimal resource footprint, ideal for both lightweight and extensive deployment scenarios.

#### πŸ‘‰ Refer to [capabilities](https://rust-mcp-stack.github.io/rust-mcp-filesystem/#/capabilities) for a full list of tools and other capabilities.

Expand Down
5 changes: 3 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Rust MCP Filesystem

Rust MCP Filesystem is a blazingly fast, asynchronous, and lightweight MCP (Model Context Protocol) server designed for efficient handling of various filesystem operations.
Rust MCP Filesystem is a blazingly fast, asynchronous, and lightweight MCP (Model Context Protocol) server designed for efficient handling of various filesystem operations.
This project is a pure Rust rewrite of the JavaScript-based **@modelcontextprotocol/server-filesystem**, offering enhanced capabilities, improved performance, and a robust feature set tailored for modern filesystem interactions.

Refer to the [quickstart](quickstart.md) guide for installation and configuration instructions.
Expand All @@ -9,7 +9,8 @@ Refer to the [quickstart](quickstart.md) guide for installation and configuratio

- **⚑ High Performance**: Built in Rust for speed and efficiency, leveraging asynchronous I/O to handle filesystem operations seamlessly.
- **πŸ”’ Read-Only by Default**: Starts with no write access, ensuring safety until explicitly configured otherwise.
- **πŸ” Advanced Glob Search**: Full glob pattern matching for precise file and directory filtering (e.g., `*.rs`, `src/**/*.txt`, `logs/error-???.log`).
- **πŸ” Advanced Glob Search**: Supports full glob pattern matching allowing precise filtering of files and directories using standard glob syntax.For example, patterns like `*.rs`, `src/**/*.txt`, and `logs/error-???.log` are valid and can be used to match specific file types, recursive directory searches, or patterned filenames.
- **πŸ”„ MCP Roots support**: enabling clients to dynamically modify the list of allowed directories (disabled by default).
- **πŸ“¦ ZIP Archive Support**: Tools to create ZIP archives from files or directories and extract ZIP files with ease.
- **πŸͺΆ Lightweight**: Standalone with no external dependencies (e.g., no Node.js, Python etc required), compiled to a single binary with a minimal resource footprint, ideal for both lightweight and extensive deployment scenarios.

Expand Down
3 changes: 2 additions & 1 deletion docs/_coverpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

- πŸͺΆ Lightweight
- ⚑ High Performance
- πŸ”’ Read-Only by Default
- πŸ”’ Secure by design
- πŸ”§ Packed with powerful tools

[GitHub](https://github.com/rust-mcp-stack/rust-mcp-filesystem)
[βš™οΈ Capabilities](capabilities.md)
Expand Down
11 changes: 8 additions & 3 deletions docs/guide/cli-command-options.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
## CLI Command Options

```sh
Usage: rust-mcp-filesystem [OPTIONS] <ALLOWED_DIRECTORIES>...
Usage: rust-mcp-filesystem [OPTIONS] [ALLOWED_DIRECTORIES]...

Arguments:
<ALLOWED_DIRECTORIES>...
[ALLOWED_DIRECTORIES]...
Provide a space-separated list of directories that are permitted for the operation.
This list allows multiple directories to be provided.

Example: rust-mcp-filesystem /path/to/dir1 /path/to/dir2 /path/to/dir3

Options:
-w, --allow-write
Enables read/write mode for the app, allowing both reading and writing.
Enables read/write mode for the app, allowing both reading and writing. Defaults to disabled.

-t, --enable-roots
Enables dynamic directory access control via Roots from the MCP client side. Defaults to disabled.
When enabled, MCP clients that support Roots can dynamically update the allowed directories.
Any directories provided by the client will completely replace the initially configured allowed directories on the server.

-h, --help
Print help (see a summary with '-h')
Expand Down
29 changes: 24 additions & 5 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,40 @@
use clap::{arg, command, Parser};
use clap::{Parser, arg, command};

#[derive(Parser, Debug)]
#[command(name = env!("CARGO_PKG_NAME"))]
#[command(version = env!("CARGO_PKG_VERSION"))]
#[command(about = "A lightning-fast, asynchronous, and lightweight MCP server designed for efficient handling of various filesystem operations",
#[command(about = "A lightning-fast, asynchronous, and lightweight MCP server designed for efficient handling of various filesystem operations",
long_about = None)]
pub struct CommandArguments {
#[arg(
short = 'w',
long,
help = "Enables read/write mode for the app, allowing both reading and writing."
help = "Enables read/write mode for the app, allowing both reading and writing. Defaults to disabled."
)]
pub allow_write: bool,
#[arg(
help = "List of directories that are permitted for the operation.",
help = "List of directories that are permitted for the operation. It is required when 'enable-roots' is not provided OR client does not support Roots.",
long_help = concat!("Provide a space-separated list of directories that are permitted for the operation.\nThis list allows multiple directories to be provided.\n\nExample: ", env!("CARGO_PKG_NAME"), " /path/to/dir1 /path/to/dir2 /path/to/dir3"),
required = true
required = false
)]
pub allowed_directories: Vec<String>,

#[arg(
short = 't',
long,
help = "Enables dynamic directory access control via Roots from the MCP client side. Defaults to disabled.\nWhen enabled, MCP clients that support Roots can dynamically update the allowed directories.\nAny directories provided by the client will completely replace the initially configured allowed directories on the server."
)]
pub enable_roots: bool,
}

impl CommandArguments {
pub fn validate(&self) -> Result<(), String> {
if !self.enable_roots && self.allowed_directories.is_empty() {
return Err(format!(
" <ALLOWED_DIRECTORIES> is required when `--enable-roots` is not provided.\n Run `{} --help` to view the usage instructions.",
env!("CARGO_PKG_NAME")
));
}
Ok(())
}
}
8 changes: 5 additions & 3 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use async_zip::error::ZipError;
use glob::PatternError;
use rust_mcp_sdk::schema::{schema_utils::SdkError, RpcError};
use rust_mcp_sdk::{error::McpSdkError, TransportError};
use rust_mcp_sdk::schema::{RpcError, schema_utils::SdkError};
use rust_mcp_sdk::{TransportError, error::McpSdkError};

use thiserror::Error;
use tokio::io;
Expand All @@ -10,7 +10,9 @@ pub type ServiceResult<T> = core::result::Result<T, ServiceError>;

#[derive(Debug, Error)]
pub enum ServiceError {
#[error("Service is running in read-only mode. To enable write access, please run with the --allow-write flag.")]
#[error(
"Service is running in read-only mode. To enable write access, please run with the --allow-write flag."
)]
NoWriteAccess,
#[error("{0}")]
FromString(String),
Expand Down
Loading