A deterministic, schema-driven execution engine for Model Context Protocol (MCP) servers. This system requires zero code changes to add new tools and uses no LLMs in the execution path.
┌─────────────────┐
│ User Input │
└────────┬────────┘
│
┌────▼─────────────┐
│ 1. NLP Module │ Extract entities (spaCy)
└────┬─────────────┘
│
┌────▼─────────────┐
│ 2. Intent Engine │ Classify intent (ML)
└────┬─────────────┘
│
┌────▼─────────────┐
│ 3. Rule Engine │ Apply business logic
└────┬─────────────┘
│
┌────▼─────────────┐
│ 4. Tool Registry │ Match tool from DB
└────┬─────────────┘
│
┌────▼─────────────┐
│ 5. Schema Exec │ Build params from schema
└────┬─────────────┘
│
┌────▼─────────────┐
│ 6. MCP Client │ Execute on MCP server
└────┬─────────────┘
│
┌────▼─────────────┐
│ 7. Audit Logger │ Store full trace
└────┬─────────────┘
│
┌────▼─────────────┐
│ Result │
└──────────────────┘
- Zero Code Changes: Add new tools by just registering MCP servers
- No LLMs: Fully deterministic execution using schemas only
- Schema-Driven: Uses JSON Schema for parameter extraction
- Full Audit: Complete execution trace for every request
- Production-Ready: PostgreSQL, async, error handling, tests
- FastAPI - High-performance async API
- PostgreSQL - Production database with SQLAlchemy
- spaCy - NLP for entity extraction
- scikit-learn - Intent classification
- json-logic-py - Rule engine
- JSON Schema - Parameter validation
- Vanilla HTML/CSS/JavaScript - No build tools required
- Modern CSS - Responsive design with flexbox/grid
- Fetch API - REST client
- JWT Auth - Token-based authentication
cd client_mcp_hybrid
python -m pip install -r requirements.txt
python -m spacy download en_core_web_smCreate PostgreSQL database and .env file:
DATABASE_URL=postgresql+asyncpg://user:password@localhost/mcp_client
SECRET_KEY=your-secret-key-here
DEBUG=trueCreate mcp_servers.json:
{
"servers": [
{
"name": "filesystem",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/files"]
}
]
}python main.pyAccess at: http://localhost:8000
Demo Credentials:
- Username:
admin/ Password:admin - Username:
user/ Password:user
- System statistics
- Active servers
- Recent executions
- Auto-refresh
- Natural language input
- Example commands
- Real-time results
- Parameter display
- Browse all tools
- Search and filter
- View JSON schemas
- Server grouping
- MCP server list
- Status monitoring
- Trigger discovery
- Statistics
- Execution history
- Filter by status/date
- Detailed traces
- Pipeline information
POST /api/v1/auth/login
POST /api/v1/auth/refreshPOST /api/v1/execute
# Body: {"input": "list files in /tmp"}GET /api/v1/tools
GET /api/v1/tools/{tool_id}
GET /api/v1/tools/{tool_id}/schemaGET /api/v1/servers
POST /api/v1/servers/discover
GET /api/v1/servers/{server_id}/statsGET /api/v1/audit
GET /api/v1/audit/{execution_id}client_mcp_hybrid/
├── main.py # FastAPI application
├── requirements.txt # Dependencies
│
├── config/ # Configuration
├── database/ # Database models
├── nlp/ # Entity extraction
├── intent/ # Intent classification
├── rules/ # Rule engine
├── registry/ # Tool registry
├── executor/ # Schema executor
├── mcp/ # MCP client
├── discovery/ # Server discovery
├── audit/ # Audit logging
├── api/ # REST API
├── pipeline/ # Pipeline orchestrator
│
├── frontend/ # Web UI (vanilla JS)
│ ├── login.html
│ ├── dashboard.html
│ ├── execute.html
│ ├── tools.html
│ ├── servers.html
│ ├── audit.html
│ ├── css/
│ │ └── style.css
│ └── js/
│ ├── auth.js
│ ├── api.js
│ ├── utils.js
│ ├── dashboard.js
│ ├── execute.js
│ ├── tools.js
│ ├── servers.js
│ └── audit.js
│
└── tests/ # Test suite
curl -X POST http://localhost:8000/api/v1/execute \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"input": "list all files in /tmp"}'{
"status": "success",
"tool_name": "list_directory",
"server_name": "filesystem",
"result": {
"files": ["file1.txt", "file2.txt"]
},
"parameters": {
"path": "/tmp"
},
"duration_ms": 156,
"execution_id": "exec_123"
}- Add new MCP server to
mcp_servers.json - Restart application (or POST to
/api/v1/servers/discover) - Tools are automatically available - no code changes!
- Execute commands using new tools immediately
# Run all tests
pytest
# Specific test
pytest tests/test_pipeline.py
# With coverage
pytest --cov=. --cov-report=htmldocker build -t mcp-client .
docker run -p 8000:8000 \
-e DATABASE_URL=postgresql://... \
-e SECRET_KEY=... \
mcp-client[Unit]
Description=MCP Client
After=network.target postgresql.service
[Service]
Type=simple
User=mcp
WorkingDirectory=/opt/mcp-client
Environment="DATABASE_URL=postgresql://..."
ExecStart=/opt/mcp-client/venv/bin/python main.py
Restart=always
[Install]
WantedBy=multi-user.targetserver {
listen 80;
server_name mcp.example.com;
location / {
proxy_pass http://localhost:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}INSERT INTO business_rules (intent, conditions, actions, priority)
VALUES (
'file_operation',
'{"and": [{"var": "action"}, {"==": [{"var": "action"}, "read"]}]}',
'{"require_permission": "read"}',
100
);from intent.classifier import IntentClassifier
classifier = IntentClassifier()
classifier.train(training_data)
classifier.save_model("intent_model.pkl")# Check PostgreSQL
sudo systemctl status postgresql
# Test connection
psql -h localhost -U user -d mcp_client# Test server manually
npx -y @modelcontextprotocol/server-filesystem /tmp
# Validate config
python -m json.tool mcp_servers.json- Check browser console for errors
- Verify FastAPI is serving static files
- Ensure all JS files are loaded (auth.js, api.js, utils.js)
Zero code changes • No LLMs • Fully deterministic