LocalFiles MCP Server
Provides secure access to local files from specified directories. Enables listing files, reading contents, and configurable file size and extension filtering.
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
- lf_list_files - List files in allowed directories
- lf_read_file - Read contents of a specific file
- lf_get_config - Get current server configuration
Security
- Only files within configured
ALLOWED_DIRECTORIEScan 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:
- No .env file exists - Create a
.envfile withALLOWED_DIRECTORIESsetting - Empty ALLOWED_DIRECTORIES - Ensure the value is not empty
- Wrong working directory - The server looks for
.envin the script directory first, then current directory - 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
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
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.
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.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
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.
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.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
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.