@mantyx/sdk 2026.11.12 → 2026.11.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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,18 @@ and new releases use calendar versions (`YYYY.M.RELEASE`). Historical versions r
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ### Added
9
+
10
+ - `defineLocalMcp({ ..., toolFilter: [...] })` restricts a local MCP server to the listed tools, as `mantyxMcp` already allows. Unlisted tools are left out of the catalog sent to MANTYX, and the SDK refuses to forward a call to one. The filter stays in the client.
11
+
12
+ ### Fixed
13
+
14
+ - A local MCP connection is now closed when `tools/list` fails during discovery.
15
+
16
+ ### Changed
17
+
18
+ - **Node.js 22 or newer is now required** (`engines.node` is `>=22.0.0`, and the bundle targets Node 22). Node.js 18 and 20 have reached end of life.
19
+
8
20
  ### Removed
9
21
 
10
22
  - **Breaking:** plan-only runs, which are deprecated and no longer offered by this SDK (the server still honors `planOnly` from older SDK versions). Removed `MantyxClient.runPlan`, `AgentSession.runPlan`, the `planOnly()` helper, `PlanOptions.planOnly`, `RunResult.plan` and `ResultEvent.plan`. `plan` with `"auto"`, `"required"` or `{ mode?, steps?, brief? }` still drives the live checklist on `task_plan` events. A `planOnly: true` passed through an untyped object now fails locally with `MantyxError`; `planOnly: false` is dropped from the request.
package/README.md CHANGED
@@ -32,7 +32,7 @@ npm install @mantyx/sdk zod
32
32
  # or: yarn add @mantyx/sdk zod
