Local Filesystem MCP Server
by saravanarjun
README.md
# ๐ Local Filesystem MCP Server
> A production-ready **Model Context Protocol (MCP)** server that allows AI assistants such as ChatGPT, Claude, Cursor, Perplexity, VS Code, and other MCP-compatible clients to securely browse, search, inspect, and understand local projects.




---
# ๐ Overview
Large Language Models perform significantly better when they have structured access to a project's source code instead of relying on manually copied snippets.
This project exposes your local filesystem through the **Model Context Protocol (MCP)** using **FastMCP** and **Streamable HTTP**, enabling AI assistants to:
- Browse project directories
- Read source code
- Search files
- Search text across projects
- Build project context
- Generate project statistics
- Locate definitions
- Find references
- Read multiple files simultaneously
- Produce project outlines
Instead of uploading your project manually, the AI can explore it through dedicated MCP tools.
---
# โจ Features
โ
List directories
โ
Read files
โ
Read multiple files
โ
Read selected line ranges
โ
Read entire projects
โ
Build project context
โ
Generate project tree
โ
Search filenames
โ
Search text inside files
โ
Generate project statistics
โ
Extract code outline
โ
Locate symbol definitions
โ
Find symbol references
โ
Fast recursive traversal
โ
Ignore build folders automatically
โ
UTF-8 safe reading
โ
Streamable HTTP transport
โ
Works with public tunnels (ngrok / Cloudflare)
---
# ๐ Architecture
```
+----------------------+
| AI Client |
| ChatGPT |
| Claude |
| Cursor |
| VS Code |
| Perplexity |
+----------+-----------+
|
| MCP
|
v
+----------------------+
| FastMCP Server |
| server.py |
+----------+-----------+
|
|
+------------------------------+
| |
v v
Filesystem Tool Layer Security Layer
|
v
+----------------------+
| Local File System |
+----------------------+
```
The AI client communicates with the MCP server using **Streamable HTTP**, and each tool performs a specific filesystem operation.
---
# ๐ Project Structure
```
MCP_PROJECT/
โโโ logs/
โ
โโโ tools/
โ โโโ code_outline.py
โ โโโ file_tree.py
โ โโโ find_references.py
โ โโโ list_directory.py
โ โโโ locate_definition.py
โ โโโ metadata.py
โ โโโ project_context.py
โ โโโ project_statistics.py
โ โโโ read_directory.py
โ โโโ read_files.py
โ โโโ read_lines.py
โ โโโ read_multiple_files.py
โ โโโ search_files.py
โ
โโโ config.py
โโโ filesystem.py
โโโ security.py
โโโ server.py
โโโ requirements.txt
โโโ README.md
```
---
# ๐ Installation
Clone the repository
```bash
git clone https://github.com/<your-username>/local-filesystem-mcp.git
cd local-filesystem-mcp
```
Create a virtual environment
```bash
python -m venv .venv
```
Activate it
Windows
```powershell
.venv\Scripts\activate
```
Linux / macOS
```bash
source .venv/bin/activate
```
Install dependencies
```bash
pip install -r requirements.txt
```
---
# โถ Running the Server
Simply run
```bash
python server.py
```
The default server starts on
```
http://localhost:8000/mcp
```
using the **Streamable HTTP** transport.
---
# ๐งช Testing with MCP Inspector
Launch the inspector
```bash
mcp dev server.py
```
Open
```
http://localhost:6274
```
Use
```
Transport
Streamable HTTP
```
URL
```
http://localhost:8000/mcp
```
Press **Connect**.
If successful, all registered tools will appear automatically.
---
# ๐ Exposing the Server Publicly
Although the server runs locally, it can be securely exposed over the internet using tunneling services.
Supported options include:
- ngrok
- Cloudflare Tunnel
- Tailscale Funnel
- Reverse Proxy (Nginx/Caddy)
---
## Using ngrok
Start your MCP server
```bash
python server.py
```
Expose port 8000
```bash
ngrok http 8000
```
Example output
```
Forwarding
https://abcd-1234.ngrok-free.app
โ
http://localhost:8000
```
Your public MCP endpoint becomes
```
https://abcd-1234.ngrok-free.app/mcp
```
This endpoint can now be added to any MCP-compatible client.
---
# ๐ง Available Tools
The server exposes multiple MCP tools for filesystem exploration and project understanding.
---
## ๐ list_directory
Lists files and folders inside a directory.
### Parameters
| Name | Type | Description |
|------|------|-------------|
| path | string | Directory path |
Example
```json
{
"path":"D:/Projects"
}
```
Returns
- folders
- files
- relative paths
---
## ๐ read_file_tool
Reads an entire text file.
### Parameters
| Name | Type |
|------|------|
| path | string |
Returns
```
Complete file contents
```
---
## ๐ read_multiple_files
Reads multiple files in one request.
Example
```json
{
"paths":[
"server.py",
"filesystem.py",
"README.md"
]
}
```
Useful for reducing multiple MCP calls.
---
## ๐ read_lines_tool
Reads only selected lines.
Example
```json
{
"path":"server.py",
"start":100,
"end":140
}
```
Ideal for debugging specific code sections.
---
## ๐ read_directory
Recursively scans an entire directory and returns supported source files.
Automatically ignores
- node_modules
- build
- dist
- venv
- __pycache__
- .git
Supported languages include
- Python
- JavaScript
- TypeScript
- Java
- C/C++
- C#
- Go
- Rust
- HTML
- CSS
- SQL
- JSON
- YAML
- XML
- Markdown
---
## ๐ณ file_tree
Generates a visual directory tree.
Example
```
project/
โโโ server.py
โโโ requirements.txt
โโโ tools
โ โโโ read_file.py
โ โโโ metadata.py
โ โโโ project_context.py
โโโ frontend
```
Useful before exploring a large repository.
---
## ๐ search_files
Searches filenames recursively.
Example
```
invoice
```
Returns
```
invoice.py
invoice_parser.py
invoice_service.py
```
---
## ๐ search_text
Searches text inside source code.
Example
```
FastMCP
```
Returns
```
server.py : line 18
filesystem.py : line 62
config.py : line 11
```
---
## ๐ง project_context
Builds an optimized context for Large Language Models.
Priority files
- README.md
- package.json
- requirements.txt
- pyproject.toml
- Dockerfile
- .gitignore
are loaded first.
Then the remaining source code is loaded.
This dramatically improves repository understanding.
---
## ๐ project_statistics
Returns project metrics.
Includes
- total files
- source files
- folders
- languages
- lines of code
- largest files
Useful for repository analysis.
---
## ๐ code_outline
Extracts
- classes
- functions
- methods
without returning the full file.
Ideal for navigating large source files.
---
## ๐ฏ locate_definition
Locates where a function or class is defined.
Example
```
search
โ
search_text()
```
Returns
```
filesystem.py
Line 281
```
---
## ๐ find_references
Finds every reference to a symbol.
Example
```
project_context
```
Returns
```
server.py
tools/project_context.py
README.md
```
Excellent for code navigation.
---
# ๐ก Typical AI Workflow
Rather than immediately reading every source file, an AI assistant should follow this workflow.
```
file_tree()
โ
project_statistics()
โ
project_context()
โ
search_files()
โ
read_file()
โ
read_lines()
โ
find_references()
โ
locate_definition()
```
This minimizes unnecessary data transfer while maximizing repository understanding.
---
# ๐ Security
The server is designed to expose only the directories you explicitly request.
Additional safeguards include
- UTF-8 safe reading
- ignored system folders
- ignored virtual environments
- ignored build artifacts
- configurable transport security
- optional DNS rebinding protection
- Streamable HTTP transport
For production deployments, enable DNS rebinding protection and configure allowed hosts appropriately.
---
# โ Configuration
Default configuration
| Setting | Value |
|----------|--------|
| Host | 0.0.0.0 |
| Port | 8000 |
| Endpoint | /mcp |
| Transport | Streamable HTTP |
These values can be customized in `server.py`.
---
# ๐ฃ Roadmap
Planned improvements include
- Git integration
- Symbol indexing
- AST-based code navigation
- Dependency graph generation
- Call graph visualization
- Semantic code search
- Repository summarization
- Incremental indexing
- Embedding support
- Vector search
- Workspace caching
---
# ๐ค Contributing
Contributions are welcome.
You can contribute by
- Reporting bugs
- Suggesting features
- Improving documentation
- Optimizing filesystem traversal
- Adding new MCP tools
- Improving cross-platform compatibility
Please read **CONTRIBUTING.md** before submitting pull requests.
---
# ๐ License
This project is licensed under the MIT License.
See the **LICENSE** file for details.
---
# โญ Support
If you find this project useful, consider giving it a โญ on GitHub.
It helps others discover the project and motivates future development.
---
# ๐จโ๐ป Author
Developed as part of an internship project to provide secure, extensible, and AI-friendly access to local filesystems through the **Model Context Protocol (MCP)**.
Happy Coding! ๐This server cannot be deployed
Maintenance
ActivityInactive
ResponsivenessNo issues