File Rank MCP Server

by admica
Verified

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Analyzes C/C++ source files to detect includes and differentiate between system and local headers for dependency tracking and importance ranking.

  • Processes JavaScript files using regex patterns to detect import/require statements for dependency tracking and importance ranking.

  • Supports running the MCP server from WSL Linux environments with compatible configuration files.

File Rank MCP (Model Context Protocol) Server

A TypeScript-based tool for ranking files in your codebase by importance and providing summaries with dependency tracking.

Overview

This tool helps you keep track of which files in your project are most important, giving them a rating between 0 (least important) to 10 (most important). It also tracks file dependencies and provides summaries, helping you understand the codebase structure.

Features

  • Rank files on a scale from 0-10 (10 being most important)
  • Track and visualize file dependencies (which files import which)
  • Real-time file system monitoring for automatic updates
  • Get summaries of files (with placeholder for LLM integration)
  • Query rankings for individual files, directories, or the entire codebase
  • Self-documenting API with discovery endpoints
  • Simple stdio JSON interface

Setup

  1. Clone this repository
  2. Make the build script executable:
    chmod +x build.sh
  3. Run the build script:
    ./build.sh
    This will:
    • Check for Node.js installation
    • Install project dependencies
    • Compile TypeScript code
    • Generate MCP configuration
    • Create a detailed log file in /tmp/file-rank-mcp_*.log
  4. Move the generated mcp.json to your project's .cursor/ directory to use with Cursor AI

Usage

The tool communicates via JSON over stdio using the Model Context Protocol (MCP). It automatically monitors your project directory for changes and updates the file tree accordingly.

Running the Server

node dist/mcp-server.js

Supported Languages

The server automatically detects dependencies in the following languages:

  • Python: import and from ... import statements
  • C/C++: #include directives
  • Rust: use and mod statements
  • Lua: require statements
  • JavaScript/TypeScript: import statements

How It Works

The tool maintains a real-time tree structure of your codebase, stored in file-tree.json. This file is automatically updated whenever changes are detected in your project directory.

Data Structure

The file tree is stored in a JSON structure:

{ "path": "/path/to/directory", "name": "directory_name", "isDirectory": true, "children": [ { "path": "/path/to/file.ts", "name": "file.ts", "isDirectory": false, "dependencies": ["/path/to/dependency.ts"], "importance": 8 } ] }

Dependency Detection

The tool analyzes source code to detect dependencies:

  • Scans file contents for language-specific import patterns
  • Resolves relative imports to absolute paths
  • Verifies that imported files exist
  • Calculates importance based on dependency count

File Importance Calculation

Files are assigned importance scores (0-10) based on:

  • Number of dependencies (files that import this file)
  • Position in the dependency tree
  • File type and location

Technical Stack

  • TypeScript/Node.js
  • Model Context Protocol SDK (v1.7.0)
  • Chokidar for file system monitoring
  • ES2020 target with CommonJS modules

Development

To modify or extend the project:

  1. Make changes to the TypeScript files in the src directory
  2. Run the build script to compile and update configuration:
    ./build.sh
  3. Run the server:
    node dist/mcp-server.js

The build script will:

  • Install any new dependencies
  • Compile TypeScript code
  • Generate updated MCP configuration
  • Create a detailed log file for troubleshooting

Integration with LLMs

The current implementation includes a placeholder for LLM integration. In a production environment, the server could be extended to:

  • Generate file summaries using LLMs
  • Analyze code complexity and maintainability
  • Provide intelligent suggestions for file organization
  • Generate documentation based on code structure

License

This project is licensed under the GNU General Public License v3 (GPL-3.0). See the LICENSE file for the full license text.

-
security - not tested
A
license - permissive license
-
quality - not tested

A tool that helps rank codebase files by importance (1-10 scale), track file dependencies, and provide summaries, all accessible through a simple JSON-based interface.

  1. Overview
    1. Features
      1. Setup
        1. Usage
          1. Running the Server
          2. Supported Languages
        2. How It Works
          1. Data Structure
          2. Dependency Detection
          3. File Importance Calculation
        3. Technical Stack
          1. Development
            1. Integration with LLMs
              1. License