brain-mcp 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. brain_mcp-0.1.0/LICENSE +21 -0
  2. brain_mcp-0.1.0/PKG-INFO +374 -0
  3. brain_mcp-0.1.0/README.md +338 -0
  4. brain_mcp-0.1.0/brain_mcp/__init__.py +2 -0
  5. brain_mcp-0.1.0/brain_mcp/cli.py +431 -0
  6. brain_mcp-0.1.0/brain_mcp/config.py +286 -0
  7. brain_mcp-0.1.0/brain_mcp/embed/__init__.py +1 -0
  8. brain_mcp-0.1.0/brain_mcp/embed/embed.py +251 -0
  9. brain_mcp-0.1.0/brain_mcp/ingest/__init__.py +59 -0
  10. brain_mcp-0.1.0/brain_mcp/ingest/chatgpt.py +183 -0
  11. brain_mcp-0.1.0/brain_mcp/ingest/claude_code.py +175 -0
  12. brain_mcp-0.1.0/brain_mcp/ingest/clawdbot.py +132 -0
  13. brain_mcp-0.1.0/brain_mcp/ingest/generic.py +174 -0
  14. brain_mcp-0.1.0/brain_mcp/ingest/noise_filter.py +95 -0
  15. brain_mcp-0.1.0/brain_mcp/ingest/schema.py +128 -0
  16. brain_mcp-0.1.0/brain_mcp/server/__init__.py +1 -0
  17. brain_mcp-0.1.0/brain_mcp/server/__main__.py +13 -0
  18. brain_mcp-0.1.0/brain_mcp/server/db.py +314 -0
  19. brain_mcp-0.1.0/brain_mcp/server/server.py +192 -0
  20. brain_mcp-0.1.0/brain_mcp/server/tools_analytics.py +427 -0
  21. brain_mcp-0.1.0/brain_mcp/server/tools_conversations.py +127 -0
  22. brain_mcp-0.1.0/brain_mcp/server/tools_github.py +381 -0
  23. brain_mcp-0.1.0/brain_mcp/server/tools_prosthetic.py +1105 -0
  24. brain_mcp-0.1.0/brain_mcp/server/tools_search.py +631 -0
  25. brain_mcp-0.1.0/brain_mcp/server/tools_stats.py +420 -0
  26. brain_mcp-0.1.0/brain_mcp/server/tools_synthesis.py +623 -0
  27. brain_mcp-0.1.0/brain_mcp/summarize/__init__.py +1 -0
  28. brain_mcp-0.1.0/brain_mcp/summarize/summarize.py +460 -0
  29. brain_mcp-0.1.0/brain_mcp/sync.py +3 -0
  30. brain_mcp-0.1.0/brain_mcp.egg-info/PKG-INFO +374 -0
  31. brain_mcp-0.1.0/brain_mcp.egg-info/SOURCES.txt +36 -0
  32. brain_mcp-0.1.0/brain_mcp.egg-info/dependency_links.txt +1 -0
  33. brain_mcp-0.1.0/brain_mcp.egg-info/entry_points.txt +2 -0
  34. brain_mcp-0.1.0/brain_mcp.egg-info/requires.txt +17 -0
  35. brain_mcp-0.1.0/brain_mcp.egg-info/top_level.txt +1 -0
  36. brain_mcp-0.1.0/pyproject.toml +46 -0
  37. brain_mcp-0.1.0/setup.cfg +4 -0
  38. brain_mcp-0.1.0/tests/test_basic.py +616 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mordechai Potash
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,374 @@
1
+ Metadata-Version: 2.4
2
+ Name: brain-mcp
3
+ Version: 0.1.0
4
+ Summary: Turn your AI conversations into a searchable second brain with cognitive prosthetic tools
5
+ Author: Mordechai Potash
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/mordechaipotash/brain-mcp
8
+ Project-URL: Documentation, https://brainmcp.dev
9
+ Project-URL: Repository, https://github.com/mordechaipotash/brain-mcp
10
+ Keywords: mcp,brain,ai,conversations,search,cognitive,prosthetic
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
+ Requires-Python: >=3.11
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: mcp>=1.0
21
+ Requires-Dist: lancedb>=0.20
22
+ Requires-Dist: duckdb>=1.0
23
+ Requires-Dist: pandas>=2.0
24
+ Requires-Dist: pyarrow>=15.0
25
+ Requires-Dist: sentence-transformers>=2.0
26
+ Requires-Dist: pyyaml
27
+ Requires-Dist: rich>=13.0
28
+ Provides-Extra: summarize
29
+ Requires-Dist: anthropic>=0.40; extra == "summarize"
30
+ Requires-Dist: openai>=1.0; extra == "summarize"
31
+ Provides-Extra: dev
32
+ Requires-Dist: pytest>=7.0; extra == "dev"
33
+ Requires-Dist: build; extra == "dev"
34
+ Requires-Dist: twine; extra == "dev"
35
+ Dynamic: license-file
36
+
37
+ # brain-mcp
38
+
39
+ **You've had thousands of AI conversations. You can't search any of them.**
40
+
41
+ brain-mcp fixes that. It's a local [MCP server](https://modelcontextprotocol.io) that ingests your conversations from Claude Code, ChatGPT, Cursor, and more — then gives your AI assistant the ability to search, synthesize, and reason over everything you've ever discussed.
42
+
43
+ Your data stays on your machine. Nothing leaves your computer.
44
+
45
+ ---
46
+
47
+ ## Quick Start (3 commands)
48
+
49
+ ```bash
50
+ npx brain-mcp init # discover your conversations
51
+ npx brain-mcp init --full # import + embed (one-time, ~5 min)
52
+ npx brain-mcp setup claude # auto-configure Claude Code
53
+ ```
54
+
55
+ That's it. Restart Claude Code, and ask: *"Search my past conversations about authentication"*
56
+
57
+ ### Alternative: pip install
58
+
59
+ ```bash
60
+ pip install brain-mcp
61
+ brain-mcp init --full
62
+ brain-mcp setup claude
63
+ ```
64
+
65
+ ---
66
+
67
+ ## What Happens
68
+
69
+ `brain-mcp init` auto-discovers your AI conversations:
70
+
71
+ ```
72
+ Discovering AI conversations...
73
+
74
+ found Claude Code 438 sessions ~/.claude/projects/
75
+ found ChatGPT 47 exports ~/Downloads/chatgpt-export/
76
+ -- Cursor not found
77
+ -- Windsurf not found
78
+
79
+ Config saved to ~/.config/brain-mcp/brain.yaml
80
+ ```
81
+
82
+ `brain-mcp init --full` imports everything and creates searchable embeddings:
83
+
84
+ ```
85
+ Importing conversations...
86
+ Claude Code ████████████████████ 23,456 messages (32s)
87
+ ChatGPT ████████████████████ 8,923 messages (12s)
88
+
89
+ Creating embeddings...
90
+ Embedding ████████████████████ 19,847 embedded (2m 31s)
91
+
92
+ Your brain is ready!
93
+ Messages: 32,379
94
+ Embedded: 19,847
95
+ Sources: 2 (Claude Code, ChatGPT)
96
+ ```
97
+
98
+ ---
99
+
100
+ ## Why Brain MCP?
101
+
102
+ | Feature | Brain MCP | Mem0 | Letta |
103
+ |---------|:---------:|:----:|:-----:|
104
+ | **Approach** | Conversation archaeology — search & synthesize across your full AI history | Key-value memory store | Tiered memory agents |
105
+ | **MCP Tools** | 25 | ~5 | ~5 |
106
+ | **Data Location** | 100% local | Cloud | Cloud/Self-hosted |
107
+ | **Privacy** | No telemetry, no phone-home | Cloud-dependent | Cloud-dependent |
108
+ | **Cost** | Free (MIT) | Freemium | Freemium |
109
+ | **Unique Feature** | Cognitive prosthetic — reconstructs where you left off in any domain | Automatic memory extraction | Persistent agent memory |
110
+ | **Setup** | 3 commands | API key + cloud setup | Complex multi-service |
111
+ | **AI Sources** | Claude Code, ChatGPT, Clawdbot, Generic JSONL | N/A (runtime only) | N/A (runtime only) |
112
+
113
+ Brain MCP isn't a memory layer — it's **conversation archaeology**. It searches, synthesizes, and reconstructs context from your entire AI conversation history. The prosthetic tools don't just find information — they rebuild the *state* of your thinking.
114
+
115
+ ---
116
+
117
+ ## 🔒 Data Privacy
118
+
119
+ Brain MCP is radically local:
120
+
121
+ - **All data stays on your machine** — conversations, embeddings, summaries, everything
122
+ - **No telemetry** — we don't collect any usage data, ever
123
+ - **No phone-home** — the software never contacts any server
124
+ - **No cloud dependency** — works fully offline after initial model download
125
+ - **No accounts** — no sign-up, no API keys required (unless you opt into LLM summarization)
126
+ - **You own everything** — all data is in standard formats (parquet, LanceDB) you can read with any tool
127
+ - **MIT licensed** — fork it, audit it, modify it
128
+
129
+ The embedding model (~275MB) is downloaded once and runs locally. After that, Brain MCP works entirely offline.
130
+
131
+ ---
132
+
133
+ ## 25 Tools
134
+
135
+ ### Search (4 tools)
136
+
137
+ | Tool | What it does |
138
+ |------|-------------|
139
+ | `semantic_search` | Find conceptually similar messages, even without exact keywords |
140
+ | `search_conversations` | Full-text keyword search across all messages |
141
+ | `unified_search` | Cross-source search (conversations + GitHub + docs) |
142
+ | `search_docs` | Search markdown documentation corpus |
143
+
144
+ ### Conversations (3 tools)
145
+
146
+ | Tool | What it does |
147
+ |------|-------------|
148
+ | `get_conversation` | Retrieve a full conversation by ID |
149
+ | `conversations_by_date` | Browse conversations from a specific date |
150
+ | `search_summaries` | Search structured conversation summaries |
151
+
152
+ ### Synthesis (4 tools)
153
+
154
+ | Tool | What it does |
155
+ |------|-------------|
156
+ | `what_do_i_think` | Synthesize your views on a topic across conversations |
157
+ | `alignment_check` | Check if a decision aligns with your stated principles |
158
+ | `thinking_trajectory` | Track how your thinking evolved over time |
159
+ | `what_was_i_thinking` | Monthly snapshot: what was on your mind in 2024-08? |
160
+
161
+ ### Stats & Analytics (4 tools)
162
+
163
+ | Tool | What it does |
164
+ |------|-------------|
165
+ | `brain_stats` | Overview with 7 views (messages, domains, pulse, etc.) |
166
+ | `unfinished_threads` | Threads with unresolved questions |
167
+ | `query_analytics` | Custom SQL analytics over your conversation data |
168
+ | `github_search` | Search your GitHub repos and commits (if configured) |
169
+
170
+ ### Cognitive Prosthetic (8 tools)
171
+
172
+ This is what makes brain-mcp different from "just search." These tools don't just find information — they reconstruct the *state* of your thinking.
173
+
174
+ | Tool | What it does |
175
+ |------|-------------|
176
+ | `tunnel_state` | "Load game" — where you left off in a domain |
177
+ | `context_recovery` | Full re-entry briefing after time away |
178
+ | `switching_cost` | Should you switch? Quantified cost before you do |
179
+ | `dormant_contexts` | Abandoned topics with unresolved questions |
180
+ | `open_threads` | All unfinished business, every domain, one view |
181
+ | `cognitive_patterns` | When and how you think best, backed by data |
182
+ | `tunnel_history` | Your engagement with a domain over time |
183
+ | `trust_dashboard` | Everything preserved. Nothing lost. Proof. |
184
+
185
+ ### Principles (2 tools)
186
+
187
+ | Tool | What it does |
188
+ |------|-------------|
189
+ | `list_principles` | List your configured principles |
190
+ | `get_principle` | Get details about a specific principle |
191
+
192
+ ---
193
+
194
+ ## Supported Sources
195
+
196
+ | Source | Auto-detected | Format |
197
+ |--------|:---:|--------|
198
+ | **Claude Code** | yes | JSONL sessions in `~/.claude/projects/` |
199
+ | **ChatGPT** | yes | JSON export from Settings > Data Controls |
200
+ | **Clawdbot** | yes | JSONL sessions in `~/.clawdbot/agents/` |
201
+ | **Cursor** | coming soon | Workspace storage |
202
+ | **Windsurf** | coming soon | Workspace storage |
203
+ | **Generic JSONL** | manual | `{role, content, timestamp}` per line |
204
+
205
+ ### ChatGPT Export
206
+
207
+ 1. Go to [chat.openai.com](https://chat.openai.com) > Settings > Data Controls > Export
208
+ 2. Download the zip, extract to `~/Downloads/`
209
+ 3. Run `brain-mcp init` — it auto-detects the export
210
+
211
+ ---
212
+
213
+ ## CLI Reference
214
+
215
+ ```bash
216
+ brain-mcp init # Discover sources, create config
217
+ brain-mcp init --full # Discover + ingest + embed (one command)
218
+ brain-mcp ingest # Import conversations to parquet
219
+ brain-mcp embed # Create/update vector embeddings
220
+ brain-mcp serve # Start MCP server (stdio)
221
+ brain-mcp setup claude # Auto-configure Claude Code
222
+ brain-mcp setup cursor # Auto-configure Cursor
223
+ brain-mcp setup windsurf # Auto-configure Windsurf
224
+ brain-mcp doctor # Health check (what's working, what's missing)
225
+ brain-mcp status # One-line status
226
+ brain-mcp sync # Incremental update (new conversations only)
227
+ ```
228
+
229
+ ### Health Check
230
+
231
+ ```bash
232
+ $ brain-mcp doctor
233
+
234
+ Brain MCP Health Check
235
+
236
+ ok Python 3.12.1
237
+ ok Config: ~/.config/brain-mcp/brain.yaml
238
+ ok Parquet: 32,379 messages
239
+ ok Vectors: 19,847 embeddings
240
+ warn Summaries: not generated (prosthetic tools in basic mode)
241
+ -> Run: brain-mcp summarize (requires ANTHROPIC_API_KEY)
242
+ ok Claude Code: configured
243
+ -- Cursor: not configured
244
+ ```
245
+
246
+ ---
247
+
248
+ ## How It Works
249
+
250
+ ```
251
+ You ──────────────────────────────────────────────────────────
252
+
253
+ "Search my conversations about authentication"
254
+ "What do I think about microservices?"
255
+ "Where did I leave off with the database redesign?"
256
+
257
+
258
+
259
+
260
+ MCP Server ─────────────────────────────────────────────────
261
+
262
+ 25 tools registered:
263
+ Search │ Synthesis │ Prosthetic │ Stats │ Principles
264
+
265
+
266
+
267
+
268
+ Data Layer ─────────────────────────────────────────────────
269
+
270
+ DuckDB (SQL over parquet) LanceDB (vector search)
271
+ ┌─────────────────────┐ ┌────────────────────┐
272
+ │ all_conversations │ │ message vectors │
273
+ │ .parquet │ │ (768-dim, local) │
274
+ └─────────────────────┘ └────────────────────┘
275
+
276
+
277
+
278
+
279
+ Ingest Pipeline ────────────────────────────────────────────
280
+
281
+ Claude Code │ ChatGPT │ Clawdbot │ Generic JSONL
282
+ (auto-discovered from your machine)
283
+ ```
284
+
285
+ All data stored at `~/.config/brain-mcp/`. Embedding model runs locally (nomic-embed-text-v1.5, ~275MB download on first run).
286
+
287
+ ---
288
+
289
+ ## Progressive Feature Tiers
290
+
291
+ brain-mcp works at every scale. You don't need 100K messages to get value.
292
+
293
+ | What you have | What works |
294
+ |---------------|-----------|
295
+ | **Just conversations** (after `ingest`) | Keyword search, date browsing, stats, analytics |
296
+ | **+ Embeddings** (after `embed`) | Semantic search, synthesis, trajectory tracking |
297
+ | **+ Summaries** (after `summarize`) | Full prosthetic tools with structured analysis |
298
+
299
+ Every tool works at every tier — just with increasing depth. The prosthetic tools (tunnel_state, switching_cost, etc.) give useful results from raw messages, and richer results with summaries.
300
+
301
+ ---
302
+
303
+ ## Configuration
304
+
305
+ Config lives at `~/.config/brain-mcp/brain.yaml` (created by `brain-mcp init`).
306
+
307
+ | Key | Description | Default |
308
+ |-----|-------------|---------|
309
+ | `data_dir` | Parquet file storage | `~/.config/brain-mcp/data` |
310
+ | `vectors_dir` | LanceDB vectors | `~/.config/brain-mcp/vectors` |
311
+ | `sources` | Conversation sources (auto-detected) | `[]` |
312
+ | `embedding.model` | Embedding model | `nomic-ai/nomic-embed-text-v1.5` |
313
+ | `embedding.dim` | Vector dimensions | `768` |
314
+ | `summarizer.enabled` | Enable summarization | `false` |
315
+ | `summarizer.provider` | LLM provider | `anthropic` |
316
+ | `summarizer.model` | LLM model | `claude-sonnet-4-20250514` |
317
+ | `domains` | Domain categories for prosthetic tools | (auto-generated) |
318
+
319
+ ---
320
+
321
+ ## Requirements
322
+
323
+ - Python 3.11+ (auto-managed if using npx)
324
+ - ~500MB disk (embedding model + data)
325
+ - ~2GB RAM for embedding
326
+ - macOS, Linux, or WSL
327
+
328
+ ---
329
+
330
+ ## Project Structure
331
+
332
+ ```
333
+ brain-mcp/
334
+ ├── pyproject.toml # Package config
335
+ ├── brain_mcp/ # Python package
336
+ │ ├── cli.py # CLI (init, ingest, embed, serve, etc.)
337
+ │ ├── config.py # Config loader
338
+ │ ├── sync.py # Incremental sync
339
+ │ ├── server/ # MCP server + 25 tools
340
+ │ │ ├── server.py # FastMCP server
341
+ │ │ ├── db.py # DuckDB + LanceDB connections
342
+ │ │ ├── tools_search.py
343
+ │ │ ├── tools_synthesis.py
344
+ │ │ ├── tools_prosthetic.py
345
+ │ │ ├── tools_stats.py
346
+ │ │ ├── tools_conversations.py
347
+ │ │ ├── tools_github.py
348
+ │ │ └── tools_analytics.py
349
+ │ ├── ingest/ # Conversation ingesters
350
+ │ │ ├── claude_code.py
351
+ │ │ ├── chatgpt.py
352
+ │ │ ├── clawdbot.py
353
+ │ │ └── generic.py
354
+ │ ├── embed/ # Local embedding pipeline
355
+ │ └── summarize/ # Optional LLM summarization
356
+ ├── npm/ # npx wrapper
357
+ │ ├── package.json
358
+ │ └── bin/brain-mcp.js
359
+ ├── principles/ # Template for personal principles
360
+ ├── tests/
361
+ ├── CONTRIBUTING.md
362
+ ├── CHANGELOG.md
363
+ └── LICENSE
364
+ ```
365
+
366
+ ---
367
+
368
+ ## Contributing
369
+
370
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for how to set up the dev environment, run tests, and submit PRs.
371
+
372
+ ## License
373
+
374
+ MIT — see [LICENSE](LICENSE).