A temporal knowledge graph memory system implementing the Model Context Protocol (MCP), inspired by CORE (getcore.me).
Purpose: Build your personal memory system to power your AI apps. Like CORE, but open-source, self-hosted, and built with PostgreSQL + pgvector for semantic search, entity extraction, relationship tracking, and multi-hop reasoning.
π§ Temporal Knowledge Graph - Track who said what, when, and why with full provenance π Semantic Search - Find memories by meaning using sentence-transformers embeddings πΈοΈ Relationship Extraction - Automatically extract entities and relationships using spaCy π― Multi-Hop Reasoning - Traverse knowledge graph connections for complex queries π€ User Personas - Learn and recall user preferences, skills, and background π Conversation Sessions - Track context across interactions β‘ Local-First - No API keys required, runs entirely offline with local ML models
- Start infrastructure services:
docker compose up -d postgres redis rabbitmq- Install Python dependencies:
cd SerialMemory.Mcp.Python
pip install -r requirements.txt
python -m spacy download en_core_web_sm- Run the MCP server:
python -m src.main# Start everything including .NET API/Worker
docker compose up --buildOnce running, access:
| Service | URL | Credentials |
|---|---|---|
| API (Swagger) | http://localhost:5000/swagger | - |
| API Metrics | http://localhost:5000/metrics | - |
| Worker Metrics | http://localhost:8081/metrics | - |
| RabbitMQ Management | http://localhost:15672 | guest/guest |
| Prometheus | http://localhost:9090 | - |
| Grafana | http://localhost:3000 | admin/admin |
| Redis | localhost:6379 | - |
| PostgreSQL | localhost:5432 | postgres/postgres |
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MCP Server (Python/STDIO) β
β ββββββββββββββββββββββββββββββββββββββ β
β β sentence-transformers (embeddings)β β
β β spaCy (entity extraction) β β
β β Knowledge Graph Service β β
β ββββββββββββββββββββββββββββββββββββββ β
β β β
β ββββββββββββββββββββββββββββββββββββββ β
β β PostgreSQL + pgvector β β
β β - memories (with embeddings) β β
β β - entities & relationships β β
β β - user personas β β
β β - conversation sessions β β
β ββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Memory Ingestion:
- Client sends memory via
memory_ingesttool - Generate embedding using sentence-transformers
- Extract entities and relationships using spaCy
- Store memory, entities, and relationships in PostgreSQL
- Link entities to memory via many-to-many relationship
Semantic Search:
- Client queries via
memory_searchtool - Generate query embedding
- Search memories using pgvector cosine similarity
- Optionally combine with full-text search (hybrid mode)
- Enrich results with linked entities and relationships
Multi-Hop Reasoning:
- Find initial memories matching query
- Extract entities from those memories
- Traverse entity relationships
- Find connected memories via related entities
- Return graph of memories, entities, and relationships
- Python MCP Server - Temporal knowledge graph with semantic search
- PostgreSQL + pgvector - Graph storage with vector similarity search
- sentence-transformers - Local embedding generation (384-dim vectors)
- spaCy - Entity extraction and relationship detection
- Redis (optional) - Caching layer for hot memories
- .NET API/Worker (optional) - HTTP REST API and real-time SignalR updates
# Build solution
dotnet build SerialMemoryServer.sln
# Run locally (requires Redis + RabbitMQ running)
dotnet run --project SerialMemory.Api
dotnet run --project SerialMemory.Worker
dotnet run --project SerialMemory.McpAdd to your Claude Desktop claude_desktop_config.json:
{
"mcpServers": {
"serial-memory": {
"command": "python",
"args": ["-m", "src.main"],
"cwd": "D:\\DEV\\SerialMemoryServer\\SerialMemory.Mcp.Python",
"env": {
"POSTGRES_HOST": "localhost",
"POSTGRES_PORT": "5432",
"POSTGRES_USER": "postgres",
"POSTGRES_PASSWORD": "postgres",
"POSTGRES_DB": "contextdb"
}
}
}
}| Tool | Description |
|---|---|
| memory_search | Search memories using semantic/text/hybrid search with entity enrichment |
| memory_ingest | Add new memories with automatic entity/relationship extraction |
| memory_about_user | Retrieve user persona (preferences, skills, background) |
| initialise_conversation_session | Start a new conversation session for context tracking |
| end_conversation_session | End the current conversation session |
| memory_multi_hop_search | Traverse knowledge graph for multi-hop reasoning |
| get_integrations | List available external integrations |
| Resource | Description |
|---|---|
| memory://recent | List of recently added memories (JSON) |
| memory://sessions | List of recent conversation sessions (JSON) |
# Add a memory
memory_ingest({
"content": "I met John Smith at the conference. He works at Acme Corp on AI research.",
"source": "claude-desktop"
})
# β Automatically extracts entities: John Smith (PERSON), Acme Corp (ORG)
# β Extracts relationship: John Smith WORKS_AT Acme Corp
# Search semantically
memory_search({
"query": "Who did I meet at the conference?",
"mode": "hybrid",
"limit": 5
})
# β Returns relevant memories with entities and similarity scores
# Multi-hop reasoning
memory_multi_hop_search({
"query": "AI research",
"hops": 2
})
# β Finds memories about AI research
# β Follows entity relationships to find connected memories# List all contexts
curl http://localhost:5000/context
# Get specific context
curl http://localhost:5000/context/mykey
# Set context
curl -X POST http://localhost:5000/context/mykey -d "my value"
# Delete context
curl -X DELETE http://localhost:5000/context/mykey
# View metrics
curl http://localhost:5000/metrics
curl http://localhost:8081/metricsCustom Metrics:
rabbit_published_total- Events published to RabbitMQrabbit_consumed_total- Events consumed by Workerredis_latency_ms- Redis operation latency histogram
Built-in Metrics:
- Runtime instrumentation (GC, memory, threads)
- Process instrumentation (CPU, handles)
- HTTP instrumentation (request duration, status codes)
- Python 3.11+
- MCP SDK - Model Context Protocol implementation
- sentence-transformers - Semantic embeddings (all-MiniLM-L6-v2)
- spaCy - NLP and entity extraction (en_core_web_sm)
- pgvector - Vector similarity search
- psycopg - Async PostgreSQL driver
- PyTorch - ML framework backend
- PostgreSQL 17 + pgvector - Knowledge graph storage
- Redis 7 - Optional caching layer
- RabbitMQ 3 - Optional event streaming (for .NET API)
- .NET 9 with C# 13
- SignalR - Real-time WebSocket updates
- OpenTelemetry - Metrics & tracing
- Prometheus + Grafana - Observability
This project demonstrates:
β Temporal Knowledge Graphs - Entity-relationship models with provenance tracking β Semantic Search - Vector embeddings + pgvector for similarity search β NLP Pipeline - Entity extraction, relationship detection, dependency parsing β Model Context Protocol - STDIO server for AI agent integration β Multi-Hop Reasoning - Graph traversal for complex queries β Local-First ML - No external API dependencies β Clean Architecture - Layered design (DB β Services β Tools β Server) β Async/Await - Fully async Python with connection pooling β Containerization - Docker Compose orchestration
The knowledge graph uses 8 core tables:
- memories - Core episodes with embeddings (vector(384))
- entities - Extracted entities (PERSON, ORG, GPE, DATE, etc.)
- entity_relationships - Relationships between entities
- memory_entities - Many-to-many memoryβentity links
- user_personas - User preferences, skills, background
- conversation_sessions - Session tracking
- integrations + integration_actions - External tool registry
Indexes: pgvector IVFFlat, full-text search (tsvector), foreign keys
| Feature | CORE (getcore.me) | SerialMemoryServer |
|---|---|---|
| Temporal knowledge graph | β | β |
| Semantic search | β | β (pgvector) |
| Entity extraction | β | β (spaCy) |
| Relationship tracking | β | β |
| Multi-hop reasoning | β | β |
| User personas | β | β |
| MCP integration | β | β |
| Open source | β | β |
| Self-hosted | Paid | β Free |
| Local-first (no APIs) | β | β |
| LoCoMo benchmark | 88.24% | Not tested |
- Multi-hop reasoning is partially implemented (traversal logic can be enhanced)
- User persona extraction is rule-based (could be improved with LLM)
- No authentication/authorization (demo purposes)
- Redis integration is optional (can be removed if not needed)
MIT