mcp-execution-files
In-memory virtual filesystem for MCP tools organization and export.
Installation
[]
= "0.6"
Or with cargo-add:
[!IMPORTANT] Requires Rust 1.89 or later.
Usage
Basic Usage
use ;
let fs = new
.add_file
.add_file
.build
.unwrap;
// Read files
let content = fs.read_file.unwrap;
// Check existence
assert!;
Directory Operations
use FilesBuilder;
let fs = new
.add_file
.add_file
.add_file
.build
.unwrap;
let files = fs.list_dir.unwrap;
assert_eq!;
Integration with Code Generation
use FilesBuilder;
use ;
let mut code = new;
code.add_file;
let vfs = from_generated_code
.build
.unwrap;
assert!;
[!TIP] Use
from_generated_codeto seamlessly integrate withmcp-execution-codegenoutput.
Export to Disk
use ;
use Path;
let fs = new
.add_file
.build
.unwrap;
let options = default;
fs.export_to_disk?;
[!NOTE] Export validates paths to prevent directory traversal attacks.
Features
- In-Memory Storage: Fast access without disk I/O during generation
- Builder Pattern: Fluent API for VFS construction
- Strong Types: Type-safe paths and error handling
- Disk Export: Write VFS contents to filesystem
- Thread-Safe: All types are
Send + Sync
Types Reference
| Type | Description |
|---|---|
FileSystem |
In-memory virtual filesystem |
FilesBuilder |
Builder for constructing FileSystem |
FilePath |
Validated file path (newtype) |
FileEntry |
File entry with path and content |
ExportOptions |
Options for disk export |
FilesError |
Error type for file operations |
Performance
| Operation | Target | Achieved |
|---|---|---|
| VFS export | <10ms | 1.2ms (8.3x faster) |
| Memory (1000 files) | <256MB | ~2MB |
Related Crates
This crate is part of the mcp-execution workspace:
mcp-execution-core- Foundation types used by this cratemcp-execution-codegen- Generates code that this crate organizes
MSRV Policy
Minimum Supported Rust Version: 1.89
MSRV increases are considered minor version bumps.
License
Licensed under either of Apache License 2.0 or MIT license at your option.