Local Filesystem MCP Server
Enables AI assistants to securely browse, search, inspect, and understand local project files through Model Context Protocol tools.
README
🚀 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
git clone https://github.com/<your-username>/local-filesystem-mcp.git
cd local-filesystem-mcp
Create a virtual environment
python -m venv .venv
Activate it
Windows
.venv\Scripts\activate
Linux / macOS
source .venv/bin/activate
Install dependencies
pip install -r requirements.txt
▶ Running the Server
Simply run
python server.py
The default server starts on
http://localhost:8000/mcp
using the Streamable HTTP transport.
🧪 Testing with MCP Inspector
Launch the inspector
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
python server.py
Expose port 8000
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
{
"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
{
"paths":[
"server.py",
"filesystem.py",
"README.md"
]
}
Useful for reducing multiple MCP calls.
📜 read_lines_tool
Reads only selected lines.
Example
{
"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! 🚀
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。