File Context Server
Mirror of
MCP-Mirror
README
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
npm install @modelcontextprotocol/file-context-server
Usage
Starting the Server
npx file-context-server
Available Tools
-
list_context_files
- Lists files in a directory with detailed metadata
{ "path": "./src", "recursive": true, "includeHidden": false }
-
read_context
- Reads file or directory contents with metadata
{ "path": "./src/index.ts", "encoding": "utf8", "maxSize": 1000000, "recursive": true, "fileTypes": ["ts", "js"] }
-
search_context
- Searches for patterns in files with context
{ "pattern": "function.*", "path": "./src", "options": { "recursive": true, "contextLines": 2, "fileTypes": ["ts"] } }
-
analyze_code
- Analyzes code files for quality metrics
{ "path": "./src", "recursive": true, "metrics": ["complexity", "dependencies", "quality"] }
-
cache_stats
- Gets cache statistics and performance metrics
{ "detailed": true }
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
# Install dependencies
npm install
# Build
npm run build
# Run tests
npm test
# Start in development mode
npm run dev
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.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
MCP Package Docs Server
Facilitates LLMs to efficiently access and fetch structured documentation for packages in Go, Python, and NPM, enhancing software development with multi-language support and performance optimization.
Claude Code MCP
An implementation of Claude Code as a Model Context Protocol server that enables using Claude's software engineering capabilities (code generation, editing, reviewing, and file operations) through the standardized MCP interface.
@kazuph/mcp-taskmanager
Model Context Protocol server for Task Management. This allows Claude Desktop (or any MCP client) to manage and execute tasks in a queue-based system.
Linear MCP Server
Enables interaction with Linear's API for managing issues, teams, and projects programmatically through the Model Context Protocol.
mermaid-mcp-server
A Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.
Jira-Context-MCP
MCP server to provide Jira Tickets information to AI coding agents like Cursor

Linear MCP Server
A Model Context Protocol server that integrates with Linear's issue tracking system, allowing LLMs to create, update, search, and comment on Linear issues through natural language interactions.

Sequential Thinking MCP Server
This server facilitates structured problem-solving by breaking down complex issues into sequential steps, supporting revisions, and enabling multiple solution paths through full MCP integration.