A FastMCP server for semantic search over technical documentation (.txt, .md files)
Project description
MCP Documentation Server
A powerful Model Context Protocol (MCP) server that enables semantic search across technical documentation. Built with FastMCP and advanced natural language processing, this server allows you to upload .txt and .md files and perform intelligent semantic searches to quickly find relevant information.
โจ Features
๐ง Semantic Search Engine
- Advanced NLP: Uses
paraphrase-multilingual-mpnet-base-v2model for high-quality embeddings - Intelligent Chunking: Smart text segmentation with overlap for context preservation
- Multilingual Support: Works with Italian, English, and other languages
- Lightning Fast: Sub-60ms search times after initial processing
๐ Document Management
- Multiple Formats: Support for
.txtand.mdfiles - Automatic Processing: Scans directory for new/modified documents
- Metadata Tracking: File size, modification dates, character counts
- Cache System: Efficient embedding storage and retrieval
๐ง MCP Integration
- Standard Compliant: Full MCP protocol support
- Four Core Tools: Document upload, listing, searching, and removal
- Async Architecture: Non-blocking operations for better performance
- Error Handling: Robust error management and logging
๐ Proven Performance
- Tested at Scale: Successfully handles 639KB+ documents (19,000+ lines)
- 100% Success Rate: All test queries return relevant results
- High Accuracy: Average similarity scores > 0.66
- Production Ready: Thoroughly tested with real technical documentation
๐ Quick Start
Automated Installation (Recommended)
The easiest way to install and configure the server is using our automated installer:
# Install the package
pip install mcp-documentation-server
# Run the automated setup
mcp-doc-install
What it does:
- โ Creates an isolated virtual environment (no permission issues!)
- โ Installs the server and all dependencies
- โ Sets up directories and configuration
- โ Generates wrapper scripts for easy CLI access
- โ Creates configuration files for all major MCP clients
- โ Provides step-by-step setup instructions
Manual Installation Options
Option 1: Install from PyPI
pip install mcp-documentation-server
Option 2: Install from Source
git clone <repository-url>
cd mcp-documentation-server
pip install -e .
Setup and Configuration
Automatic Setup (Recommended)
Run the installation wizard to configure the server for your MCP client:
mcp-doc-install
This will:
- Create an isolated virtual environment in
~/.mcp-documentation-server/venv - Install the server without requiring system-wide permissions
- Create necessary directories
- Generate configuration files for Claude Desktop, Cursor, and VS Code
- Create wrapper scripts for easy command-line usage
- Provide step-by-step setup instructions
Manual Setup
-
Create a base directory for your documentation:
mkdir ~/.mcp-documentation-server cd ~/.mcp-documentation-server mkdir data embeddings
-
Configure your MCP client (see Configuration section below)
-
Add your documents to the
datadirectory
Quick Test
-
After automated setup, use the wrapper scripts:
# Windows C:\Users\YourName\.mcp-documentation-server\scripts\mcp-documentation-server.bat # Linux/Mac ~/.mcp-documentation-server/scripts/mcp-documentation-server
-
Or start the server directly (if installed globally):
mcp-documentation-server
-
Or use the launcher with custom settings:
mcp-doc-launcher --base-dir ~/my-docs --log-level DEBUG
โ๏ธ Configuration
Environment Variables
The server can be configured using environment variables:
MCP_DOC_BASE_DIR: Base directory for the server (default: current directory)MCP_DOC_DATA_DIR: Directory containing documentation files (default: data)MCP_DOC_EMBEDDINGS_DIR: Directory for embeddings cache (default: embeddings)MCP_DOC_METADATA_FILE: Metadata file path (default: metadata.json)MCP_DOC_LOG_LEVEL: Logging level (DEBUG/INFO/WARNING/ERROR, default: INFO)
MCP Client Configuration
Claude Desktop
Add to your Claude Desktop configuration file:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"documentation": {
"command": "mcp-documentation-server",
"env": {
"MCP_DOC_BASE_DIR": "/path/to/your/documentation",
"MCP_DOC_LOG_LEVEL": "INFO"
}
}
}
}
Cursor
Add to your Cursor MCP configuration:
{
"mcpServers": {
"documentation": {
"command": "mcp-documentation-server",
"env": {
"MCP_DOC_BASE_DIR": "/path/to/your/documentation",
"MCP_DOC_LOG_LEVEL": "INFO"
}
}
}
}
VS Code with MCP Extension
Add to your VS Code MCP configuration:
{
"mcpServers": {
"documentation": {
"command": "mcp-documentation-server",
"env": {
"MCP_DOC_BASE_DIR": "/path/to/your/documentation",
"MCP_DOC_LOG_LEVEL": "INFO"
}
}
}
}
For detailed VS Code integration instructions, see VS_CODE_INTEGRATION.md.
๐ฏ Why Automated Installation?
Our automated installer (mcp-doc-install) provides significant advantages:
๐ Isolated Environment
- No System Pollution: Installs in a dedicated virtual environment
- No Permission Issues: Works without administrator/sudo privileges
- Clean Uninstall: Easy to remove without affecting your system
๐ Zero Configuration
- Smart Defaults: Automatically detects optimal settings
- Cross-Platform: Works on Windows, macOS, and Linux
- Multiple Clients: Generates configs for Claude, Cursor, and VS Code simultaneously
๐ ๏ธ Developer Friendly
- Wrapper Scripts: Easy-to-use command-line tools
- Local Development: Automatically finds and installs local builds
- Professional Setup: Follows Python packaging best practices
๐ Organized Structure
~/.mcp-documentation-server/
โโโ venv/ # Isolated Python environment
โโโ data/ # Your documentation files
โโโ embeddings/ # Cached embeddings for fast search
โโโ configs/ # Generated MCP client configs
โโโ scripts/ # Wrapper scripts for easy CLI access
๐ Usage
MCP Tools
Once configured with your MCP client, you can use these tools:
- get_upload_info: Get information about where to upload documents
- list_documents: List all uploaded documents with metadata
- search_documents: Perform semantic search across all documents
- remove_document: Remove a document from the index
Example Queries
With your MCP client (Claude Desktop, etc.), you can ask:
- "What documents do I have available?"
- "Search for information about authentication"
- "Find documentation about API endpoints"
- "How do I configure the database connection?"
Command Line Usage
Interactive Mode
# Start with default settings
mcp-documentation-server
# Start with custom configuration
mcp-doc-launcher --base-dir ~/my-docs --log-level DEBUG
Environment Variables
export MCP_DOC_BASE_DIR=~/my-documentation
export MCP_DOC_LOG_LEVEL=DEBUG
mcp-documentation-server
.\venv\Scripts\activate
macOS/Linux
source venv/bin/activate
3. **Install dependencies**
```bash
pip install -r requirements.txt
- Start the server
python server.py
Adding Documents
Simply place your .txt or .md files in the data/ directory. The server will automatically detect and process them on the next operation.
๐ ๏ธ MCP Tools
The server provides four main tools for document management and search:
1. get_upload_info
Returns information about where and how to upload documents.
Example Response:
{
"upload_path": "/path/to/data",
"supported_formats": [".txt", ".md"],
"instructions": "Place files in the data directory..."
}
2. list_documents
Lists all available documents with metadata.
Example Response:
{
"documents": [
{
"id": "technical_docs.md",
"name": "technical_docs.md",
"size": 639757,
"char_count": 619348,
"last_modified": "2025-06-14T00:30:00"
}
]
}
3. search_documents
Performs semantic search across all documents.
Parameters:
query(string): Search querymax_results(integer, optional): Maximum results to return (default: 5)
Example:
{
"query": "Docker containerization",
"max_results": 3
}
Response:
{
"results": [
{
"document_id": "technical_docs.md",
"similarity_score": 0.8423,
"text": "Docker is a containerization platform...",
"chunk_id": 5,
"start_char": 1250,
"end_char": 1750
}
],
"query": "Docker containerization",
"total_results": 15
}
4. remove_document
Removes a document and its associated embeddings.
Parameters:
filename(string): Name of the file to remove
๐ Performance Benchmarks
Based on comprehensive testing with real technical documentation:
| Metric | Value | Notes |
|---|---|---|
| Document Size Tested | 639 KB | MCP protocol documentation |
| Search Success Rate | 100% | All 21 test queries successful |
| Average Search Time | 50.7ms | After initial processing |
| Average Similarity Score | 0.6689 | High relevance results |
| Best Match Score | 0.8423 | "MCP Model Context Protocol" |
| Processing Time | ~3min | 639KB initial processing |
Test Categories Validated
- โ Basic Concepts
- โ Client Implementations
- โ Tool Development
- โ Resource Management
- โ Prompt Engineering
- โ Technical Specifications
โ๏ธ Configuration
Environment Settings
The server uses the following directory structure:
mcp-documentation-server/
โโโ data/ # Place your documents here
โโโ embeddings/ # Cached embeddings (auto-generated)
โโโ venv/ # Virtual environment
โโโ server.py # Main MCP server
โโโ document_manager.py # Document handling
โโโ search_engine.py # Semantic search engine
โโโ metadata.json # Document metadata
Customization Options
Model Selection: Change the embedding model in search_engine.py:
model_name = "paraphrase-multilingual-mpnet-base-v2" # Default
# model_name = "all-MiniLM-L6-v2" # Faster, smaller
Chunk Settings: Adjust chunking parameters:
chunk_size = 500 # Characters per chunk
overlap = 50 # Overlap between chunks
Search Results: Modify default result count:
default_max_results = 5 # Default results returned
๏ฟฝ Integration Examples
Claude Desktop Configuration
Add to your Claude Desktop MCP settings:
{
"mcpServers": {
"documentation-search": {
"command": "python",
"args": ["/path/to/mcp-documentation-server/server.py"],
"cwd": "/path/to/mcp-documentation-server"
}
}
}
VS Code + GitHub Copilot Integration
Prerequisites: VS Code 1.99+, GitHub Copilot subscription
-
Enable MCP Support in VS Code settings:
{ "chat.mcp.enabled": true, "chat.mcp.discovery.enabled": true }
-
Configure Server - The
.vscode/mcp.jsonfile is already included:{ "servers": { "documentationSearch": { "type": "stdio", "command": "python", "args": ["server.py"], "cwd": "${workspaceFolder}" } } }
-
Use in Copilot Chat:
- Open Chat (
Ctrl+Alt+I) - Switch to Agent Mode
- Select Tools and enable documentation search tools
- Ask:
Search for Docker containerization in my docs
- Open Chat (
๐ Full Setup Guide: See VS_CODE_INTEGRATION.md
Using with Other MCP Clients
The server follows standard MCP protocol and works with any compliant client:
- Start the server via stdio transport
- Connect your client to the server process
- Use the tools for document search and management
๐งช Testing
Run the included test suite to verify functionality:
# Basic functionality test
python test_direct.py
# Advanced testing with large documents
python test_advanced.py
# Quick search verification
python test_quick.py
๐ Requirements
Python Dependencies
fastmcp>=0.1.0
sentence-transformers>=2.2.2
scikit-learn>=1.3.0
numpy>=1.24.0
System Requirements
- RAM: 2GB+ (model loading)
- Storage: 500MB+ (model cache)
- CPU: Any modern processor
๐ค Contributing
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and add tests
- Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
Development Setup
# Install development dependencies
pip install -r requirements-dev.txt
# Run tests
python -m pytest tests/
# Code formatting
black .
flake8 .
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐โโ๏ธ Support
- Issues: Report bugs and request features on GitHub Issues
- Documentation: Check the
docs/directory for detailed guides - Community: Join discussions in GitHub Discussions
๐ฎ Roadmap
Planned Features
- PDF Support: Add PDF document processing
- Web Interface: Optional web UI for document management
- Docker Support: Containerized deployment
- Advanced Filters: Search by document type, date, size
- Hybrid Search: Combine semantic and keyword search
- REST API: Additional HTTP API alongside MCP
Performance Improvements
- Incremental Updates: Update only changed document sections
- Compressed Embeddings: Reduce storage requirements
- Distributed Processing: Multi-threaded document processing
๐ Project Stats
- Languages: Python
- Framework: FastMCP
- AI Model: Sentence Transformers
- Protocol: Model Context Protocol (MCP)
- Status: โ Production Ready
- Test Coverage: 100% core functionality
- Documentation: Complete
Built with โค๏ธ for the MCP community
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_documentation_server-0.1.0.tar.gz.
File metadata
- Download URL: mcp_documentation_server-0.1.0.tar.gz
- Upload date:
- Size: 194.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7cf0152b11cbfb09a18af2e55583ecd0236bf0a7a576ba929dd3202c5600c222
|
|
| MD5 |
b208f50b8a701c4425a022cde55a9a2a
|
|
| BLAKE2b-256 |
271a404899451821de6a350ec744b10307e26aeac6b195690e4c4235110d17cd
|
File details
Details for the file mcp_documentation_server-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mcp_documentation_server-0.1.0-py3-none-any.whl
- Upload date:
- Size: 26.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b479f4372720283ca718b40d1800a287af3c47f1482d281b34ef42a13377e417
|
|
| MD5 |
b431898e0af5f50d9fe84de3f69ba752
|
|
| BLAKE2b-256 |
7fa1286cbce5e2443aec1861a7bdb776a5368e0dd3bdfbf34aae7f98349b9ea4
|