OpenKai
OpenKai is an open-source MCP server that gives AI agents persistent memory across conversations, supporting core, long-term, short-term, episodic, and working memory types with goals, emotional intelligence, and temporal queries.
README
OpenKai
An open-source personal memory system for AI agents via MCP
What is OpenKai?
OpenKai is a PostgreSQL + SQLite hybrid MCP (Model Context Protocol) server that gives AI agents persistent memory across conversations. It remembers who you are, what you've talked about, your goals, emotions, and more.
Built as an MCP server, it integrates directly with Claude Desktop and any MCP-compatible client.
Key Features
- 51 MCP tools for comprehensive memory management
- 5 memory types: Core, Long-term, Short-term, Episodic, Working
- Goals & Projects tracking with milestones and progress
- Emotional Intelligence - tag and query memories by emotion
- Temporal Queries - "what did we discuss last week?"
- Memory Consolidation - automatically promotes important short-term memories
- Reflection Engine - finds contradictions and consolidation opportunities
- Memory Reinforcement - tracks access patterns and strengthens connections
- PostgreSQL for persistent storage, SQLite for fast in-memory caching
- Bun runtime for 20x faster startup than Node.js
Quick Start
Prerequisites
- Bun 1.2+ (JavaScript runtime)
- Docker Desktop (for PostgreSQL)
- Claude Desktop or any MCP-compatible client
Installation
# 1. Clone the repository
git clone https://github.com/yourusername/openkai.git
cd openkai
# 2. Install dependencies
bun install
# 3. Copy environment template and set your password
cp .env.example .env
# Edit .env and set POSTGRES_PASSWORD to a secure value
# 4. Start PostgreSQL
cd docker && POSTGRES_PASSWORD=yourpassword POSTGRES_PORT=5433 docker compose up -d postgres
cd ..
# 5. Start the MCP server
bun start
Development Commands
bun start # Start MCP server
bun run dev # Start with hot reload
bun run health # Health check
bun test # Run tests
bun run docker:up # Start Docker containers
bun run docker:down # Stop Docker containers
Claude Desktop Configuration
Add to your Claude Desktop config file:
- Windows:
%APPDATA%\Claude\claude_desktop_config.json - macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"openkai": {
"command": "bun",
"args": ["/path/to/openkai/src/server/index.js"],
"env": {
"POSTGRES_HOST": "localhost",
"POSTGRES_PORT": "5433",
"POSTGRES_DB": "kai",
"POSTGRES_USER": "postgres",
"POSTGRES_PASSWORD": "your-password-here",
"CACHE_BACKEND": "sqlite",
"REDIS_OPTIONAL": "true",
"NODE_ENV": "development",
"LOG_LEVEL": "info"
}
}
}
}
Replace /path/to/openkai/ with your actual installation path.
Memory Types
| Type | Description | Persistence |
|---|---|---|
| Core | Permanent memories (name, identity, key facts) | Never expires |
| Long-term | Categorized memories with importance & strength | Never expires |
| Short-term | Temporary memories with configurable expiration | TTL-based |
| Episodic | Conversation summaries with key points & decisions | Never expires |
| Working | Session scratchpad for active work | Session-based |
MCP Tools (51 total)
Core Memory (3)
save_core_memory, update_core_memory, delete_core_memory
Long-term Memory (3)
save_long_term_memory, update_long_term_memory, delete_long_term_memory
Short-term Memory (2)
save_short_term_memory, delete_short_term_memory
Utility (5)
load_complete_memory, search_memories, get_memory_statistics, cleanup_expired_memories, apply_importance_decay
Episodic Memory (3)
save_episodic_memory, get_episodic_memories, search_episodes
Working Memory / Scratchpad (4)
save_to_scratchpad, get_from_scratchpad, get_full_scratchpad, clear_scratchpad
Reflection Engine (3)
reflect_on_memories, get_unresolved_findings, resolve_finding
Memory Reinforcement (3)
reinforce_memory, get_memory_health, apply_memory_maintenance
Goals & Projects (10)
create_goal, update_goal, update_goal_progress, get_active_goals, get_goal_details, add_goal_milestone, complete_milestone, log_goal_activity, get_neglected_goals, get_goal_stats
Temporal Queries (4)
get_memories_by_time, get_date_summary, get_weekly_summary, get_activity_timeline
Emotional Intelligence (5)
tag_memory_emotion, get_memories_by_emotion, get_emotional_distribution, get_emotional_trend, auto_tag_emotions
Memory Consolidation (5)
run_memory_consolidation, get_promotion_candidates, promote_memory, get_consolidation_stats, strengthen_connections
Architecture
┌─────────────────────────────────────────────┐
│ MCP Client (Claude Desktop) │
└──────────────────┬──────────────────────────┘
│ stdio
v
┌─────────────────────────────────────────────┐
│ OpenKai MCP Server (Bun) │
│ ┌────────────┐ ┌────────────────────────┐ │
│ │ MCP Tools │ │ Memory Modules │ │
│ │ (51 tools) │ │ core, longterm, short │ │
│ │ │ │ episodic, working │ │
│ │ │ │ goals, emotions │ │
│ │ │ │ temporal, consolidation│ │
│ │ │ │ reflection, reinforce │ │
│ └────────────┘ └────────────────────────┘ │
└──────────┬──────────────────┬───────────────┘
│ │
v v
┌──────────────────┐ ┌──────────────────┐
│ PostgreSQL 15 │ │ SQLite Cache │
│ (Persistent) │ │ (In-memory) │
│ Port 5433 │ │ Fast reads │
└──────────────────┘ └──────────────────┘
Project Structure
openkai/
├── src/server/
│ ├── index.js # MCP server entry point
│ ├── config.js # Environment configuration
│ ├── database/
│ │ ├── postgres.js # PostgreSQL connection & queries
│ │ └── sqlite-cache.js # SQLite in-memory cache
│ ├── memory/
│ │ ├── core.js # Core memory CRUD
│ │ ├── longterm.js # Long-term memory CRUD
│ │ ├── shortterm.js # Short-term memory CRUD
│ │ ├── episodic.js # Conversation summaries
│ │ ├── working.js # Working memory scratchpad
│ │ ├── goals.js # Goals & projects tracking
│ │ ├── emotions.js # Emotional intelligence
│ │ ├── temporal.js # Temporal queries
│ │ ├── consolidation.js # Memory consolidation
│ │ ├── reflection.js # Reflection engine
│ │ └── reinforcement.js # Memory reinforcement
│ ├── tools/
│ │ ├── index.js # Base tool registry
│ │ └── v5-tools.js # Extended tool definitions
│ └── utils/
│ ├── logger.js # Logging
│ ├── errors.js # Custom errors
│ └── validation.js # Input validation
├── docker/
│ ├── docker-compose.yml # PostgreSQL container
│ └── postgres/init.sql # Database schema
├── scripts/ # Operational scripts
├── config/ # Configuration templates
├── .env.example # Environment template
└── package.json # Bun dependencies
Configuration
All configuration is via environment variables (.env file). See .env.example for the full template.
Required Settings
POSTGRES_HOST=localhost
POSTGRES_PORT=5433
POSTGRES_DB=kai
POSTGRES_USER=postgres
POSTGRES_PASSWORD=your-secure-password
Optional Settings
CACHE_BACKEND=sqlite # SQLite in-memory cache (default)
REDIS_OPTIONAL=true # Redis is optional/legacy
NODE_ENV=development
LOG_LEVEL=info
Database Schema
PostgreSQL tables:
kai_core_memories- Permanent memorieskai_long_term_memories- Categorized memories with strength ratingskai_short_term_memories- Temporary memories with expirationkai_episodic_memories- Conversation summarieskai_working_memory- Session scratchpadkai_goals- Goals and projectskai_goal_milestones- Goal checkpointskai_goal_activities- Goal activity logkai_reflection_log- Reflection findingskai_memory_access_log- Access analyticskai_memory_connections- Memory relationship graphkai_emergent_patterns- Pattern discoverykai_consolidation_log- Consolidation historykai_temporal_context- Daily context summarieskai_system_metadata- Schema version and system state
See docker/postgres/init.sql for the complete schema.
Troubleshooting
PostgreSQL won't start
# Check if port 5433 is in use
docker ps | grep 5433
# Start postgres only
cd docker && POSTGRES_PASSWORD=yourpassword POSTGRES_PORT=5433 docker compose up -d postgres
MCP client can't connect
- Make sure
kai-postgresis running:docker ps --filter "name=kai-postgres" - Verify
bunis installed:bun --version - Check the path in your MCP client config points to
src/server/index.js - Restart your MCP client after config changes
Health check
bun run health
Contributing
See CONTRIBUTING.md for guidelines on how to contribute.
License
OpenKai v1.0.0 | Powered by Model Context Protocol | PostgreSQL | Bun
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.