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 "Install 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 installed
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
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/boleyn/fs-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server