@abraca/mcp 2.48.0 → 2.50.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/dist/abracadabra-mcp.cjs +35 -7
- package/dist/abracadabra-mcp.cjs.map +1 -1
- package/dist/abracadabra-mcp.esm.js +35 -7
- package/dist/abracadabra-mcp.esm.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/package.json +2 -2
- package/src/active-server.ts +1 -0
- package/src/hook-bridge.ts +39 -10
- package/src/server.ts +19 -0
- package/src/tools/tree.ts +4 -1
package/dist/abracadabra-mcp.cjs
CHANGED
|
@@ -12816,6 +12816,7 @@ const DISCONNECTED = {
|
|
|
12816
12816
|
agentColor: "hsl(270, 80%, 60%)",
|
|
12817
12817
|
getTreeMap: () => null,
|
|
12818
12818
|
getTrashMap: () => null,
|
|
12819
|
+
refreshSpaces: async () => [],
|
|
12819
12820
|
getDocSummary: () => null,
|
|
12820
12821
|
getEnabledPluginNames: () => [],
|
|
12821
12822
|
setActiveToolCall: () => {},
|
|
@@ -12974,6 +12975,7 @@ var HookBridge = class {
|
|
|
12974
12975
|
this.server = server;
|
|
12975
12976
|
this.httpServer = null;
|
|
12976
12977
|
this._port = null;
|
|
12978
|
+
this.portFileTimer = null;
|
|
12977
12979
|
this.portFilePath = process.env.ABRA_HOOK_PORT_FILE || node_path.join(node_os.homedir(), ".abracadabra-mcp-hook.port");
|
|
12978
12980
|
}
|
|
12979
12981
|
get port() {
|
|
@@ -12996,19 +12998,30 @@ var HookBridge = class {
|
|
|
12996
12998
|
}
|
|
12997
12999
|
this._port = addr.port;
|
|
12998
13000
|
this.httpServer = srv;
|
|
12999
|
-
|
|
13000
|
-
|
|
13001
|
-
|
|
13002
|
-
console.error(`[hook-bridge] Warning: could not write port file: ${err.message}`);
|
|
13003
|
-
}
|
|
13001
|
+
this.writePortFile();
|
|
13002
|
+
this.portFileTimer = setInterval(() => this.writePortFile(), 2e3);
|
|
13003
|
+
this.portFileTimer.unref?.();
|
|
13004
13004
|
console.error(`[hook-bridge] Listening on 127.0.0.1:${this._port}`);
|
|
13005
13005
|
console.error(`[hook-bridge] Port file: ${this.portFilePath}`);
|
|
13006
13006
|
resolve(this._port);
|
|
13007
13007
|
});
|
|
13008
13008
|
});
|
|
13009
13009
|
}
|
|
13010
|
+
/** Write the current listening port to the shared port file (best-effort). */
|
|
13011
|
+
writePortFile() {
|
|
13012
|
+
if (this._port == null) return;
|
|
13013
|
+
try {
|
|
13014
|
+
node_fs.writeFileSync(this.portFilePath, String(this._port), "utf-8");
|
|
13015
|
+
} catch (err) {
|
|
13016
|
+
console.error(`[hook-bridge] Warning: could not write port file: ${err.message}`);
|
|
13017
|
+
}
|
|
13018
|
+
}
|
|
13010
13019
|
/** Shut down the HTTP server and remove the port file. */
|
|
13011
13020
|
async destroy() {
|
|
13021
|
+
if (this.portFileTimer) {
|
|
13022
|
+
clearInterval(this.portFileTimer);
|
|
13023
|
+
this.portFileTimer = null;
|
|
13024
|
+
}
|
|
13012
13025
|
if (this.httpServer) {
|
|
13013
13026
|
await new Promise((resolve) => {
|
|
13014
13027
|
this.httpServer.close(() => resolve());
|
|
@@ -13016,7 +13029,7 @@ var HookBridge = class {
|
|
|
13016
13029
|
this.httpServer = null;
|
|
13017
13030
|
}
|
|
13018
13031
|
try {
|
|
13019
|
-
node_fs.unlinkSync(this.portFilePath);
|
|
13032
|
+
if (node_fs.readFileSync(this.portFilePath, "utf-8").trim() === String(this._port)) node_fs.unlinkSync(this.portFilePath);
|
|
13020
13033
|
} catch {}
|
|
13021
13034
|
this._port = null;
|
|
13022
13035
|
console.error("[hook-bridge] Shut down");
|
|
@@ -20306,6 +20319,21 @@ var AbracadabraMCPServer = class AbracadabraMCPServer {
|
|
|
20306
20319
|
get spaces() {
|
|
20307
20320
|
return this._spaces;
|
|
20308
20321
|
}
|
|
20322
|
+
/**
|
|
20323
|
+
* Re-fetch the server's top-level `kind="space"` docs and refresh the
|
|
20324
|
+
* cached `_spaces` snapshot. {@link connect} only takes the snapshot once,
|
|
20325
|
+
* so a space created/seeded after connect (or removed) would otherwise stay
|
|
20326
|
+
* invisible to `list_spaces` until a full reconnect. Tools that surface the
|
|
20327
|
+
* space list should call this first so they reflect server truth.
|
|
20328
|
+
*/
|
|
20329
|
+
async refreshSpaces() {
|
|
20330
|
+
if (!this.client) return this._spaces;
|
|
20331
|
+
try {
|
|
20332
|
+
const { spaces } = (0, _abraca_dabra.pickEntrySpace)(await this.client.listChildren());
|
|
20333
|
+
this._spaces = spaces;
|
|
20334
|
+
} catch {}
|
|
20335
|
+
return this._spaces;
|
|
20336
|
+
}
|
|
20309
20337
|
get rootDocument() {
|
|
20310
20338
|
return this._activeConnection?.doc ?? null;
|
|
20311
20339
|
}
|
|
@@ -22927,7 +22955,7 @@ function registerTreeTools(mcp, server, validator = null) {
|
|
|
22927
22955
|
});
|
|
22928
22956
|
mcp.tool("list_spaces", "List all Spaces available on the server. Spaces are top-level documents (direct children of the server root) tagged with kind=\"space\". Returns id, label, public_access, and active flag. Use switch_space to navigate.", {}, async () => {
|
|
22929
22957
|
server.setActiveToolCall({ name: "list_spaces" });
|
|
22930
|
-
const spaces = server.
|
|
22958
|
+
const spaces = await server.refreshSpaces();
|
|
22931
22959
|
if (!spaces.length) return { content: [{
|
|
22932
22960
|
type: "text",
|
|
22933
22961
|
text: "No spaces available — create one to get started."
|