@cachly-dev/mcp-server 0.10.14 โ†’ 0.10.16

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 (44) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +50 -0
  2. package/.github/ISSUE_TEMPLATE/config.yml +8 -0
  3. package/.github/ISSUE_TEMPLATE/feature_request.md +25 -0
  4. package/.github/workflows/publish.yml +72 -0
  5. package/CHANGELOG.md +59 -0
  6. package/LAUNCH_TEXTS.md +182 -0
  7. package/LICENSE +202 -0
  8. package/README.md +136 -112
  9. package/dist/__tests__/auth.test.d.ts +1 -0
  10. package/dist/__tests__/auth.test.js +107 -0
  11. package/dist/__tests__/auth.test.js.map +1 -0
  12. package/dist/handlers/brain.js +7 -67
  13. package/dist/handlers/brain.js.map +1 -1
  14. package/dist/handlers/fedbrain.js +93 -44
  15. package/dist/handlers/fedbrain.js.map +1 -1
  16. package/dist/handlers/roadmap.js +8 -2
  17. package/dist/handlers/roadmap.js.map +1 -1
  18. package/dist/handlers/syndicate.js +15 -7
  19. package/dist/handlers/syndicate.js.map +1 -1
  20. package/dist/handlers/team.js +62 -50
  21. package/dist/handlers/team.js.map +1 -1
  22. package/dist/index.js +724 -95
  23. package/dist/index.js.map +1 -1
  24. package/dist/tools.d.ts +3 -54
  25. package/dist/tools.js +8 -62
  26. package/dist/tools.js.map +1 -1
  27. package/glama.json +36 -0
  28. package/llms.txt +155 -0
  29. package/package.json +29 -13
  30. package/scripts/postinstall.js +12 -12
  31. package/server.json +3 -9
  32. package/smithery.yaml +15 -8
  33. package/src/__tests__/auth.test.ts +147 -0
  34. package/src/handlers/brain.ts +7 -64
  35. package/src/handlers/fedbrain.ts +88 -38
  36. package/src/handlers/roadmap.ts +7 -2
  37. package/src/handlers/syndicate.ts +13 -7
  38. package/src/handlers/team.ts +57 -33
  39. package/src/index.ts +755 -108
  40. package/src/tools.ts +8 -66
  41. package/dist/__tests__/brain-predict-failures.test.d.ts +0 -17
  42. package/dist/__tests__/brain-predict-failures.test.js +0 -339
  43. package/dist/__tests__/brain-predict-failures.test.js.map +0 -1
  44. package/src/__tests__/brain-predict-failures.test.ts +0 -430
package/README.md CHANGED
@@ -1,58 +1,93 @@
1
1
  # ๐Ÿง  cachly AI Brain โ€” MCP Server
2
2
 
3
- > **Your AI forgot that 3-hour fix. Again.**
4
- > cachly gives every AI coding assistant โ€” Claude Code, Cursor, GitHub Copilot, Windsurf, Cline & Zed โ€” **permanent memory across all sessions, all projects, all editors.**
5
-
6
- <p align="center">
7
- <a href="https://cachly.dev?utm_source=npm&utm_medium=readme&utm_campaign=mcp-server">
8
- <img src="https://img.shields.io/badge/โ–ถ_Free_Brain_in_30s-cachly.dev-7c3aed?style=for-the-badge" alt="Free Brain" />
9
- </a>
10
- &nbsp;&nbsp;
11
- <a href="https://marketplace.visualstudio.com/items?itemName=cachly-dev.cachly-brain">
12
- <img src="https://img.shields.io/badge/VS_Code_Extension-Install_Free-0078d7?style=for-the-badge&logo=visual-studio-code" alt="VS Code Extension" />
13
- </a>
14
- </p>
3
+ > **Persistent memory for Claude Code, Cursor, GitHub Copilot, Windsurf, Cline & Zed.**
4
+ > Your AI remembers every lesson, every fix, every architecture decision โ€” forever.
15
5
 
16
6
  <p align="center">
17
7
  <a href="https://www.npmjs.com/package/@cachly-dev/mcp-server">
18
- <img src="https://img.shields.io/npm/v/@cachly-dev/mcp-server?color=red&logo=npm" alt="npm version" />
8
+ <img src="https://img.shields.io/npm/v/@cachly-dev/mcp-server?color=violet&logo=npm" alt="npm version" />
19
9
  </a>
20
10
  &nbsp;
21
11
  <a href="https://www.npmjs.com/package/@cachly-dev/mcp-server">
22
- <img src="https://img.shields.io/npm/dw/@cachly-dev/mcp-server?color=blue&label=weekly%20installs" alt="weekly installs" />
12
+ <img src="https://img.shields.io/npm/dw/@cachly-dev/mcp-server?color=blue&label=weekly%20installs" alt="npm downloads" />
23
13
  </a>
24
14
  &nbsp;
25
- <a href="https://www.npmjs.com/package/@cachly-dev/mcp-server">
26
- <img src="https://img.shields.io/npm/dt/@cachly-dev/mcp-server?color=blueviolet&label=total%20installs" alt="total installs" />
27
- </a>
28
- &nbsp;
29
- <a href="https://cachly.dev?utm_source=npm&utm_medium=readme&utm_campaign=mcp-server">
30
- <img src="https://img.shields.io/badge/Free%20tier-โ‚ฌ0%2Fmo%20forever-brightgreen" alt="Free tier" />
15
+ <a href="https://cachly.dev">
16
+ <img src="https://img.shields.io/badge/Free%20tier-โ‚ฌ0%2Fmo-brightgreen" alt="Free tier" />
31
17
  </a>
