File Context Server logo

File Context Server

by MCP-Mirror

The File Context Server is a Model Context Protocol (MCP) server designed to provide file system context to Large Language Models (LLMs). It enables LLMs to effectively read, search, and analyze code files using advanced caching and real-time file watching capabilities.

View on GitHub

Last updated: N/A

What is File Context Server?

The File Context Server acts as a bridge between LLMs and the file system, allowing LLMs to access, process, and understand code files. It leverages MCP to provide a structured interface for LLMs to interact with file data and code analysis results.

How to use File Context Server?

Install the server using npm: npm install @modelcontextprotocol/file-context-server. Start the server using npx file-context-server. Use available tools like list_context_files, read_context, search_context, analyze_code, and cache_stats by sending JSON requests to the server.

Key features of File Context Server

  • Real-time file watching and cache invalidation

  • Advanced Search with Regex and Context-aware Results

  • Code Analysis for Cyclomatic Complexity, Dependencies, and Quality Metrics

  • Smart Caching with LRU strategy

  • Detailed error handling

Use cases of File Context Server

  • Enabling LLMs to assist in code debugging and error detection

  • Providing LLMs with context for code completion and suggestion

  • Facilitating LLMs to perform code review and quality assessment

  • Allow machine learning models to understand the codebase for training intelligent agents for software development

FAQ from File Context Server

How do I configure the cache size?

You can configure the maximum cache size by setting the MAX_CACHE_SIZE environment variable.

How do I configure how long the cache should last?

You can configure the cache time-to-live by setting the CACHE_TTL environment variable in milliseconds.

What error codes does the server return?

The server provides error messages with codes such as FILE_NOT_FOUND, PERMISSION_DENIED, INVALID_PATH, FILE_TOO_LARGE, ENCODING_ERROR, and UNKNOWN_ERROR.

Does the server support different file encodings?

Yes, the server supports multiple file encodings, allowing you to specify the encoding when reading files.

How do I contribute to the project?

Contributions are welcome! Please read the Contributing Guide for details on our code of conduct and the process for submitting pull requests.