A next-generation Knowledge Management System MCP server that intelligently routes knowledge to optimal storage systems with sub-100ms FACT caching.
The unified_store tool is the brain of the system that automatically decides where to store each piece of knowledge:
-
Content Analysis: AI analyzes text patterns:
"Client prefers morning sessions"β Mem0 (memory pattern)"Reframing technique effective for anxiety"β Neo4j (relationship/insight)"Session config: duration 60min"β MongoDB (structured data)
-
Storage Decision: Returns intelligent routing:
{ "primary": "mem0", "secondary": ["mongodb"], "reasoning": "Memory patterns optimize for Mem0 semantic search", "cacheStrategy": "L1" } -
Multi-System Storage: Stores in primary + secondary for redundancy
-
FACT Caching: Caches based on importance (richard_yaker = L1, coaching = L2, general = L3)
- π§ Intelligent Storage Routing: AI decides optimal storage system
- β‘ FACT Caching: 3-layer cache for sub-100ms responses
- π Cross-System Linking: Automatic data relationships
- π― Unified API: 6 powerful tools instead of separate servers
- π Analytics: Comprehensive performance monitoring
- π‘οΈ Error Resilience: Graceful degradation when systems are offline
- π Remote MCP Support: HTTP/SSE transport for remote access
- π OAuth 2.1 Authentication: Secure access with JWT and token introspection
- π¦ Rate Limiting & CORS: Production-ready security features
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Mem0 Storage β β Neo4j Storage β β MongoDB Storage β
β (Memories) β β (Relationships) β β (Structured) β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β β β
βββββββββββββββββββββββββΌββββββββββββββββββββββββ
β
βββββββββββββββββββββββ
β Intelligent Router β
β (Pattern Matching) β
βββββββββββββββββββββββ
β
βββββββββββββββββββββββ
β FACT Cache β
β L1βL2βL3βDatabase β
βββββββββββββββββββββββ
β
βββββββββββββββββββββββ
β Unified MCP API β
β 6 Tools β
βββββββββββββββββββββββ
This unified KMS requires four cloud services for optimal performance. We recommend using managed services (PAAS) for reliability and scalability:
What it does: Semantic memory storage with natural language understanding
Get it: Sign up at Mem0 - Free tier available
Need: API key from your dashboard
What it does: Stores relationships between concepts and insights
Get it: Neo4j Aura (Cloud) - Free tier with 50k nodes
Need: Connection URI, username, password
What it does: Document storage for structured data and configurations
Get it: MongoDB Atlas - Free 512MB cluster
Need: Connection string (mongodb+srv://...)
What it does: Fast caching layer for sub-100ms responses
Get it: Redis Cloud or Upstash - Free tiers available
Need: Connection URI (redis://... or rediss://...)
π‘ Pro Tip: All these services offer generous free tiers perfect for getting started. You can upgrade as your knowledge base grows!
# Clone and install
cd /Volumes/Dev/localDev/KMSmcp
npm install
# Configure environment
cp .env.example .env
# Edit .env with your service credentials (see Prerequisites above)
# Build
npm run build
# Development
npm run dev
# Production
npm startAdd to your Claude Code configuration:
{
"mcpServers": {
"personal-kms": {
"type": "http",
"url": "https://your-kms-server.com/mcp"
}
}
}- Go to Settings β MCP Connectors
- Click "Add custom connector"
- Enter:
- Name:
personal-kms - Remote MCP server URL:
https://your-kms-server.com/mcp
- Name:
- Click "Add"
The server supports three transport modes:
Traditional MCP for local use with Claude Desktop:
TRANSPORT_MODE=stdioRemote MCP server accessible via HTTP/REST:
TRANSPORT_MODE=http
HTTP_PORT=3001
HTTP_HOST=0.0.0.0Both STDIO and HTTP simultaneously:
TRANSPORT_MODE=dual
HTTP_PORT=3001
HTTP_HOST=0.0.0.0For secure remote access, enable OAuth 2.1:
# Enable OAuth
OAUTH_ENABLED=true
OAUTH_ISSUER=https://your-auth-server.com
OAUTH_AUDIENCE=https://your-mcp-server.com
# Token validation (choose one)
OAUTH_JWKS_URI=https://your-auth-server.com/.well-known/jwks.json
# OR
OAUTH_TOKEN_INTROSPECTION_ENDPOINT=https://your-auth-server.com/oauth/introspect
# Optional: Client credentials for introspection
OAUTH_CLIENT_ID=your-client-id
OAUTH_CLIENT_SECRET=your-client-secretCore Configuration:
MEM0_API_KEY: Your Mem0 API key (required)MONGODB_URI: MongoDB connection stringNEO4J_URI,NEO4J_USERNAME,NEO4J_PASSWORD: Neo4j credentialsREDIS_URI: Redis connection for L2 cache
HTTP Transport (if enabled):
HTTP_PORT: Server port (default: 3001)HTTP_HOST: Bind address (default: 0.0.0.0)
OAuth (if enabled):
OAUTH_ISSUER: Authorization server URLOAUTH_AUDIENCE: MCP server resource identifier
{
"name": "unified_store",
"params": {
"content": "Client responds well to morning meditation sessions",
"contentType": "memory",
"source": "coaching",
"userId": "client_123",
"confidence": 0.9
}
}{
"name": "unified_search",
"params": {
"query": "meditation techniques anxiety",
"filters": {
"contentType": ["insight", "memory"],
"minConfidence": 0.7
},
"options": {
"maxResults": 10,
"cacheStrategy": "conservative"
}
}
}{
"name": "get_storage_recommendation",
"params": {
"content": "Bug fix: authentication middleware timeout issue"
}
}{
"name": "get_kms_analytics",
"params": {
"timeRange": "24h",
"includeCache": true
}
}{
"name": "cache_invalidate",
"params": {
"pattern": "user:richard_yaker",
"level": "all"
}
}{
"name": "test_routing",
"params": {
"runTests": true
}
}- Deploy unified server alongside existing MCP servers
- Start using unified tools for new knowledge
- Existing data remains accessible
- Use built-in sync tools to migrate existing data
- Validate data integrity across systems
- Test performance improvements
- Retire individual MCP servers
- Optimize cache settings
- Enable cross-coach learning features
- β Sub-100ms responses via FACT caching
- β Intelligent routing based on content analysis
- β Cross-system redundancy for data safety
- β Graceful degradation when systems are offline
- β Real-time analytics for optimization
When HTTP transport is enabled, the server exposes these endpoints:
POST /mcp- MCP JSON-RPC endpointGET /mcp/events- Server-Sent Events for real-time updatesGET /health- Health check endpoint
GET /.well-known/oauth-protected-resource- OAuth resource metadata
# Health check
curl http://localhost:3001/health
# MCP request (with OAuth)
curl -X POST http://localhost:3001/mcp \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/list",
"id": 1
}'
# Tool call
curl -X POST http://localhost:3001/mcp \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "unified_store",
"arguments": {
"content": "Client responds well to morning meditation sessions",
"contentType": "memory",
"source": "coaching"
}
},
"id": 2
}'Run the comprehensive test suite:
# Install dependencies
npm install
# Run unit tests
npm test
# Run tests with coverage
npm run test:coverage
# Run specific test suites
npm test -- --testPathPattern=OAuth2Authenticator
npm test -- --testPathPattern=HttpTransport// Store a coaching insight
const result = await unified_store({
content: "Client shows 40% improvement with morning routine consistency",
contentType: "insight",
source: "coaching",
coachId: "sophia",
confidence: 0.85
});
// Search across all systems
const results = await unified_search({
query: "morning routine effectiveness",
filters: { contentType: ["insight", "pattern"] },
options: { cacheStrategy: "aggressive" }
});
// Get storage recommendation
const recommendation = await get_storage_recommendation({
content: "User authentication session expired"
});The unified KMS creates intelligent, learning coaching systems that:
- Remember everything about each client
- Discover effective techniques automatically
- Share insights across coaches
- Respond in sub-100ms
- Continuously improve from every interaction
Your AI coaches become extensions of human expertise that grow smarter over time! π§ β¨
MIT - Build amazing coaching platforms!