cortex-mcp 2.6.0 → 2.7.1

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 (198) hide show
  1. package/CHANGELOG.md +58 -279
  2. package/README.md +224 -393
  3. package/dist/cli/setup.js +60 -58
  4. package/dist/cli/setup.js.map +1 -1
  5. package/dist/config/config.js +2 -2
  6. package/dist/config/config.js.map +1 -1
  7. package/dist/db/database.d.ts +0 -8
  8. package/dist/db/database.d.ts.map +1 -1
  9. package/dist/db/database.js +2 -34
  10. package/dist/db/database.js.map +1 -1
  11. package/dist/db/event-log.d.ts +0 -4
  12. package/dist/db/event-log.d.ts.map +1 -1
  13. package/dist/db/event-log.js +10 -14
  14. package/dist/db/event-log.js.map +1 -1
  15. package/dist/db/memory-store.d.ts +3 -30
  16. package/dist/db/memory-store.d.ts.map +1 -1
  17. package/dist/db/memory-store.js +44 -140
  18. package/dist/db/memory-store.js.map +1 -1
  19. package/dist/embedding-worker.js +1 -1
  20. package/dist/embedding-worker.js.map +1 -1
  21. package/dist/hooks/git-capture.js +3 -3
  22. package/dist/hooks/git-hooks.js +2 -5
  23. package/dist/mcp-stdio.js +3 -34
  24. package/dist/mcp-stdio.js.map +1 -1
  25. package/dist/memory/anticipation-engine.d.ts.map +1 -1
  26. package/dist/memory/anticipation-engine.js +10 -18
  27. package/dist/memory/anticipation-engine.js.map +1 -1
  28. package/dist/memory/auto-learner.d.ts.map +1 -1
  29. package/dist/memory/auto-learner.js +43 -190
  30. package/dist/memory/auto-learner.js.map +1 -1
  31. package/dist/memory/confidence-decay.d.ts.map +1 -1
  32. package/dist/memory/confidence-decay.js +9 -13
  33. package/dist/memory/confidence-decay.js.map +1 -1
  34. package/dist/memory/embedding-manager.d.ts.map +1 -1
  35. package/dist/memory/embedding-manager.js +4 -6
  36. package/dist/memory/embedding-manager.js.map +1 -1
  37. package/dist/memory/export-import.js +2 -2
  38. package/dist/memory/export-import.js.map +1 -1
  39. package/dist/memory/git-memory.d.ts.map +1 -1
  40. package/dist/memory/git-memory.js +26 -20
  41. package/dist/memory/git-memory.js.map +1 -1
  42. package/dist/memory/learning-rate.js +7 -8
  43. package/dist/memory/learning-rate.js.map +1 -1
  44. package/dist/memory/llm-enhancer.d.ts +14 -2
  45. package/dist/memory/llm-enhancer.d.ts.map +1 -1
  46. package/dist/memory/llm-enhancer.js +46 -66
  47. package/dist/memory/llm-enhancer.js.map +1 -1
  48. package/dist/memory/memory-cache.d.ts.map +1 -1
  49. package/dist/memory/memory-cache.js +0 -10
  50. package/dist/memory/memory-cache.js.map +1 -1
  51. package/dist/memory/memory-consolidator.d.ts.map +1 -1
  52. package/dist/memory/memory-consolidator.js +14 -20
  53. package/dist/memory/memory-consolidator.js.map +1 -1
  54. package/dist/memory/memory-decay.d.ts.map +1 -1
  55. package/dist/memory/memory-decay.js +52 -82
  56. package/dist/memory/memory-decay.js.map +1 -1
  57. package/dist/memory/memory-quality.d.ts +1 -1
  58. package/dist/memory/memory-quality.d.ts.map +1 -1
  59. package/dist/memory/memory-quality.js +6 -9
  60. package/dist/memory/memory-quality.js.map +1 -1
  61. package/dist/memory/memory-ranker.d.ts.map +1 -1
  62. package/dist/memory/memory-ranker.js +3 -12
  63. package/dist/memory/memory-ranker.js.map +1 -1
  64. package/dist/memory/meta-memory.js +3 -3
  65. package/dist/memory/meta-memory.js.map +1 -1
  66. package/dist/memory/session-tracker.d.ts +0 -2
  67. package/dist/memory/session-tracker.d.ts.map +1 -1
  68. package/dist/memory/session-tracker.js +8 -26
  69. package/dist/memory/session-tracker.js.map +1 -1
  70. package/dist/memory/temporal-engine.d.ts.map +1 -1
  71. package/dist/memory/temporal-engine.js +13 -9
  72. package/dist/memory/temporal-engine.js.map +1 -1
  73. package/dist/retrieval/hybrid-retriever.d.ts +2 -0
  74. package/dist/retrieval/hybrid-retriever.d.ts.map +1 -1
  75. package/dist/retrieval/hybrid-retriever.js +13 -3
  76. package/dist/retrieval/hybrid-retriever.js.map +1 -1
  77. package/dist/scanners/architecture-graph.js +2 -2
  78. package/dist/scanners/architecture-graph.js.map +1 -1
  79. package/dist/scanners/code-verifier.d.ts +0 -1
  80. package/dist/scanners/code-verifier.d.ts.map +1 -1
  81. package/dist/scanners/code-verifier.js +14 -14
  82. package/dist/scanners/code-verifier.js.map +1 -1
  83. package/dist/scanners/context-builder.d.ts.map +1 -1
  84. package/dist/scanners/context-builder.js +45 -33
  85. package/dist/scanners/context-builder.js.map +1 -1
  86. package/dist/scanners/export-map.js +2 -2
  87. package/dist/scanners/export-map.js.map +1 -1
  88. package/dist/scanners/project-scanner.js +2 -2
  89. package/dist/scanners/project-scanner.js.map +1 -1
  90. package/dist/security/encryption.js +1 -1
  91. package/dist/security/encryption.js.map +1 -1
  92. package/dist/security/feature-gate.d.ts.map +1 -1
  93. package/dist/security/feature-gate.js +20 -62
  94. package/dist/security/feature-gate.js.map +1 -1
  95. package/dist/security/license.js +35 -282
  96. package/dist/security/license.js.map +1 -1
  97. package/dist/security/rate-limiter.d.ts +3 -4
  98. package/dist/security/rate-limiter.d.ts.map +1 -1
  99. package/dist/security/rate-limiter.js +29 -11
  100. package/dist/security/rate-limiter.js.map +1 -1
  101. package/dist/server/dashboard.js +327 -166
  102. package/dist/server/dashboard.js.map +1 -1
  103. package/dist/server/mcp-handler.d.ts.map +1 -1
  104. package/dist/server/mcp-handler.js +827 -1002
  105. package/dist/server/mcp-handler.js.map +1 -1
  106. package/package.json +8 -18
  107. package/dist/memory/access-pattern-tracker.d.ts +0 -51
  108. package/dist/memory/access-pattern-tracker.d.ts.map +0 -1
  109. package/dist/memory/access-pattern-tracker.js +0 -92
  110. package/dist/memory/access-pattern-tracker.js.map +0 -1
  111. package/dist/memory/completion-resolver.d.ts +0 -38
  112. package/dist/memory/completion-resolver.d.ts.map +0 -1
  113. package/dist/memory/completion-resolver.js +0 -127
  114. package/dist/memory/completion-resolver.js.map +0 -1
  115. package/dist/memory/convention-detector.d.ts +0 -11
  116. package/dist/memory/convention-detector.d.ts.map +0 -1
  117. package/dist/memory/convention-detector.js +0 -294
  118. package/dist/memory/convention-detector.js.map +0 -1
  119. package/dist/memory/correction-detector.d.ts +0 -33
  120. package/dist/memory/correction-detector.d.ts.map +0 -1
  121. package/dist/memory/correction-detector.js +0 -129
  122. package/dist/memory/correction-detector.js.map +0 -1
  123. package/dist/memory/cross-memory-linker.d.ts +0 -18
  124. package/dist/memory/cross-memory-linker.d.ts.map +0 -1
  125. package/dist/memory/cross-memory-linker.js +0 -115
  126. package/dist/memory/cross-memory-linker.js.map +0 -1
  127. package/dist/memory/daily-diary.d.ts +0 -30
  128. package/dist/memory/daily-diary.d.ts.map +0 -1
  129. package/dist/memory/daily-diary.js +0 -159
  130. package/dist/memory/daily-diary.js.map +0 -1
  131. package/dist/memory/embedding-cache.d.ts +0 -32
  132. package/dist/memory/embedding-cache.d.ts.map +0 -1
  133. package/dist/memory/embedding-cache.js +0 -76
  134. package/dist/memory/embedding-cache.js.map +0 -1
  135. package/dist/memory/error-learner.d.ts +0 -26
  136. package/dist/memory/error-learner.d.ts.map +0 -1
  137. package/dist/memory/error-learner.js +0 -145
  138. package/dist/memory/error-learner.js.map +0 -1
  139. package/dist/memory/file-relationships.d.ts +0 -47
  140. package/dist/memory/file-relationships.d.ts.map +0 -1
  141. package/dist/memory/file-relationships.js +0 -130
  142. package/dist/memory/file-relationships.js.map +0 -1
  143. package/dist/memory/impact-analyzer.d.ts +0 -16
  144. package/dist/memory/impact-analyzer.d.ts.map +0 -1
  145. package/dist/memory/impact-analyzer.js +0 -189
  146. package/dist/memory/impact-analyzer.js.map +0 -1
  147. package/dist/memory/instructions-generator.d.ts +0 -30
  148. package/dist/memory/instructions-generator.d.ts.map +0 -1
  149. package/dist/memory/instructions-generator.js +0 -117
  150. package/dist/memory/instructions-generator.js.map +0 -1
  151. package/dist/memory/memory-export-md.d.ts +0 -12
  152. package/dist/memory/memory-export-md.d.ts.map +0 -1
  153. package/dist/memory/memory-export-md.js +0 -188
  154. package/dist/memory/memory-export-md.js.map +0 -1
  155. package/dist/memory/mmr-reranker.d.ts +0 -39
  156. package/dist/memory/mmr-reranker.d.ts.map +0 -1
  157. package/dist/memory/mmr-reranker.js +0 -115
  158. package/dist/memory/mmr-reranker.js.map +0 -1
  159. package/dist/memory/pre-flight.d.ts +0 -24
  160. package/dist/memory/pre-flight.d.ts.map +0 -1
  161. package/dist/memory/pre-flight.js +0 -121
  162. package/dist/memory/pre-flight.js.map +0 -1
  163. package/dist/memory/preference-learner.d.ts +0 -28
  164. package/dist/memory/preference-learner.d.ts.map +0 -1
  165. package/dist/memory/preference-learner.js +0 -144
  166. package/dist/memory/preference-learner.js.map +0 -1
  167. package/dist/memory/query-expansion.d.ts +0 -28
  168. package/dist/memory/query-expansion.d.ts.map +0 -1
  169. package/dist/memory/query-expansion.js +0 -140
  170. package/dist/memory/query-expansion.js.map +0 -1
  171. package/dist/memory/regression-guard.d.ts +0 -35
  172. package/dist/memory/regression-guard.d.ts.map +0 -1
  173. package/dist/memory/regression-guard.js +0 -90
  174. package/dist/memory/regression-guard.js.map +0 -1
  175. package/dist/memory/resume-work.d.ts +0 -37
  176. package/dist/memory/resume-work.d.ts.map +0 -1
  177. package/dist/memory/resume-work.js +0 -141
  178. package/dist/memory/resume-work.js.map +0 -1
  179. package/dist/memory/soul-manager.d.ts +0 -30
  180. package/dist/memory/soul-manager.d.ts.map +0 -1
  181. package/dist/memory/soul-manager.js +0 -171
  182. package/dist/memory/soul-manager.js.map +0 -1
  183. package/dist/memory/success-tracker.d.ts +0 -33
  184. package/dist/memory/success-tracker.d.ts.map +0 -1
  185. package/dist/memory/success-tracker.js +0 -75
  186. package/dist/memory/success-tracker.js.map +0 -1
  187. package/dist/memory/tool-recommender.d.ts +0 -29
  188. package/dist/memory/tool-recommender.d.ts.map +0 -1
  189. package/dist/memory/tool-recommender.js +0 -117
  190. package/dist/memory/tool-recommender.js.map +0 -1
  191. package/dist/memory/usage-stats.d.ts +0 -98
  192. package/dist/memory/usage-stats.d.ts.map +0 -1
  193. package/dist/memory/usage-stats.js +0 -345
  194. package/dist/memory/usage-stats.js.map +0 -1
  195. package/dist/utils/extract-tags.d.ts +0 -16
  196. package/dist/utils/extract-tags.d.ts.map +0 -1
  197. package/dist/utils/extract-tags.js +0 -40
  198. package/dist/utils/extract-tags.js.map +0 -1
