Skip to main content

fs_mcp_rs/
lib.rs

1//! A bounded, root-isolated filesystem server for the Model Context Protocol (MCP).
2//!
3//! The crate separates path-policy enforcement, filesystem operations, search,
4//! protocol types, configuration, and child-process management into independent
5//! modules. Applications can embed these modules directly or run the bundled
6//! `fs-mcp-rs` binary using either HTTP POST or STDIO JSON-RPC transports.
7//!
8//! # Transports & Execution Modes
9//!
10//! - **STDIO Mode**: Standard input/output line-delimited JSON-RPC 2.0 streaming,
11//!   ideal for local MCP client subprocess integration (e.g. via `npx fs-mcp-rs`).
12//! - **HTTP Mode**: Streamable HTTP server exposing `/mcp` and `/health` endpoints
13//!   with optional OAuth 2.0 / OIDC authentication metadata.
14//! - **CLI Quickstart**: Roots can be passed directly as positional arguments or configured
15//!   via TOML files and environment variables.
16//!
17//! # Security model
18//!
19//! All filesystem entry points accept a [`security::Policy`]. The policy
20//! canonicalizes paths, confines them to configured roots, optionally rejects
21//! symbolic links, and can disable every write operation.
22//!
23//! # Resource bounds
24//!
25//! Reads, writes, search results, terminal output, terminal reads, execution
26//! time, and concurrency are bounded by configuration. File replacement is
27//! performed through a temporary file in the destination directory.
28//!
29//! # Modules
30//!
31//! - [`filesystem`] provides bounded and atomic filesystem operations.
32//! - [`search`] implements parallel filename and text search.
33//! - [`security`] validates paths against the configured access policy.
34//! - [`protocol`] contains the JSON-RPC and MCP wire types.
35//! - [`settings`] loads and validates TOML configuration.
36//! - [`terminal`] manages bounded persistent command sessions.
37//! - [`tree`] generates bounded and paginated directory trees.
38//! - [`patch`] validates and applies unified diff text patches.
39//! - [`cli_format`] generates client configuration snippets and help views.
40//! - [`wizard`] interactive setup wizard for initial configuration.
41#![warn(missing_docs)]
42
43pub mod filesystem;
44pub mod protocol;
45pub mod search;
46pub mod security;
47pub mod settings;
48pub mod terminal;
49
50pub mod patch;
51pub mod tree;
52
53pub mod cli_format;
54pub mod wizard;