@joseairosa/recall 1.2.0

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.
@@ -0,0 +1,17 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(npm install)",
5
+ "Bash(git mv:*)",
6
+ "Bash(git add:*)",
7
+ "Bash(git commit:*)",
8
+ "Bash(git remote add:*)",
9
+ "Bash(git push:*)"
10
+ ],
11
+ "deny": [],
12
+ "ask": []
13
+ },
14
+ "enabledMcpjsonServers": [
15
+ "memory"
16
+ ]
17
+ }
package/.env.example ADDED
@@ -0,0 +1,5 @@
1
+ # Redis connection string
2
+ REDIS_URL=redis://localhost:6379
3
+
4
+ # Anthropic API key for semantic embeddings
5
+ ANTHROPIC_API_KEY=sk-ant-your-api-key-here
package/.mcp.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "mcpServers": {
3
+ "memory": {
4
+ "command": "node",
5
+ "args": [
6
+ "/Users/joseairosa/Development/mcp/mem/dist/index.js"
7
+ ],
8
+ "env": {
9
+ "REDIS_URL": "redis://localhost:6379",
10
+ "ANTHROPIC_API_KEY": "YOUR_ANTHROPIC_API_KEY_HERE"
11
+ }
12
+ }
13
+ }
14
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "mcpServers": {
3
+ "memory": {
4
+ "command": "node",
5
+ "args": [
6
+ "/Users/joseairosa/Development/mcp/mem/dist/index.js"
7
+ ],
8
+ "env": {
9
+ "REDIS_URL": "redis://localhost:6379",
10
+ "ANTHROPIC_API_KEY": "sk-ant-..."
11
+ }
12
+ }
13
+ }
14
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,189 @@
1
+ # Changelog
2
+
3
+ All notable changes to **Recall** (formerly MCP Memory Server) are documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ---
9
+
10
+ ## [1.2.0] - 2025-10-02
11
+
12
+ ### Added
13
+ - **TTL Support** - Auto-expiring memories with `ttl_seconds` parameter (minimum 60s)
14
+ - **Export/Import Tools** - Backup and restore memories
15
+ - `export_memories` - Export to JSON with optional filtering by type/importance
16
+ - `import_memories` - Import from JSON with embedding regeneration option
17
+ - **Duplicate Detection** - Find and merge similar memories
18
+ - `find_duplicates` - Detect duplicates with similarity threshold (default 0.85)
19
+ - Auto-merge option with configurable keep strategy
20
+ - **Memory Consolidation** - `consolidate_memories` - Manually merge multiple memories
21
+ - **Analytics Dashboard** - `memory://analytics` resource
22
+ - Memory trends (24h, 7d, 30d)
23
+ - Top tags and importance distribution
24
+ - Activity breakdown by day and type
25
+ - **Cloud Redis Documentation** - Setup guides for Upstash, Redis Cloud, Railway
26
+
27
+ ### Changed
28
+ - Resource URI handling - Fixed pathname parsing for `memory://` scheme
29
+ - Package renamed from `@joseairosa/mcp-memory` to `@joseairosa/recall`
30
+ - Binary command: `mcp-memory` → `recall`
31
+
32
+ ### Technical
33
+ - Added `mergeMemories()` method to MemoryStore
34
+ - Added `ConsolidateMemoriesSchema`, `ExportMemoriesSchema`, `ImportMemoriesSchema`, `FindDuplicatesSchema`
35
+ - Created `src/tools/export-import-tools.ts`
36
+ - Created `src/resources/analytics.ts`
37
+
38
+ **Tools:** 13 total (6 core + 3 smart context + 4 advanced)
39
+ **Resources:** 9 total
40
+ **Prompts:** 1 (`workspace_context`)
41
+
42
+ ---
43
+
44
+ ## [1.1.0] - 2025-10-02
45
+
46
+ ### Added
47
+ - **Smart Context Management**
48
+ - `recall_relevant_context` - Proactive memory retrieval based on current task
49
+ - `analyze_and_remember` - AI-powered conversation analysis and extraction
50
+ - `summarize_session` - Create session snapshots with summaries
51
+ - **Auto-Injection Prompt**
52
+ - `workspace_context` - Automatically injects critical directives and decisions at conversation start
53
+ - **Workspace Isolation** - Memories automatically segmented by project directory
54
+ - **AI Analysis** - Claude Haiku integration for intelligent memory extraction
55
+
56
+ ### Changed (Breaking)
57
+ - **API Migration**: OpenAI → Anthropic Claude
58
+ - Environment variable: `OPENAI_API_KEY` → `ANTHROPIC_API_KEY`
59
+ - Embeddings: OpenAI 1536-dim → Hybrid (Claude keywords + trigrams) 128-dim
60
+ - Cost reduction: ~$2/day → ~$0.20/day
61
+ - **Redis Key Structure**: Added workspace prefix `ws:{workspace_id}:`
62
+ - **Package Dependencies**: `openai` → `@anthropic-ai/sdk`
63
+
64
+ ### Technical
65
+ - Added `ConversationAnalyzer` class for AI-powered analysis
66
+ - Created `src/analysis/conversation-analyzer.ts`
67
+ - Created `src/prompts/` directory (index.ts, formatters.ts)
68
+ - Created `src/tools/context-tools.ts`
69
+ - Updated `src/embeddings/generator.ts` - Hybrid embedding approach
70
+ - Added MCP prompts capability to server
71
+
72
+ **Tools:** 9 total (6 core + 3 smart context)
73
+ **Resources:** 8 total
74
+ **Prompts:** 1 (new capability)
75
+
76
+ ---
77
+
78
+ ## [1.0.0] - 2025-10-02
79
+
80
+ ### Added
81
+ - **Initial Release** - Persistent memory server for Claude using MCP protocol
82
+ - **6 Core Tools**
83
+ - `store_memory` - Store single memory with metadata
84
+ - `store_batch_memories` - Batch store multiple memories
85
+ - `update_memory` - Modify existing memory
86
+ - `delete_memory` - Remove memory by ID
87
+ - `search_memories` - Semantic search using embeddings
88
+ - `organize_session` - Create session snapshots
89
+ - **8 Resources** - Read-only memory access
90
+ - `memory://recent` - Recent memories (default 50)
91
+ - `memory://by-type/{type}` - Filter by context type
92
+ - `memory://by-tag/{tag}` - Filter by tag
93
+ - `memory://important` - High importance (≥8)
94
+ - `memory://session/{session_id}` - Session memories
95
+ - `memory://sessions` - All sessions list
96
+ - `memory://search?q=query` - Search interface
97
+ - `memory://summary` - Statistics overview
98
+ - **10 Context Types**
99
+ - directive, information, heading, decision, code_pattern
100
+ - requirement, error, todo, insight, preference
101
+ - **Features**
102
+ - Redis in-memory storage
103
+ - OpenAI embeddings for semantic search
104
+ - ULID identifiers
105
+ - Importance scoring (1-10)
106
+ - Tag-based organization
107
+ - Session management
108
+ - Zod schema validation
109
+
110
+ ### Technical
111
+ - TypeScript with ESM modules
112
+ - Redis (ioredis) for storage
113
+ - OpenAI text-embedding-3-small (1536-dim)
114
+ - MCP SDK v1.0.4
115
+ - Multiple access patterns (hashes, sets, sorted sets)
116
+
117
+ **Tools:** 6
118
+ **Resources:** 8
119
+ **Prompts:** 0
120
+
121
+ ---
122
+
123
+ ## Migration Guides
124
+
125
+ ### Migrating from v1.1.0 to v1.2.0
126
+
127
+ **No breaking changes.** All existing functionality works identically.
128
+
129
+ **New features available immediately:**
130
+ - Set `ttl_seconds` when creating memories
131
+ - Use `export_memories` and `import_memories` tools
132
+ - Access `memory://analytics` resource
133
+
134
+ **Optional: Upgrade Redis connection**
135
+ - Consider cloud Redis for remote access (Upstash, Redis Cloud, Railway)
136
+ - See README for setup instructions
137
+
138
+ ### Migrating from v1.0.0 to v1.1.0
139
+
140
+ **Breaking changes - Action required:**
141
+
142
+ 1. **Update environment variable**
143
+ ```json
144
+ // Before
145
+ {
146
+ "env": {
147
+ "OPENAI_API_KEY": "sk-..."
148
+ }
149
+ }
150
+
151
+ // After
152
+ {
153
+ "env": {
154
+ "ANTHROPIC_API_KEY": "sk-ant-..."
155
+ }
156
+ }
157
+ ```
158
+
159
+ 2. **Embeddings migration (optional but recommended)**
160
+ ```javascript
161
+ // Export without embeddings
162
+ {tool: "export_memories", args: {include_embeddings: false}}
163
+
164
+ // Import with regenerated embeddings
165
+ {tool: "import_memories", args: {data: "...", regenerate_embeddings: true}}
166
+ ```
167
+
168
+ 3. **Workspace awareness**
169
+ - Memories are now isolated by directory
170
+ - Old memories without workspace prefix may need manual migration
171
+ - Use Redis CLI to add `ws:{id}:` prefix if needed
172
+
173
+ **Benefits:**
174
+ - 10x cost reduction (~$2/day → ~$0.20/day)
175
+ - No OpenAI dependency
176
+ - Faster embedding generation
177
+ - Better context management with smart tools
178
+
179
+ ### Migrating to v1.0.0
180
+
181
+ Initial release - no migration needed.
182
+
183
+ ---
184
+
185
+ ## Links
186
+
187
+ - **GitHub**: https://github.com/joseairosa/recall
188
+ - **npm**: https://www.npmjs.com/package/@joseairosa/recall
189
+ - **Issues**: https://github.com/joseairosa/recall/issues
package/CLAUDE.md ADDED
@@ -0,0 +1,345 @@
1
+ # CLAUDE.md - MCP Memory Server
2
+
3
+ Project-specific instructions for Claude when working with this codebase.
4
+
5
+ ---
6
+
7
+ ## Project Context
8
+
9
+ This is an MCP (Model Context Protocol) server that provides **long-term memory** for Claude conversations. It stores context in Redis with semantic search capabilities to survive context window limitations.
10
+
11
+ **Key Principle**: This server IS the solution to context loss - treat it with care and always maintain backward compatibility.
12
+
13
+ ---
14
+
15
+ ## Development Guidelines
16
+
17
+ ### Code Style
18
+
19
+ - **TypeScript**: Strict mode, full type safety
20
+ - **ESM Modules**: Use `.js` extensions in imports (even for `.ts` files)
21
+ - **Naming**: camelCase for variables/functions, PascalCase for types/classes
22
+ - **Files**: kebab-case for filenames (e.g., `memory-store.ts`)
23
+
24
+ ### Architecture Principles
25
+
26
+ 1. **Immutable Memory IDs**: Never change ULID generation - memories must remain accessible
27
+ 2. **Backward Compatible**: New context types OK, removing types breaks existing memories
28
+ 3. **Index Integrity**: Always update ALL indexes when modifying/deleting memories
29
+ 4. **Atomic Operations**: Use Redis pipelines for multi-step updates
30
+ 5. **Error Handling**: Use MCP error codes (`ErrorCode.InvalidRequest`, `ErrorCode.InternalError`)
31
+
32
+ ### Redis Data Model
33
+
34
+ **NEVER** change these key patterns without migration:
35
+ ```
36
+ memory:{id} → Hash
37
+ memories:all → Set
38
+ memories:timeline → Sorted Set (score = timestamp)
39
+ memories:type:{type} → Set
40
+ memories:tag:{tag} → Set
41
+ memories:important → Sorted Set (score = importance)
42
+ session:{id} → Hash
43
+ sessions:all → Set
44
+ ```
45
+
46
+ ### Context Types (Do Not Remove)
47
+
48
+ These 10 types are core to the system:
49
+ - `directive`, `information`, `heading`, `decision`, `code_pattern`, `requirement`, `error`, `todo`, `insight`, `preference`
50
+
51
+ **Adding new types**: OK, add to enum in [types.ts](src/types.ts)
52
+ **Removing types**: NO - breaks existing memories
53
+
54
+ ### Importance Scale
55
+
56
+ - **1-3**: Low (transient)
57
+ - **4-7**: Medium (general)
58
+ - **8-10**: High (critical, auto-indexed)
59
+
60
+ **Do not change**: The ≥8 threshold for `memories:important` index
61
+
62
+ ---
63
+
64
+ ## Making Changes
65
+
66
+ ### Adding a New Tool
67
+
68
+ 1. Add Zod schema to [types.ts](src/types.ts)
69
+ 2. Add method to `MemoryStore` class in [memory-store.ts](src/redis/memory-store.ts)
70
+ 3. Add tool handler to [tools/index.ts](src/tools/index.ts)
71
+ 4. Update documentation in [README.md](README.md)
72
+
73
+ ### Adding a New Resource
74
+
75
+ 1. Add resource handler to [resources/index.ts](src/resources/index.ts)
76
+ 2. Add routing in [index.ts](src/index.ts) `ReadResourceRequestSchema` handler
77
+ 3. Add to resource list in `ListResourcesRequestSchema` handler
78
+ 4. Update documentation
79
+
80
+ ### Modifying Storage Logic
81
+
82
+ **CRITICAL**: If changing `MemoryStore` methods:
83
+ 1. Ensure index updates are atomic (use pipelines)
84
+ 2. Test with existing Redis data
85
+ 3. Document migration path if needed
86
+ 4. Update version in [package.json](package.json)
87
+
88
+ ### Adding Dependencies
89
+
90
+ - Keep bundle size small (currently 35KB)
91
+ - Prefer native Node.js APIs when possible
92
+ - Check for ESM compatibility
93
+ - Update [package.json](package.json)
94
+
95
+ ---
96
+
97
+ ## Build & Test
98
+
99
+ ### Build
100
+ ```bash
101
+ npm run build # Production build
102
+ npm run dev # Watch mode
103
+ ```
104
+
105
+ ### Manual Testing
106
+ ```bash
107
+ # Start Redis
108
+ redis-server
109
+
110
+ # Run server (manual test)
111
+ REDIS_URL=redis://localhost:6379 OPENAI_API_KEY=sk-... node dist/index.js
112
+
113
+ # In another terminal, test Redis
114
+ redis-cli
115
+ > KEYS *
116
+ ```
117
+
118
+ ### Verify MCP Config
119
+ ```bash
120
+ # Check Claude Desktop config
121
+ cat ~/Library/Application\ Support/Claude/claude_desktop_config.json
122
+
123
+ # Check logs
124
+ tail -f ~/Library/Logs/Claude/mcp*.log
125
+ ```
126
+
127
+ ---
128
+
129
+ ## Common Tasks
130
+
131
+ ### Update OpenAI Model
132
+
133
+ Edit [embeddings/generator.ts](src/embeddings/generator.ts):
134
+ ```typescript
135
+ model: 'text-embedding-3-small', // Current
136
+ // Change to: 'text-embedding-3-large' for better quality
137
+ ```
138
+
139
+ ⚠️ **Warning**: Changing model invalidates existing embeddings! Need migration.
140
+
141
+ ### Add New Context Type
142
+
143
+ 1. Edit [types.ts](src/types.ts):
144
+ ```typescript
145
+ export const ContextType = z.enum([
146
+ // existing...
147
+ 'your_new_type',
148
+ ]);
149
+ ```
150
+
151
+ 2. Update documentation in [README.md](README.md)
152
+
153
+ ### Increase Embedding Dimensions
154
+
155
+ If switching to larger embedding model:
156
+ 1. Update `embedding` field handling in [memory-store.ts](src/redis/memory-store.ts)
157
+ 2. Existing memories will have wrong dimensions - need migration
158
+ 3. Consider versioning: `embedding_v1`, `embedding_v2`
159
+
160
+ ---
161
+
162
+ ## Database Migrations
163
+
164
+ **Current**: No formal migration system
165
+
166
+ **If Redis Schema Changes**:
167
+ 1. Create migration script in `scripts/migrate-{version}.ts`
168
+ 2. Document in `MIGRATIONS.md`
169
+ 3. Provide rollback instructions
170
+ 4. Test on copy of production data first
171
+
172
+ **Never** delete old keys without migration path!
173
+
174
+ ---
175
+
176
+ ## Performance Considerations
177
+
178
+ ### Semantic Search Bottlenecks
179
+
180
+ **Current**: O(n) cosine similarity in-app
181
+ - Fine for <10k memories (~2s)
182
+ - Slow for >50k memories
183
+
184
+ **Future**: Use RediSearch with vector similarity
185
+ - O(log n) with HNSW index
186
+ - Requires Redis Stack
187
+ - Need migration for index creation
188
+
189
+ ### OpenAI API Costs
190
+
191
+ - `text-embedding-3-small`: ~$0.0001 per 1k tokens
192
+ - Average memory: ~100 tokens = $0.00001
193
+ - 10k memories: ~$0.10
194
+ - Use batch API when storing >5 memories
195
+
196
+ ### Redis Memory Usage
197
+
198
+ - Per memory: ~2KB (content + embedding + indexes)
199
+ - 10k memories: ~20MB
200
+ - 100k memories: ~200MB
201
+ - Redis can handle this easily in-memory
202
+
203
+ ---
204
+
205
+ ## Security
206
+
207
+ ### Current (Local Use)
208
+
209
+ - ✅ Runs on localhost
210
+ - ✅ No network exposure
211
+ - ✅ Uses local Redis
212
+
213
+ ### For Production
214
+
215
+ Would need:
216
+ - [ ] Redis AUTH password
217
+ - [ ] TLS for Redis connection
218
+ - [ ] Rate limiting on tools
219
+ - [ ] User namespacing
220
+ - [ ] API key rotation
221
+ - [ ] Audit logging
222
+
223
+ ---
224
+
225
+ ## Debugging
226
+
227
+ ### Server Not Starting
228
+
229
+ ```bash
230
+ # Check Redis
231
+ redis-cli ping
232
+
233
+ # Check env vars
234
+ echo $REDIS_URL
235
+ echo $OPENAI_API_KEY
236
+
237
+ # Check logs
238
+ tail -f ~/Library/Logs/Claude/mcp*.log
239
+ ```
240
+
241
+ ### Memory Not Storing
242
+
243
+ 1. Check OpenAI API key validity
244
+ 2. Check Redis connection
245
+ 3. Look for errors in Claude Desktop logs
246
+ 4. Test Redis directly: `redis-cli KEYS memory:*`
247
+
248
+ ### Search Not Working
249
+
250
+ 1. Verify embeddings are generated (check `embedding` field length)
251
+ 2. Check OpenAI API quota
252
+ 3. Verify cosine similarity calculation
253
+ 4. Test with exact content match first
254
+
255
+ ---
256
+
257
+ ## Documentation Updates
258
+
259
+ When modifying functionality:
260
+
261
+ 1. Update [README.md](README.md) - User-facing docs
262
+ 2. Update [QUICKSTART.md](QUICKSTART.md) - If setup changes
263
+ 3. Update [ai_docs/learnings/README.md](ai_docs/learnings/README.md) - Technical insights
264
+ 4. Update [ai_docs/plans/README.md](ai_docs/plans/README.md) - Architecture changes
265
+ 5. Update this file - Development guidelines
266
+
267
+ ---
268
+
269
+ ## Version Management
270
+
271
+ **Current**: 1.0.0
272
+
273
+ **Semantic Versioning**:
274
+ - **Major (2.0.0)**: Breaking changes (schema changes, removed tools/resources)
275
+ - **Minor (1.1.0)**: New features (new tools, resources, context types)
276
+ - **Patch (1.0.1)**: Bug fixes, performance improvements
277
+
278
+ **Before Publishing**:
279
+ - Test with real Redis instance
280
+ - Verify all tools work
281
+ - Check bundle size
282
+ - Update CHANGELOG.md
283
+
284
+ ---
285
+
286
+ ## Don't Break
287
+
288
+ ### Critical Files (Change with Extreme Care)
289
+
290
+ - [types.ts](src/types.ts) - Schema changes break existing data
291
+ - [memory-store.ts](src/redis/memory-store.ts) - Storage logic changes need migration
292
+ - [package.json](package.json) - Dependency changes affect bundle
293
+
294
+ ### Safe to Modify
295
+
296
+ - [README.md](README.md) - Documentation only
297
+ - [resources/index.ts](src/resources/index.ts) - Adding resources is safe
298
+ - [tools/index.ts](src/tools/index.ts) - Adding tools is safe
299
+
300
+ ---
301
+
302
+ ## Testing Checklist
303
+
304
+ Before committing major changes:
305
+
306
+ - [ ] TypeScript compiles (`npm run build`)
307
+ - [ ] Bundle size reasonable (`ls -lh dist/index.js`)
308
+ - [ ] Shebang present (`head -1 dist/index.js`)
309
+ - [ ] Can store memory
310
+ - [ ] Can retrieve memory
311
+ - [ ] Can search memories
312
+ - [ ] Sessions work
313
+ - [ ] All indexes update correctly
314
+ - [ ] Error handling works
315
+ - [ ] Documentation updated
316
+
317
+ ---
318
+
319
+ ## Emergency Rollback
320
+
321
+ If production Redis has issues:
322
+
323
+ ```bash
324
+ # Backup Redis
325
+ redis-cli SAVE
326
+ cp /var/lib/redis/dump.rdb dump.rdb.backup
327
+
328
+ # Restore from backup
329
+ redis-cli SHUTDOWN
330
+ cp dump.rdb.backup /var/lib/redis/dump.rdb
331
+ redis-server
332
+ ```
333
+
334
+ ---
335
+
336
+ ## Support
337
+
338
+ **Maintainer**: José Airosa
339
+ **Issues**: File in GitHub (once published)
340
+ **Logs**: `~/Library/Logs/Claude/`
341
+
342
+ ---
343
+
344
+ **Last Updated**: 2025-10-02
345
+ **Version**: 1.0.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 José Airosa
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.