home / mcp / 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.
Configuration
View docs{
"mcpServers": {
"bsmi021-mcp-file-context-server": {
"command": "npx",
"args": [
"file-context-server"
],
"env": {
"CACHE_TTL": "3600000",
"MAX_FILE_SIZE": "1048576",
"MAX_CACHE_SIZE": "1000"
}
}
}
}File Context Server provides a focused MCP that lets large language models access and analyze code bases by reading files, searching content, and computing quality metrics. It uses smart caching and real-time file watching to keep results fresh, making it easier to build code-aware AI assistants and tooling.
You connect to File Context Server through an MCP client to request file listings, read file content with metadata, search patterns with contextual lines, analyze code for quality metrics, and inspect cache statistics. Use these capabilities to help LLMs read and reason about code, understand project structure, locate definitions, and detect code quality issues across your repository.
In practice, run the server locally and point your MCP client at its endpoint. Start by listing files to understand the project layout, then read individual files to gather encoding and size details. Use search to locate function patterns or dependencies, and invoke analyze_code to surface complexity, dependencies, and quality signals. Monitor cache_stats to tune performance.
Prerequisites: ensure you have Node.js and npm installed on your system. Node.js version 14 or newer is typically suitable for MCP servers.
Option 1: Install for use with an MCP client via a quick one-liner using a package runner.
npx -y @smithery/cli install @bsmi021/mcp-file-context-server --client claudeOption 2: Install the server package locally for development or customization.
npm install @modelcontextprotocol/file-context-serverConfiguration and runtime details are available to customize performance and behavior. You can adjust cache size and TTL, enable different file size limits, and control how the server watches for real-time changes. The server exposes a set of environment variables for these options, including MAX_CACHE_SIZE, CACHE_TTL, and MAX_FILE_SIZE. Use these to tailor caching and file-reading behavior to your workload.
Starting the server locally is straightforward after installation. Use the provided command to launch and then connect your MCP client to the running process.
Lists files in a directory with detailed metadata
Reads file or directory contents with metadata
Searches for patterns in files with context and configurable surrounding lines
Analyzes code files for quality metrics including complexity, dependencies, and quality signals
Provides cache statistics and performance metrics