Secure MCP Server
Production-ready MCP server with web search, persistent memory, multi-user support, and SwarmUI integration.
README
🔒 Secure MCP Server
Production-ready Multi-Context Protocol server with web search and persistent memory
Works on Windows, Linux, and Mac - Built with Python for maximum security and compatibility.
✨ Features
| Feature | Description |
|---|---|
| 🔐 Security First | JWT authentication, rate limiting, input sanitization, encryption |
| 🧠 Persistent Memory | Vector database with semantic search using AI embeddings |
| 🔍 Web Search | Built-in web search (DuckDuckGo + optional Brave API) |
| 👥 Multi-User | Isolated memory spaces and authentication per user |
| 🪟 Windows Ready | Full support for Windows, Linux, and Mac |
| 🚀 Easy Setup | Automated installation with sensible defaults |
🎯 Quick Start
Windows (5 minutes)
setup.bat
venv\Scripts\activate
python manage_users.py
python src\server.py
See QUICKSTART_WINDOWS.md for detailed Windows instructions
Linux/Mac (5 minutes)
chmod +x setup.sh
./setup.sh
source venv/bin/activate
python3 manage_users.py
python3 src/server.py
See QUICKSTART.md for detailed Linux/Mac instructions
📋 Requirements
- Python 3.8+ (Download)
- ⚠️ Windows: Check "Add Python to PATH" during installation
- 2GB RAM recommended
- Internet connection (for web search)
🛠️ What's Included
MCP tools (memory, search, SwarmUI skills)
web_search- Search the internet for informationstore_memory- Save information with tags for latersearch_memory- Find memories using semantic searchget_recent_memories- Retrieve recent contextmemory_stats- View storage statisticsclear_memories- Reset memory storagedelete_memory- Remove one memory by IDlist_swarmui_skills/get_swarmui_skill- Load SwarmUI agent skills from.agents/skills/*/SKILL.mdwhenswarmui.pathorSWARMUI_PATHis set- SwarmUI HTTP API (when
swarmui.api_urlorSWARMUI_API_URL):swarmui_get_queue_status,swarmui_list_models,swarmui_list_t2i_params,swarmui_generate_image,swarmui_interrupt— calls SwarmUI’s JSONPOST /API/...(session + optional login). For broad compatibility, callswarmui_list_modelswith an empty arguments object ({}) first, then narrow by path/subtype if needed.swarmui_generate_imagealso auto-resolves nickname/partial model text to a valid model path by querying listmodels internally, and accepts a natural-languageinstructionstring (it parses model/steps/cfg/resolution/images). It downloads outputs and returns embedded MCP image content so clients like LM Studio can render images directly in chat (rather than URL-only Markdown links); if the client sends a progress token with the tool call, queue/backend updates are sent while generation runs. Seeconfig.example.yaml.
Core Components
- ✅ MCP Server (
src/server.py) - Main server with stdio transport - ✅ Security Module - JWT auth, encryption, rate limiting
- ✅ Memory System - Vector database with ChromaDB
- ✅ Web Search - DuckDuckGo (free) + Brave API (optional)
- ✅ User Management - CLI tool for user administration
- ✅ Test Client - Automated testing and verification
🔒 Security Features
- ✅ JWT token-based authentication (30-min expiration)
- ✅ Per-user rate limiting (60/min, 1000/hour)
- ✅ AES-256 encryption for sensitive data
- ✅ Bcrypt password hashing
- ✅ Input sanitization (prevents injection attacks)
- ✅ URL filtering for web search
- ✅ Isolated user memory spaces
- ✅ Comprehensive audit logging
📁 Project Structure
secure-mcp-server/
├── src/
│ ├── server.py # Main MCP server ⭐
│ ├── security.py # Authentication & encryption
│ ├── memory_system.py # Vector database & memory
│ └── web_search.py # Web search functionality
├── data/ # Runtime data (auto-created)
│ ├── memory_db/ # Memory storage
│ └── server.log # Activity logs
├── setup.bat # Windows installation ⭐
├── setup.sh # Linux/Mac installation ⭐
├── manage_users.py # User management CLI ⭐
├── test_client.py # Testing utility ⭐
├── QUICKSTART_WINDOWS.md # Windows guide ⭐
├── QUICKSTART.md # Linux/Mac guide
└── requirements.txt # Python dependencies
⭐ = Most important files
🧪 Testing Your Server
Automated Tests (Windows)
venv\Scripts\activate
python test_client.py
Automated Tests (Linux/Mac)
source venv/bin/activate
python test_client.py
Interactive Mode
python test_client.py --interactive
💡 Usage Example
# Store a memory
await session.call_tool(
"store_memory",
arguments={
"content": "User prefers Python and dark mode",
"tags": ["preferences"]
},
meta={"user_id": "john"}
)
# Search memories
await session.call_tool(
"search_memory",
arguments={"query": "What are user preferences?"},
meta={"user_id": "john"}
)
# Web search
await session.call_tool(
"web_search",
arguments={"query": "Python MCP tutorial"},
meta={"user_id": "john"}
)
🔧 Configuration
Edit .env file for settings:
# Security
JWT_SECRET_KEY=your-secret-key
ENCRYPTION_KEY=your-encryption-key
# Memory
MEMORY_DB_PATH=./data/memory_db
MEMORY_MAX_RESULTS=10
# Web Search
SEARCH_API_KEY=optional-brave-api-key
SEARCH_MAX_RESULTS=10
# Rate Limiting
RATE_LIMIT_PER_MINUTE=60
RATE_LIMIT_PER_HOUR=1000
🪟 Windows-Specific Notes
Python Installation
- Download from python.org
- ⚠️ IMPORTANT: Check "Add Python to PATH" during installation
- Restart Command Prompt after installation
Running Scripts
- Use
python(notpython3) - Use
\for paths (e.g.,data\memory_db) - Activate venv:
venv\Scripts\activate
Claude Desktop Integration
Config file location: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"secure-mcp": {
"command": "python",
"args": ["C:\\path\\to\\secure-mcp-server\\src\\server.py"]
}
}
}
🐛 Troubleshooting
Windows
| Issue | Solution |
|---|---|
| "Python not recognized" | Add Python to PATH or reinstall with PATH option |
| Module errors | Run pip install -r requirements.txt |
| Activation fails | Use venv\Scripts\activate.bat |
Linux/Mac
| Issue | Solution |
|---|---|
| Permission denied | Run chmod +x setup.sh |
| Module errors | Run pip install -r requirements.txt |
| Python version | Ensure Python 3.8+ with python3 --version |
All Platforms
| Issue | Solution |
|---|---|
| Slow first run | Embedding model downloads once (~80MB) |
| Web search fails | Check internet; DuckDuckGo works without API key |
| Auth failures | Verify user exists with manage_users.py |
📊 Performance
- Memory search: <100ms for 1000 memories
- Web search: 1-3 seconds (network dependent)
- Authentication: <10ms
- Supports: Hundreds of concurrent users
🚨 Security Checklist
Before deploying:
- [ ] Change default admin password (admin/changeme123)
- [ ] Generate unique JWT_SECRET_KEY
- [ ] Generate unique ENCRYPTION_KEY
- [ ] Review rate limits in
.env - [ ] Enable logging and monitoring
- [ ] Backup
data/directory regularly - [ ] Keep dependencies updated
📚 Documentation
- Windows Quick Start - Windows installation
- Linux/Mac Quick Start - Unix installation
- Project Summary - Complete overview
- Full Documentation - Detailed guide
- Tool Usage Playbook - LLM-facing MCP tool routing and reliability rules
🎓 Learning Resources
- MCP Protocol: https://docs.anthropic.com/mcp
- ChromaDB: https://docs.trychroma.com/
- Brave Search API: https://brave.com/search/api/
📝 License
Provided as-is for educational and development purposes.
🎉 You're All Set!
Your MCP server is:
- ✅ Fully functional
- ✅ Production-ready
- ✅ Windows compatible
- ✅ Security-hardened
- ✅ Multi-user capable
- ✅ Well-documented
Questions? Check the documentation or review code comments.
Ready to start? Follow your platform's Quick Start guide!
Built with ❤️ for Windows, Linux, and Mac. Happy building! 🚀
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。