Personal semantic memory system with MCP interface. Store, search, and analyze everything that matters to you.
Open Brain is a personal knowledge management system that acts as your second brain. It:
- π₯ Ingests data from anywhere (Telegram, WhatsApp, Claude Code, Gmail, files)
- π§ Embeds everything semantically (OpenRouter, OpenAI, Ollama, or any custom API)
- π Searches instantly using vector similarity
- π Analyzes trends, clusters, and connections
- π Notifies you of important changes
- π Serves via MCP, REST API, CLI, or Dashboard
Think of it as Obsidian meets ChatGPT memory β but accessible from any tool.
- Semantic Search β Find memories by meaning, not just keywords
- Auto-Tagging β Automatic topic and entity extraction
- Entity Recognition β Extracts people, places, organizations, dates
- Trend Analysis β See what topics are emerging or declining
- MCP Server β Use from Claude, Codex, or any MCP client
- REST API β HTTP access for any application
- CLI β Command-line interface for quick operations
- Source Connectors β Import from Telegram, WhatsApp, Gmail, Claude Code
- Streamlit Dashboard β Visualize memories, stats, and trends
- Weekly Reports β Automated markdown reports
- Docker + Docker Compose
- At least 2GB RAM
- (Optional) OpenRouter API key for embeddings
git clone https://github.com/benclawbot/open-brain.git
cd open-brain
# Copy environment file
cp .env.example .envEdit .env:
# Database
DB_PASSWORD=your_secure_password
# Embeddings (OpenRouter = FREE)
OPENROUTER_API_KEY=your_openrouter_key
# Optional: Telegram notifications
TELEGRAM_BOT_TOKEN=
TELEGRAM_CHAT_ID=No API key? OpenRouter has a free tier. Just sign up at openrouter.ai.
docker compose up -d| Service | URL | Description |
|---|---|---|
| Dashboard | http://localhost:8501 | Streamlit UI |
| MCP Server | http://localhost:8080 | MCP protocol |
| REST API | http://localhost:8000 | HTTP API |
| API Docs | http://localhost:8000/docs | Swagger docs |
All settings in config/settings.yaml:
database:
host: postgres
port: 5432
name: openbrain
user: postgres
password: ${DB_PASSWORD}
embedder:
# Providers: openrouter, openai, ollama, custom
provider: openrouter
model: text-embedding-3-small
dimensions: 768
mcp:
host: 0.0.0.0
port: 8080
api:
host: 0.0.0.0
port: 8000
dashboard:
port: 8501| Provider | Env Variable | Notes |
|---|---|---|
| OpenRouter (default) | OPENROUTER_API_KEY |
Free tier available |
| OpenAI | OPENAI_API_KEY |
Paid |
| Ollama | OLLAMA_BASE_URL |
Local, free |
| Custom | CUSTOM_API_URL + CUSTOM_API_KEY |
Any OpenAI-compatible |
# Install
pip install -e .
# Search memories
openbrain search "what did I learn about AI"
# Store a memory
openbrain store "Meeting with Oliver about trading bot" --source telegram --tags ai,trading
# Show stats
openbrain stats
# Generate weekly report
openbrain report
# Start API server
openbrain serveConnect any MCP client to http://localhost:8080:
# Example: Using memory_search
{
"name": "memory_search",
"arguments": {
"query": "trading strategies",
"limit": 5,
"sources": ["telegram", "claude"]
}
}# Search
curl -X POST http://localhost:8000/memories/search \
-H "Content-Type: application/json" \
-d '{"query": "AI agents", "limit": 5}'
# Store
curl -X POST http://localhost:8000/memories \
-H "Content-Type: application/json" \
-d '{"content": "New idea", "source": "manual"}'
# Stats
curl http://localhost:8000/statsβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Clients β
β Claude Code | Codex | OpenClaw | Custom Apps | CLI β
βββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ
β MCP / HTTP / CLI
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Open Brain β
β βββββββββββββββ ββββββββββββββββ ββββββββββββββββββββ β
β β MCP API β β REST API β β CLI Tools β β
β βββββββββββββββ ββββββββββββββββ ββββββββββββββββββββ β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Application Layer β β
β β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β β
β β βExtractorsβ β Tagger β βAnalytics β β Notifier β β β
β β β (Entitiesβ β (Auto-tagβ β (Trends) β β(Telegram)β β β
β β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Embedder (Multi-Provider) β β
β β OpenRouter | OpenAI | Ollama | Custom β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββ
β PostgreSQL + pgvector β
β memory table with vector embeddings, GIN indexes β
β for tags/entities, IVFFlat for similarity search β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Component | Technology | Purpose |
|---|---|---|
| Database | PostgreSQL + pgvector | Storage + vector search |
| MCP Server | FastMCP | Tool interface for AI agents |
| REST API | FastAPI | HTTP access |
| CLI | Click | Terminal commands |
| Dashboard | Streamlit | Visual UI |
| Embedder | requests | Multi-provider embeddings |
| Extractors | NLTK/spaCy | Entity extraction |
open-brain/
βββ config/
β βββ settings.yaml # Configuration
βββ src/
β βββ main.py # MCP server entry
β βββ db/ # Database layer
β β βββ schema.sql
β β βββ connection.py
β β βββ queries.py
β βββ embedder/ # Multi-provider embeddings
β βββ extractors/ # NER + tagging
β βββ analytics/ # Trends + reports
β βββ connectors/ # Source importers
β βββ cli/ # CLI commands
β βββ api/ # REST API
β βββ notifications/ # Telegram + email
β βββ ingestion/ # Bulk import
βββ ui/
β βββ dashboard.py # Streamlit dashboard
βββ scripts/
β βββ setup_db.py # Database setup
β βββ backup.sh # Automated backups
β βββ healthcheck.sh # Health monitoring
βββ tests/
β βββ test_core.py
βββ docker-compose.yml # Full stack
βββ Dockerfile # App container
βββ pyproject.toml # CLI package
βββ requirements.txt # Python deps
βββ README.md
from src.connectors.telegram import TelegramImporter
importer = TelegramImporter(
export_file="telegram_export.json"
)
importer.import_all(db_conn)from src.connectors.whatsapp import WhatsAppImporter
importer = WhatsAppImporter(
export_file="whatsapp_chat.txt"
)
importer.import_all(db_conn)from src.connectors.claude_code import ClaudeCodeImporter
importer = ClaudeCodeImporter(
sessions_path="~/.claude/sessions"
)
importer.import_all(db_conn)from src.connectors.gmail import GmailImporter
importer = GmailImporter(
takeout_path="./mail"
)
importer.import_all(db_conn)Automatically detects:
- Emerging topics β Tags increasing >50% vs baseline
- Declining topics β Tags dropping >30%
- New entities β People/places appearing for first time
- Co-occurrence β Topics that appear together
Generated every Sunday via cron:
# Weekly Memory Report
### Activity
- New memories: 47
- By source: telegram: 23, claude: 15, manual: 9
### What's Hot
- ai: +200% (15 mentions)
- trading: +50% (8 mentions)
### Insights
- You're researching AI agents heavily this week
- Oliver appeared 5 times β significant collaboration- New emerging trends
- Weekly reports
- Memory stats summaries
- Daily digests
- Weekly reports
- Anomaly alerts
| Service | Image | Ports |
|---|---|---|
| postgres | pgvector/pgvector:0.5.1 | 5432 |
| api | benclawbot/open-brain | 8000 |
| dashboard | benclawbot/open-brain | 8501 |
| mcp | benclawbot/open-brain | 8080 |
For running on an old Android phone converted to Linux:
# Use ARM-compatible images
docker-compose -f docker-compose.arm.yml up -d
# Or build locally on phone
docker build --platform=linux/arm64 .Resources: ~500MB RAM, ~1GB storage
# Run tests
pytest tests/
# Test MCP connection
python -c "from src.main import mcp; print(mcp)"MIT License β do whatever you want with it.
- pgvector β Vector similarity for PostgreSQL
- FastMCP β MCP framework
- OpenRouter β Free embedding API