Skip to content

Architecture

MCP Filesystem Ultra is built with a modular, high-performance architecture designed for maximum efficiency and reliability.

The central UltraFastEngine struct coordinates all operations:

  • Worker pool: Goroutine management with ants/v2
  • Operation semaphore: Concurrency control
  • Metrics tracking: Real-time performance monitoring
  • Cache management: Intelligent caching layer

3-tier caching architecture:

  • BigCache: File content (O(1) operations)
  • go-cache: Directory listings
  • go-cache: Metadata (file info, stats)

Hit rates: 98.9% in production

  • RenameFile: Atomic rename with validation
  • SoftDeleteFile: Safe deletion to filesdelete/
  • CopyFile: Recursive copy with permission preservation
  • MoveFile: Atomic move operations
  • GetFileInfo: Detailed file metadata
  • EditFile: Intelligent multi-line search and replace
  • MultiEdit: Batch editing with rollback
  • Backup system: Automatic backups before modifications
  • Risk assessment: 4-level risk evaluation (LOW/MEDIUM/HIGH/CRITICAL)
  • Safety hooks: Pre/post edit validation

Streaming Operations (core/streaming_operations.go)

Section titled “Streaming Operations (core/streaming_operations.go)”
  • StreamingWriteFile: Chunk-based writing for large files
  • ChunkedReadFile: Memory-efficient reading
  • SmartEditFile: Edit files >1MB without loading into memory

Search Operations (core/search_operations.go)

Section titled “Search Operations (core/search_operations.go)”
  • SmartSearch: Filename and content search
  • AdvancedTextSearch: Regex search with context

Claude Optimizer (core/claude_optimizer.go)

Section titled “Claude Optimizer (core/claude_optimizer.go)”

Auto-optimization for Claude Desktop:

  • File size detection
  • Strategy selection (direct vs streaming)
  • Progress reporting
  • Error recovery
┌─────────────┐
│ Claude │
│ Desktop │
└──────┬──────┘
│ MCP Protocol
┌─────────────┐
│ main.go │ ← Tool registrations (16 tools)
│ MCP Server │
└──────┬──────┘
┌─────────────┐
│ Engine │ ← Central coordinator
│ (core) │
└──────┬──────┘
├─────► Cache ────► BigCache
│ go-cache
├─────► File Ops ──► OS Filesystem
├─────► Search ────► Walker + Matcher
└─────► Backup ────► Backup Manager
type UltraFastEngine struct {
pool *ants.Pool // Goroutine pool
operationSem chan struct{} // Semaphore
}

Reuses goroutines for better performance and lower GC pressure.

// 3-tier cache hierarchy
fileCache *bigcache.BigCache // Hot path
dirCache *cache.Cache // Warm path
metaCache *cache.Cache // Cold path

Auto-selects optimal strategy based on file size:

  • < 50KB: Direct I/O
  • 50KB - 500KB: Buffered I/O
  • > 500KB: Streaming

File watcher invalidates cache on external changes:

watcher *fsnotify.Watcher
  • Max concurrent ops: 2x CPU cores (default)
  • Configurable via --parallel-ops
  • Channel-based semaphore
  • Cache size: 100MB - 500MB
  • LRU eviction
  • Auto-invalidation on modifications
  • 98.9% hit rate
  • Large files use mmap when available
  • Fallback to buffered I/O on Windows
  • Zero-copy for read operations
  • Chunk size: 64KB - 1MB (adaptive)
  • Progress reporting every 5%
  • Backpressure handling
if len(e.config.AllowedPaths) > 0 {
if !e.isPathAllowed(path) {
return PathError{Op: op, Path: path, Err: ErrAccessDenied}
}
}
resolvedPath, err := filepath.EvalSymlinks(path)
// Prevents symlink traversal attacks
  • Unique IDs with crypto/rand
  • Sanitized paths (no .., /, \)
  • Restricted permissions (0600)
PackagePurposeVersion
github.com/mark3labs/mcp-goMCP SDKv0.43.2
github.com/allegro/bigcache/v3File cachev3.1.0
github.com/patrickmn/go-cacheDir/meta cachev2.1.0
github.com/panjf2000/ants/v2Worker poolv2.11.5
github.com/fsnotify/fsnotifyFile watchingv1.9.0

Custom error types in core/errors.go:

  • PathError: File path issues
  • ValidationError: Input validation
  • CacheError: Cache operations
  • EditError: Edit operations
  • ContextError: Context issues

All errors wrapped with context using fmt.Errorf("op: %w", err).

Loaded from CLI flags in main.go:

type Config struct {
AllowedPaths []string
CacheSize int64
ParallelOps int
CompactMode bool
// ... 20+ more options
}

Real-time metrics via server_info({ action: "stats" }) tool:

  • Operations per second
  • Cache hit rate
  • Average response time
  • Memory usage
  • Per-operation counters