mcp-ai-brain
README.md
# π§ mcp-ai-brain
> **Persistent memory for AI coding agents.** Local-first. Zero API costs. Works everywhere.
AI agents forget everything between sessions. **mcp-ai-brain** fixes that.
A [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server that gives your AI agent a persistent, searchable, privacy-first memory β powered by SQLite, FTS5, and biological-inspired decay.
---
## β¨ Features
| Feature | Description |
|---------|-------------|
| π **Hybrid Search** | Keyword (FTS5) + local vector embeddings via `all-MiniLM-L6-v2`, fused with RRF |
| 𧬠**Memory Decay** | Ebbinghaus-inspired forgetting curve β unused memories lose relevance, critical ones never fade |
| π **Project Scoping** | Memories are scoped to projects β your web app context stays separate from your CLI tool context |
| π **Privacy-First** | Everything stays on your machine. No cloud. No API calls. Your `brain.db` never leaves `~/.mcp-ai-brain/` |
| β‘ **Zero Cost** | No embeddings API needed. Runs `all-MiniLM-L6-v2` locally via `@xenova/transformers` (~25MB, downloads once) |
| π€ **Auto-Learning** | `brain_session_end` extracts facts automatically from your session summary. No manual `remember` calls needed |
| π― **Proactive Context** | `brain_session_start_smart` detects your workspace and loads the right memories automatically |
| π **Dashboard** | Built-in web dashboard at `localhost:3333` β view, search, edit memories in real-time |
| π **Universal** | Works with Claude Desktop, Cursor, Windsurf, Cline, Antigravity, and any MCP-compatible tool |
---
## π Quick Start
### Install
```bash
npm install -g mcp-ai-brain
```
### Configure your AI tool
Add to your MCP config (e.g., `claude_desktop_config.json`, `.cursor/mcp.json`):
```json
{
"mcpServers": {
"brain": {
"command": "mcp-ai-brain"
}
}
}
```
That's it. Your AI now has a brain. π§
---
## π οΈ Tools
### `brain_remember`
Store a memory. Supports categorization, tagging, importance levels, and project scoping.
```
Categories: fact | decision | preference | architecture | bug | config | pattern | incident | workflow
Importance: critical (never decays) | high | normal | low
```
### `brain_recall`
Retrieve memories by project, category, or importance β without needing a search query.
### `brain_search`
Hybrid search using keyword matching (FTS5) + local vector embeddings (`all-MiniLM-L6-v2`). Results fused with Reciprocal Rank Fusion β semantic similarity works out of the box once the model downloads (~25MB, one-time).
### `brain_forget`
Soft-delete a memory. It's excluded from search but can be restored.
### `brain_session_start`
Start a session β loads top memories for your project, runs decay maintenance, and returns context.
### `brain_session_end`
End a session β records what happened and for how long.
### `brain_projects_*`
Manage the project registry (`list`, `upsert`, `get`, `delete`).
### `brain_stats`
Brain diagnostics β memory counts, category breakdown, database path, vector status.
---
## 𧬠How Decay Works
Memories follow a biological forgetting curve:
1. **Grace Period** (7 days): No decay. Fresh memories stay at full strength.
2. **Active Decay**: Score decreases based on importance weight and time since last access.
3. **Access Resets Clock**: Every time a memory is recalled or found in search, its decay resets.
4. **Critical = Permanent**: Set importance to `critical` and the memory never decays.
5. **Decayed β Deleted**: Decayed memories can be restored with `brain_restore`.
---
## βοΈ Configuration
| Environment Variable | Default | Description |
|---|---|---|
| `BRAIN_DB_PATH` | `~/.mcp-ai-brain/brain.db` | Custom database file location |
---
## ποΈ Architecture
```
βββββββββββββββββββββββββββββββββββ
β AI Agent (Claude, etc.) β
β via MCP Protocol β
ββββββββββββββ¬βββββββββββββββββββββ
β stdio
ββββββββββββββΌβββββββββββββββββββββ
β mcp-ai-brain server β
β ββββββββββββ βββββββββββββββ β
β β FTS5 β β MiniLM-L6v2 β β
β β (keyword)β β (local vec) β β
β ββββββ¬ββββββ ββββββββ¬βββββββ β
β β RRF Fusion β β
β βββββββββ¬βββββββββ β
β βββββββΌβββββββ β
β β SQLite DB β β
β β brain.db β β
β ββββββββββββββ β
β ββββββββββββββββββββββββββββ β
β β Decay Engine β β
β β (Ebbinghaus curve) β β
β ββββββββββββββββββββββββββββ β
β ββββββββββββββββββββββββββββ β
β β Auto-Learning (v1.1) β β
β β Session summary β facts β β
β ββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββ
```
---
## π What Your AI Agent Should Remember
| Category | Example |
|----------|---------|
| `decision` | "We chose NextJS over Remix because of Vercel deployment simplicity" |
| `architecture` | "Auth flow: Firebase Auth β Custom Claims β Middleware guard" |
| `config` | "Cron schedule: */10 * * * * (every 10 min, Vercel 300s timeout)" |
| `bug` | "Safari iOS AudioContext requires user gesture β fixed with click handler" |
| `pattern` | "All Firestore writes use transactions for multi-tenant isolation" |
| `preference` | "User prefers dark mode UI with Inter font family" |
| `incident` | "2024-01-15: Stripe webhook double-firing caused duplicate charges" |
---
## πΊοΈ Roadmap
- [x] v1.0 β Core memory + keyword search (FTS5) + Ebbinghaus decay engine
- [x] v1.1 β Local embeddings (`all-MiniLM-L6-v2` via `@xenova/transformers`) + Auto-Learning + Proactive Context + Web Dashboard
- [ ] v1.2 β Multi-agent support + relationship graph between memories
- [ ] v2.0 β Proactive suggestions + memory consolidation + export/import
---
## π€ Contributing
PRs welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
---
## π License
MIT β see [LICENSE](LICENSE).
---
---
## π Built With This
Real-world projects powered by `mcp-ai-brain` β demonstrating persistent AI memory in production:
| Project | What It Does |
|---------|-------------|
| π€ [Ace Your Interviews](https://aceyourinterviews.app) | AI-powered real-time voice mock interviews β the only tool that simulates a real phone screen |
| π [GeoQuote.ai](https://geoquote.ai) | Instant contractor quoting platform β real-time pricing intelligence for homeowners |
| π [The Funny Christmas Shop](https://thefunnychristmas.shop) | Hilarious holiday t-shirts with AI-generated designs, updated daily |
| π [ChairFull.org](https://chairfull.org) | Office chair reviews and buying guides β AI-researched, human-curated |
| π° [VaultNest.org](https://vaultnest.org) | Personal finance guides β savings, investing, and financial independence |
| π [FleetShield.org](https://fleetshield.org) | Commercial trucking insurance guides for fleet owners |
| βοΈ [DutyPilot.org](https://dutypilot.org) | Import duty and customs tariff guides for international shoppers |
| π [ManualJPro.org](https://manualjpro.org) | Product manual library β user guides and instruction manuals |
| π [Should I Buy It](https://sibt.ca) | AI buying-intent analysis β know before you spend |
> Want your project listed here? Open a PR and add it to this table.
---
## π€ About the Author
Built and maintained by **[Pravin Nawkar](https://github.com/nawkarpravinp-bit)** β a developer building AI-powered SaaS tools and content platforms.
---
<p align="center">
<b>Built with β€οΈ to give AI agents the memory they deserve.</b>
</p>
This server cannot be deployed
Maintenance
ActivityInactive
ResponsivenessNo issues