Skip to main content
Glama
saravanarjun

Local Filesystem MCP Server

by saravanarjun

๐Ÿš€ 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.

Python MCP FastMCP License


๐Ÿ“– 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.


Related MCP server: folder-mcp

๐Ÿ“ 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! ๐Ÿš€

A
license - permissive license
-
quality - not tested
C
maintenance

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/saravanarjun/local-folder-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server