mcp-use 1.4.0-canary.3 → 1.4.1-canary.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/.tsbuildinfo +1 -1
- package/dist/index.cjs +97 -10
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +97 -9
- package/dist/src/client/codeExecutor.d.ts +1 -1
- package/dist/src/client/codeExecutor.d.ts.map +1 -1
- package/dist/src/client/executors/vm.d.ts +9 -0
- package/dist/src/client/executors/vm.d.ts.map +1 -1
- package/dist/src/client.d.ts +2 -2
- package/dist/src/client.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -919,9 +919,11 @@ __export(index_exports, {
|
|
|
919
919
|
AcquireActiveMCPServerTool: () => AcquireActiveMCPServerTool,
|
|
920
920
|
AddMCPServerFromConfigTool: () => AddMCPServerFromConfigTool,
|
|
921
921
|
BaseAdapter: () => BaseAdapter,
|
|
922
|
+
BaseCodeExecutor: () => BaseCodeExecutor,
|
|
922
923
|
BaseConnector: () => BaseConnector,
|
|
923
924
|
BrowserOAuthClientProvider: () => BrowserOAuthClientProvider,
|
|
924
925
|
ConnectMCPServerTool: () => ConnectMCPServerTool,
|
|
926
|
+
E2BCodeExecutor: () => E2BCodeExecutor,
|
|
925
927
|
HttpConnector: () => HttpConnector,
|
|
926
928
|
LINEAR_OAUTH_CONFIG: () => LINEAR_OAUTH_CONFIG,
|
|
927
929
|
LangChainAdapter: () => LangChainAdapter,
|
|
@@ -938,11 +940,13 @@ __export(index_exports, {
|
|
|
938
940
|
ServerManager: () => ServerManager,
|
|
939
941
|
StdioConnector: () => StdioConnector,
|
|
940
942
|
Telemetry: () => Telemetry,
|
|
943
|
+
VMCodeExecutor: () => VMCodeExecutor,
|
|
941
944
|
WebSocketConnector: () => WebSocketConnector,
|
|
942
945
|
WidgetDebugger: () => WidgetDebugger,
|
|
943
946
|
WidgetFullscreenWrapper: () => WidgetFullscreenWrapper,
|
|
944
947
|
createOAuthMCPConfig: () => createOAuthMCPConfig,
|
|
945
948
|
createReadableStreamFromGenerator: () => createReadableStreamFromGenerator,
|
|
949
|
+
isVMAvailable: () => isVMAvailable,
|
|
946
950
|
loadConfigFile: () => loadConfigFile,
|
|
947
951
|
logger: () => logger,
|
|
948
952
|
onMcpAuthorization: () => onMcpAuthorization,
|
|
@@ -4345,8 +4349,51 @@ ${shim}
|
|
|
4345
4349
|
};
|
|
4346
4350
|
|
|
4347
4351
|
// src/client/executors/vm.ts
|
|
4348
|
-
var import_node_vm = __toESM(require("vm"), 1);
|
|
4349
4352
|
init_logging();
|
|
4353
|
+
var vm = null;
|
|
4354
|
+
var vmCheckAttempted = false;
|
|
4355
|
+
function tryLoadVM() {
|
|
4356
|
+
if (vmCheckAttempted) {
|
|
4357
|
+
return vm !== null;
|
|
4358
|
+
}
|
|
4359
|
+
vmCheckAttempted = true;
|
|
4360
|
+
try {
|
|
4361
|
+
const nodeRequire = typeof require !== "undefined" ? require : null;
|
|
4362
|
+
if (nodeRequire) {
|
|
4363
|
+
vm = nodeRequire("node:vm");
|
|
4364
|
+
return true;
|
|
4365
|
+
}
|
|
4366
|
+
} catch (error) {
|
|
4367
|
+
logger.debug("node:vm module not available via require");
|
|
4368
|
+
}
|
|
4369
|
+
return false;
|
|
4370
|
+
}
|
|
4371
|
+
__name(tryLoadVM, "tryLoadVM");
|
|
4372
|
+
async function tryLoadVMAsync() {
|
|
4373
|
+
if (vm !== null) {
|
|
4374
|
+
return true;
|
|
4375
|
+
}
|
|
4376
|
+
if (!vmCheckAttempted) {
|
|
4377
|
+
if (tryLoadVM()) {
|
|
4378
|
+
return true;
|
|
4379
|
+
}
|
|
4380
|
+
}
|
|
4381
|
+
try {
|
|
4382
|
+
vm = await import("vm");
|
|
4383
|
+
return true;
|
|
4384
|
+
} catch (error) {
|
|
4385
|
+
logger.debug(
|
|
4386
|
+
"node:vm module not available in this environment (e.g., Deno)"
|
|
4387
|
+
);
|
|
4388
|
+
return false;
|
|
4389
|
+
}
|
|
4390
|
+
}
|
|
4391
|
+
__name(tryLoadVMAsync, "tryLoadVMAsync");
|
|
4392
|
+
function isVMAvailable() {
|
|
4393
|
+
tryLoadVM();
|
|
4394
|
+
return vm !== null;
|
|
4395
|
+
}
|
|
4396
|
+
__name(isVMAvailable, "isVMAvailable");
|
|
4350
4397
|
var VMCodeExecutor = class extends BaseCodeExecutor {
|
|
4351
4398
|
static {
|
|
4352
4399
|
__name(this, "VMCodeExecutor");
|
|
@@ -4357,6 +4404,21 @@ var VMCodeExecutor = class extends BaseCodeExecutor {
|
|
|
4357
4404
|
super(client);
|
|
4358
4405
|
this.defaultTimeout = options?.timeoutMs ?? 3e4;
|
|
4359
4406
|
this.memoryLimitMb = options?.memoryLimitMb;
|
|
4407
|
+
tryLoadVM();
|
|
4408
|
+
}
|
|
4409
|
+
/**
|
|
4410
|
+
* Ensure VM module is loaded before execution
|
|
4411
|
+
*/
|
|
4412
|
+
async ensureVMLoaded() {
|
|
4413
|
+
if (vm !== null) {
|
|
4414
|
+
return;
|
|
4415
|
+
}
|
|
4416
|
+
const loaded = await tryLoadVMAsync();
|
|
4417
|
+
if (!loaded) {
|
|
4418
|
+
throw new Error(
|
|
4419
|
+
"node:vm module is not available in this environment. Please use E2B executor instead or run in a Node.js environment."
|
|
4420
|
+
);
|
|
4421
|
+
}
|
|
4360
4422
|
}
|
|
4361
4423
|
/**
|
|
4362
4424
|
* Execute JavaScript/TypeScript code with access to MCP tools.
|
|
@@ -4366,6 +4428,7 @@ var VMCodeExecutor = class extends BaseCodeExecutor {
|
|
|
4366
4428
|
*/
|
|
4367
4429
|
async execute(code, timeout) {
|
|
4368
4430
|
const effectiveTimeout = timeout ?? this.defaultTimeout;
|
|
4431
|
+
await this.ensureVMLoaded();
|
|
4369
4432
|
await this.ensureServersConnected();
|
|
4370
4433
|
const logs = [];
|
|
4371
4434
|
const startTime = Date.now();
|
|
@@ -4382,7 +4445,7 @@ var VMCodeExecutor = class extends BaseCodeExecutor {
|
|
|
4382
4445
|
}
|
|
4383
4446
|
})()
|
|
4384
4447
|
`;
|
|
4385
|
-
const script = new
|
|
4448
|
+
const script = new vm.Script(wrappedCode, {
|
|
4386
4449
|
filename: "agent_code.js"
|
|
4387
4450
|
});
|
|
4388
4451
|
const promise = script.runInNewContext(context, {
|
|
@@ -4485,7 +4548,7 @@ var VMCodeExecutor = class extends BaseCodeExecutor {
|
|
|
4485
4548
|
toolNamespaces[serverName] = true;
|
|
4486
4549
|
}
|
|
4487
4550
|
sandbox.__tool_namespaces = Object.keys(toolNamespaces);
|
|
4488
|
-
return
|
|
4551
|
+
return vm.createContext(sandbox);
|
|
4489
4552
|
}
|
|
4490
4553
|
/**
|
|
4491
4554
|
* Clean up resources.
|
|
@@ -5828,18 +5891,42 @@ var MCPClient = class _MCPClient extends BaseMCPClient {
|
|
|
5828
5891
|
const opts = this._executorOptions;
|
|
5829
5892
|
if (!opts?.apiKey) {
|
|
5830
5893
|
logger.warn("E2B executor requires apiKey. Falling back to VM.");
|
|
5894
|
+
try {
|
|
5895
|
+
this._codeExecutor = new VMCodeExecutor(
|
|
5896
|
+
this,
|
|
5897
|
+
this._executorOptions
|
|
5898
|
+
);
|
|
5899
|
+
} catch (error) {
|
|
5900
|
+
throw new Error(
|
|
5901
|
+
"VM executor is not available in this environment and E2B API key is not provided. Please provide an E2B API key or run in a Node.js environment."
|
|
5902
|
+
);
|
|
5903
|
+
}
|
|
5904
|
+
} else {
|
|
5905
|
+
this._codeExecutor = new E2BCodeExecutor(this, opts);
|
|
5906
|
+
}
|
|
5907
|
+
} else {
|
|
5908
|
+
try {
|
|
5831
5909
|
this._codeExecutor = new VMCodeExecutor(
|
|
5832
5910
|
this,
|
|
5833
5911
|
this._executorOptions
|
|
5834
5912
|
);
|
|
5835
|
-
}
|
|
5836
|
-
|
|
5913
|
+
} catch (error) {
|
|
5914
|
+
const e2bOpts = this._executorOptions;
|
|
5915
|
+
const e2bApiKey = e2bOpts?.apiKey || process.env.E2B_API_KEY;
|
|
5916
|
+
if (e2bApiKey) {
|
|
5917
|
+
logger.info(
|
|
5918
|
+
"VM executor not available in this environment. Falling back to E2B."
|
|
5919
|
+
);
|
|
5920
|
+
this._codeExecutor = new E2BCodeExecutor(this, {
|
|
5921
|
+
...e2bOpts,
|
|
5922
|
+
apiKey: e2bApiKey
|
|
5923
|
+
});
|
|
5924
|
+
} else {
|
|
5925
|
+
throw new Error(
|
|
5926
|
+
"VM executor is not available in this environment. Please provide an E2B API key via executorOptions or E2B_API_KEY environment variable, or run in a Node.js environment."
|
|
5927
|
+
);
|
|
5928
|
+
}
|
|
5837
5929
|
}
|
|
5838
|
-
} else {
|
|
5839
|
-
this._codeExecutor = new VMCodeExecutor(
|
|
5840
|
-
this,
|
|
5841
|
-
this._executorOptions
|
|
5842
|
-
);
|
|
5843
5930
|
}
|
|
5844
5931
|
}
|
|
5845
5932
|
return this._codeExecutor;
|
package/dist/index.d.ts
CHANGED
|
@@ -32,4 +32,6 @@ export * from "./src/react/index.js";
|
|
|
32
32
|
export { PROMPTS } from "./src/agents/index.js";
|
|
33
33
|
export { BaseConnector, HttpConnector, loadConfigFile, Logger, logger, MCPAgent, MCPClient, MCPSession, RemoteAgent, StdioConnector, WebSocketConnector, };
|
|
34
34
|
export type { CodeModeConfig, E2BExecutorOptions, ExecutorOptions, MCPClientOptions, VMExecutorOptions, } from "./src/client.js";
|
|
35
|
+
export { BaseCodeExecutor, E2BCodeExecutor, VMCodeExecutor, isVMAvailable, } from "./src/client.js";
|
|
36
|
+
export type { ExecutionResult, SearchToolsFunction, ToolNamespaceInfo, ToolSearchResult, } from "./src/client/codeExecutor.js";
|
|
35
37
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,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AAC/B,YAAY,EACV,kBAAkB,EAClB,WAAW,EACX,cAAc,EACd,WAAW,EACX,UAAU,GACX,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGvD,cAAc,sBAAsB,CAAC;AAGrC,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAQhD,OAAO,EACL,aAAa,EACb,aAAa,EACb,cAAc,EACd,MAAM,EACN,MAAM,EACN,QAAQ,EACR,SAAS,EACT,UAAU,EACV,WAAW,EACX,cAAc,EACd,kBAAkB,GACnB,CAAC;AAGF,YAAY,EACV,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,aAAa,GACd,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EACV,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,8BAA8B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -50,7 +50,8 @@ import {
|
|
|
50
50
|
logger
|
|
51
51
|
} from "./chunk-34R6SIER.js";
|
|
52
52
|
import {
|
|
53
|
-
__name
|
|
53
|
+
__name,
|
|
54
|
+
__require
|
|
54
55
|
} from "./chunk-3GQAWCBQ.js";
|
|
55
56
|
|
|
56
57
|
// src/client.ts
|
|
@@ -460,7 +461,50 @@ ${shim}
|
|
|
460
461
|
};
|
|
461
462
|
|
|
462
463
|
// src/client/executors/vm.ts
|
|
463
|
-
|
|
464
|
+
var vm = null;
|
|
465
|
+
var vmCheckAttempted = false;
|
|
466
|
+
function tryLoadVM() {
|
|
467
|
+
if (vmCheckAttempted) {
|
|
468
|
+
return vm !== null;
|
|
469
|
+
}
|
|
470
|
+
vmCheckAttempted = true;
|
|
471
|
+
try {
|
|
472
|
+
const nodeRequire = typeof __require !== "undefined" ? __require : null;
|
|
473
|
+
if (nodeRequire) {
|
|
474
|
+
vm = nodeRequire("node:vm");
|
|
475
|
+
return true;
|
|
476
|
+
}
|
|
477
|
+
} catch (error) {
|
|
478
|
+
logger.debug("node:vm module not available via require");
|
|
479
|
+
}
|
|
480
|
+
return false;
|
|
481
|
+
}
|
|
482
|
+
__name(tryLoadVM, "tryLoadVM");
|
|
483
|
+
async function tryLoadVMAsync() {
|
|
484
|
+
if (vm !== null) {
|
|
485
|
+
return true;
|
|
486
|
+
}
|
|
487
|
+
if (!vmCheckAttempted) {
|
|
488
|
+
if (tryLoadVM()) {
|
|
489
|
+
return true;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
try {
|
|
493
|
+
vm = await import("vm");
|
|
494
|
+
return true;
|
|
495
|
+
} catch (error) {
|
|
496
|
+
logger.debug(
|
|
497
|
+
"node:vm module not available in this environment (e.g., Deno)"
|
|
498
|
+
);
|
|
499
|
+
return false;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
__name(tryLoadVMAsync, "tryLoadVMAsync");
|
|
503
|
+
function isVMAvailable() {
|
|
504
|
+
tryLoadVM();
|
|
505
|
+
return vm !== null;
|
|
506
|
+
}
|
|
507
|
+
__name(isVMAvailable, "isVMAvailable");
|
|
464
508
|
var VMCodeExecutor = class extends BaseCodeExecutor {
|
|
465
509
|
static {
|
|
466
510
|
__name(this, "VMCodeExecutor");
|
|
@@ -471,6 +515,21 @@ var VMCodeExecutor = class extends BaseCodeExecutor {
|
|
|
471
515
|
super(client);
|
|
472
516
|
this.defaultTimeout = options?.timeoutMs ?? 3e4;
|
|
473
517
|
this.memoryLimitMb = options?.memoryLimitMb;
|
|
518
|
+
tryLoadVM();
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Ensure VM module is loaded before execution
|
|
522
|
+
*/
|
|
523
|
+
async ensureVMLoaded() {
|
|
524
|
+
if (vm !== null) {
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
const loaded = await tryLoadVMAsync();
|
|
528
|
+
if (!loaded) {
|
|
529
|
+
throw new Error(
|
|
530
|
+
"node:vm module is not available in this environment. Please use E2B executor instead or run in a Node.js environment."
|
|
531
|
+
);
|
|
532
|
+
}
|
|
474
533
|
}
|
|
475
534
|
/**
|
|
476
535
|
* Execute JavaScript/TypeScript code with access to MCP tools.
|
|
@@ -480,6 +539,7 @@ var VMCodeExecutor = class extends BaseCodeExecutor {
|
|
|
480
539
|
*/
|
|
481
540
|
async execute(code, timeout) {
|
|
482
541
|
const effectiveTimeout = timeout ?? this.defaultTimeout;
|
|
542
|
+
await this.ensureVMLoaded();
|
|
483
543
|
await this.ensureServersConnected();
|
|
484
544
|
const logs = [];
|
|
485
545
|
const startTime = Date.now();
|
|
@@ -859,18 +919,42 @@ var MCPClient = class _MCPClient extends BaseMCPClient {
|
|
|
859
919
|
const opts = this._executorOptions;
|
|
860
920
|
if (!opts?.apiKey) {
|
|
861
921
|
logger.warn("E2B executor requires apiKey. Falling back to VM.");
|
|
922
|
+
try {
|
|
923
|
+
this._codeExecutor = new VMCodeExecutor(
|
|
924
|
+
this,
|
|
925
|
+
this._executorOptions
|
|
926
|
+
);
|
|
927
|
+
} catch (error) {
|
|
928
|
+
throw new Error(
|
|
929
|
+
"VM executor is not available in this environment and E2B API key is not provided. Please provide an E2B API key or run in a Node.js environment."
|
|
930
|
+
);
|
|
931
|
+
}
|
|
932
|
+
} else {
|
|
933
|
+
this._codeExecutor = new E2BCodeExecutor(this, opts);
|
|
934
|
+
}
|
|
935
|
+
} else {
|
|
936
|
+
try {
|
|
862
937
|
this._codeExecutor = new VMCodeExecutor(
|
|
863
938
|
this,
|
|
864
939
|
this._executorOptions
|
|
865
940
|
);
|
|
866
|
-
}
|
|
867
|
-
|
|
941
|
+
} catch (error) {
|
|
942
|
+
const e2bOpts = this._executorOptions;
|
|
943
|
+
const e2bApiKey = e2bOpts?.apiKey || process.env.E2B_API_KEY;
|
|
944
|
+
if (e2bApiKey) {
|
|
945
|
+
logger.info(
|
|
946
|
+
"VM executor not available in this environment. Falling back to E2B."
|
|
947
|
+
);
|
|
948
|
+
this._codeExecutor = new E2BCodeExecutor(this, {
|
|
949
|
+
...e2bOpts,
|
|
950
|
+
apiKey: e2bApiKey
|
|
951
|
+
});
|
|
952
|
+
} else {
|
|
953
|
+
throw new Error(
|
|
954
|
+
"VM executor is not available in this environment. Please provide an E2B API key via executorOptions or E2B_API_KEY environment variable, or run in a Node.js environment."
|
|
955
|
+
);
|
|
956
|
+
}
|
|
868
957
|
}
|
|
869
|
-
} else {
|
|
870
|
-
this._codeExecutor = new VMCodeExecutor(
|
|
871
|
-
this,
|
|
872
|
-
this._executorOptions
|
|
873
|
-
);
|
|
874
958
|
}
|
|
875
959
|
}
|
|
876
960
|
return this._codeExecutor;
|
|
@@ -1329,9 +1413,11 @@ export {
|
|
|
1329
1413
|
AcquireActiveMCPServerTool,
|
|
1330
1414
|
AddMCPServerFromConfigTool,
|
|
1331
1415
|
BaseAdapter,
|
|
1416
|
+
BaseCodeExecutor,
|
|
1332
1417
|
BaseConnector,
|
|
1333
1418
|
BrowserOAuthClientProvider,
|
|
1334
1419
|
ConnectMCPServerTool,
|
|
1420
|
+
E2BCodeExecutor,
|
|
1335
1421
|
HttpConnector,
|
|
1336
1422
|
LINEAR_OAUTH_CONFIG,
|
|
1337
1423
|
LangChainAdapter,
|
|
@@ -1348,11 +1434,13 @@ export {
|
|
|
1348
1434
|
ServerManager,
|
|
1349
1435
|
StdioConnector,
|
|
1350
1436
|
Telemetry,
|
|
1437
|
+
VMCodeExecutor,
|
|
1351
1438
|
WebSocketConnector,
|
|
1352
1439
|
WidgetDebugger,
|
|
1353
1440
|
WidgetFullscreenWrapper,
|
|
1354
1441
|
createOAuthMCPConfig,
|
|
1355
1442
|
createReadableStreamFromGenerator,
|
|
1443
|
+
isVMAvailable,
|
|
1356
1444
|
loadConfigFile,
|
|
1357
1445
|
logger,
|
|
1358
1446
|
onMcpAuthorization,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { BaseCodeExecutor } from "./executors/base.js";
|
|
2
2
|
export type { ExecutionResult, SearchToolsFunction, ToolNamespaceInfo, ToolSearchResult, } from "./executors/base.js";
|
|
3
3
|
export { E2BCodeExecutor } from "./executors/e2b.js";
|
|
4
|
-
export { VMCodeExecutor } from "./executors/vm.js";
|
|
4
|
+
export { VMCodeExecutor, isVMAvailable } from "./executors/vm.js";
|
|
5
5
|
export { BaseCodeExecutor as CodeExecutor } from "./executors/base.js";
|
|
6
6
|
//# sourceMappingURL=codeExecutor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codeExecutor.d.ts","sourceRoot":"","sources":["../../../src/client/codeExecutor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,YAAY,EACV,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"codeExecutor.d.ts","sourceRoot":"","sources":["../../../src/client/codeExecutor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,YAAY,EACV,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlE,OAAO,EAAE,gBAAgB,IAAI,YAAY,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { MCPClient, VMExecutorOptions } from "../../client.js";
|
|
2
2
|
import { BaseCodeExecutor, type ExecutionResult } from "./base.js";
|
|
3
|
+
/**
|
|
4
|
+
* Check if VM executor is available in the current environment
|
|
5
|
+
* This is a synchronous check that returns true if vm was already loaded
|
|
6
|
+
*/
|
|
7
|
+
export declare function isVMAvailable(): boolean;
|
|
3
8
|
/**
|
|
4
9
|
* VM-based code executor using Node.js vm module.
|
|
5
10
|
* Executes code in an isolated V8 context with access to MCP tools.
|
|
@@ -8,6 +13,10 @@ export declare class VMCodeExecutor extends BaseCodeExecutor {
|
|
|
8
13
|
private defaultTimeout;
|
|
9
14
|
private memoryLimitMb?;
|
|
10
15
|
constructor(client: MCPClient, options?: VMExecutorOptions);
|
|
16
|
+
/**
|
|
17
|
+
* Ensure VM module is loaded before execution
|
|
18
|
+
*/
|
|
19
|
+
private ensureVMLoaded;
|
|
11
20
|
/**
|
|
12
21
|
* Execute JavaScript/TypeScript code with access to MCP tools.
|
|
13
22
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vm.d.ts","sourceRoot":"","sources":["../../../../src/client/executors/vm.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vm.d.ts","sourceRoot":"","sources":["../../../../src/client/executors/vm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EAAE,gBAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AA4DnE;;;GAGG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAGvC;AAED;;;GAGG;AACH,qBAAa,cAAe,SAAQ,gBAAgB;IAClD,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,aAAa,CAAC,CAAS;gBAEnB,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,iBAAiB;IAS1D;;OAEG;YACW,cAAc;IAc5B;;;;;OAKG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAsEvE;;;;OAIG;YACW,aAAa;IA6F3B;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAG/B"}
|
package/dist/src/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseMCPClient } from "./client/base.js";
|
|
2
2
|
import type { ExecutionResult } from "./client/codeExecutor.js";
|
|
3
|
-
import { BaseCodeExecutor
|
|
3
|
+
import { BaseCodeExecutor } from "./client/codeExecutor.js";
|
|
4
4
|
import type { BaseConnector } from "./connectors/base.js";
|
|
5
5
|
export type CodeExecutorFunction = (code: string, timeout?: number) => Promise<ExecutionResult>;
|
|
6
6
|
export type CodeExecutorType = "vm" | "e2b";
|
|
@@ -21,7 +21,7 @@ export interface CodeModeConfig {
|
|
|
21
21
|
export interface MCPClientOptions {
|
|
22
22
|
codeMode?: boolean | CodeModeConfig;
|
|
23
23
|
}
|
|
24
|
-
export { BaseCodeExecutor, E2BCodeExecutor, VMCodeExecutor };
|
|
24
|
+
export { BaseCodeExecutor, E2BCodeExecutor, isVMAvailable, VMCodeExecutor, } from "./client/codeExecutor.js";
|
|
25
25
|
/**
|
|
26
26
|
* Node.js-specific MCPClient implementation
|
|
27
27
|
*
|
package/dist/src/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EACL,gBAAgB,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO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OAAO,CAAC,EAAE,gBAAgB;WAuCd,QAAQ,CACpB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACxB,OAAO,CAAC,EAAE,gBAAgB,GACzB,SAAS;WAIE,cAAc,CAC1B,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,gBAAgB,GACzB,SAAS;IAIZ;;OAEG;IACI,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAQzC;;;OAGG;IACH,SAAS,CAAC,yBAAyB,CACjC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAChC,aAAa;IAIhB,OAAO,CAAC,uBAAuB;IAU/B,OAAO,CAAC,mBAAmB;IAkE3B;;OAEG;IACU,WAAW,CACtB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,eAAe,CAAC;IAc3B;;OAEG;IACU,WAAW,CACtB,KAAK,GAAE,MAAW,EAClB,WAAW,GAAE,OAAO,GAAG,cAAc,GAAG,MAAe,GACtD,OAAO,CAAC,OAAO,0BAA0B,EAAE,gBAAgB,EAAE,CAAC;IAUjE;;OAEG;IACI,cAAc,IAAI,MAAM,EAAE;IAOjC;;;OAGG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAUpC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-use",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.4.
|
|
4
|
+
"version": "1.4.1-canary.0",
|
|
5
5
|
"description": "Opinionated MCP Framework for TypeScript (@modelcontextprotocol/sdk compatible) - Build MCP Agents and Clients + MCP Servers with support for MCP-UI.",
|
|
6
6
|
"author": "mcp-use, Inc.",
|
|
7
7
|
"license": "MIT",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"@modelcontextprotocol/sdk": "1.20.0",
|
|
96
96
|
"@scarf/scarf": "^1.4.0",
|
|
97
97
|
"ai": "^4.3.19",
|
|
98
|
-
"chalk": "^5.
|
|
98
|
+
"chalk": "^5.6.2",
|
|
99
99
|
"cli-highlight": "^2.1.11",
|
|
100
100
|
"commander": "^14.0.1",
|
|
101
101
|
"dotenv": "^16.5.0",
|
|
@@ -114,15 +114,15 @@
|
|
|
114
114
|
"ws": "^8.18.2",
|
|
115
115
|
"zod": "^3.25.48",
|
|
116
116
|
"zod-to-json-schema": "^3.24.6",
|
|
117
|
-
"@mcp-use/cli": "2.2.
|
|
118
|
-
"@mcp-use/inspector": "0.6.
|
|
117
|
+
"@mcp-use/cli": "2.2.5-canary.0",
|
|
118
|
+
"@mcp-use/inspector": "0.6.1-canary.0"
|
|
119
119
|
},
|
|
120
120
|
"optionalDependencies": {
|
|
121
121
|
"@tailwindcss/vite": "^4.1.15",
|
|
122
122
|
"@vitejs/plugin-react": "^5.0.4",
|
|
123
|
-
"vite": ">=5.4.21",
|
|
124
123
|
"connect": "^3.7.0",
|
|
125
|
-
"node-mocks-http": "^1.16.2"
|
|
124
|
+
"node-mocks-http": "^1.16.2",
|
|
125
|
+
"vite": ">=5.4.21"
|
|
126
126
|
},
|
|
127
127
|
"devDependencies": {
|
|
128
128
|
"@antfu/eslint-config": "^4.13.2",
|