A working implementation of a semantic layer that enhances the MCP memory server with real pattern matching and type inference capabilities.
- SQLite-based pattern storage
- Real-time type inference with confidence scoring
- Pattern matching with attribute validation
- API endpoints for inference and pattern management
pip install -r requirements.txt
- Start the server:
python src/api.py
- Test the functionality:
python tests/test_semantic.py
POST /infer
{
"id": "doc1",
"attributes": {
"title": "Project Document",
"format": "pdf"
}
}
GET /patterns
-
Pattern Matching:
- Validates required attributes
- Checks string patterns and values
- Applies keyword matching
-
Confidence Scoring:
- Weights required vs optional attributes
- Adjusts for pattern specificity
- Considers attribute match quality
-
Storage:
- Patterns stored in SQLite
- Inference results cached
- Pattern confidence tracked
- Add new patterns in
semantic_core.py
- Extend pattern matching in
_match_value
- Add new API endpoints in
api.py