FS-MCP Server
Uses python-dotenv for environment management, allowing users to configure server settings through environment variables for security, encoding, and AI embeddings.
Leverages LangChain for AI integration, vector search, and semantic understanding capabilities to enable intelligent document search across multiple file formats.
Automatically converts various document formats to Markdown for consistent representation and includes support for reading and processing Markdown files.
Uses OpenAI's embedding service for generating vector representations of documents, enabling semantic search across files with configurable API endpoints.
Requires Python 3.12+ as the runtime environment, with specific installation instructions for setting up the server with Python dependencies.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@FS-MCP Serversearch for authentication logic in Python files"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
FS-MCP: Universal File Reader & Intelligent Search MCP Server
A powerful MCP (Model Context Protocol) server that provides intelligent file reading and semantic search capabilities
English
๐ Features
๐ง Intelligent Text Detection: Automatically identifies text files without relying on file extensions
๐ Multi-Format Support: Handles text files and document formats (Word, Excel, PDF, etc.)
๐ Security First: Restricted access to configured safe directories only
๐ Range Reading: Supports reading specific line ranges for large files
๐ Document Conversion: Automatic conversion of documents to Markdown with caching
๐ Vector Search: Semantic search powered by AI embeddings
โก High Performance: Batch processing and intelligent caching support
๐ Multi-language: Supports both English and Chinese content
๐ Table of Contents
๐ Quick Start
1. Clone and Install
git clone https://github.com/yourusername/fs-mcp.git
cd fs-mcpUsing uv (Recommended):
uv syncUsing pip:
pip install -r requirements.txt # If you have a requirements.txt
# OR install directly
pip install fastmcp>=2.0.0 langchain>=0.3.0 python-dotenv>=1.1.02. Environment Configuration
Create a .env file in the project root:
# Security Settings
SAFE_DIRECTORY=. # Directory restriction (required)
MAX_FILE_SIZE_MB=100 # File size limit in MB
# Encoding Settings
DEFAULT_ENCODING=utf-8
# AI Embeddings Configuration (for vector search)
OPENAI_EMBEDDINGS_API_KEY=your-api-key
OPENAI_EMBEDDINGS_BASE_URL=http://your-embedding-service/v1
EMBEDDING_MODEL_NAME=BAAI/bge-m3 # Or your preferred model
EMBEDDING_CHUNK_SIZE=10003. Start the Server
python main.pyThe server will start on http://localhost:3002 and automatically build the vector index.
๐ ๏ธ Installation
System Requirements
Python: 3.12 or higher
OS: Windows, macOS, Linux
Memory: 4GB+ recommended for vector search
Storage: 1GB+ for caching and indexes
Dependencies
Core dependencies are managed in pyproject.toml:
fastmcp>=2.0.0- MCP server frameworklangchain>=0.3.0- AI and vector searchpython-dotenv>=1.1.0- Environment managementDocument processing libraries (pandas, openpyxl, python-docx, etc.)
โ๏ธ Configuration
Environment Variables
Variable | Default | Description |
|
| Root directory for file access |
|
| Maximum file size limit |
|
| Default file encoding |
| - | API key for embedding service |
| - | Embedding service URL |
|
| AI model for embeddings |
|
| Text chunk size for processing |
Advanced Configuration
For production deployments, consider:
Setting up rate limiting
Configuring log rotation
Using external vector databases
Setting up monitoring
๐ง MCP Tools
1. view_directory_tree
Purpose: Display directory structure in tree format
view_directory_tree(
directory_path=".", # Target directory
max_depth=3, # Maximum depth
max_entries=300 # Maximum entries to show
)2. read_file_content
Purpose: Read file content with line range support
read_file_content(
file_path="example.py", # File path
start_line=1, # Start line (optional)
end_line=50 # End line (optional)
)3. search_documents
Purpose: Intelligent semantic search across documents
search_documents(
query="authentication logic", # Search query
search_type="semantic", # semantic/filename/hybrid/extension
file_extensions=".py,.js", # File type filter (optional)
max_results=10 # Maximum results
)4. rebuild_document_index
Purpose: Rebuild vector index for search
rebuild_document_index() # No parameters needed5. get_document_stats
Purpose: Get index statistics and system status
get_document_stats() # Returns comprehensive stats6. list_files
Purpose: List files in directory with pattern matching
list_files(
directory_path="./src", # Directory to list
pattern="*.py", # File pattern
include_size=True # Include file sizes
)7. preview_file
Purpose: Quick preview of file content
preview_file(
file_path="example.py", # File to preview
lines=20 # Number of lines
)๐ Vector Search
Capabilities
Semantic Understanding: Search "user authentication" finds "login verification" code
Synonym Recognition: Search "database" finds "ๆฐๆฎๅบ" (Chinese) content
Multi-language Support: Handles English, Chinese, and mixed content
Context Awareness: Understands code semantics and relationships
Search Types
Semantic Search (
semantic): AI-powered understandingFilename Search (
filename): Fast filename matchingExtension Search (
extension): Filter by file typeHybrid Search (
hybrid): Combines semantic + filename
Technical Stack
Embedding Model: BAAI/bge-m3 (1024-dimensional vectors)
Vector Database: ChromaDB
Text Splitting: Intelligent semantic chunking
Incremental Updates: Hash-based change detection
๐ Supported Formats
Auto-detected Text Files
Programming languages:
.py,.js,.ts,.java,.cpp,.c,.go,.rs, etc.Config files:
.json,.yaml,.toml,.ini,.xml,.envDocumentation:
.md,.txt,.rstWeb files:
.html,.css,.scssData files:
.csv,.tsvFiles without extensions (auto-detected)
Document Formats (Auto-converted to Markdown)
Microsoft Office:
.docx,.xlsx,.pptxOpenDocument:
.odt,.ods,.odpPDF:
.pdf(text extraction)Legacy formats:
.doc,.xls(limited support)
๐ Security Features
Access Control
Directory Restriction: Access limited to
SAFE_DIRECTORYand subdirectoriesPath Traversal Protection: Automatic prevention of
../attacksSymlink Control: Configurable symbolic link access
File Size Limits: Prevents reading oversized files
Validation
Path Sanitization: Automatic path cleaning and validation
Permission Checks: Verify read permissions before access
Error Handling: Graceful failure with informative messages
๐ Integration
Claude Desktop
Add to your Claude Desktop MCP configuration:
{
"mcpServers": {
"fs-mcp": {
"command": "python",
"args": ["main.py"],
"cwd": "/path/to/fs-mcp",
"env": {
"SAFE_DIRECTORY": "/your/project/directory"
}
}
}
}Other MCP Clients
Connect to http://localhost:3002 using Server-Sent Events (SSE) protocol.
API Integration
The server exposes standard MCP endpoints that can be integrated with any MCP-compatible client.
๐๏ธ Project Structure
fs-mcp/
โโโ main.py # Main MCP server
โโโ src/ # Core modules
โ โโโ __init__.py # Package initialization
โ โโโ file_reader.py # Core file reading logic
โ โโโ security_validator.py # Security and validation
โ โโโ text_detector.py # Intelligent file detection
โ โโโ config_manager.py # Configuration management
โ โโโ document_cache.py # Document caching system
โ โโโ file_converters.py # Document format converters
โ โโโ dir_tree.py # Directory tree generation
โ โโโ embedding_config.py # AI embedding configuration
โ โโโ codebase_indexer.py # Vector indexing system
โ โโโ codebase_search.py # Search engine
โ โโโ index_scheduler.py # Index scheduling
โ โโโ progress_bar.py # Progress display utilities
โโโ tests/ # Test suite
โโโ cache/ # Document cache (auto-created)
โโโ logs/ # Log files (auto-created)
โโโ pyproject.toml # Project configuration
โโโ .env.example # Environment template
โโโ .gitignore # Git ignore rules
โโโ README.md # This file๐ป Development
Setting Up Development Environment
# Clone repository
git clone https://github.com/yourusername/fs-mcp.git
cd fs-mcp
# Install with development dependencies
uv sync --group dev
# OR with pip
pip install -e ".[dev]"Running Tests
# Run all tests
pytest
# Run with coverage
pytest --cov=src
# Run specific test
pytest tests/test_file_reader.pyCode Quality
# Format code
black src/ tests/
# Lint code
flake8 src/ tests/
# Type checking
mypy src/Debugging
Monitor logs in real-time:
tail -f logs/mcp_server_$(date +%Y%m%d).log๐ค Contributing
We welcome contributions! Here's how to get started:
1. Fork and Clone
git clone https://github.com/yourusername/fs-mcp.git
cd fs-mcp2. Create Feature Branch
git checkout -b feature/your-feature-name3. Make Changes
Follow the existing code style
Add tests for new functionality
Update documentation as needed
4. Test Your Changes
pytest
black src/ tests/
flake8 src/ tests/5. Submit Pull Request
Describe your changes clearly
Reference any related issues
Ensure all tests pass
Development Guidelines
Code Style: Follow PEP 8, use Black for formatting
Testing: Maintain test coverage above 80%
Documentation: Update README and docstrings
Commits: Use conventional commit messages
Security: Follow security best practices
๐ Roadmap
Enhanced PDF Processing: Better table and image extraction
More Embedding Models: Support for local models
Real-time Indexing: File system watchers
Advanced Search: Regex, proximity, faceted search
Performance Optimization: Async processing, caching improvements
Web Interface: Optional web UI for management
Plugin System: Custom file type handlers
Enterprise Features: Authentication, rate limiting, monitoring
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
FastMCP - MCP server framework
LangChain - AI integration
ChromaDB - Vector database
BGE-M3 - Embedding model
๐ Support
Issues: GitHub Issues
Discussions: GitHub Discussions
Documentation: Check the
docs/folder (when available)
Related MCP server: MCP Filesystem Server
ไธญๆ
๐ ๅ่ฝ็น็น
๐ง ๆบ่ฝๆๆฌๆฃๆต: ๆ ้ไพ่ตๆฉๅฑๅ๏ผ่ชๅจ่ฏๅซๆๆฌๆไปถ
๐ ๅคๆ ผๅผๆฏๆ: ๆฏๆๆๆฌๆไปถๅๆๆกฃๆ ผๅผ๏ผWordใExcelใPDF็ญ๏ผ
๐ ๅฎๅ จ้ช่ฏ: ๅชๅ ่ฎธ่ฏปๅ้ ็ฝฎ็ๅฎๅ จ็ฎๅฝไธญ็ๆไปถ
๐ ๆ่ก่ฏปๅ: ๆฏๆๆๅฎ่ก่ๅด่ฏปๅ๏ผไพฟไบๅค็ๅคงๆไปถ
๐ ๆๆกฃ่ฝฌๆข: ่ชๅจๅฐๆๆกฃๆ ผๅผ่ฝฌๆขไธบMarkdownๅนถ็ผๅญ
๐ ๅ้ๆ็ดข: ๅบไบAIๅตๅ ฅ็่ฏญไนๆ็ดข
โก ้ซๆง่ฝ: ๆฏๆๆน้ๆไปถๅค็ๅๆบ่ฝ็ผๅญ
๐ ๅค่ฏญ่จ: ๆฏๆไธญ่ฑๆๅ ๅฎนๅค็
๐ ๅฟซ้ๅผๅง
1. ๅ ้ๅๅฎ่ฃ
git clone https://github.com/yourusername/fs-mcp.git
cd fs-mcp
# ๆจ่ไฝฟ็จ uv
uv sync
# ๆไฝฟ็จ pip
pip install -r requirements.txt2. ็ฏๅข้ ็ฝฎ
ๅๅปบ .env ๆไปถ๏ผ
# ๅฎๅ
จ่ฎพ็ฝฎ
SAFE_DIRECTORY=. # ็ฎๅฝ่ฎฟ้ฎ้ๅถ๏ผๅฟ
้๏ผ
MAX_FILE_SIZE_MB=100 # ๆไปถๅคงๅฐ้ๅถ๏ผMB๏ผ
# ็ผ็ ่ฎพ็ฝฎ
DEFAULT_ENCODING=utf-8
# AIๅตๅ
ฅ้
็ฝฎ๏ผ็จไบๅ้ๆ็ดข๏ผ
OPENAI_EMBEDDINGS_API_KEY=your-api-key
OPENAI_EMBEDDINGS_BASE_URL=http://your-embedding-service/v1
EMBEDDING_MODEL_NAME=BAAI/bge-m3 # ๆๆจๅๅฅฝ็ๆจกๅ
EMBEDDING_CHUNK_SIZE=10003. ๅฏๅจๆๅกๅจ
python main.pyๆๅกๅจๅฐๅจ http://localhost:3002 ๅฏๅจๅนถ่ชๅจๅปบ็ซๅ้็ดขๅผใ
๐ ๏ธ MCPๅทฅๅ ท่ฏดๆ
่ฏฆ็ป็ๅทฅๅ ทไฝฟ็จๆนๆณ่ฏทๅ่่ฑๆ้จๅ็ MCP Tools ็ซ ่ใ
๐ ๅ้ๆ็ดขๅ่ฝ
ๆฆๅฟตๅน้ ๏ผๆ็ดข"็จๆท่ฎค่ฏ"่ฝๆพๅฐ"็ปๅฝ้ช่ฏ"็ธๅ ณไปฃ็
ๅไน่ฏ็่งฃ๏ผๆ็ดข"database"่ฝๆพๅฐ"ๆฐๆฎๅบ"็ธๅ ณๅ ๅฎน
ๅค่ฏญ่จๆฏๆ๏ผๅๆถ็่งฃไธญ่ฑๆไปฃ็ ๅๆณจ้
ไธไธๆ็่งฃ๏ผ็่งฃไปฃ็ ็่ฏญไนๅไธไธๆๅ ณ็ณป
๐ ๆฏๆ็ๆไปถๆ ผๅผ
่ฏฆ็ป็ๆ ผๅผๆฏๆ่ฏทๅ่่ฑๆ้จๅ็ Supported Formats ็ซ ่ใ
๐ ๅฎๅ จ็นๆง
่ทฏๅพ้ช่ฏ: ๅชๅ ่ฎธ่ฎฟ้ฎ้ ็ฝฎ็ๅฎๅ จ็ฎๅฝๅๅ ถๅญ็ฎๅฝ
ๆไปถๅคงๅฐ้ๅถ: ้ฒๆญข่ฏปๅ่ฟๅคงๆไปถ
่ทฏๅพ้ๅ้ฒๆค: ่ชๅจ้ฒๆญข
../็ญ่ทฏๅพ้ๅๆปๅป็ฌฆๅท้พๆฅๆงๅถ: ๅฏ้ ็ฝฎๆฏๅฆๅ ่ฎธ่ฎฟ้ฎ็ฌฆๅท้พๆฅ
๐ ้ๆๆนๅผ
Claude Desktop้ๆ
ๅจ Claude Desktop ็ MCP ้ ็ฝฎไธญๆทปๅ ๏ผ
{
"mcpServers": {
"fs-mcp": {
"command": "python",
"args": ["main.py"],
"cwd": "/path/to/fs-mcp",
"env": {
"SAFE_DIRECTORY": "/your/project/directory"
}
}
}
}๐ป ๅผๅ
ๅผๅ็ฏๅข่ฎพ็ฝฎ
# ๅ
้ไปๅบ
git clone https://github.com/yourusername/fs-mcp.git
cd fs-mcp
# ๅฎ่ฃ
ๅผๅไพ่ต
uv sync --group dev่ฟ่กๆต่ฏ
# ่ฟ่กๆๆๆต่ฏ
pytest
# ่ฟ่ก่ฆ็็ๆต่ฏ
pytest --cov=src๐ค ่ดก็ฎ
ๆฌข่ฟ่ดก็ฎไปฃ็ ๏ผ่ฏทๅ่่ฑๆ้จๅ็ Contributing ็ซ ่ไบ่งฃ่ฏฆ็ปไฟกๆฏใ
๐ ่ฎธๅฏ่ฏ
ๆฌ้กน็ฎ้็จ MIT ่ฎธๅฏ่ฏ - ่ฏฆ่ง LICENSE ๆไปถใ
Made with โค๏ธ for the AI community
This server cannot be deployed
Maintenance
Related MCP Connectors
The Needle MCP server enables semantic search on documents stored in files like PDFs, DOCX, and XLSX by connecting AI applications to external data sources. It provides capabilities to create and manage document collections, perform natural language searches on stored content, and retrieve relevant information without requiring exact keyword matches.
A Model Context Protocol server for Wix AI tools
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yoโฆ
Model Context Protocol server for the Apideck Unified API. Connect any MCP-compatible agent framework to 100+ accounting systems, HRIS platforms, file storage providers, and more through one integration. More information https://www.apideck.com/mcp-server
Related MCP Servers
- FlicenseBqualityDmaintenanceA Model Context Protocol server that enables LLMs to extract and use content from unstructured documents across a wide variety of file formats.111-
- AlicenseAqualityFmaintenanceA Model Context Protocol server that provides secure and intelligent interaction with files and filesystems, offering smart context management and token-efficient operations for working with large files and complex directory structures.2167MIT

CodeAlive MCPofficial
AlicenseNot gradedqualityAmaintenanceA Model Context Protocol server that enhances AI agents by providing deep semantic understanding of codebases, enabling more intelligent interactions through advanced code search and contextual awareness.90MIT- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that provides AI assistants with direct access to local document collections through full-text search, supporting multiple formats and hierarchical collections.MIT