Skip to content

konepone/open-brain

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 Open Brain

Personal semantic memory system with MCP interface. Store, search, and analyze everything that matters to you.

GitHub Stars Docker License

What is Open Brain?

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.


✨ Features

Core

  • 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

Integrations

  • 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

UI

  • Streamlit Dashboard β€” Visualize memories, stats, and trends
  • Weekly Reports β€” Automated markdown reports

πŸš€ Quick Start

Prerequisites

  • Docker + Docker Compose
  • At least 2GB RAM
  • (Optional) OpenRouter API key for embeddings

1. Clone & Configure

git clone https://github.com/benclawbot/open-brain.git
cd open-brain

# Copy environment file
cp .env.example .env

2. Set Environment Variables

Edit .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.

3. Start Everything

docker compose up -d

4. Access Services

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

πŸ”§ Configuration

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

Embedder Providers

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

πŸ“‘ Usage

CLI

# 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 serve

MCP Tools

Connect any MCP client to http://localhost:8080:

# Example: Using memory_search
{
  "name": "memory_search",
  "arguments": {
    "query": "trading strategies",
    "limit": 5,
    "sources": ["telegram", "claude"]
  }
}

REST API

# 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

πŸ— Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        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          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Components

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

πŸ“ Project Structure

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

πŸ”Œ Source Connectors

Telegram

from src.connectors.telegram import TelegramImporter

importer = TelegramImporter(
    export_file="telegram_export.json"
)
importer.import_all(db_conn)

WhatsApp

from src.connectors.whatsapp import WhatsAppImporter

importer = WhatsAppImporter(
    export_file="whatsapp_chat.txt"
)
importer.import_all(db_conn)

Claude Code

from src.connectors.claude_code import ClaudeCodeImporter

importer = ClaudeCodeImporter(
    sessions_path="~/.claude/sessions"
)
importer.import_all(db_conn)

Gmail

from src.connectors.gmail import GmailImporter

importer = GmailImporter(
    takeout_path="./mail"
)
importer.import_all(db_conn)

πŸ“Š Analytics

Trend Detection

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

Weekly Reports

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

πŸ”” Notifications

Telegram Alerts

  • New emerging trends
  • Weekly reports
  • Memory stats summaries

Email

  • Daily digests
  • Weekly reports
  • Anomaly alerts

🐳 Docker Services

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

πŸ€– Phone Installation (ARM)

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


πŸ§ͺ Testing

# Run tests
pytest tests/

# Test MCP connection
python -c "from src.main import mcp; print(mcp)"

πŸ“ License

MIT License β€” do whatever you want with it.


πŸ™ Acknowledgments


πŸ”— Links

About

Personal semantic memory system with MCP interface - PostgreSQL + pgvector

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 96.0%
  • Shell 2.5%
  • PLpgSQL 1.2%
  • Dockerfile 0.3%