@omgbase/sync 0.5.8 → 0.5.14

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.
@@ -4,7 +4,19 @@ import type { EngineClient, ChangesPage, DocBytes } from "./engine-client.js";
4
4
  /** Wraps a connected MCP SDK Client, calling the engine's sync tools. */
5
5
  export declare class McpEngineClient implements EngineClient {
6
6
  private readonly client;
7
+ private tools;
7
8
  constructor(client: Client);
9
+ /**
10
+ * The tool names the server lists (`tools/list`), fetched once per
11
+ * connection — `connectEngine` does it on connect, so a caller may ask
12
+ * `hasTool` synchronously afterwards. A server may serve a catalog PROFILE
13
+ * (spec/surface §4 "Profiles", 4.3: `omg mcp --tools minimal` lists ten
14
+ * tools); the CLI's `--server` verbs ask before calling a sugar tool and fall
15
+ * back to `apply { effects }` when it is not listed (spec/cli §2.3, 4.2).
16
+ */
17
+ listTools(): Promise<ReadonlySet<string>>;
18
+ /** Whether the server lists `name` — after `listTools()` ran (it has, for a client `connectEngine` returned); `true` while unknown, so a never-listed client behaves as before. */
19
+ hasTool(name: string): boolean;
8
20
  /** Call any MCP tool and return its parsed JSON result. Throws on a tool
9
21
  * error (the message carries the engine error code) or non-JSON output. The
10
22
  * general-purpose call the CLI's `--server` mode uses for arbitrary tools. */
@@ -6,9 +6,29 @@ import { VERSION } from "@omgbase/core";
6
6
  /** Wraps a connected MCP SDK Client, calling the engine's sync tools. */
7
7
  export class McpEngineClient {
8
8
  client;
9
+ tools = null;
9
10
  constructor(client) {
10
11
  this.client = client;
11
12
  }
13
+ /**
14
+ * The tool names the server lists (`tools/list`), fetched once per
15
+ * connection — `connectEngine` does it on connect, so a caller may ask
16
+ * `hasTool` synchronously afterwards. A server may serve a catalog PROFILE
17
+ * (spec/surface §4 "Profiles", 4.3: `omg mcp --tools minimal` lists ten
18
+ * tools); the CLI's `--server` verbs ask before calling a sugar tool and fall
19
+ * back to `apply { effects }` when it is not listed (spec/cli §2.3, 4.2).
20
+ */
21
+ async listTools() {
22
+ if (this.tools)
23
+ return this.tools;
24
+ const res = await this.client.listTools();
25
+ this.tools = new Set(res.tools.map((t) => t.name));
26
+ return this.tools;
27
+ }
28
+ /** Whether the server lists `name` — after `listTools()` ran (it has, for a client `connectEngine` returned); `true` while unknown, so a never-listed client behaves as before. */
29
+ hasTool(name) {
30
+ return this.tools === null ? true : this.tools.has(name);
31
+ }
12
32
  /** Call any MCP tool and return its parsed JSON result. Throws on a tool
13
33
  * error (the message carries the engine error code) or non-JSON output. The
14
34
  * general-purpose call the CLI's `--server` mode uses for arbitrary tools. */
@@ -74,7 +94,12 @@ export async function connectStdioEngine(spec) {
74
94
  ...(spec.env ? { env: spec.env } : {}),
75
95
  });
76
96
  await client.connect(transport);
77
- return new McpEngineClient(client);
97
+ return listed(new McpEngineClient(client));
98
+ }
99
+ /** The one `tools/list` of a connection (see `McpEngineClient.listTools`), so `hasTool` answers synchronously. */
100
+ async function listed(engine) {
101
+ await engine.listTools();
102
+ return engine;
78
103
  }
79
104
  /** Connect to an omgbase MCP server over Streamable HTTP at `url`. The full URL
80
105
  * (including any base path) is used verbatim, so a secret-prefixed endpoint
@@ -90,7 +115,7 @@ export async function connectHttpEngine(spec) {
90
115
  ...(spec.headers && Object.keys(spec.headers).length > 0 ? { requestInit: { headers: spec.headers } } : {}),
91
116
  });
92
117
  await client.connect(transport);
93
- return new McpEngineClient(client);
118
+ return listed(new McpEngineClient(client));
94
119
  }
95
120
  const HTTP_URL_RE = /^https?:\/\//i;
96
121
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omgbase/sync",
3
- "version": "0.5.8",
3
+ "version": "0.5.14",
4
4
  "description": "Open Markdown Graph Base — standalone store-to-store synchronizer: a coordinator over an EngineClient seam (in-process or MCP-client) and source adapters",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -53,7 +53,7 @@
53
53
  },
54
54
  "dependencies": {
55
55
  "@modelcontextprotocol/sdk": "^1.30.0",
56
- "@omgbase/core": "^0.15.0",
56
+ "@omgbase/core": "^0.21.0",
57
57
  "@omgbase/fs-adapter": "^0.2.0"
58
58
  },
59
59
  "scripts": {