mcp-memory-keeper 0.10.0 → 0.10.2

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/CHANGELOG.md CHANGED
@@ -7,8 +7,42 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.10.2] - 2025-09-16
11
+
12
+ ### Fixed
13
+
14
+ - **Critical Token Limit Issue (#24)** - Fixed token overflow with includeMetadata
15
+ - Implemented dynamic token limit calculation based on actual content size
16
+ - Automatically adjusts item limits based on average item size in session
17
+ - More accurate token estimation (3.5 chars/token vs 4)
18
+ - Configurable via environment variables (MCP_MAX_TOKENS, MCP_TOKEN_SAFETY_BUFFER)
19
+ - Added tokenInfo to response metadata for transparency
20
+ - Resolves "MCP tool context_get response exceeds maximum allowed tokens" errors
21
+
22
+ ### Added
23
+
24
+ - **Token Limit Management Module** (`utils/token-limits.ts`)
25
+ - Dynamic calculation of safe item limits
26
+ - Response overhead estimation
27
+ - Configurable token limits via environment
28
+ - Better visibility into token usage
29
+ - Proper TypeScript interfaces for context items
30
+ - Environment variable validation with bounds checking
31
+ - Safe JSON parsing with error handling
32
+ - Well-documented constants replacing magic numbers
33
+
34
+ ## [0.10.1] - 2025-07-11
35
+
10
36
  ### Fixed
11
37
 
38
+ - **Token Limit Enforcement** - Fixed MCP protocol token limit errors
39
+
40
+ - Added automatic response truncation when approaching 25,000 token limit
41
+ - Implemented `calculateSafeItemCount()` helper to determine safe result size
42
+ - Enhanced pagination metadata with `truncated` and `truncatedCount` fields
43
+ - Improved warning messages with specific pagination instructions
44
+ - Prevents "response exceeds maximum allowed tokens" errors from MCP clients
45
+
12
46
  - **Pagination Defaults in context_get** - Improved consistency
13
47
  - Added proper validation of pagination parameters at handler level
14
48
  - Default limit of 100 items now properly applied when not specified
@@ -53,7 +87,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
53
87
  - Added recipes for common patterns in RECIPES.md
54
88
  - Added troubleshooting tips for new features
55
89
 
56
- ## [0.10.0] - 2025-01-26
90
+ ## [0.10.0] - 2025-06-26
57
91
 
58
92
  ### Added
59
93
 
@@ -92,7 +126,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
92
126
  - Enhanced validation for channel names
93
127
  - Backward compatible - existing items default to 'default' channel
94
128
 
95
- ## [0.9.0] - 2025-01-20
129
+ ## [0.9.0] - 2025-06-21
96
130
 
97
131
  ### Changed (BREAKING)
98
132
 
@@ -115,7 +149,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
115
149
  - `context_get_shared` tool (use `context_get` instead)
116
150
  - Complex sharing mechanism that was causing inconsistencies
117
151
 
118
- ## [0.8.4] - 2025-01-19
152
+ ## [0.8.4] - 2025-06-19
119
153
 
120
154
  ### Fixed
121
155
 
@@ -129,7 +163,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
129
163
  - Feature flags system (planned)
130
164
  - Database migration system (planned)
131
165
 
132
- ## [0.8.3] - 2025-01-19
166
+ ## [0.8.3] - 2025-06-19
133
167
 
134
168
  ### Added
135
169
 
@@ -150,7 +184,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
150
184
 
151
185
  - Automatic schema migration for existing databases to add the `working_directory` column
152
186
 
153
- ## [0.8.0] - 2024-01-18
187
+ ## [0.8.0] - 2025-06-18
154
188
 
155
189
  ### Added
156
190
 
@@ -190,7 +224,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
190
224
  - New tables: `journal_entries`, `compressed_context`, `tool_events`
191
225
  - All 255 tests passing
192
226
 
193
- ## [0.7.0] - 2024-01-18
227
+ ## [0.7.0] - 2025-06-18
194
228
 
195
229
  ### Added
196
230
 
@@ -214,7 +248,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
214
248
  - Added comprehensive test coverage (30 new tests)
215
249
  - All 236 tests passing
216
250
 
217
- ## [0.6.0] - 2024-01-17
251
+ ## [0.6.0] - 2025-06-17
218
252
 
219
253
  ### Added
220
254
 
@@ -237,7 +271,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
237
271
  - Comprehensive test coverage for semantic search
238
272
  - All 206 tests passing
239
273
 
240
- ## [0.5.0] - 2024-01-17
274
+ ## [0.5.0] - 2025-06-17
241
275
 
242
276
  ### Added
243
277
 
@@ -260,7 +294,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
260
294
  - Added `knowledge-graph.ts` utility module
261
295
  - Comprehensive test coverage for graph operations
262
296
 
263
- ## [0.4.2] - 2024-01-16
297
+ ## [0.4.2] - 2025-06-17
264
298
 
265
299
  ### Added
266
300
 
@@ -274,7 +308,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
274
308
  - Git integration error handling
275
309
  - Session list date filtering
276
310
 
277
- ## [0.4.1] - 2024-01-16
311
+ ## [0.4.1] - 2025-06-17
278
312
 
279
313
  ### Fixed
280
314
 
@@ -287,7 +321,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
287
321
  - Improved error messages for better debugging
288
322
  - Enhanced validation for file paths
289
323
 
290
- ## [0.4.0] - 2024-01-15
324
+ ## [0.4.0] - 2025-06-17
291
325
 
292
326
  ### Added
293
327
 
@@ -308,7 +342,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
308
342
  - Created `git.ts` utility module
309
343
  - 97% test coverage maintained
310
344
 
311
- ## [0.3.0] - 2024-01-14
345
+ ## [0.3.0] - 2025-06-17
312
346
 
313
347
  ### Added
314
348
 
@@ -337,7 +371,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
337
371
  - Implemented streaming for large exports
338
372
  - Transaction support for atomic operations
339
373
 
340
- ## [0.2.0] - 2024-01-13
374
+ ## [0.2.0] - 2025-06-17
341
375
 
342
376
  ### Added
343
377
 
@@ -367,7 +401,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
367
401
  - Memory leak in file cache operations
368
402
  - Session switching race condition
369
403
 
370
- ## [0.1.0] - 2024-01-12
404
+ ## [0.1.0] - 2025-06-17
371
405
 
372
406
  ### Added
373
407
 
@@ -395,12 +429,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
395
429
 
396
430
  ## Development Releases
397
431
 
398
- ### [0.1.0-beta.2] - 2024-01-11
432
+ ### [0.1.0-beta.2] - 2025-06-17
399
433
 
400
434
  - Fixed Windows path handling
401
435
  - Added Node.js 18+ compatibility
402
436
 
403
- ### [0.1.0-beta.1] - 2024-01-10
437
+ ### [0.1.0-beta.1] - 2025-06-17
404
438
 
405
439
  - Initial beta release
406
440
  - Basic functionality testing
package/README.md CHANGED
@@ -1,11 +1,106 @@
1
1
  # MCP Memory Keeper - Claude Code Context Management
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/mcp-memory-keeper.svg)](https://www.npmjs.com/package/mcp-memory-keeper)
4
+ [![npm downloads](https://img.shields.io/npm/dm/mcp-memory-keeper.svg)](https://www.npmjs.com/package/mcp-memory-keeper)
3
5
  [![CI](https://github.com/mkreyman/mcp-memory-keeper/actions/workflows/ci.yml/badge.svg)](https://github.com/mkreyman/mcp-memory-keeper/actions/workflows/ci.yml)
4
6
  [![codecov](https://codecov.io/gh/mkreyman/mcp-memory-keeper/branch/main/graph/badge.svg)](https://codecov.io/gh/mkreyman/mcp-memory-keeper)
5
- [![npm version](https://badge.fury.io/js/mcp-memory-keeper.svg)](https://badge.fury.io/js/mcp-memory-keeper)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
8
 
7
9
  A Model Context Protocol (MCP) server that provides persistent context management for Claude AI coding assistants. Never lose context during compaction again! This MCP server helps Claude Code maintain context across sessions, preserving your work history, decisions, and progress.
8
10
 
11
+ ## 🚀 Quick Start
12
+
13
+ Get started in under 30 seconds:
14
+
15
+ ```bash
16
+ # Add memory-keeper to Claude
17
+ claude mcp add memory-keeper npx mcp-memory-keeper
18
+
19
+ # Start a new Claude session and use it!
20
+ # Try: Analyze the current repo and save your analysis in memory-keeper
21
+ ```
22
+
23
+ That's it! Memory Keeper is now available in all your Claude sessions. Your context is stored in `~/mcp-data/memory-keeper/` and persists across sessions.
24
+
25
+ ## 🚀 Practical Memory Keeper Workflow Example
26
+
27
+ ### **Custom Command + CLAUDE.md = Automatic Context Management**
28
+
29
+ #### **CLAUDE.md** (condensed example)
30
+
31
+ ```markdown
32
+ # Project Configuration
33
+
34
+ ## Development Rules
35
+
36
+ - Always use memory-keeper to track progress
37
+ - Save architectural decisions and test results
38
+ - Create checkpoints before context limits
39
+
40
+ ## Quality Standards
41
+
42
+ - All tests must pass before marking complete
43
+ - Document actual vs claimed results
44
+ ```
45
+
46
+ #### **Custom Command Example: `/my-dev-workflow`**
47
+
48
+ ```markdown
49
+ # My Development Workflow
50
+
51
+ When working on the provided project:
52
+
53
+ - Use memory-keeper with channel: <project_name>
54
+ - Save progress at every major milestone
55
+ - Document all decisions with category: "decision"
56
+ - Track implementation status with category: "progress"
57
+ - Before claiming anything is complete, save test results
58
+
59
+ ## Workflow Steps
60
+
61
+ 1. Initialize session with project name as channel
62
+ 2. Save findings during investigation
63
+ 3. Create checkpoint before major changes
64
+ 4. Document what actually works vs what should work
65
+ ```
66
+
67
+ #### **Usage Example**
68
+
69
+ ```
70
+ User: /my-dev-workflow authentication-service
71
+
72
+ AI: Setting up workflow for authentication-service.
73
+ [Uses memory-keeper with channel "authentication-service"]
74
+
75
+ [... AI works, automatically saving context ...]
76
+
77
+ User: "Getting close to context limit. Create checkpoint and give me a key"
78
+
79
+ AI: "Checkpoint created: authentication-service-checkpoint-20250126-143026"
80
+
81
+ [Continue working until context reset or compact manually]
82
+
83
+ User: "Restore from key: authentication-service-checkpoint-20250126-143026"
84
+
85
+ AI: "Restored! Continuing OAuth implementation. We completed the token validation, working on refresh logic..."
86
+ ```
87
+
88
+ **The Pattern:**
89
+
90
+ 1. Custom command includes instructions to use memory-keeper
91
+ 2. AI follows those instructions automatically
92
+ 3. **When you notice the conversation getting long, YOU ask Claude to save a checkpoint** (like saving your game before a boss fight!)
93
+ 4. **When Claude runs out of space and starts fresh, YOU tell it to restore using the checkpoint key**
94
+
95
+ **🎯 Key Feature:** Memory Keeper is a shared board! You can:
96
+
97
+ - Continue in the same session after reset
98
+ - Start a completely new session and restore
99
+ - Have multiple Claude sessions running in parallel, all sharing the same memory
100
+ - One session can save context that another session retrieves
101
+
102
+ This enables powerful workflows like having one Claude session doing research while another implements code, both sharing discoveries through Memory Keeper!
103
+
9
104
  ## Why MCP Memory Keeper?
10
105
 
11
106
  Claude Code users often face context loss when the conversation window fills up. This MCP server solves that problem by providing a persistent memory layer for Claude AI. Whether you're working on complex refactoring, multi-file changes, or long debugging sessions, Memory Keeper ensures your Claude assistant remembers important context, decisions, and progress.
@@ -39,31 +134,33 @@ Claude Code users often face context loss when the conversation window fills up.
39
134
 
40
135
  ## Installation
41
136
 
42
- ### Method 1: NPX (Recommended)
43
-
44
- The simplest way to use memory-keeper with Claude:
137
+ ### Recommended: NPX Installation
45
138
 
46
139
  ```bash
47
140
  claude mcp add memory-keeper npx mcp-memory-keeper
48
141
  ```
49
142
 
50
- That's it! This will:
143
+ This single command:
51
144
 
52
- - Always use the latest version
53
- - Handle all dependencies automatically
54
- - Create the data directory at `~/mcp-data/memory-keeper/`
55
- - Work across different platforms
145
+ - Always uses the latest version
146
+ - Handles all dependencies automatically
147
+ - Works across macOS, Linux, and Windows
148
+ - No manual building or native module issues
56
149
 
57
- ### Method 2: Global Installation
150
+ ### Alternative Installation Methods
58
151
 
59
- If you prefer a global installation:
152
+ <details>
153
+ <summary>Global Installation</summary>
60
154
 
61
155
  ```bash
62
156
  npm install -g mcp-memory-keeper
63
157
  claude mcp add memory-keeper mcp-memory-keeper
64
158
  ```
65
159
 
66
- ### Method 3: From Source
160
+ </details>
161
+
162
+ <details>
163
+ <summary>From Source (for development)</summary>
67
164
 
68
165
  ```bash
69
166
  # 1. Clone the repository
@@ -80,14 +177,42 @@ npm run build
80
177
  claude mcp add memory-keeper node /absolute/path/to/mcp-memory-keeper/dist/index.js
81
178
  ```
82
179
 
180
+ </details>
181
+
83
182
  ## Configuration
84
183
 
85
184
  ### Environment Variables
86
185
 
186
+ #### Storage and Installation
187
+
87
188
  - `DATA_DIR` - Directory for database storage (default: `~/mcp-data/memory-keeper/`)
88
189
  - `MEMORY_KEEPER_INSTALL_DIR` - Installation directory (default: `~/.local/mcp-servers/memory-keeper/`)
89
190
  - `MEMORY_KEEPER_AUTO_UPDATE` - Set to `1` to enable auto-updates
90
191
 
192
+ #### Token Limit Configuration
193
+
194
+ - `MCP_MAX_TOKENS` - Maximum tokens allowed in responses (default: `25000`, range: `1000-100000`)
195
+ - Adjust this if your MCP client has different limits
196
+ - `MCP_TOKEN_SAFETY_BUFFER` - Safety buffer percentage (default: `0.8`, range: `0.1-1.0`)
197
+ - Uses only this fraction of the max tokens to prevent overflows
198
+ - `MCP_MIN_ITEMS` - Minimum items to return even if exceeding limits (default: `1`, range: `1-100`)
199
+ - Ensures at least some results are returned
200
+ - `MCP_MAX_ITEMS` - Maximum items allowed per response (default: `100`, range: `10-1000`)
201
+ - Upper bound for result sets regardless of token limits
202
+ - `MCP_CHARS_PER_TOKEN` - Characters per token ratio (default: `3.5`, range: `2.5-5.0`) **[Advanced]**
203
+ - Adjusts token estimation accuracy for different content types
204
+ - Lower values = more conservative (safer but returns fewer items)
205
+ - Higher values = more aggressive (returns more items but risks overflow)
206
+
207
+ Example configuration for stricter token limits:
208
+
209
+ ```bash
210
+ export MCP_MAX_TOKENS=20000 # Lower max tokens
211
+ export MCP_TOKEN_SAFETY_BUFFER=0.7 # More conservative buffer
212
+ export MCP_MAX_ITEMS=50 # Fewer items per response
213
+ export MCP_CHARS_PER_TOKEN=3.0 # More conservative estimation (optional)
214
+ ```
215
+
91
216
  ### Claude Code (CLI)
92
217
 
93
218
  #### Configuration Scopes
@@ -96,13 +221,13 @@ Choose where to save the configuration:
96
221
 
97
222
  ```bash
98
223
  # Project-specific (default) - only for you in this project
99
- claude mcp add memory-keeper node /path/to/mcp-memory-keeper/dist/index.js
224
+ claude mcp add memory-keeper npx mcp-memory-keeper
100
225
 
101
226
  # Shared with team via .mcp.json
102
- claude mcp add --scope project memory-keeper node /path/to/mcp-memory-keeper/dist/index.js
227
+ claude mcp add --scope project memory-keeper npx mcp-memory-keeper
103
228
 
104
229
  # Available across all your projects
105
- claude mcp add --scope user memory-keeper node /path/to/mcp-memory-keeper/dist/index.js
230
+ claude mcp add --scope user memory-keeper npx mcp-memory-keeper
106
231
  ```
107
232
 
108
233
  #### Verify Configuration
@@ -126,20 +251,14 @@ claude mcp get memory-keeper
126
251
  {
127
252
  "mcpServers": {
128
253
  "memory-keeper": {
129
- "command": "node",
130
- "args": ["/absolute/path/to/mcp-memory-keeper/dist/index.js"]
254
+ "command": "npx",
255
+ "args": ["mcp-memory-keeper"]
131
256
  }
132
257
  }
133
258
  }
134
259
  ```
135
260
 
136
- **Important**: Replace `/absolute/path/to/mcp-memory-keeper` with the actual path where you cloned/installed the project.
137
-
138
- ### Example paths:
139
-
140
- - macOS: `/Users/username/projects/mcp-memory-keeper/dist/index.js`
141
- - Windows: `C:\\Users\\username\\projects\\mcp-memory-keeper\\dist\\index.js`
142
- - Linux: `/home/username/projects/mcp-memory-keeper/dist/index.js`
261
+ That's it! No paths needed - npx automatically handles everything.
143
262
 
144
263
  ### Verify Installation
145
264
 
@@ -166,7 +285,7 @@ If Memory Keeper isn't working:
166
285
  ```bash
167
286
  # Remove and re-add the server
168
287
  claude mcp remove memory-keeper
169
- claude mcp add memory-keeper node /absolute/path/to/mcp-memory-keeper/dist/index.js
288
+ claude mcp add memory-keeper npx mcp-memory-keeper
170
289
 
171
290
  # Check logs for errors
172
291
  # The server output will appear in Claude Code's output panel
@@ -174,26 +293,19 @@ claude mcp add memory-keeper node /absolute/path/to/mcp-memory-keeper/dist/index
174
293
 
175
294
  ### Updating to Latest Version
176
295
 
177
- To get the latest features and bug fixes:
178
-
179
- ```bash
180
- # 1. Navigate to your Memory Keeper directory
181
- cd /path/to/mcp-memory-keeper
296
+ With the npx installation method, you automatically get the latest version every time! No manual updates needed.
182
297
 
183
- # 2. Pull the latest changes
184
- git pull
298
+ If you're using the global installation method:
185
299
 
186
- # 3. Install any new dependencies (if package.json changed)
187
- npm install
188
-
189
- # 4. Rebuild the project
190
- npm run build
300
+ ```bash
301
+ # Update to latest version
302
+ npm update -g mcp-memory-keeper
191
303
 
192
- # 5. Start a new Claude session
304
+ # Start a new Claude session
193
305
  # The updated features will be available immediately
194
306
  ```
195
307
 
196
- **Note**: You don't need to reconfigure the MCP server in Claude after updating. Just pull, build, and start a new session!
308
+ **Note**: You don't need to reconfigure the MCP server in Claude after updating. Just start a new session!
197
309
 
198
310
  ## Usage
199
311
 
@@ -27,7 +27,9 @@ const serverPath = path.join(__dirname, '..', 'dist', 'index.js');
27
27
  // Check if the server is built
28
28
  if (!fs.existsSync(serverPath)) {
29
29
  console.error('Error: Server not built. This should not happen with the npm package.');
30
- console.error('Please report this issue at: https://github.com/mkreyman/mcp-memory-keeper/issues');
30
+ console.error(
31
+ 'Please report this issue at: https://github.com/mkreyman/mcp-memory-keeper/issues'
32
+ );
31
33
  process.exit(1);
32
34
  }
33
35
 
@@ -37,16 +39,16 @@ process.chdir(DATA_DIR);
37
39
  // Spawn the server
38
40
  const child = spawn(process.execPath, [serverPath, ...process.argv.slice(2)], {
39
41
  stdio: 'inherit',
40
- env: process.env
42
+ env: process.env,
41
43
  });
42
44
 
43
45
  // Handle exit
44
- child.on('exit', (code) => {
46
+ child.on('exit', code => {
45
47
  process.exit(code);
46
48
  });
47
49
 
48
50
  // Handle errors
49
- child.on('error', (err) => {
51
+ child.on('error', err => {
50
52
  console.error('Failed to start memory-keeper server:', err);
51
53
  process.exit(1);
52
- });
54
+ });