|
1 | 1 | # MCP Classification Server |
2 | 2 |
|
3 | | -Example MCP server that provides text classification with intelligent routing for the semantic router. |
| 3 | +Example MCP servers that provide text classification with intelligent routing for the semantic router. |
4 | 4 |
|
5 | | -## Features |
| 5 | +## 📦 Two Implementations |
| 6 | + |
| 7 | +This directory contains **two MCP classification servers**: |
| 8 | + |
| 9 | +### 1. **Regex-Based Server** (`server.py`) |
| 10 | + |
| 11 | +- ✅ **Simple & Fast** - Pattern matching with regex |
| 12 | +- ✅ **Lightweight** - ~10MB memory, <5ms per query |
| 13 | +- ✅ **No Dependencies** - Just MCP SDK |
| 14 | +- 📝 **Best For**: Prototyping, simple rules, low-latency requirements |
| 15 | + |
| 16 | +### 2. **Embedding-Based Server** (`server_embedding.py`) 🆕 |
| 17 | + |
| 18 | +- ✅ **High Accuracy** - Semantic understanding with Qwen3-Embedding-0.6B |
| 19 | +- ✅ **RAG-Style** - FAISS vector database with similarity search |
| 20 | +- ✅ **Flexible** - Handles paraphrases, synonyms, variations |
| 21 | +- 📝 **Best For**: Production use, high-accuracy requirements |
| 22 | + |
| 23 | +**Choose based on your needs:** |
| 24 | + |
| 25 | +- **Quick start / Testing?** → Use `server.py` (regex-based) |
| 26 | +- **Production / Accuracy?** → Use `server_embedding.py` (embedding-based) |
| 27 | + |
| 28 | +--- |
| 29 | + |
| 30 | +## Regex-Based Server (`server.py`) |
| 31 | + |
| 32 | +### Features |
6 | 33 |
|
7 | 34 | - **Dynamic Categories**: Loaded from MCP server at runtime via `list_categories` |
8 | 35 | - **Per-Category System Prompts**: Each category has its own specialized system prompt for LLM context |
9 | 36 | - **Intelligent Routing**: Returns `model` and `use_reasoning` in classification response |
10 | | -- **Regex-Based**: Simple pattern matching (replace with ML models for production) |
| 37 | +- **Regex-Based**: Simple pattern matching (fast but limited) |
11 | 38 | - **Dual Transport**: Supports both HTTP and stdio |
12 | 39 |
|
13 | 40 | ## Categories |
@@ -164,6 +191,36 @@ if systemPrompt, ok := classifier.GetCategorySystemPrompt(category); ok { |
164 | 191 | } |
165 | 192 | ``` |
166 | 193 |
|
167 | | -## License |
| 194 | +--- |
| 195 | + |
| 196 | +## Embedding-Based Server (`server_embedding.py`) |
| 197 | + |
| 198 | +For **production use with high accuracy**, see the embedding-based server: |
| 199 | + |
| 200 | +### Quick Start |
| 201 | + |
| 202 | +```bash |
| 203 | +# Install dependencies |
| 204 | +pip install -r requirements_embedding.txt |
| 205 | +
|
| 206 | +# Start server (HTTP mode on port 8090) |
| 207 | +python3 server_embedding.py --http --port 8090 |
| 208 | +``` |
| 209 | + |
| 210 | +### Features |
| 211 | + |
| 212 | +- **Qwen3-Embedding-0.6B** model with 1024-dimensional embeddings |
| 213 | +- **FAISS vector database** for fast similarity search |
| 214 | +- **RAG-style classification** using 95 training examples |
| 215 | +- **Same MCP protocol** as regex server (drop-in replacement) |
| 216 | +- **Higher accuracy** - Understands semantic meaning, not just patterns |
| 217 | + |
| 218 | +### Comparison |
168 | 219 |
|
169 | | -MIT |
| 220 | +| Feature | Regex (`server.py`) | Embedding (`server_embedding.py`) | |
| 221 | +|---------|---------------------|-----------------------------------| |
| 222 | +| **Accuracy** | ⭐⭐⭐ | ⭐⭐⭐⭐⭐ | |
| 223 | +| **Speed** | ~1-5ms | ~50-100ms | |
| 224 | +| **Memory** | ~10MB | ~600MB | |
| 225 | +| **Setup** | Simple | Requires model | |
| 226 | +| **Best For** | Prototyping | Production | |
0 commit comments