@danielsimonjr/memory-mcp 12.8.2 → 12.9.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.
- package/README.md +15 -15
- package/dist/index.js +4 -2
- package/dist/server/MCPServer.d.ts +11 -2
- package/dist/server/MCPServer.d.ts.map +1 -1
- package/dist/server/MCPServer.js +27 -21
- package/dist/server/toolHandlers.d.ts +9 -0
- package/dist/server/toolHandlers.d.ts.map +1 -1
- package/dist/server/toolHandlers.js +20 -0
- package/package.json +12 -9
package/README.md
CHANGED
|
@@ -178,14 +178,14 @@ git clone https://github.com/danielsimonjr/memory-mcp.git
|
|
|
178
178
|
cd memory-mcp
|
|
179
179
|
|
|
180
180
|
# Install and build
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
bun install
|
|
182
|
+
bun run build
|
|
183
183
|
|
|
184
|
-
# Run tests (
|
|
185
|
-
|
|
184
|
+
# Run tests (794 tests, ~85% statement coverage)
|
|
185
|
+
bun run test
|
|
186
186
|
|
|
187
187
|
# Type check
|
|
188
|
-
|
|
188
|
+
bun run typecheck
|
|
189
189
|
```
|
|
190
190
|
|
|
191
191
|
### Claude Desktop Configuration
|
|
@@ -774,20 +774,20 @@ node dist/migrate-from-jsonl-to-sqlite.js --from memory.db --to memory.jsonl
|
|
|
774
774
|
|
|
775
775
|
### Prerequisites
|
|
776
776
|
|
|
777
|
-
-
|
|
778
|
-
-
|
|
779
|
-
- TypeScript
|
|
777
|
+
- Bun 1.4+ (install + scripts; `bun.lock` is authoritative)
|
|
778
|
+
- Node.js 22+ (shipped runtime — CI smokes `dist/` under Node)
|
|
779
|
+
- TypeScript 7+
|
|
780
780
|
|
|
781
781
|
### Build Commands
|
|
782
782
|
|
|
783
783
|
```bash
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
784
|
+
bun install # Install dependencies
|
|
785
|
+
bun run build # Build TypeScript
|
|
786
|
+
bun run test # Run tests (794 tests across 37 files; ~85% coverage)
|
|
787
|
+
bun run typecheck # Strict type checking
|
|
788
|
+
bun run watch # Development watch mode
|
|
789
|
+
bun run clean # Remove dist/ directory
|
|
790
|
+
bun run docs:deps # Generate dependency graph
|
|
791
791
|
```
|
|
792
792
|
|
|
793
793
|
### Architecture
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,9 @@ let managerContext;
|
|
|
22
22
|
// process alive as an orphan until manually killed.
|
|
23
23
|
// ctx.close() (memoryjs v3) releases storage handles before exit; it is a
|
|
24
24
|
// no-op for JSONL but closes the SQLite handle when MEMORY_STORAGE_TYPE=sqlite.
|
|
25
|
+
let mcpServer;
|
|
25
26
|
function shutdown() {
|
|
27
|
+
void mcpServer?.close();
|
|
26
28
|
managerContext?.close();
|
|
27
29
|
process.exit(0);
|
|
28
30
|
}
|
|
@@ -40,8 +42,8 @@ async function main() {
|
|
|
40
42
|
storageType,
|
|
41
43
|
});
|
|
42
44
|
// Initialize and start MCP server
|
|
43
|
-
|
|
44
|
-
await
|
|
45
|
+
mcpServer = new MCPServer(managerContext);
|
|
46
|
+
await mcpServer.start();
|
|
45
47
|
}
|
|
46
48
|
main().catch((error) => {
|
|
47
49
|
logger.error("Fatal error in main():", error);
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
* Handles Model Context Protocol server initialization and tool registration.
|
|
5
5
|
* Tool definitions and handlers are extracted to separate modules for maintainability.
|
|
6
6
|
*
|
|
7
|
+
* Serves MCP protocol revision 2026-07-28 via `serveStdio`, with backward-compatible
|
|
8
|
+
* support for 2025-era clients on the same stdio connection.
|
|
9
|
+
*
|
|
7
10
|
* @module server/MCPServer
|
|
8
11
|
*/
|
|
9
12
|
import { type ManagerContext } from '@danielsimonjr/memoryjs';
|
|
@@ -12,10 +15,16 @@ import { type ManagerContext } from '@danielsimonjr/memoryjs';
|
|
|
12
15
|
* Exposes tools for entity/relation management, search, and analysis.
|
|
13
16
|
*/
|
|
14
17
|
export declare class MCPServer {
|
|
15
|
-
private server;
|
|
16
18
|
private ctx;
|
|
19
|
+
private stdioHandle;
|
|
17
20
|
constructor(ctx: ManagerContext);
|
|
18
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Build a fresh Server instance for one stdio connection.
|
|
23
|
+
* `serveStdio` pins one instance per connection; the shared ManagerContext
|
|
24
|
+
* holds graph state across reconnects.
|
|
25
|
+
*/
|
|
26
|
+
private createServer;
|
|
19
27
|
start(): Promise<void>;
|
|
28
|
+
close(): Promise<void>;
|
|
20
29
|
}
|
|
21
30
|
//# sourceMappingURL=MCPServer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MCPServer.d.ts","sourceRoot":"","sources":["../../src/server/MCPServer.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"MCPServer.d.ts","sourceRoot":"","sources":["../../src/server/MCPServer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,EAAU,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAqBtE;;;GAGG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,GAAG,CAAiB;IAC5B,OAAO,CAAC,WAAW,CAAkC;IAErD,YAAY,GAAG,EAAE,cAAc,EAE9B;IAED;;;;OAIG;IACH,OAAO,CAAC,YAAY;IAyBd,KAAK,kBAGV;IAEK,KAAK,kBAGV;CACF"}
|
package/dist/server/MCPServer.js
CHANGED
|
@@ -4,12 +4,14 @@
|
|
|
4
4
|
* Handles Model Context Protocol server initialization and tool registration.
|
|
5
5
|
* Tool definitions and handlers are extracted to separate modules for maintainability.
|
|
6
6
|
*
|
|
7
|
+
* Serves MCP protocol revision 2026-07-28 via `serveStdio`, with backward-compatible
|
|
8
|
+
* support for 2025-era clients on the same stdio connection.
|
|
9
|
+
*
|
|
7
10
|
* @module server/MCPServer
|
|
8
11
|
*/
|
|
9
12
|
import { createRequire } from 'node:module';
|
|
10
|
-
import { Server } from
|
|
11
|
-
import {
|
|
12
|
-
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
13
|
+
import { Server } from '@modelcontextprotocol/server';
|
|
14
|
+
import { serveStdio } from '@modelcontextprotocol/server/stdio';
|
|
13
15
|
import { logger } from '@danielsimonjr/memoryjs';
|
|
14
16
|
import { toolDefinitions } from './toolDefinitions.js';
|
|
15
17
|
import { handleToolCall } from './toolHandlers.js';
|
|
@@ -27,36 +29,40 @@ const version = typeof __PKG_VERSION__ === 'string'
|
|
|
27
29
|
* Exposes tools for entity/relation management, search, and analysis.
|
|
28
30
|
*/
|
|
29
31
|
export class MCPServer {
|
|
30
|
-
server;
|
|
31
32
|
ctx;
|
|
33
|
+
stdioHandle = null;
|
|
32
34
|
constructor(ctx) {
|
|
33
35
|
this.ctx = ctx;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Build a fresh Server instance for one stdio connection.
|
|
39
|
+
* `serveStdio` pins one instance per connection; the shared ManagerContext
|
|
40
|
+
* holds graph state across reconnects.
|
|
41
|
+
*/
|
|
42
|
+
createServer() {
|
|
43
|
+
const server = new Server({
|
|
44
|
+
name: 'memory-server',
|
|
36
45
|
version,
|
|
37
46
|
}, {
|
|
38
47
|
capabilities: {
|
|
39
48
|
tools: {},
|
|
40
49
|
},
|
|
41
50
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
this.server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
47
|
-
return {
|
|
48
|
-
tools: toolDefinitions,
|
|
49
|
-
};
|
|
50
|
-
});
|
|
51
|
-
// Register call tool handler
|
|
52
|
-
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
51
|
+
server.setRequestHandler('tools/list', async () => ({
|
|
52
|
+
tools: toolDefinitions,
|
|
53
|
+
}));
|
|
54
|
+
server.setRequestHandler('tools/call', async (request) => {
|
|
53
55
|
const { name, arguments: args } = request.params;
|
|
54
|
-
return handleToolCall(name, args
|
|
56
|
+
return handleToolCall(name, args ?? {}, this.ctx);
|
|
55
57
|
});
|
|
58
|
+
return server;
|
|
56
59
|
}
|
|
57
60
|
async start() {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
this.stdioHandle = serveStdio(() => this.createServer());
|
|
62
|
+
logger.info('Knowledge Graph MCP Server running on stdio (MCP 2026-07-28)');
|
|
63
|
+
}
|
|
64
|
+
async close() {
|
|
65
|
+
await this.stdioHandle?.close();
|
|
66
|
+
this.stdioHandle = null;
|
|
61
67
|
}
|
|
62
68
|
}
|
|
@@ -8,6 +8,15 @@
|
|
|
8
8
|
* @module server/toolHandlers
|
|
9
9
|
*/
|
|
10
10
|
import { formatToolResponse, type ManagerContext } from '@danielsimonjr/memoryjs';
|
|
11
|
+
/**
|
|
12
|
+
* Read the active project scope for a context.
|
|
13
|
+
*
|
|
14
|
+
* The scope is per-context session state set by the `set_project_scope` tool.
|
|
15
|
+
* It is held in a WeakMap because `ctx.defaultProjectId` is readonly.
|
|
16
|
+
*
|
|
17
|
+
* @param ctx - The manager context to read the scope from.
|
|
18
|
+
* @returns The active project id, or `undefined` when no scope is set.
|
|
19
|
+
*/
|
|
11
20
|
export declare function getActiveProjectScope(ctx: ManagerContext): string | undefined;
|
|
12
21
|
/**
|
|
13
22
|
* Tool response type for MCP SDK compatibility.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolHandlers.d.ts","sourceRoot":"","sources":["../../src/server/toolHandlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EACL,kBAAkB,EA2ClB,KAAK,cAAc,EAyBpB,MAAM,yBAAyB,CAAC;AAyBjC,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,cAAc,GAAG,MAAM,GAAG,SAAS,CAE7E;AAgFD;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEzF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,CACxB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC1B,OAAO,CAAC,YAAY,CAAC,CAAC;AAiF3B,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"toolHandlers.d.ts","sourceRoot":"","sources":["../../src/server/toolHandlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EACL,kBAAkB,EA2ClB,KAAK,cAAc,EAyBpB,MAAM,yBAAyB,CAAC;AAyBjC;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,cAAc,GAAG,MAAM,GAAG,SAAS,CAE7E;AAgFD;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEzF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,CACxB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC1B,OAAO,CAAC,YAAY,CAAC,CAAC;AAiF3B,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAkvGpD,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC,YAAY,CAAC,CAiBvB"}
|
|
@@ -29,6 +29,15 @@ const queryCostEstimatorMap = new WeakMap();
|
|
|
29
29
|
// `set_project_scope` tool; handlers may consult `getActiveProjectScope(ctx)`
|
|
30
30
|
// when they want to auto-apply the scope.
|
|
31
31
|
const projectScopeMap = new WeakMap();
|
|
32
|
+
/**
|
|
33
|
+
* Read the active project scope for a context.
|
|
34
|
+
*
|
|
35
|
+
* The scope is per-context session state set by the `set_project_scope` tool.
|
|
36
|
+
* It is held in a WeakMap because `ctx.defaultProjectId` is readonly.
|
|
37
|
+
*
|
|
38
|
+
* @param ctx - The manager context to read the scope from.
|
|
39
|
+
* @returns The active project id, or `undefined` when no scope is set.
|
|
40
|
+
*/
|
|
32
41
|
export function getActiveProjectScope(ctx) {
|
|
33
42
|
return projectScopeMap.get(ctx);
|
|
34
43
|
}
|
|
@@ -1244,6 +1253,17 @@ export const toolHandlers = {
|
|
|
1244
1253
|
return formatTextResponse('No active consolidation scheduler found. Start one first with start_consolidation.');
|
|
1245
1254
|
}
|
|
1246
1255
|
scheduler.stop();
|
|
1256
|
+
// `stop()` clears the interval but cannot cancel a cycle already running:
|
|
1257
|
+
// `runConsolidationCycle` checks `running` only on entry, then awaits a full
|
|
1258
|
+
// graph save. `start()` fires one cycle IMMEDIATELY -- it does not wait for
|
|
1259
|
+
// the interval, which defaults to an hour -- so a start/stop pair always
|
|
1260
|
+
// leaves a write in flight. Returning "stopped" there is a lie the caller
|
|
1261
|
+
// acts on: teardown that deletes the storage directory races the write and
|
|
1262
|
+
// logs `ConsolidationScheduler cycle error: ENOENT ... memory.jsonl.tmp.*`.
|
|
1263
|
+
// memoryjs 4.2.0 exposes that cycle as `initialCyclePromise`; awaiting it
|
|
1264
|
+
// makes "stopped" mean quiesced. The cycle handles its own errors, so this
|
|
1265
|
+
// settles rather than rejects.
|
|
1266
|
+
await scheduler.initialCyclePromise;
|
|
1247
1267
|
return formatTextResponse('Consolidation scheduler stopped');
|
|
1248
1268
|
},
|
|
1249
1269
|
run_consolidation_now: async (ctx) => {
|
package/package.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danielsimonjr/memory-mcp",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.9.0",
|
|
4
4
|
"description": "Enhanced MCP memory server with hierarchies, compression, archiving, graph algorithms, semantic search, temporal KG, RBAC, bitemporal validity, OCC, procedural memory, causal reasoning, world model, do_not_remember exclusions, decision rationale, project context, heuristic guidelines, tool affordance + observer, observation dedup, spell correction, event memory, reconstructive memory, relation consolidation, agent reflection, and 241 advanced tools",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"packageManager": "bun@1.4.2",
|
|
6
7
|
"engines": {
|
|
7
|
-
"node": ">=22.0.0"
|
|
8
|
+
"node": ">=22.0.0",
|
|
9
|
+
"bun": ">=1.4.2"
|
|
8
10
|
},
|
|
9
11
|
"author": "Daniel Simon Jr. (https://github.com/danielsimonjr)",
|
|
10
12
|
"homepage": "https://github.com/danielsimonjr/memory-mcp",
|
|
@@ -48,7 +50,7 @@
|
|
|
48
50
|
],
|
|
49
51
|
"scripts": {
|
|
50
52
|
"build": "tsc",
|
|
51
|
-
"prepare": "
|
|
53
|
+
"prepare": "tsc",
|
|
52
54
|
"watch": "tsc --watch",
|
|
53
55
|
"test": "vitest run --coverage",
|
|
54
56
|
"typecheck": "tsc --noEmit --noUnusedLocals --noUnusedParameters --strict",
|
|
@@ -58,19 +60,20 @@
|
|
|
58
60
|
"tools:build": "cd tools/chunking-for-files && npm run build && cd ../compress-for-context && npm run build && cd ../create-dependency-graph && npm run build && cd ../migrate-from-jsonl-to-sqlite && npm run build"
|
|
59
61
|
},
|
|
60
62
|
"dependencies": {
|
|
61
|
-
"@danielsimonjr/memoryjs": "^
|
|
62
|
-
"@modelcontextprotocol/
|
|
63
|
-
"
|
|
63
|
+
"@danielsimonjr/memoryjs": "^4.2.0",
|
|
64
|
+
"@modelcontextprotocol/core": "^2.0.0",
|
|
65
|
+
"@modelcontextprotocol/server": "^2.0.0",
|
|
66
|
+
"zod": "^4.6.2"
|
|
64
67
|
},
|
|
65
68
|
"overrides": {
|
|
66
|
-
"better-sqlite3": "^
|
|
69
|
+
"better-sqlite3": "^13.0.3"
|
|
67
70
|
},
|
|
68
71
|
"devDependencies": {
|
|
69
72
|
"@types/node": "^26",
|
|
70
|
-
"@vitest/coverage-v8": "^
|
|
73
|
+
"@vitest/coverage-v8": "^5.0.0",
|
|
71
74
|
"esbuild": "^0.28.2",
|
|
72
75
|
"shx": "^0.4.0",
|
|
73
76
|
"typescript": "^7.0.2",
|
|
74
|
-
"vitest": "^
|
|
77
|
+
"vitest": "^5.0.0"
|
|
75
78
|
}
|
|
76
79
|
}
|