MCP File Browser Server
Enables Large Language Models to safely browse and interact with local file systems through secure directory listing, file reading, and content search capabilities. Built with comprehensive security controls and high-performance handling of large directories and files.
README
MCP File Browser Server
A secure, high-performance Model Context Protocol (MCP) server that enables Large Language Models to safely browse and interact with local file systems. Built with security-first architecture and comprehensive access controls.
🚀 Features
Core Capabilities
- 📁 Directory Browsing: List directories with comprehensive metadata (size, permissions, modification date, type)
- 📄 File Reading: Stream large files with encoding detection and size validation
- 🔍 File Search: Search by name, extension, and content patterns
- 🔗 Symbolic Link Support: Intelligent handling of symbolic links with clear metadata marking
- ⚡ High Performance: Handles directories with 10,000+ files in under 2 seconds
Security & Access Control
- 🛡️ Path Validation: Prevents directory traversal attacks with canonical path resolution
- 🔐 Permission-Based Access: Granular permission levels (read-only, read-write, admin)
- 📋 Allowlist/Denylist: Configurable directory access controls
- 📊 Audit Logging: Comprehensive logging of all file access attempts
- 🚫 System Protection: Never exposes sensitive directories (/etc, /root, /home) by default
Performance & Reliability
- 💾 Intelligent Caching: Configurable caching for frequently accessed directories and metadata
- 🌊 Streaming Support: Memory-efficient handling of large files
- ⚙️ Resource Management: Configurable limits for memory usage, file size, and directory depth
- 📈 Monitoring: Health checks and performance metrics
- 🔄 Concurrent Operations: Support for multiple simultaneous LLM clients
📋 Requirements
System Requirements
- Operating System: Linux, macOS, or Windows
- Memory: Minimum 100MB RAM (configurable)
- Storage: Minimal disk space for server and cache
- Permissions: Standard file system access permissions
Dependencies
- MCP Protocol compliance
- File system access capabilities
- Logging and monitoring support
🛠️ Installation
Prerequisites
# Ensure you have the necessary development tools
# (Installation instructions will be added as development progresses)
Quick Start
# Clone the repository
git clone https://github.com/ntufar/mcp.git
cd mcp
# Install dependencies
# (Installation commands will be added)
# Configure the server
# (Configuration instructions will be added)
# Start the server
# (Start commands will be added)
⚙️ Configuration
Basic Configuration
{
"server": {
"name": "mcp-file-browser",
"version": "1.0.0"
},
"security": {
"allowedPaths": ["/home/user/documents", "/home/user/projects"],
"deniedPaths": ["/etc", "/root", "/sys"],
"maxFileSize": "100MB",
"maxDirectoryDepth": 10
},
"performance": {
"cacheSize": "50MB",
"cacheTTL": 300,
"maxConcurrentOperations": 50
}
}
Security Settings
- allowedPaths: Directories the server can access
- deniedPaths: Directories explicitly blocked
- maxFileSize: Maximum file size for operations
- maxDirectoryDepth: Maximum directory traversal depth
🔧 Usage
MCP Protocol Integration
The server exposes the following MCP tools and resources:
Tools
list_directory- List directory contents with metadataread_file- Read file contents with streaming supportsearch_files- Search files by name, extension, or contentget_file_metadata- Retrieve detailed file informationcheck_permissions- Verify file/directory access permissions
Resources
- Directory listings with structured metadata
- File contents with encoding detection
- Search results with relevance scoring
- System health and performance metrics
Example Usage
// List directory contents
const directoryListing = await mcpClient.callTool('list_directory', {
path: '/home/user/projects',
includeHidden: false,
maxDepth: 2
});
// Read file with streaming
const fileContent = await mcpClient.callTool('read_file', {
path: '/home/user/documents/example.txt',
encoding: 'utf-8',
maxSize: '10MB'
});
// Search files
const searchResults = await mcpClient.callTool('search_files', {
query: 'configuration',
searchPath: '/home/user',
fileTypes: ['.json', '.yaml', '.conf']
});
🏗️ Architecture
Core Components
- Security Layer: Path validation, permission checking, audit logging
- File System Interface: Abstraction layer for file operations
- Caching Engine: Intelligent metadata and content caching
- MCP Protocol Handler: Standard MCP tools and resources
- Monitoring System: Health checks and performance metrics
Data Flow
LLM Client → MCP Protocol → Security Validation → File System → Cache → Response
🧪 Testing
Comprehensive Testing Strategy
- Test-Driven Development (TDD): Tests written before implementation for all file system operations
- 90%+ Code Coverage: Mandatory coverage for file system operation modules
- Mock File Systems: Deterministic unit tests using mock file systems
- Real LLM Integration: Testing with actual LLM clients (Claude, GPT-4, Gemini, Qwen, OpenCode)
Test Coverage
- Unit Tests: Individual component testing with mock file systems
- Integration Tests: End-to-end MCP protocol testing
- Security Tests: Path traversal, permission boundary testing, attack prevention
- Performance Tests: Large directory and file handling with specific benchmarks
- Concurrent Tests: Multi-client operation testing
- Contract Tests: API contract validation with OpenAPI specification
- LLM Integration Tests: Real LLM client workflow validation
LLM Client Testing
- Universal Compatibility: Testing across all major LLM platforms
- Workflow Validation: Multi-step file analysis tasks with LLMs
- Error Handling: LLM error recovery and user experience validation
- Performance Under Load: Multiple LLM clients with concurrent operations
- User Experience: Response quality and task completion efficiency
Running Tests
# Run all tests
npm test
# Run specific test suites
npm run test:unit
npm run test:integration
npm run test:security
npm run test:performance
npm run test:contract
npm run test:llm
# Run LLM integration tests
npm run test:llm:claude
npm run test:llm:gpt4
npm run test:llm:gemini
npm run test:llm:qwen
📊 Performance Benchmarks
Directory Operations
- Small directories (< 100 files): < 100ms
- Medium directories (100-1,000 files): < 500ms
- Large directories (1,000-10,000 files): < 2 seconds
- Massive directories (> 10,000 files): < 5 seconds
File Operations
- File metadata retrieval: < 50ms
- Small file reading (< 1MB): < 100ms
- Large file streaming (> 100MB): Streaming with < 10MB memory usage
Resource Usage
- Memory footprint: < 100MB for normal operations
- Concurrent clients: 50+ simultaneous operations
- Cache efficiency: 90%+ hit rate for frequently accessed data
🔒 Security Considerations
Built-in Security Features
- Path Traversal Protection: Canonical path resolution prevents
../attacks - Permission Respect: Never bypasses operating system security
- Audit Trail: Comprehensive logging of all operations
- Resource Limits: Prevents resource exhaustion attacks
- Input Validation: Strict validation of all user inputs
Security Best Practices
- Configure allowlists for production deployments
- Monitor audit logs for suspicious access patterns
- Regular security updates and vulnerability scanning
- Principle of least privilege for file system access
- Encryption at rest for sensitive configuration data
🤝 Contributing
Development Guidelines
We follow strict development principles outlined in our Constitution:
- Security-First Architecture: All changes must enhance security
- Test-Driven Development: TDD mandatory for all file operations
- Performance Standards: Maintain established benchmarks
- MCP Protocol Compliance: Full adherence to MCP standards
Getting Started
- Read the Constitution
- Review the Specification (64 requirements)
- Study the Implementation Tasks (T001-T064)
- Follow the Implementation Plan with TDD approach
- Set up development environment
- Execute tasks in order: Setup → Tests → Implementation → Integration → Polish
- Run comprehensive tests to ensure everything works
- Submit a pull request with security review
Task Execution Strategy
- Testing-First: Complete Phase 3.2 (16 test tasks) before any implementation
- Parallel Execution: 30+ tasks can run simultaneously (marked with [P])
- Constitutional Compliance: Follow security-first, TDD, and performance principles
- LLM Integration: Include real LLM client testing throughout development
Code Quality Requirements
- 90%+ test coverage for file system operations (constitutional requirement)
- Test-Driven Development (TDD) mandatory for all file operations
- LLM integration testing with real LLM clients
- Security-focused code reviews for all file access code
- Performance benchmarks maintained with each release
- Comprehensive documentation for all public APIs
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🆘 Support
Documentation
- Constitution - Project governance and principles
- Specification - Detailed feature requirements (64 requirements)
- Implementation Plan - Comprehensive planning and LLM testing strategy
- Implementation Tasks - 64 detailed implementation tasks (T001-T064)
- Data Model - Complete entity definitions and relationships
- API Contracts - OpenAPI specification and contract tests
- Quickstart Guide - Step-by-step validation scenarios
- API Documentation - MCP tools and resources reference
Getting Help
- Issues: Report bugs and feature requests on GitHub
- Discussions: Ask questions in GitHub Discussions
- Security: Report security issues privately via email
🗺️ Roadmap
Phase 1: Foundation & Planning ✅
- [x] Project constitution and governance principles
- [x] Comprehensive specification (64 requirements)
- [x] Architecture design and data modeling
- [x] API contracts and testing strategy
- [x] LLM integration testing planning
Phase 2: Core Implementation 🚧
- [ ] 64 Implementation Tasks Generated (T001-T064)
- [ ] Testing infrastructure setup (TDD approach)
- [ ] Security layer implementation
- [ ] File system interface development
- [ ] MCP protocol integration
- [ ] Performance optimization
Phase 3: Advanced Features 📋
- [ ] LLM client integration testing
- [ ] Advanced search capabilities
- [ ] Enhanced caching system
- [ ] Comprehensive test suite execution
Phase 4: Enterprise Features 📋
- [ ] Multi-user support
- [ ] Advanced monitoring and analytics
- [ ] Enterprise security features
- [ ] Production deployment
📈 Status
Current Status: Tasks Generated - Ready for Implementation
- Specification: ✅ Complete (v1.0.0) - 64 requirements (16 functional + 48 testing)
- Architecture: ✅ Complete - Comprehensive data model and API contracts
- Testing Strategy: ✅ Complete - TDD approach with LLM integration testing
- Implementation Plan: ✅ Complete - 40-45 tasks with testing-first approach
- Implementation Tasks: ✅ Complete - 64 detailed tasks (T001-T064) generated
- Core Implementation: 🚀 Ready to Begin
- Documentation: 🚧 In Progress
Built with ❤️ by Nicolai Tufar for the MCP ecosystem
Empowering LLMs with secure, efficient file system access while maintaining the highest standards of security and performance.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。