@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.
@@ -12808,6 +12808,7 @@ const DISCONNECTED = {
12808
12808
  agentColor: "hsl(270, 80%, 60%)",
12809
12809
  getTreeMap: () => null,
12810
12810
  getTrashMap: () => null,
12811
+ refreshSpaces: async () => [],
12811
12812
  getDocSummary: () => null,
12812
12813
  getEnabledPluginNames: () => [],
12813
12814
  setActiveToolCall: () => {},
@@ -12966,6 +12967,7 @@ var HookBridge = class {
12966
12967
  this.server = server;
12967
12968
  this.httpServer = null;
12968
12969
  this._port = null;
12970
+ this.portFileTimer = null;
12969
12971
  this.portFilePath = process.env.ABRA_HOOK_PORT_FILE || path.join(os.homedir(), ".abracadabra-mcp-hook.port");
12970
12972
  }
12971
12973
  get port() {
@@ -12988,19 +12990,30 @@ var HookBridge = class {
12988
12990
  }
12989
12991
  this._port = addr.port;
12990
12992
  this.httpServer = srv;
12991
- try {
12992
- fs.writeFileSync(this.portFilePath, String(this._port), "utf-8");
12993
- } catch (err) {
12994
- console.error(`[hook-bridge] Warning: could not write port file: ${err.message}`);
12995
- }
12993
+ this.writePortFile();
12994
+ this.portFileTimer = setInterval(() => this.writePortFile(), 2e3);
12995
+ this.portFileTimer.unref?.();
12996
12996
  console.error(`[hook-bridge] Listening on 127.0.0.1:${this._port}`);
12997
12997
  console.error(`[hook-bridge] Port file: ${this.portFilePath}`);
12998
12998
  resolve(this._port);
12999
12999
  });
13000
13000
  });
13001
13001
  }
13002
+ /** Write the current listening port to the shared port file (best-effort). */
13003
+ writePortFile() {
13004
+ if (this._port == null) return;
13005
+ try {
13006
+ fs.writeFileSync(this.portFilePath, String(this._port), "utf-8");
13007
+ } catch (err) {
13008
+ console.error(`[hook-bridge] Warning: could not write port file: ${err.message}`);
13009
+ }
13010
+ }
13002
13011
  /** Shut down the HTTP server and remove the port file. */
13003
13012
  async destroy() {
13013
+ if (this.portFileTimer) {
13014
+ clearInterval(this.portFileTimer);
13015
+ this.portFileTimer = null;
13016
+ }
13004
13017
  if (this.httpServer) {
13005
13018
  await new Promise((resolve) => {
13006
13019
  this.httpServer.close(() => resolve());
@@ -13008,7 +13021,7 @@ var HookBridge = class {
13008
13021
  this.httpServer = null;
13009
13022
  }
13010
13023
  try {
13011
- fs.unlinkSync(this.portFilePath);
13024
+ if (fs.readFileSync(this.portFilePath, "utf-8").trim() === String(this._port)) fs.unlinkSync(this.portFilePath);
13012
13025
  } catch {}
13013
13026
  this._port = null;
13014
13027
  console.error("[hook-bridge] Shut down");
@@ -20298,6 +20311,21 @@ var AbracadabraMCPServer = class AbracadabraMCPServer {
20298
20311
  get spaces() {
20299
20312
  return this._spaces;
20300
20313
  }
20314
+ /**
20315
+ * Re-fetch the server's top-level `kind="space"` docs and refresh the
20316
+ * cached `_spaces` snapshot. {@link connect} only takes the snapshot once,
20317
+ * so a space created/seeded after connect (or removed) would otherwise stay
20318
+ * invisible to `list_spaces` until a full reconnect. Tools that surface the
20319
+ * space list should call this first so they reflect server truth.
20320
+ */
20321
+ async refreshSpaces() {
20322
+ if (!this.client) return this._spaces;
20323
+ try {
20324
+ const { spaces } = pickEntrySpace(await this.client.listChildren());
20325
+ this._spaces = spaces;
20326
+ } catch {}
20327
+ return this._spaces;
20328
+ }
20301
20329
  get rootDocument() {
20302
20330
  return this._activeConnection?.doc ?? null;
20303
20331
  }
@@ -22916,7 +22944,7 @@ function registerTreeTools(mcp, server, validator = null) {
22916
22944
  });
22917
22945
  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 () => {
22918
22946
  server.setActiveToolCall({ name: "list_spaces" });
22919
- const spaces = server.spaces;
22947
+ const spaces = await server.refreshSpaces();
22920
22948
  if (!spaces.length) return { content: [{
22921
22949
  type: "text",
22922
22950
  text: "No spaces available — create one to get started."