FileScopeMCP
The FileScopeMCP server helps understand codebase structure and dependencies through these capabilities:
File Tree Management: Create, select, list, and delete file tree configurations for different projects
Dependency Analysis: Track bidirectional dependencies across multiple languages (Python, JS/TS, C/C++, Rust, Lua, Zig)
Importance Handling: Calculate, recalculate, and manually set file importance scores (0-10) based on dependencies
File Operations: List files with importance rankings, find important files, and read file content
File Summaries: Add, retrieve, and persist human or AI-generated summaries for specific files
Visualization: Generate Mermaid diagrams in various styles (dependency, directory, hybrid) with filtering and layout options
Auto-updates: Toggle file watching to automatically update when files change
Persistence: Store all file tree data including dependencies, importance, and summaries in JSON files
Analyzes C/C++ source files by detecting #include directives to map dependencies and calculate importance scores for files in C/C++ projects.
Analyzes JavaScript files by detecting import statements and require() calls to track dependencies and assign importance scores to files in JavaScript projects.
Analyzes Lua source files by detecting require statements to map dependencies and calculate importance scores for files in Lua projects.
Generates Mermaid diagrams to visualize file relationships with color-coded visualization based on importance scores for dependency graphs or directory trees.
Analyzes Python source files by detecting import and from...import statements to map dependencies and calculate importance scores for files in Python projects.
Analyzes Rust source files by detecting use and mod statements to map dependencies and calculate importance scores for files in Rust projects.
Provides enhanced support for TypeScript projects by analyzing import statements, tracking dependencies, and assigning higher base importance scores to TypeScript files.
Analyzes Zig source files by detecting @import directives to map dependencies and calculate importance scores for files in Zig projects.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@FileScopeMCPshow me the most important files in my project"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
FileScopeMCP
Understand your codebase — ranked, related, summarized, and kept up to date automatically.
FileScopeMCP is a TypeScript MCP server and standalone daemon that ranks every file in your codebase by importance, tracks bidirectional dependencies across 12 languages, detects circular dependency chains, and auto-generates AI summaries, concepts, and change impact assessments — keeping all metadata fresh in the background as your code changes.
What It Does
File importance ranking — 0–10 score per file using a weighted formula: incoming dependents (+3), outgoing dependencies (+2), package dependencies (+1), file type, location, and name significance. Surface your most critical files instantly.
Dependency tracking — bidirectional relationships (who imports a file, what it imports). Covers 12 languages: Python, JavaScript, TypeScript, C/C++, Rust, Lua, Zig, PHP, C#, Java, Go, Ruby.
Circular dependency detection — iterative Tarjan's SCC algorithm finds all cycles in the dependency graph. Query project-wide or per-file.
Autonomous background updates — filesystem watcher (chokidar) handles add/change/delete events. Incremental updates only touch the affected file. Startup integrity sweep heals the database after offline periods. Per-file mtime validation catches changes missed by the watcher.
Semantic change detection — tree-sitter AST diffing for TypeScript/JavaScript classifies changes as
body-only,exports-changed,types-changed, orunknown. LLM-powered diff analysis handles all other languages. Body-only changes skip cascade propagation entirely.Cascade engine — BFS staleness propagation through the dependency graph when exports or types change. Per-field granularity:
summary,concepts, andchange_impactare tracked independently. Depth cap of 10 prevents runaway propagation.LLM broker — standalone process auto-spawned on first MCP connect. Communicates with Ollama (or any OpenAI-compatible endpoint) over a Unix domain socket (
~/.filescope/broker.sock). In-memory priority queue: interactive (tier 1) > cascade (tier 2) > background (tier 3). LLM enabled by default.SQLite storage — all metadata in
.filescope/data.db(WAL mode). Type-safe schema via drizzle-orm. Auto-migrates legacy JSON tree files on first run.Custom exclusion patterns —
.filescopeignorefile (gitignore syntax) plus ~90 built-in patterns covering all major languages and toolchains.
Related MCP server: SourceSage MCP
Quick Start
Prerequisites
Node.js 22+ — download from nodejs.org
Native build tools (usually optional) —
better-sqlite3andtree-sittership prebuilt binaries for most platforms. If prebuilds aren't available,npm installfalls back to compiling from source:Linux:
sudo apt install build-essential python3macOS:
xcode-select --installWindows: Visual Studio Build Tools with C++ workload
Install
Linux / macOS / WSL:
git clone https://github.com/admica/FileScopeMCP.git
cd FileScopeMCP
./build.shWindows:
git clone https://github.com/admica/FileScopeMCP.git
cd FileScopeMCP
build.batBoth scripts install npm dependencies, compile TypeScript to dist/, generate mcp.json for Cursor AI, and register the server with Claude Code (~/.claude.json).
LLM Setup (Optional)
FileScopeMCP uses a custom Ollama model (FileScopeMCP-brain) for generating summaries, concepts, and change impact assessments. Without it, file tracking and dependency analysis still work fully.
See docs/ollama-setup.md for step-by-step guides:
Same machine (Linux/macOS) — run
./setup-llm.shWSL2 + Windows GPU — Ollama on Windows, FileScopeMCP in WSL
Remote / LAN server — Ollama on a different machine
Verify
# Build output exists
ls dist/mcp-server.js
# Registered with Claude Code
claude mcp list
# Start a Claude Code session — FileScopeMCP auto-initializes to your project directory
# Then from the AI assistant:
find_important_files(limit: 5)
status()Gitignore
Add these to your project's .gitignore:
.filescope/
.filescope-daemon.log
mcp-debug.logMCP Client Configuration
Claude Code
Registered automatically by build.sh. To re-register without rebuilding:
./install-mcp-claude.shThe server auto-initializes to the current working directory when a Claude Code session starts. Use set_base_directory to analyze a different directory:
set_base_directory(path: "/path/to/your/project")Cursor AI (WSL — Cursor running on Windows)
Build inside WSL, then copy mcp.json to your project's .cursor/ directory:
{
"mcpServers": {
"FileScopeMCP": {
"command": "wsl",
"args": ["-d", "Ubuntu-24.04", "/home/yourname/FileScopeMCP/run.sh", "--base-dir=${projectRoot}"],
"transport": "stdio",
"disabled": false,
"alwaysAllow": []
}
}
}Cursor AI (Windows native)
{
"mcpServers": {
"FileScopeMCP": {
"command": "node",
"args": ["C:\\FileScopeMCP\\dist\\mcp-server.js", "--base-dir=${projectRoot}"],
"transport": "stdio",
"disabled": false,
"alwaysAllow": []
}
}
}Cursor AI (macOS / Linux native)
{
"mcpServers": {
"FileScopeMCP": {
"command": "node",
"args": ["/path/to/FileScopeMCP/dist/mcp-server.js", "--base-dir=${projectRoot}"],
"transport": "stdio"
}
}
}Daemon Mode
Run FileScopeMCP as a standalone background process (no MCP client required):
node dist/mcp-server.js --daemon --base-dir=/path/to/projectLogs go to .filescope-daemon.log in the project root. A PID file at .filescope/instance.pid prevents concurrent daemons on the same project.
Available Tools
FileScopeMCP exposes 11 tools (consolidated from 22 in v1.1).
Project Setup
Tool | Description |
| Override the base directory to analyze a subdirectory or different project path. Takes |
File Analysis
Tool | Description |
| List all tracked files with their importance rankings. No parameters. |
| Find the most important files. Optional: |
| Full file intel: summary, importance, dependencies, dependents, package dependencies, concepts, change impact, and staleness fields. Takes |
| Manually set a file's summary. Takes |
| Manually set a file's importance score. Takes |
LLM Processing
Tool | Description |
| Queue all files for LLM summarization. Intensive — use when you need full codebase intelligence. Optional: |
| System health: broker connection, queue depth, LLM progress (summarized X/Y, concepts X/Y, pending counts), file watching state, and project info. |
Dependency Analysis
Tool | Description |
| Detect all circular dependency groups in the project's file graph. Returns cycle groups with participant file lists. |
| Get cycle groups containing a specific file. Takes |
Utilities
Tool | Description |
| Exclude a file or glob pattern from the file tree and remove it from the database. Takes |
Configuration
.filescope/config.json
Per-project configuration. Optional — sensible defaults apply when absent. Created automatically when you change settings via MCP tools.
{
"baseDirectory": "/path/to/your/project",
"excludePatterns": [
"docs/generated/**",
"*.csv"
],
"fileWatching": {
"enabled": true,
"ignoreDotFiles": true,
"autoRebuildTree": true,
"maxWatchedDirectories": 1000,
"watchForNewFiles": true,
"watchForDeleted": true,
"watchForChanged": true
},
"llm": {
"enabled": true
},
"version": "1.0.0"
}excludePatterns contains only project-specific additions. The ~90 built-in default patterns (node_modules, .git, dist, build, language artifacts, etc.) are always applied automatically.
The llm block only controls whether the broker connection is active. All LLM settings (model, endpoint, API key) live in ~/.filescope/broker.json.
.filescopeignore
Place a .filescopeignore file in your project root to exclude files using gitignore syntax:
docs/api/
*.csv
*.parquet
tmp/
vendor/Loaded once at startup. Use .filescope/config.json for programmatic patterns set via MCP tools; use .filescopeignore for patterns you want to commit to the repo.
Broker Configuration (~/.filescope/broker.json)
Global LLM settings shared across all projects. If missing, the broker auto-copies broker.default.json from the install directory on first start.
Three templates ship with the project:
Template | When to use |
| Ollama on localhost (default) |
| Ollama on Windows host from WSL2 (uses |
| Ollama on a LAN machine by IP |
Copy the matching template to ~/.filescope/broker.json and edit as needed.
Config fields:
Field | Default | Description |
|
|
|
|
| Model identifier |
| — | API endpoint (required for |
| — | API key (optional; uses env vars if omitted) |
|
| Maximum tokens per LLM call |
|
| Job timeout in milliseconds |
|
| Maximum pending jobs |
Custom LLM Model (Modelfile)
The Modelfile in the repo root defines the FileScopeMCP-brain Ollama model — system prompt, base model (qwen2.5-coder:7b-instruct-q6_K), and tuned parameters (temperature: 0.1, num_ctx: 32768). The system prompt teaches the model all three task types (summary, concepts, change_impact) and enforces output format rules.
To modify: edit Modelfile, then run ollama create FileScopeMCP-brain -f Modelfile. No broker restart needed.
How It Works
Dependency Detection
Import patterns detected per language:
Python —
importandfrom ... importstatementsJavaScript / TypeScript —
importstatements,require()calls, dynamicimport()expressionsC / C++ —
#includedirectivesRust —
useandmodstatementsLua —
requirestatementsZig —
@importdirectivesPHP —
require,require_once,include,include_once,useC# —
usingdirectivesJava —
importstatementsGo —
importstatements withgo.modmodule resolutionRuby —
requireandrequire_relativewith.rbextension probing
Importance Calculation
Scores (0–10) from a weighted formula:
Factor | Max contribution |
Incoming dependents (files that import this file) | +3 |
Outgoing dependencies (files this file imports) | +2 |
Package dependencies imported | +1 |
File type (TS/JS base score; PHP +2; config files like package.json +3) | varies |
Location ( | varies |
Naming ( | varies |
Autonomous Update Pipeline
When a file event fires:
Debounce — events coalesced per
filePath:eventTypekey (default 2 s)Mutex — all mutations serialized through
AsyncMutexSemantic change detection — tree-sitter AST diff (TS/JS) or LLM-powered diff (all other languages) classifies the change
Incremental update — re-parses the changed file, diffs dependency lists, patches reverse-dependency map, recalculates importance
Cascade engine — BFS propagates staleness to transitive dependents if exports/types changed; body-only changes affect only the changed file
LLM broker — picks up stale files and regenerates summaries, concepts, and change impact in priority order
Freshness Validation
Two complementary strategies:
Startup sweep — runs once at initialization. Compares every tracked file against the filesystem to detect adds, deletes, and modifications that occurred while the server was offline.
Per-file mtime check — when you call
get_file_summary, the system compares current mtime against the last recorded value. If changed, the file is immediately flagged stale and queued for re-analysis.
Cycle Detection
Loads all local import edges from SQLite in a single batch query
Runs iterative Tarjan's SCC algorithm on the directed dependency graph
Filters out trivial SCCs (single files with no self-loop)
Returns cycle groups listing all participating files
Storage
All data in .filescope/data.db (SQLite, WAL mode):
files— metadata, staleness flags, summary, concepts, change_impactfile_dependencies— bidirectional relationshipsschema_version— migration versioning
Auto-migration: on first run, any legacy JSON tree files are imported into SQLite automatically.
Directory Structure
Per-repo (inside your project):
.filescope/
config.json # Project config (optional)
data.db # SQLite database
data.db-wal # SQLite write-ahead log
data.db-shm # SQLite shared memory
instance.pid # Daemon PID lock file
.filescope-daemon.log # Daemon log output (project root)
Global (shared across all projects):
~/.filescope/
broker.json # LLM broker config
broker.sock # Unix domain socket (broker IPC)
broker.pid # Broker PID file
broker.log # Broker log output
stats.json # Per-repo token usage statsTroubleshooting
Project not initializing
FileScopeMCP auto-initializes to the current working directory when Claude Code starts. For a different directory, call set_base_directory(path: "/your/project"). For Cursor AI or daemon mode, pass --base-dir=/your/project as a startup argument.
MCP server not appearing in Claude Code
Run
claude mcp listto check registrationIf missing, run
./install-mcp-claude.shCheck
~/.claude.json— it should have aFileScopeMCPentry undermcpServersRestart Claude Code after registration
npm install fails on native modules
better-sqlite3 and tree-sitter include native addons. If prebuilt binaries aren't available:
Linux:
sudo apt install build-essential python3macOS:
xcode-select --installWindows: Install Visual Studio Build Tools with C++ workload
LLM broker not generating metadata
Call
status()— checkbroker.brokerConnectedCheck
~/.filescope/broker.logfor connection errorsIf using Ollama:
curl http://localhost:11434/v1/modelsCheck
~/.filescope/broker.json—baseURLandmodelmust be correctRun
./setup-llm.sh --statusto verify Ollama and model installation
For WSL + Windows issues, see docs/ollama-setup.md.
Stale PID file ("daemon already running" error)
cat /path/to/project/.filescope/instance.pid
kill -0 <PID> 2>/dev/null && echo "Running" || echo "Stale"
# If stale:
rm /path/to/project/.filescope/instance.pidDatabase corruption
rm /path/to/project/.filescope/data.db
rm -f /path/to/project/.filescope/data.db-wal
rm -f /path/to/project/.filescope/data.db-shmThe database is rebuilt from scratch on next startup.
Log file locations
File | When active | Location |
| Always (broker process) | Global directory |
| Daemon mode | Project root |
| MCP server mode | Global directory ( |
License
Copyright (c) 2026 admica. All rights reserved. See the LICENSE file for details.
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/admica/FileScopeMCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server