@j0hanz/memory-mcp 0.1.1 → 1.0.1
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 +8 -5
- 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/instructions.md +102 -56
- package/dist/lib/errors.d.ts +3 -0
- package/dist/lib/errors.d.ts.map +1 -1
- package/dist/lib/errors.js +11 -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 +27 -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/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 +21 -35
- package/dist/prompts/index.js.map +1 -1
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/index.js +12 -32
- 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 +28 -17
- 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 +23 -20
- 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 +13 -13
- 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 +18 -12
- 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 +16 -8
- 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 +27 -16
- 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 +26 -20
- 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 +129 -0
- package/dist/tools/progress.js.map +1 -0
- package/dist/tools/recall.d.ts.map +1 -1
- package/dist/tools/recall.js +150 -98
- package/dist/tools/recall.js.map +1 -1
- package/dist/tools/result.d.ts +5 -0
- package/dist/tools/result.d.ts.map +1 -0
- package/dist/tools/result.js +14 -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 +99 -26
- 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 +28 -40
- 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 +30 -18
- 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 +32 -13
- 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 +35 -16
- package/dist/tools/update-memory.js.map +1 -1
- package/package.json +1 -2
- 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
|
@@ -3,11 +3,6 @@ export declare const ErrorResultSchema: z.ZodObject<{
|
|
|
3
3
|
code: z.ZodString;
|
|
4
4
|
message: z.ZodString;
|
|
5
5
|
}, z.core.$strict>;
|
|
6
|
-
declare const OK_SCHEMA: z.ZodBoolean;
|
|
7
|
-
declare const OPTIONAL_ERROR_SCHEMA: z.ZodOptional<z.ZodObject<{
|
|
8
|
-
code: z.ZodString;
|
|
9
|
-
message: z.ZodString;
|
|
10
|
-
}, z.core.$strict>>;
|
|
11
6
|
export declare const MemorySchema: z.ZodObject<{
|
|
12
7
|
hash: z.ZodString;
|
|
13
8
|
content: z.ZodString;
|
|
@@ -19,43 +14,27 @@ export declare const MemorySchema: z.ZodObject<{
|
|
|
19
14
|
relevance: z.ZodOptional<z.ZodNumber>;
|
|
20
15
|
}, z.core.$strict>;
|
|
21
16
|
export declare const MemoryResultSchema: z.ZodObject<{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
relevance: z.ZodOptional<z.ZodNumber>;
|
|
32
|
-
}, z.core.$strict>>;
|
|
33
|
-
error: typeof OPTIONAL_ERROR_SCHEMA;
|
|
34
|
-
}, z.core.$strip>;
|
|
17
|
+
hash: z.ZodString;
|
|
18
|
+
content: z.ZodString;
|
|
19
|
+
tags: z.ZodArray<z.ZodString>;
|
|
20
|
+
memory_type: z.ZodString;
|
|
21
|
+
importance: z.ZodNumber;
|
|
22
|
+
created_at: z.ZodString;
|
|
23
|
+
updated_at: z.ZodString;
|
|
24
|
+
relevance: z.ZodOptional<z.ZodNumber>;
|
|
25
|
+
}, z.core.$strict>;
|
|
35
26
|
export declare const StoreResultSchema: z.ZodObject<{
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
created: z.ZodBoolean;
|
|
40
|
-
}, z.core.$strict>>;
|
|
41
|
-
error: typeof OPTIONAL_ERROR_SCHEMA;
|
|
42
|
-
}, z.core.$strip>;
|
|
27
|
+
hash: z.ZodString;
|
|
28
|
+
created: z.ZodBoolean;
|
|
29
|
+
}, z.core.$strict>;
|
|
43
30
|
export declare const UpdateResultSchema: z.ZodObject<{
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
new_hash: z.ZodString;
|
|
48
|
-
}, z.core.$strict>>;
|
|
49
|
-
error: typeof OPTIONAL_ERROR_SCHEMA;
|
|
50
|
-
}, z.core.$strip>;
|
|
31
|
+
old_hash: z.ZodString;
|
|
32
|
+
new_hash: z.ZodString;
|
|
33
|
+
}, z.core.$strict>;
|
|
51
34
|
export declare const DeleteResultSchema: z.ZodObject<{
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
deleted: z.ZodBoolean;
|
|
56
|
-
}, z.core.$strict>>;
|
|
57
|
-
error: typeof OPTIONAL_ERROR_SCHEMA;
|
|
58
|
-
}, z.core.$strip>;
|
|
35
|
+
hash: z.ZodString;
|
|
36
|
+
deleted: z.ZodBoolean;
|
|
37
|
+
}, z.core.$strict>;
|
|
59
38
|
export declare const BatchItemResultSchema: z.ZodObject<{
|
|
60
39
|
hash: z.ZodString;
|
|
61
40
|
ok: z.ZodBoolean;
|
|
@@ -64,38 +43,30 @@ export declare const BatchItemResultSchema: z.ZodObject<{
|
|
|
64
43
|
error: z.ZodOptional<z.ZodString>;
|
|
65
44
|
}, z.core.$strict>;
|
|
66
45
|
export declare const BatchResultSchema: z.ZodObject<{
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
deleted: z.ZodOptional<z.ZodBoolean>;
|
|
74
|
-
error: z.ZodOptional<z.ZodString>;
|
|
75
|
-
}, z.core.$strict>>;
|
|
76
|
-
succeeded: z.ZodNumber;
|
|
77
|
-
failed: z.ZodNumber;
|
|
46
|
+
items: z.ZodArray<z.ZodObject<{
|
|
47
|
+
hash: z.ZodString;
|
|
48
|
+
ok: z.ZodBoolean;
|
|
49
|
+
created: z.ZodOptional<z.ZodBoolean>;
|
|
50
|
+
deleted: z.ZodOptional<z.ZodBoolean>;
|
|
51
|
+
error: z.ZodOptional<z.ZodString>;
|
|
78
52
|
}, z.core.$strict>>;
|
|
79
|
-
|
|
80
|
-
|
|
53
|
+
succeeded: z.ZodNumber;
|
|
54
|
+
failed: z.ZodNumber;
|
|
55
|
+
}, z.core.$strict>;
|
|
81
56
|
export declare const SearchResultSchema: z.ZodObject<{
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
updated_at: z.ZodString;
|
|
92
|
-
relevance: z.ZodOptional<z.ZodNumber>;
|
|
93
|
-
}, z.core.$strict>>;
|
|
94
|
-
nextCursor: z.ZodOptional<z.ZodString>;
|
|
95
|
-
total_returned: z.ZodNumber;
|
|
57
|
+
memories: z.ZodArray<z.ZodObject<{
|
|
58
|
+
hash: z.ZodString;
|
|
59
|
+
content: z.ZodString;
|
|
60
|
+
tags: z.ZodArray<z.ZodString>;
|
|
61
|
+
memory_type: z.ZodString;
|
|
62
|
+
importance: z.ZodNumber;
|
|
63
|
+
created_at: z.ZodString;
|
|
64
|
+
updated_at: z.ZodString;
|
|
65
|
+
relevance: z.ZodOptional<z.ZodNumber>;
|
|
96
66
|
}, z.core.$strict>>;
|
|
97
|
-
|
|
98
|
-
|
|
67
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
68
|
+
total_returned: z.ZodNumber;
|
|
69
|
+
}, z.core.$strict>;
|
|
99
70
|
export declare const RelationshipEdgeSchema: z.ZodObject<{
|
|
100
71
|
from_hash: z.ZodString;
|
|
101
72
|
to_hash: z.ZodString;
|
|
@@ -111,92 +82,67 @@ export declare const RelationshipWithMemorySchema: z.ZodObject<{
|
|
|
111
82
|
linked_tags: z.ZodArray<z.ZodString>;
|
|
112
83
|
}, z.core.$strict>;
|
|
113
84
|
export declare const RelationshipResultSchema: z.ZodObject<{
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
linked_content: z.ZodString;
|
|
123
|
-
linked_tags: z.ZodArray<z.ZodString>;
|
|
124
|
-
}, z.core.$strict>>;
|
|
125
|
-
count: z.ZodNumber;
|
|
85
|
+
relationships: z.ZodArray<z.ZodObject<{
|
|
86
|
+
from_hash: z.ZodString;
|
|
87
|
+
to_hash: z.ZodString;
|
|
88
|
+
relation_type: z.ZodString;
|
|
89
|
+
created_at: z.ZodString;
|
|
90
|
+
linked_hash: z.ZodString;
|
|
91
|
+
linked_content: z.ZodString;
|
|
92
|
+
linked_tags: z.ZodArray<z.ZodString>;
|
|
126
93
|
}, z.core.$strict>>;
|
|
127
|
-
|
|
128
|
-
}, z.core.$
|
|
94
|
+
count: z.ZodNumber;
|
|
95
|
+
}, z.core.$strict>;
|
|
129
96
|
export declare const CreateRelationshipResultSchema: z.ZodObject<{
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
created: z.ZodBoolean;
|
|
133
|
-
}, z.core.$strict>>;
|
|
134
|
-
error: typeof OPTIONAL_ERROR_SCHEMA;
|
|
135
|
-
}, z.core.$strip>;
|
|
97
|
+
created: z.ZodBoolean;
|
|
98
|
+
}, z.core.$strict>;
|
|
136
99
|
export declare const DeleteRelationshipResultSchema: z.ZodObject<{
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
deleted: z.ZodBoolean;
|
|
140
|
-
}, z.core.$strict>>;
|
|
141
|
-
error: typeof OPTIONAL_ERROR_SCHEMA;
|
|
142
|
-
}, z.core.$strip>;
|
|
100
|
+
deleted: z.ZodBoolean;
|
|
101
|
+
}, z.core.$strict>;
|
|
143
102
|
export declare const StatsResultSchema: z.ZodObject<{
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
by_type: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
156
|
-
}, z.core.$strict>>;
|
|
157
|
-
error: typeof OPTIONAL_ERROR_SCHEMA;
|
|
158
|
-
}, z.core.$strip>;
|
|
103
|
+
memories: z.ZodObject<{
|
|
104
|
+
total: z.ZodNumber;
|
|
105
|
+
oldest: z.ZodNullable<z.ZodString>;
|
|
106
|
+
newest: z.ZodNullable<z.ZodString>;
|
|
107
|
+
avg_importance: z.ZodNullable<z.ZodNumber>;
|
|
108
|
+
}, z.core.$strict>;
|
|
109
|
+
relationships: z.ZodObject<{
|
|
110
|
+
total: z.ZodNumber;
|
|
111
|
+
}, z.core.$strict>;
|
|
112
|
+
by_type: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
113
|
+
}, z.core.$strict>;
|
|
159
114
|
export declare const RecallResultSchema: z.ZodObject<{
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
to_hash: z.ZodString;
|
|
175
|
-
relation_type: z.ZodString;
|
|
176
|
-
}, z.core.$strict>>;
|
|
177
|
-
depth_reached: z.ZodNumber;
|
|
178
|
-
aborted: z.ZodOptional<z.ZodBoolean>;
|
|
179
|
-
nextCursor: z.ZodOptional<z.ZodString>;
|
|
115
|
+
memories: z.ZodArray<z.ZodObject<{
|
|
116
|
+
hash: z.ZodString;
|
|
117
|
+
content: z.ZodString;
|
|
118
|
+
tags: z.ZodArray<z.ZodString>;
|
|
119
|
+
memory_type: z.ZodString;
|
|
120
|
+
importance: z.ZodNumber;
|
|
121
|
+
created_at: z.ZodString;
|
|
122
|
+
updated_at: z.ZodString;
|
|
123
|
+
relevance: z.ZodOptional<z.ZodNumber>;
|
|
124
|
+
}, z.core.$strict>>;
|
|
125
|
+
graph: z.ZodArray<z.ZodObject<{
|
|
126
|
+
from_hash: z.ZodString;
|
|
127
|
+
to_hash: z.ZodString;
|
|
128
|
+
relation_type: z.ZodString;
|
|
180
129
|
}, z.core.$strict>>;
|
|
181
|
-
|
|
182
|
-
|
|
130
|
+
depth_reached: z.ZodNumber;
|
|
131
|
+
aborted: z.ZodOptional<z.ZodBoolean>;
|
|
132
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
133
|
+
}, z.core.$strict>;
|
|
183
134
|
export declare const RetrieveContextResultSchema: z.ZodObject<{
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
updated_at: z.ZodString;
|
|
194
|
-
relevance: z.ZodOptional<z.ZodNumber>;
|
|
195
|
-
}, z.core.$strict>>;
|
|
196
|
-
estimated_tokens: z.ZodNumber;
|
|
197
|
-
truncated: z.ZodBoolean;
|
|
135
|
+
memories: z.ZodArray<z.ZodObject<{
|
|
136
|
+
hash: z.ZodString;
|
|
137
|
+
content: z.ZodString;
|
|
138
|
+
tags: z.ZodArray<z.ZodString>;
|
|
139
|
+
memory_type: z.ZodString;
|
|
140
|
+
importance: z.ZodNumber;
|
|
141
|
+
created_at: z.ZodString;
|
|
142
|
+
updated_at: z.ZodString;
|
|
143
|
+
relevance: z.ZodOptional<z.ZodNumber>;
|
|
198
144
|
}, z.core.$strict>>;
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
145
|
+
estimated_tokens: z.ZodNumber;
|
|
146
|
+
truncated: z.ZodBoolean;
|
|
147
|
+
}, z.core.$strict>;
|
|
202
148
|
//# sourceMappingURL=outputs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outputs.d.ts","sourceRoot":"","sources":["../../src/schemas/outputs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"outputs.d.ts","sourceRoot":"","sources":["../../src/schemas/outputs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAM3B,eAAO,MAAM,iBAAiB;;;kBAG5B,CAAC;AAEH,eAAO,MAAM,YAAY;;;;;;;;;kBASvB,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;kBAAe,CAAC;AAE/C,eAAO,MAAM,iBAAiB;;;kBAG5B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;kBAG7B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;kBAG7B,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;kBAMhC,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;kBAI5B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;kBAI7B,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;;kBAIjC,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;;;;;;kBAQvC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;kBAGnC,CAAC;AAEH,eAAO,MAAM,8BAA8B;;kBAEzC,CAAC;AAEH,eAAO,MAAM,8BAA8B;;kBAEzC,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;;kBAW5B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;kBAM7B,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;kBAItC,CAAC"}
|
package/dist/schemas/outputs.js
CHANGED
|
@@ -1,58 +1,51 @@
|
|
|
1
1
|
import { z } from 'zod/v4';
|
|
2
|
+
const STRING_SCHEMA = z.string();
|
|
3
|
+
const NUMBER_SCHEMA = z.number();
|
|
4
|
+
const BOOLEAN_SCHEMA = z.boolean();
|
|
2
5
|
export const ErrorResultSchema = z.strictObject({
|
|
3
|
-
code:
|
|
4
|
-
message:
|
|
5
|
-
});
|
|
6
|
-
const OK_SCHEMA = z.boolean();
|
|
7
|
-
const OPTIONAL_ERROR_SCHEMA = ErrorResultSchema.optional();
|
|
8
|
-
function createOutputSchema(result) {
|
|
9
|
-
const optionalResult = result.optional();
|
|
10
|
-
return z.strictObject({
|
|
11
|
-
ok: OK_SCHEMA,
|
|
12
|
-
result: optionalResult,
|
|
13
|
-
error: OPTIONAL_ERROR_SCHEMA,
|
|
14
|
-
});
|
|
15
|
-
}
|
|
6
|
+
code: STRING_SCHEMA,
|
|
7
|
+
message: STRING_SCHEMA,
|
|
8
|
+
});
|
|
16
9
|
export const MemorySchema = z.strictObject({
|
|
17
|
-
hash:
|
|
18
|
-
content:
|
|
19
|
-
tags: z.array(
|
|
20
|
-
memory_type:
|
|
21
|
-
importance:
|
|
22
|
-
created_at:
|
|
23
|
-
updated_at:
|
|
24
|
-
relevance:
|
|
10
|
+
hash: STRING_SCHEMA,
|
|
11
|
+
content: STRING_SCHEMA,
|
|
12
|
+
tags: z.array(STRING_SCHEMA),
|
|
13
|
+
memory_type: STRING_SCHEMA,
|
|
14
|
+
importance: NUMBER_SCHEMA,
|
|
15
|
+
created_at: STRING_SCHEMA,
|
|
16
|
+
updated_at: STRING_SCHEMA,
|
|
17
|
+
relevance: NUMBER_SCHEMA.optional(),
|
|
18
|
+
});
|
|
19
|
+
export const MemoryResultSchema = MemorySchema;
|
|
20
|
+
export const StoreResultSchema = z.strictObject({
|
|
21
|
+
hash: STRING_SCHEMA,
|
|
22
|
+
created: BOOLEAN_SCHEMA,
|
|
23
|
+
});
|
|
24
|
+
export const UpdateResultSchema = z.strictObject({
|
|
25
|
+
old_hash: STRING_SCHEMA,
|
|
26
|
+
new_hash: STRING_SCHEMA,
|
|
27
|
+
});
|
|
28
|
+
export const DeleteResultSchema = z.strictObject({
|
|
29
|
+
hash: STRING_SCHEMA,
|
|
30
|
+
deleted: BOOLEAN_SCHEMA,
|
|
25
31
|
});
|
|
26
|
-
export const MemoryResultSchema = createOutputSchema(MemorySchema);
|
|
27
|
-
export const StoreResultSchema = createOutputSchema(z.strictObject({
|
|
28
|
-
hash: z.string(),
|
|
29
|
-
created: z.boolean(),
|
|
30
|
-
}));
|
|
31
|
-
export const UpdateResultSchema = createOutputSchema(z.strictObject({
|
|
32
|
-
old_hash: z.string(),
|
|
33
|
-
new_hash: z.string(),
|
|
34
|
-
}));
|
|
35
|
-
export const DeleteResultSchema = createOutputSchema(z.strictObject({
|
|
36
|
-
hash: z.string(),
|
|
37
|
-
deleted: z.boolean(),
|
|
38
|
-
}));
|
|
39
32
|
export const BatchItemResultSchema = z.strictObject({
|
|
40
|
-
hash:
|
|
41
|
-
ok:
|
|
42
|
-
created:
|
|
43
|
-
deleted:
|
|
44
|
-
error:
|
|
33
|
+
hash: STRING_SCHEMA,
|
|
34
|
+
ok: BOOLEAN_SCHEMA,
|
|
35
|
+
created: BOOLEAN_SCHEMA.optional(),
|
|
36
|
+
deleted: BOOLEAN_SCHEMA.optional(),
|
|
37
|
+
error: STRING_SCHEMA.optional(),
|
|
45
38
|
});
|
|
46
|
-
export const BatchResultSchema =
|
|
39
|
+
export const BatchResultSchema = z.strictObject({
|
|
47
40
|
items: z.array(BatchItemResultSchema),
|
|
48
41
|
succeeded: z.number(),
|
|
49
42
|
failed: z.number(),
|
|
50
|
-
})
|
|
51
|
-
export const SearchResultSchema =
|
|
43
|
+
});
|
|
44
|
+
export const SearchResultSchema = z.strictObject({
|
|
52
45
|
memories: z.array(MemorySchema),
|
|
53
46
|
nextCursor: z.string().optional(),
|
|
54
47
|
total_returned: z.number(),
|
|
55
|
-
})
|
|
48
|
+
});
|
|
56
49
|
export const RelationshipEdgeSchema = z.strictObject({
|
|
57
50
|
from_hash: z.string(),
|
|
58
51
|
to_hash: z.string(),
|
|
@@ -67,38 +60,38 @@ export const RelationshipWithMemorySchema = z.strictObject({
|
|
|
67
60
|
linked_content: z.string(),
|
|
68
61
|
linked_tags: z.array(z.string()),
|
|
69
62
|
});
|
|
70
|
-
export const RelationshipResultSchema =
|
|
63
|
+
export const RelationshipResultSchema = z.strictObject({
|
|
71
64
|
relationships: z.array(RelationshipWithMemorySchema),
|
|
72
65
|
count: z.number(),
|
|
73
|
-
})
|
|
74
|
-
export const CreateRelationshipResultSchema =
|
|
66
|
+
});
|
|
67
|
+
export const CreateRelationshipResultSchema = z.strictObject({
|
|
75
68
|
created: z.boolean(),
|
|
76
|
-
})
|
|
77
|
-
export const DeleteRelationshipResultSchema =
|
|
69
|
+
});
|
|
70
|
+
export const DeleteRelationshipResultSchema = z.strictObject({
|
|
78
71
|
deleted: z.boolean(),
|
|
79
|
-
})
|
|
80
|
-
export const StatsResultSchema =
|
|
72
|
+
});
|
|
73
|
+
export const StatsResultSchema = z.strictObject({
|
|
81
74
|
memories: z.strictObject({
|
|
82
|
-
total:
|
|
83
|
-
oldest:
|
|
84
|
-
newest:
|
|
85
|
-
avg_importance:
|
|
75
|
+
total: NUMBER_SCHEMA,
|
|
76
|
+
oldest: STRING_SCHEMA.nullable(),
|
|
77
|
+
newest: STRING_SCHEMA.nullable(),
|
|
78
|
+
avg_importance: NUMBER_SCHEMA.nullable(),
|
|
86
79
|
}),
|
|
87
80
|
relationships: z.strictObject({
|
|
88
|
-
total:
|
|
81
|
+
total: NUMBER_SCHEMA,
|
|
89
82
|
}),
|
|
90
|
-
by_type: z.record(
|
|
91
|
-
})
|
|
92
|
-
export const RecallResultSchema =
|
|
83
|
+
by_type: z.record(STRING_SCHEMA, NUMBER_SCHEMA),
|
|
84
|
+
});
|
|
85
|
+
export const RecallResultSchema = z.strictObject({
|
|
93
86
|
memories: z.array(MemorySchema),
|
|
94
87
|
graph: z.array(RelationshipEdgeSchema),
|
|
95
|
-
depth_reached:
|
|
96
|
-
aborted:
|
|
97
|
-
nextCursor:
|
|
98
|
-
})
|
|
99
|
-
export const RetrieveContextResultSchema =
|
|
88
|
+
depth_reached: NUMBER_SCHEMA,
|
|
89
|
+
aborted: BOOLEAN_SCHEMA.optional(),
|
|
90
|
+
nextCursor: STRING_SCHEMA.optional(),
|
|
91
|
+
});
|
|
92
|
+
export const RetrieveContextResultSchema = z.strictObject({
|
|
100
93
|
memories: z.array(MemorySchema),
|
|
101
|
-
estimated_tokens:
|
|
102
|
-
truncated:
|
|
103
|
-
})
|
|
94
|
+
estimated_tokens: NUMBER_SCHEMA,
|
|
95
|
+
truncated: BOOLEAN_SCHEMA,
|
|
96
|
+
});
|
|
104
97
|
//# sourceMappingURL=outputs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outputs.js","sourceRoot":"","sources":["../../src/schemas/outputs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,MAAM,
|
|
1
|
+
{"version":3,"file":"outputs.js","sourceRoot":"","sources":["../../src/schemas/outputs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;AACjC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;AACjC,MAAM,cAAc,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;AAEnC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,YAAY,CAAC;IAC9C,IAAI,EAAE,aAAa;IACnB,OAAO,EAAE,aAAa;CACvB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,YAAY,CAAC;IACzC,IAAI,EAAE,aAAa;IACnB,OAAO,EAAE,aAAa;IACtB,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC;IAC5B,WAAW,EAAE,aAAa;IAC1B,UAAU,EAAE,aAAa;IACzB,UAAU,EAAE,aAAa;IACzB,UAAU,EAAE,aAAa;IACzB,SAAS,EAAE,aAAa,CAAC,QAAQ,EAAE;CACpC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,YAAY,CAAC;AAE/C,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,YAAY,CAAC;IAC9C,IAAI,EAAE,aAAa;IACnB,OAAO,EAAE,cAAc;CACxB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,YAAY,CAAC;IAC/C,QAAQ,EAAE,aAAa;I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AC,KAAK,CAAC,YAAY,CAAC;IAC/B,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,sBAAsB,CAAC;IACtC,aAAa,EAAE,aAAa;IAC5B,OAAO,EAAE,cAAc,CAAC,QAAQ,EAAE;IAClC,UAAU,EAAE,aAAa,CAAC,QAAQ,EAAE;CACrC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,YAAY,CAAC;IACxD,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC;IAC/B,gBAAgB,EAAE,aAAa;IAC/B,SAAS,EAAE,cAAc;CAC1B,CAAC,CAAC"}
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAMpE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAMpE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AA4E7C,wBAAgB,YAAY,CAAC,EAAE,EAAE,OAAO,GAAG,SAAS,CAqBnD"}
|
package/dist/server.js
CHANGED
|
@@ -2,24 +2,31 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
|
2
2
|
import { readFileSync } from 'node:fs';
|
|
3
3
|
import { findPackageJSON } from 'node:module';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { loadInstructions } from './lib/instructions.js';
|
|
5
6
|
import { registerAllPrompts } from './prompts/index.js';
|
|
6
7
|
import { registerAllResources } from './resources/index.js';
|
|
7
|
-
import {
|
|
8
|
+
import { registerAllTools } from './tools/index.js';
|
|
8
9
|
const ICON_ASSET = 'logo.svg';
|
|
9
10
|
const ICON_MIME = 'image/svg+xml';
|
|
10
11
|
const ICON_SIZES = ['any'];
|
|
11
12
|
const MAX_ICON_BYTES = 2 * 1024 * 1024;
|
|
12
13
|
const SERVER_NAME = 'memory-mcp';
|
|
13
|
-
|
|
14
|
+
const SERVER_CAPABILITIES = {
|
|
15
|
+
logging: {},
|
|
16
|
+
completions: {},
|
|
17
|
+
resources: { subscribe: true },
|
|
18
|
+
prompts: {},
|
|
19
|
+
tools: {},
|
|
20
|
+
};
|
|
21
|
+
function parsePackageManifest(contents) {
|
|
22
|
+
return JSON.parse(contents);
|
|
23
|
+
}
|
|
24
|
+
function loadPackageManifest() {
|
|
14
25
|
const pkgPath = findPackageJSON('.', import.meta.url);
|
|
15
26
|
if (!pkgPath) {
|
|
16
27
|
throw new Error('Could not find package.json');
|
|
17
28
|
}
|
|
18
|
-
return
|
|
19
|
-
}
|
|
20
|
-
function loadPackageVersion() {
|
|
21
|
-
const { version } = loadPackageJson();
|
|
22
|
-
return version;
|
|
29
|
+
return parsePackageManifest(readFileSync(pkgPath, 'utf-8'));
|
|
23
30
|
}
|
|
24
31
|
function getLocalIconData() {
|
|
25
32
|
const candidates = [
|
|
@@ -49,23 +56,18 @@ function createIconDescriptors() {
|
|
|
49
56
|
return [{ src, mimeType: ICON_MIME, sizes: ICON_SIZES }];
|
|
50
57
|
}
|
|
51
58
|
export function createServer(db) {
|
|
59
|
+
const { version } = loadPackageManifest();
|
|
52
60
|
const icons = createIconDescriptors();
|
|
61
|
+
const instructions = loadInstructions();
|
|
53
62
|
const server = new McpServer({
|
|
54
63
|
name: SERVER_NAME,
|
|
55
|
-
version
|
|
64
|
+
version,
|
|
56
65
|
...(icons ? { icons } : {}),
|
|
57
66
|
}, {
|
|
58
|
-
capabilities:
|
|
59
|
-
|
|
60
|
-
completions: {},
|
|
61
|
-
resources: { subscribe: true },
|
|
62
|
-
prompts: {},
|
|
63
|
-
tools: {},
|
|
64
|
-
},
|
|
67
|
+
capabilities: SERVER_CAPABILITIES,
|
|
68
|
+
instructions,
|
|
65
69
|
});
|
|
66
|
-
|
|
67
|
-
registerTool(server, db);
|
|
68
|
-
}
|
|
70
|
+
registerAllTools(server, db);
|
|
69
71
|
registerAllResources(server, db);
|
|
70
72
|
registerAllPrompts(server);
|
|
71
73
|
return server;
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,UAAU,GAAG,UAAU,CAAC;AAC9B,MAAM,SAAS,GAAG,eAAe,CAAC;AAClC,MAAM,UAAU,G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AAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"create-relationship.d.ts","sourceRoot":"","sources":["../../src/tools/create-relationship.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIzE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AA8C9C,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,SAAS,EACjB,EAAE,EAAE,OAAO,GACV,IAAI,CAgDN"}
|
|
@@ -1,13 +1,28 @@
|
|
|
1
|
-
import { E_NOT_FOUND, E_UNKNOWN, getErrorMessage } from '../lib/errors.js';
|
|
1
|
+
import { E_NOT_FOUND, E_UNKNOWN, getErrorMessage, rethrowMcpError, } from '../lib/errors.js';
|
|
2
|
+
import { logToolEvent } from '../lib/mcp-utils.js';
|
|
2
3
|
import { createErrorResponse, createToolResponse, } from '../lib/tool-response.js';
|
|
3
4
|
import { CreateRelationshipInputSchema } from '../schemas/inputs.js';
|
|
4
5
|
import { CreateRelationshipResultSchema } from '../schemas/outputs.js';
|
|
5
|
-
import {
|
|
6
|
+
import { wrapToolHandler } from './progress.js';
|
|
6
7
|
const INSERT_RELATIONSHIP_SQL = `INSERT OR IGNORE INTO relationships (from_hash, to_hash, relation_type, created_at)
|
|
7
8
|
VALUES (?, ?, ?, ?)`;
|
|
9
|
+
const SELECT_HASHES_SQL = 'SELECT hash FROM memories WHERE hash IN (?, ?) LIMIT 2';
|
|
8
10
|
function formatMemoryNotFound(kind, hash) {
|
|
9
11
|
return `${kind} memory not found: ${hash}`;
|
|
10
12
|
}
|
|
13
|
+
function getMissingEndpoint(db, params) {
|
|
14
|
+
const rows = db
|
|
15
|
+
.prepareOnce(SELECT_HASHES_SQL)
|
|
16
|
+
.all(params.from_hash, params.to_hash);
|
|
17
|
+
const found = new Set(rows.map((row) => row.hash));
|
|
18
|
+
if (!found.has(params.from_hash)) {
|
|
19
|
+
return { kind: 'Source', hash: params.from_hash };
|
|
20
|
+
}
|
|
21
|
+
if (!found.has(params.to_hash)) {
|
|
22
|
+
return { kind: 'Target', hash: params.to_hash };
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
11
26
|
export function registerCreateRelationship(server, db) {
|
|
12
27
|
server.registerTool('create_relationship', {
|
|
13
28
|
title: 'Create Relationship',
|
|
@@ -15,17 +30,15 @@ export function registerCreateRelationship(server, db) {
|
|
|
15
30
|
inputSchema: CreateRelationshipInputSchema,
|
|
16
31
|
outputSchema: CreateRelationshipResultSchema,
|
|
17
32
|
annotations: { idempotentHint: true, openWorldHint: false },
|
|
18
|
-
}, async (params) => {
|
|
33
|
+
}, wrapToolHandler(async (params) => {
|
|
19
34
|
try {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (!memoryExists(db, params.to_hash)) {
|
|
24
|
-
return createErrorResponse(E_NOT_FOUND, formatMemoryNotFound('Target', params.to_hash));
|
|
35
|
+
const missing = getMissingEndpoint(db, params);
|
|
36
|
+
if (missing) {
|
|
37
|
+
return createErrorResponse(E_NOT_FOUND, formatMemoryNotFound(missing.kind, missing.hash));
|
|
25
38
|
}
|
|
26
|
-
const now =
|
|
39
|
+
const now = new Date().toISOString();
|
|
27
40
|
const result = db
|
|
28
|
-
.
|
|
41
|
+
.prepareOnce(INSERT_RELATIONSHIP_SQL)
|
|
29
42
|
.run(params.from_hash, params.to_hash, params.relation_type, now);
|
|
30
43
|
const created = result.changes > 0;
|
|
31
44
|
await logToolEvent(server, 'create_relationship', {
|
|
@@ -34,16 +47,14 @@ export function registerCreateRelationship(server, db) {
|
|
|
34
47
|
relationType: params.relation_type,
|
|
35
48
|
created,
|
|
36
49
|
});
|
|
37
|
-
return createToolResponse({
|
|
38
|
-
ok: true,
|
|
39
|
-
result: {
|
|
40
|
-
created,
|
|
41
|
-
},
|
|
42
|
-
});
|
|
50
|
+
return createToolResponse({ created });
|
|
43
51
|
}
|
|
44
52
|
catch (err) {
|
|
53
|
+
rethrowMcpError(err);
|
|
45
54
|
return createErrorResponse(E_UNKNOWN, getErrorMessage(err));
|
|
46
55
|
}
|
|
47
|
-
}
|
|
56
|
+
}, {
|
|
57
|
+
progressMessage: (params) => `⊕ create_relationship: ${params.from_hash.slice(0, 8)}... -> ${params.to_hash.slice(0, 8)}... [${params.relation_type}]`,
|
|
58
|
+
}));
|
|
48
59
|
}
|
|
49
60
|
//# sourceMappingURL=create-relationship.js.map
|