In-memory virtual filesystem for MCP tools organization and export.
[dependencies]
mcp-execution-files = "0.6"Or with cargo-add:
cargo add mcp-execution-filesImportant
Requires Rust 1.89 or later.
use mcp_execution_files::{FileSystem, FilesBuilder};
let fs = FilesBuilder::new()
.add_file("/mcp-tools/manifest.json", "{\"version\": \"1.0\"}")
.add_file("/mcp-tools/createIssue.ts", "export function createIssue() {}")
.build()
.unwrap();
// Read files
let content = fs.read_file("/mcp-tools/manifest.json").unwrap();
// Check existence
assert!(fs.exists("/mcp-tools/createIssue.ts"));use mcp_execution_files::FilesBuilder;
let fs = FilesBuilder::new()
.add_file("/servers/github/createIssue.ts", "// code")
.add_file("/servers/github/updateIssue.ts", "// code")
.add_file("/servers/github/getIssue.ts", "// code")
.build()
.unwrap();
let files = fs.list_dir("/servers/github").unwrap();
assert_eq!(files.len(), 3);use mcp_execution_files::FilesBuilder;
use mcp_execution_codegen::{GeneratedCode, GeneratedFile};
let mut code = GeneratedCode::new();
code.add_file(GeneratedFile {
path: "createIssue.ts".to_string(),
content: "export function createIssue() {}".to_string(),
});
let vfs = FilesBuilder::from_generated_code(code, "/servers/github")
.build()
.unwrap();
assert!(vfs.exists("/servers/github/createIssue.ts"));Tip
Use from_generated_code to seamlessly integrate with mcp-execution-codegen output.
use mcp_execution_files::{FilesBuilder, ExportOptions};
use std::path::Path;
let fs = FilesBuilder::new()
.add_file("/github/createIssue.ts", "// code")
.build()
.unwrap();
let options = ExportOptions::default();
fs.export_to_disk(Path::new("~/.claude/servers"), &options)?;Note
Export validates paths to prevent directory traversal attacks.
- 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
| 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 |
| Operation | Target | Achieved |
|---|---|---|
| VFS export | <10ms | 1.2ms (8.3x faster) |
| Memory (1000 files) | <256MB | ~2MB |
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
Minimum Supported Rust Version: 1.89
MSRV increases are considered minor version bumps.
Licensed under either of Apache License 2.0 or MIT license at your option.