@memloom/mcp 0.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/LICENSE +202 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +18 -0
- package/dist/bin.js.map +1 -0
- package/dist/chunk-KMKBEXJI.js +201 -0
- package/dist/chunk-KMKBEXJI.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/dist/bin.d.ts
ADDED
package/dist/bin.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
buildServer
|
|
4
|
+
} from "./chunk-KMKBEXJI.js";
|
|
5
|
+
|
|
6
|
+
// src/bin.ts
|
|
7
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
8
|
+
import { connect } from "memloom";
|
|
9
|
+
async function main() {
|
|
10
|
+
const engine = await connect();
|
|
11
|
+
const server = buildServer(engine);
|
|
12
|
+
await server.connect(new StdioServerTransport());
|
|
13
|
+
}
|
|
14
|
+
main().catch((err) => {
|
|
15
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
16
|
+
process.exit(1);
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/bin.ts"],"sourcesContent":["import { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport { connect } from \"memloom\";\nimport { buildServer } from \"./server.js\";\n\n// memloom MCP server over stdio. Routes through the `memloom serve` daemon (auto-started by\n// connect() if needed), so it never opens the store directly: no lock conflicts with the CLI\n// or a DB client. Register in Claude Desktop as:\n// { \"command\": \"node\", \"args\": [\"<path>/dist/bin.js\"], \"env\": { \"OPENROUTER_API_KEY\": \"...\" } }\n\nasync function main() {\n const engine = await connect();\n const server = buildServer(engine);\n await server.connect(new StdioServerTransport());\n}\n\nmain().catch((err) => {\n console.error(err instanceof Error ? err.message : String(err));\n process.exit(1);\n});\n"],"mappings":";;;;;;AAAA,SAAS,4BAA4B;AACrC,SAAS,eAAe;AAQxB,eAAe,OAAO;AACpB,QAAM,SAAS,MAAM,QAAQ;AAC7B,QAAM,SAAS,YAAY,MAAM;AACjC,QAAM,OAAO,QAAQ,IAAI,qBAAqB,CAAC;AACjD;AAEA,KAAK,EAAE,MAAM,CAAC,QAAQ;AACpB,UAAQ,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAC9D,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/tools.ts
|
|
4
|
+
import {
|
|
5
|
+
PASSAGE_CHARS
|
|
6
|
+
} from "@memloom/core";
|
|
7
|
+
async function saveMemory(memloom, args) {
|
|
8
|
+
const result = await memloom.save({
|
|
9
|
+
content: args.content,
|
|
10
|
+
...args.canonical ? { canonical: args.canonical } : {},
|
|
11
|
+
...args.type ? { memoryType: args.type } : {}
|
|
12
|
+
});
|
|
13
|
+
if (result.outcome === "conflict") {
|
|
14
|
+
return `Saved (id ${result.id}), but it CONTRADICTS an existing memory. Both are kept; the user should resolve conflict ${result.conflictId} (keep new / keep existing / keep both / merge).`;
|
|
15
|
+
}
|
|
16
|
+
if (result.outcome === "merged") {
|
|
17
|
+
return `Already known: merged into memory ${result.id}, nothing duplicated.`;
|
|
18
|
+
}
|
|
19
|
+
return `Saved memory ${result.id}.`;
|
|
20
|
+
}
|
|
21
|
+
async function recallMemory(memloom, args) {
|
|
22
|
+
const results = await memloom.recall(args.query, { limit: args.limit ?? 10 });
|
|
23
|
+
if (results.length === 0) return "No memories found.";
|
|
24
|
+
return results.map((m) => {
|
|
25
|
+
const title = m.canonical ?? (m.content.length > 60 ? `${m.content.slice(0, 57)}...` : m.content);
|
|
26
|
+
const saved = new Date(m.createdAt).toISOString().slice(0, 16).replace("T", " ");
|
|
27
|
+
const passage = m.content.length > PASSAGE_CHARS ? `${m.content.slice(0, PASSAGE_CHARS)}... [truncated: call read_passage with id ${m.id} for the full text]` : m.content;
|
|
28
|
+
const lines = [
|
|
29
|
+
title,
|
|
30
|
+
`- ${passage}`,
|
|
31
|
+
`- saved ${saved} UTC`,
|
|
32
|
+
`- similarity ${(m.similarity ?? 0).toFixed(2)}`
|
|
33
|
+
];
|
|
34
|
+
if (m.source) {
|
|
35
|
+
const where = [
|
|
36
|
+
`- from ${m.source.title}`,
|
|
37
|
+
m.source.headingPath ? `\u203A ${m.source.headingPath}` : "",
|
|
38
|
+
m.source.page != null ? `(p. ${m.source.page})` : ""
|
|
39
|
+
].filter(Boolean).join(" ");
|
|
40
|
+
lines.push(where);
|
|
41
|
+
}
|
|
42
|
+
lines.push(`- id ${m.id}${!m.source && m.version > 1 ? ` (v${m.version})` : ""}`);
|
|
43
|
+
return lines.join("\n");
|
|
44
|
+
}).join("\n---\n");
|
|
45
|
+
}
|
|
46
|
+
async function readPassage(memloom, args) {
|
|
47
|
+
const content = await memloom.passage(args.id);
|
|
48
|
+
if (content === null) {
|
|
49
|
+
return `No memory or document passage with id ${args.id}. Use an id from recall_memory results.`;
|
|
50
|
+
}
|
|
51
|
+
return content;
|
|
52
|
+
}
|
|
53
|
+
async function memoryHistory(memloom, args) {
|
|
54
|
+
const versions = await memloom.history(args.memoryId);
|
|
55
|
+
if (versions.length === 0) return "No such memory.";
|
|
56
|
+
return versions.map((v) => {
|
|
57
|
+
const when = new Date(v.assertedAt).toISOString().slice(0, 16).replace("T", " ");
|
|
58
|
+
const marker = v.status === "active" ? "current" : "superseded";
|
|
59
|
+
return `v${v.version} (${marker}, since ${when} UTC)
|
|
60
|
+
- ${v.content}`;
|
|
61
|
+
}).join("\n---\n");
|
|
62
|
+
}
|
|
63
|
+
async function listConflicts(memloom) {
|
|
64
|
+
const conflicts = await memloom.conflicts();
|
|
65
|
+
if (conflicts.length === 0) return "No pending conflicts.";
|
|
66
|
+
return conflicts.map(
|
|
67
|
+
(c) => `Conflict ${c.id}
|
|
68
|
+
NEW: ${c.incoming.content}
|
|
69
|
+
EXISTING: ${c.candidates.map((x) => x.content).join("; ")}`
|
|
70
|
+
).join("\n\n");
|
|
71
|
+
}
|
|
72
|
+
async function resolveConflict(memloom, args) {
|
|
73
|
+
let decision;
|
|
74
|
+
switch (args.action) {
|
|
75
|
+
case "keep_existing":
|
|
76
|
+
if (!args.candidateId) throw new Error("keep_existing requires candidateId");
|
|
77
|
+
decision = { action: "keep_existing", candidateId: args.candidateId };
|
|
78
|
+
break;
|
|
79
|
+
case "merge":
|
|
80
|
+
if (!args.content) throw new Error("merge requires the reconciled content");
|
|
81
|
+
decision = { action: "merge", content: args.content };
|
|
82
|
+
break;
|
|
83
|
+
case "keep_new":
|
|
84
|
+
decision = { action: "keep_new" };
|
|
85
|
+
break;
|
|
86
|
+
case "keep_both":
|
|
87
|
+
decision = { action: "keep_both" };
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
await memloom.resolveConflict(args.conflictId, decision);
|
|
91
|
+
return `Resolved conflict ${args.conflictId} with "${args.action}" (reversible).`;
|
|
92
|
+
}
|
|
93
|
+
async function setSchemaEntryStatus(memloom, args) {
|
|
94
|
+
const schema = await memloom.describeSchema();
|
|
95
|
+
const pool = args.kind === "entity_type" ? schema.entityTypes : schema.predicates;
|
|
96
|
+
const entry = pool.find((e) => e.name === args.name.toLowerCase());
|
|
97
|
+
if (!entry) return `No ${args.kind} named "${args.name}" exists.`;
|
|
98
|
+
if (entry.status === args.status) {
|
|
99
|
+
return `"${entry.name}" is already ${args.status}.`;
|
|
100
|
+
}
|
|
101
|
+
await memloom.setSchemaStatus(entry.id, args.status);
|
|
102
|
+
return `${args.status === "disabled" ? "Disabled" : "Enabled"} ${args.kind} "${entry.name}".`;
|
|
103
|
+
}
|
|
104
|
+
async function deleteSchemaEntry(memloom, args) {
|
|
105
|
+
const schema = await memloom.describeSchema();
|
|
106
|
+
const pool = args.kind === "entity_type" ? schema.entityTypes : schema.predicates;
|
|
107
|
+
const entry = pool.find((e) => e.name === args.name.toLowerCase());
|
|
108
|
+
if (!entry) return `No ${args.kind} named "${args.name}" exists.`;
|
|
109
|
+
if (entry.tier === "system") {
|
|
110
|
+
return `"${entry.name}" is a built-in ${args.kind}; it can be disabled but never deleted.`;
|
|
111
|
+
}
|
|
112
|
+
if (entry.status !== "disabled") {
|
|
113
|
+
return `"${entry.name}" is still active. Disable it first (set_schema_entry_status), then delete.`;
|
|
114
|
+
}
|
|
115
|
+
await memloom.deleteSchemaEntry(entry.id);
|
|
116
|
+
return `Deleted ${args.kind} "${entry.name}" from the vocabulary. Entities already extracted under it stay in the graph.`;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// src/server.ts
|
|
120
|
+
import { MEMORY_TYPES } from "@memloom/core";
|
|
121
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
122
|
+
import { z } from "zod";
|
|
123
|
+
function buildServer(memloom) {
|
|
124
|
+
const server = new McpServer({ name: "memloom", version: "0.1.0" });
|
|
125
|
+
server.tool(
|
|
126
|
+
"save_memory",
|
|
127
|
+
"Save a durable memory the user owns. Set `type` to classify it: fact (a stable truth), preference (how the user likes things), episode (a time-bound event or decision), or procedure (reusable how-to steps); defaults to fact. memloom dedupes automatically and flags contradictions instead of overwriting, so save what is worth remembering; the response says if it created a conflict to resolve.",
|
|
128
|
+
{
|
|
129
|
+
content: z.string(),
|
|
130
|
+
canonical: z.string().optional(),
|
|
131
|
+
type: z.enum(MEMORY_TYPES).optional()
|
|
132
|
+
},
|
|
133
|
+
async (args) => ({ content: [{ type: "text", text: await saveMemory(memloom, args) }] })
|
|
134
|
+
);
|
|
135
|
+
server.tool(
|
|
136
|
+
"recall_memory",
|
|
137
|
+
"Recall the user's memories AND ingested context documents by meaning, ranked by hybrid retrieval (semantic + exact keyword + entity). Exact identifiers like file paths, config keys, or error codes make excellent queries. Document results say which file and section they came from. Only active (non-superseded) memories are returned. Very long results are truncated with a marker; read_passage fetches the full text by id.",
|
|
138
|
+
{ query: z.string(), limit: z.number().optional() },
|
|
139
|
+
async (args) => ({ content: [{ type: "text", text: await recallMemory(memloom, args) }] })
|
|
140
|
+
);
|
|
141
|
+
server.tool(
|
|
142
|
+
"read_passage",
|
|
143
|
+
"The full text of one recall_memory result, by the `id` shown with it. Call ONLY when a result ended with a truncation marker and the answer may be in the cut part.",
|
|
144
|
+
{ id: z.string() },
|
|
145
|
+
async (args) => ({ content: [{ type: "text", text: await readPassage(memloom, args) }] })
|
|
146
|
+
);
|
|
147
|
+
server.tool(
|
|
148
|
+
"memory_history",
|
|
149
|
+
"Show how a memory changed over time: its full version chain, newest first, with the current version and every superseded one. Pass the `id` shown by recall_memory. Read-only: editing memories is a human action in the viewer or CLI.",
|
|
150
|
+
{ memoryId: z.string() },
|
|
151
|
+
async (args) => ({ content: [{ type: "text", text: await memoryHistory(memloom, args) }] })
|
|
152
|
+
);
|
|
153
|
+
server.tool(
|
|
154
|
+
"list_conflicts",
|
|
155
|
+
"List pending memory conflicts (contradictions the user has not resolved yet).",
|
|
156
|
+
{},
|
|
157
|
+
async () => ({ content: [{ type: "text", text: await listConflicts(memloom) }] })
|
|
158
|
+
);
|
|
159
|
+
server.tool(
|
|
160
|
+
"resolve_conflict",
|
|
161
|
+
"Resolve a memory conflict. Actions: keep_new, keep_existing (needs candidateId), keep_both, or merge (needs reconciled content). Every resolution is reversible.",
|
|
162
|
+
{
|
|
163
|
+
conflictId: z.string(),
|
|
164
|
+
action: z.enum(["keep_new", "keep_existing", "keep_both", "merge"]),
|
|
165
|
+
candidateId: z.string().optional(),
|
|
166
|
+
content: z.string().optional()
|
|
167
|
+
},
|
|
168
|
+
async (args) => ({ content: [{ type: "text", text: await resolveConflict(memloom, args) }] })
|
|
169
|
+
);
|
|
170
|
+
server.tool(
|
|
171
|
+
"set_schema_entry_status",
|
|
172
|
+
"Enable or disable a graph schema entry (an entity type or predicate). A disabled entry stops being used by future extraction, but entities already extracted under it stay in the graph. Built-in entries can only be disabled, never deleted; user-defined entries must be disabled before delete_schema_entry will remove them.",
|
|
173
|
+
{
|
|
174
|
+
kind: z.enum(["entity_type", "predicate"]),
|
|
175
|
+
name: z.string(),
|
|
176
|
+
status: z.enum(["active", "disabled"])
|
|
177
|
+
},
|
|
178
|
+
async (args) => ({
|
|
179
|
+
content: [{ type: "text", text: await setSchemaEntryStatus(memloom, args) }]
|
|
180
|
+
})
|
|
181
|
+
);
|
|
182
|
+
server.tool(
|
|
183
|
+
"delete_schema_entry",
|
|
184
|
+
"Permanently remove a DISABLED user-defined vocabulary entry (an entity type or predicate) from the graph schema. Built-in entries can only be disabled, and an active entry must be disabled before deletion; the response explains any refusal. Entities already extracted under the deleted type stay in the graph.",
|
|
185
|
+
{
|
|
186
|
+
kind: z.enum(["entity_type", "predicate"]),
|
|
187
|
+
name: z.string()
|
|
188
|
+
},
|
|
189
|
+
async (args) => ({ content: [{ type: "text", text: await deleteSchemaEntry(memloom, args) }] })
|
|
190
|
+
);
|
|
191
|
+
return server;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export {
|
|
195
|
+
saveMemory,
|
|
196
|
+
recallMemory,
|
|
197
|
+
listConflicts,
|
|
198
|
+
resolveConflict,
|
|
199
|
+
buildServer
|
|
200
|
+
};
|
|
201
|
+
//# sourceMappingURL=chunk-KMKBEXJI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/tools.ts","../src/server.ts"],"sourcesContent":["import {\n type MemoryEngine,\n type MemoryType,\n PASSAGE_CHARS,\n type ResolveDecision,\n} from \"@memloom/core\";\n\n// The MCP tool implementations, kept as pure functions over a Memloom so they're testable\n// without an MCP transport. server.ts wires them to the protocol.\n\nexport async function saveMemory(\n memloom: MemoryEngine,\n args: { content: string; canonical?: string; type?: MemoryType },\n): Promise<string> {\n const result = await memloom.save({\n content: args.content,\n ...(args.canonical ? { canonical: args.canonical } : {}),\n ...(args.type ? { memoryType: args.type } : {}),\n });\n if (result.outcome === \"conflict\") {\n return `Saved (id ${result.id}), but it CONTRADICTS an existing memory. Both are kept; the user should resolve conflict ${result.conflictId} (keep new / keep existing / keep both / merge).`;\n }\n if (result.outcome === \"merged\") {\n return `Already known: merged into memory ${result.id}, nothing duplicated.`;\n }\n return `Saved memory ${result.id}.`;\n}\n\nexport async function recallMemory(\n memloom: MemoryEngine,\n args: { query: string; limit?: number },\n): Promise<string> {\n const results = await memloom.recall(args.query, { limit: args.limit ?? 10 });\n if (results.length === 0) return \"No memories found.\";\n return results\n .map((m) => {\n // Title: the canonical form when the memory has one, else the content's first words.\n const title =\n m.canonical ?? (m.content.length > 60 ? `${m.content.slice(0, 57)}...` : m.content);\n const saved = new Date(m.createdAt).toISOString().slice(0, 16).replace(\"T\", \" \");\n // The same passage budget the viewer assistant uses: a markdown chunk is a whole\n // heading section (up to 16k chars), so a cut passage names the escape hatch.\n const passage =\n m.content.length > PASSAGE_CHARS\n ? `${m.content.slice(0, PASSAGE_CHARS)}... [truncated: call read_passage with id ${m.id} for the full text]`\n : m.content;\n const lines = [\n title,\n `- ${passage}`,\n `- saved ${saved} UTC`,\n `- similarity ${(m.similarity ?? 0).toFixed(2)}`,\n ];\n if (m.source) {\n // Context chunks carry provenance; always show where the text came from.\n const where = [\n `- from ${m.source.title}`,\n m.source.headingPath ? `› ${m.source.headingPath}` : \"\",\n m.source.page != null ? `(p. ${m.source.page})` : \"\",\n ]\n .filter(Boolean)\n .join(\" \");\n lines.push(where);\n }\n // Every hit surfaces its id: memory_history looks up how a memory changed, and\n // read_passage fetches a truncated hit's full text (memories AND chunks).\n lines.push(`- id ${m.id}${!m.source && m.version > 1 ? ` (v${m.version})` : \"\"}`);\n return lines.join(\"\\n\");\n })\n .join(\"\\n---\\n\");\n}\n\n/** The full text of one recall hit: the follow-up for a passage recall_memory truncated. */\nexport async function readPassage(memloom: MemoryEngine, args: { id: string }): Promise<string> {\n const content = await memloom.passage(args.id);\n if (content === null) {\n return `No memory or document passage with id ${args.id}. Use an id from recall_memory results.`;\n }\n return content;\n}\n\nexport async function memoryHistory(\n memloom: MemoryEngine,\n args: { memoryId: string },\n): Promise<string> {\n const versions = await memloom.history(args.memoryId);\n if (versions.length === 0) return \"No such memory.\";\n return versions\n .map((v) => {\n const when = new Date(v.assertedAt).toISOString().slice(0, 16).replace(\"T\", \" \");\n const marker = v.status === \"active\" ? \"current\" : \"superseded\";\n return `v${v.version} (${marker}, since ${when} UTC)\\n- ${v.content}`;\n })\n .join(\"\\n---\\n\");\n}\n\nexport async function listConflicts(memloom: MemoryEngine): Promise<string> {\n const conflicts = await memloom.conflicts();\n if (conflicts.length === 0) return \"No pending conflicts.\";\n return conflicts\n .map(\n (c) =>\n `Conflict ${c.id}\\n NEW: ${c.incoming.content}\\n EXISTING: ${c.candidates\n .map((x) => x.content)\n .join(\"; \")}`,\n )\n .join(\"\\n\\n\");\n}\n\nexport async function resolveConflict(\n memloom: MemoryEngine,\n args: {\n conflictId: string;\n action: \"keep_new\" | \"keep_existing\" | \"keep_both\" | \"merge\";\n candidateId?: string;\n content?: string;\n },\n): Promise<string> {\n let decision: ResolveDecision;\n switch (args.action) {\n case \"keep_existing\":\n if (!args.candidateId) throw new Error(\"keep_existing requires candidateId\");\n decision = { action: \"keep_existing\", candidateId: args.candidateId };\n break;\n case \"merge\":\n if (!args.content) throw new Error(\"merge requires the reconciled content\");\n decision = { action: \"merge\", content: args.content };\n break;\n case \"keep_new\":\n decision = { action: \"keep_new\" };\n break;\n case \"keep_both\":\n decision = { action: \"keep_both\" };\n break;\n }\n await memloom.resolveConflict(args.conflictId, decision);\n return `Resolved conflict ${args.conflictId} with \"${args.action}\" (reversible).`;\n}\n\nexport async function setSchemaEntryStatus(\n memloom: MemoryEngine,\n args: { kind: \"entity_type\" | \"predicate\"; name: string; status: \"active\" | \"disabled\" },\n): Promise<string> {\n const schema = await memloom.describeSchema();\n const pool = args.kind === \"entity_type\" ? schema.entityTypes : schema.predicates;\n const entry = pool.find((e) => e.name === args.name.toLowerCase());\n if (!entry) return `No ${args.kind} named \"${args.name}\" exists.`;\n if (entry.status === args.status) {\n return `\"${entry.name}\" is already ${args.status}.`;\n }\n await memloom.setSchemaStatus(entry.id, args.status);\n return `${args.status === \"disabled\" ? \"Disabled\" : \"Enabled\"} ${args.kind} \"${entry.name}\".`;\n}\n\nexport async function deleteSchemaEntry(\n memloom: MemoryEngine,\n args: { kind: \"entity_type\" | \"predicate\"; name: string },\n): Promise<string> {\n const schema = await memloom.describeSchema();\n const pool = args.kind === \"entity_type\" ? schema.entityTypes : schema.predicates;\n const entry = pool.find((e) => e.name === args.name.toLowerCase());\n if (!entry) return `No ${args.kind} named \"${args.name}\" exists.`;\n // Mirror the engine guards with readable answers instead of raw errors: the calling\n // agent should relay these to the user rather than retry.\n if (entry.tier === \"system\") {\n return `\"${entry.name}\" is a built-in ${args.kind}; it can be disabled but never deleted.`;\n }\n if (entry.status !== \"disabled\") {\n return `\"${entry.name}\" is still active. Disable it first (set_schema_entry_status), then delete.`;\n }\n await memloom.deleteSchemaEntry(entry.id);\n return `Deleted ${args.kind} \"${entry.name}\" from the vocabulary. Entities already extracted under it stay in the graph.`;\n}\n","import { MEMORY_TYPES, type MemoryEngine } from \"@memloom/core\";\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport {\n deleteSchemaEntry,\n listConflicts,\n memoryHistory,\n readPassage,\n recallMemory,\n resolveConflict,\n saveMemory,\n setSchemaEntryStatus,\n} from \"./tools.js\";\n\n// Wire the tool functions to the MCP protocol. Descriptions tell the calling agent when to\n// reach for each tool and how memloom behaves (dedup + human-in-the-loop conflicts).\n\nexport function buildServer(memloom: MemoryEngine): McpServer {\n const server = new McpServer({ name: \"memloom\", version: \"0.1.0\" });\n\n server.tool(\n \"save_memory\",\n \"Save a durable memory the user owns. Set `type` to classify it: fact (a stable truth), \" +\n \"preference (how the user likes things), episode (a time-bound event or decision), or \" +\n \"procedure (reusable how-to steps); defaults to fact. memloom dedupes automatically and \" +\n \"flags contradictions instead of overwriting, so save what is worth remembering; the \" +\n \"response says if it created a conflict to resolve.\",\n {\n content: z.string(),\n canonical: z.string().optional(),\n type: z.enum(MEMORY_TYPES).optional(),\n },\n async (args) => ({ content: [{ type: \"text\", text: await saveMemory(memloom, args) }] }),\n );\n\n server.tool(\n \"recall_memory\",\n \"Recall the user's memories AND ingested context documents by meaning, ranked by hybrid \" +\n \"retrieval (semantic + exact keyword + entity). Exact identifiers like file paths, \" +\n \"config keys, or error codes make excellent queries. Document results say which file \" +\n \"and section they came from. Only active (non-superseded) memories are returned. Very \" +\n \"long results are truncated with a marker; read_passage fetches the full text by id.\",\n { query: z.string(), limit: z.number().optional() },\n async (args) => ({ content: [{ type: \"text\", text: await recallMemory(memloom, args) }] }),\n );\n\n server.tool(\n \"read_passage\",\n \"The full text of one recall_memory result, by the `id` shown with it. Call ONLY when \" +\n \"a result ended with a truncation marker and the answer may be in the cut part.\",\n { id: z.string() },\n async (args) => ({ content: [{ type: \"text\", text: await readPassage(memloom, args) }] }),\n );\n\n server.tool(\n \"memory_history\",\n \"Show how a memory changed over time: its full version chain, newest first, with the \" +\n \"current version and every superseded one. Pass the `id` shown by recall_memory. Read-only: \" +\n \"editing memories is a human action in the viewer or CLI.\",\n { memoryId: z.string() },\n async (args) => ({ content: [{ type: \"text\", text: await memoryHistory(memloom, args) }] }),\n );\n\n server.tool(\n \"list_conflicts\",\n \"List pending memory conflicts (contradictions the user has not resolved yet).\",\n {},\n async () => ({ content: [{ type: \"text\", text: await listConflicts(memloom) }] }),\n );\n\n server.tool(\n \"resolve_conflict\",\n \"Resolve a memory conflict. Actions: keep_new, keep_existing (needs candidateId), \" +\n \"keep_both, or merge (needs reconciled content). Every resolution is reversible.\",\n {\n conflictId: z.string(),\n action: z.enum([\"keep_new\", \"keep_existing\", \"keep_both\", \"merge\"]),\n candidateId: z.string().optional(),\n content: z.string().optional(),\n },\n async (args) => ({ content: [{ type: \"text\", text: await resolveConflict(memloom, args) }] }),\n );\n\n server.tool(\n \"set_schema_entry_status\",\n \"Enable or disable a graph schema entry (an entity type or predicate). A disabled entry \" +\n \"stops being used by future extraction, but entities already extracted under it stay \" +\n \"in the graph. Built-in entries can only be disabled, never deleted; user-defined \" +\n \"entries must be disabled before delete_schema_entry will remove them.\",\n {\n kind: z.enum([\"entity_type\", \"predicate\"]),\n name: z.string(),\n status: z.enum([\"active\", \"disabled\"]),\n },\n async (args) => ({\n content: [{ type: \"text\", text: await setSchemaEntryStatus(memloom, args) }],\n }),\n );\n\n server.tool(\n \"delete_schema_entry\",\n \"Permanently remove a DISABLED user-defined vocabulary entry (an entity type or \" +\n \"predicate) from the graph schema. Built-in entries can only be disabled, and an \" +\n \"active entry must be disabled before deletion; the response explains any refusal. \" +\n \"Entities already extracted under the deleted type stay in the graph.\",\n {\n kind: z.enum([\"entity_type\", \"predicate\"]),\n name: z.string(),\n },\n async (args) => ({ content: [{ type: \"text\", text: await deleteSchemaEntry(memloom, args) }] }),\n );\n\n return server;\n}\n"],"mappings":";;;AAAA;AAAA,EAGE;AAAA,OAEK;AAKP,eAAsB,WACpB,SACA,MACiB;AACjB,QAAM,SAAS,MAAM,QAAQ,KAAK;AAAA,IAChC,SAAS,KAAK;AAAA,IACd,GAAI,KAA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AAE,CAAC,EAAE;AAAA,EAC/F;AAEA,SAAO;AACT;","names":[]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { MemoryEngine, MemoryType } from '@memloom/core';
|
|
2
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
|
|
4
|
+
declare function buildServer(memloom: MemoryEngine): McpServer;
|
|
5
|
+
|
|
6
|
+
declare function saveMemory(memloom: MemoryEngine, args: {
|
|
7
|
+
content: string;
|
|
8
|
+
canonical?: string;
|
|
9
|
+
type?: MemoryType;
|
|
10
|
+
}): Promise<string>;
|
|
11
|
+
declare function recallMemory(memloom: MemoryEngine, args: {
|
|
12
|
+
query: string;
|
|
13
|
+
limit?: number;
|
|
14
|
+
}): Promise<string>;
|
|
15
|
+
declare function listConflicts(memloom: MemoryEngine): Promise<string>;
|
|
16
|
+
declare function resolveConflict(memloom: MemoryEngine, args: {
|
|
17
|
+
conflictId: string;
|
|
18
|
+
action: "keep_new" | "keep_existing" | "keep_both" | "merge";
|
|
19
|
+
candidateId?: string;
|
|
20
|
+
content?: string;
|
|
21
|
+
}): Promise<string>;
|
|
22
|
+
|
|
23
|
+
export { buildServer, listConflicts, recallMemory, resolveConflict, saveMemory };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
buildServer,
|
|
4
|
+
listConflicts,
|
|
5
|
+
recallMemory,
|
|
6
|
+
resolveConflict,
|
|
7
|
+
saveMemory
|
|
8
|
+
} from "./chunk-KMKBEXJI.js";
|
|
9
|
+
export {
|
|
10
|
+
buildServer,
|
|
11
|
+
listConflicts,
|
|
12
|
+
recallMemory,
|
|
13
|
+
resolveConflict,
|
|
14
|
+
saveMemory
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@memloom/mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "memloom MCP server (stdio): save_memory, recall_memory, resolve_conflict.",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"author": "Kostek Sytnyk <kostek@versuno.ai>",
|
|
8
|
+
"homepage": "https://memloom.dev",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"memory",
|
|
11
|
+
"ai",
|
|
12
|
+
"agents",
|
|
13
|
+
"local-first",
|
|
14
|
+
"context",
|
|
15
|
+
"mcp",
|
|
16
|
+
"knowledge-graph"
|
|
17
|
+
],
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/memloom/memloom.git",
|
|
21
|
+
"directory": "packages/mcp"
|
|
22
|
+
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=22"
|
|
28
|
+
},
|
|
29
|
+
"main": "./dist/index.js",
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"import": "./dist/index.js"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"bin": {
|
|
38
|
+
"memloom-mcp": "./dist/bin.js"
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"dist"
|
|
42
|
+
],
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
45
|
+
"zod": "^3.24.0",
|
|
46
|
+
"memloom": "0.1.0",
|
|
47
|
+
"@memloom/core": "0.1.0"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "tsup",
|
|
51
|
+
"typecheck": "tsc --noEmit"
|
|
52
|
+
}
|
|
53
|
+
}
|