@cachly-dev/mcp-server 0.10.6 → 0.10.7

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.
package/LICENSE DELETED
@@ -1,202 +0,0 @@
1
-
2
- Apache License
3
- Version 2.0, January 2004
4
- http://www.apache.org/licenses/
5
-
6
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
-
8
- 1. Definitions.
9
-
10
- "License" shall mean the terms and conditions for use, reproduction,
11
- and distribution as defined by Sections 1 through 9 of this document.
12
-
13
- "Licensor" shall mean the copyright owner or entity authorized by
14
- the copyright owner that is granting the License.
15
-
16
- "Legal Entity" shall mean the union of the acting entity and all
17
- other entities that control, are controlled by, or are under common
18
- control with that entity. For the purposes of this definition,
19
- "control" means (i) the power, direct or indirect, to cause the
20
- direction or management of such entity, whether by contract or
21
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
- outstanding shares, or (iii) beneficial ownership of such entity.
23
-
24
- "You" (or "Your") shall mean an individual or Legal Entity
25
- exercising permissions granted by this License.
26
-
27
- "Source" form shall mean the preferred form for making modifications,
28
- including but not limited to software source code, documentation
29
- source, and configuration files.
30
-
31
- "Object" form shall mean any form resulting from mechanical
32
- transformation or translation of a Source form, including but
33
- not limited to compiled object code, generated documentation,
34
- and conversions to other media types.
35
-
36
- "Work" shall mean the work of authorship, whether in Source or
37
- Object form, made available under the License, as indicated by a
38
- copyright notice that is included in or attached to the work
39
- (an example is provided in the Appendix below).
40
-
41
- "Derivative Works" shall mean any work, whether in Source or Object
42
- form, that is based on (or derived from) the Work and for which the
43
- editorial revisions, annotations, elaborations, or other modifications
44
- represent, as a whole, an original work of authorship. For the purposes
45
- of this License, Derivative Works shall not include works that remain
46
- separable from, or merely link (or bind by name) to the interfaces of,
47
- the Work and Derivative Works thereof.
48
-
49
- "Contribution" shall mean any work of authorship, including
50
- the original version of the Work and any modifications or additions
51
- to that Work or Derivative Works thereof, that is intentionally
52
- submitted to Licensor for inclusion in the Work by the copyright owner
53
- or by an individual or Legal Entity authorized to submit on behalf of
54
- the copyright owner. For the purposes of this definition, "submitted"
55
- means any form of electronic, verbal, or written communication sent
56
- to the Licensor or its representatives, including but not limited to
57
- communication on electronic mailing lists, source code control systems,
58
- and issue tracking systems that are managed by, or on behalf of, the
59
- Licensor for the purpose of discussing and improving the Work, but
60
- excluding communication that is conspicuously marked or otherwise
61
- designated in writing by the copyright owner as "Not a Contribution."
62
-
63
- "Contributor" shall mean Licensor and any individual or Legal Entity
64
- on behalf of whom a Contribution has been received by Licensor and
65
- subsequently incorporated within the Work.
66
-
67
- 2. Grant of Copyright License. Subject to the terms and conditions of
68
- this License, each Contributor hereby grants to You a perpetual,
69
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
- copyright license to reproduce, prepare Derivative Works of,
71
- publicly display, publicly perform, sublicense, and distribute the
72
- Work and such Derivative Works in Source or Object form.
73
-
74
- 3. Grant of Patent License. Subject to the terms and conditions of
75
- this License, each Contributor hereby grants to You a perpetual,
76
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
- (except as stated in this section) patent license to make, have made,
78
- use, offer to sell, sell, import, and otherwise transfer the Work,
79
- where such license applies only to those patent claims licensable
80
- by such Contributor that are necessarily infringed by their
81
- Contribution(s) alone or by combination of their Contribution(s)
82
- with the Work to which such Contribution(s) was submitted. If You
83
- institute patent litigation against any entity (including a
84
- cross-claim or counterclaim in a lawsuit) alleging that the Work
85
- or a Contribution incorporated within the Work constitutes direct
86
- or contributory patent infringement, then any patent licenses
87
- granted to You under this License for that Work shall terminate
88
- as of the date such litigation is filed.
89
-
90
- 4. Redistribution. You may reproduce and distribute copies of the
91
- Work or Derivative Works thereof in any medium, with or without
92
- modifications, and in Source or Object form, provided that You
93
- meet the following conditions:
94
-
95
- (a) You must give any other recipients of the Work or
96
- Derivative Works a copy of this License; and
97
-
98
- (b) You must cause any modified files to carry prominent notices
99
- stating that You changed the files; and
100
-
101
- (c) You must retain, in the Source form of any Derivative Works
102
- that You distribute, all copyright, patent, trademark, and
103
- attribution notices from the Source form of the Work,
104
- excluding those notices that do not pertain to any part of
105
- the Derivative Works; and
106
-
107
- (d) If the Work includes a "NOTICE" text file as part of its
108
- distribution, then any Derivative Works that You distribute must
109
- include a readable copy of the attribution notices contained
110
- within such NOTICE file, excluding those notices that do not
111
- pertain to any part of the Derivative Works, in at least one
112
- of the following places: within a NOTICE text file distributed
113
- as part of the Derivative Works; within the Source form or
114
- documentation, if provided along with the Derivative Works; or,
115
- within a display generated by the Derivative Works, if and
116
- wherever such third-party notices normally appear. The contents
117
- of the NOTICE file are for informational purposes only and
118
- do not modify the License. You may add Your own attribution
119
- notices within Derivative Works that You distribute, alongside
120
- or as an addendum to the NOTICE text from the Work, provided
121
- that such additional attribution notices cannot be construed
122
- as modifying the License.
123
-
124
- You may add Your own copyright statement to Your modifications and
125
- may provide additional or different license terms and conditions
126
- for use, reproduction, or distribution of Your modifications, or
127
- for any such Derivative Works as a whole, provided Your use,
128
- reproduction, and distribution of the Work otherwise complies with
129
- the conditions stated in this License.
130
-
131
- 5. Submission of Contributions. Unless You explicitly state otherwise,
132
- any Contribution intentionally submitted for inclusion in the Work
133
- by You to the Licensor shall be under the terms and conditions of
134
- this License, without any additional terms or conditions.
135
- Notwithstanding the above, nothing herein shall supersede or modify
136
- the terms of any separate license agreement you may have executed
137
- with Licensor regarding such Contributions.
138
-
139
- 6. Trademarks. This License does not grant permission to use the trade
140
- names, trademarks, service marks, or product names of the Licensor,
141
- except as required for reasonable and customary use in describing the
142
- origin of the Work and reproducing the content of the NOTICE file.
143
-
144
- 7. Disclaimer of Warranty. Unless required by applicable law or
145
- agreed to in writing, Licensor provides the Work (and each
146
- Contributor provides its Contributions) on an "AS IS" BASIS,
147
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
- implied, including, without limitation, any warranties or conditions
149
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
- PARTICULAR PURPOSE. You are solely responsible for determining the
151
- appropriateness of using or redistributing the Work and assume any
152
- risks associated with Your exercise of permissions under this License.
153
-
154
- 8. Limitation of Liability. In no event and under no legal theory,
155
- whether in tort (including negligence), contract, or otherwise,
156
- unless required by applicable law (such as deliberate and grossly
157
- negligent acts) or agreed to in writing, shall any Contributor be
158
- liable to You for damages, including any direct, indirect, special,
159
- incidental, or consequential damages of any character arising as a
160
- result of this License or out of the use or inability to use the
161
- Work (including but not limited to damages for loss of goodwill,
162
- work stoppage, computer failure or malfunction, or any and all
163
- other commercial damages or losses), even if such Contributor
164
- has been advised of the possibility of such damages.
165
-
166
- 9. Accepting Warranty or Additional Liability. While redistributing
167
- the Work or Derivative Works thereof, You may choose to offer,
168
- and charge a fee for, acceptance of support, warranty, indemnity,
169
- or other liability obligations and/or rights consistent with this
170
- License. However, in accepting such obligations, You may act only
171
- on Your own behalf and on Your sole responsibility, not on behalf
172
- of any other Contributor, and only if You agree to indemnify,
173
- defend, and hold each Contributor harmless for any liability
174
- incurred by, or claims asserted against, such Contributor by reason
175
- of your accepting any such warranty or additional liability.
176
-
177
- END OF TERMS AND CONDITIONS
178
-
179
- APPENDIX: How to apply the Apache License to your work.
180
-
181
- To apply the Apache License to your work, attach the following
182
- boilerplate notice, with the fields enclosed by brackets "[]"
183
- replaced with your own identifying information. (Don't include
184
- the brackets!) The text should be enclosed in the appropriate
185
- comment syntax for the file format. We also recommend that a
186
- file or class name and description of purpose be included on the
187
- same "printed page" as the copyright notice for easier
188
- identification within third-party archives.
189
-
190
- Copyright [yyyy] [name of copyright owner]
191
-
192
- Licensed under the Apache License, Version 2.0 (the "License");
193
- you may not use this file except in compliance with the License.
194
- You may obtain a copy of the License at
195
-
196
- http://www.apache.org/licenses/LICENSE-2.0
197
-
198
- Unless required by applicable law or agreed to in writing, software
199
- distributed under the License is distributed on an "AS IS" BASIS,
200
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
- See the License for the specific language governing permissions and
202
- limitations under the License.
@@ -1 +0,0 @@
1
- export {};
@@ -1,107 +0,0 @@
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
@@ -1 +0,0 @@
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,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC/F,MAAM,IAAI,GAAK,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC1E,OAAO,GAAG,M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EAAE,MAAM,CAAC,gBAAgB,CAAC,yBAAyB,CAAC,EAAE,CAAC,CACzF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/glama.json DELETED
@@ -1,29 +0,0 @@
1
- {
2
- "$schema": "https://glama.ai/mcp/schemas/server.json",
3
- "maintainers": [
4
- "HeinrichNebula"
5
- ],
6
- "categories": [
7
- "memory",
8
- "developer-tools",
9
- "productivity",
10
- "knowledge-management",
11
- "team-collaboration"
12
- ],
13
- "keywords": [
14
- "persistent-memory",
15
- "ai-memory",
16
- "mcp-server",
17
- "claude-code",
18
- "cursor",
19
- "copilot",
20
- "windsurf",
21
- "causal-trace",
22
- "brain-predict",
23
- "smart-recall",
24
- "knowledge-graph",
25
- "team-brain",
26
- "gdpr",
27
- "free-tier"
28
- ]
29
- }
package/llms.txt DELETED
@@ -1,155 +0,0 @@
1
- # cachly AI Brain — MCP Server
2
-
3
- > Persistent memory layer for AI coding assistants. Gives Claude Code, Cursor, GitHub Copilot, Windsurf, Cline and Zed a permanent brain that learns from every session, bug fix, git commit, and CI run — automatically.
4
-
5
- ## What cachly is
6
-
7
- cachly is an MCP (Model Context Protocol) server that adds long-term memory to AI coding assistants. Unlike conversation-window context, cachly memory persists forever across sessions, projects, and team members.
8
-
9
- It works by maintaining a Causal Knowledge Graph (CKG) — a structured store of lessons, bug fixes, architecture decisions, deployment commands, and failure patterns. On every session start, the AI receives a briefing with relevant lessons. On every fix or commit, new lessons are automatically stored.
10
-
11
- **Key differentiator**: causal_trace — given any error or problem description, traces the causal chain through the graph (root cause → intermediate causes → known fix). No other memory system does this.
12
-
13
- ## Installation (zero config)
14
-
15
- ```bash
16
- npx @cachly-dev/mcp-server@latest setup
17
- ```
18
-
19
- This command: authenticates via OAuth device flow (one browser click), auto-detects all installed editors, writes the correct MCP config for each, creates CLAUDE.md with Brain rules, installs a git post-commit hook.
20
-
21
- Free tier: 25 MB, no credit card, German servers (GDPR).
22
-
23
- ## Supported editors
24
-
25
- Claude Code, Cursor, Windsurf, VS Code, GitHub Copilot, Cline, Zed, Continue.dev
26
-
27
- ## How memory works
28
-
29
- 1. Session starts → AI receives: last session summary, open failures, relevant lessons, memory crystal (compressed history)
30
- 2. During work → AI stores: WIP state, architecture decisions, file summaries
31
- 3. Bug fixed → lesson stored: what failed, what worked, commands used, severity, file paths
32
- 4. Editor closes → session summary saved, git log analyzed, ambient lessons extracted
33
- 5. Next session → AI arrives pre-briefed
34
-
35
- ## Tool catalog (89 tools)
36
-
37
- ### Session & Memory
38
- - session_start: Single-call session briefing — last summary, open failures, recent lessons, brain health
39
- - session_end: Save session summary when finishing work
40
- - session_handoff: Detailed handoff for next chat window
41
- - session_ping: Lightweight checkpoint every ~5 tool calls
42
- - auto_learn_session: Auto-learn from session observations without explicit calls
43
- - sync_file_changes: Associate recent file changes with brain knowledge
44
-
45
- ### Lesson Storage & Recall
46
- - learn_from_attempts: Store structured lesson from any fix, deploy, or discovery
47
- - recall_best_solution: Best known solution for a topic with success/failure history
48
- - smart_recall: BM25+ semantic search across all brain data (11 languages: EN DE FR ES IT PT ZH JA KO AR HE)
49
- - brain_search: Full-text search over all brain data
50
- - recall_at: Brain archaeology — see what a lesson looked like at a point in time
51
-
52
- ### Causal Analysis & Prediction
53
- - causal_trace: Root Cause Analysis through memory — problem → causal chain → known fix
54
- - brain_predict: Predictive pre-fetch — predicts likely failures given current context, returns fixes
55
- - brain_predict_failures: Pre-deploy failure prediction with probability percentages
56
- - trace_dependency: Find all lessons that depend on a given prerequisite
57
- - knowledge_decay: Confidence scoring for every lesson
58
-
59
- ### Context Management
60
- - remember_context: Save architecture findings, decisions, file summaries
61
- - recall_context: Retrieve saved context by key (supports glob)
62
- - list_remembered: List all cached context entries
63
- - forget_context: Delete cached context entries
64
- - compact_recover: Reconstruct full context from Memory Crystal after context limit
65
-
66
- ### Memory Maintenance
67
- - memory_consolidate: Weekly garbage collector — deduplicates, detects contradictions, expires stale lessons
68
- - memory_crystalize: Compress sessions into dense Memory Crystal snapshot
69
- - crystal_view: Inspect current Memory Crystal
70
- - brain_diff: See exactly what changed in the brain since a point in time
71
- - brain_doctor: Health check — lesson count, IQ boost %, open failures, recommendations
72
- - brain_from_git: Bootstrap brain lessons from existing git history
73
-
74
- ### Team Brain
75
- - team_learn: Store lesson in shared team brain
76
- - team_recall: Recall from shared team brain (shows who learned what)
77
- - team_synthesize: Merge multiple contributors' lessons on same topic into canonical version
78
- - madc_deliberate: Multi-Agent Deliberation Chamber — 6 specialist agents vote on conflicting lessons
79
-
80
- ### Knowledge Commons (Global)
81
- - syndicate: Contribute verified lesson to global Knowledge Commons
82
- - syndicate_search: Search global Knowledge Commons
83
- - syndicate_trending: Trending lessons globally
84
- - fedbrain_contribute: Contribute with cryptographic knowledge certificate
85
- - fedbrain_search: Context-weighted search of global commons
86
- - fedbrain_confirm: Confirm a syndicated lesson worked for you
87
- - publish_lesson: Publish lesson to Cachly Public Brain
88
- - import_public_brain: Import community lessons for a framework
89
- - global_learn: Store lesson that applies across all your projects
90
- - global_recall: Retrieve cross-project lessons
91
-
92
- ### Continuous Learning Stream
93
- - cls_ingest: Ingest learning signals from git commits, CI runs, IDE diagnostics without session_end
94
- - cls_install_hooks: Generate git post-commit hook and GitHub Actions step for automatic learning
95
-
96
- ### Autopilot — self-managing AI instructions
97
- - autopilot: Generate a CLAUDE.md / copilot-instructions.md / .github/copilot-instructions.md from actual Brain content. Supports Claude, Cursor, Copilot, Windsurf, Gemini. style="minimal" for just the hooks, style="full" for complete ruleset with examples. Re-run as the Brain learns more to continuously upgrade the instructions file.
98
-
99
- ### Roadmap & Planning
100
- - roadmap_add: Add item to persistent project roadmap stored in Brain
101
- - roadmap_update: Update roadmap item status, priority, details
102
- - roadmap_list: List roadmap items filtered by status, priority, tag, milestone
103
- - roadmap_next: Get the single most important next actionable item
104
-
105
- ### Cache & Infrastructure
106
- - list_instances / create_instance / delete_instance: Manage Brain instances
107
- - cache_get / cache_set / cache_delete: Standard Redis/Valkey cache operations
108
- - cache_mget / cache_mset: Bulk pipeline (single round-trip)
109
- - cache_exists / cache_ttl / cache_keys / cache_stats: Cache introspection
110
- - semantic_search: Find cached entries by semantic similarity
111
- - cache_warmup: Pre-warm semantic cache with prompt/value pairs
112
- - cache_lock_acquire / cache_lock_release: Distributed locking
113
- - cache_stream_set / cache_stream_get: LLM token stream caching
114
- - index_project: Index source files for semantic search
115
- - detect_namespace: Classify prompts into semantic namespaces
116
- - get_connection_string: Get Redis/Valkey connection string
117
- - get_api_status: Full diagnostic — call when anything is broken
118
-
119
- ### Organization & Teams
120
- - list_orgs / create_org / invite_member / get_org_plan: Multi-tenant organization management
121
- - ckg_inspect: Inspect Causal Knowledge Graph for a concept
122
- - autopilot: Generate CLAUDE.md / copilot-instructions.md for self-managing AI
123
- - setup_ai_memory: One-shot setup of 3-layer AI Memory system
124
- - brain_federate: Private org knowledge transfer
125
-
126
- ## Comparison to alternatives
127
-
128
- | Feature | cachly | mem0 | Plain CLAUDE.md |
129
- |---------|--------|------|-----------------|
130
- | Persistent across sessions | ✅ | ✅ | Manual |
131
- | Causal root cause analysis | ✅ | ❌ | ❌ |
132
- | Automatic (no explicit calls) | ✅ | ❌ | ❌ |
133
- | Team knowledge sharing | ✅ | Paid | ❌ |
134
- | Failure prediction | ✅ | ❌ | ❌ |
135
- | Git-ambient learning | ✅ | ❌ | ❌ |
136
- | 11-language search | ✅ | ❌ | ❌ |
137
- | Free tier forever | ✅ | Limited | ✅ |
138
- | GDPR / EU servers | ✅ | ❌ | ✅ |
139
-
140
- ## Pricing
141
-
142
- - Free: 25 MB, 1 instance, €0/month forever
143
- - Dev: 200 MB, €19/month
144
- - Pro: 900 MB, team features, €49/month
145
- - Speed: 900 MB + Dragonfly engine, €79/month
146
- - Business: 7 GB, €199/month
147
-
148
- All plans: German servers, GDPR-compliant, 99.9% SLA.
149
-
150
- ## Links
151
-
152
- - npm: https://www.npmjs.com/package/@cachly-dev/mcp-server
153
- - GitHub: https://github.com/cachly-dev/cachly-mcp
154
- - Docs: https://cachly.dev/docs/ai-memory
155
- - Dashboard: https://cachly.dev
@@ -1,147 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
3
- import { jwtExpiryMs, checkJwt, handleApiError } from '../auth.js';
4
-
5
- function makeJwt(payload: Record<string, unknown>): string {
6
- const header = Buffer.from(JSON.stringify({ alg: 'HS256', typ: 'JWT' })).toString('base64url');
7
- const body = Buffer.from(JSON.stringify(payload)).toString('base64url');
8
- return `${header}.${body}.fakesig`;
9
- }
10
-
11
- const nowSec = () => Math.floor(Date.now() / 1000);
12
-
13
- describe('jwtExpiryMs', () => {
14
- it('returns null for an empty string', () => {
15
- expect(jwtExpiryMs('')).toBeNull();
16
- });
17
-
18
- it('returns null for a plain (non-JWT) string', () => {
19
- expect(jwtExpiryMs('not-a-token')).toBeNull();
20
- });
21
-
22
- it('returns null when the JWT has only two parts', () => {
23
- expect(jwtExpiryMs('header.payload')).toBeNull();
24
- });
25
-
26
- it('returns null when the JWT has four parts', () => {
27
- expect(jwtExpiryMs('a.b.c.d')).toBeNull();
28
- });
29
-
30
- it('returns null when the payload base64 is invalid', () => {
31
- expect(jwtExpiryMs('header.!!!.sig')).toBeNull();
32
- });
33
-
34
- it('returns null when the payload has no exp field', () => {
35
- expect(jwtExpiryMs(makeJwt({ sub: 'user-123', iat: nowSec() }))).toBeNull();
36
- });
37
-
38
- it('returns null when exp is 0', () => {
39
- expect(jwtExpiryMs(makeJwt({ exp: 0 }))).toBeNull();
40
- });
41
-
42
- it('converts exp (seconds) to milliseconds', () => {
43
- const expSec = nowSec() + 3600;
44
- expect(jwtExpiryMs(makeJwt({ exp: expSec }))).toBe(expSec * 1000);
45
- });
46
-
47
- it('returns a past timestamp for an expired token', () => {
48
- expect(jwtExpiryMs(makeJwt({ exp: nowSec() - 300 }))).toBeLessThan(Date.now());
49
- });
50
-
51
- it('returns a future timestamp for a valid token', () => {
52
- expect(jwtExpiryMs(makeJwt({ exp: nowSec() + 86400 }))).toBeGreaterThan(Date.now());
53
- });
54
-
55
- it('handles a token expiring in less than 60 minutes', () => {
56
- const expSec = nowSec() + 30 * 60;
57
- const result = jwtExpiryMs(makeJwt({ exp: expSec }))!;
58
- const minsLeft = Math.floor((result - Date.now()) / 60_000);
59
- expect(minsLeft).toBeGreaterThanOrEqual(29);
60
- expect(minsLeft).toBeLessThanOrEqual(30);
61
- });
62
-
63
- it('ignores extra claims', () => {
64
- const expSec = nowSec() + 3600;
65
- expect(jwtExpiryMs(makeJwt({ sub: 'u', iat: nowSec(), exp: expSec, plan: 'free' }))).toBe(expSec * 1000);
66
- });
67
-
68
- it('handles padding-free base64url payloads', () => {
69
- // base64url (no =) — Buffer.from handles this natively
70
- const expSec = nowSec() + 7200;
71
- expect(jwtExpiryMs(makeJwt({ exp: expSec, x: 'a' }))).toBe(expSec * 1000);
72
- });
73
- });
74
-
75
- describe('checkJwt', () => {
76
- it('throws InvalidRequest when jwt is empty', () => {
77
- expect(() => checkJwt('')).toThrowError(
78
- expect.objectContaining({ code: ErrorCode.InvalidRequest, message: expect.stringContaining('CACHLY_JWT env var not set') }),
79
- );
80
- });
81
-
82
- it('throws with setup URL when jwt is missing', () => {
83
- expect(() => checkJwt('')).toThrowError(
84
- expect.objectContaining({ message: expect.stringContaining('cachly.dev/setup-ai') }),
85
- );
86
- });
87
-
88
- it('throws InvalidRequest with expiry timestamp for an expired token', () => {
89
- const expSec = nowSec() - 60;
90
- const token = makeJwt({ exp: expSec });
91
- expect(() => checkJwt(token)).toThrowError(
92
- expect.objectContaining({
93
- code: ErrorCode.InvalidRequest,
94
- message: expect.stringContaining('expired at'),
95
- }),
96
- );
97
- });
98
-
99
- it('does not throw for a valid non-expired token', () => {
100
- expect(() => checkJwt(makeJwt({ exp: nowSec() + 3600 }))).not.toThrow();
101
- });
102
-
103
- it('does not throw for a token with no exp claim', () => {
104
- expect(() => checkJwt(makeJwt({ sub: 'user' }))).not.toThrow();
105
- });
106
- });
107
-
108
- describe('handleApiError', () => {
109
- it('throws InvalidRequest for 401 with the detail message', () => {
110
- expect(() => handleApiError(401, 'token expired')).toThrowError(
111
- expect.objectContaining({
112
- code: ErrorCode.InvalidRequest,
113
- message: expect.stringContaining('Authentication failed (401): token expired'),
114
- }),
115
- );
116
- });
117
-
118
- it('throws InvalidRequest for 403 with the detail message', () => {
119
- expect(() => handleApiError(403, 'plan limit reached')).toThrowError(
120
- expect.objectContaining({
121
- code: ErrorCode.InvalidRequest,
122
- message: expect.stringContaining('Access denied (403): plan limit reached'),
123
- }),
124
- );
125
- });
126
-
127
- it('throws InternalError for other status codes', () => {
128
- expect(() => handleApiError(500, 'server crash')).toThrowError(
129
- expect.objectContaining({
130
- code: ErrorCode.InternalError,
131
- message: expect.stringContaining('cachly API error 500: server crash'),
132
- }),
133
- );
134
- });
135
-
136
- it('includes the cachly.dev/setup-ai link for 401 errors', () => {
137
- expect(() => handleApiError(401, 'Unauthorized')).toThrowError(
138
- expect.objectContaining({ message: expect.stringContaining('cachly.dev/setup-ai') }),
139
- );
140
- });
141
-
142
- it('includes account access hint for 403 errors', () => {
143
- expect(() => handleApiError(403, 'Forbidden')).toThrowError(
144
- expect.objectContaining({ message: expect.stringContaining('access to this resource') }),
145
- );
146
- });
147
- });