A Model Context Protocol (MCP) server that provides file system context to Large Language Models (LLMs). This server enables LLMs to read, search, and analyze code files with advanced caching and real-time file watching capabilities.
Features
**File Operations**
- Read file and directory contents
- List files with detailed metadata
- Real-time file watching and cache invalidation
- Support for multiple file encodings
- Recursive directory traversal
- File type filtering
The server provides detailed error messages with specific error codes:
`FILE_NOT_FOUND`: File or directory does not exist
`PERMISSION_DENIED`: Access permission issues
`INVALID_PATH`: Invalid file path format
`FILE_TOO_LARGE`: File exceeds size limit
`ENCODING_ERROR`: File encoding issues
`UNKNOWN_ERROR`: Unexpected errors
Configuration
Environment variables for customization:
`MAX_CACHE_SIZE`: Maximum number of cached entries (default: 1000)
`CACHE_TTL`: Cache time-to-live in milliseconds (default: 1 hour)
`MAX_FILE_SIZE`: Maximum file size in bytes for reading
Development
License
MIT
Contributing
Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.
Cross-Platform Path Compatibility
**Note:** As of April 2025, all file and directory path handling in File Context Server has been updated for improved cross-platform compatibility (Windows, macOS, Linux):
All glob patterns use POSIX-style paths (forward slashes) internally, ensuring consistent file matching regardless of OS.
All file system operations (reading, writing, stat, etc.) use normalized absolute paths for reliability.
If you are developing or extending the server, use `path.posix.join` for glob patterns and `path.normalize` for file system access.
This change prevents issues with path separators and file matching on different operating systems.
No changes are required for end users, but developers should follow these conventions when contributing to the project.