@illli-studio/mory 0.1.2 → 0.1.4
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 +3 -0
- package/package.json +1 -1
- package/src/cli.mjs +19 -4
- package/src/mcp.mjs +2 -1
package/README.md
CHANGED
|
@@ -5,7 +5,9 @@ Local-first memory runtime with a web console and a generic MCP server.
|
|
|
5
5
|
```bash
|
|
6
6
|
npm install -g @illli-studio/mory
|
|
7
7
|
mory init
|
|
8
|
+
mory --version
|
|
8
9
|
mory start
|
|
10
|
+
mory start --background
|
|
9
11
|
mory status
|
|
10
12
|
mory stop
|
|
11
13
|
mory export ./mory-export.json
|
|
@@ -13,6 +15,7 @@ mory import ./mory-export.json
|
|
|
13
15
|
```
|
|
14
16
|
|
|
15
17
|
For MCP clients, use `mory mcp` as a stdio server. Set `MORY_API_URL` and `MORY_API_TOKEN` when the API is managed separately.
|
|
18
|
+
Use `mory mcp --check` to diagnose the local API connection without starting the stdio protocol.
|
|
16
19
|
|
|
17
20
|
The same package also exports the TypeScript client:
|
|
18
21
|
|
package/package.json
CHANGED
package/src/cli.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import { fileURLToPath } from "node:url";
|
|
|
8
8
|
import { runMcp } from "./mcp.mjs";
|
|
9
9
|
|
|
10
10
|
const packageRoot = resolve(fileURLToPath(new URL("..", import.meta.url)));
|
|
11
|
+
const runtimeVersion = "0.1.4";
|
|
11
12
|
const repoRoot = resolve(packageRoot, "../..");
|
|
12
13
|
const dataDir = process.env.MORY_HOME || join(homedir(), ".mory");
|
|
13
14
|
const configPath = join(dataDir, "config.json");
|
|
@@ -32,22 +33,34 @@ async function waitForHealth(base, token, timeout = 8000) {
|
|
|
32
33
|
return false;
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
async function start() {
|
|
36
|
+
async function start(background = false) {
|
|
36
37
|
const current = config();
|
|
37
38
|
const base = `http://127.0.0.1:${current.port}`;
|
|
38
39
|
if (await waitForHealth(base, current.token, 500)) { console.log(`Mory is already running at ${base}`); return; }
|
|
39
40
|
const env = { ...process.env, MORY_PORT: String(current.port), MORY_API_TOKEN: current.token, MORY_DATABASE: current.database, MORY_WEB_DIST: webDist() };
|
|
40
|
-
const child = spawn(process.execPath, [apiEntry()], { env, stdio: "inherit", detached:
|
|
41
|
+
const child = spawn(process.execPath, [apiEntry()], { env, stdio: background ? "ignore" : "inherit", detached: background });
|
|
41
42
|
if (!await waitForHealth(base, current.token)) { child.kill(); throw new Error("Mory failed to start. Run `mory doctor` for diagnostics."); }
|
|
42
43
|
writeFileSync(pidPath, String(child.pid));
|
|
43
44
|
child.once("exit", () => { if (existsSync(pidPath) && readFileSync(pidPath, "utf8").trim() === String(child.pid)) unlinkSync(pidPath); });
|
|
45
|
+
if (background) child.unref();
|
|
44
46
|
console.log(`Mory is running at ${base}`);
|
|
45
47
|
console.log(`Data: ${current.database}`);
|
|
46
48
|
console.log("MCP: run `mory mcp` from your agent configuration");
|
|
49
|
+
if (background) console.log("Running in background. Use `mory status` or `mory stop`.");
|
|
50
|
+
if (background) return;
|
|
47
51
|
process.on("SIGINT", () => child.kill("SIGINT"));
|
|
48
52
|
process.on("SIGTERM", () => child.kill("SIGTERM"));
|
|
49
53
|
}
|
|
50
54
|
|
|
55
|
+
async function mcpCheck() {
|
|
56
|
+
const current = config();
|
|
57
|
+
const base = process.env.MORY_API_URL || `http://127.0.0.1:${current.port}`;
|
|
58
|
+
const token = process.env.MORY_API_TOKEN || current.token;
|
|
59
|
+
const response = await fetch(base.replace(/\/$/, "") + "/health", { headers: { authorization: `Bearer ${token}` } });
|
|
60
|
+
console.log(JSON.stringify({ api: base, reachable: response.ok, mcp: "ready", protocol: "2025-06-18" }, null, 2));
|
|
61
|
+
if (!response.ok) process.exitCode = 1;
|
|
62
|
+
}
|
|
63
|
+
|
|
51
64
|
async function stop() {
|
|
52
65
|
const current = config();
|
|
53
66
|
if (!await waitForHealth(`http://127.0.0.1:${current.port}`, current.token, 500)) { if (existsSync(pidPath)) unlinkSync(pidPath); console.log("Mory is not running."); return; }
|
|
@@ -91,11 +104,13 @@ async function importMemories(inputPath) {
|
|
|
91
104
|
|
|
92
105
|
const [command = "start", ...args] = process.argv.slice(2);
|
|
93
106
|
try {
|
|
94
|
-
if (command === "
|
|
95
|
-
else if (command === "
|
|
107
|
+
if (command === "--version" || command === "-v" || command === "version") console.log(runtimeVersion);
|
|
108
|
+
else if (command === "init") { config(); console.log(`Initialized Mory at ${dataDir}`); }
|
|
109
|
+
else if (command === "start") await start(args.includes("--background") || args.includes("-d"));
|
|
96
110
|
else if (command === "stop") await stop();
|
|
97
111
|
else if (command === "export") await exportMemories(args[0]);
|
|
98
112
|
else if (command === "import") await importMemories(args[0]);
|
|
113
|
+
else if (command === "mcp" && args.includes("--check")) await mcpCheck();
|
|
99
114
|
else if (command === "mcp") await runMcp({ baseUrl: process.env.MORY_API_URL || `http://127.0.0.1:${config().port}`, token: process.env.MORY_API_TOKEN || config().token });
|
|
100
115
|
else if (command === "doctor") await doctor();
|
|
101
116
|
else if (command === "status") { const c = config(); console.log(JSON.stringify({ url: `http://127.0.0.1:${c.port}`, dataDir, running: await waitForHealth(`http://127.0.0.1:${c.port}`, c.token, 500) }, null, 2)); }
|
package/src/mcp.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const protocolVersion = "2025-06-18";
|
|
2
|
+
const runtimeVersion = "0.1.4";
|
|
2
3
|
|
|
3
4
|
async function callApi(baseUrl, token, path, method = "POST", body) {
|
|
4
5
|
const response = await fetch(baseUrl.replace(/\/$/, "") + path, { method, headers: { authorization: `Bearer ${token}`, "content-type": "application/json" }, body: body === undefined ? undefined : JSON.stringify(body) });
|
|
@@ -17,7 +18,7 @@ const tools = [
|
|
|
17
18
|
];
|
|
18
19
|
|
|
19
20
|
async function handle(message, options) {
|
|
20
|
-
if (message.method === "initialize") return { protocolVersion, capabilities: { tools: {} }, serverInfo: { name: "mory", version:
|
|
21
|
+
if (message.method === "initialize") return { protocolVersion, capabilities: { tools: {} }, serverInfo: { name: "mory", version: runtimeVersion } };
|
|
21
22
|
if (message.method === "notifications/initialized") return null;
|
|
22
23
|
if (message.method === "tools/list") return { tools };
|
|
23
24
|
if (message.method !== "tools/call") return {};
|