@mantyx/sdk 2026.11.13 → 2026.11.15
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 +12 -0
- package/README.md +3 -0
- package/dist/a2a-server.js +1 -1
- package/dist/{chunk-EXTS5Q3T.js → chunk-FWRGNJUW.js} +80 -13
- package/dist/index.cjs +81 -14
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/local-resolver.d.ts +6 -0
- package/dist/tools.d.ts +45 -0
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
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
|
+
- `defineLocalMcp({ ..., beforeCall })` runs a hook before every MCP `tools/call`. It gets the unprefixed tool name and a copy of the arguments, and a returned string refuses the call: the string goes back to the model as the tool's error and the server is never called. It may be async.
|
|
13
|
+
- `defineLocalMcp({ ..., fetch })` sets the `fetch` every request of a Streamable HTTP MCP session goes through, including the SSE GET and the closing DELETE, for per-request signing such as AWS SigV4.
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- A local MCP connection is now closed when `tools/list` fails during discovery.
|
|
18
|
+
- Closing a Streamable HTTP local MCP connection now ends the server-side session (`DELETE`), as the Python SDK does.
|
|
19
|
+
|
|
8
20
|
### Changed
|
|
9
21
|
|
|
10
22
|
- **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.
|
package/README.md
CHANGED
|
@@ -214,6 +214,9 @@ 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
|
|
218
|
+
// beforeCall: (tool, args) => refusal string or undefined, // optional call check
|
|
219
|
+
// fetch: signingFetch, // optional, e.g. per-request SigV4 signing
|
|
217
220
|
}),
|
|
218
221
|
|
|
219
222
|
// (b) stdio MCP server — the SDK spawns the process for you.
|
package/dist/a2a-server.js
CHANGED
|
@@ -158,8 +158,30 @@ 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
|
+
}
|
|
173
|
+
function localMcpBeforeCall(beforeCall) {
|
|
174
|
+
if (beforeCall === void 0) return {};
|
|
175
|
+
if (typeof beforeCall !== "function") {
|
|
176
|
+
throw new Error("defineLocalMcp: beforeCall must be a function");
|
|
177
|
+
}
|
|
178
|
+
return { beforeCall };
|
|
179
|
+
}
|
|
161
180
|
function defineLocalMcp(opts) {
|
|
162
181
|
assertToolName(opts.name);
|
|
182
|
+
if (opts.fetch !== void 0 && typeof opts.fetch !== "function") {
|
|
183
|
+
throw new Error("defineLocalMcp: fetch must be a function");
|
|
184
|
+
}
|
|
163
185
|
const hasHttp = typeof opts.url === "string" && opts.url.length > 0;
|
|
164
186
|
const hasStdio = typeof opts.command === "string" && opts.command.length > 0;
|
|
165
187
|
if (hasHttp && hasStdio) {
|
|
@@ -172,6 +194,9 @@ function defineLocalMcp(opts) {
|
|
|
172
194
|
"defineLocalMcp: one of `url` (Streamable HTTP) or `command` (stdio) is required"
|
|
173
195
|
);
|
|
174
196
|
}
|
|
197
|
+
if (opts.fetch !== void 0 && !hasHttp) {
|
|
198
|
+
throw new Error("defineLocalMcp: `fetch` applies to the Streamable HTTP transport only");
|
|
199
|
+
}
|
|
175
200
|
if (hasHttp) {
|
|
176
201
|
const url = opts.url;
|
|
177
202
|
return {
|
|
@@ -179,9 +204,12 @@ function defineLocalMcp(opts) {
|
|
|
179
204
|
name: opts.name,
|
|
180
205
|
http: {
|
|
181
206
|
url,
|
|
182
|
-
...opts.headers ? { headers: { ...opts.headers } } : {}
|
|
207
|
+
...opts.headers ? { headers: { ...opts.headers } } : {},
|
|
208
|
+
...opts.fetch ? { fetch: opts.fetch } : {}
|
|
183
209
|
},
|
|
184
210
|
stdio: void 0,
|
|
211
|
+
...localMcpToolFilter(opts.toolFilter),
|
|
212
|
+
...localMcpBeforeCall(opts.beforeCall),
|
|
185
213
|
...toolGrouping(opts)
|
|
186
214
|
};
|
|
187
215
|
}
|
|
@@ -196,6 +224,8 @@ function defineLocalMcp(opts) {
|
|
|
196
224
|
...opts.env ? { env: { ...opts.env } } : {},
|
|
197
225
|
...opts.cwd ? { cwd: opts.cwd } : {}
|
|
198
226
|
},
|
|
227
|
+
...localMcpToolFilter(opts.toolFilter),
|
|
228
|
+
...localMcpBeforeCall(opts.beforeCall),
|
|
199
229
|
...toolGrouping(opts)
|
|
200
230
|
};
|
|
201
231
|
}
|
|
@@ -534,7 +564,8 @@ async function resolveMcp(t) {
|
|
|
534
564
|
if (t.http) {
|
|
535
565
|
const { StreamableHTTPClientTransport } = await import("@modelcontextprotocol/sdk/client/streamableHttp.js");
|
|
536
566
|
const httpTransport = new StreamableHTTPClientTransport(new URL(t.http.url), {
|
|
537
|
-
requestInit: t.http.headers ? { headers: t.http.headers } : {}
|
|
567
|
+
requestInit: t.http.headers ? { headers: t.http.headers } : {},
|
|
568
|
+
...t.http.fetch ? { fetch: t.http.fetch } : {}
|
|
538
569
|
});
|
|
539
570
|
transport = httpTransport;
|
|
540
571
|
connect = (c) => c.connect(httpTransport);
|
|
@@ -562,18 +593,12 @@ async function resolveMcp(t) {
|
|
|
562
593
|
{ cause: err }
|
|
563
594
|
);
|
|
564
595
|
}
|
|
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
596
|
const close = async () => {
|
|
597
|
+
try {
|
|
598
|
+
const t2 = transport;
|
|
599
|
+
if (t2.terminateSession) await t2.terminateSession();
|
|
600
|
+
} catch {
|
|
601
|
+
}
|
|
577
602
|
try {
|
|
578
603
|
await client.close();
|
|
579
604
|
} catch {
|
|
@@ -584,6 +609,24 @@ async function resolveMcp(t) {
|
|
|
584
609
|
} catch {
|
|
585
610
|
}
|
|
586
611
|
};
|
|
612
|
+
const serverInfo = client.getServerVersion() ?? { name: t.name };
|
|
613
|
+
let listed;
|
|
614
|
+
try {
|
|
615
|
+
listed = await client.listTools();
|
|
616
|
+
} catch (err) {
|
|
617
|
+
await close();
|
|
618
|
+
throw err;
|
|
619
|
+
}
|
|
620
|
+
const allowed = t.toolFilter ? new Set(t.toolFilter) : void 0;
|
|
621
|
+
const tools = listed.tools.filter((tool) => !allowed || allowed.has(tool.name)).map((tool) => {
|
|
622
|
+
const out = {
|
|
623
|
+
name: tool.name,
|
|
624
|
+
inputSchema: tool.inputSchema
|
|
625
|
+
};
|
|
626
|
+
if (typeof tool.description === "string") out.description = tool.description;
|
|
627
|
+
if (tool.annotations) out.annotations = tool.annotations;
|
|
628
|
+
return out;
|
|
629
|
+
});
|
|
587
630
|
t._resolved = {
|
|
588
631
|
serverInfo,
|
|
589
632
|
tools,
|
|
@@ -592,6 +635,20 @@ async function resolveMcp(t) {
|
|
|
592
635
|
};
|
|
593
636
|
return true;
|
|
594
637
|
}
|
|
638
|
+
async function mcpCallRefusal(server, toolName, args) {
|
|
639
|
+
if (server.toolFilter && !server.toolFilter.includes(toolName)) {
|
|
640
|
+
return `MCP tool ${JSON.stringify(toolName)} is not in the toolFilter of defineLocalMcp(${JSON.stringify(server.name)})`;
|
|
641
|
+
}
|
|
642
|
+
if (!server.beforeCall) return void 0;
|
|
643
|
+
const out = await server.beforeCall(toolName, structuredClone(args));
|
|
644
|
+
if (out === void 0 || out === null) return void 0;
|
|
645
|
+
if (typeof out !== "string") {
|
|
646
|
+
throw new Error(
|
|
647
|
+
`defineLocalMcp(${JSON.stringify(server.name)}): beforeCall must return a string, undefined or null`
|
|
648
|
+
);
|
|
649
|
+
}
|
|
650
|
+
return out || `defineLocalMcp(${JSON.stringify(server.name)}): beforeCall refused the call`;
|
|
651
|
+
}
|
|
595
652
|
async function closeMcpRefs(tools) {
|
|
596
653
|
if (!tools || tools.length === 0) return;
|
|
597
654
|
const closes = [];
|
|
@@ -688,6 +745,11 @@ async function callMcpTool(server, toolName, args) {
|
|
|
688
745
|
`defineLocalMcp(${JSON.stringify(server.name)}): MCP server has not been initialised`
|
|
689
746
|
);
|
|
690
747
|
}
|
|
748
|
+
if (server.toolFilter && !server.toolFilter.includes(toolName)) {
|
|
749
|
+
throw new Error(
|
|
750
|
+
`MCP tool ${JSON.stringify(toolName)} is not in the toolFilter of defineLocalMcp(${JSON.stringify(server.name)})`
|
|
751
|
+
);
|
|
752
|
+
}
|
|
691
753
|
const result = await resolved.client.callTool({ name: toolName, arguments: args });
|
|
692
754
|
if (result.isError) {
|
|
693
755
|
const text = textFromMcpContent(result.content) || "MCP tool reported an error";
|
|
@@ -1068,6 +1130,11 @@ var MantyxClient = class {
|
|
|
1068
1130
|
return;
|
|
1069
1131
|
}
|
|
1070
1132
|
const upstreamName = mcpToolName.startsWith(`${serverName}_`) ? mcpToolName.slice(serverName.length + 1) : mcpToolName;
|
|
1133
|
+
const refusal = await mcpCallRefusal(server, upstreamName, ev.args ?? {});
|
|
1134
|
+
if (refusal !== void 0) {
|
|
1135
|
+
await this.postToolResult(runId, ev.toolUseId, { error: refusal });
|
|
1136
|
+
return;
|
|
1137
|
+
}
|
|
1071
1138
|
out = await callMcpTool(server, upstreamName, ev.args ?? {});
|
|
1072
1139
|
} else {
|
|
1073
1140
|
const handler = handlers.localTools.get(ev.name);
|
package/dist/index.cjs
CHANGED
|
@@ -229,8 +229,30 @@ 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
|
+
}
|
|
244
|
+
function localMcpBeforeCall(beforeCall) {
|
|
245
|
+
if (beforeCall === void 0) return {};
|
|
246
|
+
if (typeof beforeCall !== "function") {
|
|
247
|
+
throw new Error("defineLocalMcp: beforeCall must be a function");
|
|
248
|
+
}
|
|
249
|
+
return { beforeCall };
|
|
250
|
+
}
|
|
232
251
|
function defineLocalMcp(opts) {
|
|
233
252
|
assertToolName(opts.name);
|
|
253
|
+
if (opts.fetch !== void 0 && typeof opts.fetch !== "function") {
|
|
254
|
+
throw new Error("defineLocalMcp: fetch must be a function");
|
|
255
|
+
}
|
|
234
256
|
const hasHttp = typeof opts.url === "string" && opts.url.length > 0;
|
|
235
257
|
const hasStdio = typeof opts.command === "string" && opts.command.length > 0;
|
|
236
258
|
if (hasHttp && hasStdio) {
|
|
@@ -243,6 +265,9 @@ function defineLocalMcp(opts) {
|
|
|
243
265
|
"defineLocalMcp: one of `url` (Streamable HTTP) or `command` (stdio) is required"
|
|
244
266
|
);
|
|
245
267
|
}
|
|
268
|
+
if (opts.fetch !== void 0 && !hasHttp) {
|
|
269
|
+
throw new Error("defineLocalMcp: `fetch` applies to the Streamable HTTP transport only");
|
|
270
|
+
}
|
|
246
271
|
if (hasHttp) {
|
|
247
272
|
const url = opts.url;
|
|
248
273
|
return {
|
|
@@ -250,9 +275,12 @@ function defineLocalMcp(opts) {
|
|
|
250
275
|
name: opts.name,
|
|
251
276
|
http: {
|
|
252
277
|
url,
|
|
253
|
-
...opts.headers ? { headers: { ...opts.headers } } : {}
|
|
278
|
+
...opts.headers ? { headers: { ...opts.headers } } : {},
|
|
279
|
+
...opts.fetch ? { fetch: opts.fetch } : {}
|
|
254
280
|
},
|
|
255
281
|
stdio: void 0,
|
|
282
|
+
...localMcpToolFilter(opts.toolFilter),
|
|
283
|
+
...localMcpBeforeCall(opts.beforeCall),
|
|
256
284
|
...toolGrouping(opts)
|
|
257
285
|
};
|
|
258
286
|
}
|
|
@@ -267,6 +295,8 @@ function defineLocalMcp(opts) {
|
|
|
267
295
|
...opts.env ? { env: { ...opts.env } } : {},
|
|
268
296
|
...opts.cwd ? { cwd: opts.cwd } : {}
|
|
269
297
|
},
|
|
298
|
+
...localMcpToolFilter(opts.toolFilter),
|
|
299
|
+
...localMcpBeforeCall(opts.beforeCall),
|
|
270
300
|
...toolGrouping(opts)
|
|
271
301
|
};
|
|
272
302
|
}
|
|
@@ -390,7 +420,8 @@ async function resolveMcp(t) {
|
|
|
390
420
|
if (t.http) {
|
|
391
421
|
const { StreamableHTTPClientTransport } = await import("@modelcontextprotocol/sdk/client/streamableHttp.js");
|
|
392
422
|
const httpTransport = new StreamableHTTPClientTransport(new URL(t.http.url), {
|
|
393
|
-
requestInit: t.http.headers ? { headers: t.http.headers } : {}
|
|
423
|
+
requestInit: t.http.headers ? { headers: t.http.headers } : {},
|
|
424
|
+
...t.http.fetch ? { fetch: t.http.fetch } : {}
|
|
394
425
|
});
|
|
395
426
|
transport = httpTransport;
|
|
396
427
|
connect = (c) => c.connect(httpTransport);
|
|
@@ -418,18 +449,12 @@ async function resolveMcp(t) {
|
|
|
418
449
|
{ cause: err }
|
|
419
450
|
);
|
|
420
451
|
}
|
|
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
452
|
const close = async () => {
|
|
453
|
+
try {
|
|
454
|
+
const t2 = transport;
|
|
455
|
+
if (t2.terminateSession) await t2.terminateSession();
|
|
456
|
+
} catch {
|
|
457
|
+
}
|
|
433
458
|
try {
|
|
434
459
|
await client.close();
|
|
435
460
|
} catch {
|
|
@@ -440,6 +465,24 @@ async function resolveMcp(t) {
|
|
|
440
465
|
} catch {
|
|
441
466
|
}
|
|
442
467
|
};
|
|
468
|
+
const serverInfo = client.getServerVersion() ?? { name: t.name };
|
|
469
|
+
let listed;
|
|
470
|
+
try {
|
|
471
|
+
listed = await client.listTools();
|
|
472
|
+
} catch (err) {
|
|
473
|
+
await close();
|
|
474
|
+
throw err;
|
|
475
|
+
}
|
|
476
|
+
const allowed = t.toolFilter ? new Set(t.toolFilter) : void 0;
|
|
477
|
+
const tools = listed.tools.filter((tool) => !allowed || allowed.has(tool.name)).map((tool) => {
|
|
478
|
+
const out = {
|
|
479
|
+
name: tool.name,
|
|
480
|
+
inputSchema: tool.inputSchema
|
|
481
|
+
};
|
|
482
|
+
if (typeof tool.description === "string") out.description = tool.description;
|
|
483
|
+
if (tool.annotations) out.annotations = tool.annotations;
|
|
484
|
+
return out;
|
|
485
|
+
});
|
|
443
486
|
t._resolved = {
|
|
444
487
|
serverInfo,
|
|
445
488
|
tools,
|
|
@@ -448,6 +491,20 @@ async function resolveMcp(t) {
|
|
|
448
491
|
};
|
|
449
492
|
return true;
|
|
450
493
|
}
|
|
494
|
+
async function mcpCallRefusal(server, toolName, args) {
|
|
495
|
+
if (server.toolFilter && !server.toolFilter.includes(toolName)) {
|
|
496
|
+
return `MCP tool ${JSON.stringify(toolName)} is not in the toolFilter of defineLocalMcp(${JSON.stringify(server.name)})`;
|
|
497
|
+
}
|
|
498
|
+
if (!server.beforeCall) return void 0;
|
|
499
|
+
const out = await server.beforeCall(toolName, structuredClone(args));
|
|
500
|
+
if (out === void 0 || out === null) return void 0;
|
|
501
|
+
if (typeof out !== "string") {
|
|
502
|
+
throw new Error(
|
|
503
|
+
`defineLocalMcp(${JSON.stringify(server.name)}): beforeCall must return a string, undefined or null`
|
|
504
|
+
);
|
|
505
|
+
}
|
|
506
|
+
return out || `defineLocalMcp(${JSON.stringify(server.name)}): beforeCall refused the call`;
|
|
507
|
+
}
|
|
451
508
|
async function closeMcpRefs(tools) {
|
|
452
509
|
if (!tools || tools.length === 0) return;
|
|
453
510
|
const closes = [];
|
|
@@ -544,6 +601,11 @@ async function callMcpTool(server, toolName, args) {
|
|
|
544
601
|
`defineLocalMcp(${JSON.stringify(server.name)}): MCP server has not been initialised`
|
|
545
602
|
);
|
|
546
603
|
}
|
|
604
|
+
if (server.toolFilter && !server.toolFilter.includes(toolName)) {
|
|
605
|
+
throw new Error(
|
|
606
|
+
`MCP tool ${JSON.stringify(toolName)} is not in the toolFilter of defineLocalMcp(${JSON.stringify(server.name)})`
|
|
607
|
+
);
|
|
608
|
+
}
|
|
547
609
|
const result = await resolved.client.callTool({ name: toolName, arguments: args });
|
|
548
610
|
if (result.isError) {
|
|
549
611
|
const text = textFromMcpContent(result.content) || "MCP tool reported an error";
|
|
@@ -1139,6 +1201,11 @@ var MantyxClient = class {
|
|
|
1139
1201
|
return;
|
|
1140
1202
|
}
|
|
1141
1203
|
const upstreamName = mcpToolName.startsWith(`${serverName}_`) ? mcpToolName.slice(serverName.length + 1) : mcpToolName;
|
|
1204
|
+
const refusal = await mcpCallRefusal(server, upstreamName, ev.args ?? {});
|
|
1205
|
+
if (refusal !== void 0) {
|
|
1206
|
+
await this.postToolResult(runId, ev.toolUseId, { error: refusal });
|
|
1207
|
+
return;
|
|
1208
|
+
}
|
|
1142
1209
|
out = await callMcpTool(server, upstreamName, ev.args ?? {});
|
|
1143
1210
|
} else {
|
|
1144
1211
|
const handler = handlers.localTools.get(ev.name);
|
|
@@ -2847,7 +2914,7 @@ async function runComputerUse(opts) {
|
|
|
2847
2914
|
}
|
|
2848
2915
|
|
|
2849
2916
|
// src/version.ts
|
|
2850
|
-
var SDK_VERSION = "2026.11.
|
|
2917
|
+
var SDK_VERSION = "2026.11.15";
|
|
2851
2918
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2852
2919
|
0 && (module.exports = {
|
|
2853
2920
|
AgentSession,
|
package/dist/index.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export type { DecisionContent, DecisionQuestion, DecisionRequest, DecisionAnswer
|
|
|
37
37
|
export { MantyxClient, AgentSession, DEFAULT_BASE_URL, parseRunOutput, taskPlanFromEventData, inputFileAttachment, inputFileUrlAttachment, } from "./client.js";
|
|
38
38
|
export type { MantyxClientOptions, ModelInfo, ModelCatalog, AgentSpecBase, RunSpec, SessionSpec, ToolNamespace, OutputSchema, OutputSchemaValue, LoopDetection, ToolBudget, ToolBudgets, Supervisor, SupervisorAction, SupervisorPhase, ReasoningTrigger, Subagents, SubagentSelf, SubagentDefinition, SubagentStatus, PlanOptions, PlanMode, PlanSpec, TaskPlan, TaskPlanStep, TaskPlanStepStatus, TaskPlanTransition, RunResult, RunTokenUsage, RunModelInfo, RunEvent, RunEventBase, AssistantDeltaEvent, ThinkingDeltaEvent, AssistantMessageEvent, ModelFallbackEvent, UserMessageEvent, InputFileAttachment, InputFileUrlAttachment, MessageAttachment, InputFileAttachmentMetadata, InputFileUrlAttachmentMetadata, AttachmentMetadata, ConversationMessage, ToolInteraction, ServerToolResultEvent, LocalToolCallEvent, LocalToolResultInEvent, LoopDetectedEvent, ToolBudgetExceededEvent, SupervisorEvent, SubagentStartedEvent, SubagentResultEvent, TaskPlanEvent, ResultEvent, ErrorEvent, CancelledEvent, SessionInfo, SessionSummary, SessionListResult, SessionEventsPage, RunStatus, RunInfo, RunSummary, RunListResult, ListRunsOptions, LocalHandlers, RunFeedbackVerdict, TurnInstructionsAuthority, RunFeedbackInput, RunFeedbackResult, } from "./client.js";
|
|
39
39
|
export { defineLocalTool, mantyxA2A, defineLocalA2A, mantyxMcp, defineLocalMcp, isLocalTool, isLocalA2ATool, isLocalMcpServer, } from "./tools.js";
|
|
40
|
-
export type { LocalTool, LocalToolResult, LocalToolOutput, ToolResultFile, ToolRef, ZodLikeObject, DefineLocalToolOptions, ReasoningLevel, A2AToolRef, LocalA2ATool, McpToolRef, LocalMcpServer, LocalMcpHttpTransport, LocalMcpStdioTransport, MantyxA2AOptions, DefineLocalA2AOptions, MantyxMcpOptions, DefineLocalMcpOptions, ToolGrouping, ToolGroupingOptions, } from "./tools.js";
|
|
40
|
+
export type { LocalTool, LocalToolResult, LocalToolOutput, ToolResultFile, ToolRef, ZodLikeObject, DefineLocalToolOptions, ReasoningLevel, A2AToolRef, LocalA2ATool, McpToolRef, LocalMcpServer, LocalMcpHttpTransport, LocalMcpStdioTransport, McpBeforeCall, McpFetch, MantyxA2AOptions, DefineLocalA2AOptions, MantyxMcpOptions, DefineLocalMcpOptions, ToolGrouping, ToolGroupingOptions, } from "./tools.js";
|
|
41
41
|
export { MantyxError, MantyxAuthError, MantyxNetworkError, MantyxParseError, MantyxScopeError, MantyxToolError, MantyxRunError, } from "./errors.js";
|
|
42
42
|
export type { MantyxRunErrorInit, MantyxRunErrorTokens, MantyxRunErrorModel, } from "./errors.js";
|
|
43
43
|
export type { OutputSchemaEnforcement, StructuredOutputEnforcementMechanism, StructuredOutputInfo, } from "./structured-output.js";
|
package/dist/index.js
CHANGED
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
taskPlanFromEventData,
|
|
25
25
|
toToolParametersWire,
|
|
26
26
|
zodToJsonSchema
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-FWRGNJUW.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.
|
|
604
|
+
var SDK_VERSION = "2026.11.15";
|
|
605
605
|
export {
|
|
606
606
|
AgentSession,
|
|
607
607
|
COMPUTER_USE_ACTIONS,
|
package/dist/local-resolver.d.ts
CHANGED
|
@@ -24,6 +24,12 @@ export declare function resolveLocalRefs(tools: ReadonlyArray<ToolRef> | undefin
|
|
|
24
24
|
/** MCP servers opened in *this* call — the run driver closes these on completion. */
|
|
25
25
|
newlyOpenedMcp: LocalMcpServer[];
|
|
26
26
|
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Why a `tools/call` must not be sent (the {@link LocalMcpServer.toolFilter},
|
|
29
|
+
* then the user's `beforeCall` hook), or `undefined` to send it. A returned
|
|
30
|
+
* string goes back to the model as the tool's error.
|
|
31
|
+
*/
|
|
32
|
+
export declare function mcpCallRefusal(server: LocalMcpServer, toolName: string, args: Record<string, unknown>): Promise<string | undefined>;
|
|
27
33
|
/**
|
|
28
34
|
* Close every MCP transport on the given refs (best-effort, idempotent).
|
|
29
35
|
* Safe to call multiple times — the resolved cache is cleared after the
|
package/dist/tools.d.ts
CHANGED
|
@@ -300,7 +300,19 @@ export interface LocalMcpHttpTransport {
|
|
|
300
300
|
url: string;
|
|
301
301
|
/** HTTP headers sent on every MCP request (typically `Authorization`). */
|
|
302
302
|
headers?: Record<string, string>;
|
|
303
|
+
/** `fetch` used for every MCP request; see {@link DefineLocalMcpOptions.fetch}. */
|
|
304
|
+
fetch?: McpFetch;
|
|
303
305
|
}
|
|
306
|
+
/** `fetch`-compatible function the local MCP HTTP transport sends requests with. */
|
|
307
|
+
export type McpFetch = (url: string | URL, init?: RequestInit) => Promise<Response>;
|
|
308
|
+
/**
|
|
309
|
+
* Hook run before every local MCP `tools/call`. Receives the tool name as
|
|
310
|
+
* the MCP server knows it (unprefixed) and a copy of the arguments. Return
|
|
311
|
+
* `undefined` / `null` to send the call, or a string to refuse it: the
|
|
312
|
+
* string goes back to the model as the tool's error and the server is
|
|
313
|
+
* never called.
|
|
314
|
+
*/
|
|
315
|
+
export type McpBeforeCall = (toolName: string, args: Record<string, unknown>) => string | null | undefined | Promise<string | null | undefined>;
|
|
304
316
|
/**
|
|
305
317
|
* stdio transport spec for {@link defineLocalMcp}. The SDK spawns the
|
|
306
318
|
* specified executable with the given arguments and speaks JSON-RPC over
|
|
@@ -337,6 +349,14 @@ export interface LocalMcpServer extends ToolGrouping {
|
|
|
337
349
|
readonly http: LocalMcpHttpTransport | undefined;
|
|
338
350
|
/** One-of with {@link http} — the transport spec is mutually exclusive. */
|
|
339
351
|
readonly stdio: LocalMcpStdioTransport | undefined;
|
|
352
|
+
/**
|
|
353
|
+
* Upstream (unprefixed) MCP tool names the model may use. Unlisted tools
|
|
354
|
+
* are left out of the catalog shipped in the spec, and a call to one is
|
|
355
|
+
* refused without reaching the server. Unset exposes every tool.
|
|
356
|
+
*/
|
|
357
|
+
readonly toolFilter?: string[];
|
|
358
|
+
/** Client-only hook run before every `tools/call` (never sent to MANTYX). */
|
|
359
|
+
readonly beforeCall?: McpBeforeCall;
|
|
340
360
|
/**
|
|
341
361
|
* Internal cache of the resolved MCP client + catalog. Populated lazily
|
|
342
362
|
* by the run driver on the first run; not part of the user contract.
|
|
@@ -413,6 +433,31 @@ export interface DefineLocalMcpOptions extends ToolGroupingOptions {
|
|
|
413
433
|
env?: Record<string, string>;
|
|
414
434
|
/** Working directory for the stdio child process. */
|
|
415
435
|
cwd?: string;
|
|
436
|
+
/**
|
|
437
|
+
* Optional allowlist of upstream (unprefixed) MCP tool names, as in
|
|
438
|
+
* {@link mantyxMcp}. Unlisted tools are left out of the catalog the model
|
|
439
|
+
* sees, and the SDK refuses to forward a call to one. Applied in the
|
|
440
|
+
* client only: `toolFilter: ["run_query"]` keeps a server's write tools
|
|
441
|
+
* away from the model.
|
|
442
|
+
*/
|
|
443
|
+
toolFilter?: string[];
|
|
444
|
+
/**
|
|
445
|
+
* Runs before every `tools/call`, after {@link toolFilter}, with the tool
|
|
446
|
+
* name as the MCP server knows it (unprefixed) and a copy of the model's
|
|
447
|
+
* arguments. Return `undefined` / `null` to send the call, or a string to
|
|
448
|
+
* refuse it: the string goes back to the model as the tool's error and
|
|
449
|
+
* the server is never called. A thrown error is reported the same way.
|
|
450
|
+
* May be async. Stays in your process.
|
|
451
|
+
*/
|
|
452
|
+
beforeCall?: McpBeforeCall;
|
|
453
|
+
/**
|
|
454
|
+
* HTTP transport only: the `fetch` the MCP transport sends every request
|
|
455
|
+
* with (the `tools/call` POSTs, the SSE GET and the closing DELETE). Wrap
|
|
456
|
+
* the global `fetch` to sign each request, for example with AWS SigV4
|
|
457
|
+
* over method, URL, body and timestamp. Static {@link headers} are
|
|
458
|
+
* already set on `init.headers` when it is called. Stays in your process.
|
|
459
|
+
*/
|
|
460
|
+
fetch?: McpFetch;
|
|
416
461
|
}
|
|
417
462
|
export declare function defineLocalMcp(opts: DefineLocalMcpOptions): LocalMcpServer;
|
|
418
463
|
export type ToolRef = LocalTool | A2AToolRef | LocalA2ATool | McpToolRef | LocalMcpServer;
|
package/dist/version.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mantyx/sdk",
|
|
3
|
-
"version": "2026.11.
|
|
3
|
+
"version": "2026.11.15",
|
|
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",
|