open-brain-mcp
An MCP server for storing and retrieving thoughts, notes, and ideas with semantic vector search, enabling integration with Claude Desktop and other MCP clients.
README
open-brain-mcp
Ein MCP-Server und CLI-Anwendung zum Speichern von Informationen mit semantischer Vektorsuche. Gedanken, Notizen und Ideen werden gespeichert und auf Anfrage als Kontext zur Verfügung gestellt.
Der MCP-Server ist im Produktionsbetrieb per HTTP erreichbar und kann mit Claude Desktop oder anderen MCP-Clients genutzt werden.
Features
- Semantische Suche: Finde Gedanken nach Bedeutung, nicht nur nach Keywords
- Automatische Metadaten: Extrahiert Typ, Topics, Personen und Action Items via GPT-4o-mini
- MCP-Server: Integration mit Claude Desktop und anderen MCP-Clients
- CLI: Komfortables Kommandozeilen-Interface
- Export/Import: Backup und Restore aller Daten
Tech-Stack
| Komponente | Technologie |
|---|---|
| Sprache | Python 3.11+ |
| MCP-Framework | FastMCP |
| Datenbank | SQLite + sqlite-vec |
| LLM/Embeddings | OpenRouter (GPT-4o-mini, text-embedding-3-small) |
Voraussetzungen
- Python 3.11+
- Ein OpenRouter-API-Key
Installation
Mit pip
# Repository klonen
git clone https://github.com/user/open-brain-mcp.git
cd open-brain-mcp
# Virtuelle Umgebung erstellen
python -m venv .venv
source .venv/bin/activate # Linux/macOS
# oder: .venv\Scripts\activate # Windows
# Installieren
pip install -e .
# Mit Entwicklungs-Dependencies (Tests, Linting)
pip install -e ".[dev]"
sqlite-vec Installation
sqlite-vec wird automatisch als Python-Package installiert und bringt die native Extension mit. Keine manuelle Installation nötig!
Falls dennoch Probleme auftreten:
macOS:
pip install sqlite-vec
Linux:
pip install sqlite-vec
Hinweis: Die native Bibliothek wird automatisch heruntergeladen. Bei Architektur-Problemen kann die Umgebungsvariable SQLITE_VEC_PATH gesetzt werden, um einen alternativen Pfad zur Bibliothek anzugeben.
Konfiguration
Kopiere .env.example zu .env und fülle die Werte aus:
# Pflicht
OPENROUTER_API_KEY=sk-or-your-key-here
# Optional
OPENBRAIN_DB_PATH=./brain.db
OPENROUTER_RATE_LIMIT=2.0
OPENBRAIN_EMBEDDING_DIM=1536
OPENBRAIN_LOG_LEVEL=INFO
Die Datenbank wird beim ersten Start automatisch erstellt.
Schnellstart
Server starten
open-brain --port 4567
# oder: python server.py
Gedanken speichern (CLI)
open-brain add "Ich sollte das Deployment mit GitHub Actions automatisieren."
Suchen (CLI)
open-brain search "Deployment"
Mit Claude Desktop nutzen
Füge zu ~/Library/Application Support/Claude/claude_desktop_config.json hinzu:
{
"mcpServers": {
"open-brain": {
"url": "http://localhost:4567/mcp"
}
}
}
Funktionsweise
add(thought)
Speichert einen neuen Gedanken mit automatisch extrahierten Metadaten:
-
Metadaten-Extraktion: Via
openai/gpt-4o-miniwerden extrahiert:people: Erwähnte Personenaction_items: Implizite To-Dosdates_mentioned: Erwähnte Daten (YYYY-MM-DD)topics: 1-3 kurze Topic-Tagstype:observation,task,idea,referenceoderperson_note
-
Embedding-Erzeugung: Via
openai/text-embedding-3-smallwird ein 1536-dimensionaler Vektor erzeugt. -
Speicherung: Gedanke, Embedding und Metadaten werden in SQLite gespeichert.
search(text)
Semantische Suche nach Bedeutung. Nutzt Vektorähnlichkeit, um relevante Gedanken zu finden.
list_thoughts()
Listet gespeicherte Gedanken mit optionalen Filtern:
type: Nach Typ filterntopic: Nach Topic filternperson: Nach Person filterndays: Nach Zeitraum filtern
stats()
Zeigt Statistiken: Gesamtanzahl, Typen, Top-Topics und Personen.
health()
Health-Check mit Datenbank-Connectivity-Test für Monitoring.
CLI-Referenz
Gedanken speichern
# Direkt
open-brain add "Mein Gedanke..."
# Aus Datei
open-brain add --file notes.txt
# JSON-Ausgabe
open-brain add "Test" --json
Suchen
# Semantische Suche
open-brain search "Suchbegriff"
# Mit Optionen
open-brain search "python" --limit 20 --threshold 0.5
open-brain search "meeting" --json
Auflisten
# Alle Gedanken
open-brain list
# Mit Filtern
open-brain list --type task --days 7
open-brain list --topic python --person "Max"
open-brain list --limit 20 --json
Statistiken
open-brain stats
open-brain stats --json
Export/Import
# Export
open-brain export backup.json
open-brain export backup_full.json --full # inkl. Embeddings
# Import
open-brain import backup.json
open-brain import backup.json --on-conflict replace
MCP-Server
Startoptionen
| Option | Default | Beschreibung |
|---|---|---|
--port |
4567 | HTTP-Port |
--host |
0.0.0.0 | Bind-Adresse |
--key |
- | API-Key für Authentifizierung |
Mit Authentifizierung
open-brain --key mein-geheimes-passwort
Clients müssen dann x-brain-key Header oder ?key= Parameter senden.
Verfügbare Tools
| Tool | Beschreibung |
|---|---|
add(thought) |
Gedanke speichern mit automatischen Metadaten |
search(text, limit?, threshold?) |
Semantische Suche |
list_thoughts(limit?, type?, topic?, person?, days?) |
Auflisten mit Filtern |
stats() |
Statistiken |
health() |
Health-Check mit DB-Connectivity |
Datenbankstruktur
-- Haupttabelle
CREATE TABLE thoughts (
id TEXT PRIMARY KEY,
content TEXT NOT NULL,
metadata TEXT DEFAULT '{}',
created_at TEXT DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
updated_at TEXT DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))
);
-- Vektor-Tabelle (virtuell)
CREATE VIRTUAL TABLE thoughts_vec USING vec0(
rowid INTEGER PRIMARY KEY,
embedding float[1536]
);
Verknüpfung über rowid. Vektorsuche via sqlite-vec (Cosine KNN).
Konfiguration
Umgebungsvariablen
| Variable | Default | Beschreibung |
|---|---|---|
OPENROUTER_API_KEY |
- | Pflicht: OpenRouter API-Key |
OPENBRAIN_DB_PATH |
./brain.db |
Pfad zur SQLite-Datenbank |
OPENROUTER_RATE_LIMIT |
2.0 | API-Calls pro Sekunde |
OPENBRAIN_EMBEDDING_DIM |
1536 | Embedding-Dimension |
OPENBRAIN_LOG_LEVEL |
INFO | Log-Level (DEBUG, INFO, WARNING, ERROR) |
Embedding-Modelle
| Modell | Dimension | Empfehlung |
|---|---|---|
text-embedding-3-small |
1536 | Default, guter Kompromiss |
text-embedding-3-large |
3072 | Höhere Qualität, mehr Kosten |
text-embedding-ada-002 |
1536 | Älteres Modell |
Wichtig: Bei Wechsel der Dimension müssen bestehende Embeddings neu generiert werden!
Entwicklung
Tests ausführen
# Alle Tests
pytest tests/ -v
# Mit Coverage
pytest tests/ -v --cov=. --cov-report=term-missing
Code-Qualität
# Type-Check
mypy *.py
# Linting
ruff check *.py
# Formatierung
ruff format *.py
Projektstruktur
open-brain-mcp/
├── config.py # Konfiguration & Logging
├── db.py # Datenbankschicht
├── ai.py # OpenRouter Integration
├── server.py # MCP-Server
├── cli.py # CLI-Anwendung
├── pyproject.toml # Projekt-Konfiguration
├── tests/ # Test-Suite
│ ├── test_ai.py
│ ├── test_cli.py
│ ├── test_config.py
│ ├── test_db.py
│ └── test_server.py
└── README.md
Technologie-Stack
- FastMCP: MCP-Server Framework
- sqlite-vec: Vektorsuche in SQLite
- OpenRouter: API für Embeddings und LLM
- tenacity: Retry-Logik
Lizenz
MIT
Beitragen
Issues und Pull Requests sind willkommen!
- Fork erstellen
- Feature-Branch:
git checkout -b feature/mein-feature - Commit:
git commit -m 'Add feature' - Push:
git push origin feature/mein-feature - Pull Request öffnen
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.