LocalFiles MCP Server

LocalFiles MCP Server

Provides secure access to local files from specified directories. Enables listing files, reading contents, and configurable file size and extension filtering.

Category
Visit Server

README

LocalFiles MCP Server

A Model Context Protocol (MCP) server that provides secure access to local files from specified directories.

Features

  • List files in configured directories
  • Read file contents (text and binary)
  • File size and extension filtering
  • Secure path validation
  • Configuration via .env file or environment variables

Configuration

Method 1: .env file (Recommended)

Create a .env file in the same directory as app.py:

# Comma-separated list of allowed directories
ALLOWED_DIRECTORIES=/home/user/documents,/home/user/projects,/path/to/your/files

# Maximum file size in bytes (default: 10MB)
MAX_FILE_SIZE=10485760

# Allowed file extensions (comma-separated)
ALLOWED_EXTENSIONS=.txt,.md,.py,.js,.json,.yaml,.yml,.csv,.xml,.html,.css

Method 2: Environment Variables

Set environment variables directly:

export ALLOWED_DIRECTORIES="/home/user/documents,/home/user/projects"
export MAX_FILE_SIZE=10485760
export ALLOWED_EXTENSIONS=".txt,.md,.py,.js,.json,.yaml,.yml,.csv,.xml,.html,.css"

Usage

Start the server

python app.py

Available Tools

  1. lf_list_files - List files in allowed directories
  2. lf_read_file - Read contents of a specific file
  3. lf_get_config - Get current server configuration

Security

  • Only files within configured ALLOWED_DIRECTORIES can be accessed
  • File size limits prevent reading overly large files
  • File extension filtering restricts access to specified file types
  • All paths are resolved and validated to prevent directory traversal attacks

Troubleshooting

"No allowed directories configured" error

This error occurs when:

  1. No .env file exists - Create a .env file with ALLOWED_DIRECTORIES setting
  2. Empty ALLOWED_DIRECTORIES - Ensure the value is not empty
  3. Wrong working directory - The server looks for .env in the script directory first, then current directory
  4. Environment variables not set - If not using .env, ensure environment variables are properly set

Debug configuration

Use the lf_get_config tool to check what configuration the server is actually using:

# This will show the current configuration
lf_get_config()

Example .env file

# Example configuration for a development environment
ALLOWED_DIRECTORIES=/home/alice/projects,/home/alice/documents,/tmp/safe-files
MAX_FILE_SIZE=52428800
ALLOWED_EXTENSIONS=.txt,.md,.py,.js,.json,.yaml,.yml,.csv,.xml,.html,.css,.log

Requirements

  • Python 3.7+
  • fastmcp library
  • pathlib (built-in)

Installation

pip install fastmcp

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured