MCP Document Server
A secure Model Context Protocol server that enables Claude AI to list, search, and read local documents in formats such as PDF, DOCX, and XLSX. It features read-only access with path traversal protection and supports deployment via Docker with SSE or STDIO transport options.
README
MCP Document Server
A secure Model Context Protocol (MCP) server that provides Claude AI with access to your local documents. Built for Aaron's work document integration needs.
Features
- 🔒 Secure: Read-only access with path traversal protection
- 📁 File Support: PDF, DOCX, XLSX, PPTX, TXT, MD, JSON, YAML, CSV, LOG
- 🔍 Search: Full-text search across documents
- 🐳 Docker: Easy deployment with Docker Compose
- 🌐 Network: Works over HTTP (SSE) or local STDIO
- 🔌 Tailscale Ready: Integrate with your existing Tailscale network
Quick Start
Option 1: Docker Compose (Recommended)
-
Clone and setup:
cd mcp-document-server cp .env.example .env # Edit .env if needed -
Create documents directory:
mkdir -p documents # Add your work documents here -
Start the server:
docker-compose up -d -
Test it:
curl http://localhost:8000/health
Option 2: Python Virtual Environment
-
Setup:
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt -
Configure:
cp .env.example .env export $(cat .env | xargs) -
Run:
python server.py
Configuration
Environment Variables
| Variable | Default | Description |
|---|---|---|
MCP_TRANSPORT |
sse |
Transport type: sse (HTTP) or stdio |
MCP_HOST |
0.0.0.0 |
Server host (SSE only) |
MCP_PORT |
8000 |
Server port (SSE only) |
DOCUMENTS_PATH |
/documents |
Path to documents directory |
MAX_FILE_SIZE_MB |
10 |
Maximum file size in MB |
ALLOWED_EXTENSIONS |
.txt,.md,... |
Comma-separated allowed extensions |
Docker Compose Volumes
Edit docker-compose.yml to mount your work documents:
volumes:
# Option 1: Local directory
- ./documents:/documents:ro
# Option 2: Specific path
- /path/to/work/documents:/documents:ro
Integration with Claude
Via Claude Desktop (Local)
- Edit Claude Desktop config (
~/.config/claude/mcp_servers.jsonon Linux):
{
"document-server": {
"command": "docker",
"args": ["exec", "-i", "mcp-document-server", "python", "server.py"],
"env": {
"MCP_TRANSPORT": "stdio"
}
}
}
Via HTTP (Tailscale/Network)
If running on your home server and accessing via Tailscale:
- Start server with SSE transport (default)
- Note your Tailscale IP (e.g.,
100.x.x.x) - Access at
http://100.x.x.x:8000
Configure Claude to use this URL in your MCP client settings.
Available Tools
1. list_documents
List all documents in a directory.
Parameters:
subdirectory(optional): Subdirectory to listrecursive(optional): List recursively
Example:
{
"subdirectory": "projects/2024",
"recursive": true
}
2. read_document
Read the contents of a specific document.
Parameters:
file_path: Relative path to documentmax_chars(optional): Maximum characters to return (default: 50000)
Example:
{
"file_path": "projects/2024/Q4-report.pdf",
"max_chars": 50000
}
3. search_documents
Search for documents containing specific text.
Parameters:
query: Search queryfile_extension(optional): Filter by extensioncase_sensitive(optional): Case-sensitive search
Example:
{
"query": "quarterly review",
"file_extension": ".docx",
"case_sensitive": false
}
Security Considerations
Path Traversal Protection
- All file access is restricted to
DOCUMENTS_PATH - Symbolic links are resolved and validated
- Path traversal attempts (../) are blocked
Read-Only Access
- Server only reads files, never writes
- Docker container runs with read-only volume mount
- No file modification capabilities exposed
File Type Restrictions
- Only allowed extensions can be accessed
- Binary files require appropriate parsers
- Unknown types are rejected
Network Security
- Use Tailscale for encrypted access
- Consider adding authentication token
- Bind to localhost if only local access needed
Tailscale Integration
Setup
-
On your home server, ensure Tailscale is running:
sudo tailscale status -
Start MCP server:
docker-compose up -d -
Get Tailscale IP:
tailscale ip -4 -
Access from anywhere:
http://<your-tailscale-ip>:8000
Firewall Rules
If using OPNsense with Tailscale:
- Allow port 8000 on Tailscale interface
- Add rule:
pass in on tailscale0 proto tcp from any to any port 8000
Advanced Configuration
Custom Document Parsers
To add support for additional file types, modify server.py:
elif full_path.suffix == '.custom':
# Your custom parser here
content = parse_custom_file(full_path)
Authentication
Add basic token authentication:
- Set
MCP_AUTH_TOKENin.env - Modify server to check token in requests
- Pass token in Claude MCP client config
Multiple Document Directories
Run multiple instances with different compose files:
# Work documents
docker-compose -f docker-compose.work.yml up -d
# Personal documents
docker-compose -f docker-compose.personal.yml up -d
Troubleshooting
Server won't start
# Check logs
docker-compose logs -f
# Verify documents directory exists
ls -la ./documents
# Check permissions
chmod 755 ./documents
Cannot read files
# Verify file extensions are allowed
docker-compose exec mcp-document-server python -c \
"import os; print(os.getenv('ALLOWED_EXTENSIONS'))"
# Check file permissions
ls -la ./documents/
Claude can't connect
# Test server is running
curl http://localhost:8000/health
# Check Tailscale connectivity
ping <tailscale-ip>
# Verify firewall rules
# On OPNsense, check Firewall > Rules > Tailscale
Development
Running Tests
# Install dev dependencies
pip install pytest pytest-asyncio
# Run tests
pytest tests/
Debug Mode
# Enable debug logging
export LOG_LEVEL=DEBUG
python server.py
Hot Reload
For development with auto-reload:
uvicorn server:mcp.app --reload --host 0.0.0.0 --port 8000
Architecture
┌─────────────┐
│ Claude │
│ (claude.ai)│
└──────┬──────┘
│ MCP Protocol
│ (SSE/HTTP)
↓
┌─────────────────┐ ┌──────────────┐
│ MCP Document │─────→│ Documents │
│ Server │ │ Directory │
│ (Docker) │ │ (Read-Only) │
└─────────────────┘ └──────────────┘
│
│ Tailscale Network
│
┌─────────────────┐
│ Home Server │
│ (OPNsense) │
└─────────────────┘
Contributing
This is a custom implementation for Aaron's needs, but feel free to adapt it for your own use.
License
MIT License - See LICENSE file for details
Support
For issues or questions:
- Check troubleshooting section
- Review Docker logs:
docker-compose logs -f - Verify network connectivity with Tailscale
Built for: Aaron Watson
Integration: Claude AI + Local Documents
Stack: Python, MCP SDK, Docker, FastAPI
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。