@probelabs/probe 0.6.0-rc120 → 0.6.0-rc122
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/README.md +36 -2
- package/build/agent/ProbeAgent.js +50 -14
- package/build/agent/index.js +182 -48
- package/build/agent/mcp/client.js +69 -15
- package/build/agent/mcp/config.js +8 -8
- package/build/agent/mcp/xmlBridge.js +52 -7
- package/build/agent/schemaUtils.js +28 -15
- package/build/grep.js +152 -0
- package/build/index.js +2 -0
- package/build/mcp/index.js +105 -87
- package/build/mcp/index.ts +120 -97
- package/cjs/agent/ProbeAgent.cjs +191 -57
- package/cjs/index.cjs +249 -57
- package/index.d.ts +45 -0
- package/package.json +1 -1
- package/src/agent/ProbeAgent.js +50 -14
- package/src/agent/index.js +1 -1
- package/src/agent/mcp/client.js +69 -15
- package/src/agent/mcp/config.js +8 -8
- package/src/agent/mcp/xmlBridge.js +52 -7
- package/src/agent/schemaUtils.js +28 -15
- package/src/grep.js +152 -0
- package/src/index.js +2 -0
- package/src/mcp/index.ts +120 -97
package/build/agent/index.js
CHANGED
|
@@ -21345,8 +21345,8 @@ var require_dist_cjs59 = __commonJS({
|
|
|
21345
21345
|
module2.exports = __toCommonJS2(index_exports);
|
|
21346
21346
|
var import_property_provider2 = require_dist_cjs24();
|
|
21347
21347
|
var import_shared_ini_file_loader = require_dist_cjs42();
|
|
21348
|
-
var
|
|
21349
|
-
var
|
|
21348
|
+
var import_child_process10 = __require("child_process");
|
|
21349
|
+
var import_util10 = __require("util");
|
|
21350
21350
|
var import_client7 = (init_client(), __toCommonJS(client_exports));
|
|
21351
21351
|
var getValidatedProcessCredentials = /* @__PURE__ */ __name((profileName, data2, profiles) => {
|
|
21352
21352
|
if (data2.Version !== 1) {
|
|
@@ -21382,7 +21382,7 @@ var require_dist_cjs59 = __commonJS({
|
|
|
21382
21382
|
if (profiles[profileName]) {
|
|
21383
21383
|
const credentialProcess = profile["credential_process"];
|
|
21384
21384
|
if (credentialProcess !== void 0) {
|
|
21385
|
-
const execPromise = (0,
|
|
21385
|
+
const execPromise = (0, import_util10.promisify)(import_shared_ini_file_loader.externalDataInterceptor?.getTokenRecord?.().exec ?? import_child_process10.exec);
|
|
21386
21386
|
try {
|
|
21387
21387
|
const { stdout } = await execPromise(credentialProcess);
|
|
21388
21388
|
let data2;
|
|
@@ -28654,6 +28654,18 @@ var init_extract = __esm({
|
|
|
28654
28654
|
}
|
|
28655
28655
|
});
|
|
28656
28656
|
|
|
28657
|
+
// src/grep.js
|
|
28658
|
+
import { execFile } from "child_process";
|
|
28659
|
+
import { promisify as promisify5 } from "util";
|
|
28660
|
+
var execFileAsync;
|
|
28661
|
+
var init_grep = __esm({
|
|
28662
|
+
"src/grep.js"() {
|
|
28663
|
+
"use strict";
|
|
28664
|
+
init_utils2();
|
|
28665
|
+
execFileAsync = promisify5(execFile);
|
|
28666
|
+
}
|
|
28667
|
+
});
|
|
28668
|
+
|
|
28657
28669
|
// src/tools/common.js
|
|
28658
28670
|
import { z as z2 } from "zod";
|
|
28659
28671
|
function parseXmlToolCall(xmlString, validTools = DEFAULT_VALID_TOOLS) {
|
|
@@ -30809,7 +30821,7 @@ var init_tools = __esm({
|
|
|
30809
30821
|
// src/utils/file-lister.js
|
|
30810
30822
|
import fs4 from "fs";
|
|
30811
30823
|
import path4 from "path";
|
|
30812
|
-
import { promisify as
|
|
30824
|
+
import { promisify as promisify6 } from "util";
|
|
30813
30825
|
import { exec as exec5 } from "child_process";
|
|
30814
30826
|
async function listFilesByLevel(options) {
|
|
30815
30827
|
const {
|
|
@@ -30902,7 +30914,7 @@ var execAsync4;
|
|
|
30902
30914
|
var init_file_lister = __esm({
|
|
30903
30915
|
"src/utils/file-lister.js"() {
|
|
30904
30916
|
"use strict";
|
|
30905
|
-
execAsync4 =
|
|
30917
|
+
execAsync4 = promisify6(exec5);
|
|
30906
30918
|
}
|
|
30907
30919
|
});
|
|
30908
30920
|
|
|
@@ -31133,7 +31145,7 @@ var init_simpleTelemetry = __esm({
|
|
|
31133
31145
|
|
|
31134
31146
|
// src/agent/probeTool.js
|
|
31135
31147
|
import { exec as exec6 } from "child_process";
|
|
31136
|
-
import { promisify as
|
|
31148
|
+
import { promisify as promisify7 } from "util";
|
|
31137
31149
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
31138
31150
|
import { EventEmitter } from "events";
|
|
31139
31151
|
import fs5 from "fs";
|
|
@@ -31416,6 +31428,7 @@ var init_index = __esm({
|
|
|
31416
31428
|
init_search();
|
|
31417
31429
|
init_query();
|
|
31418
31430
|
init_extract();
|
|
31431
|
+
init_grep();
|
|
31419
31432
|
init_delegate();
|
|
31420
31433
|
init_utils2();
|
|
31421
31434
|
init_tools();
|
|
@@ -60568,6 +60581,14 @@ function cleanSchemaResponse(response) {
|
|
|
60568
60581
|
return response;
|
|
60569
60582
|
}
|
|
60570
60583
|
const trimmed = response.trim();
|
|
60584
|
+
const jsonBlockMatch = trimmed.match(/```json\s*\n([\s\S]*?)\n```/);
|
|
60585
|
+
if (jsonBlockMatch) {
|
|
60586
|
+
return jsonBlockMatch[1].trim();
|
|
60587
|
+
}
|
|
60588
|
+
const anyBlockMatch = trimmed.match(/```\s*\n([{\[][\s\S]*?[}\]])\s*```/);
|
|
60589
|
+
if (anyBlockMatch) {
|
|
60590
|
+
return anyBlockMatch[1].trim();
|
|
60591
|
+
}
|
|
60571
60592
|
const codeBlockPatterns = [
|
|
60572
60593
|
/```json\s*\n?([{\[][\s\S]*?[}\]])\s*\n?```/,
|
|
60573
60594
|
/```\s*\n?([{\[][\s\S]*?[}\]])\s*\n?```/,
|
|
@@ -61443,8 +61464,8 @@ function loadMCPConfigurationFromPath(configPath) {
|
|
|
61443
61464
|
try {
|
|
61444
61465
|
const content = readFileSync(configPath, "utf8");
|
|
61445
61466
|
const config = JSON.parse(content);
|
|
61446
|
-
if (process.env.DEBUG === "1") {
|
|
61447
|
-
console.error(`[MCP] Loaded configuration from: ${configPath}`);
|
|
61467
|
+
if (process.env.DEBUG === "1" || process.env.DEBUG_MCP === "1") {
|
|
61468
|
+
console.error(`[MCP DEBUG] Loaded configuration from: ${configPath}`);
|
|
61448
61469
|
}
|
|
61449
61470
|
return mergeWithEnvironment(config);
|
|
61450
61471
|
} catch (error2) {
|
|
@@ -61470,12 +61491,12 @@ function loadMCPConfiguration() {
|
|
|
61470
61491
|
try {
|
|
61471
61492
|
const content = readFileSync(configPath, "utf8");
|
|
61472
61493
|
config = JSON.parse(content);
|
|
61473
|
-
if (process.env.DEBUG === "1") {
|
|
61474
|
-
console.error(`[MCP] Loaded configuration from: ${configPath}`);
|
|
61494
|
+
if (process.env.DEBUG === "1" || process.env.DEBUG_MCP === "1") {
|
|
61495
|
+
console.error(`[MCP DEBUG] Loaded configuration from: ${configPath}`);
|
|
61475
61496
|
}
|
|
61476
61497
|
break;
|
|
61477
61498
|
} catch (error2) {
|
|
61478
|
-
console.error(`[MCP] Failed to parse config from ${configPath}:`, error2.message);
|
|
61499
|
+
console.error(`[MCP ERROR] Failed to parse config from ${configPath}:`, error2.message);
|
|
61479
61500
|
}
|
|
61480
61501
|
}
|
|
61481
61502
|
}
|
|
@@ -61551,12 +61572,12 @@ function parseEnabledServers(config) {
|
|
|
61551
61572
|
}
|
|
61552
61573
|
if (server.transport === "stdio") {
|
|
61553
61574
|
if (!server.command) {
|
|
61554
|
-
console.error(`[MCP] Server ${name14} missing required 'command' for stdio transport`);
|
|
61575
|
+
console.error(`[MCP ERROR] Server ${name14} missing required 'command' for stdio transport`);
|
|
61555
61576
|
continue;
|
|
61556
61577
|
}
|
|
61557
61578
|
} else if (["websocket", "sse", "http"].includes(server.transport)) {
|
|
61558
61579
|
if (!server.url) {
|
|
61559
|
-
console.error(`[MCP] Server ${name14} missing required 'url' for ${server.transport} transport`);
|
|
61580
|
+
console.error(`[MCP ERROR] Server ${name14} missing required 'url' for ${server.transport} transport`);
|
|
61560
61581
|
continue;
|
|
61561
61582
|
}
|
|
61562
61583
|
}
|
|
@@ -61683,20 +61704,45 @@ var init_client2 = __esm({
|
|
|
61683
61704
|
async initialize(config = null) {
|
|
61684
61705
|
this.config = config || loadMCPConfiguration();
|
|
61685
61706
|
const servers = parseEnabledServers(this.config);
|
|
61707
|
+
console.error(`[MCP INFO] Found ${servers.length} enabled MCP server${servers.length !== 1 ? "s" : ""}`);
|
|
61708
|
+
if (servers.length === 0) {
|
|
61709
|
+
console.error("[MCP INFO] No MCP servers configured or enabled");
|
|
61710
|
+
console.error("[MCP INFO] 0 MCP tools available");
|
|
61711
|
+
return {
|
|
61712
|
+
connected: 0,
|
|
61713
|
+
total: 0,
|
|
61714
|
+
tools: []
|
|
61715
|
+
};
|
|
61716
|
+
}
|
|
61686
61717
|
if (this.debug) {
|
|
61687
|
-
console.error(
|
|
61718
|
+
console.error("[MCP DEBUG] Server details:");
|
|
61719
|
+
servers.forEach((server) => {
|
|
61720
|
+
console.error(`[MCP DEBUG] - ${server.name} (${server.transport})`);
|
|
61721
|
+
});
|
|
61688
61722
|
}
|
|
61689
61723
|
const connectionPromises = servers.map(
|
|
61690
61724
|
(server) => this.connectToServer(server).catch((error2) => {
|
|
61691
|
-
console.error(`[MCP] Failed to connect to ${server.name}:`, error2.message);
|
|
61725
|
+
console.error(`[MCP ERROR] Failed to connect to ${server.name}:`, error2.message);
|
|
61692
61726
|
return null;
|
|
61693
61727
|
})
|
|
61694
61728
|
);
|
|
61695
61729
|
const results = await Promise.all(connectionPromises);
|
|
61696
61730
|
const connectedCount = results.filter(Boolean).length;
|
|
61697
|
-
if (
|
|
61698
|
-
console.error(`[MCP]
|
|
61699
|
-
console.error(
|
|
61731
|
+
if (connectedCount === 0) {
|
|
61732
|
+
console.error(`[MCP ERROR] Failed to connect to all ${servers.length} server${servers.length !== 1 ? "s" : ""}`);
|
|
61733
|
+
console.error("[MCP INFO] 0 MCP tools available");
|
|
61734
|
+
} else if (connectedCount < servers.length) {
|
|
61735
|
+
console.error(`[MCP INFO] Successfully connected to ${connectedCount}/${servers.length} servers`);
|
|
61736
|
+
console.error(`[MCP INFO] ${this.tools.size} MCP tool${this.tools.size !== 1 ? "s" : ""} available`);
|
|
61737
|
+
} else {
|
|
61738
|
+
console.error(`[MCP INFO] Successfully connected to all ${connectedCount} server${connectedCount !== 1 ? "s" : ""}`);
|
|
61739
|
+
console.error(`[MCP INFO] ${this.tools.size} MCP tool${this.tools.size !== 1 ? "s" : ""} available`);
|
|
61740
|
+
}
|
|
61741
|
+
if (this.debug && this.tools.size > 0) {
|
|
61742
|
+
console.error("[MCP DEBUG] Available tools:");
|
|
61743
|
+
Array.from(this.tools.keys()).forEach((toolName) => {
|
|
61744
|
+
console.error(`[MCP DEBUG] - ${toolName}`);
|
|
61745
|
+
});
|
|
61700
61746
|
}
|
|
61701
61747
|
return {
|
|
61702
61748
|
connected: connectedCount,
|
|
@@ -61712,7 +61758,7 @@ var init_client2 = __esm({
|
|
|
61712
61758
|
const { name: name14 } = serverConfig;
|
|
61713
61759
|
try {
|
|
61714
61760
|
if (this.debug) {
|
|
61715
|
-
console.error(`[MCP] Connecting to ${name14} via ${serverConfig.transport}...`);
|
|
61761
|
+
console.error(`[MCP DEBUG] Connecting to ${name14} via ${serverConfig.transport}...`);
|
|
61716
61762
|
}
|
|
61717
61763
|
const transport = createTransport(serverConfig);
|
|
61718
61764
|
const client = new Client(
|
|
@@ -61731,6 +61777,7 @@ var init_client2 = __esm({
|
|
|
61731
61777
|
config: serverConfig
|
|
61732
61778
|
});
|
|
61733
61779
|
const toolsResponse = await client.listTools();
|
|
61780
|
+
const toolCount = toolsResponse?.tools?.length || 0;
|
|
61734
61781
|
if (toolsResponse && toolsResponse.tools) {
|
|
61735
61782
|
for (const tool3 of toolsResponse.tools) {
|
|
61736
61783
|
const qualifiedName = `${name14}_${tool3.name}`;
|
|
@@ -61740,16 +61787,17 @@ var init_client2 = __esm({
|
|
|
61740
61787
|
originalName: tool3.name
|
|
61741
61788
|
});
|
|
61742
61789
|
if (this.debug) {
|
|
61743
|
-
console.error(`[MCP]
|
|
61790
|
+
console.error(`[MCP DEBUG] Registered tool: ${qualifiedName}`);
|
|
61744
61791
|
}
|
|
61745
61792
|
}
|
|
61746
61793
|
}
|
|
61747
|
-
|
|
61748
|
-
console.error(`[MCP] Connected to ${name14} with ${toolsResponse?.tools?.length || 0} tools`);
|
|
61749
|
-
}
|
|
61794
|
+
console.error(`[MCP INFO] Connected to ${name14}: ${toolCount} tool${toolCount !== 1 ? "s" : ""} loaded`);
|
|
61750
61795
|
return true;
|
|
61751
61796
|
} catch (error2) {
|
|
61752
|
-
console.error(`[MCP] Error connecting to ${name14}:`, error2.message);
|
|
61797
|
+
console.error(`[MCP ERROR] Error connecting to ${name14}:`, error2.message);
|
|
61798
|
+
if (this.debug) {
|
|
61799
|
+
console.error(`[MCP DEBUG] Full error details:`, error2);
|
|
61800
|
+
}
|
|
61753
61801
|
return false;
|
|
61754
61802
|
}
|
|
61755
61803
|
}
|
|
@@ -61769,7 +61817,7 @@ var init_client2 = __esm({
|
|
|
61769
61817
|
}
|
|
61770
61818
|
try {
|
|
61771
61819
|
if (this.debug) {
|
|
61772
|
-
console.error(`[MCP] Calling ${toolName} with args:`, args);
|
|
61820
|
+
console.error(`[MCP DEBUG] Calling ${toolName} with args:`, JSON.stringify(args, null, 2));
|
|
61773
61821
|
}
|
|
61774
61822
|
const timeout = this.config?.settings?.timeout || 3e4;
|
|
61775
61823
|
const timeoutPromise = new Promise((_2, reject2) => {
|
|
@@ -61784,9 +61832,15 @@ var init_client2 = __esm({
|
|
|
61784
61832
|
}),
|
|
61785
61833
|
timeoutPromise
|
|
61786
61834
|
]);
|
|
61835
|
+
if (this.debug) {
|
|
61836
|
+
console.error(`[MCP DEBUG] Tool ${toolName} executed successfully`);
|
|
61837
|
+
}
|
|
61787
61838
|
return result;
|
|
61788
61839
|
} catch (error2) {
|
|
61789
|
-
console.error(`[MCP] Error calling tool ${toolName}:`, error2);
|
|
61840
|
+
console.error(`[MCP ERROR] Error calling tool ${toolName}:`, error2.message);
|
|
61841
|
+
if (this.debug) {
|
|
61842
|
+
console.error(`[MCP DEBUG] Full error details:`, error2);
|
|
61843
|
+
}
|
|
61790
61844
|
throw error2;
|
|
61791
61845
|
}
|
|
61792
61846
|
}
|
|
@@ -61831,20 +61885,32 @@ var init_client2 = __esm({
|
|
|
61831
61885
|
*/
|
|
61832
61886
|
async disconnect() {
|
|
61833
61887
|
const disconnectPromises = [];
|
|
61888
|
+
if (this.clients.size === 0) {
|
|
61889
|
+
if (this.debug) {
|
|
61890
|
+
console.error("[MCP DEBUG] No MCP clients to disconnect");
|
|
61891
|
+
}
|
|
61892
|
+
return;
|
|
61893
|
+
}
|
|
61894
|
+
if (this.debug) {
|
|
61895
|
+
console.error(`[MCP DEBUG] Disconnecting from ${this.clients.size} MCP server${this.clients.size !== 1 ? "s" : ""}...`);
|
|
61896
|
+
}
|
|
61834
61897
|
for (const [name14, clientInfo] of this.clients.entries()) {
|
|
61835
61898
|
disconnectPromises.push(
|
|
61836
61899
|
clientInfo.client.close().then(() => {
|
|
61837
61900
|
if (this.debug) {
|
|
61838
|
-
console.error(`[MCP] Disconnected from ${name14}`);
|
|
61901
|
+
console.error(`[MCP DEBUG] Disconnected from ${name14}`);
|
|
61839
61902
|
}
|
|
61840
61903
|
}).catch((error2) => {
|
|
61841
|
-
console.error(`[MCP] Error disconnecting from ${name14}:`, error2);
|
|
61904
|
+
console.error(`[MCP ERROR] Error disconnecting from ${name14}:`, error2.message);
|
|
61842
61905
|
})
|
|
61843
61906
|
);
|
|
61844
61907
|
}
|
|
61845
61908
|
await Promise.all(disconnectPromises);
|
|
61846
61909
|
this.clients.clear();
|
|
61847
61910
|
this.tools.clear();
|
|
61911
|
+
if (this.debug) {
|
|
61912
|
+
console.error("[MCP DEBUG] All MCP connections closed");
|
|
61913
|
+
}
|
|
61848
61914
|
}
|
|
61849
61915
|
};
|
|
61850
61916
|
}
|
|
@@ -61996,31 +62062,58 @@ var init_xmlBridge = __esm({
|
|
|
61996
62062
|
async initialize(config = null) {
|
|
61997
62063
|
let mcpConfigs = null;
|
|
61998
62064
|
if (!config) {
|
|
62065
|
+
if (this.debug) {
|
|
62066
|
+
console.error("[MCP DEBUG] No config provided, attempting auto-discovery...");
|
|
62067
|
+
}
|
|
61999
62068
|
mcpConfigs = loadMCPConfiguration();
|
|
62069
|
+
if (!mcpConfigs || !mcpConfigs.mcpServers || Object.keys(mcpConfigs.mcpServers).length === 0) {
|
|
62070
|
+
console.error("[MCP WARNING] MCP enabled but no configuration found");
|
|
62071
|
+
console.error("[MCP INFO] To use MCP, provide configuration via:");
|
|
62072
|
+
console.error("[MCP INFO] - mcpConfig option when creating ProbeAgent");
|
|
62073
|
+
console.error("[MCP INFO] - mcpConfigPath option pointing to a config file");
|
|
62074
|
+
console.error("[MCP INFO] - Config file in standard locations (~/.mcp/config.json, etc.)");
|
|
62075
|
+
console.error("[MCP INFO] - Environment variable MCP_CONFIG_PATH");
|
|
62076
|
+
}
|
|
62000
62077
|
} else if (Array.isArray(config)) {
|
|
62078
|
+
if (this.debug) {
|
|
62079
|
+
console.error("[MCP DEBUG] Using deprecated array config format (consider using mcpConfig object)");
|
|
62080
|
+
}
|
|
62001
62081
|
mcpConfigs = { mcpServers: config };
|
|
62002
62082
|
} else {
|
|
62083
|
+
if (this.debug) {
|
|
62084
|
+
console.error("[MCP DEBUG] Using provided MCP config object");
|
|
62085
|
+
}
|
|
62003
62086
|
mcpConfigs = config;
|
|
62004
62087
|
}
|
|
62005
62088
|
if (!mcpConfigs || !mcpConfigs.mcpServers || Object.keys(mcpConfigs.mcpServers).length === 0) {
|
|
62006
|
-
|
|
62007
|
-
console.error("[MCP] No MCP servers configured");
|
|
62008
|
-
}
|
|
62089
|
+
console.error("[MCP INFO] 0 MCP tools available");
|
|
62009
62090
|
return;
|
|
62010
62091
|
}
|
|
62011
62092
|
try {
|
|
62093
|
+
if (this.debug) {
|
|
62094
|
+
console.error("[MCP DEBUG] Initializing MCP client manager...");
|
|
62095
|
+
}
|
|
62012
62096
|
this.mcpManager = new MCPClientManager({ debug: this.debug });
|
|
62013
62097
|
const result = await this.mcpManager.initialize(mcpConfigs);
|
|
62014
62098
|
const vercelTools = this.mcpManager.getVercelTools();
|
|
62015
62099
|
this.mcpTools = vercelTools;
|
|
62100
|
+
const toolCount = Object.keys(vercelTools).length;
|
|
62016
62101
|
for (const [name14, tool3] of Object.entries(vercelTools)) {
|
|
62017
62102
|
this.xmlDefinitions[name14] = mcpToolToXmlDefinition(name14, tool3);
|
|
62018
62103
|
}
|
|
62019
|
-
if (
|
|
62020
|
-
console.error(
|
|
62104
|
+
if (toolCount === 0) {
|
|
62105
|
+
console.error("[MCP INFO] MCP initialization complete: 0 tools loaded");
|
|
62106
|
+
} else {
|
|
62107
|
+
console.error(`[MCP INFO] MCP initialization complete: ${toolCount} tool${toolCount !== 1 ? "s" : ""} loaded from ${result.connected} server${result.connected !== 1 ? "s" : ""}`);
|
|
62108
|
+
if (this.debug) {
|
|
62109
|
+
console.error("[MCP DEBUG] Tool definitions generated for XML bridge");
|
|
62110
|
+
}
|
|
62021
62111
|
}
|
|
62022
62112
|
} catch (error2) {
|
|
62023
|
-
console.error("[MCP] Failed to initialize MCP connections:", error2);
|
|
62113
|
+
console.error("[MCP ERROR] Failed to initialize MCP connections:", error2.message);
|
|
62114
|
+
if (this.debug) {
|
|
62115
|
+
console.error("[MCP DEBUG] Full error details:", error2);
|
|
62116
|
+
}
|
|
62024
62117
|
}
|
|
62025
62118
|
}
|
|
62026
62119
|
/**
|
|
@@ -62045,24 +62138,35 @@ var init_xmlBridge = __esm({
|
|
|
62045
62138
|
async executeFromXml(xmlString) {
|
|
62046
62139
|
const parsed = parseXmlMcpToolCall(xmlString, this.getToolNames());
|
|
62047
62140
|
if (!parsed) {
|
|
62141
|
+
console.error("[MCP ERROR] No valid MCP tool call found in XML");
|
|
62048
62142
|
throw new Error("No valid MCP tool call found in XML");
|
|
62049
62143
|
}
|
|
62050
62144
|
const { toolName, params } = parsed;
|
|
62051
62145
|
if (this.debug) {
|
|
62052
|
-
console.error(`[MCP] Executing MCP tool: ${toolName}
|
|
62146
|
+
console.error(`[MCP DEBUG] Executing MCP tool: ${toolName}`);
|
|
62147
|
+
console.error(`[MCP DEBUG] Parameters:`, JSON.stringify(params, null, 2));
|
|
62053
62148
|
}
|
|
62054
62149
|
const tool3 = this.mcpTools[toolName];
|
|
62055
62150
|
if (!tool3) {
|
|
62151
|
+
console.error(`[MCP ERROR] Unknown MCP tool: ${toolName}`);
|
|
62152
|
+
console.error(`[MCP ERROR] Available tools: ${this.getToolNames().join(", ")}`);
|
|
62056
62153
|
throw new Error(`Unknown MCP tool: ${toolName}`);
|
|
62057
62154
|
}
|
|
62058
62155
|
try {
|
|
62059
62156
|
const result = await tool3.execute(params);
|
|
62157
|
+
if (this.debug) {
|
|
62158
|
+
console.error(`[MCP DEBUG] Tool ${toolName} executed successfully`);
|
|
62159
|
+
}
|
|
62060
62160
|
return {
|
|
62061
62161
|
success: true,
|
|
62062
62162
|
toolName,
|
|
62063
62163
|
result
|
|
62064
62164
|
};
|
|
62065
62165
|
} catch (error2) {
|
|
62166
|
+
console.error(`[MCP ERROR] Tool ${toolName} execution failed:`, error2.message);
|
|
62167
|
+
if (this.debug) {
|
|
62168
|
+
console.error(`[MCP DEBUG] Full error details:`, error2);
|
|
62169
|
+
}
|
|
62066
62170
|
return {
|
|
62067
62171
|
success: false,
|
|
62068
62172
|
toolName,
|
|
@@ -62196,6 +62300,7 @@ var init_ProbeAgent = __esm({
|
|
|
62196
62300
|
this.mcpConfig = options.mcpConfig || null;
|
|
62197
62301
|
this.mcpServers = options.mcpServers || null;
|
|
62198
62302
|
this.mcpBridge = null;
|
|
62303
|
+
this._mcpInitialized = false;
|
|
62199
62304
|
this.initializeModel();
|
|
62200
62305
|
}
|
|
62201
62306
|
/**
|
|
@@ -62203,7 +62308,8 @@ var init_ProbeAgent = __esm({
|
|
|
62203
62308
|
* This method initializes MCP and merges MCP tools into the tool list
|
|
62204
62309
|
*/
|
|
62205
62310
|
async initialize() {
|
|
62206
|
-
if (this.enableMcp) {
|
|
62311
|
+
if (this.enableMcp && !this._mcpInitialized) {
|
|
62312
|
+
this._mcpInitialized = true;
|
|
62207
62313
|
try {
|
|
62208
62314
|
await this.initializeMCP();
|
|
62209
62315
|
if (this.mcpBridge) {
|
|
@@ -62227,7 +62333,10 @@ var init_ProbeAgent = __esm({
|
|
|
62227
62333
|
console.error("[DEBUG] ========================================\n");
|
|
62228
62334
|
}
|
|
62229
62335
|
} catch (error2) {
|
|
62230
|
-
console.error("[MCP] Failed to initialize MCP:", error2);
|
|
62336
|
+
console.error("[MCP ERROR] Failed to initialize MCP:", error2.message);
|
|
62337
|
+
if (this.debug) {
|
|
62338
|
+
console.error("[MCP DEBUG] Full error details:", error2);
|
|
62339
|
+
}
|
|
62231
62340
|
this.mcpBridge = null;
|
|
62232
62341
|
}
|
|
62233
62342
|
}
|
|
@@ -62651,13 +62760,13 @@ var init_ProbeAgent = __esm({
|
|
|
62651
62760
|
if (this.mcpConfig) {
|
|
62652
62761
|
mcpConfig = this.mcpConfig;
|
|
62653
62762
|
if (this.debug) {
|
|
62654
|
-
console.
|
|
62763
|
+
console.error("[MCP DEBUG] Using provided MCP config object");
|
|
62655
62764
|
}
|
|
62656
62765
|
} else if (this.mcpConfigPath) {
|
|
62657
62766
|
try {
|
|
62658
62767
|
mcpConfig = loadMCPConfigurationFromPath(this.mcpConfigPath);
|
|
62659
62768
|
if (this.debug) {
|
|
62660
|
-
console.
|
|
62769
|
+
console.error(`[MCP DEBUG] Loaded MCP config from: ${this.mcpConfigPath}`);
|
|
62661
62770
|
}
|
|
62662
62771
|
} catch (error2) {
|
|
62663
62772
|
throw new Error(`Failed to load MCP config from ${this.mcpConfigPath}: ${error2.message}`);
|
|
@@ -62665,8 +62774,13 @@ var init_ProbeAgent = __esm({
|
|
|
62665
62774
|
} else if (this.mcpServers) {
|
|
62666
62775
|
mcpConfig = { mcpServers: this.mcpServers };
|
|
62667
62776
|
if (this.debug) {
|
|
62668
|
-
console.
|
|
62777
|
+
console.error("[MCP DEBUG] Using deprecated mcpServers option. Consider using mcpConfig instead.");
|
|
62669
62778
|
}
|
|
62779
|
+
} else {
|
|
62780
|
+
if (this.debug) {
|
|
62781
|
+
console.error("[MCP DEBUG] No explicit MCP config provided, will attempt auto-discovery");
|
|
62782
|
+
}
|
|
62783
|
+
mcpConfig = null;
|
|
62670
62784
|
}
|
|
62671
62785
|
this.mcpBridge = new MCPXmlBridge({ debug: this.debug });
|
|
62672
62786
|
await this.mcpBridge.initialize(mcpConfig);
|
|
@@ -62674,22 +62788,25 @@ var init_ProbeAgent = __esm({
|
|
|
62674
62788
|
const mcpToolCount = mcpToolNames.length;
|
|
62675
62789
|
if (mcpToolCount > 0) {
|
|
62676
62790
|
if (this.debug) {
|
|
62677
|
-
console.error("\n[DEBUG] ========================================");
|
|
62678
|
-
console.error(`[DEBUG] MCP Tools Initialized (${mcpToolCount} tools)`);
|
|
62679
|
-
console.error("[DEBUG] Available MCP tools:");
|
|
62791
|
+
console.error("\n[MCP DEBUG] ========================================");
|
|
62792
|
+
console.error(`[MCP DEBUG] MCP Tools Initialized (${mcpToolCount} tools)`);
|
|
62793
|
+
console.error("[MCP DEBUG] Available MCP tools:");
|
|
62680
62794
|
for (const toolName of mcpToolNames) {
|
|
62681
|
-
console.error(`[DEBUG] - ${toolName}`);
|
|
62795
|
+
console.error(`[MCP DEBUG] - ${toolName}`);
|
|
62682
62796
|
}
|
|
62683
|
-
console.error("[DEBUG] ========================================\n");
|
|
62797
|
+
console.error("[MCP DEBUG] ========================================\n");
|
|
62684
62798
|
}
|
|
62685
62799
|
} else {
|
|
62686
62800
|
if (this.debug) {
|
|
62687
|
-
console.error("[DEBUG] No MCP tools loaded, setting bridge to null");
|
|
62801
|
+
console.error("[MCP DEBUG] No MCP tools loaded, setting bridge to null");
|
|
62688
62802
|
}
|
|
62689
62803
|
this.mcpBridge = null;
|
|
62690
62804
|
}
|
|
62691
62805
|
} catch (error2) {
|
|
62692
|
-
console.error("[MCP] Error initializing MCP:", error2);
|
|
62806
|
+
console.error("[MCP ERROR] Error initializing MCP:", error2.message);
|
|
62807
|
+
if (this.debug) {
|
|
62808
|
+
console.error("[MCP DEBUG] Full error details:", error2);
|
|
62809
|
+
}
|
|
62693
62810
|
this.mcpBridge = null;
|
|
62694
62811
|
}
|
|
62695
62812
|
}
|
|
@@ -62697,6 +62814,23 @@ var init_ProbeAgent = __esm({
|
|
|
62697
62814
|
* Get the system message with instructions for the AI (XML Tool Format)
|
|
62698
62815
|
*/
|
|
62699
62816
|
async getSystemMessage() {
|
|
62817
|
+
if (this.enableMcp && !this.mcpBridge && !this._mcpInitialized) {
|
|
62818
|
+
this._mcpInitialized = true;
|
|
62819
|
+
try {
|
|
62820
|
+
await this.initializeMCP();
|
|
62821
|
+
if (this.mcpBridge) {
|
|
62822
|
+
const mcpTools = this.mcpBridge.mcpTools || {};
|
|
62823
|
+
for (const [toolName, toolImpl] of Object.entries(mcpTools)) {
|
|
62824
|
+
this.toolImplementations[toolName] = toolImpl;
|
|
62825
|
+
}
|
|
62826
|
+
}
|
|
62827
|
+
} catch (error2) {
|
|
62828
|
+
console.error("[MCP ERROR] Failed to lazy-initialize MCP:", error2.message);
|
|
62829
|
+
if (this.debug) {
|
|
62830
|
+
console.error("[MCP DEBUG] Full error details:", error2);
|
|
62831
|
+
}
|
|
62832
|
+
}
|
|
62833
|
+
}
|
|
62700
62834
|
let toolDefinitions = `
|
|
62701
62835
|
${searchToolDefinition}
|
|
62702
62836
|
${queryToolDefinition}
|
|
@@ -64675,7 +64809,7 @@ var ProbeAgentMcpServer = class {
|
|
|
64675
64809
|
);
|
|
64676
64810
|
this.agent = null;
|
|
64677
64811
|
this.setupToolHandlers();
|
|
64678
|
-
this.server.onerror = (error2) => console.error("[MCP
|
|
64812
|
+
this.server.onerror = (error2) => console.error("[MCP ERROR]", error2);
|
|
64679
64813
|
process.on("SIGINT", async () => {
|
|
64680
64814
|
await this.server.close();
|
|
64681
64815
|
process.exit(0);
|
|
@@ -128,14 +128,30 @@ export class MCPClientManager {
|
|
|
128
128
|
this.config = config || loadMCPConfiguration();
|
|
129
129
|
const servers = parseEnabledServers(this.config);
|
|
130
130
|
|
|
131
|
+
// Always log the number of servers found
|
|
132
|
+
console.error(`[MCP INFO] Found ${servers.length} enabled MCP server${servers.length !== 1 ? 's' : ''}`);
|
|
133
|
+
|
|
134
|
+
if (servers.length === 0) {
|
|
135
|
+
console.error('[MCP INFO] No MCP servers configured or enabled');
|
|
136
|
+
console.error('[MCP INFO] 0 MCP tools available');
|
|
137
|
+
return {
|
|
138
|
+
connected: 0,
|
|
139
|
+
total: 0,
|
|
140
|
+
tools: []
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
131
144
|
if (this.debug) {
|
|
132
|
-
console.error(
|
|
145
|
+
console.error('[MCP DEBUG] Server details:');
|
|
146
|
+
servers.forEach(server => {
|
|
147
|
+
console.error(`[MCP DEBUG] - ${server.name} (${server.transport})`);
|
|
148
|
+
});
|
|
133
149
|
}
|
|
134
150
|
|
|
135
151
|
// Connect to each enabled server
|
|
136
152
|
const connectionPromises = servers.map(server =>
|
|
137
153
|
this.connectToServer(server).catch(error => {
|
|
138
|
-
console.error(`[MCP] Failed to connect to ${server.name}:`, error.message);
|
|
154
|
+
console.error(`[MCP ERROR] Failed to connect to ${server.name}:`, error.message);
|
|
139
155
|
return null;
|
|
140
156
|
})
|
|
141
157
|
);
|
|
@@ -143,9 +159,23 @@ export class MCPClientManager {
|
|
|
143
159
|
const results = await Promise.all(connectionPromises);
|
|
144
160
|
const connectedCount = results.filter(Boolean).length;
|
|
145
161
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
console.error(`[MCP]
|
|
162
|
+
// Always log connection results
|
|
163
|
+
if (connectedCount === 0) {
|
|
164
|
+
console.error(`[MCP ERROR] Failed to connect to all ${servers.length} server${servers.length !== 1 ? 's' : ''}`);
|
|
165
|
+
console.error('[MCP INFO] 0 MCP tools available');
|
|
166
|
+
} else if (connectedCount < servers.length) {
|
|
167
|
+
console.error(`[MCP INFO] Successfully connected to ${connectedCount}/${servers.length} servers`);
|
|
168
|
+
console.error(`[MCP INFO] ${this.tools.size} MCP tool${this.tools.size !== 1 ? 's' : ''} available`);
|
|
169
|
+
} else {
|
|
170
|
+
console.error(`[MCP INFO] Successfully connected to all ${connectedCount} server${connectedCount !== 1 ? 's' : ''}`);
|
|
171
|
+
console.error(`[MCP INFO] ${this.tools.size} MCP tool${this.tools.size !== 1 ? 's' : ''} available`);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (this.debug && this.tools.size > 0) {
|
|
175
|
+
console.error('[MCP DEBUG] Available tools:');
|
|
176
|
+
Array.from(this.tools.keys()).forEach(toolName => {
|
|
177
|
+
console.error(`[MCP DEBUG] - ${toolName}`);
|
|
178
|
+
});
|
|
149
179
|
}
|
|
150
180
|
|
|
151
181
|
return {
|
|
@@ -164,7 +194,7 @@ export class MCPClientManager {
|
|
|
164
194
|
|
|
165
195
|
try {
|
|
166
196
|
if (this.debug) {
|
|
167
|
-
console.error(`[MCP] Connecting to ${name} via ${serverConfig.transport}...`);
|
|
197
|
+
console.error(`[MCP DEBUG] Connecting to ${name} via ${serverConfig.transport}...`);
|
|
168
198
|
}
|
|
169
199
|
|
|
170
200
|
// Create transport
|
|
@@ -193,6 +223,7 @@ export class MCPClientManager {
|
|
|
193
223
|
|
|
194
224
|
// Fetch and register tools
|
|
195
225
|
const toolsResponse = await client.listTools();
|
|
226
|
+
const toolCount = toolsResponse?.tools?.length || 0;
|
|
196
227
|
|
|
197
228
|
if (toolsResponse && toolsResponse.tools) {
|
|
198
229
|
for (const tool of toolsResponse.tools) {
|
|
@@ -205,18 +236,19 @@ export class MCPClientManager {
|
|
|
205
236
|
});
|
|
206
237
|
|
|
207
238
|
if (this.debug) {
|
|
208
|
-
console.error(`[MCP]
|
|
239
|
+
console.error(`[MCP DEBUG] Registered tool: ${qualifiedName}`);
|
|
209
240
|
}
|
|
210
241
|
}
|
|
211
242
|
}
|
|
212
243
|
|
|
213
|
-
|
|
214
|
-
console.error(`[MCP] Connected to ${name} with ${toolsResponse?.tools?.length || 0} tools`);
|
|
215
|
-
}
|
|
244
|
+
console.error(`[MCP INFO] Connected to ${name}: ${toolCount} tool${toolCount !== 1 ? 's' : ''} loaded`);
|
|
216
245
|
|
|
217
246
|
return true;
|
|
218
247
|
} catch (error) {
|
|
219
|
-
console.error(`[MCP] Error connecting to ${name}:`, error.message);
|
|
248
|
+
console.error(`[MCP ERROR] Error connecting to ${name}:`, error.message);
|
|
249
|
+
if (this.debug) {
|
|
250
|
+
console.error(`[MCP DEBUG] Full error details:`, error);
|
|
251
|
+
}
|
|
220
252
|
return false;
|
|
221
253
|
}
|
|
222
254
|
}
|
|
@@ -239,7 +271,7 @@ export class MCPClientManager {
|
|
|
239
271
|
|
|
240
272
|
try {
|
|
241
273
|
if (this.debug) {
|
|
242
|
-
console.error(`[MCP] Calling ${toolName} with args:`, args);
|
|
274
|
+
console.error(`[MCP DEBUG] Calling ${toolName} with args:`, JSON.stringify(args, null, 2));
|
|
243
275
|
}
|
|
244
276
|
|
|
245
277
|
// Get timeout from config (default 30 seconds)
|
|
@@ -261,9 +293,16 @@ export class MCPClientManager {
|
|
|
261
293
|
timeoutPromise
|
|
262
294
|
]);
|
|
263
295
|
|
|
296
|
+
if (this.debug) {
|
|
297
|
+
console.error(`[MCP DEBUG] Tool ${toolName} executed successfully`);
|
|
298
|
+
}
|
|
299
|
+
|
|
264
300
|
return result;
|
|
265
301
|
} catch (error) {
|
|
266
|
-
console.error(`[MCP] Error calling tool ${toolName}:`, error);
|
|
302
|
+
console.error(`[MCP ERROR] Error calling tool ${toolName}:`, error.message);
|
|
303
|
+
if (this.debug) {
|
|
304
|
+
console.error(`[MCP DEBUG] Full error details:`, error);
|
|
305
|
+
}
|
|
267
306
|
throw error;
|
|
268
307
|
}
|
|
269
308
|
}
|
|
@@ -316,16 +355,27 @@ export class MCPClientManager {
|
|
|
316
355
|
async disconnect() {
|
|
317
356
|
const disconnectPromises = [];
|
|
318
357
|
|
|
358
|
+
if (this.clients.size === 0) {
|
|
359
|
+
if (this.debug) {
|
|
360
|
+
console.error('[MCP DEBUG] No MCP clients to disconnect');
|
|
361
|
+
}
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
if (this.debug) {
|
|
366
|
+
console.error(`[MCP DEBUG] Disconnecting from ${this.clients.size} MCP server${this.clients.size !== 1 ? 's' : ''}...`);
|
|
367
|
+
}
|
|
368
|
+
|
|
319
369
|
for (const [name, clientInfo] of this.clients.entries()) {
|
|
320
370
|
disconnectPromises.push(
|
|
321
371
|
clientInfo.client.close()
|
|
322
372
|
.then(() => {
|
|
323
373
|
if (this.debug) {
|
|
324
|
-
console.error(`[MCP] Disconnected from ${name}`);
|
|
374
|
+
console.error(`[MCP DEBUG] Disconnected from ${name}`);
|
|
325
375
|
}
|
|
326
376
|
})
|
|
327
377
|
.catch(error => {
|
|
328
|
-
console.error(`[MCP] Error disconnecting from ${name}:`, error);
|
|
378
|
+
console.error(`[MCP ERROR] Error disconnecting from ${name}:`, error.message);
|
|
329
379
|
})
|
|
330
380
|
);
|
|
331
381
|
}
|
|
@@ -333,6 +383,10 @@ export class MCPClientManager {
|
|
|
333
383
|
await Promise.all(disconnectPromises);
|
|
334
384
|
this.clients.clear();
|
|
335
385
|
this.tools.clear();
|
|
386
|
+
|
|
387
|
+
if (this.debug) {
|
|
388
|
+
console.error('[MCP DEBUG] All MCP connections closed');
|
|
389
|
+
}
|
|
336
390
|
}
|
|
337
391
|
}
|
|
338
392
|
|