Skip to content

Commit c80bdb7

Browse files
authored
Merge branch 'main' into 1014-yuluo/chore
2 parents e44ba4d + 7d3a9f8 commit c80bdb7

File tree

6 files changed

+1587
-5
lines changed

6 files changed

+1587
-5
lines changed

examples/mcp-classifier-server/README.md

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,40 @@
11
# MCP Classification Server
22

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.
44

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
633

734
- **Dynamic Categories**: Loaded from MCP server at runtime via `list_categories`
835
- **Per-Category System Prompts**: Each category has its own specialized system prompt for LLM context
936
- **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)
1138
- **Dual Transport**: Supports both HTTP and stdio
1239

1340
## Categories
@@ -164,6 +191,36 @@ if systemPrompt, ok := classifier.GetCategorySystemPrompt(category); ok {
164191
}
165192
```
166193

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
168219

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 |
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# MCP Embedding-Based Classification Server Requirements
2+
3+
# Core MCP SDK
4+
mcp>=1.0.0
5+
6+
# Embedding and Vector Search
7+
transformers>=4.30.0
8+
torch>=2.0.0
9+
faiss-cpu>=1.7.4 # Use faiss-gpu if you have GPU support
10+
11+
# HTTP server support (optional, for HTTP mode)
12+
aiohttp>=3.9.0
13+
14+
# Utilities
15+
numpy>=1.24.0
16+

0 commit comments

Comments
 (0)