Integrations
Enables installation of the MCP server via npm, providing access to NPM package management for installing and running the file context server.
File Context Server
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
- Code Analysis
- Cyclomatic complexity calculation
- Dependency extraction
- Comment analysis
- Quality metrics:
- Duplicate lines detection
- Long lines detection (>100 characters)
- Complex function identification
- Line counts (total, non-empty, comments)
- Smart Caching
- LRU (Least Recently Used) caching strategy
- Automatic cache invalidation on file changes
- Size-aware caching with configurable limits
- Cache statistics and performance metrics
- Last read result caching for efficient searches
- Advanced Search
- Regex pattern matching
- Context-aware results with configurable surrounding lines
- File type filtering
- Multi-pattern search support
- Cached result searching
- Exclusion patterns
Installation
Installing via Smithery
To install File Context Server for Claude Desktop automatically via Smithery:
Manual Installation
Usage
Starting the Server
Available Tools
- list_context_files
- Lists files in a directory with detailed metadata
Copy - read_context
- Reads file or directory contents with metadata
Copy - search_context
- Searches for patterns in files with context
Copy - analyze_code
- Analyzes code files for quality metrics
Copy - cache_stats
- Gets cache statistics and performance metrics
Copy
Error Handling
The server provides detailed error messages with specific error codes:
FILE_NOT_FOUND
: File or directory does not existPERMISSION_DENIED
: Access permission issuesINVALID_PATH
: Invalid file path formatFILE_TOO_LARGE
: File exceeds size limitENCODING_ERROR
: File encoding issuesUNKNOWN_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 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 andpath.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.
This server cannot be installed
local-only server
The server can only run on the client's local machine because it depends on local resources.
A Model Context Protocol server that enables LLMs to read, search, and analyze code files with advanced caching and real-time file watching capabilities.
- Features
- Installation
- Usage
- Error Handling
- Configuration
- Development
- License
- Contributing
- Cross-Platform Path Compatibility
Related Resources
Related MCP Servers
- -securityAlicense-qualityA Model Context Protocol server that extracts and analyzes Python code structures, focusing on import/export relationships between files to help LLMs understand code context.Last updated -2PythonMIT License
- -securityFlicense-qualityA Model Context Protocol server that enables LLMs to extract and use content from unstructured documents across a wide variety of file formats.Last updated -2Python
- -securityFlicense-qualityA Model Context Protocol server that connects LLMs to the Compiler Explorer API, enabling them to compile code, explore compiler features, and analyze optimizations across different compilers and languages.Last updated -Python
- -securityAlicense-qualityA Model Context Protocol (MCP) server designed to easily dump your codebase context into Large Language Models (LLMs).Last updated -0JavaScriptApache 2.0