Skip to content

Commit ab3a1e0

Browse files
Merge pull request #392 from s2005/feature/memory-improvements
Feature/memory improvements
2 parents fe7f6c7 + 98d983a commit ab3a1e0

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

src/memory/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,29 @@ Add this to your claude_desktop_config.json:
158158
}
159159
```
160160

161+
#### NPX with custom setting
162+
163+
The server can be configured using the following environment variables:
164+
165+
```json
166+
{
167+
"mcpServers": {
168+
"memory": {
169+
"command": "npx",
170+
"args": [
171+
"-y",
172+
"@modelcontextprotocol/server-memory"
173+
],
174+
"env": {
175+
"MEMORY_FILE_PATH": "/path/to/custom/memory.json"
176+
}
177+
}
178+
}
179+
}
180+
```
181+
182+
- `MEMORY_FILE_PATH`: Path to the memory storage JSON file (default: `memory.json` in the server directory)
183+
161184
### System Prompt
162185

163186
The prompt for utilizing memory depends on the use case. Changing the prompt will help the model determine the frequency and types of memories created.

src/memory/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ import { promises as fs } from 'fs';
1010
import path from 'path';
1111
import { fileURLToPath } from 'url';
1212

13+
// Define memory file path using environment variable with fallback
14+
const defaultMemoryPath = path.join(path.dirname(fileURLToPath(import.meta.url)), 'memory.json');
1315

14-
// Define the path to the JSONL file, you can change this to your desired local path
15-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
16-
const MEMORY_FILE_PATH = path.join(__dirname, 'memory.json');
16+
// If MEMORY_FILE_PATH is just a filename, put it in the same directory as the script
17+
const MEMORY_FILE_PATH = process.env.MEMORY_FILE_PATH
18+
? path.isAbsolute(process.env.MEMORY_FILE_PATH)
19+
? process.env.MEMORY_FILE_PATH
20+
: path.join(path.dirname(fileURLToPath(import.meta.url)), process.env.MEMORY_FILE_PATH)
21+
: defaultMemoryPath;
1722

1823
// We are storing our memory using entities, relations, and observations in a graph structure
1924
interface Entity {

src/memory/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@modelcontextprotocol/server-memory",
3-
"version": "0.6.2",
3+
"version": "0.6.3",
44
"description": "MCP server for enabling memory for Claude through a knowledge graph",
55
"license": "MIT",
66
"author": "Anthropic, PBC (https://anthropic.com)",

0 commit comments

Comments
 (0)