33
33
  ```
34
34
 
35
- Requires Node.js 18.17+ (for `fetch` and `ReadableStream`). The SDK depends
35
+ Requires Node.js 22+. The SDK depends
36
36
  on `zod` (parameter schemas) and `@modelcontextprotocol/sdk` (the official
37
37
  MCP TypeScript SDK that powers `defineLocalMcp`'s stdio + Streamable HTTP
38
38
  transports). The MCP SDK is loaded lazily — apps that never use
@@ -214,6 +214,7 @@ await client.runAgent({
214
214
  name: "fs",
215
215
  url: "http://localhost:8080/mcp",
216
216
  headers: { Authorization: `Bearer ${process.env.FS_TOKEN}` },
217
+ toolFilter: ["read_file", "list_dir"], // optional allow-list, enforced by the SDK
217
218
  }),
218
219
 
219
220
  // (b) stdio MCP server — the SDK spawns the process for you.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  MantyxError,
3
3
  MantyxRunError
4
- } from "./chunk-EXTS5Q3T.js";
4
+ } from "./chunk-DBMT5UZ2.js";
5
5
 
6
6
  // src/a2a-server.ts
7
7
  import {
@@ -158,6 +158,18 @@ function mantyxMcp(opts) {
158
158
  ...toolGrouping(opts)
159
159
  };
160
160
  }
161
+ function localMcpToolFilter(toolFilter) {
162
+ if (toolFilter === void 0) return {};
163
+ if (!Array.isArray(toolFilter)) {
164
+ throw new Error("defineLocalMcp: toolFilter must be an array of tool names");
165
+ }
166
+ for (const entry of toolFilter) {
167
+ if (typeof entry !== "string" || entry.length === 0) {
168
+ throw new Error("defineLocalMcp: toolFilter entries must be non-empty strings");
169
+ }
170
+ }
171
+ return toolFilter.length > 0 ? { toolFilter: [...toolFilter] } : {};
172
+ }
161
173
  function defineLocalMcp(opts) {
162
174
  assertToolName(opts.name);
163
175
  const hasHttp = typeof opts.url === "string" && opts.url.length > 0;
@@ -182,6 +194,7 @@ function defineLocalMcp(opts) {
182
194
  ...opts.headers ? { headers: { ...opts.headers } } : {}
183
195
  },
184
196
  stdio: void 0,
197
+ ...localMcpToolFilter(opts.toolFilter),
185
198
  ...toolGrouping(opts)
186
199
  };
187
200
  }
@@ -196,6 +209,7 @@ function defineLocalMcp(opts) {
196
209
  ...opts.env ? { env: { ...opts.env } } : {},
197
210
  ...opts.cwd ? { cwd: opts.cwd } : {}
198
211
  },
212
+ ...localMcpToolFilter(opts.toolFilter),
199
213
  ...toolGrouping(opts)
200
214
  };
201
215
  }
@@ -562,17 +576,6 @@ async function resolveMcp(t) {
562
576
  { cause: err }
563
577
  );
564
578
  }
565
- const serverInfo = client.getServerVersion() ?? { name: t.name };
566
- const listed = await client.listTools();
567
- const tools = listed.tools.map((tool) => {
568
- const out = {
569
- name: tool.name,
570
- inputSchema: tool.inputSchema
571
- };
572
- if (typeof tool.description === "string") out.description = tool.description;
573
- if (tool.annotations) out.annotations = tool.annotations;
574
- return out;
575
- });
576
579
  const close = async () => {
577
580
  try {
578
581
  await client.close();
@@ -584,6 +587,24 @@ async function resolveMcp(t) {
584
587
  } catch {
585
588
  }
586
589
  };
590
+ const serverInfo = client.getServerVersion() ?? { name: t.name };
591
+ let listed;
592
+ try {
593
+ listed = await client.listTools();
594
+ } catch (err) {
595
+ await close();
596
+ throw err;
597
+ }
598
+ const allowed = t.toolFilter ? new Set(t.toolFilter) : void 0;
599
+ const tools = listed.tools.filter((tool) => !allowed || allowed.has(tool.name)).map((tool) => {
600
+ const out = {
601
+ name: tool.name,
602
+ inputSchema: tool.inputSchema
603
+ };
604
+ if (typeof tool.description === "string") out.description = tool.description;
605
+ if (tool.annotations) out.annotations = tool.annotations;
606
+ return out;
607
+ });
587
608
  t._resolved = {
588
609
  serverInfo,
589
610
  tools,
@@ -688,6 +709,11 @@ async function callMcpTool(server, toolName, args) {
688
709
  `defineLocalMcp(${JSON.stringify(server.name)}): MCP server has not been initialised`
689
710
  );
690
711
  }
712
+ if (server.toolFilter && !server.toolFilter.includes(toolName)) {
713
+ throw new Error(
714
+ `MCP tool ${JSON.stringify(toolName)} is not in the toolFilter of defineLocalMcp(${JSON.stringify(server.name)})`
715
+ );
716
+ }
691
717
  const result = await resolved.client.callTool({ name: toolName, arguments: args });
692
718
  if (result.isError) {
693
719
  const text = textFromMcpContent(result.content) || "MCP tool reported an error";
package/dist/index.cjs CHANGED
@@ -229,6 +229,18 @@ function mantyxMcp(opts) {
229
229
  ...toolGrouping(opts)
230
230
  };
231
231
  }
232
+ function localMcpToolFilter(toolFilter) {
233
+ if (toolFilter === void 0) return {};
234
+ if (!Array.isArray(toolFilter)) {
235
+ throw new Error("defineLocalMcp: toolFilter must be an array of tool names");
236
+ }
237
+ for (const entry of toolFilter) {
238
+ if (typeof entry !== "string" || entry.length === 0) {
239
+ throw new Error("defineLocalMcp: toolFilter entries must be non-empty strings");
240
+ }
241
+ }
242
+ return toolFilter.length > 0 ? { toolFilter: [...toolFilter] } : {};
243
+ }
232
244
  function defineLocalMcp(opts) {
233
245
  assertToolName(opts.name);
234
246
  const hasHttp = typeof opts.url === "string" && opts.url.length > 0;
@@ -253,6 +265,7 @@ function defineLocalMcp(opts) {
253
265
  ...opts.headers ? { headers: { ...opts.headers } } : {}
254
266
  },
255
267
  stdio: void 0,
268
+ ...localMcpToolFilter(opts.toolFilter),
256
269
  ...toolGrouping(opts)
257
270
  };
258
271
  }
@@ -267,6 +280,7 @@ function defineLocalMcp(opts) {
267
280
  ...opts.env ? { env: { ...opts.env } } : {},
268
281
  ...opts.cwd ? { cwd: opts.cwd } : {}
269
282
  },
283
+ ...localMcpToolFilter(opts.toolFilter),
270
284
  ...toolGrouping(opts)
271
285
  };
272
286
  }
@@ -418,17 +432,6 @@ async function resolveMcp(t) {
418
432
  { cause: err }
419
433
  );
420
434
  }
421
- const serverInfo = client.getServerVersion() ?? { name: t.name };
422
- const listed = await client.listTools();
423
- const tools = listed.tools.map((tool) => {
424
- const out = {
425
- name: tool.name,
426
- inputSchema: tool.inputSchema
427
- };
428
- if (typeof tool.description === "string") out.description = tool.description;
429
- if (tool.annotations) out.annotations = tool.annotations;
430
- return out;
431
- });
432
435
  const close = async () => {
433
436
  try {
434
437
  await client.close();
@@ -440,6 +443,24 @@ async function resolveMcp(t) {
440
443
  } catch {
441
444
  }
442
445
  };
446
+ const serverInfo = client.getServerVersion() ?? { name: t.name };
447
+ let listed;
448
+ try {
449
+ listed = await client.listTools();
450
+ } catch (err) {
451
+ await close();
452
+ throw err;
453
+ }
454
+ const allowed = t.toolFilter ? new Set(t.toolFilter) : void 0;
455
+ const tools = listed.tools.filter((tool) => !allowed || allowed.has(tool.name)).map((tool) => {
456
+ const out = {
457
+ name: tool.name,
458
+ inputSchema: tool.inputSchema
459
+ };
460
+ if (typeof tool.description === "string") out.description = tool.description;
461
+ if (tool.annotations) out.annotations = tool.annotations;
462
+ return out;
463
+ });
443
464
  t._resolved = {
444
465
  serverInfo,
445
466
  tools,
@@ -544,6 +565,11 @@ async function callMcpTool(server, toolName, args) {
544
565
  `defineLocalMcp(${JSON.stringify(server.name)}): MCP server has not been initialised`
545
566
  );
546
567
  }
568
+ if (server.toolFilter && !server.toolFilter.includes(toolName)) {
569
+ throw new Error(
570
+ `MCP tool ${JSON.stringify(toolName)} is not in the toolFilter of defineLocalMcp(${JSON.stringify(server.name)})`
571
+ );
572
+ }
547
573
  const result = await resolved.client.callTool({ name: toolName, arguments: args });
548
574
  if (result.isError) {
549
575
  const text = textFromMcpContent(result.content) || "MCP tool reported an error";
@@ -2847,7 +2873,7 @@ async function runComputerUse(opts) {
2847
2873
  }
2848
2874
 
2849
2875
  // src/version.ts
2850
- var SDK_VERSION = "2026.11.12";
2876
+ var SDK_VERSION = "2026.11.14";
2851
2877
  // Annotate the CommonJS export names for ESM import in node:
2852
2878
  0 && (module.exports = {
2853
2879
  AgentSession,
package/dist/index.js CHANGED
@@ -24,7 +24,7 @@ import {
24
24
  taskPlanFromEventData,
25
25
  toToolParametersWire,
26
26
  zodToJsonSchema
27
- } from "./chunk-EXTS5Q3T.js";
27
+ } from "./chunk-DBMT5UZ2.js";
28
28
 
29
29
  // src/oauth.ts
30
30
  var DEFAULT_OAUTH_BASE_URL = "https://app.mantyx.io";
@@ -601,7 +601,7 @@ async function runComputerUse(opts) {
601
601
  }
602
602
 
603
603
  // src/version.ts
604
- var SDK_VERSION = "2026.11.12";
604
+ var SDK_VERSION = "2026.11.14";
605
605
  export {
606
606
  AgentSession,
607
607
  COMPUTER_USE_ACTIONS,
package/dist/tools.d.ts CHANGED
@@ -337,6 +337,12 @@ export interface LocalMcpServer extends ToolGrouping {
337
337
  readonly http: LocalMcpHttpTransport | undefined;
338
338
  /** One-of with {@link http} — the transport spec is mutually exclusive. */
339
339
  readonly stdio: LocalMcpStdioTransport | undefined;
340
+ /**
341
+ * Upstream (unprefixed) MCP tool names the model may use. Unlisted tools
342
+ * are left out of the catalog shipped in the spec, and a call to one is
343
+ * refused without reaching the server. Unset exposes every tool.
344
+ */
345
+ readonly toolFilter?: string[];
340
346
  /**
341
347
  * Internal cache of the resolved MCP client + catalog. Populated lazily
342
348
  * by the run driver on the first run; not part of the user contract.
@@ -413,6 +419,14 @@ export interface DefineLocalMcpOptions extends ToolGroupingOptions {
413
419
  env?: Record<string, string>;
414
420
  /** Working directory for the stdio child process. */
415
421
  cwd?: string;
422
+ /**
423
+ * Optional allowlist of upstream (unprefixed) MCP tool names, as in
424
+ * {@link mantyxMcp}. Unlisted tools are left out of the catalog the model
425
+ * sees, and the SDK refuses to forward a call to one. Applied in the
426
+ * client only: `toolFilter: ["run_query"]` keeps a server's write tools
427
+ * away from the model.
428
+ */
429
+ toolFilter?: string[];
416
430
  }
417
431
  export declare function defineLocalMcp(opts: DefineLocalMcpOptions): LocalMcpServer;
418
432
  export type ToolRef = LocalTool | A2AToolRef | LocalA2ATool | McpToolRef | LocalMcpServer;
package/dist/version.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Release version — synced from sdk/VERSION (`pnpm run sync-version`).
3
3
  */
4
- export declare const SDK_VERSION = "2026.11.12";
4
+ export declare const SDK_VERSION = "2026.11.14";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mantyx/sdk",
3
- "version": "2026.11.12",
3
+ "version": "2026.11.14",
4
4
  "description": "MANTYX as a hosted agent runtime: define agents inline, mix server-resolved MCP and A2A tools with locally-executed tools, run them remotely.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -31,7 +31,7 @@
31
31
  "LICENSE"
32
32
  ],
33
33
  "engines": {
34
- "node": ">=18.17.0"
34
+ "node": ">=22.0.0"
35
35
  },
36
36
  "dependencies": {
37
37
  "@modelcontextprotocol/sdk": "^1.32.2",
@@ -56,7 +56,7 @@
56
56
  "devDependencies": {
57
57
  "@a2a-js/sdk": "^1.3.0",
58
58
  "@types/express": "^5.0.6",
59
- "@types/node": "^26.6.10",
59
+ "@types/node": "^26.6.11",
60
60
  "express": "^5.3.0",
61
61
  "playwright": "^1.65.1",
62
62
  "tsrs": "7.1.0-beta.tsrs5",