@j0hanz/memory-mcp 1.0.0 → 1.1.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 +32 -25
- package/dist/completions/index.d.ts.map +1 -1
- package/dist/completions/index.js +11 -8
- package/dist/completions/index.js.map +1 -1
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +68 -8
- package/dist/db/index.js.map +1 -1
- package/dist/db/typed.d.ts +9 -3
- package/dist/db/typed.d.ts.map +1 -1
- package/dist/db/typed.js +33 -4
- package/dist/db/typed.js.map +1 -1
- package/dist/index.js +13 -8
- package/dist/index.js.map +1 -1
- package/dist/lib/errors.d.ts +4 -0
- package/dist/lib/errors.d.ts.map +1 -1
- package/dist/lib/errors.js +12 -4
- package/dist/lib/errors.js.map +1 -1
- package/dist/lib/hash.d.ts.map +1 -1
- package/dist/lib/hash.js +9 -2
- package/dist/lib/hash.js.map +1 -1
- package/dist/lib/instructions.d.ts +2 -0
- package/dist/lib/instructions.d.ts.map +1 -0
- package/dist/lib/instructions.js +96 -0
- package/dist/lib/instructions.js.map +1 -0
- package/dist/lib/mcp-utils.d.ts +6 -0
- package/dist/lib/mcp-utils.d.ts.map +1 -0
- package/dist/lib/mcp-utils.js +26 -0
- package/dist/lib/mcp-utils.js.map +1 -0
- package/dist/lib/pagination.d.ts.map +1 -1
- package/dist/lib/pagination.js +14 -7
- package/dist/lib/pagination.js.map +1 -1
- package/dist/lib/search-cursor.d.ts +13 -0
- package/dist/lib/search-cursor.d.ts.map +1 -0
- package/dist/lib/search-cursor.js +89 -0
- package/dist/lib/search-cursor.js.map +1 -0
- package/dist/lib/search.d.ts +16 -0
- package/dist/lib/search.d.ts.map +1 -1
- package/dist/lib/search.js +53 -12
- package/dist/lib/search.js.map +1 -1
- package/dist/lib/sql.d.ts +17 -0
- package/dist/lib/sql.d.ts.map +1 -0
- package/dist/lib/sql.js +18 -0
- package/dist/lib/sql.js.map +1 -0
- package/dist/lib/tool-contracts.d.ts +18 -0
- package/dist/lib/tool-contracts.d.ts.map +1 -0
- package/dist/lib/tool-contracts.js +120 -0
- package/dist/lib/tool-contracts.js.map +1 -0
- package/dist/lib/tool-response.d.ts +1 -5
- package/dist/lib/tool-response.d.ts.map +1 -1
- package/dist/lib/tool-response.js +9 -7
- package/dist/lib/tool-response.js.map +1 -1
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/types.js +10 -9
- package/dist/lib/types.js.map +1 -1
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +22 -36
- package/dist/prompts/index.js.map +1 -1
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/index.js +15 -36
- package/dist/resources/index.js.map +1 -1
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +1 -1
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/inputs.d.ts +5 -5
- package/dist/schemas/inputs.d.ts.map +1 -1
- package/dist/schemas/inputs.js +21 -14
- package/dist/schemas/inputs.js.map +1 -1
- package/dist/schemas/outputs.d.ts +94 -148
- package/dist/schemas/outputs.d.ts.map +1 -1
- package/dist/schemas/outputs.js +59 -66
- package/dist/schemas/outputs.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +20 -18
- package/dist/server.js.map +1 -1
- package/dist/tools/create-relationship.d.ts.map +1 -1
- package/dist/tools/create-relationship.js +38 -25
- package/dist/tools/create-relationship.js.map +1 -1
- package/dist/tools/delete-memories.d.ts.map +1 -1
- package/dist/tools/delete-memories.js +37 -30
- package/dist/tools/delete-memories.js.map +1 -1
- package/dist/tools/delete-memory.d.ts.map +1 -1
- package/dist/tools/delete-memory.js +24 -22
- package/dist/tools/delete-memory.js.map +1 -1
- package/dist/tools/delete-relationship.d.ts.map +1 -1
- package/dist/tools/delete-relationship.js +28 -20
- package/dist/tools/delete-relationship.js.map +1 -1
- package/dist/tools/get-memory.d.ts.map +1 -1
- package/dist/tools/get-memory.js +26 -16
- package/dist/tools/get-memory.js.map +1 -1
- package/dist/tools/get-relationships.d.ts.map +1 -1
- package/dist/tools/get-relationships.js +71 -40
- package/dist/tools/get-relationships.js.map +1 -1
- package/dist/tools/index.d.ts +6 -14
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +5 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/memory-stats.d.ts.map +1 -1
- package/dist/tools/memory-stats.js +29 -39
- package/dist/tools/memory-stats.js.map +1 -1
- package/dist/tools/progress.d.ts +34 -0
- package/dist/tools/progress.d.ts.map +1 -0
- package/dist/tools/progress.js +136 -0
- package/dist/tools/progress.js.map +1 -0
- package/dist/tools/recall.d.ts.map +1 -1
- package/dist/tools/recall.js +157 -105
- package/dist/tools/recall.js.map +1 -1
- package/dist/tools/result.d.ts +7 -0
- package/dist/tools/result.d.ts.map +1 -0
- package/dist/tools/result.js +19 -0
- package/dist/tools/result.js.map +1 -0
- package/dist/tools/retrieve-context.d.ts.map +1 -1
- package/dist/tools/retrieve-context.js +127 -40
- package/dist/tools/retrieve-context.js.map +1 -1
- package/dist/tools/search-memories.d.ts.map +1 -1
- package/dist/tools/search-memories.js +37 -47
- package/dist/tools/search-memories.js.map +1 -1
- package/dist/tools/store-memories.d.ts.map +1 -1
- package/dist/tools/store-memories.js +44 -28
- package/dist/tools/store-memories.js.map +1 -1
- package/dist/tools/store-memory.d.ts.map +1 -1
- package/dist/tools/store-memory.js +43 -23
- package/dist/tools/store-memory.js.map +1 -1
- package/dist/tools/update-memory.d.ts.map +1 -1
- package/dist/tools/update-memory.js +63 -29
- package/dist/tools/update-memory.js.map +1 -1
- package/package.json +1 -3
- package/dist/instructions.md +0 -123
- package/dist/tools/helpers.d.ts +0 -13
- package/dist/tools/helpers.d.ts.map +0 -1
- package/dist/tools/helpers.js +0 -49
- package/dist/tools/helpers.js.map +0 -1
package/dist/instructions.md
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
# MEMORY-MCP INSTRUCTIONS
|
|
2
|
-
|
|
3
|
-
These instructions are available as a resource `internal://instructions` or prompt `get-help`. Load them when unsure about tool usage.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## CORE CAPABILITY
|
|
8
|
-
|
|
9
|
-
- Domain: SQLite-backed memory store with FTS5 search and knowledge graph for AI assistants.
|
|
10
|
-
- Primary Resources: Memories (content+tags+hash), Relationships (directed edges).
|
|
11
|
-
- Tools: `search_memories`, `get_memory`, `recall`, `get_relationships`, `memory_stats`, `retrieve_context` (READ); `store_memory`, `store_memories`, `update_memory`, `delete_memory`, `delete_memories`, `create_relationship`, `delete_relationship` (WRITE).
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
## PROMPTS
|
|
16
|
-
|
|
17
|
-
- `get-help`: Returns these instructions for quick recall.
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## RESOURCES & RESOURCE LINKS
|
|
22
|
-
|
|
23
|
-
- `internal://instructions`: This document.
|
|
24
|
-
- `memory://memories/{hash}`: Retrieve a single memory by its SHA-256 hash.
|
|
25
|
-
- If a tool response includes a `resourceUri` or `resource_link`, call `resources/read` with the URI to fetch the full payload.
|
|
26
|
-
|
|
27
|
-
---
|
|
28
|
-
|
|
29
|
-
## THE "GOLDEN PATH" WORKFLOWS (CRITICAL)
|
|
30
|
-
|
|
31
|
-
### WORKFLOW A: RECALL & EXPLORATION
|
|
32
|
-
|
|
33
|
-
- Call `search_memories` with `{ query }` to find memories by content/tags.
|
|
34
|
-
- Call `recall` with `{ query, depth }` to traverse graph connections from hits.
|
|
35
|
-
- Call `get_memory` with `{ hash }` for exact retrieval using hash from results.
|
|
36
|
-
NOTE: Never guess hashes. Always search first.
|
|
37
|
-
|
|
38
|
-
### WORKFLOW B: KNOWLEDGE MANAGEMENT (STORAGE)
|
|
39
|
-
|
|
40
|
-
- Call `store_memory` or `store_memories` (batch ≤50) to persist content with tags.
|
|
41
|
-
- Call `create_relationship` to link memories via `{ from_hash, to_hash, relation_type }`.
|
|
42
|
-
- Call `update_memory` with `{ hash, content }` to revise — returns new hash.
|
|
43
|
-
NOTE: `update_memory` changes the hash because hash depends on content.
|
|
44
|
-
|
|
45
|
-
### WORKFLOW C: CONTEXT RETRIEVAL (RAG)
|
|
46
|
-
|
|
47
|
-
- Call `retrieve_context` with `{ query, token_budget }` to get relevant memories fitting a token limit.
|
|
48
|
-
- Use `strategy='importance'` for high-priority items or `strategy='recency'` for latest updates.
|
|
49
|
-
NOTE: Output is truncated to fit `token_budget`.
|
|
50
|
-
|
|
51
|
-
### WORKFLOW D: CLEANUP & MAINTENANCE
|
|
52
|
-
|
|
53
|
-
- Call `delete_memory` or `delete_memories` to remove obsolete items.
|
|
54
|
-
- Call `delete_relationship` to remove specific edges.
|
|
55
|
-
- Call `memory_stats` to monitor database size and health.
|
|
56
|
-
NOTE: Always confirm destructive actions (delete) with the user first.
|
|
57
|
-
|
|
58
|
-
---
|
|
59
|
-
|
|
60
|
-
## TOOL NUANCES & GOTCHAS
|
|
61
|
-
|
|
62
|
-
`store_memory` / `store_memories`
|
|
63
|
-
|
|
64
|
-
- Purpose: Persist memory content.
|
|
65
|
-
- Input: `tags` (array, no whitespace, max 50 chars each), `importance` (0-10).
|
|
66
|
-
- Output: Returns `hash` and `created` boolean.
|
|
67
|
-
- Gotcha: Idempotent. Storing identical content+tags returns existing hash with `created: false`.
|
|
68
|
-
|
|
69
|
-
`update_memory`
|
|
70
|
-
|
|
71
|
-
- Purpose: Modify memory content.
|
|
72
|
-
- Input: Requires `hash` and new `content`. `tags` optional.
|
|
73
|
-
- Output: Returns `old_hash` and `new_hash`.
|
|
74
|
-
- Nuance: Changing content changes the hash. The old memory is effectively replaced.
|
|
75
|
-
|
|
76
|
-
`search_memories`
|
|
77
|
-
|
|
78
|
-
- Purpose: FTS5 full-text search over content and tags.
|
|
79
|
-
- Input: `query`, `limit` (default 20), `cursor` for pagination.
|
|
80
|
-
- Limits: Max 100 results per call.
|
|
81
|
-
|
|
82
|
-
`recall`
|
|
83
|
-
|
|
84
|
-
- Purpose: Graph traversal starting from search hits.
|
|
85
|
-
- Input: `depth` (0-3, default 1). 0 = search only. Higher depth = more hops.
|
|
86
|
-
- Gotcha: High depth may return large graphs. Use cautiously.
|
|
87
|
-
|
|
88
|
-
`retrieve_context`
|
|
89
|
-
|
|
90
|
-
- Purpose: Get memories optimized for LLM context window.
|
|
91
|
-
- Input: `token_budget` (default 4000).
|
|
92
|
-
- Output: `memories` array and `truncated` boolean.
|
|
93
|
-
|
|
94
|
-
`create_relationship`
|
|
95
|
-
|
|
96
|
-
- Purpose: Link two memories.
|
|
97
|
-
- Input: `from_hash`, `to_hash`, `relation_type` (e.g., related_to, causes).
|
|
98
|
-
- Gotcha: Both hashes must exist.
|
|
99
|
-
|
|
100
|
-
---
|
|
101
|
-
|
|
102
|
-
## CROSS-FEATURE RELATIONSHIPS
|
|
103
|
-
|
|
104
|
-
- Use `store_memory` to get hashes, then `create_relationship` to link them.
|
|
105
|
-
- Use `search_memories` to find entry points for `recall` traversals.
|
|
106
|
-
- `retrieve_context` uses the same ranking as `search_memories` but limits by token count.
|
|
107
|
-
|
|
108
|
-
---
|
|
109
|
-
|
|
110
|
-
## CONSTRAINTS & LIMITATIONS
|
|
111
|
-
|
|
112
|
-
- Content size: Max 100,000 characters per memory.
|
|
113
|
-
- Batch size: Max 50 items for `store_memories` and `delete_memories`.
|
|
114
|
-
- Tags: Max 100 tags per memory, no whitespace.
|
|
115
|
-
- Relationships: Directed edges only.
|
|
116
|
-
|
|
117
|
-
---
|
|
118
|
-
|
|
119
|
-
## ERROR HANDLING STRATEGY
|
|
120
|
-
|
|
121
|
-
- `E_NOT_FOUND`: Memory hash or relationship not found. → Search/recall to find valid hashes.
|
|
122
|
-
- `E_INVALID_CURSOR`: Pagination cursor invalid or expired. → Restart search without cursor.
|
|
123
|
-
- `E_UNKNOWN`: Unexpected internal error. → Check input format and retry.
|
package/dist/tools/helpers.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import type { TypedDb } from '../db/typed.js';
|
|
3
|
-
import type { MemoryRow } from '../lib/types.js';
|
|
4
|
-
type LogLevel = 'debug' | 'info' | 'notice' | 'warning' | 'error';
|
|
5
|
-
export declare function logToolEvent(server: McpServer, logger: string, data: unknown, level?: LogLevel): Promise<void>;
|
|
6
|
-
export declare function nowIso(): string;
|
|
7
|
-
export declare function normalizeMemoryType(memoryType?: string): string;
|
|
8
|
-
export declare function getMemoryRow(db: TypedDb, hash: string): MemoryRow | undefined;
|
|
9
|
-
export declare function memoryExists(db: TypedDb, hash: string): boolean;
|
|
10
|
-
export declare function withImmediateTransaction<T>(db: TypedDb, action: () => T): T;
|
|
11
|
-
export declare function notifyMemoryResourceUpdated(server: McpServer, hash: string): Promise<void>;
|
|
12
|
-
export {};
|
|
13
|
-
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/tools/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,KAAK,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC;AAOlE,wBAAsB,YAAY,CAChC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,KAAK,GAAE,QAAiB,GACvB,OAAO,CAAC,IAAI,CAAC,CAMf;AAED,wBAAgB,MAAM,IAAI,MAAM,CAE/B;AAED,wBAAgB,mBAAmB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAE7E;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAK/D;AAED,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAU3E;AAED,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC,CAYf"}
|
package/dist/tools/helpers.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
const DEFAULT_MEMORY_TYPE = 'general';
|
|
2
|
-
const MEMORY_RESOURCE_PREFIX = 'memory://memories/';
|
|
3
|
-
const SELECT_MEMORY_BY_HASH_SQL = 'SELECT * FROM memories WHERE hash = ?';
|
|
4
|
-
const SELECT_MEMORY_HASH_SQL = 'SELECT hash FROM memories WHERE hash = ?';
|
|
5
|
-
export async function logToolEvent(server, logger, data, level = 'info') {
|
|
6
|
-
if (!server.isConnected()) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
await server.sendLoggingMessage({ level, logger, data });
|
|
10
|
-
}
|
|
11
|
-
export function nowIso() {
|
|
12
|
-
return new Date().toISOString();
|
|
13
|
-
}
|
|
14
|
-
export function normalizeMemoryType(memoryType) {
|
|
15
|
-
return memoryType ?? DEFAULT_MEMORY_TYPE;
|
|
16
|
-
}
|
|
17
|
-
export function getMemoryRow(db, hash) {
|
|
18
|
-
return db.prepare(SELECT_MEMORY_BY_HASH_SQL).get(hash);
|
|
19
|
-
}
|
|
20
|
-
export function memoryExists(db, hash) {
|
|
21
|
-
return (db.prepare(SELECT_MEMORY_HASH_SQL).get(hash) !==
|
|
22
|
-
undefined);
|
|
23
|
-
}
|
|
24
|
-
export function withImmediateTransaction(db, action) {
|
|
25
|
-
db.exec('BEGIN IMMEDIATE');
|
|
26
|
-
try {
|
|
27
|
-
const result = action();
|
|
28
|
-
db.exec('COMMIT');
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
|
-
catch (err) {
|
|
32
|
-
db.exec('ROLLBACK');
|
|
33
|
-
throw err;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
export async function notifyMemoryResourceUpdated(server, hash) {
|
|
37
|
-
if (!server.isConnected()) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
try {
|
|
41
|
-
await server.server.sendResourceUpdated({
|
|
42
|
-
uri: `${MEMORY_RESOURCE_PREFIX}${hash}`,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
catch {
|
|
46
|
-
// best-effort notification
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/tools/helpers.ts"],"names":[],"mappings":"AAOA,MAAM,mBAAmB,GAAG,SAAS,CAAC;AACtC,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AACpD,MAAM,yBAAyB,GAAG,uCAAuC,CAAC;AAC1E,MAAM,sBAAsB,GAAG,0CAA0C,CAAC;AAE1E,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAiB,EACjB,MAAc,EACd,IAAa,EACb,QAAkB,MAAM;IAExB,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,EAAE,CAAC;QAC1B,OAAO;IACT,CAAC;IAED,MAAM,MAAM,CAAC,kBAAkB,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,MAAM;IACpB,OAAO,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,UAAmB;IACrD,OAAO,UAAU,IAAI,mBAAmB,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,EAAW,EAAE,IAAY;IACpD,OAAO,EAAE,CAAC,OAAO,CAAY,yBAAyB,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,EAAW,EAAE,IAAY;IACpD,OAAO,CACL,EAAE,CAAC,OAAO,CAA0B,sBAAsB,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC;QACrE,SAAS,CACV,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAI,EAAW,EAAE,MAAe;IACtE,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAC3B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC;QACxB,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAClB,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACpB,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,MAAiB,EACjB,IAAY;IAEZ,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,EAAE,CAAC;QAC1B,OAAO;IACT,CAAC;IAED,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC;YACtC,GAAG,EAAE,GAAG,sBAAsB,GAAG,IAAI,EAAE;SACxC,CAAC,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACP,2BAA2B;IAC7B,CAAC;AACH,CAAC"}
|