@topodb/pi 0.0.1 → 0.0.2
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/dist/server-handle.js +10 -6
- package/package.json +1 -1
package/dist/server-handle.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// src/server-handle.ts
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
+
import { mkdirSync } from "node:fs";
|
|
4
|
+
import { dirname } from "node:path";
|
|
3
5
|
import { McpStdioClient } from "./mcp-client.js";
|
|
4
6
|
const require = createRequire(import.meta.url);
|
|
5
7
|
export class TopodbServer {
|
|
@@ -12,15 +14,17 @@ export class TopodbServer {
|
|
|
12
14
|
static resolveLauncher() {
|
|
13
15
|
return require.resolve("@topodb/topodb-mcp/bin/topodb-mcp.js");
|
|
14
16
|
}
|
|
15
|
-
args() {
|
|
16
|
-
const db = this.env.TOPODB_DB || ".topodb/memory.redb";
|
|
17
|
-
const scope = this.env.TOPODB_SCOPE || "shared";
|
|
18
|
-
return [TopodbServer.resolveLauncher(), "--db", db, "--scope", scope];
|
|
19
|
-
}
|
|
20
17
|
async ensure() {
|
|
21
18
|
if (this.client?.running)
|
|
22
19
|
return this.client;
|
|
23
|
-
|
|
20
|
+
const db = this.env.TOPODB_DB || ".topodb/memory.redb";
|
|
21
|
+
const scope = this.env.TOPODB_SCOPE || "shared";
|
|
22
|
+
// topodb-mcp creates the db file on open but treats a missing parent
|
|
23
|
+
// directory as a startup error — and the default `.topodb/` won't exist in
|
|
24
|
+
// a fresh project. Create it so the server comes up on first use.
|
|
25
|
+
mkdirSync(dirname(db), { recursive: true });
|
|
26
|
+
const args = [TopodbServer.resolveLauncher(), "--db", db, "--scope", scope];
|
|
27
|
+
this.client = new McpStdioClient(args);
|
|
24
28
|
await this.client.start();
|
|
25
29
|
return this.client;
|
|
26
30
|
}
|