32
18
  &nbsp;
33
19
  <a href="https://cachly.dev/legal">
34
- <img src="https://img.shields.io/badge/GDPR-EU%20servers-green" alt="GDPR: EU only" />
20
+ <img src="https://img.shields.io/badge/GDPR-EU%20servers-green" alt="GDPR: EU servers" />
35
21
  </a>
36
22
  &nbsp;
23
+ <img src="https://img.shields.io/badge/89%20MCP%20tools-violet" alt="89 MCP tools" />
24
+ &nbsp;
37
25
  <img src="https://img.shields.io/badge/License-Apache--2.0-yellow" alt="License: Apache-2.0" />
26
+ &nbsp;
27
+ <a href="https://cachly.dev">
28
+ <img src="https://img.shields.io/badge/Brain%20badge-embed%20in%20README-7c3aed" alt="Brain badge" />
29
+ </a>
38
30
  </p>
39
31
 
40
32
  ---
41
33
 
34
+ ## Try it right now โ€” no account needed
35
+
36
+ ```bash
37
+ npx @cachly-dev/mcp-server@latest demo
38
+ ```
39
+
40
+ Run this in any project directory. It reads your git history and shows exactly what your AI would know:
41
+
42
+ ```
43
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
44
+ โ”‚ ๐Ÿง  Brain Preview โ€” What your AI would know โ”‚
45
+ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
46
+ โ”‚ Commits analysed : 847 Date range: 2024-01-12 โ†’ 2026-05-14 โ”‚
47
+ โ”‚ Lessons extracted: 634 Contributors: 7 โ”‚
48
+ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
49
+ โ”‚ Category breakdown: โ”‚
50
+ โ”‚ ๐Ÿ”ง fix โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ 312 โ”‚
51
+ โ”‚ โœจ feat โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ 189 โ”‚
52
+ โ”‚ ๐Ÿ”’ security โ–ˆโ–ˆ 18 โ”‚
53
+ โ”‚ ๐Ÿš€ deploy โ–ˆโ–ˆ 15 โ”‚
54
+ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
55
+ โ”‚ ๐Ÿ”’ Security fixes your AI would know: โ”‚
56
+ โ”‚ โ€ข fix(auth): JWT expiry check before signature validation โ”‚
57
+ โ”‚ โ€ข security: sanitize webhook payload before JSON.parse โ”‚
58
+ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
59
+ โ”‚ ๐Ÿ”ง Bug fixes your AI would remember: โ”‚
60
+ โ”‚ โ€ข fix: Redis pub/sub race condition under high concurrency โ”‚
61
+ โ”‚ โ€ข fix: k8s readinessProbe threshold too low for cold start โ”‚
62
+ โ”‚ โ€ข fix: Stripe idempotency_key missing on retry path โ”‚
63
+ โ”‚ โ€ข fix: tRPC context not forwarded to background jobs โ”‚
64
+ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
65
+ โ”‚ ๐Ÿ’ก With cachly, your AI arrives pre-briefed every session. โ”‚
66
+ โ”‚ No more re-explaining. No more repeated mistakes. โ”‚
67
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
68
+
69
+ Make this permanent (free, 30 seconds):
70
+ $ npx @cachly-dev/mcp-server@latest setup
71
+
72
+ Works with: Claude Code ยท Cursor ยท Windsurf ยท Copilot ยท Cline ยท Zed
73
+ Free forever ยท GDPR ยท German servers ยท No credit card
74
+ ```
75
+
76
+ ---
77
+
42
78
  ## The Problem
43
79
 
44
80
  Every morning, you open your AI coding assistant. It doesn't remember yesterday.
45
81
  You explain your architecture. You explain the deployment process. You explain the bug you fixed last week.
46
82
 
47
- **The average developer wastes 45 minutes/day re-establishing context.**
48
- That's ~$18,000/year per developer โ€” before you even count the re-discovered bugs.
83
+ **The average developer wastes 45 minutes/day re-establishing context.**
49
84
 
50
85
  ---
51
86
 
52
87
  ## One Command. Fully Automatic.
53
88
 
54
89
  ```bash
55
- npx @cachly-dev/init
90
+ npx @cachly-dev/mcp-server@latest setup
56
91
  ```
57
92
 
58
93
  Run it once. It handles everything:
@@ -61,37 +96,15 @@ Run it once. It handles everything:
61
96
  2. **Detects your editors** โ€” Claude Code, Cursor, Windsurf, VS Code, Copilot, Cline & Zed
62
97
  3. **Writes the MCP config** for every detected editor automatically
63
98
  4. **Creates `CLAUDE.md`** with Brain rules so your AI acts autonomously
64
- 5. **Installs a git hook** that learns from every commit automatically
99
+ 5. **Reads your git history** โ€” extracts lessons from years of commits before your first session
100
+ 6. **Installs a git hook** โ€” learns from every future commit automatically
65
101
 
66
102
  **Restart your editor.** From now on your AI arrives pre-briefed โ€” every session.
67
103
 
