✨ Instantly understand and visualize your codebase structure & dependencies! ✨ A TypeScript-based tool for ranking files in your codebase by importance, tracking dependencies, and providing summaries to help understand code structure. This MCP server analyzes your codebase to identify the most important files based on dependency relationships. It generates importance scores (0-10) for each file, t
Add this skill
npx mdskills install admica/filescopemcpComprehensive codebase analysis MCP server with dependency tracking, importance scoring, and visualization
1# FileScopeMCP (Model Context Protocol) Server23**✨ Instantly understand and visualize your codebase structure & dependencies! ✨**45<!-- Add Badges Here (e.g., License, Version, Build Status) -->6[](https://github.com/admica/FileScopeMCP/actions)7[](https://nodejs.org/)8[](https://www.gnu.org/licenses/gpl-3.0)910[](https://archestra.ai/mcp-catalog/admica__filescopemcp)11<!-- Add other badges -->1213A TypeScript-based tool for ranking files in your codebase by importance, tracking dependencies, and providing summaries to help understand code structure.1415## Overview1617This MCP server analyzes your codebase to identify the most important files based on dependency relationships. It generates importance scores (0-10) for each file, tracks bidirectional dependencies, and allows you to add custom summaries for files. All this information is made available to AI tools through Cursor's Model Context Protocol.1819## Features2021🚀 **Supercharge your Code Understanding!** FileScopeMCP provides insights directly to your AI assistant:2223- **🎯 File Importance Analysis**24 - Rank files on a 0-10 scale based on their role in the codebase.25 - Calculate importance using incoming/outgoing dependencies.26 - Instantly pinpoint the most critical files in your project.27 - Smart calculation considers file type, location, and name significance.2829- **🔗 Dependency Tracking**30 - Map bidirectional dependency relationships between files.31 - Identify which files import a given file (dependents).32 - See which files are imported by a given file (dependencies).33 - Distinguish between local and package dependencies.34 - Multi-language support: Python, JavaScript, TypeScript, C/C++, Rust, Lua, Zig, C#, Java.3536- **📊 Visualization**37 - Generate Mermaid diagrams to visualize file relationships.38 - Color-coded visualization based on importance scores.39 - Support for dependency graphs, directory trees, or hybrid views.40 - HTML output with embedded rendering including theme toggle and responsive design.41 - Customize diagram depth, filter by importance, and adjust layout options.4243- **📝 File Summaries**44 - Add human or AI-generated summaries to any file.45 - Retrieve stored summaries to quickly grasp file purpose.46 - Summaries persist across server restarts.4748- **📚 Multiple Project Support**49 - Create and manage multiple file trees for different project areas.50 - Configure separate trees with distinct base directories.51 - Switch between different file trees effortlessly.52 - Cached trees for faster subsequent operations.5354- **💾 Persistent Storage**55 - All data automatically saved to disk in JSON format.56 - Load existing file trees without rescanning the filesystem.57 - Track when file trees were last updated.5859## Installation60611. Clone this repository622. Build the project:6364 The build script will install all node dependencies and generate mcp.json for you.6566 Windows:67 ```bash68 build.bat69 ```7071 Copy the generated mcp.json configuration to your project's `.cursor` directory:7273 ```json74 {75 "mcpServers": {76 "FileScopeMCP": {77 "command": "node",78 "args": ["<build script sets this>/mcp-server.js","--base-dir=C:/Users/admica/my/project/base"],79 "transport": "stdio",80 "disabled": false,81 "alwaysAllow": []82 }83 }84 }85 ```8687 Linux: (Cursor in Windows, but your project is in Linux WSL, then put the MCP in Linux and build)88 ```bash89 build.sh90 ```9192 ```json93 {94 "mcpServers": {95 "FileScopeMCP": {96 "command": "wsl",97 "args": ["-d", "Ubuntu-24.04", "/home/admica/FileScopeMCP/run.sh"],98 "transport": "stdio",99 "disabled": false,100 "alwaysAllow": []101 }102 }103 }104 ```1054. Update the arg path --base-dir to your project's base path.106107## How It Works108109### Dependency Detection110111The tool scans source code for import statements and other language-specific patterns:112- Python: `import` and `from ... import` statements113- JavaScript/TypeScript: `import` statements and `require()` calls114- C/C++: `#include` directives115- Rust: `use` and `mod` statements116- Lua: `require` statements117- Zig: `@import` directives118- C#: `using` directives119- Java: `import` statements120121### Importance Calculation122123Files are assigned importance scores (0-10) based on a weighted formula that considers:124- Number of files that import this file (dependents)125- Number of files this file imports (dependencies)126- File type and extension (with TypeScript/JavaScript files getting higher base scores)127- Location in the project structure (files in `src/` are weighted higher)128- File naming (files like 'index', 'main', 'server', etc. get additional points)129130A file that is central to the codebase (imported by many files) will have a higher score.131132### Diagram Generation133134The system uses a three-phase approach to generate valid Mermaid syntax:1351. Collection Phase: Register all nodes and relationships1362. Node Definition Phase: Generate definitions for all nodes before any references1373. Edge Generation Phase: Create edges between defined nodes138139This ensures all diagrams have valid syntax and render correctly. HTML output includes:140- Responsive design that works on any device141- Light/dark theme toggle with system preference detection142- Client-side Mermaid rendering for optimal performance143- Timestamp of generation144145### Path Normalization146147The system handles various path formats to ensure consistent file identification:148- Windows and Unix path formats149- Absolute and relative paths150- URL-encoded paths151- Cross-platform compatibility152153### File Storage154155All file tree data is stored in JSON files with the following structure:156- Configuration metadata (filename, base directory, last updated timestamp)157- Complete file tree with dependencies, dependents, importance scores, and summaries158159## Technical Details160161- **TypeScript/Node.js**: Built with TypeScript for type safety and modern JavaScript features162- **Model Context Protocol**: Implements the MCP specification for integration with Cursor163- **Mermaid.js**: Uses Mermaid syntax for diagram generation164- **JSON Storage**: Uses simple JSON files for persistence165- **Path Normalization**: Cross-platform path handling to support Windows and Unix166- **Caching**: Implements caching for faster repeated operations167168## Available Tools169170The MCP server exposes the following tools:171172### File Tree Management173174- **list_saved_trees**: List all saved file trees175- **create_file_tree**: Create a new file tree configuration for a specific directory176- **select_file_tree**: Select an existing file tree to work with177- **delete_file_tree**: Delete a file tree configuration178179### File Analysis180181- **list_files**: List all files in the project with their importance rankings182- **get_file_importance**: Get detailed information about a specific file, including dependencies and dependents183- **find_important_files**: Find the most important files in the project based on configurable criteria184- **read_file_content**: Read the content of a specific file185- **recalculate_importance**: Recalculate importance values for all files based on dependencies186187### File Summaries188189- **get_file_summary**: Get the stored summary of a specific file190- **set_file_summary**: Set or update the summary of a specific file191192### File Watching193194- **toggle_file_watching**: Toggle file watching on/off195- **get_file_watching_status**: Get the current status of file watching196- **update_file_watching_config**: Update file watching configuration197198### Diagram Generation199200- **generate_diagram**: Create Mermaid diagrams with customizable options201 - Output formats: Mermaid text (`.mmd`) or HTML with embedded rendering202 - Diagram styles: default, dependency, directory, or hybrid views203 - Filter options: max depth, minimum importance threshold204 - Layout options: direction (TB, BT, LR, RL), node spacing, rank spacing205206## Usage Examples207208The easiest way to get started is to enable this mcp in cursor and tell cursor to figure it out and use it. As soon as the mcp starts, it builds an initial json tree. Tell an LLM to make summaries of all your important files and use the mcp's set_file_summary to add them.209210### Analyzing a Project2112121. Create a file tree for your project:213 ```214 create_file_tree(filename: "my-project.json", baseDirectory: "/path/to/project")215 ```2162172. Find the most important files:218 ```219 find_important_files(limit: 5, minImportance: 5)220 ```2212223. Get detailed information about a specific file:223 ```224 get_file_importance(filepath: "/path/to/project/src/main.ts")225 ```226227### Working with Summaries2282291. Read a file's content to understand it:230 ```231 read_file_content(filepath: "/path/to/project/src/main.ts")232 ```2332342. Add a summary to the file:235 ```236 set_file_summary(filepath: "/path/to/project/src/main.ts", summary: "Main entry point that initializes the application, sets up routing, and starts the server.")237 ```2382393. Retrieve the summary later:240 ```241 get_file_summary(filepath: "/path/to/project/src/main.ts")242 ```243244### Generating Diagrams2452461. Create a basic project structure diagram:247 ```248 generate_diagram(style: "directory", maxDepth: 3, outputPath: "diagrams/project-structure", outputFormat: "mmd")249 ```2502512. Generate an HTML diagram with dependency relationships:252 ```253 generate_diagram(style: "hybrid", maxDepth: 2, minImportance: 5, showDependencies: true, outputPath: "diagrams/important-files", outputFormat: "html")254 ```2552563. Customize the diagram layout:257 ```258 generate_diagram(style: "dependency", layout: { direction: "LR", nodeSpacing: 50, rankSpacing: 70 }, outputPath: "diagrams/dependencies", outputFormat: "html")259 ```260261### Using File Watching2622631. Enable file watching for your project:264 ```265 toggle_file_watching()266 ```2672682. Check the current file watching status:269 ```270 get_file_watching_status()271 ```2722733. Update file watching configuration:274 ```275 update_file_watching_config(config: {276 debounceMs: 500,277 autoRebuildTree: true,278 watchForNewFiles: true,279 watchForDeleted: true,280 watchForChanged: true281 })282 ```283284### Testing285286A testing framework (Vitest) is now included. Initial unit tests cover path normalization, glob-to-regexp conversion, and platform-specific path handling.287288To run tests and check coverage:289290```bash291npm test292npm run coverage293```294295### Recent Improvements296297- Improved exclusions logic, ignoring hidden virtual environments (e.g., `.venv`) and other common unwanted directories. This helps keep dependency graphs clean and relevant.298- Testing framework299- Added more programming languages300301## Future Improvements302303- Add more sophisticated importance calculation algorithms304- Enhance diagram customization options305- Support for exporting diagrams to additional formats306307## License308309This project is licensed under the GNU General Public License v3 (GPL-3.0). See the [LICENSE](LICENSE) file for the full license text.310
Full transparency — inspect the skill content before installing.