package/README.md CHANGED
@@ -1,393 +1,224 @@
1
- # Cortex MCP — Persistent AI Memory
2
-
3
- [![npm version](https://img.shields.io/npm/v/cortex-mcp.svg)](https://www.npmjs.com/package/cortex-mcp)
4
- [![npm downloads](https://img.shields.io/npm/dm/cortex-mcp.svg)](https://www.npmjs.com/package/cortex-mcp)
5
- [![CI](https://github.com/jaswanthkumarj1234-beep/cortex-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/jaswanthkumarj1234-beep/cortex-mcp/actions/workflows/ci.yml)
6
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
7
- [![Node.js](https://img.shields.io/badge/node-%3E%3D20-brightgreen.svg)](https://nodejs.org/)
8
-
9
- > Give your AI coding assistant a brain that remembers across sessions.
10
-
11
- Cortex is an MCP (Model Context Protocol) server that provides persistent, intelligent memory to any AI coding assistant — Cursor, Claude Code, Windsurf, Cline, or any MCP-compatible tool.
12
-
13
- ## What's New in v2.4
14
-
15
- - **🧠 Smart importance scoring** — Memories ranked by type (CORRECTION > INSIGHT) + content signals (file paths, error keywords boost importance)
16
- - **🏷️ Auto topic tags** Memories auto-tagged with technologies, domains, and actions (`['typescript', 'auth', 'database']`)
17
- - **🏁 Task completion tracking** Say "finished SEO work" and old SEO memories get demoted automatically
18
- - **🔍 Resolved memory filtering** FTS search, ranker, and context builder all exclude completed work
19
- - **🛡️ Code block safety** Auto-learn no longer extracts from code blocks (no `const foo = bar()` as memories)
20
- - **📊 Dashboard auto-refresh** Updates every 30 seconds
21
- - **Free LLM integration** — Add `OPENROUTER_API_KEY` for 3x smarter memory extraction (zero cost!)
22
- - **40+ auto-learn patterns** Captures decisions, corrections, conventions, bug fixes from AI responses
23
- - **Error fingerprints** — Auto-captures stack traces, TS errors, npm failures for instant fix recall
24
- - **Success tracking** — Detects "that worked!" and stores proven approaches
25
- - **Brain Health Score** — Gamified 0-100 score with grades (Newborn → Genius)
26
- - **Git-enhanced resume** Shows recent commits + branch context when resuming work
27
-
28
- See [CHANGELOG.md](CHANGELOG.md) for full details.
29
-
30
- ## The Problem
31
-
32
- Every time you start a new conversation, your AI assistant forgets everything:
33
-
34
- - Coding conventions you already explained
35
- - Bugs you already fixed
36
- - Decisions you already made
37
- - What files you were working on
38
-
39
- **Cortex solves this.** It stores, ranks, and proactively recalls context so your AI never starts from zero.
40
-
41
- ## Quick Start
42
-
43
- ### Option 1: npx (recommended always up to date)
44
-
45
- Add to your MCP config (no install needed, auto-updates on every launch):
46
-
47
- ```json
48
- {
49
- "mcpServers": {
50
- "cortex": {
51
- "command": "npx",
52
- "args": ["-y", "cortex-mcp@latest"],
53
- "transportType": "stdio"
54
- }
55
- }
56
- }
57
- ```
58
-
59
- ### 🧠 Supercharge with Free LLM (Optional)
60
-
61
- Add a **free** OpenRouter API key to make Cortex 3x smarter at extracting knowledge:
62
-
63
- ```json
64
- {
65
- "mcpServers": {
66
- "cortex": {
67
- "command": "npx",
68
- "args": ["-y", "cortex-mcp@latest"],
69
- "transportType": "stdio",
70
- "env": {
71
- "OPENROUTER_API_KEY": "sk-or-v1-your-key-here"
72
- }
73
- }
74
- }
75
- }
76
- ```
77
-
78
- **How to get a free key:**
79
-
80
- 1. Go to [openrouter.ai/keys](https://openrouter.ai/keys)
81
- 2. Create a free account
82
- 3. Generate an API key
83
- 4. Paste it in the config above
84
-
85
- **What it enables:** When regex can't extract patterns from your conversation, Cortex uses a free LLM (Llama 4 Scout) to catch implicit decisions, preferences, and architecture knowledge that keywords miss. Without it, ~70% of conversations produce no memories. With it, that drops to ~20%.
86
-
87
- ### Option 2: Global install
88
-
89
- ```bash
90
- npm install -g cortex-mcp
91
- ```
92
-
93
- Then add to your MCP config:
94
-
95
- ```json
96
- {
97
- "mcpServers": {
98
- "cortex": {
99
- "command": "cortex-mcp",
100
- "transportType": "stdio"
101
- }
102
- }
103
- }
104
- ```
105
-
106
- ### Option 2: Clone from source
107
-
108
- ```bash
109
- git clone https://github.com/jaswanthkumarj1234-beep/cortex-mcp.git
110
- cd cognitive-memory
111
- npm install
112
- npm run build
113
- ```
114
-
115
- Then add to your MCP config:
116
-
117
- ```json
118
- {
119
- "mcpServers": {
120
- "cortex": {
121
- "command": "node",
122
- "args": ["<path-to>/cognitive-memory/dist/mcp-stdio.js"],
123
- "transportType": "stdio"
124
- }
125
- }
126
- }
127
- ```
128
-
129
- Restart your IDE and Cortex is active.
130
-
131
- ### Try the Demo
132
-
133
- See Cortex in action without any AI client:
134
-
135
- ```bash
136
- npm run demo # Interactive demo store, search, dedup
137
- npm run benchmark # Performance benchmark write, read, FTS ops/sec
138
- ```
139
-
140
- ### IDE-Specific Setup Guides
141
-
142
- Step-by-step instructions for your IDE: **[Cursor · Claude Code · Windsurf · Cline · Copilot](docs/ide-setup.md)**
143
-
144
- ### Recipes & Use Cases
145
-
146
- 10 practical examples: **[docs/recipes.md](docs/recipes.md)** conventions, bug tracking, anti-hallucination, team onboarding, and more.
147
-
148
- ## Features
149
-
150
- ### Why Cortex?
151
-
152
- | Feature | Cortex | Other MCP memory servers |
153
- | --------------------------- | :------------------------------------------------------: | :----------------------: |
154
- | **Retrieval** | Hybrid (FTS + Vector + Graph) | Usually FTS only |
155
- | **Auto-learning** | Extracts memories from AI responses | Manual store only |
156
- | **Hallucination detection** | `verify_code` + `verify_files` | No |
157
- | **Git integration** | Auto-captures commits, diffs, branch context | No |
158
- | **Cognitive features** | Decay, attention, contradiction detection, consolidation | No |
159
- | **Brain pipeline** | 12+ layer context injection | Simple key-value recall |
160
- | **Setup** | `npm i -g cortex-mcp` + 1 config line | Varies |
161
- | **Offline** | 100% local SQLite (no API key needed) | Often requires API |
162
-
163
- ### 20 MCP Tools
164
-
165
- | Tool | Purpose |
166
- | ----------------- | ---------------------------------------------------------------------------------- |
167
- | `force_recall` | Full brain dump at conversation start (12+ layer pipeline) |
168
- | `recall_memory` | Search memories by topic (FTS + vector + graph) |
169
- | `store_memory` | Store a decision, correction, convention, or bug fix |
170
- | `quick_store` | One-liner memory storage with auto-classification |
171
- | `auto_learn` | Extract memories from AI responses automatically |
172
- | `scan_project` | Scan project structure, stack, git, exports, architecture |
173
- | `verify_code` | Check if imports/exports/env vars actually exist |
174
- | `verify_files` | Check if file paths are real or hallucinated |
175
- | `get_context` | Get compressed context for current file |
176
- | `review_code` | Review code against stored conventions and past bug patterns |
177
- | `pre_check` | Pre-flight check before editing — get all conventions and past bugs for a file |
178
- | `check_impact` | Impact analysis — check which files depend on the file you plan to modify |
179
- | `resume_work` | Resume after a break — get last session summary, recent corrections, pending tasks |
180
- | `get_stats` | Memory database statistics |
181
- | `list_memories` | List all active memories |
182
- | `update_memory` | Update an existing memory |
183
- | `delete_memory` | Delete a memory |
184
- | `export_memories` | Export all memories to JSON |
185
- | `import_memories` | Import memories from JSON |
186
- | `health_check` | Server health check |
187
-
188
- ### 12+ Layer Brain Pipeline
189
-
190
- Every conversation starts with `force_recall`, which runs 12+ layers (layers 6-12 run **in parallel** for speed):
191
-
192
- | Layer | Feature | Parallel? |
193
- | :---: | ------------------------------------------------------------- | :-------: |
194
- | 0 | Session management — track what you're working on | — |
195
- | 1 | Maintenance — decay, boost corrections, consolidate | — |
196
- | 2 | Attention focus — detect debugging vs coding vs reviewing | — |
197
- | 3 | Session continuity — resume where you left off | — |
198
- | 4 | Hot corrections — frequently-corrected topics | — |
199
- | 5 | Core context — corrections, decisions, conventions, bug fixes | — |
200
- | 6 | Anticipation — proactive recall based on current file | ✅ |
201
- | 7 | Temporal — what changed today, yesterday, this week | ✅ |
202
- | 8 | Workspace git — branch, recent commits, diffs | ✅ |
203
- | 8.5 | Git memory — auto-capture commits + file changes | ✅ |
204
- | 9 | Topic search FTS + decay + causal chain traversal | ✅ |
205
- | 10 | Knowledge gaps — flag files with zero memories | ✅ |
206
- | 11 | Export map all functions/classes (anti-hallucination) | ✅ |
207
- | 12 | Architecture graph — layers, circular deps, API endpoints | ✅ |
208
-
209
- ### Cognitive Features
210
-
211
- - **Confidence decay** — old unused memories fade, frequently accessed ones strengthen
212
- - **Attention ranking** debugging context boosts bug-fix memories, coding boosts conventions
213
- - **Contradiction detection** — new memories automatically supersede conflicting old ones
214
- - **Memory consolidation** — similar memories merge into higher-level insights
215
- - **Cross-session threading** — related sessions link by topic overlap
216
- - **Learning rate** — topics corrected 3+ times get CRITICAL priority
217
-
218
- ### Performance & Reliability
219
-
220
- - **`force_recall` latency**: ~3-5s first call, instant on cache hit (v1.2 — was 15-19s)
221
- - **`recall_memory` latency**: <1ms average (local SQLite + WAL)
222
- - **Throughput**: 1800+ ops/sec (verified via Soak Test)
223
- - **Stability**: Zero memory leaks over sustained operation
224
- - **Protocol**: Full JSON-RPC 2.0 compliance (passed E2E suite)
225
- - **CI**: Tested on Node 18, 20, 22 with lint + build + E2E on every push
226
-
227
- ### Anti-Hallucination
228
-
229
- - Deep export map scans every source file for all exported functions, classes, types
230
- - When AI references a function that doesn't exist, `verify_code` suggests the closest real match
231
- - Architecture graph shows actual project layers and dependencies
232
-
233
- ## Optional: LLM Enhancement
234
-
235
- Cortex works fully without any API key. Optionally, add an LLM key for smarter memory extraction:
236
-
237
- ```bash
238
- # Option 1: OpenAI
239
- set OPENAI_API_KEY=sk-your-key
240
-
241
- # Option 2: Anthropic
242
- set ANTHROPIC_API_KEY=sk-ant-your-key
243
-
244
- # Option 3: Local (Ollama, free)
245
- set CORTEX_LLM_KEY=ollama
246
- set CORTEX_LLM_BASE_URL=http://localhost:11434
247
- ```
248
-
249
- ## Memory Types
250
-
251
- | Type | Use For |
252
- | ------------------- | --------------------------------------------------- |
253
- | `CORRECTION` | "Don't use var, use const" |
254
- | `DECISION` | "We chose PostgreSQL over MongoDB" |
255
- | `CONVENTION` | "All API routes start with /api/v1" |
256
- | `BUG_FIX` | "Fixed race condition in auth middleware" |
257
- | `INSIGHT` | "The codebase uses a layered architecture" |
258
- | `FAILED_SUGGESTION` | "Tried Redis caching, too complex for this project" |
259
- | `PROVEN_PATTERN` | "useDebounce hook works well for search inputs" |
260
-
261
- ## Architecture
262
-
263
- ```
264
- src/
265
- ├── server/ # MCP handler (12+ layer brain pipeline) + dashboard
266
- ├── memory/ # 17 cognitive modules (decay, attention, anticipation, etc.)
267
- ├── scanners/ # Project scanner, code verifier, export map, architecture graph
268
- ├── db/ # SQLite storage, event log
269
- ├── security/ # Rate limiter, encryption
270
- ├── hooks/ # Git capture
271
- ├── config/ # Configuration
272
- └── cli/ # Setup wizard
273
- ```
274
-
275
- ## Pricing & Features
276
-
277
- Cortex is open core. The basic version is free forever. To unlock deep cognitive features, upgrade to PRO.
278
-
279
- | Feature | FREE (npm install) | PRO ($9/mo) |
280
- | ----------------------------------- | :----------------: | :---------: |
281
- | **Memory Capacity** | ∞ Unlimited | ∞ Unlimited |
282
- | **Brain Layers** | 12+ (Full) | 12+ (Full) |
283
- | **All 16 Tools** | Yes | Yes |
284
- | **Auto-Learn** | Yes | Yes |
285
- | **Export Map (Anti-Hallucination)** | Yes | Yes |
286
- | **Architecture Graph** | Yes | Yes |
287
- | **Git Memory** | Yes | Yes |
288
- | **Confidence Decay** | Yes | Yes |
289
- | **Contradiction Detection** | Yes | Yes |
290
- | **Priority Support** | — | Yes |
291
-
292
- > **Launch Edition**: All features are currently free. Get started now and lock in lifetime access.
293
-
294
- ### Activate PRO
295
-
296
- 1. Get a license key from your [Cortex AI Dashboard](https://cortex-ai-iota.vercel.app/dashboard)
297
- 2. Set it in your environment:
298
-
299
- ```bash
300
- # Option A: Environment variable
301
- export CORTEX_LICENSE_KEY=CORTEX-XXXX-XXXX-XXXX-XXXX
302
-
303
- # Option B: License file
304
- echo CORTEX-XXXX-XXXX-XXXX-XXXX > ~/.cortex/license
305
- ```
306
-
307
- 3. Restart your IDE / MCP server.
308
-
309
- ## Architecture
310
-
311
- ```mermaid
312
- graph TB
313
- AI["AI Client (Cursor, Claude, etc.)"]
314
- MCP["MCP Server (stdio)"]
315
- ML["Memory Layer"]
316
- DB["SQLite Database"]
317
- SEC["Security Layer"]
318
- API["License API"]
319
-
320
- AI -->|"JSON-RPC via stdio"| MCP
321
- MCP --> ML
322
- ML --> DB
323
- MCP --> SEC
324
- SEC -->|"verify license"| API
325
-
326
- subgraph "Memory Layer"
327
- ML --> EMB["Embedding Manager"]
328
- ML --> AL["Auto-Learner"]
329
- ML --> QG["Quality Gates"]
330
- ML --> TD["Temporal Decay"]
331
- end
332
-
333
- subgraph "Retrieval"
334
- ML --> HR["Hybrid Retriever"]
335
- HR --> VS["Vector Search"]
336
- HR --> FTS["Full-Text Search"]
337
- HR --> RR["Recency Ranker"]
338
- end
339
- ```
340
-
341
- ## FAQ / Troubleshooting
342
-
343
- <details>
344
- <summary><strong>Cortex doesn't start or my AI client can't connect</strong></summary>
345
-
346
- 1. Make sure Node.js >=18 is installed: `node --version`
347
- 2. Try running manually: `npx cortex-mcp` — check stderr for errors
348
- 3. Check if another Cortex instance is running on the same workspace
349
- 4. Delete the cache and restart: `rm -rf .ai/brain-data`
350
- </details>
351
-
352
- <details>
353
- <summary><strong>Memories aren't being recalled</strong></summary>
354
-
355
- 1. Confirm your AI client's system prompt includes the Cortex rules (run `cortex-setup` to install them)
356
- 2. Check the dashboard at `http://localhost:3456` to see stored memories
357
- 3. Verify memories exist: the AI should call `force_recall` at conversation start
358
- </details>
359
-
360
- <details>
361
- <summary><strong>"better-sqlite3" build errors on install</strong></summary>
362
-
363
- `better-sqlite3` requires a C++ compiler:
364
-
365
- - **Windows**: Install [Visual Studio Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/)
366
- - **macOS**: Run `xcode-select --install`
367
- - **Linux**: Run `sudo apt-get install build-essential python3`
368
- </details>
369
-
370
- <details>
371
- <summary><strong>License key not working</strong></summary>
372
-
373
- 1. Verify the key format: `CORTEX-XXXX-XXXX-XXXX-XXXX`
374
- 2. Check your internet connection (license is verified online on first use)
375
- 3. Clear the cache: `rm ~/.cortex/license-cache.json`
376
- 4. Try setting it via environment variable: `export CORTEX_LICENSE_KEY=CORTEX-...`
377
- </details>
378
-
379
- <details>
380
- <summary><strong>Dashboard not loading</strong></summary>
381
-
382
- 1. Default port is 3456. Check if something else is using it: `lsof -i :3456`
383
- 2. Set a custom port: `export CORTEX_PORT=4000`
384
- 3. The dashboard URL is shown in your AI client's stderr on startup
385
- </details>
386
-
387
- ## Contributing
388
-
389
- See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, coding conventions, and the PR process.
390
-
391
- ## License
392
-
393
- MIT
1
+ # 🧠 Cortex MCP — Persistent Memory for AI Coding Assistants
2
+
3
+ > **Give your AI a brain that never forgets.**
4
+ > Cortex injects context from every past session directly into your AI's LLM requests — automatically.
5
+
6
+ [![npm](https://img.shields.io/npm/v/cortex-mcp)](https://www.npmjs.com/package/cortex-mcp)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
8
+ [![100% Free](https://img.shields.io/badge/price-100%25%20FREE-brightgreen)](https://www.npmjs.com/package/cortex-mcp)
9
+
10
+ ---
11
+
12
+ ## What Is Cortex?
13
+
14
+ Every time you close your IDE, your AI forgets everything. Every decision, every bug fix, every convention — gone.
15
+
16
+ **Cortex solves this.** It's a local MCP server that:
17
+ - Stores everything your AI learns about your project
18
+ - Automatically injects the right memories into every conversation
19
+ - Learns passively by reading your AI's own responses
20
+ - Never needs an API key, never phones home, never loses your data
21
+
22
+ **Fully local. Fully free. No account. No limits.**
23
+
24
+ ---
25
+
26
+ ## Quick Start (30 seconds)
27
+
28
+ ```bash
29
+ # Install globally
30
+ npm install -g cortex-mcp
31
+
32
+ # Auto-configure your AI client (Cursor, Claude, Windsurf, Copilot...)
33
+ cd your-project
34
+ cortex-setup
35
+ ```
36
+
37
+ That's it. Restart your AI client and Cortex is active.
38
+
39
+ ---
40
+
41
+ ## Supported AI Clients
42
+
43
+ | Client | Auto-configured by `cortex-setup` |
44
+ |--------|----------------------------------|
45
+ | **Cursor** | |
46
+ | **Claude Desktop** | ✅ |
47
+ | **GitHub Copilot (VS Code)** | ✅ |
48
+ | **Windsurf** | ✅ |
49
+ | **Zed** | ✅ |
50
+ | **Antigravity / Gemini** | ✅ |
51
+ | Any MCP-compatible client | ✅ Manual config |
52
+
53
+ ---
54
+
55
+ ## How It Works
56
+
57
+ ```
58
+ Your AI responds → Cortex reads the response → Extracts decisions, corrections, bug fixes
59
+
60
+ Next conversation → Cortex injects relevant memories → AI already knows your project
61
+ ```
62
+
63
+ **No manual work required.** Every session builds the brain automatically.
64
+
65
+ ---
66
+
67
+ ## All 35 Tools (All Free)
68
+
69
+ ### Core Memory
70
+ | Tool | What it does |
71
+ |------|-------------|
72
+ | `store_memory` | Store a decision, correction, convention, or bug fix |
73
+ | `recall_memory` | Search memories by topic, file, or type |
74
+ | `force_recall` | At session start — returns ALL critical context + topic search |
75
+ | `auto_learn` | After every AI reply — auto-extracts memories from text |
76
+ | `quick_store` | One-line shortcut for fast memory storage |
77
+
78
+ ### Memory Management
79
+ | Tool | What it does |
80
+ |------|-------------|
81
+ | `list_memories` | List all active memories, filterable by type |
82
+ | `update_memory` | Edit an existing memory |
83
+ | `delete_memory` | Remove a memory permanently |
84
+ | `pin_memory` | Pin a memory so it's ALWAYS injected (for critical rules) |
85
+ | `unpin_memory` | Unpin a previously pinned memory |
86
+ | `undo_last` | Undo the last N stored memories |
87
+ | `clear_memories` | Bulk delete by type or age |
88
+ | `thumbs_up` | Mark a memory as useful (boosts importance) |
89
+ | `thumbs_down` | Mark a memory as wrong (demotes/removes it) |
90
+ | `get_related_memories` | Follow graph edges to find connected memories |
91
+
92
+ ### Time & History
93
+ | Tool | What it does |
94
+ |------|-------------|
95
+ | `search_timeline` | Search memories by date range ("what did we decide last week?") |
96
+ | `get_daily_summary` | Read or generate a summary of today's/any day's memories |
97
+
98
+ ### Project Intelligence
99
+ | Tool | What it does |
100
+ |------|-------------|
101
+ | `scan_project` | Scan source code and auto-create memories from comments & structure |
102
+ | `get_context` | Get full brain context for the current file/topic |
103
+ | `get_stats` | Stats about the brain (memory count, types, health) |
104
+ | `analytics` | Deep analytics — distribution, most accessed, feedback scores |
105
+
106
+ ### Code Safety (Anti-Hallucination)
107
+ | Tool | What it does |
108
+ |------|-------------|
109
+ | `verify_code` | Checks if packages exist in package.json before suggesting imports |
110
+ | `verify_files` | Confirms file paths are real before referencing them |
111
+ | `search_by_file` | Find all memories related to a specific file |
112
+
113
+ ### Backup & Portability
114
+ | Tool | What it does |
115
+ |------|-------------|
116
+ | `backup_brain` | Creates a timestamped `.db` copy of the entire memory database |
117
+ | `export_memories` | Export all memories to a shareable JSON file |
118
+ | `import_memories` | Import memories from a JSON file (skip duplicates) |
119
+
120
+ ### Health & Maintenance
121
+ | Tool | What it does |
122
+ |------|-------------|
123
+ | `health_check` | Server health, embedding status, vector search status |
124
+
125
+ ---
126
+
127
+ ## Memory Types
128
+
129
+ Cortex organizes everything into 5 types:
130
+
131
+ | Type | What gets stored | Auto-detected from |
132
+ |------|-----------------|-------------------|
133
+ | `correction` | "Don't do X", "Wrong approach was Y" | Words like "never", "don't use", "avoid" |
134
+ | `decision` | "We chose X over Y because Z" | "We decided", "going with", "chosen" |
135
+ | `convention` | "Always use X for Y in this project" | "always", "must", "convention", "standard" |
136
+ | `bug_fix` | "Bug was X, fixed by Y" | "root cause", "fixed by", "was crashing" |
137
+ | `insight` | "Key thing to know: X" | "important", "worth noting", "key insight" |
138
+
139
+ Plus 4 additional auto-detected types: `failed_attempt`, `business_rule`, `gotcha`, `current_task`
140
+
141
+ ---
142
+
143
+ ## Web Dashboard
144
+
145
+ When Cortex is running, open **http://localhost:3456** to:
146
+ - View all memories organized by type
147
+ - Search and filter in real-time
148
+ - Delete or pin memories from the UI
149
+ - Export your brain as JSON
150
+ - See live stats (auto-refreshes every 30 seconds)
151
+
152
+ ---
153
+
154
+ ## Git Integration
155
+
156
+ `cortex-setup` automatically installs git hooks that capture:
157
+ - Every commit (type + message + files changed)
158
+ - Every branch switch
159
+ - Every merge
160
+
161
+ So your AI knows your recent git history automatically.
162
+
163
+ ---
164
+
165
+ ## Environment Variables
166
+
167
+ ```bash
168
+ CORTEX_PORT=4000 # Dashboard port (default: 3456)
169
+ CORTEX_DEBUG=1 # Enable file logging (cortex.log)
170
+ CORTEX_MAX_CONTEXT_CHARS=12000 # Context size injected per request (default: 12000)
171
+ OPENAI_API_KEY=sk-... # Enable LLM-enhanced memory classification
172
+ ANTHROPIC_API_KEY=sk-ant-.. # Alternative LLM provider (Claude)
173
+ CORTEX_LLM_BASE_URL=http://localhost:11434 # Ollama or any OpenAI-compatible API
174
+ ```
175
+
176
+ ---
177
+
178
+ ## Data & Privacy
179
+
180
+ - **100% local.** All memories stored in `.ai/brain-data/` inside your project folder.
181
+ - **Zero telemetry.** No analytics, no phone-home, no account required.
182
+ - **Offline-first.** Works with no internet. LLM key optional (uses fast regex-based classification otherwise).
183
+ - **Open source.** MIT license.
184
+
185
+ ---
186
+
187
+ ## Manual Configuration
188
+
189
+ If `cortex-setup` doesn't detect your client, add this to your MCP config:
190
+
191
+ ```json
192
+ {
193
+ "mcpServers": {
194
+ "cortex": {
195
+ "command": "npx",
196
+ "args": ["-y", "cortex-mcp"]
197
+ }
198
+ }
199
+ }
200
+ ```
201
+
202
+ ---
203
+
204
+ ## Limits (Auto-Reset Every 24 Hours)
205
+
206
+ | Operation | Daily Limit |
207
+ |-----------|------------|
208
+ | Store memory | 500/day |
209
+ | Auto-learn calls | 1,000/day |
210
+ | Total tool calls | 5,000/day |
211
+
212
+ All limits reset automatically every 24 hours. No manual restart needed.
213
+
214
+ ---
215
+
216
+ ## Built By
217
+
218
+ **Perla Jaswanth Kumar** — [GitHub](https://github.com/jaswanthkumarj1234-beep/cortex-mcp)
219
+ Website: [cortex-website-theta.vercel.app](https://cortex-website-theta.vercel.app)
220
+ Issues: [GitHub Issues](https://github.com/jaswanthkumarj1234-beep/cortex-mcp/issues)
221
+
222
+ ---
223
+
224
+ *Cortex is 100% free and open source. Give your AI a brain. It's about time.*