68
- > **Also a VS Code user?** Install the **[cachly Brain extension](https://marketplace.visualstudio.com/items?itemName=cachly-dev.cachly-brain)** โ€” see your AI's memory, lesson count, and tokens saved right in the status bar.
69
-
70
- ---
71
-
72
- ## ๐Ÿ†“ What You Get for Free
73
-
74
- No credit card. No expiry. No catch.
75
-
76
- | Feature | Free tier |
77
- |---------|-----------|
78
- | Brain storage | 25 MB |
79
- | MCP tools | All 89 |
80
- | Sessions | Unlimited |
81
- | Projects | Unlimited |
82
- | Team sharing | 1 shared Brain |
83
- | Git hook learning | โœ… |
84
- | Causal root cause analysis | โœ… |
85
- | Failure prediction | โœ… |
86
-
87
- **[โ†’ Create your free Brain](https://cachly.dev?utm_source=npm&utm_medium=readme&utm_campaign=free-cta)**
88
-
89
104
  ---
90
105
 
91
106
  ## What happens after setup โ€” everything is automatic
92
107
 
93
- You never type another command. The Brain runs entirely in the background:
94
-
95
108
  | Trigger | What the Brain does automatically |
96
109
  |---------|----------------------------------|
97
110
  | First tool call | Session starts, project gets indexed in background |
@@ -116,31 +129,61 @@ You never type another command. The Brain runs entirely in the background:
116
129
 
117
130
  ---
118
131
 
132
+ ## CLI Commands
133
+
134
+ ```bash
135
+ npx @cachly-dev/mcp-server@latest demo # Preview your Brain (no account needed)
136
+ npx @cachly-dev/mcp-server@latest setup # Wire up all your AI editors (30 seconds)
137
+ npx @cachly-dev/mcp-server@latest health # Check token, API, editors, git hook
138
+ npx @cachly-dev/mcp-server@latest digest # Weekly Brain summary โ€” shareable
139
+ npx @cachly-dev/mcp-server@latest share # Generate a shareable stats card + tweet
140
+ npx @cachly-dev/mcp-server@latest badge # Get a live README badge for your Brain
141
+ npx @cachly-dev/mcp-server@latest invite # Invite a teammate to share your Brain
142
+ ```
143
+
144
+ ---
145
+
146
+ ## Brain Badge โ€” show your lessons live
147
+
148
+ Add a live lesson-count badge to any README โ€” updates every hour, no auth required:
149
+
150
+ ```bash
151
+ npx @cachly-dev/mcp-server@latest badge
152
+ ```
153
+
154
+ Outputs your personal Markdown snippet:
155
+
156
+ ```markdown
157
+ [![cachly Brain](https://api.cachly.dev/api/v1/badge/YOUR_INSTANCE_ID)](https://cachly.dev)
158
+ ```
159
+
160
+ Drop it in your repo's README and anyone visiting sees how many lessons your AI has accumulated. The badge endpoint is public, rate-limited, and only exposes the lesson count โ€” no topic names, no content.
161
+
162
+ ---
163
+
119
164
  ## What makes cachly different
120
165
 
121
166
  | Feature | What it does |
122
167
  |---------|-------------|
123
168
  | **`causal_trace`** | Root Cause Analysis through memory: problem โ†’ chain โ†’ solution. **No other system does this.** |
169
+ | **`brain_from_git`** | Reads your entire git history and loads every lesson before your first session. Incremental on repeat runs. |
170
+ | **`brain_predict`** | Predicts failures before they happen based on past incident patterns |
124
171
  | **`memory_consolidate`** | Weekly garbage collector โ€” detects contradictions, merges duplicates, expires stale lessons |
125
- | **`brain_predict`** | Predicts failures before they happen based on past patterns |
126
172
  | **Team Brain** | Shared lessons across your whole team with author attribution |
127
173
  | **Ambient Git** | git hook auto-extracts lessons from every commit. Zero extra calls. |
128
174
  | **Memory Crystals** | Distills all lessons into a compact snapshot for instant session briefing |
129
175
  | **11 languages** | BM25+ search in EN, DE, FR, ES, IT, PT, ZH, JA, KO, AR, HE โ€” no config |
130
176
 
131
- **The `causal_trace` moment:**
177
+ **`causal_trace` in action:**
132
178
  ```
133
179
  causal_trace(problem="auth breaks after restart")
134
180
 
135
181
  โ†’ Root: k8s:namespace-terminating
136
- โ†’ Via: keycloak:jwks-race
182
+ โ†’ Via: keycloak:jwks-race
137
183
  โ†’ Fix: PollUntilContextTimeout 3min โ† used this March 12, worked
138
184
  ```
139
185
  *30 minutes of git blame in one call.*
140
186
 
141
- **The `autopilot` command:**
142
- Run `autopilot` once and it generates a fully self-managing `CLAUDE.md` or `copilot-instructions.md` โ€” tailored to your actual Brain content. Every AI (Claude, Cursor, Copilot, Windsurf, Gemini) gets the full ruleset for your project. No copy-paste, no manual writing. As the Brain learns more, re-run `autopilot` to upgrade the file.
143
-
144
187
  ---
145
188
 
146
189
  ## cachly vs. alternatives
@@ -171,10 +214,10 @@ Run `autopilot` once and it generates a fully self-managing `CLAUDE.md` or `copi
171
214
  | **`learn_from_attempts`** | Store structured lessons after any fix, deploy, or discovery |
172
215
  | **`recall_best_solution`** | Best known solution for a topic โ€” with success/failure history |
173
216
  | **`remember_context`** | Cache architecture findings, decisions, file summaries |
174
- | **`recall_context`** | Get exact context by key (supports glob) |
175
217
  | **`smart_recall`** | BM25+ full-text search across all brain data โ€” 11 languages |
176
218
  | **`causal_trace`** | Root cause analysis through memory |
177
219
  | **`brain_predict`** | Predict likely failures before they happen |
220
+ | **`brain_from_git`** | Bootstrap from git history โ€” incremental, only new commits each run |
178
221
  | **`memory_consolidate`** | Deduplicate and expire stale lessons |
179
222
  | **`compact_recover`** | Full context recovery after hitting context window limit |
180
223
 
@@ -187,26 +230,22 @@ Run `autopilot` once and it generates a fully self-managing `CLAUDE.md` or `copi
187
230
  | `madc_deliberate` | 6 specialist AI agents vote to resolve contradictory lessons |
188
231
  | `memory_crystalize` | Distill all lessons into a Crystal for instant team context |
189
232
  | `brain_doctor` | Health check: lesson count, IQ boost %, open failures |
190
- | `autopilot` | Generate a self-managing `CLAUDE.md` / `copilot-instructions.md` from Brain content |
233
+ | `autopilot` | Generate a self-managing `CLAUDE.md` from Brain content |
191
234
  | `global_learn` / `global_recall` | Cross-project universal lessons |
192
- | `publish_lesson` / `import_public_brain` | Share/import community knowledge |
193
235
 
194
- ### ๐ŸŒ Knowledge Commons (Global)
236
+ ### ๐ŸŒ Knowledge Commons
195
237
 
196
238
  | Tool | What it does |
197
239
  |------|-------------|
198
240
  | `syndicate` | Contribute verified lesson to global Knowledge Commons |
199
- | `syndicate_search` | Search community solutions by tech stack |
200
- | `fedbrain_contribute` | Contribute with cryptographic provenance certificate |
201
241
  | `fedbrain_search` | Context-weighted global search |
202
242
 
203
- ### โš™๏ธ Cache & Infrastructure
243
+ ### โš™๏ธ Infrastructure
204
244
 
205
245
  | Tool | What it does |
206
246
  |------|-------------|
207
247
  | `list_instances` / `create_instance` / `delete_instance` | Manage Brain instances |
208
248
  | `cache_get` / `cache_set` / `cache_delete` | Standard cache operations |
209
- | `cache_mget` / `cache_mset` | Bulk pipeline (single round-trip) |
210
249
  | `semantic_search` | Find cached entries by meaning |
211
250
  | `index_project` | Index source files for semantic retrieval |
212
251
 
@@ -224,33 +263,27 @@ Run `autopilot` once and it generates a fully self-managing `CLAUDE.md` or `copi
224
263
  **Does my AI need to call `session_start` manually?**
225
264
  No. Sessions start and end automatically on the first tool call and when the editor closes.
226
265
 
227
- **What happens to memory if I switch projects?**
228
- Memory is scoped per Brain instance. You can have one instance per project, or one shared instance across projects.
266
+ **What is incremental `brain_from_git`?**
267
+ After the first run, only new commits since the last scan are processed. Repeated calls are instant.
229
268
 
230
269
  **Can my whole team share the same Brain?**
231
- Yes. `team_learn` / `team_recall` share lessons with author attribution. `memory_crystalize` gives any new team member instant full context.
270
+ Yes. Use `team_learn` / `team_recall` or run `npx @cachly-dev/mcp-server@latest invite teammate@example.com`.
232
271
 
233
272
  **What is a Memory Crystal?**
234
- A compressed snapshot of all lessons distilled into a compact briefing. Injected at every session start so the AI arrives pre-briefed even with a cold context window.
235
-
236
- **What is causal_trace and why is it unique?**
237
- Given any error or problem, `causal_trace` walks the Causal Knowledge Graph (CKG) to find: the root cause, intermediate causes, and the exact fix that worked โ€” including the date and commands used. No other memory system builds or queries a causal graph.
273
+ A compressed snapshot of all lessons injected at every session start. The AI arrives pre-briefed even with a cold context window.
238
274
 
239
- **How does cachly learn from git commits?**
240
- The `setup` wizard installs a git post-commit hook. After each commit, the hook calls `cls_ingest` with the commit message and changed files. The Brain extracts lessons automatically โ€” no `session_end` required.
241
-
242
- **What happens if I hit the context window limit mid-session?**
243
- Call `compact_recover`. It reconstructs full context from the Memory Crystal + recent sessions + WIP registry entries โ€” typically restoring full context in one tool call.
275
+ **What is `causal_trace` and why is it unique?**
276
+ Given any error, `causal_trace` walks the Causal Knowledge Graph to find: root cause, intermediate causes, and the exact fix that worked โ€” including the date and commands used. No other memory system builds or queries a causal graph.
244
277
 
245
278
  **Is my code sent to cachly servers?**
246
- No code content is stored. cachly stores: lesson text, commit messages, session summaries, and key-value context entries. All data is on German servers, GDPR-compliant.
279
+ No code content is stored. cachly stores: lesson text, commit messages, session summaries, key-value context entries. All data on German servers, GDPR-compliant.
247
280
 
248
- **Does cachly work without an internet connection?**
249
- No โ€” cachly is a managed cloud service. The MCP server is a thin client; the Brain runs on cachly's infrastructure.
281
+ **What if I hit the context window limit mid-session?**
282
+ Call `compact_recover`. It reconstructs full context from Memory Crystal + recent sessions + WIP registry โ€” typically one tool call.
250
283
 
251
284
  ---
252
285
 
253
- ## Manual Setup (alternative to the wizard)
286
+ ## Manual Setup
254
287
 
255
288
  <details>
256
289
  <summary><b>Claude Code</b> (<code>~/.claude/mcp.json</code> or <code>.mcp.json</code>)</summary>
@@ -269,7 +302,7 @@ On the first tool call your AI will prompt you to sign in โ€” takes 10 seconds.
269
302
  </details>
270
303
 
271
304
  <details>
272
- <summary><b>Cursor / Windsurf / VS Code / Copilot / Cline</b> (<code>.cursor/mcp.json</code> / <code>.mcp.json</code>)</summary>
305
+ <summary><b>Cursor / Windsurf / VS Code / Copilot / Cline</b></summary>
273
306
 
274
307
  ```json
275
308
  {
@@ -284,6 +317,23 @@ On the first tool call your AI will prompt you to sign in โ€” takes 10 seconds.
284
317
  ```
285
318
  </details>
286
319
 
320
+ <details>
321
+ <summary><b>Zed</b> (<code>.zed/settings.json</code>)</summary>
322
+
323
+ ```json
324
+ {
325
+ "context_servers": {
326
+ "cachly": {
327
+ "command": {
328
+ "path": "npx",
329
+ "args": ["-y", "@cachly-dev/mcp-server@latest"]
330
+ }
331
+ }
332
+ }
333
+ }
334
+ ```
335
+ </details>
336
+
287
337
  ---
288
338
 
289
339
  ## Pricing
@@ -302,12 +352,10 @@ On the first tool call your AI will prompt you to sign in โ€” takes 10 seconds.
302
352
 
303
353
  ## Environment Variables
304
354
 
305
- Set automatically by the setup wizard โ€” only needed for manual configuration.
306
-
307
355
  | Variable | Default | Description |
308
356
  |----------|---------|-------------|
309
- | `CACHLY_JWT` | โ€” | API token (set by wizard, or get from cachly.dev) |
310
- | `CACHLY_BRAIN_INSTANCE_ID` | โ€” | Default instance UUID (optional if passed per-call) |
357
+ | `CACHLY_JWT` | โ€” | API token (set by wizard automatically) |
358
+ | `CACHLY_BRAIN_INSTANCE_ID` | โ€” | Default instance UUID (optional โ€” auto-resolved) |
311
359
  | `CACHLY_API_URL` | `https://api.cachly.dev` | Override for self-hosted |
312
360
  | `CACHLY_NO_TELEMETRY` | unset | Set to `1` to disable anonymous usage pings |
313
361
 
@@ -315,40 +363,16 @@ Set automatically by the setup wizard โ€” only needed for manual configuration.
315
363
 
316
364
  ## ๐Ÿ› ๏ธ Ecosystem
317
365
 
318
- | Package / Extension | What it does |
319
- |---------------------|-------------|
320
- | **[`@cachly-dev/mcp-server`](https://www.npmjs.com/package/@cachly-dev/mcp-server)** | โ† you are here โ€” AI Brain for all MCP-compatible editors |
321
- | **[VS Code Extension](https://marketplace.visualstudio.com/items?itemName=cachly-dev.cachly-brain)** | See your Brain's lessons, health & tokens saved inside VS Code |
322
- | **[`@cachly-dev/init`](https://www.npmjs.com/package/@cachly-dev/init)** | One-command setup wizard โ€” detects editors, writes configs automatically |
323
- | **[`@cachly-dev/openclaw`](https://www.npmjs.com/package/@cachly-dev/openclaw)** | Cut LLM costs 60โ€“90% with semantic caching in JS/TS apps |
324
- | **[`@cachly-dev/cli`](https://www.npmjs.com/package/@cachly-dev/cli)** | Terminal CLI โ€” manage Brain instances from your shell |
325
- | **[Go SDK](https://github.com/cachly-dev/sdk-go)** | Native Go client for the cachly API |
326
- | **[Python SDK](https://github.com/cachly-dev/sdk-python)** | Native Python client |
327
- | **[Java / Kotlin / .NET / Rust / PHP / Swift](https://cachly.dev/docs)** | SDKs in 11 languages |
328
-
329
- ---
330
-
331
- ## ๐Ÿ“– Blog & Guides
332
-
333
- - **[How to give Claude Code persistent memory](https://cachly.dev/blog/claude-code-mcp-memory)** โ€” step-by-step
334
- - **[Windsurf persistent memory with cachly](https://cachly.dev/blog/windsurf-persistent-memory)** โ€” full guide
335
- - **[Cline MCP memory โ€” stop re-explaining everything](https://cachly.dev/blog/cline-mcp-memory)** โ€” Cline setup
336
- - **[cachly vs. mem0 โ€” full comparison](https://cachly.dev/blog)** โ€” which is right for you
366
+ | Package | What it does |
367
+ |---------|-------------|
368
+ | **[`@cachly-dev/mcp-server`](https://www.npmjs.com/package/@cachly-dev/mcp-server)** | โ† you are here |
369
+ | **[`@cachly-dev/openclaw`](https://www.npmjs.com/package/@cachly-dev/openclaw)** | Cut LLM costs 60โ€“90% in JS/TS apps |
337
370
 
338
371
  ---
339
372
 
340
373
  ## Links
341
374
 
342
- - ๐ŸŒ [cachly.dev](https://cachly.dev?utm_source=npm&utm_medium=readme&utm_campaign=mcp-server) โ€” Dashboard & free Brain signup
375
+ - ๐ŸŒ [cachly.dev](https://cachly.dev) โ€” Dashboard & free signup
343
376
  - ๐Ÿ“– [Docs](https://cachly.dev/docs/ai-memory) โ€” Full documentation
344
- - ๐Ÿ”Œ [VS Code Extension](https://marketplace.visualstudio.com/items?itemName=cachly-dev.cachly-brain) โ€” Brain panel inside VS Code
345
377
  - ๐Ÿ’ฌ [GitHub Issues](https://github.com/cachly-dev/cachly-mcp/issues) โ€” Bug reports & feature requests
346
378
  - โญ [Star on GitHub](https://github.com/cachly-dev/cachly-mcp) โ€” If cachly saves you time, a star means a lot!
347
-
348
- ---
349
-
350
- <p align="center">
351
- <a href="https://cachly.dev?utm_source=npm&utm_medium=readme&utm_campaign=mcp-bottom">
352
- <strong>โ†’ Start free at cachly.dev โ€” no credit card, no expiry</strong>
353
- </a>
354
- </p>
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,107 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { ErrorCode } from '@modelcontextprotocol/sdk/types.js';
3
+ import { jwtExpiryMs, checkJwt, handleApiError } from '../auth.js';
4
+ function makeJwt(payload) {
5
+ const header = Buffer.from(JSON.stringify({ alg: 'HS256', typ: 'JWT' })).toString('base64url');
6
+ const body = Buffer.from(JSON.stringify(payload)).toString('base64url');
7
+ return `${header}.${body}.fakesig`;
8
+ }
9
+ const nowSec = () => Math.floor(Date.now() / 1000);
10
+ describe('jwtExpiryMs', () => {
11
+ it('returns null for an empty string', () => {
12
+ expect(jwtExpiryMs('')).toBeNull();
13
+ });
14
+ it('returns null for a plain (non-JWT) string', () => {
15
+ expect(jwtExpiryMs('not-a-token')).toBeNull();
16
+ });
17
+ it('returns null when the JWT has only two parts', () => {
18
+ expect(jwtExpiryMs('header.payload')).toBeNull();
19
+ });
20
+ it('returns null when the JWT has four parts', () => {
21
+ expect(jwtExpiryMs('a.b.c.d')).toBeNull();
22
+ });
23
+ it('returns null when the payload base64 is invalid', () => {
24
+ expect(jwtExpiryMs('header.!!!.sig')).toBeNull();
25
+ });
26
+ it('returns null when the payload has no exp field', () => {
27
+ expect(jwtExpiryMs(makeJwt({ sub: 'user-123', iat: nowSec() }))).toBeNull();
28
+ });
29
+ it('returns null when exp is 0', () => {
30
+ expect(jwtExpiryMs(makeJwt({ exp: 0 }))).toBeNull();
31
+ });
32
+ it('converts exp (seconds) to milliseconds', () => {
33
+ const expSec = nowSec() + 3600;
34
+ expect(jwtExpiryMs(makeJwt({ exp: expSec }))).toBe(expSec * 1000);
35
+ });
36
+ it('returns a past timestamp for an expired token', () => {
37
+ expect(jwtExpiryMs(makeJwt({ exp: nowSec() - 300 }))).toBeLessThan(Date.now());
38
+ });
39
+ it('returns a future timestamp for a valid token', () => {
40
+ expect(jwtExpiryMs(makeJwt({ exp: nowSec() + 86400 }))).toBeGreaterThan(Date.now());
41
+ });
42
+ it('handles a token expiring in less than 60 minutes', () => {
43
+ const expSec = nowSec() + 30 * 60;
44
+ const result = jwtExpiryMs(makeJwt({ exp: expSec }));
45
+ const minsLeft = Math.floor((result - Date.now()) / 60_000);
46
+ expect(minsLeft).toBeGreaterThanOrEqual(29);
47
+ expect(minsLeft).toBeLessThanOrEqual(30);
48
+ });
49
+ it('ignores extra claims', () => {
50
+ const expSec = nowSec() + 3600;
51
+ expect(jwtExpiryMs(makeJwt({ sub: 'u', iat: nowSec(), exp: expSec, plan: 'free' }))).toBe(expSec * 1000);
52
+ });
53
+ it('handles padding-free base64url payloads', () => {
54
+ // base64url (no =) โ€” Buffer.from handles this natively
55
+ const expSec = nowSec() + 7200;
56
+ expect(jwtExpiryMs(makeJwt({ exp: expSec, x: 'a' }))).toBe(expSec * 1000);
57
+ });
58
+ });
59
+ describe('checkJwt', () => {
60
+ it('throws InvalidRequest when jwt is empty', () => {
61
+ expect(() => checkJwt('')).toThrowError(expect.objectContaining({ code: ErrorCode.InvalidRequest, message: expect.stringContaining('CACHLY_JWT env var not set') }));
62
+ });
63
+ it('throws with setup URL when jwt is missing', () => {
64
+ expect(() => checkJwt('')).toThrowError(expect.objectContaining({ message: expect.stringContaining('cachly.dev/setup-ai') }));
65
+ });
66
+ it('throws InvalidRequest with expiry timestamp for an expired token', () => {
67
+ const expSec = nowSec() - 60;
68
+ const token = makeJwt({ exp: expSec });
69
+ expect(() => checkJwt(token)).toThrowError(expect.objectContaining({
70
+ code: ErrorCode.InvalidRequest,
71
+ message: expect.stringContaining('expired at'),
72
+ }));
73
+ });
74
+ it('does not throw for a valid non-expired token', () => {
75
+ expect(() => checkJwt(makeJwt({ exp: nowSec() + 3600 }))).not.toThrow();
76
+ });
77
+ it('does not throw for a token with no exp claim', () => {
78
+ expect(() => checkJwt(makeJwt({ sub: 'user' }))).not.toThrow();
79
+ });
80
+ });
81
+ describe('handleApiError', () => {
82
+ it('throws InvalidRequest for 401 with the detail message', () => {
83
+ expect(() => handleApiError(401, 'token expired')).toThrowError(expect.objectContaining({
84
+ code: ErrorCode.InvalidRequest,
85
+ message: expect.stringContaining('Authentication failed (401): token expired'),
86
+ }));
87
+ });
88
+ it('throws InvalidRequest for 403 with the detail message', () => {
89
+ expect(() => handleApiError(403, 'plan limit reached')).toThrowError(expect.objectContaining({
90
+ code: ErrorCode.InvalidRequest,
91
+ message: expect.stringContaining('Access denied (403): plan limit reached'),
92
+ }));
93
+ });
94
+ it('throws InternalError for other status codes', () => {
95
+ expect(() => handleApiError(500, 'server crash')).toThrowError(expect.objectContaining({
96
+ code: ErrorCode.InternalError,
97
+ message: expect.stringContaining('cachly API error 500: server crash'),
98
+ }));
99
+ });
100
+ it('includes the cachly.dev/setup-ai link for 401 errors', () => {
101
+ expect(() => handleApiError(401, 'Unauthorized')).toThrowError(expect.objectContaining({ message: expect.stringContaining('cachly.dev/setup-ai') }));
102
+ });
103
+ it('includes account access hint for 403 errors', () => {
104
+ expect(() => handleApiError(403, 'Forbidden')).toThrowError(expect.objectContaining({ message: expect.stringContaining('access to this resource') }));
105
+ });
106
+ });
107
+ //# sourceMappingURL=auth.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.test.js","sourceRoot":"","sources":["../../src/__tests__/auth.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAY,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEnE,SAAS,OAAO,CAAC,OAAgC;IAC/C,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE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,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE;QACrD,MAAM,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,YAAY,CACzD,MAAM,CAAC,gBAAgB,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,gBAAgB,CAAC,yBAAyB,CAAC,EAAE,CAAC,CACzF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -5,13 +5,15 @@ import { safeJsonParse } from '../utils.js';
5
5
  import { keywordSearch, tokenize, splitMultiQuery, levenshtein, indexVocab as _indexVocab } from '../search.js';
6
6
  import { computeEmbedding, hasEmbedProvider } from '../embeddings.js';
7
7
  // โ”€โ”€ Changelog (shown once per version in session_start) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
8
- const MCP_VERSION = '0.10.10';
8
+ const MCP_VERSION = '0.10.0';
9
9
  const WHATS_NEW = {
10
- '0.10.10': [
10
+ '0.10.0': [
11
11
  `๐Ÿ†• **What's new in v${MCP_VERSION}:**`,
12
- ` ๐Ÿ“Œ **pin_lesson / unpin_lesson** โ€” Pin critical lessons to always show in session_start`,
13
- ` ๐Ÿ“Š **brain_stats** โ€” At-a-glance health dashboard (lessons, streak, roadmap, pinned, top topics)`,
14
- ` โœ… Pinned lessons appear at top of every session briefing โ€” never decay, never forgotten`,
12
+ ` โœ… Zero-friction setup โ€” auto-provisions your Brain, no manual config needed`,
13
+ ` โœ… 10ร— faster briefings โ€” batch Redis fetches replace per-key loops`,
14
+ ` โœ… Crash-proof data reads โ€” corrupted cache entries no longer break tools`,
15
+ ` โœ… \`session_end\` warns when called without an active session`,
16
+ ` โœ… \`get_api_status\` now shows live Redis ping + all instance statuses`,
15
17
  ],
16
18
  };
17
19
  export const BRAIN_TOOL_NAMES = new Set([
@@ -270,20 +272,6 @@ export async function handleBrainTool(name, args, getConnection, apiFetch) {
270
272
  }
271
273
  }
272
274
  catch { /* CKG updates are non-critical */ }
273
- // โ”€โ”€ Auto-pin critical lessons โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
274
- // severity=critical โ†’ always pin automatically so the lesson
275
- // appears in every session_start without the user ever calling pin_lesson.
276
- let autoPinNote = '';
277
- if (severity === 'critical' && (outcome === 'success' || outcome === 'partial')) {
278
- try {
279
- const alreadyPinned = await redis.exists(`cachly:lesson:pin:${topic}`);
280
- if (!alreadyPinned) {
281
- await redis.set(`cachly:lesson:pin:${topic}`, '1');
282
- autoPinNote = `๐Ÿ“Œ Auto-pinned (critical severity) โ€” will appear in every session_start.`;
283
- }
284
- }
285
- catch { /* non-critical */ }
286
- }
287
275
  const emoji = outcome === 'success' ? 'โœ…' : outcome === 'partial' ? 'โš ๏ธ' : 'โŒ';
288
276
  const sevEmoji = severity === 'critical' ? '๐Ÿ”ด' : severity === 'major' ? '๐ŸŸก' : '๐ŸŸข';
289
277
  const action = isUpdate ? 'updated' : 'stored';
@@ -304,7 +292,6 @@ export async function handleBrainTool(name, args, getConnection, apiFetch) {
304
292
  depends_on.length > 0
305
293
  ? `๐Ÿ”— Depends on: ${depends_on.map(d => `\`${d}\``).join(', ')} โ†’ trace with \`trace_dependency\``
306
294
  : '',
307
- autoPinNote,
308
295
  ...templateWarnings,
309
296
  ...iWasWrongWarning,
310
297
  ].filter(l => l !== '').join('\n');
@@ -831,37 +818,6 @@ export async function handleBrainTool(name, args, getConnection, apiFetch) {
831
818
  }
832
819
  lines.push('');
833
820
  }
834
- // โ”€โ”€ Pinned lessons โ€” always shown regardless of age/confidence โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
835
- try {
836
- const pinKeys = [];
837
- const pinStream = redis.scanStream({ match: 'cachly:lesson:pin:*', count: 100 });
838
- await new Promise((res, rej) => {
839
- pinStream.on('data', (b) => pinKeys.push(...b));
840
- pinStream.on('end', res);
841
- pinStream.on('error', rej);
842
- });
843
- if (pinKeys.length > 0) {
844
- const pinnedTopics = pinKeys.map(k => k.replace('cachly:lesson:pin:', ''));
845
- const pinLessonRaws = await redis.mget(...pinnedTopics.map(t => `cachly:lesson:best:${t}`));
846
- const pinLines = [];
847
- for (const raw of pinLessonRaws) {
848
- if (!raw)
849
- continue;
850
- const l = safeJsonParse(raw, null);
851
- if (!l)
852
- continue;
853
- const emoji = l.outcome === 'success' ? 'โœ…' : l.outcome === 'partial' ? 'โš ๏ธ' : 'โŒ';
854
- const sev = l.severity === 'critical' ? '๐Ÿ”ด' : l.severity === 'major' ? '๐ŸŸก' : '';
855
- pinLines.push(` ๐Ÿ“Œ${emoji}${sev} \`${l.topic}\` โ€” ${l.what_worked.slice(0, 100)}`);
856
- }
857
- if (pinLines.length > 0) {
858
- lines.push(`๐Ÿ“Œ **Pinned lessons (always shown):**`);
859
- lines.push(...pinLines);
860
- lines.push('');
861
- }
862
- }
863
- }
864
- catch { /* non-critical */ }
865
821
  // Recent lessons
866
822
  if (lessons.length > 0) {
867
823
  lines.push(`๐Ÿ• **Recent lessons:**`);
@@ -1328,21 +1284,6 @@ export async function handleBrainTool(name, args, getConnection, apiFetch) {
1328
1284
  catch { /* git not available or not a repo โ€” silent skip */ }
1329
1285
  }
1330
1286
  const durationStr = durationMin !== undefined ? ` ยท ${durationMin} min` : '';
1331
- // โ”€โ”€ Mini brain-stats snapshot at session end โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
1332
- let miniStatsLines = [];
1333
- try {
1334
- const totalLessons = await redis.keys('cachly:lesson:best:*').then(k => k.length).catch(() => 0);
1335
- const pinCount = await redis.keys('cachly:lesson:pin:*').then(k => k.length).catch(() => 0);
1336
- const streakRaw = await redis.get('cachly:streak:current');
1337
- const streak = streakRaw ? JSON.parse(streakRaw).days : 0;
1338
- const parts = [`๐Ÿ“š ${totalLessons} lesson${totalLessons !== 1 ? 's' : ''} total`];
1339
- if (pinCount > 0)
1340
- parts.push(`๐Ÿ“Œ ${pinCount} pinned`);
1341
- if (streak > 1)
1342
- parts.push(`๐Ÿ”ฅ ${streak}-day streak`);
1343
- miniStatsLines = [`๐Ÿง  **Brain:** ${parts.join(' ยท ')}`];
1344
- }
1345
- catch { /* non-critical */ }
1346
1287
  return [
1347
1288
  `โœ… **Session saved**${durationStr}`,
1348
1289
  ``,
@@ -1351,7 +1292,6 @@ export async function handleBrainTool(name, args, getConnection, apiFetch) {
1351
1292
  lessons_learned !== undefined ? `๐Ÿง  **Lessons stored:** ${lessons_learned}` : '',
1352
1293
  autoLearned.length > 0 ? `๐Ÿค– **Auto-learned:** ${autoLearned.length} lessons extracted from summary (${autoLearned.slice(0, 3).map(t => `\`${t}\``).join(', ')}${autoLearned.length > 3 ? 'โ€ฆ' : ''})` : '',
1353
1294
  ambientLearned.length > 0 ? `๐ŸŒฟ **Ambient git learning:** ${ambientLearned.length} commit${ambientLearned.length > 1 ? 's' : ''} auto-learned (${ambientLearned.slice(0, 3).map(t => `\`${t}\``).join(', ')}${ambientLearned.length > 3 ? 'โ€ฆ' : ''})` : '',
1354
- ...miniStatsLines,
1355
1295
  ``,
1356
1296
  `๐Ÿ’ก Next session: \`session_start(focus="...")\` to see this summary.`,
1357
1297
  ].filter(l => l !== '').join('\n');