mcp file context server
A Model Context Protocol server that enables LLMs to read, search, and analyze code files with advanced caching and real-time file watching capabilities.
A Model Context Protocol server that enables LLMs to read, search, and analyze code files with advanced caching and real-time file watching capabilities.
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.
File type filtering
Code Analysis
Quality metrics:
Smart Caching
Last read result caching for efficient searches
Advanced Search
To install File Context Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @bsmi021/mcp-file-context-server --client claude
npm install @modelcontextprotocol/file-context-server
npx file-context-server
{
"path": "./src",
"recursive": true,
"includeHidden": false
}
{
"path": "./src/index.ts",
"encoding": "utf8",
"maxSize": 1000000,
"recursive": true,
"fileTypes": ["ts", "js"]
}
{
"pattern": "function.*",
"path": "./src",
"options": {
"recursive": true,
"contextLines": 2,
"fileTypes": ["ts"]
}
}
{
"path": "./src",
"recursive": true,
"metrics": ["complexity", "dependencies", "quality"]
}
{
"detailed": true
}
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 errorsEnvironment 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# Install dependencies
npm install
# Build
npm run build
# Run tests
npm test
# Start in development mode
npm run dev
MIT
Contributions are welcome! Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.
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):
path.posix.join
for glob patterns and path.normalize
for file system access.No changes are required for end users, but developers should follow these conventions when contributing to the project.