@mcpc-tech/cli 0.1.1-beta.1 → 0.1.2
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 +38 -6
- package/app.mjs +4269 -0
- package/{src/bin.mjs → bin.mjs} +1753 -678
- package/index.mjs +4483 -0
- package/package.json +28 -23
- package/server.mjs +4470 -0
- package/types/src/app.d.ts.map +1 -1
- package/types/src/config/loader.d.ts +69 -0
- package/types/src/config/loader.d.ts.map +1 -0
package/{src/bin.mjs → bin.mjs}
RENAMED
|
@@ -9,16 +9,141 @@ var __export = (target, all) => {
|
|
|
9
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
// ../
|
|
12
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/schema.js
|
|
13
|
+
function jsonSchema(schema, options = {}) {
|
|
14
|
+
if (isWrappedSchema(schema)) {
|
|
15
|
+
return schema;
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
[schemaSymbol]: true,
|
|
19
|
+
[validatorSymbol]: true,
|
|
20
|
+
_type: void 0,
|
|
21
|
+
jsonSchema: schema,
|
|
22
|
+
validate: options.validate
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function isWrappedSchema(value) {
|
|
26
|
+
return typeof value === "object" && value !== null && schemaSymbol in value && value[schemaSymbol] === true;
|
|
27
|
+
}
|
|
28
|
+
function extractJsonSchema(schema) {
|
|
29
|
+
if (isWrappedSchema(schema)) {
|
|
30
|
+
return schema.jsonSchema;
|
|
31
|
+
}
|
|
32
|
+
return schema;
|
|
33
|
+
}
|
|
34
|
+
var schemaSymbol, validatorSymbol;
|
|
35
|
+
var init_schema = __esm({
|
|
36
|
+
"../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/schema.js"() {
|
|
37
|
+
schemaSymbol = Symbol.for("mcpc.schema");
|
|
38
|
+
validatorSymbol = Symbol.for("mcpc.validator");
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/logger.js
|
|
43
|
+
function createLogger(name, server2) {
|
|
44
|
+
return new MCPLogger(name, server2);
|
|
45
|
+
}
|
|
46
|
+
var LOG_LEVELS, MCPLogger, logger;
|
|
47
|
+
var init_logger = __esm({
|
|
48
|
+
"../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/logger.js"() {
|
|
49
|
+
LOG_LEVELS = {
|
|
50
|
+
debug: 0,
|
|
51
|
+
info: 1,
|
|
52
|
+
notice: 2,
|
|
53
|
+
warning: 3,
|
|
54
|
+
error: 4,
|
|
55
|
+
critical: 5,
|
|
56
|
+
alert: 6,
|
|
57
|
+
emergency: 7
|
|
58
|
+
};
|
|
59
|
+
MCPLogger = class _MCPLogger {
|
|
60
|
+
server;
|
|
61
|
+
loggerName;
|
|
62
|
+
minLevel = "debug";
|
|
63
|
+
constructor(loggerName = "mcpc", server2) {
|
|
64
|
+
this.loggerName = loggerName;
|
|
65
|
+
this.server = server2;
|
|
66
|
+
}
|
|
67
|
+
setServer(server2) {
|
|
68
|
+
this.server = server2;
|
|
69
|
+
}
|
|
70
|
+
setLevel(level) {
|
|
71
|
+
this.minLevel = level;
|
|
72
|
+
}
|
|
73
|
+
async log(level, data) {
|
|
74
|
+
if (LOG_LEVELS[level] < LOG_LEVELS[this.minLevel]) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
this.logToConsole(level, data);
|
|
78
|
+
if (this.server) {
|
|
79
|
+
try {
|
|
80
|
+
await this.server.sendLoggingMessage({
|
|
81
|
+
level,
|
|
82
|
+
logger: this.loggerName,
|
|
83
|
+
data
|
|
84
|
+
});
|
|
85
|
+
} catch {
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
logToConsole(level, data) {
|
|
90
|
+
const message = typeof data === "string" ? data : JSON.stringify(data);
|
|
91
|
+
const prefix = `[${this.loggerName}]`;
|
|
92
|
+
if (level === "debug") {
|
|
93
|
+
console.debug(prefix, message);
|
|
94
|
+
} else if (level === "info" || level === "notice") {
|
|
95
|
+
console.info(prefix, message);
|
|
96
|
+
} else if (level === "warning") {
|
|
97
|
+
console.warn(prefix, message);
|
|
98
|
+
} else {
|
|
99
|
+
console.error(prefix, message);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
debug(data) {
|
|
103
|
+
return this.log("debug", data);
|
|
104
|
+
}
|
|
105
|
+
info(data) {
|
|
106
|
+
return this.log("info", data);
|
|
107
|
+
}
|
|
108
|
+
notice(data) {
|
|
109
|
+
return this.log("notice", data);
|
|
110
|
+
}
|
|
111
|
+
warning(data) {
|
|
112
|
+
return this.log("warning", data);
|
|
113
|
+
}
|
|
114
|
+
error(data) {
|
|
115
|
+
return this.log("error", data);
|
|
116
|
+
}
|
|
117
|
+
critical(data) {
|
|
118
|
+
return this.log("critical", data);
|
|
119
|
+
}
|
|
120
|
+
alert(data) {
|
|
121
|
+
return this.log("alert", data);
|
|
122
|
+
}
|
|
123
|
+
emergency(data) {
|
|
124
|
+
return this.log("emergency", data);
|
|
125
|
+
}
|
|
126
|
+
child(name) {
|
|
127
|
+
const child = new _MCPLogger(`${this.loggerName}.${name}`, this.server);
|
|
128
|
+
child.setLevel(this.minLevel);
|
|
129
|
+
return child;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
logger = new MCPLogger("mcpc");
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/plugins/built-in/config-plugin.js
|
|
13
137
|
var createConfigPlugin, config_plugin_default;
|
|
14
138
|
var init_config_plugin = __esm({
|
|
15
|
-
"../
|
|
139
|
+
"../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/plugins/built-in/config-plugin.js"() {
|
|
16
140
|
createConfigPlugin = () => ({
|
|
17
141
|
name: "built-in-config",
|
|
142
|
+
version: "1.0.0",
|
|
18
143
|
enforce: "pre",
|
|
19
|
-
transformTool: (tool,
|
|
20
|
-
const server2 =
|
|
21
|
-
const config2 = server2.findToolConfig?.(
|
|
144
|
+
transformTool: (tool, context2) => {
|
|
145
|
+
const server2 = context2.server;
|
|
146
|
+
const config2 = server2.findToolConfig?.(context2.toolName);
|
|
22
147
|
if (config2?.description) {
|
|
23
148
|
tool.description = config2.description;
|
|
24
149
|
}
|
|
@@ -29,16 +154,17 @@ var init_config_plugin = __esm({
|
|
|
29
154
|
}
|
|
30
155
|
});
|
|
31
156
|
|
|
32
|
-
// ../
|
|
157
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/plugins/built-in/tool-name-mapping-plugin.js
|
|
33
158
|
var createToolNameMappingPlugin, tool_name_mapping_plugin_default;
|
|
34
159
|
var init_tool_name_mapping_plugin = __esm({
|
|
35
|
-
"../
|
|
160
|
+
"../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/plugins/built-in/tool-name-mapping-plugin.js"() {
|
|
36
161
|
createToolNameMappingPlugin = () => ({
|
|
37
162
|
name: "built-in-tool-name-mapping",
|
|
163
|
+
version: "1.0.0",
|
|
38
164
|
enforce: "pre",
|
|
39
|
-
transformTool: (tool,
|
|
40
|
-
const server2 =
|
|
41
|
-
const toolName =
|
|
165
|
+
transformTool: (tool, context2) => {
|
|
166
|
+
const server2 = context2.server;
|
|
167
|
+
const toolName = context2.toolName;
|
|
42
168
|
const dotNotation = toolName.replace(/_/g, ".");
|
|
43
169
|
const underscoreNotation = toolName.replace(/\./g, "_");
|
|
44
170
|
if (dotNotation !== toolName && server2.toolNameMapping) {
|
|
@@ -56,58 +182,37 @@ var init_tool_name_mapping_plugin = __esm({
|
|
|
56
182
|
}
|
|
57
183
|
});
|
|
58
184
|
|
|
59
|
-
// ../
|
|
185
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/plugins/built-in/logging-plugin.js
|
|
60
186
|
var createLoggingPlugin, logging_plugin_default;
|
|
61
187
|
var init_logging_plugin = __esm({
|
|
62
|
-
"../
|
|
188
|
+
"../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/plugins/built-in/logging-plugin.js"() {
|
|
189
|
+
init_logger();
|
|
63
190
|
createLoggingPlugin = (options = {}) => {
|
|
64
191
|
const { enabled = true, verbose = false, compact: compact2 = true } = options;
|
|
65
192
|
return {
|
|
66
193
|
name: "built-in-logging",
|
|
67
|
-
|
|
194
|
+
version: "1.0.0",
|
|
195
|
+
composeEnd: async (context2) => {
|
|
68
196
|
if (!enabled) return;
|
|
197
|
+
const logger2 = createLogger("mcpc.plugin.logging", context2.server);
|
|
69
198
|
if (compact2) {
|
|
70
|
-
const pluginCount =
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
const internalList = server2.getInternalToolNames();
|
|
74
|
-
const hiddenList = server2.getHiddenToolNames();
|
|
75
|
-
const publicToolNames = server2.getPublicToolNames();
|
|
76
|
-
const externalCount = externalList.length;
|
|
77
|
-
const internalCount = internalList.length;
|
|
78
|
-
const hiddenCount = hiddenList.length;
|
|
79
|
-
const globalCount = publicToolNames.length;
|
|
80
|
-
console.log(`\u{1F9E9} [${context.toolName}] ${pluginCount} plugins \u2022 ${externalCount} external \u2022 ${internalCount} internal \u2022 ${hiddenCount} hidden \u2022 ${globalCount} global`);
|
|
199
|
+
const pluginCount = context2.pluginNames.length;
|
|
200
|
+
const { stats } = context2;
|
|
201
|
+
await logger2.info(`[${context2.toolName}] ${pluginCount} plugins \u2022 ${stats.publicTools} public \u2022 ${stats.hiddenTools} hidden`);
|
|
81
202
|
} else if (verbose) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const totalSet = /* @__PURE__ */ new Set([
|
|
91
|
-
...external,
|
|
92
|
-
...internal,
|
|
93
|
-
...globalNames
|
|
94
|
-
]);
|
|
95
|
-
const totalList = Array.from(totalSet);
|
|
96
|
-
if (external.length > 0) {
|
|
97
|
-
console.log(` \u251C\u2500 External: ${external.join(", ")}`);
|
|
98
|
-
}
|
|
99
|
-
if (internal.length > 0) {
|
|
100
|
-
console.log(` \u251C\u2500 Internal: ${internal.join(", ")}`);
|
|
101
|
-
}
|
|
102
|
-
if (globalNames.length > 0) {
|
|
103
|
-
console.log(` \u251C\u2500 Global: ${globalNames.join(", ")}`);
|
|
104
|
-
}
|
|
105
|
-
if (hidden.length > 0) {
|
|
106
|
-
console.log(` \u251C\u2500 Hidden: ${hidden.join(", ")}`);
|
|
203
|
+
await logger2.info(`[${context2.toolName}] Composition complete`);
|
|
204
|
+
await logger2.info(` \u251C\u2500 Plugins: ${context2.pluginNames.join(", ")}`);
|
|
205
|
+
const { stats } = context2;
|
|
206
|
+
const server2 = context2.server;
|
|
207
|
+
const publicTools = Array.from(new Set(server2.getPublicToolNames().map(String)));
|
|
208
|
+
const hiddenTools = Array.from(new Set(server2.getHiddenToolNames().map(String)));
|
|
209
|
+
if (publicTools.length > 0) {
|
|
210
|
+
await logger2.info(` \u251C\u2500 Public: ${publicTools.join(", ")}`);
|
|
107
211
|
}
|
|
108
|
-
if (
|
|
109
|
-
|
|
212
|
+
if (hiddenTools.length > 0) {
|
|
213
|
+
await logger2.info(` \u251C\u2500 Hidden: ${hiddenTools.join(", ")}`);
|
|
110
214
|
}
|
|
215
|
+
await logger2.info(` \u2514\u2500 Total: ${stats.totalTools} tools`);
|
|
111
216
|
}
|
|
112
217
|
}
|
|
113
218
|
};
|
|
@@ -119,7 +224,7 @@ var init_logging_plugin = __esm({
|
|
|
119
224
|
}
|
|
120
225
|
});
|
|
121
226
|
|
|
122
|
-
// ../
|
|
227
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/plugins/built-in/index.js
|
|
123
228
|
var built_in_exports = {};
|
|
124
229
|
__export(built_in_exports, {
|
|
125
230
|
createConfigPlugin: () => createConfigPlugin,
|
|
@@ -135,7 +240,7 @@ function getBuiltInPlugins() {
|
|
|
135
240
|
];
|
|
136
241
|
}
|
|
137
242
|
var init_built_in = __esm({
|
|
138
|
-
"../
|
|
243
|
+
"../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/plugins/built-in/index.js"() {
|
|
139
244
|
init_config_plugin();
|
|
140
245
|
init_tool_name_mapping_plugin();
|
|
141
246
|
init_logging_plugin();
|
|
@@ -145,20 +250,362 @@ var init_built_in = __esm({
|
|
|
145
250
|
}
|
|
146
251
|
});
|
|
147
252
|
|
|
148
|
-
// ../
|
|
253
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/plugin-utils.js
|
|
254
|
+
var plugin_utils_exports = {};
|
|
255
|
+
__export(plugin_utils_exports, {
|
|
256
|
+
checkCircularDependencies: () => checkCircularDependencies,
|
|
257
|
+
clearPluginCache: () => clearPluginCache,
|
|
258
|
+
getPluginsWithHook: () => getPluginsWithHook,
|
|
259
|
+
isValidPlugin: () => isValidPlugin,
|
|
260
|
+
loadPlugin: () => loadPlugin,
|
|
261
|
+
shouldApplyPlugin: () => shouldApplyPlugin,
|
|
262
|
+
sortPluginsByOrder: () => sortPluginsByOrder,
|
|
263
|
+
validatePlugins: () => validatePlugins
|
|
264
|
+
});
|
|
265
|
+
function shouldApplyPlugin(plugin, mode) {
|
|
266
|
+
if (!plugin.apply) return true;
|
|
267
|
+
if (typeof plugin.apply === "string") {
|
|
268
|
+
return mode.includes(plugin.apply);
|
|
269
|
+
}
|
|
270
|
+
if (typeof plugin.apply === "function") {
|
|
271
|
+
try {
|
|
272
|
+
return plugin.apply(mode);
|
|
273
|
+
} catch (error) {
|
|
274
|
+
console.warn(`Plugin "${plugin.name}" apply function failed: ${error}. Defaulting to true.`);
|
|
275
|
+
return true;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return true;
|
|
279
|
+
}
|
|
280
|
+
function sortPluginsByOrder(plugins) {
|
|
281
|
+
const pluginMap = /* @__PURE__ */ new Map();
|
|
282
|
+
for (const plugin of plugins) {
|
|
283
|
+
pluginMap.set(plugin.name, plugin);
|
|
284
|
+
}
|
|
285
|
+
const visited = /* @__PURE__ */ new Set();
|
|
286
|
+
const sorted = [];
|
|
287
|
+
function visit(plugin) {
|
|
288
|
+
if (visited.has(plugin.name)) return;
|
|
289
|
+
visited.add(plugin.name);
|
|
290
|
+
if (plugin.dependencies) {
|
|
291
|
+
for (const depName of plugin.dependencies) {
|
|
292
|
+
const dep = pluginMap.get(depName);
|
|
293
|
+
if (dep) {
|
|
294
|
+
visit(dep);
|
|
295
|
+
} else {
|
|
296
|
+
console.warn(`Plugin "${plugin.name}" depends on "${depName}" which is not loaded`);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
sorted.push(plugin);
|
|
301
|
+
}
|
|
302
|
+
const prePlugins = plugins.filter((p2) => p2.enforce === "pre");
|
|
303
|
+
const normalPlugins = plugins.filter((p2) => !p2.enforce);
|
|
304
|
+
const postPlugins = plugins.filter((p2) => p2.enforce === "post");
|
|
305
|
+
[
|
|
306
|
+
...prePlugins,
|
|
307
|
+
...normalPlugins,
|
|
308
|
+
...postPlugins
|
|
309
|
+
].forEach(visit);
|
|
310
|
+
return sorted;
|
|
311
|
+
}
|
|
312
|
+
function getPluginsWithHook(plugins, hookName) {
|
|
313
|
+
return plugins.filter((p2) => typeof p2[hookName] === "function");
|
|
314
|
+
}
|
|
315
|
+
function isValidPlugin(plugin) {
|
|
316
|
+
if (!plugin || typeof plugin !== "object") return false;
|
|
317
|
+
const p2 = plugin;
|
|
318
|
+
if (!p2.name || typeof p2.name !== "string" || p2.name.trim() === "") {
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
const hasHook = typeof p2.configureServer === "function" || typeof p2.composeStart === "function" || typeof p2.transformTool === "function" || typeof p2.finalizeComposition === "function" || typeof p2.composeEnd === "function" || typeof p2.transformInput === "function" || typeof p2.transformOutput === "function" || typeof p2.dispose === "function";
|
|
322
|
+
if (!hasHook) return false;
|
|
323
|
+
if (p2.enforce && p2.enforce !== "pre" && p2.enforce !== "post") {
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
if (p2.apply && typeof p2.apply !== "string" && typeof p2.apply !== "function") {
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
if (p2.dependencies && !Array.isArray(p2.dependencies)) {
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
return true;
|
|
333
|
+
}
|
|
334
|
+
function parseQueryParams(params) {
|
|
335
|
+
const typedParams = {};
|
|
336
|
+
for (const [key, value] of Object.entries(params)) {
|
|
337
|
+
const numValue = Number(value);
|
|
338
|
+
if (!isNaN(numValue) && value.trim() !== "") {
|
|
339
|
+
typedParams[key] = numValue;
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
if (value === "true") {
|
|
343
|
+
typedParams[key] = true;
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
346
|
+
if (value === "false") {
|
|
347
|
+
typedParams[key] = false;
|
|
348
|
+
continue;
|
|
349
|
+
}
|
|
350
|
+
if (value.includes(",")) {
|
|
351
|
+
typedParams[key] = value.split(",").map((v) => v.trim());
|
|
352
|
+
continue;
|
|
353
|
+
}
|
|
354
|
+
typedParams[key] = value;
|
|
355
|
+
}
|
|
356
|
+
return typedParams;
|
|
357
|
+
}
|
|
358
|
+
async function loadPlugin(pluginPath, options = {
|
|
359
|
+
cache: true
|
|
360
|
+
}) {
|
|
361
|
+
if (options.cache && pluginCache.has(pluginPath)) {
|
|
362
|
+
return pluginCache.get(pluginPath);
|
|
363
|
+
}
|
|
364
|
+
try {
|
|
365
|
+
const [rawPath, queryString] = pluginPath.split("?", 2);
|
|
366
|
+
const searchParams = new URLSearchParams(queryString || "");
|
|
367
|
+
const params = Object.fromEntries(searchParams.entries());
|
|
368
|
+
const importPath = rawPath;
|
|
369
|
+
const pluginModule = await import(importPath);
|
|
370
|
+
const pluginFactory = pluginModule.createPlugin;
|
|
371
|
+
const defaultPlugin = pluginModule.default;
|
|
372
|
+
let plugin;
|
|
373
|
+
if (Object.keys(params).length > 0) {
|
|
374
|
+
if (typeof pluginFactory !== "function") {
|
|
375
|
+
throw new Error(`Plugin "${rawPath}" has parameters but no createPlugin export function`);
|
|
376
|
+
}
|
|
377
|
+
const typedParams = parseQueryParams(params);
|
|
378
|
+
plugin = pluginFactory(typedParams);
|
|
379
|
+
} else {
|
|
380
|
+
if (defaultPlugin) {
|
|
381
|
+
plugin = defaultPlugin;
|
|
382
|
+
} else if (typeof pluginFactory === "function") {
|
|
383
|
+
plugin = pluginFactory();
|
|
384
|
+
} else {
|
|
385
|
+
throw new Error(`Plugin "${rawPath}" has no default export or createPlugin function`);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
if (!isValidPlugin(plugin)) {
|
|
389
|
+
throw new Error(`Invalid plugin format in "${rawPath}": must have a unique name and at least one lifecycle hook`);
|
|
390
|
+
}
|
|
391
|
+
if (options.cache) {
|
|
392
|
+
pluginCache.set(pluginPath, plugin);
|
|
393
|
+
}
|
|
394
|
+
return plugin;
|
|
395
|
+
} catch (error) {
|
|
396
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
397
|
+
throw new Error(`Failed to load plugin from "${pluginPath}": ${errorMsg}`);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
function clearPluginCache() {
|
|
401
|
+
pluginCache.clear();
|
|
402
|
+
}
|
|
403
|
+
function checkCircularDependencies(plugins) {
|
|
404
|
+
const errors = [];
|
|
405
|
+
const pluginMap = /* @__PURE__ */ new Map();
|
|
406
|
+
for (const plugin of plugins) {
|
|
407
|
+
pluginMap.set(plugin.name, plugin);
|
|
408
|
+
}
|
|
409
|
+
function checkCircular(pluginName, visited, path) {
|
|
410
|
+
if (visited.has(pluginName)) {
|
|
411
|
+
const cycle = [
|
|
412
|
+
...path,
|
|
413
|
+
pluginName
|
|
414
|
+
].join(" -> ");
|
|
415
|
+
errors.push(`Circular dependency detected: ${cycle}`);
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
const plugin = pluginMap.get(pluginName);
|
|
419
|
+
if (!plugin || !plugin.dependencies) return;
|
|
420
|
+
visited.add(pluginName);
|
|
421
|
+
path.push(pluginName);
|
|
422
|
+
for (const dep of plugin.dependencies) {
|
|
423
|
+
checkCircular(dep, new Set(visited), [
|
|
424
|
+
...path
|
|
425
|
+
]);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
for (const plugin of plugins) {
|
|
429
|
+
checkCircular(plugin.name, /* @__PURE__ */ new Set(), []);
|
|
430
|
+
}
|
|
431
|
+
return errors;
|
|
432
|
+
}
|
|
433
|
+
function validatePlugins(plugins) {
|
|
434
|
+
const errors = [];
|
|
435
|
+
const names = /* @__PURE__ */ new Map();
|
|
436
|
+
for (const plugin of plugins) {
|
|
437
|
+
const count = names.get(plugin.name) || 0;
|
|
438
|
+
names.set(plugin.name, count + 1);
|
|
439
|
+
}
|
|
440
|
+
for (const [name, count] of names.entries()) {
|
|
441
|
+
if (count > 1) {
|
|
442
|
+
errors.push(`Duplicate plugin name: "${name}" (${count} instances)`);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
const circularErrors = checkCircularDependencies(plugins);
|
|
446
|
+
errors.push(...circularErrors);
|
|
447
|
+
for (const plugin of plugins) {
|
|
448
|
+
if (!isValidPlugin(plugin)) {
|
|
449
|
+
const name = plugin.name || "unknown";
|
|
450
|
+
errors.push(`Invalid plugin: "${name}"`);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
return {
|
|
454
|
+
valid: errors.length === 0,
|
|
455
|
+
errors
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
var pluginCache;
|
|
459
|
+
var init_plugin_utils = __esm({
|
|
460
|
+
"../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/plugin-utils.js"() {
|
|
461
|
+
pluginCache = /* @__PURE__ */ new Map();
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/schema.js
|
|
466
|
+
import traverse from "json-schema-traverse";
|
|
467
|
+
function updateRefPaths(schema, wrapperPath) {
|
|
468
|
+
if (!schema || typeof schema !== "object") {
|
|
469
|
+
return schema;
|
|
470
|
+
}
|
|
471
|
+
if (!wrapperPath || typeof wrapperPath !== "string") {
|
|
472
|
+
throw new Error("wrapperPath must be a non-empty string");
|
|
473
|
+
}
|
|
474
|
+
const clonedSchema = JSON.parse(JSON.stringify(schema));
|
|
475
|
+
try {
|
|
476
|
+
traverse(clonedSchema, {
|
|
477
|
+
allKeys: true,
|
|
478
|
+
cb: function(schemaNode, _jsonPtr, _rootSchema, _parentJsonPtr, _parentKeyword, _parentSchema, _keyIndex) {
|
|
479
|
+
if (schemaNode && typeof schemaNode === "object" && schemaNode.$ref) {
|
|
480
|
+
const ref = schemaNode.$ref;
|
|
481
|
+
if (ref.startsWith("#/properties/")) {
|
|
482
|
+
const relativePath = ref.substring(13);
|
|
483
|
+
schemaNode.$ref = `#/properties/${wrapperPath}/properties/${relativePath}`;
|
|
484
|
+
} else if (ref === "#") {
|
|
485
|
+
schemaNode.$ref = `#/properties/${wrapperPath}`;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
} catch (error) {
|
|
491
|
+
console.warn(`Failed to traverse schema for path "${wrapperPath}":`, error);
|
|
492
|
+
return clonedSchema;
|
|
493
|
+
}
|
|
494
|
+
return clonedSchema;
|
|
495
|
+
}
|
|
496
|
+
var init_schema2 = __esm({
|
|
497
|
+
"../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/schema.js"() {
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/compose-helpers.js
|
|
502
|
+
var compose_helpers_exports = {};
|
|
503
|
+
__export(compose_helpers_exports, {
|
|
504
|
+
buildDependencyGroups: () => buildDependencyGroups,
|
|
505
|
+
processToolsWithPlugins: () => processToolsWithPlugins,
|
|
506
|
+
registerGlobalTools: () => registerGlobalTools
|
|
507
|
+
});
|
|
508
|
+
async function processToolsWithPlugins(server2, externalTools, mode) {
|
|
509
|
+
const toolManager = server2.toolManager;
|
|
510
|
+
const pluginManager = server2.pluginManager;
|
|
511
|
+
for (const [toolId, toolData] of toolManager.getToolEntries()) {
|
|
512
|
+
const defaultSchema = {
|
|
513
|
+
type: "object",
|
|
514
|
+
properties: {},
|
|
515
|
+
additionalProperties: true
|
|
516
|
+
};
|
|
517
|
+
const tempTool = {
|
|
518
|
+
name: toolId,
|
|
519
|
+
description: toolData.description,
|
|
520
|
+
inputSchema: toolData.schema || defaultSchema,
|
|
521
|
+
execute: toolData.callback
|
|
522
|
+
};
|
|
523
|
+
const processedTool = await pluginManager.applyTransformToolHooks(tempTool, {
|
|
524
|
+
toolName: toolId,
|
|
525
|
+
server: server2,
|
|
526
|
+
mode,
|
|
527
|
+
originalTool: {
|
|
528
|
+
...tempTool
|
|
529
|
+
},
|
|
530
|
+
transformationIndex: 0
|
|
531
|
+
});
|
|
532
|
+
toolManager.registerTool(toolId, processedTool.description || toolData.description, processedTool.inputSchema, processedTool.execute);
|
|
533
|
+
if (externalTools[toolId]) {
|
|
534
|
+
try {
|
|
535
|
+
const builtIn = await Promise.resolve().then(() => (init_built_in(), built_in_exports));
|
|
536
|
+
if (builtIn && typeof builtIn.processToolVisibility === "function") {
|
|
537
|
+
builtIn.processToolVisibility(toolId, processedTool, server2, externalTools);
|
|
538
|
+
}
|
|
539
|
+
} catch {
|
|
540
|
+
}
|
|
541
|
+
externalTools[toolId] = processedTool;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
function buildDependencyGroups(toolNameToDetailList, hiddenToolNames, publicToolNames, server2) {
|
|
546
|
+
const depGroups = {};
|
|
547
|
+
const toolManager = server2.toolManager;
|
|
548
|
+
toolNameToDetailList.forEach(([toolName, tool]) => {
|
|
549
|
+
const resolvedName = toolManager.resolveToolName(toolName);
|
|
550
|
+
if (hiddenToolNames.includes(resolvedName ?? "") || publicToolNames.includes(resolvedName ?? "")) {
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
if (!tool) {
|
|
554
|
+
const allToolNames = [
|
|
555
|
+
...toolNameToDetailList.map(([n]) => n)
|
|
556
|
+
];
|
|
557
|
+
throw new Error(`Action ${toolName} not found, available action list: ${allToolNames.join(", ")}`);
|
|
558
|
+
}
|
|
559
|
+
const baseSchema = tool.inputSchema.jsonSchema ?? tool.inputSchema ?? {
|
|
560
|
+
type: "object",
|
|
561
|
+
properties: {},
|
|
562
|
+
required: []
|
|
563
|
+
};
|
|
564
|
+
const baseProperties = baseSchema.type === "object" && baseSchema.properties ? baseSchema.properties : {};
|
|
565
|
+
const baseRequired = baseSchema.type === "object" && Array.isArray(baseSchema.required) ? baseSchema.required : [];
|
|
566
|
+
const updatedProperties = updateRefPaths(baseProperties, toolName);
|
|
567
|
+
depGroups[toolName] = {
|
|
568
|
+
type: "object",
|
|
569
|
+
description: tool.description,
|
|
570
|
+
properties: updatedProperties,
|
|
571
|
+
required: [
|
|
572
|
+
...baseRequired
|
|
573
|
+
],
|
|
574
|
+
additionalProperties: false
|
|
575
|
+
};
|
|
576
|
+
});
|
|
577
|
+
return depGroups;
|
|
578
|
+
}
|
|
579
|
+
function registerGlobalTools(globalToolNames, tools, server2) {
|
|
580
|
+
globalToolNames.forEach((toolId) => {
|
|
581
|
+
const tool = tools[toolId];
|
|
582
|
+
if (!tool) {
|
|
583
|
+
throw new Error(`Global tool ${toolId} not found in registry, available: ${Object.keys(tools).join(", ")}`);
|
|
584
|
+
}
|
|
585
|
+
server2.tool(toolId, tool.description || "No description available", jsonSchema(tool.inputSchema), tool.execute);
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
var init_compose_helpers = __esm({
|
|
589
|
+
"../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/compose-helpers.js"() {
|
|
590
|
+
init_schema2();
|
|
591
|
+
init_schema();
|
|
592
|
+
}
|
|
593
|
+
});
|
|
594
|
+
|
|
595
|
+
// ../__mcpc__cli_latest/node_modules/@mcpc/cli/src/bin.ts
|
|
149
596
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
150
597
|
|
|
151
|
-
// ../
|
|
598
|
+
// ../__mcpc__cli_latest/node_modules/@mcpc/cli/src/app.js
|
|
152
599
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
153
600
|
|
|
154
|
-
// ../
|
|
601
|
+
// ../__mcpc__cli_latest/node_modules/@mcpc/cli/src/controllers/messages.controller.js
|
|
155
602
|
import { createRoute } from "@hono/zod-openapi";
|
|
156
603
|
import { z } from "zod";
|
|
157
604
|
|
|
158
|
-
// ../
|
|
605
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__utils/src/transport/sse.js
|
|
159
606
|
import { JSONRPCMessageSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
160
607
|
|
|
161
|
-
// ../
|
|
608
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/std__http/server_sent_event_stream.js
|
|
162
609
|
var NEWLINE_REGEXP = /\r\n|\r|\n/;
|
|
163
610
|
var encoder = new TextEncoder();
|
|
164
611
|
function assertHasNoNewline(value, varName, errPrefix) {
|
|
@@ -196,37 +643,50 @@ var ServerSentEventStream = class extends TransformStream {
|
|
|
196
643
|
}
|
|
197
644
|
};
|
|
198
645
|
|
|
199
|
-
// ../
|
|
646
|
+
// ../__mcpc__cli_latest/node_modules/@mcpc/cli/src/controllers/sse.controller.js
|
|
200
647
|
import { createRoute as createRoute2, z as z2 } from "@hono/zod-openapi";
|
|
201
648
|
|
|
202
|
-
// ../
|
|
203
|
-
|
|
204
|
-
import {
|
|
649
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/compose.js
|
|
650
|
+
init_schema();
|
|
651
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, SetLevelRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
205
652
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
206
653
|
|
|
207
|
-
// ../
|
|
654
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__utils/src/json.js
|
|
208
655
|
import { jsonrepair } from "jsonrepair";
|
|
656
|
+
function stripMarkdownAndText(text) {
|
|
657
|
+
text = text.trim();
|
|
658
|
+
text = text.replace(/^```(?:json)?\s*\n?/i, "");
|
|
659
|
+
text = text.replace(/\n?```\s*$/, "");
|
|
660
|
+
text = text.replace(/^(?:here is|here's|response|result|output|json):\s*/i, "");
|
|
661
|
+
const jsonMatch = text.match(/(\{[\s\S]*\}|\[[\s\S]*\])/);
|
|
662
|
+
if (jsonMatch) {
|
|
663
|
+
text = jsonMatch[1];
|
|
664
|
+
}
|
|
665
|
+
return text.trim();
|
|
666
|
+
}
|
|
209
667
|
function parseJSON(text, throwError) {
|
|
210
668
|
try {
|
|
211
669
|
return JSON.parse(text);
|
|
212
670
|
} catch (_error) {
|
|
213
671
|
try {
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
672
|
+
const cleanedText = stripMarkdownAndText(text);
|
|
673
|
+
try {
|
|
674
|
+
return JSON.parse(cleanedText);
|
|
675
|
+
} catch {
|
|
676
|
+
const repairedText = jsonrepair(cleanedText);
|
|
677
|
+
console.warn(`Failed to parse JSON, cleaned and repaired. Original: ${text.slice(0, 100)}...`);
|
|
678
|
+
return JSON.parse(repairedText);
|
|
218
679
|
}
|
|
219
|
-
|
|
220
|
-
} catch {
|
|
680
|
+
} catch (_repairError) {
|
|
221
681
|
if (throwError) {
|
|
222
|
-
throw new Error(
|
|
682
|
+
throw new Error(`Failed to parse JSON after cleanup and repair. Original error: ${_error instanceof Error ? _error.message : String(_error)}`);
|
|
223
683
|
}
|
|
224
684
|
return null;
|
|
225
685
|
}
|
|
226
686
|
}
|
|
227
687
|
}
|
|
228
688
|
|
|
229
|
-
// ../
|
|
689
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__utils/src/ai.js
|
|
230
690
|
var p = (template, options = {}) => {
|
|
231
691
|
const { missingVariableHandling = "warn" } = options;
|
|
232
692
|
const names = /* @__PURE__ */ new Set();
|
|
@@ -262,7 +722,7 @@ var p = (template, options = {}) => {
|
|
|
262
722
|
};
|
|
263
723
|
};
|
|
264
724
|
|
|
265
|
-
// ../
|
|
725
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__utils/src/tool-tags.js
|
|
266
726
|
import { load } from "cheerio";
|
|
267
727
|
function parseTags(htmlString, tags) {
|
|
268
728
|
const $ = load(htmlString, {
|
|
@@ -281,13 +741,13 @@ function parseTags(htmlString, tags) {
|
|
|
281
741
|
};
|
|
282
742
|
}
|
|
283
743
|
|
|
284
|
-
// ../
|
|
744
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/mcp.js
|
|
285
745
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
286
746
|
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
287
747
|
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
288
748
|
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
289
749
|
|
|
290
|
-
// ../
|
|
750
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/registory.js
|
|
291
751
|
function connectToSmitheryServer(smitheryConfig) {
|
|
292
752
|
const serverUrl = new URL(smitheryConfig.deploymentUrl);
|
|
293
753
|
serverUrl.searchParams.set("config", btoa(JSON.stringify(smitheryConfig.config)));
|
|
@@ -312,7 +772,7 @@ function smitheryToolNameCompatibale(name, scope) {
|
|
|
312
772
|
};
|
|
313
773
|
}
|
|
314
774
|
|
|
315
|
-
// ../
|
|
775
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/mcp.js
|
|
316
776
|
import { cwd } from "node:process";
|
|
317
777
|
import process2 from "node:process";
|
|
318
778
|
import { createHash } from "node:crypto";
|
|
@@ -475,50 +935,18 @@ async function composeMcpDepTools(mcpConfig, filterIn) {
|
|
|
475
935
|
};
|
|
476
936
|
}
|
|
477
937
|
|
|
478
|
-
// ../
|
|
479
|
-
|
|
480
|
-
function updateRefPaths(schema, wrapperPath) {
|
|
481
|
-
if (!schema || typeof schema !== "object") {
|
|
482
|
-
return schema;
|
|
483
|
-
}
|
|
484
|
-
if (!wrapperPath || typeof wrapperPath !== "string") {
|
|
485
|
-
throw new Error("wrapperPath must be a non-empty string");
|
|
486
|
-
}
|
|
487
|
-
const clonedSchema = JSON.parse(JSON.stringify(schema));
|
|
488
|
-
try {
|
|
489
|
-
traverse(clonedSchema, {
|
|
490
|
-
allKeys: true,
|
|
491
|
-
cb: function(schemaNode, _jsonPtr, _rootSchema, _parentJsonPtr, _parentKeyword, _parentSchema, _keyIndex) {
|
|
492
|
-
if (schemaNode && typeof schemaNode === "object" && schemaNode.$ref) {
|
|
493
|
-
const ref = schemaNode.$ref;
|
|
494
|
-
if (ref.startsWith("#/properties/")) {
|
|
495
|
-
const relativePath = ref.substring(13);
|
|
496
|
-
schemaNode.$ref = `#/properties/${wrapperPath}/properties/${relativePath}`;
|
|
497
|
-
} else if (ref === "#") {
|
|
498
|
-
schemaNode.$ref = `#/properties/${wrapperPath}`;
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
});
|
|
503
|
-
} catch (error) {
|
|
504
|
-
console.warn(`Failed to traverse schema for path "${wrapperPath}":`, error);
|
|
505
|
-
return clonedSchema;
|
|
506
|
-
}
|
|
507
|
-
return clonedSchema;
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
// ../__mcpc__cli_0.1.1-beta.1/node_modules/@jsr/mcpc__core/src/executors/agentic/agentic-tool-registrar.js
|
|
511
|
-
import { jsonSchema } from "ai";
|
|
938
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/executors/agentic/agentic-tool-registrar.js
|
|
939
|
+
init_schema();
|
|
512
940
|
|
|
513
|
-
// ../
|
|
941
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/config.js
|
|
514
942
|
import process3 from "node:process";
|
|
515
943
|
var GEMINI_PREFERRED_FORMAT = process3.env.GEMINI_PREFERRED_FORMAT === "0" ? false : true;
|
|
516
944
|
|
|
517
|
-
// ../
|
|
945
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/json.js
|
|
518
946
|
import { jsonrepair as jsonrepair2 } from "jsonrepair";
|
|
519
947
|
import { inspect } from "node:util";
|
|
520
948
|
|
|
521
|
-
// ../
|
|
949
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/provider.js
|
|
522
950
|
var createGoogleCompatibleJSONSchema = (schema) => {
|
|
523
951
|
if (!GEMINI_PREFERRED_FORMAT) {
|
|
524
952
|
return schema;
|
|
@@ -542,7 +970,7 @@ var createGoogleCompatibleJSONSchema = (schema) => {
|
|
|
542
970
|
return removeAdditionalProperties(cleanSchema);
|
|
543
971
|
};
|
|
544
972
|
|
|
545
|
-
// ../
|
|
973
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/prompts/index.js
|
|
546
974
|
var SystemPrompts = {
|
|
547
975
|
/**
|
|
548
976
|
* Base system prompt for autonomous MCP execution
|
|
@@ -884,10 +1312,81 @@ ${JSON.stringify(steps, null, 2)}`;
|
|
|
884
1312
|
}
|
|
885
1313
|
};
|
|
886
1314
|
|
|
887
|
-
// ../
|
|
1315
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/executors/agentic/agentic-executor.js
|
|
888
1316
|
import { Ajv } from "ajv";
|
|
889
1317
|
import { AggregateAjvError } from "@segment/ajv-human-errors";
|
|
890
1318
|
import addFormats from "ajv-formats";
|
|
1319
|
+
init_logger();
|
|
1320
|
+
|
|
1321
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/tracing.js
|
|
1322
|
+
import { context, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
1323
|
+
import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
|
|
1324
|
+
import { BatchSpanProcessor, ConsoleSpanExporter, SimpleSpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
1325
|
+
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
|
|
1326
|
+
import { Resource } from "@opentelemetry/resources";
|
|
1327
|
+
import { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION } from "@opentelemetry/semantic-conventions";
|
|
1328
|
+
var tracerProvider = null;
|
|
1329
|
+
var tracer = null;
|
|
1330
|
+
var isInitialized = false;
|
|
1331
|
+
function initializeTracing(config2 = {}) {
|
|
1332
|
+
if (isInitialized) {
|
|
1333
|
+
return;
|
|
1334
|
+
}
|
|
1335
|
+
const { enabled = true, serviceName = "mcpc-sampling", serviceVersion = "0.2.0", exportTo = "console", otlpEndpoint = "http://localhost:4318/v1/traces", otlpHeaders = {} } = config2;
|
|
1336
|
+
if (!enabled) {
|
|
1337
|
+
isInitialized = true;
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1340
|
+
const resource = Resource.default().merge(new Resource({
|
|
1341
|
+
[ATTR_SERVICE_NAME]: serviceName,
|
|
1342
|
+
[ATTR_SERVICE_VERSION]: serviceVersion
|
|
1343
|
+
}));
|
|
1344
|
+
tracerProvider = new NodeTracerProvider({
|
|
1345
|
+
resource
|
|
1346
|
+
});
|
|
1347
|
+
if (exportTo === "console") {
|
|
1348
|
+
tracerProvider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
|
|
1349
|
+
} else if (exportTo === "otlp") {
|
|
1350
|
+
const otlpExporter = new OTLPTraceExporter({
|
|
1351
|
+
url: otlpEndpoint,
|
|
1352
|
+
headers: otlpHeaders
|
|
1353
|
+
});
|
|
1354
|
+
tracerProvider.addSpanProcessor(new BatchSpanProcessor(otlpExporter));
|
|
1355
|
+
}
|
|
1356
|
+
tracerProvider.register();
|
|
1357
|
+
tracer = trace.getTracer(serviceName, serviceVersion);
|
|
1358
|
+
isInitialized = true;
|
|
1359
|
+
}
|
|
1360
|
+
function getTracer() {
|
|
1361
|
+
if (!isInitialized) {
|
|
1362
|
+
initializeTracing();
|
|
1363
|
+
}
|
|
1364
|
+
return tracer;
|
|
1365
|
+
}
|
|
1366
|
+
function startSpan(name, attributes, parent) {
|
|
1367
|
+
const tracer2 = getTracer();
|
|
1368
|
+
const ctx = parent ? trace.setSpan(context.active(), parent) : void 0;
|
|
1369
|
+
return tracer2.startSpan(name, {
|
|
1370
|
+
attributes
|
|
1371
|
+
}, ctx);
|
|
1372
|
+
}
|
|
1373
|
+
function endSpan(span, error) {
|
|
1374
|
+
if (error) {
|
|
1375
|
+
span.setStatus({
|
|
1376
|
+
code: SpanStatusCode.ERROR,
|
|
1377
|
+
message: error.message
|
|
1378
|
+
});
|
|
1379
|
+
span.recordException(error);
|
|
1380
|
+
} else {
|
|
1381
|
+
span.setStatus({
|
|
1382
|
+
code: SpanStatusCode.OK
|
|
1383
|
+
});
|
|
1384
|
+
}
|
|
1385
|
+
span.end();
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/executors/agentic/agentic-executor.js
|
|
1389
|
+
import process4 from "node:process";
|
|
891
1390
|
var ajv = new Ajv({
|
|
892
1391
|
allErrors: true,
|
|
893
1392
|
verbose: true
|
|
@@ -900,6 +1399,8 @@ var AgenticExecutor = class {
|
|
|
900
1399
|
server;
|
|
901
1400
|
ACTION_KEY;
|
|
902
1401
|
NEXT_ACTION_KEY;
|
|
1402
|
+
logger;
|
|
1403
|
+
tracingEnabled;
|
|
903
1404
|
constructor(name, allToolNames, toolNameToDetailList, server2, ACTION_KEY = "action", NEXT_ACTION_KEY = "nextAction") {
|
|
904
1405
|
this.name = name;
|
|
905
1406
|
this.allToolNames = allToolNames;
|
|
@@ -907,93 +1408,216 @@ var AgenticExecutor = class {
|
|
|
907
1408
|
this.server = server2;
|
|
908
1409
|
this.ACTION_KEY = ACTION_KEY;
|
|
909
1410
|
this.NEXT_ACTION_KEY = NEXT_ACTION_KEY;
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
})
|
|
921
|
-
}
|
|
922
|
-
],
|
|
923
|
-
isError: true
|
|
924
|
-
};
|
|
925
|
-
}
|
|
926
|
-
const actionName = args[this.ACTION_KEY];
|
|
927
|
-
const currentTool = this.toolNameToDetailList.find(([name, _detail]) => name === actionName)?.[1];
|
|
928
|
-
if (currentTool) {
|
|
929
|
-
const nextAction = args[this.NEXT_ACTION_KEY];
|
|
930
|
-
const currentResult = await currentTool.execute({
|
|
931
|
-
...args[actionName]
|
|
932
|
-
});
|
|
933
|
-
if (args[nextAction]) {
|
|
934
|
-
currentResult?.content?.push({
|
|
935
|
-
type: "text",
|
|
936
|
-
text: CompiledPrompts.actionSuccess({
|
|
937
|
-
toolName: this.name,
|
|
938
|
-
nextAction,
|
|
939
|
-
currentAction: actionName
|
|
940
|
-
})
|
|
941
|
-
});
|
|
942
|
-
} else {
|
|
943
|
-
currentResult?.content?.push({
|
|
944
|
-
type: "text",
|
|
945
|
-
text: CompiledPrompts.planningPrompt({
|
|
946
|
-
currentAction: actionName
|
|
947
|
-
})
|
|
1411
|
+
this.tracingEnabled = false;
|
|
1412
|
+
this.logger = createLogger(`mcpc.agentic.${name}`, server2);
|
|
1413
|
+
try {
|
|
1414
|
+
this.tracingEnabled = process4.env.MCPC_TRACING_ENABLED === "true";
|
|
1415
|
+
if (this.tracingEnabled) {
|
|
1416
|
+
initializeTracing({
|
|
1417
|
+
enabled: true,
|
|
1418
|
+
serviceName: `mcpc-agentic-${name}`,
|
|
1419
|
+
exportTo: process4.env.MCPC_TRACING_EXPORT ?? "otlp",
|
|
1420
|
+
otlpEndpoint: process4.env.MCPC_TRACING_OTLP_ENDPOINT ?? "http://localhost:4318/v1/traces"
|
|
948
1421
|
});
|
|
949
1422
|
}
|
|
950
|
-
|
|
1423
|
+
} catch {
|
|
1424
|
+
this.tracingEnabled = false;
|
|
951
1425
|
}
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
});
|
|
968
|
-
} else {
|
|
969
|
-
callToolResult.content.push({
|
|
970
|
-
type: "text",
|
|
971
|
-
text: CompiledPrompts.planningPrompt({
|
|
972
|
-
currentAction: actionName
|
|
973
|
-
})
|
|
1426
|
+
}
|
|
1427
|
+
async execute(args, schema) {
|
|
1428
|
+
const executeSpan = this.tracingEnabled ? startSpan("mcpc.agentic_execute", {
|
|
1429
|
+
agent: this.name,
|
|
1430
|
+
action: String(args[this.ACTION_KEY] ?? "unknown"),
|
|
1431
|
+
nextAction: String(args[this.NEXT_ACTION_KEY] ?? "none"),
|
|
1432
|
+
args: JSON.stringify(args)
|
|
1433
|
+
}) : null;
|
|
1434
|
+
try {
|
|
1435
|
+
const validationResult = this.validate(args, schema);
|
|
1436
|
+
if (!validationResult.valid) {
|
|
1437
|
+
if (executeSpan) {
|
|
1438
|
+
executeSpan.setAttributes({
|
|
1439
|
+
validationError: true,
|
|
1440
|
+
errorMessage: validationResult.error || "Validation failed"
|
|
974
1441
|
});
|
|
1442
|
+
endSpan(executeSpan);
|
|
975
1443
|
}
|
|
976
|
-
|
|
977
|
-
|
|
1444
|
+
this.logger.warning({
|
|
1445
|
+
message: "Validation failed",
|
|
1446
|
+
action: args[this.ACTION_KEY],
|
|
1447
|
+
error: validationResult.error
|
|
1448
|
+
});
|
|
978
1449
|
return {
|
|
979
1450
|
content: [
|
|
980
1451
|
{
|
|
981
1452
|
type: "text",
|
|
982
|
-
text:
|
|
1453
|
+
text: CompiledPrompts.errorResponse({
|
|
1454
|
+
errorMessage: validationResult.error || "Validation failed"
|
|
1455
|
+
})
|
|
983
1456
|
}
|
|
984
1457
|
],
|
|
985
1458
|
isError: true
|
|
986
1459
|
};
|
|
987
1460
|
}
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
1461
|
+
const actionName = args[this.ACTION_KEY];
|
|
1462
|
+
if (executeSpan && actionName) {
|
|
1463
|
+
try {
|
|
1464
|
+
const safeAction = String(actionName).replace(/\s+/g, "_");
|
|
1465
|
+
if (typeof executeSpan.updateName === "function") {
|
|
1466
|
+
executeSpan.updateName(`mcpc.agentic_execute.${safeAction}`);
|
|
1467
|
+
}
|
|
1468
|
+
} catch {
|
|
994
1469
|
}
|
|
995
|
-
|
|
996
|
-
|
|
1470
|
+
}
|
|
1471
|
+
const currentTool = this.toolNameToDetailList.find(([name, _detail]) => name === actionName)?.[1];
|
|
1472
|
+
if (currentTool) {
|
|
1473
|
+
const nextAction = args[this.NEXT_ACTION_KEY];
|
|
1474
|
+
if (executeSpan) {
|
|
1475
|
+
executeSpan.setAttributes({
|
|
1476
|
+
toolType: "external",
|
|
1477
|
+
actionName,
|
|
1478
|
+
nextAction: nextAction || "none"
|
|
1479
|
+
});
|
|
1480
|
+
}
|
|
1481
|
+
this.logger.debug({
|
|
1482
|
+
message: "Executing external tool",
|
|
1483
|
+
action: actionName,
|
|
1484
|
+
nextAction
|
|
1485
|
+
});
|
|
1486
|
+
const currentResult = await currentTool.execute({
|
|
1487
|
+
...args[actionName]
|
|
1488
|
+
});
|
|
1489
|
+
if (args[nextAction]) {
|
|
1490
|
+
currentResult?.content?.push({
|
|
1491
|
+
type: "text",
|
|
1492
|
+
text: CompiledPrompts.actionSuccess({
|
|
1493
|
+
toolName: this.name,
|
|
1494
|
+
nextAction,
|
|
1495
|
+
currentAction: actionName
|
|
1496
|
+
})
|
|
1497
|
+
});
|
|
1498
|
+
} else {
|
|
1499
|
+
currentResult?.content?.push({
|
|
1500
|
+
type: "text",
|
|
1501
|
+
text: CompiledPrompts.planningPrompt({
|
|
1502
|
+
currentAction: actionName
|
|
1503
|
+
})
|
|
1504
|
+
});
|
|
1505
|
+
}
|
|
1506
|
+
if (executeSpan) {
|
|
1507
|
+
executeSpan.setAttributes({
|
|
1508
|
+
success: true,
|
|
1509
|
+
isError: !!currentResult.isError,
|
|
1510
|
+
resultContentLength: currentResult.content?.length || 0,
|
|
1511
|
+
hasNextAction: !!args[nextAction],
|
|
1512
|
+
toolResult: JSON.stringify(currentResult)
|
|
1513
|
+
});
|
|
1514
|
+
endSpan(executeSpan);
|
|
1515
|
+
}
|
|
1516
|
+
return currentResult;
|
|
1517
|
+
}
|
|
1518
|
+
if (this.allToolNames.includes(actionName)) {
|
|
1519
|
+
if (executeSpan) {
|
|
1520
|
+
executeSpan.setAttributes({
|
|
1521
|
+
toolType: "internal",
|
|
1522
|
+
actionName
|
|
1523
|
+
});
|
|
1524
|
+
}
|
|
1525
|
+
this.logger.debug({
|
|
1526
|
+
message: "Executing internal tool",
|
|
1527
|
+
action: actionName
|
|
1528
|
+
});
|
|
1529
|
+
try {
|
|
1530
|
+
const result = await this.server.callTool(actionName, args[actionName]);
|
|
1531
|
+
const nextAction = args[this.NEXT_ACTION_KEY];
|
|
1532
|
+
const callToolResult = result ?? {
|
|
1533
|
+
content: []
|
|
1534
|
+
};
|
|
1535
|
+
if (nextAction && this.allToolNames.includes(nextAction)) {
|
|
1536
|
+
callToolResult.content.push({
|
|
1537
|
+
type: "text",
|
|
1538
|
+
text: CompiledPrompts.actionSuccess({
|
|
1539
|
+
toolName: this.name,
|
|
1540
|
+
nextAction,
|
|
1541
|
+
currentAction: actionName
|
|
1542
|
+
})
|
|
1543
|
+
});
|
|
1544
|
+
} else {
|
|
1545
|
+
callToolResult.content.push({
|
|
1546
|
+
type: "text",
|
|
1547
|
+
text: CompiledPrompts.planningPrompt({
|
|
1548
|
+
currentAction: actionName
|
|
1549
|
+
})
|
|
1550
|
+
});
|
|
1551
|
+
}
|
|
1552
|
+
if (executeSpan) {
|
|
1553
|
+
executeSpan.setAttributes({
|
|
1554
|
+
success: true,
|
|
1555
|
+
isError: !!callToolResult.isError,
|
|
1556
|
+
resultContentLength: callToolResult.content?.length || 0,
|
|
1557
|
+
hasNextAction: !!(nextAction && this.allToolNames.includes(nextAction)),
|
|
1558
|
+
toolResult: JSON.stringify(callToolResult)
|
|
1559
|
+
});
|
|
1560
|
+
endSpan(executeSpan);
|
|
1561
|
+
}
|
|
1562
|
+
return callToolResult;
|
|
1563
|
+
} catch (error) {
|
|
1564
|
+
if (executeSpan) {
|
|
1565
|
+
endSpan(executeSpan, error);
|
|
1566
|
+
}
|
|
1567
|
+
this.logger.error({
|
|
1568
|
+
message: "Error executing internal tool",
|
|
1569
|
+
action: actionName,
|
|
1570
|
+
error: String(error)
|
|
1571
|
+
});
|
|
1572
|
+
return {
|
|
1573
|
+
content: [
|
|
1574
|
+
{
|
|
1575
|
+
type: "text",
|
|
1576
|
+
text: `Error executing internal tool ${actionName}: ${error instanceof Error ? error.message : String(error)}`
|
|
1577
|
+
}
|
|
1578
|
+
],
|
|
1579
|
+
isError: true
|
|
1580
|
+
};
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
if (executeSpan) {
|
|
1584
|
+
executeSpan.setAttributes({
|
|
1585
|
+
toolType: "not_found",
|
|
1586
|
+
actionName: actionName || "unknown",
|
|
1587
|
+
completion: true
|
|
1588
|
+
});
|
|
1589
|
+
endSpan(executeSpan);
|
|
1590
|
+
}
|
|
1591
|
+
this.logger.debug({
|
|
1592
|
+
message: "Tool not found, returning completion message",
|
|
1593
|
+
action: actionName
|
|
1594
|
+
});
|
|
1595
|
+
return {
|
|
1596
|
+
content: [
|
|
1597
|
+
{
|
|
1598
|
+
type: "text",
|
|
1599
|
+
text: CompiledPrompts.completionMessage()
|
|
1600
|
+
}
|
|
1601
|
+
]
|
|
1602
|
+
};
|
|
1603
|
+
} catch (error) {
|
|
1604
|
+
if (executeSpan) {
|
|
1605
|
+
endSpan(executeSpan, error);
|
|
1606
|
+
}
|
|
1607
|
+
this.logger.error({
|
|
1608
|
+
message: "Unexpected error in execute",
|
|
1609
|
+
error: String(error)
|
|
1610
|
+
});
|
|
1611
|
+
return {
|
|
1612
|
+
content: [
|
|
1613
|
+
{
|
|
1614
|
+
type: "text",
|
|
1615
|
+
text: `Unexpected error: ${error instanceof Error ? error.message : String(error)}`
|
|
1616
|
+
}
|
|
1617
|
+
],
|
|
1618
|
+
isError: true
|
|
1619
|
+
};
|
|
1620
|
+
}
|
|
997
1621
|
}
|
|
998
1622
|
// Validate arguments using JSON schema
|
|
999
1623
|
validate(args, schema) {
|
|
@@ -1016,7 +1640,7 @@ var AgenticExecutor = class {
|
|
|
1016
1640
|
}
|
|
1017
1641
|
};
|
|
1018
1642
|
|
|
1019
|
-
// ../
|
|
1643
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/es-toolkit__es-toolkit/src/function/partial.js
|
|
1020
1644
|
function partial(func, ...partialArgs) {
|
|
1021
1645
|
return partialImpl(func, placeholderSymbol, ...partialArgs);
|
|
1022
1646
|
}
|
|
@@ -1035,7 +1659,7 @@ function partialImpl(func, placeholder, ...partialArgs) {
|
|
|
1035
1659
|
var placeholderSymbol = Symbol("partial.placeholder");
|
|
1036
1660
|
partial.placeholder = placeholderSymbol;
|
|
1037
1661
|
|
|
1038
|
-
// ../
|
|
1662
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/es-toolkit__es-toolkit/src/function/partialRight.js
|
|
1039
1663
|
function partialRight(func, ...partialArgs) {
|
|
1040
1664
|
return partialRightImpl(func, placeholderSymbol2, ...partialArgs);
|
|
1041
1665
|
}
|
|
@@ -1056,10 +1680,10 @@ function partialRightImpl(func, placeholder, ...partialArgs) {
|
|
|
1056
1680
|
var placeholderSymbol2 = Symbol("partialRight.placeholder");
|
|
1057
1681
|
partialRight.placeholder = placeholderSymbol2;
|
|
1058
1682
|
|
|
1059
|
-
// ../
|
|
1683
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/es-toolkit__es-toolkit/src/function/retry.js
|
|
1060
1684
|
var DEFAULT_RETRIES = Number.POSITIVE_INFINITY;
|
|
1061
1685
|
|
|
1062
|
-
// ../
|
|
1686
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/es-toolkit__es-toolkit/src/object/pick.js
|
|
1063
1687
|
function pick(obj, keys) {
|
|
1064
1688
|
const result = {};
|
|
1065
1689
|
for (let i = 0; i < keys.length; i++) {
|
|
@@ -1071,7 +1695,7 @@ function pick(obj, keys) {
|
|
|
1071
1695
|
return result;
|
|
1072
1696
|
}
|
|
1073
1697
|
|
|
1074
|
-
// ../
|
|
1698
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/es-toolkit__es-toolkit/src/string/deburr.js
|
|
1075
1699
|
var deburrMap = new Map(
|
|
1076
1700
|
// eslint-disable-next-line no-restricted-syntax
|
|
1077
1701
|
Object.entries({
|
|
@@ -1107,7 +1731,7 @@ var deburrMap = new Map(
|
|
|
1107
1731
|
})
|
|
1108
1732
|
);
|
|
1109
1733
|
|
|
1110
|
-
// ../
|
|
1734
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/factories/args-def-factory.js
|
|
1111
1735
|
var DECISION_OPTIONS = {
|
|
1112
1736
|
RETRY: "retry",
|
|
1113
1737
|
PROCEED: "proceed",
|
|
@@ -1234,10 +1858,16 @@ Workflow step definitions - provide ONLY on initial call.
|
|
|
1234
1858
|
userRequest: {
|
|
1235
1859
|
type: "string",
|
|
1236
1860
|
description: "The task or request that should be completed autonomously by the agentic system using available tools"
|
|
1861
|
+
},
|
|
1862
|
+
context: {
|
|
1863
|
+
type: "object",
|
|
1864
|
+
description: "Necessary context for the request, e.g., the absolute path of the current working directory. This is just an example; any relevant context fields are allowed.",
|
|
1865
|
+
additionalProperties: true
|
|
1237
1866
|
}
|
|
1238
1867
|
},
|
|
1239
1868
|
required: [
|
|
1240
|
-
"userRequest"
|
|
1869
|
+
"userRequest",
|
|
1870
|
+
"context"
|
|
1241
1871
|
]
|
|
1242
1872
|
};
|
|
1243
1873
|
},
|
|
@@ -1332,11 +1962,12 @@ NOTE: The \`steps\` has been predefined` : `**You MUST execute this tool with fo
|
|
|
1332
1962
|
};
|
|
1333
1963
|
}
|
|
1334
1964
|
|
|
1335
|
-
// ../
|
|
1965
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/executors/sampling/base-sampling-executor.js
|
|
1336
1966
|
import { Ajv as Ajv2 } from "ajv";
|
|
1337
1967
|
import { AggregateAjvError as AggregateAjvError2 } from "@segment/ajv-human-errors";
|
|
1338
1968
|
import addFormats2 from "ajv-formats";
|
|
1339
|
-
|
|
1969
|
+
init_logger();
|
|
1970
|
+
import process5 from "node:process";
|
|
1340
1971
|
var ajv2 = new Ajv2({
|
|
1341
1972
|
allErrors: true,
|
|
1342
1973
|
verbose: true
|
|
@@ -1351,6 +1982,9 @@ var BaseSamplingExecutor = class {
|
|
|
1351
1982
|
conversationHistory;
|
|
1352
1983
|
maxIterations;
|
|
1353
1984
|
currentIteration;
|
|
1985
|
+
logger;
|
|
1986
|
+
tracingEnabled;
|
|
1987
|
+
summarize;
|
|
1354
1988
|
constructor(name, description, allToolNames, toolNameToDetailList, server2, config2) {
|
|
1355
1989
|
this.name = name;
|
|
1356
1990
|
this.description = description;
|
|
@@ -1358,57 +1992,158 @@ var BaseSamplingExecutor = class {
|
|
|
1358
1992
|
this.toolNameToDetailList = toolNameToDetailList;
|
|
1359
1993
|
this.server = server2;
|
|
1360
1994
|
this.conversationHistory = [];
|
|
1361
|
-
this.maxIterations =
|
|
1995
|
+
this.maxIterations = 55;
|
|
1362
1996
|
this.currentIteration = 0;
|
|
1997
|
+
this.tracingEnabled = false;
|
|
1998
|
+
this.summarize = true;
|
|
1363
1999
|
if (config2?.maxIterations) {
|
|
1364
2000
|
this.maxIterations = config2.maxIterations;
|
|
1365
2001
|
}
|
|
2002
|
+
if (config2?.summarize !== void 0) {
|
|
2003
|
+
this.summarize = config2.summarize;
|
|
2004
|
+
}
|
|
2005
|
+
this.logger = createLogger(`mcpc.sampling.${name}`, server2);
|
|
2006
|
+
try {
|
|
2007
|
+
const tracingConfig = {
|
|
2008
|
+
enabled: process5.env.MCPC_TRACING_ENABLED === "true",
|
|
2009
|
+
serviceName: `mcpc-sampling-${name}`,
|
|
2010
|
+
exportTo: process5.env.MCPC_TRACING_EXPORT ?? "otlp",
|
|
2011
|
+
otlpEndpoint: process5.env.MCPC_TRACING_OTLP_ENDPOINT ?? "http://localhost:4318/v1/traces"
|
|
2012
|
+
};
|
|
2013
|
+
this.tracingEnabled = tracingConfig.enabled;
|
|
2014
|
+
if (this.tracingEnabled) {
|
|
2015
|
+
initializeTracing(tracingConfig);
|
|
2016
|
+
}
|
|
2017
|
+
} catch {
|
|
2018
|
+
this.tracingEnabled = false;
|
|
2019
|
+
}
|
|
1366
2020
|
}
|
|
1367
2021
|
async runSamplingLoop(systemPrompt, schema, state) {
|
|
1368
|
-
this.conversationHistory = [
|
|
2022
|
+
this.conversationHistory = [
|
|
2023
|
+
{
|
|
2024
|
+
role: "user",
|
|
2025
|
+
content: {
|
|
2026
|
+
type: "text",
|
|
2027
|
+
text: 'Return ONLY raw JSON (no code fences or explanations). The JSON MUST include action and decision. Example: {"action":"<tool>","decision":"proceed|complete","<tool>":{}}'
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
];
|
|
2031
|
+
const loopSpan = this.tracingEnabled ? startSpan("mcpc.sampling_loop", {
|
|
2032
|
+
agent: this.name,
|
|
2033
|
+
maxIterations: this.maxIterations,
|
|
2034
|
+
systemPrompt: systemPrompt()
|
|
2035
|
+
}) : null;
|
|
1369
2036
|
try {
|
|
1370
2037
|
for (this.currentIteration = 0; this.currentIteration < this.maxIterations; this.currentIteration++) {
|
|
1371
|
-
|
|
1372
|
-
systemPrompt: systemPrompt(),
|
|
1373
|
-
messages: this.conversationHistory,
|
|
1374
|
-
maxTokens: Number.MAX_SAFE_INTEGER
|
|
1375
|
-
});
|
|
1376
|
-
const responseContent = response.content.text || "{}";
|
|
1377
|
-
let parsedData;
|
|
2038
|
+
let iterationSpan = null;
|
|
1378
2039
|
try {
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
}
|
|
1384
|
-
if (parsedData) {
|
|
1385
|
-
this.conversationHistory.push({
|
|
1386
|
-
role: "assistant",
|
|
1387
|
-
content: {
|
|
1388
|
-
type: "text",
|
|
1389
|
-
text: JSON.stringify(parsedData, null, 2)
|
|
1390
|
-
}
|
|
2040
|
+
const response = await this.server.createMessage({
|
|
2041
|
+
systemPrompt: systemPrompt(),
|
|
2042
|
+
messages: this.conversationHistory,
|
|
2043
|
+
maxTokens: 55e3
|
|
1391
2044
|
});
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
2045
|
+
const responseContent = response.content.text || "{}";
|
|
2046
|
+
const model = response.model;
|
|
2047
|
+
const stopReason = response.stopReason;
|
|
2048
|
+
const role = response.role;
|
|
2049
|
+
let parsedData;
|
|
2050
|
+
try {
|
|
2051
|
+
parsedData = parseJSON(responseContent.trim(), true);
|
|
2052
|
+
} catch (parseError) {
|
|
2053
|
+
iterationSpan = this.tracingEnabled ? startSpan("mcpc.sampling_iteration.parse_error", {
|
|
2054
|
+
iteration: this.currentIteration + 1,
|
|
2055
|
+
agent: this.name,
|
|
2056
|
+
error: String(parseError),
|
|
2057
|
+
maxIterations: this.maxIterations
|
|
2058
|
+
}, loopSpan ?? void 0) : null;
|
|
2059
|
+
this.addParsingErrorToHistory(responseContent, parseError);
|
|
2060
|
+
if (iterationSpan) endSpan(iterationSpan);
|
|
2061
|
+
continue;
|
|
2062
|
+
}
|
|
2063
|
+
if (parsedData) {
|
|
2064
|
+
this.conversationHistory.push({
|
|
2065
|
+
role: "assistant",
|
|
2066
|
+
content: {
|
|
2067
|
+
type: "text",
|
|
2068
|
+
text: JSON.stringify(parsedData, null, 2)
|
|
2069
|
+
}
|
|
2070
|
+
});
|
|
2071
|
+
}
|
|
2072
|
+
const action = parsedData["action"];
|
|
2073
|
+
const actionStr = action && typeof action === "string" ? String(action) : "unknown_action";
|
|
2074
|
+
const spanName = `mcpc.sampling_iteration.${actionStr}`;
|
|
2075
|
+
iterationSpan = this.tracingEnabled ? startSpan(spanName, {
|
|
2076
|
+
iteration: this.currentIteration + 1,
|
|
2077
|
+
agent: this.name,
|
|
2078
|
+
action: actionStr,
|
|
2079
|
+
systemPrompt: systemPrompt(),
|
|
2080
|
+
maxTokens: String(Number.MAX_SAFE_INTEGER),
|
|
2081
|
+
maxIterations: this.maxIterations,
|
|
2082
|
+
messages: JSON.stringify(this.conversationHistory)
|
|
2083
|
+
}, loopSpan ?? void 0) : null;
|
|
2084
|
+
if (!action || typeof parsedData["decision"] !== "string") {
|
|
2085
|
+
this.conversationHistory.push({
|
|
2086
|
+
role: "user",
|
|
2087
|
+
content: {
|
|
2088
|
+
type: "text",
|
|
2089
|
+
text: 'Required fields missing: action or decision. Return ONLY raw JSON, no code fences or explanations. Example: {"action":"<tool>","decision":"proceed|complete","<tool>":{}}'
|
|
2090
|
+
}
|
|
2091
|
+
});
|
|
2092
|
+
if (iterationSpan) endSpan(iterationSpan);
|
|
2093
|
+
continue;
|
|
2094
|
+
}
|
|
2095
|
+
const result = await this.processAction(parsedData, schema, state, loopSpan);
|
|
2096
|
+
this.logIterationProgress(parsedData, result, model, stopReason, role);
|
|
2097
|
+
if (iterationSpan) {
|
|
2098
|
+
let rawJson = "{}";
|
|
2099
|
+
try {
|
|
2100
|
+
rawJson = parsedData ? JSON.stringify(parsedData) : "{}";
|
|
2101
|
+
} catch {
|
|
1401
2102
|
}
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
2103
|
+
const attr = {
|
|
2104
|
+
isError: !!result.isError,
|
|
2105
|
+
isComplete: !!result.isComplete,
|
|
2106
|
+
iteration: this.currentIteration + 1,
|
|
2107
|
+
maxIterations: this.maxIterations,
|
|
2108
|
+
parsed: rawJson,
|
|
2109
|
+
action: typeof action === "string" ? action : String(action),
|
|
2110
|
+
samplingResponse: responseContent,
|
|
2111
|
+
toolResult: JSON.stringify(result),
|
|
2112
|
+
model,
|
|
2113
|
+
role
|
|
2114
|
+
};
|
|
2115
|
+
if (stopReason) {
|
|
2116
|
+
attr.stopReason = stopReason;
|
|
2117
|
+
}
|
|
2118
|
+
iterationSpan.setAttributes(attr);
|
|
2119
|
+
}
|
|
2120
|
+
if (result.isError) {
|
|
2121
|
+
this.conversationHistory.push({
|
|
2122
|
+
role: "user",
|
|
2123
|
+
content: {
|
|
2124
|
+
type: "text",
|
|
2125
|
+
text: result.content[0].text
|
|
2126
|
+
}
|
|
2127
|
+
});
|
|
2128
|
+
if (iterationSpan) endSpan(iterationSpan);
|
|
2129
|
+
continue;
|
|
2130
|
+
}
|
|
2131
|
+
if (result.isComplete) {
|
|
2132
|
+
if (iterationSpan) endSpan(iterationSpan);
|
|
2133
|
+
if (loopSpan) endSpan(loopSpan);
|
|
2134
|
+
return result;
|
|
2135
|
+
}
|
|
2136
|
+
if (iterationSpan) endSpan(iterationSpan);
|
|
2137
|
+
} catch (iterError) {
|
|
2138
|
+
if (iterationSpan) endSpan(iterationSpan, iterError);
|
|
2139
|
+
throw iterError;
|
|
1407
2140
|
}
|
|
1408
2141
|
}
|
|
1409
|
-
|
|
2142
|
+
if (loopSpan) endSpan(loopSpan);
|
|
2143
|
+
return await this.createMaxIterationsError(loopSpan);
|
|
1410
2144
|
} catch (error) {
|
|
1411
|
-
|
|
2145
|
+
if (loopSpan) endSpan(loopSpan, error);
|
|
2146
|
+
return await this.createExecutionError(error, loopSpan);
|
|
1412
2147
|
}
|
|
1413
2148
|
}
|
|
1414
2149
|
addParsingErrorToHistory(responseText, parseError) {
|
|
@@ -1431,71 +2166,137 @@ Please respond with valid JSON.`
|
|
|
1431
2166
|
}
|
|
1432
2167
|
});
|
|
1433
2168
|
}
|
|
1434
|
-
createMaxIterationsError() {
|
|
1435
|
-
const result = this.createCompletionResult(`
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
isComplete: false
|
|
1440
|
-
};
|
|
2169
|
+
async createMaxIterationsError(parentSpan) {
|
|
2170
|
+
const result = await this.createCompletionResult(`Reached max iterations (${this.maxIterations}). Try a more specific request.`, parentSpan);
|
|
2171
|
+
result.isError = true;
|
|
2172
|
+
result.isComplete = false;
|
|
2173
|
+
return result;
|
|
1441
2174
|
}
|
|
1442
|
-
createExecutionError(error) {
|
|
1443
|
-
const
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
isError: true,
|
|
1448
|
-
isComplete: false
|
|
1449
|
-
};
|
|
2175
|
+
async createExecutionError(error, parentSpan) {
|
|
2176
|
+
const result = await this.createCompletionResult(`Execution error: ${error instanceof Error ? error.message : String(error)}`, parentSpan);
|
|
2177
|
+
result.isError = true;
|
|
2178
|
+
result.isComplete = false;
|
|
2179
|
+
return result;
|
|
1450
2180
|
}
|
|
1451
|
-
createCompletionResult(text) {
|
|
1452
|
-
const
|
|
2181
|
+
async createCompletionResult(text, parentSpan) {
|
|
2182
|
+
const summary = this.summarize ? await this.summarizeConversation(parentSpan) : this.formatConversation();
|
|
1453
2183
|
return {
|
|
1454
2184
|
content: [
|
|
1455
2185
|
{
|
|
1456
2186
|
type: "text",
|
|
1457
|
-
text:
|
|
1458
|
-
|
|
2187
|
+
text: `${text}
|
|
2188
|
+
|
|
1459
2189
|
**Execution Summary:**
|
|
1460
2190
|
- Iterations used: ${this.currentIteration + 1}/${this.maxIterations}
|
|
1461
|
-
- Agent: ${this.name}
|
|
2191
|
+
- Agent: ${this.name}
|
|
2192
|
+
${summary}`
|
|
1462
2193
|
}
|
|
1463
2194
|
],
|
|
1464
2195
|
isError: false,
|
|
1465
2196
|
isComplete: true
|
|
1466
2197
|
};
|
|
1467
2198
|
}
|
|
1468
|
-
|
|
2199
|
+
// Use LLM to create high-signal summary for parent agent
|
|
2200
|
+
async summarizeConversation(parentSpan) {
|
|
1469
2201
|
if (this.conversationHistory.length === 0) {
|
|
1470
|
-
return "\n\n**No conversation history
|
|
2202
|
+
return "\n\n**No conversation history**";
|
|
1471
2203
|
}
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
2204
|
+
if (this.conversationHistory.length <= 3) {
|
|
2205
|
+
return this.formatConversation();
|
|
2206
|
+
}
|
|
2207
|
+
const summarizeSpan = this.tracingEnabled ? startSpan("mcpc.sampling_summarize", {
|
|
2208
|
+
agent: this.name,
|
|
2209
|
+
messageCount: this.conversationHistory.length
|
|
2210
|
+
}, parentSpan ?? void 0) : null;
|
|
2211
|
+
try {
|
|
2212
|
+
this.logger.debug({
|
|
2213
|
+
message: "Starting conversation summarization",
|
|
2214
|
+
messageCount: this.conversationHistory.length
|
|
2215
|
+
});
|
|
2216
|
+
const history = this.conversationHistory.map((msg, i) => {
|
|
2217
|
+
const prefix = `[${i + 1}] ${msg.role.toUpperCase()}`;
|
|
2218
|
+
return `${prefix}:
|
|
2219
|
+
${msg.content.text}`;
|
|
2220
|
+
}).join("\n\n---\n\n");
|
|
2221
|
+
const response = await this.server.createMessage({
|
|
2222
|
+
systemPrompt: `Summarize this agent execution:
|
|
2223
|
+
|
|
2224
|
+
Final Decision: (include complete JSON if present)
|
|
2225
|
+
Key Findings: (most important)
|
|
2226
|
+
Actions Taken: (high-level flow)
|
|
2227
|
+
Errors/Warnings: (if any)
|
|
2228
|
+
|
|
2229
|
+
${history}`,
|
|
2230
|
+
messages: [
|
|
2231
|
+
{
|
|
2232
|
+
role: "user",
|
|
2233
|
+
content: {
|
|
2234
|
+
type: "text",
|
|
2235
|
+
text: "Please provide a concise summary."
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
],
|
|
2239
|
+
maxTokens: 3e3
|
|
2240
|
+
});
|
|
2241
|
+
const summary = "\n\n" + response.content.text;
|
|
2242
|
+
this.logger.debug({
|
|
2243
|
+
message: "Summarization completed",
|
|
2244
|
+
summaryLength: summary.length
|
|
2245
|
+
});
|
|
2246
|
+
if (summarizeSpan) {
|
|
2247
|
+
summarizeSpan.setAttributes({
|
|
2248
|
+
summaryLength: summary.length,
|
|
2249
|
+
summary,
|
|
2250
|
+
success: true
|
|
2251
|
+
});
|
|
2252
|
+
endSpan(summarizeSpan);
|
|
2253
|
+
}
|
|
2254
|
+
return summary;
|
|
2255
|
+
} catch (error) {
|
|
2256
|
+
this.logger.warning({
|
|
2257
|
+
message: "Summarization failed, falling back to full history",
|
|
2258
|
+
error: String(error)
|
|
2259
|
+
});
|
|
2260
|
+
if (summarizeSpan) {
|
|
2261
|
+
endSpan(summarizeSpan, error);
|
|
2262
|
+
}
|
|
2263
|
+
return this.formatConversation();
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
2266
|
+
// Format full conversation history (for debugging)
|
|
2267
|
+
formatConversation() {
|
|
2268
|
+
if (this.conversationHistory.length === 0) {
|
|
2269
|
+
return "\n\n**No conversation history**";
|
|
2270
|
+
}
|
|
2271
|
+
const messages = this.conversationHistory.map((msg, i) => {
|
|
2272
|
+
const header = `### Message ${i + 1}: ${msg.role}`;
|
|
2273
|
+
try {
|
|
2274
|
+
const parsed = JSON.parse(msg.content.text);
|
|
2275
|
+
if (JSON.stringify(parsed).length < 100) {
|
|
2276
|
+
return `${header}
|
|
2277
|
+
${JSON.stringify(parsed)}`;
|
|
1480
2278
|
}
|
|
1481
|
-
|
|
1482
|
-
|
|
2279
|
+
return `${header}
|
|
2280
|
+
\`\`\`json
|
|
2281
|
+
${JSON.stringify(parsed, null, 2)}
|
|
2282
|
+
\`\`\``;
|
|
2283
|
+
} catch {
|
|
2284
|
+
return `${header}
|
|
2285
|
+
${msg.content.text}`;
|
|
1483
2286
|
}
|
|
1484
2287
|
});
|
|
1485
|
-
return
|
|
2288
|
+
return "\n\n**Conversation History:**\n" + messages.join("\n\n");
|
|
1486
2289
|
}
|
|
1487
|
-
logIterationProgress(parsedData, result) {
|
|
1488
|
-
|
|
2290
|
+
logIterationProgress(parsedData, result, model, stopReason, role) {
|
|
2291
|
+
this.logger.debug({
|
|
2292
|
+
iteration: `${this.currentIteration + 1}/${this.maxIterations}`,
|
|
1489
2293
|
parsedData,
|
|
1490
2294
|
isError: result.isError,
|
|
1491
2295
|
isComplete: result.isComplete,
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
compact: true,
|
|
1497
|
-
maxStringLength: 120
|
|
1498
|
-
})
|
|
2296
|
+
model,
|
|
2297
|
+
stopReason,
|
|
2298
|
+
role,
|
|
2299
|
+
result
|
|
1499
2300
|
});
|
|
1500
2301
|
}
|
|
1501
2302
|
injectJsonInstruction({ prompt, schema, schemaPrefix = "JSON schema:", schemaSuffix = `STRICT REQUIREMENTS:
|
|
@@ -1529,7 +2330,7 @@ VALID: {"key":"value"}` }) {
|
|
|
1529
2330
|
}
|
|
1530
2331
|
};
|
|
1531
2332
|
|
|
1532
|
-
// ../
|
|
2333
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/executors/sampling/agentic-sampling-executor.js
|
|
1533
2334
|
var SamplingExecutor = class extends BaseSamplingExecutor {
|
|
1534
2335
|
agenticExecutor;
|
|
1535
2336
|
constructor(name, description, allToolNames, toolNameToDetailList, server2, config2) {
|
|
@@ -1546,7 +2347,7 @@ var SamplingExecutor = class extends BaseSamplingExecutor {
|
|
|
1546
2347
|
...tool.inputSchema
|
|
1547
2348
|
};
|
|
1548
2349
|
} else {
|
|
1549
|
-
const toolSchema = this.server.
|
|
2350
|
+
const toolSchema = this.server.getHiddenToolSchema(toolName);
|
|
1550
2351
|
if (toolSchema) {
|
|
1551
2352
|
depGroups[toolName] = {
|
|
1552
2353
|
...toolSchema.schema,
|
|
@@ -1574,13 +2375,13 @@ var SamplingExecutor = class extends BaseSamplingExecutor {
|
|
|
1574
2375
|
}
|
|
1575
2376
|
const createArgsDef = createArgsDefFactory(this.name, this.allToolNames, this.buildDepGroups(), void 0, void 0);
|
|
1576
2377
|
const agenticSchema = createArgsDef.forAgentic(this.toolNameToDetailList, true);
|
|
1577
|
-
const systemPrompt = this.buildSystemPrompt(args.userRequest, agenticSchema);
|
|
2378
|
+
const systemPrompt = this.buildSystemPrompt(args.userRequest, agenticSchema, args.context && typeof args.context === "object" ? args.context : void 0);
|
|
1578
2379
|
return this.runSamplingLoop(() => systemPrompt, agenticSchema);
|
|
1579
2380
|
}
|
|
1580
|
-
async processAction(parsedData, schema) {
|
|
2381
|
+
async processAction(parsedData, schema, _state, parentSpan) {
|
|
1581
2382
|
const toolCallData = parsedData;
|
|
1582
2383
|
if (toolCallData.decision === "complete") {
|
|
1583
|
-
return this.createCompletionResult("Task completed");
|
|
2384
|
+
return await this.createCompletionResult("Task completed", parentSpan);
|
|
1584
2385
|
}
|
|
1585
2386
|
try {
|
|
1586
2387
|
const { action: _action, decision: _decision, ..._toolArgs } = toolCallData;
|
|
@@ -1595,13 +2396,13 @@ var SamplingExecutor = class extends BaseSamplingExecutor {
|
|
|
1595
2396
|
});
|
|
1596
2397
|
return toolResult;
|
|
1597
2398
|
} catch (error) {
|
|
1598
|
-
return this.createExecutionError(error);
|
|
2399
|
+
return this.createExecutionError(error, parentSpan);
|
|
1599
2400
|
}
|
|
1600
2401
|
}
|
|
1601
|
-
buildSystemPrompt(userRequest, agenticSchema) {
|
|
2402
|
+
buildSystemPrompt(userRequest, agenticSchema, context2) {
|
|
1602
2403
|
const toolList = this.allToolNames.map((name) => {
|
|
1603
2404
|
const tool = this.toolNameToDetailList.find(([toolName]) => toolName === name);
|
|
1604
|
-
const toolSchema = this.server.
|
|
2405
|
+
const toolSchema = this.server.getHiddenToolSchema(name);
|
|
1605
2406
|
if (tool && tool[1]) {
|
|
1606
2407
|
return `- ${name}: ${tool[1].description || `Tool: ${name}`}`;
|
|
1607
2408
|
} else if (toolSchema) {
|
|
@@ -1609,6 +2410,13 @@ var SamplingExecutor = class extends BaseSamplingExecutor {
|
|
|
1609
2410
|
}
|
|
1610
2411
|
return `- ${name}`;
|
|
1611
2412
|
}).join("\n");
|
|
2413
|
+
let contextInfo = "";
|
|
2414
|
+
if (context2 && typeof context2 === "object" && Object.keys(context2).length > 0) {
|
|
2415
|
+
contextInfo = `
|
|
2416
|
+
|
|
2417
|
+
Context:
|
|
2418
|
+
${JSON.stringify(context2, null, 2)}`;
|
|
2419
|
+
}
|
|
1612
2420
|
const basePrompt = CompiledPrompts.samplingExecution({
|
|
1613
2421
|
toolName: this.name,
|
|
1614
2422
|
description: this.description,
|
|
@@ -1617,7 +2425,7 @@ var SamplingExecutor = class extends BaseSamplingExecutor {
|
|
|
1617
2425
|
const taskPrompt = `
|
|
1618
2426
|
|
|
1619
2427
|
## Current Task
|
|
1620
|
-
I will now use agentic sampling to complete the following task: "${userRequest}"
|
|
2428
|
+
I will now use agentic sampling to complete the following task: "${userRequest}"${contextInfo}
|
|
1621
2429
|
|
|
1622
2430
|
When I need to use a tool, I should specify the tool name in 'action' and provide tool-specific parameters as additional properties.
|
|
1623
2431
|
When the task is complete, I should use "action": "complete".`;
|
|
@@ -1628,7 +2436,7 @@ When the task is complete, I should use "action": "complete".`;
|
|
|
1628
2436
|
}
|
|
1629
2437
|
};
|
|
1630
2438
|
|
|
1631
|
-
// ../
|
|
2439
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/executors/agentic/agentic-tool-registrar.js
|
|
1632
2440
|
function registerAgenticTool(server2, { description, name, allToolNames, depGroups, toolNameToDetailList, sampling = false }) {
|
|
1633
2441
|
const createArgsDef = createArgsDefFactory(name, allToolNames, depGroups, void 0, void 0);
|
|
1634
2442
|
const isSamplingMode = sampling === true || typeof sampling === "object";
|
|
@@ -1658,10 +2466,10 @@ function registerAgenticTool(server2, { description, name, allToolNames, depGrou
|
|
|
1658
2466
|
});
|
|
1659
2467
|
}
|
|
1660
2468
|
|
|
1661
|
-
// ../
|
|
1662
|
-
|
|
2469
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/executors/workflow/workflow-tool-registrar.js
|
|
2470
|
+
init_schema();
|
|
1663
2471
|
|
|
1664
|
-
// ../
|
|
2472
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/state.js
|
|
1665
2473
|
var WorkflowState = class {
|
|
1666
2474
|
currentStepIndex = -1;
|
|
1667
2475
|
steps = [];
|
|
@@ -1830,7 +2638,7 @@ var WorkflowState = class {
|
|
|
1830
2638
|
}
|
|
1831
2639
|
};
|
|
1832
2640
|
|
|
1833
|
-
// ../
|
|
2641
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/executors/workflow/workflow-executor.js
|
|
1834
2642
|
import { Ajv as Ajv3 } from "ajv";
|
|
1835
2643
|
import { AggregateAjvError as AggregateAjvError3 } from "@segment/ajv-human-errors";
|
|
1836
2644
|
import addFormats3 from "ajv-formats";
|
|
@@ -2157,7 +2965,7 @@ ${this.formatProgress(state)}`
|
|
|
2157
2965
|
}
|
|
2158
2966
|
};
|
|
2159
2967
|
|
|
2160
|
-
// ../
|
|
2968
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/executors/sampling/workflow-sampling-executor.js
|
|
2161
2969
|
var WorkflowSamplingExecutor = class extends BaseSamplingExecutor {
|
|
2162
2970
|
createArgsDef;
|
|
2163
2971
|
predefinedSteps;
|
|
@@ -2183,14 +2991,14 @@ var WorkflowSamplingExecutor = class extends BaseSamplingExecutor {
|
|
|
2183
2991
|
}
|
|
2184
2992
|
return await this.runSamplingLoop(() => this.buildWorkflowSystemPrompt(args, state), schema, state);
|
|
2185
2993
|
}
|
|
2186
|
-
async processAction(parsedData, _schema, state) {
|
|
2994
|
+
async processAction(parsedData, _schema, state, parentSpan) {
|
|
2187
2995
|
const workflowState = state;
|
|
2188
2996
|
if (!workflowState) {
|
|
2189
2997
|
throw new Error("WorkflowState is required for workflow");
|
|
2190
2998
|
}
|
|
2191
2999
|
const toolCallData = parsedData;
|
|
2192
3000
|
if (toolCallData.decision === "complete") {
|
|
2193
|
-
return this.createCompletionResult("Task completed");
|
|
3001
|
+
return await this.createCompletionResult("Task completed", parentSpan);
|
|
2194
3002
|
}
|
|
2195
3003
|
try {
|
|
2196
3004
|
const workflowResult = await this.workflowExecutor.execute(parsedData, workflowState);
|
|
@@ -2204,7 +3012,7 @@ var WorkflowSamplingExecutor = class extends BaseSamplingExecutor {
|
|
|
2204
3012
|
});
|
|
2205
3013
|
return workflowResult;
|
|
2206
3014
|
} catch (error) {
|
|
2207
|
-
return this.createExecutionError(error);
|
|
3015
|
+
return this.createExecutionError(error, parentSpan);
|
|
2208
3016
|
}
|
|
2209
3017
|
}
|
|
2210
3018
|
buildWorkflowSystemPrompt(args, state) {
|
|
@@ -2214,9 +3022,16 @@ var WorkflowSamplingExecutor = class extends BaseSamplingExecutor {
|
|
|
2214
3022
|
description: this.description,
|
|
2215
3023
|
workflowSchema: `${JSON.stringify(workflowSchema, null, 2)}`
|
|
2216
3024
|
});
|
|
3025
|
+
let contextInfo = "";
|
|
3026
|
+
if (args.context && typeof args.context === "object" && Object.keys(args.context).length > 0) {
|
|
3027
|
+
contextInfo = `
|
|
3028
|
+
|
|
3029
|
+
Context:
|
|
3030
|
+
${JSON.stringify(args.context, null, 2)}`;
|
|
3031
|
+
}
|
|
2217
3032
|
const workflowPrompt = `
|
|
2218
3033
|
|
|
2219
|
-
Current Task: <user_request>${args.userRequest}</user_request
|
|
3034
|
+
Current Task: <user_request>${args.userRequest}</user_request>${contextInfo}`;
|
|
2220
3035
|
return this.injectJsonInstruction({
|
|
2221
3036
|
prompt: basePrompt + workflowPrompt,
|
|
2222
3037
|
schema: workflowSchema
|
|
@@ -2224,7 +3039,7 @@ Current Task: <user_request>${args.userRequest}</user_request>`;
|
|
|
2224
3039
|
}
|
|
2225
3040
|
};
|
|
2226
3041
|
|
|
2227
|
-
// ../
|
|
3042
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/executors/workflow/workflow-tool-registrar.js
|
|
2228
3043
|
function registerAgenticWorkflowTool(server2, { description, name, allToolNames, depGroups, toolNameToDetailList, predefinedSteps, sampling = false, ensureStepActions, toolNameToIdMapping }) {
|
|
2229
3044
|
const createArgsDef = createArgsDefFactory(name, allToolNames, depGroups, predefinedSteps, ensureStepActions);
|
|
2230
3045
|
const isSamplingMode = sampling === true || typeof sampling === "object";
|
|
@@ -2244,7 +3059,7 @@ function registerAgenticWorkflowTool(server2, { description, name, allToolNames,
|
|
|
2244
3059
|
});
|
|
2245
3060
|
const argsDef = isSamplingMode ? createArgsDef.forSampling() : createArgsDef.forTool();
|
|
2246
3061
|
const toolDescription = isSamplingMode ? baseDescription : createArgsDef.forToolDescription(baseDescription, workflowState);
|
|
2247
|
-
server2.tool(name, toolDescription,
|
|
3062
|
+
server2.tool(name, toolDescription, jsonSchema(createGoogleCompatibleJSONSchema(argsDef)), async (args) => {
|
|
2248
3063
|
try {
|
|
2249
3064
|
if (isSamplingMode) {
|
|
2250
3065
|
return await workflowSamplingExecutor.executeWorkflowSampling(args, argsDef, workflowState);
|
|
@@ -2266,7 +3081,7 @@ function registerAgenticWorkflowTool(server2, { description, name, allToolNames,
|
|
|
2266
3081
|
});
|
|
2267
3082
|
}
|
|
2268
3083
|
|
|
2269
|
-
// ../
|
|
3084
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/tool-tag-processor.js
|
|
2270
3085
|
var ALL_TOOLS_PLACEHOLDER = "__ALL__";
|
|
2271
3086
|
function findToolId(toolName, tools, toolNameMapping) {
|
|
2272
3087
|
const mappedId = toolNameMapping?.get(toolName);
|
|
@@ -2286,9 +3101,9 @@ function processToolTags({ description, tagToResults, $, tools, toolOverrides, t
|
|
|
2286
3101
|
return;
|
|
2287
3102
|
}
|
|
2288
3103
|
const override = toolOverrides.get(toolName);
|
|
2289
|
-
if (override?.visibility?.
|
|
3104
|
+
if (override?.visibility?.hidden) {
|
|
2290
3105
|
$(toolEl).remove();
|
|
2291
|
-
} else if (override?.visibility?.
|
|
3106
|
+
} else if (override?.visibility?.public) {
|
|
2292
3107
|
$(toolEl).replaceWith(`<tool name="${toolName}"/>`);
|
|
2293
3108
|
} else {
|
|
2294
3109
|
const toolId = findToolId(toolName, tools, toolNameMapping);
|
|
@@ -2300,168 +3115,308 @@ function processToolTags({ description, tagToResults, $, tools, toolOverrides, t
|
|
|
2300
3115
|
return $.root().html() ?? description;
|
|
2301
3116
|
}
|
|
2302
3117
|
|
|
2303
|
-
// ../
|
|
3118
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/compose.js
|
|
2304
3119
|
init_built_in();
|
|
3120
|
+
init_logger();
|
|
3121
|
+
init_plugin_utils();
|
|
2305
3122
|
|
|
2306
|
-
// ../
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
return plugin && plugin.name && (plugin.configureServer || plugin.composeStart || plugin.transformTool || plugin.finalizeComposition || plugin.composeEnd);
|
|
2319
|
-
}
|
|
2320
|
-
async function loadPlugin(pluginPath) {
|
|
2321
|
-
try {
|
|
2322
|
-
const [rawPath, queryString] = pluginPath.split("?", 2);
|
|
2323
|
-
const searchParams = new URLSearchParams(queryString || "");
|
|
2324
|
-
const params = Object.fromEntries(searchParams.entries());
|
|
2325
|
-
const pluginModule = await import(rawPath);
|
|
2326
|
-
const pluginFactory = pluginModule.createPlugin;
|
|
2327
|
-
const defaultPlugin = pluginModule.default;
|
|
2328
|
-
let plugin;
|
|
2329
|
-
if (Object.keys(params).length > 0) {
|
|
2330
|
-
if (typeof pluginFactory === "function") {
|
|
2331
|
-
const typedParams = {};
|
|
2332
|
-
for (const [key, value] of Object.entries(params)) {
|
|
2333
|
-
const numValue = Number(value);
|
|
2334
|
-
if (!isNaN(numValue)) {
|
|
2335
|
-
typedParams[key] = numValue;
|
|
2336
|
-
} else if (value === "true") {
|
|
2337
|
-
typedParams[key] = true;
|
|
2338
|
-
} else if (value === "false") {
|
|
2339
|
-
typedParams[key] = false;
|
|
2340
|
-
} else {
|
|
2341
|
-
typedParams[key] = value;
|
|
2342
|
-
}
|
|
2343
|
-
}
|
|
2344
|
-
plugin = pluginFactory(typedParams);
|
|
2345
|
-
} else {
|
|
2346
|
-
throw new Error(`Plugin ${rawPath} has parameters but no createPlugin export`);
|
|
2347
|
-
}
|
|
2348
|
-
} else {
|
|
2349
|
-
plugin = defaultPlugin;
|
|
2350
|
-
}
|
|
2351
|
-
if (isValidPlugin(plugin)) {
|
|
2352
|
-
return plugin;
|
|
2353
|
-
} else {
|
|
2354
|
-
throw new Error(`Invalid plugin format in ${rawPath} - plugin must have a name and at least one lifecycle hook`);
|
|
2355
|
-
}
|
|
2356
|
-
} catch (error) {
|
|
2357
|
-
throw new Error(`Failed to load plugin from ${pluginPath}: ${error}`);
|
|
3123
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/plugin-manager.js
|
|
3124
|
+
init_plugin_utils();
|
|
3125
|
+
init_logger();
|
|
3126
|
+
var PluginManager = class {
|
|
3127
|
+
server;
|
|
3128
|
+
plugins;
|
|
3129
|
+
logger;
|
|
3130
|
+
constructor(server2) {
|
|
3131
|
+
this.server = server2;
|
|
3132
|
+
this.plugins = [];
|
|
3133
|
+
this.logger = createLogger("mcpc.plugin-manager");
|
|
3134
|
+
this.logger.setServer(server2);
|
|
2358
3135
|
}
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
toolConfigs = /* @__PURE__ */ new Map();
|
|
2367
|
-
globalPlugins = [];
|
|
2368
|
-
toolNameMapping = /* @__PURE__ */ new Map();
|
|
2369
|
-
constructor(_serverInfo, options) {
|
|
2370
|
-
super(_serverInfo, options);
|
|
3136
|
+
/**
|
|
3137
|
+
* Get all registered plugins
|
|
3138
|
+
*/
|
|
3139
|
+
getPlugins() {
|
|
3140
|
+
return [
|
|
3141
|
+
...this.plugins
|
|
3142
|
+
];
|
|
2371
3143
|
}
|
|
2372
3144
|
/**
|
|
2373
|
-
*
|
|
3145
|
+
* Get plugin names
|
|
2374
3146
|
*/
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
for (const plugin of builtInPlugins) {
|
|
2378
|
-
await this.addPlugin(plugin);
|
|
2379
|
-
}
|
|
3147
|
+
getPluginNames() {
|
|
3148
|
+
return this.plugins.map((p2) => p2.name);
|
|
2380
3149
|
}
|
|
2381
3150
|
/**
|
|
2382
|
-
*
|
|
2383
|
-
* TODO: Implement transformResult lifecycle hooks
|
|
3151
|
+
* Check if a plugin is registered
|
|
2384
3152
|
*/
|
|
2385
|
-
|
|
2386
|
-
return
|
|
3153
|
+
hasPlugin(name) {
|
|
3154
|
+
return this.plugins.some((p2) => p2.name === name);
|
|
2387
3155
|
}
|
|
2388
3156
|
/**
|
|
2389
|
-
*
|
|
3157
|
+
* Add a plugin with validation and error handling
|
|
2390
3158
|
*/
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
3159
|
+
async addPlugin(plugin) {
|
|
3160
|
+
const validation = validatePlugins([
|
|
3161
|
+
plugin
|
|
3162
|
+
]);
|
|
3163
|
+
if (!validation.valid) {
|
|
3164
|
+
const errorMsg = validation.errors.join(", ");
|
|
3165
|
+
throw new Error(`Invalid plugin "${plugin.name}": ${errorMsg}`);
|
|
2394
3166
|
}
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
return
|
|
3167
|
+
if (this.plugins.some((p2) => p2.name === plugin.name)) {
|
|
3168
|
+
await this.logger.warning(`Plugin "${plugin.name}" already registered, skipping`);
|
|
3169
|
+
return;
|
|
2398
3170
|
}
|
|
2399
|
-
if (
|
|
2400
|
-
const
|
|
2401
|
-
if (
|
|
2402
|
-
|
|
3171
|
+
if (plugin.dependencies) {
|
|
3172
|
+
const missingDeps = plugin.dependencies.filter((dep) => !this.plugins.some((p2) => p2.name === dep));
|
|
3173
|
+
if (missingDeps.length > 0) {
|
|
3174
|
+
throw new Error(`Plugin "${plugin.name}" has missing dependencies: ${missingDeps.join(", ")}`);
|
|
3175
|
+
}
|
|
3176
|
+
}
|
|
3177
|
+
this.plugins.push(plugin);
|
|
3178
|
+
if (plugin.configureServer) {
|
|
3179
|
+
try {
|
|
3180
|
+
await plugin.configureServer(this.server);
|
|
3181
|
+
} catch (error) {
|
|
3182
|
+
this.plugins = this.plugins.filter((p2) => p2.name !== plugin.name);
|
|
3183
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
3184
|
+
throw new Error(`Plugin "${plugin.name}" configuration failed: ${errorMsg}`);
|
|
2403
3185
|
}
|
|
2404
3186
|
}
|
|
2405
|
-
return void 0;
|
|
2406
3187
|
}
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
3188
|
+
/**
|
|
3189
|
+
* Load and register a plugin from a file path
|
|
3190
|
+
*/
|
|
3191
|
+
async loadPluginFromPath(pluginPath, options = {
|
|
3192
|
+
cache: true
|
|
3193
|
+
}) {
|
|
3194
|
+
const plugin = await loadPlugin(pluginPath, options);
|
|
3195
|
+
await this.addPlugin(plugin);
|
|
3196
|
+
}
|
|
3197
|
+
/**
|
|
3198
|
+
* Trigger composeStart hooks for all applicable plugins
|
|
3199
|
+
*/
|
|
3200
|
+
async triggerComposeStart(context2) {
|
|
3201
|
+
const startPlugins = this.plugins.filter((p2) => p2.composeStart && shouldApplyPlugin(p2, context2.mode));
|
|
3202
|
+
const sortedPlugins = sortPluginsByOrder(startPlugins);
|
|
3203
|
+
for (const plugin of sortedPlugins) {
|
|
3204
|
+
if (plugin.composeStart) {
|
|
3205
|
+
try {
|
|
3206
|
+
await plugin.composeStart(context2);
|
|
3207
|
+
} catch (error) {
|
|
3208
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
3209
|
+
await this.logger.error(`Plugin "${plugin.name}" composeStart failed: ${errorMsg}`);
|
|
3210
|
+
}
|
|
2416
3211
|
}
|
|
2417
3212
|
}
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
3213
|
+
}
|
|
3214
|
+
/**
|
|
3215
|
+
* Apply transformTool hooks to a tool during composition
|
|
3216
|
+
*/
|
|
3217
|
+
async applyTransformToolHooks(tool, context2) {
|
|
3218
|
+
const transformPlugins = this.plugins.filter((p2) => p2.transformTool && shouldApplyPlugin(p2, context2.mode));
|
|
3219
|
+
if (transformPlugins.length === 0) {
|
|
3220
|
+
return tool;
|
|
3221
|
+
}
|
|
3222
|
+
const sortedPlugins = sortPluginsByOrder(transformPlugins);
|
|
3223
|
+
let currentTool = tool;
|
|
3224
|
+
for (const plugin of sortedPlugins) {
|
|
3225
|
+
if (plugin.transformTool) {
|
|
3226
|
+
try {
|
|
3227
|
+
const result = await plugin.transformTool(currentTool, context2);
|
|
3228
|
+
if (result) {
|
|
3229
|
+
currentTool = result;
|
|
3230
|
+
}
|
|
3231
|
+
} catch (error) {
|
|
3232
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
3233
|
+
await this.logger.error(`Plugin "${plugin.name}" transformTool failed for "${context2.toolName}": ${errorMsg}`);
|
|
2422
3234
|
}
|
|
2423
|
-
});
|
|
2424
|
-
} else {
|
|
2425
|
-
const existingTool = this.tools.find((t) => t.name === name);
|
|
2426
|
-
if (!existingTool) {
|
|
2427
|
-
const newTool = {
|
|
2428
|
-
name,
|
|
2429
|
-
description,
|
|
2430
|
-
inputSchema: paramsSchema.jsonSchema
|
|
2431
|
-
};
|
|
2432
|
-
this.tools = [
|
|
2433
|
-
...this.tools,
|
|
2434
|
-
newTool
|
|
2435
|
-
];
|
|
2436
3235
|
}
|
|
2437
3236
|
}
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
3237
|
+
return currentTool;
|
|
3238
|
+
}
|
|
3239
|
+
/**
|
|
3240
|
+
* Trigger finalizeComposition hooks for all applicable plugins
|
|
3241
|
+
*/
|
|
3242
|
+
async triggerFinalizeComposition(tools, context2) {
|
|
3243
|
+
const finalizePlugins = this.plugins.filter((p2) => p2.finalizeComposition && shouldApplyPlugin(p2, context2.mode));
|
|
3244
|
+
const sortedPlugins = sortPluginsByOrder(finalizePlugins);
|
|
3245
|
+
for (const plugin of sortedPlugins) {
|
|
3246
|
+
if (plugin.finalizeComposition) {
|
|
3247
|
+
try {
|
|
3248
|
+
await plugin.finalizeComposition(tools, context2);
|
|
3249
|
+
} catch (error) {
|
|
3250
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
3251
|
+
await this.logger.error(`Plugin "${plugin.name}" finalizeComposition failed: ${errorMsg}`);
|
|
3252
|
+
}
|
|
3253
|
+
}
|
|
3254
|
+
}
|
|
3255
|
+
}
|
|
3256
|
+
/**
|
|
3257
|
+
* Trigger composeEnd hooks for all applicable plugins
|
|
3258
|
+
*/
|
|
3259
|
+
async triggerComposeEnd(context2) {
|
|
3260
|
+
const endPlugins = this.plugins.filter((p2) => p2.composeEnd && shouldApplyPlugin(p2, context2.mode));
|
|
3261
|
+
const sortedPlugins = sortPluginsByOrder(endPlugins);
|
|
3262
|
+
for (const plugin of sortedPlugins) {
|
|
3263
|
+
if (plugin.composeEnd) {
|
|
3264
|
+
try {
|
|
3265
|
+
await plugin.composeEnd(context2);
|
|
3266
|
+
} catch (error) {
|
|
3267
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
3268
|
+
await this.logger.error(`Plugin "${plugin.name}" composeEnd failed: ${errorMsg}`);
|
|
3269
|
+
}
|
|
2448
3270
|
}
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
3271
|
+
}
|
|
3272
|
+
}
|
|
3273
|
+
/**
|
|
3274
|
+
* Dispose all plugins and cleanup resources
|
|
3275
|
+
*/
|
|
3276
|
+
async dispose() {
|
|
3277
|
+
for (const plugin of this.plugins) {
|
|
3278
|
+
if (plugin.dispose) {
|
|
3279
|
+
try {
|
|
3280
|
+
await plugin.dispose();
|
|
3281
|
+
} catch (error) {
|
|
3282
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
3283
|
+
await this.logger.error(`Plugin "${plugin.name}" dispose failed: ${errorMsg}`);
|
|
3284
|
+
}
|
|
3285
|
+
}
|
|
3286
|
+
}
|
|
3287
|
+
this.plugins = [];
|
|
3288
|
+
}
|
|
3289
|
+
};
|
|
3290
|
+
|
|
3291
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/tool-manager.js
|
|
3292
|
+
var ToolManager = class {
|
|
3293
|
+
toolRegistry = /* @__PURE__ */ new Map();
|
|
3294
|
+
toolConfigs = /* @__PURE__ */ new Map();
|
|
3295
|
+
toolNameMapping = /* @__PURE__ */ new Map();
|
|
3296
|
+
publicTools = [];
|
|
3297
|
+
/**
|
|
3298
|
+
* Get tool name mapping (for external access)
|
|
3299
|
+
*/
|
|
3300
|
+
getToolNameMapping() {
|
|
3301
|
+
return this.toolNameMapping;
|
|
3302
|
+
}
|
|
3303
|
+
/**
|
|
3304
|
+
* Register a tool in the registry
|
|
3305
|
+
*/
|
|
3306
|
+
registerTool(name, description, schema, callback, options = {}) {
|
|
3307
|
+
this.toolRegistry.set(name, {
|
|
3308
|
+
callback,
|
|
3309
|
+
description,
|
|
3310
|
+
schema
|
|
2452
3311
|
});
|
|
3312
|
+
if (options.internal) {
|
|
3313
|
+
this.toolConfigs.set(name, {
|
|
3314
|
+
visibility: {
|
|
3315
|
+
hidden: true
|
|
3316
|
+
}
|
|
3317
|
+
});
|
|
3318
|
+
}
|
|
3319
|
+
}
|
|
3320
|
+
/**
|
|
3321
|
+
* Explicitly mark a tool as public (exposed to MCP clients)
|
|
3322
|
+
*/
|
|
3323
|
+
addPublicTool(name, description, schema) {
|
|
3324
|
+
const existingTool = this.publicTools.find((t) => t.name === name);
|
|
3325
|
+
if (!existingTool) {
|
|
3326
|
+
this.publicTools.push({
|
|
3327
|
+
name,
|
|
3328
|
+
description,
|
|
3329
|
+
inputSchema: schema
|
|
3330
|
+
});
|
|
3331
|
+
}
|
|
3332
|
+
}
|
|
3333
|
+
/**
|
|
3334
|
+
* Check if a tool is public (exposed to MCP clients)
|
|
3335
|
+
*/
|
|
3336
|
+
isPublic(name) {
|
|
3337
|
+
const config2 = this.toolConfigs.get(name);
|
|
3338
|
+
return config2?.visibility?.public === true;
|
|
3339
|
+
}
|
|
3340
|
+
/**
|
|
3341
|
+
* Check if a tool is hidden from agent context
|
|
3342
|
+
*/
|
|
3343
|
+
isHidden(name) {
|
|
3344
|
+
const config2 = this.toolConfigs.get(name);
|
|
3345
|
+
return config2?.visibility?.hidden === true;
|
|
3346
|
+
}
|
|
3347
|
+
/**
|
|
3348
|
+
* Get all public tool names (exposed to MCP clients)
|
|
3349
|
+
*/
|
|
3350
|
+
getPublicToolNames() {
|
|
3351
|
+
return Array.from(this.toolConfigs.entries()).filter(([_name, config2]) => config2.visibility?.public === true).map(([name]) => this.resolveToolName(name) ?? name);
|
|
2453
3352
|
}
|
|
2454
3353
|
/**
|
|
2455
|
-
*
|
|
3354
|
+
* Get all hidden tool names
|
|
2456
3355
|
*/
|
|
3356
|
+
getHiddenToolNames() {
|
|
3357
|
+
return Array.from(this.toolConfigs.entries()).filter(([_name, config2]) => config2.visibility?.hidden === true).map(([name]) => this.resolveToolName(name) ?? name);
|
|
3358
|
+
}
|
|
3359
|
+
/**
|
|
3360
|
+
* Get all public tools
|
|
3361
|
+
*/
|
|
3362
|
+
getPublicTools() {
|
|
3363
|
+
return [
|
|
3364
|
+
...this.publicTools
|
|
3365
|
+
];
|
|
3366
|
+
}
|
|
2457
3367
|
/**
|
|
2458
|
-
|
|
2459
|
-
|
|
3368
|
+
* Set public tools list
|
|
3369
|
+
*/
|
|
3370
|
+
setPublicTools(tools) {
|
|
3371
|
+
this.publicTools = [
|
|
3372
|
+
...tools
|
|
3373
|
+
];
|
|
3374
|
+
}
|
|
3375
|
+
/**
|
|
3376
|
+
* Get tool callback by name
|
|
3377
|
+
*/
|
|
2460
3378
|
getToolCallback(name) {
|
|
2461
3379
|
return this.toolRegistry.get(name)?.callback;
|
|
2462
3380
|
}
|
|
2463
3381
|
/**
|
|
2464
|
-
*
|
|
3382
|
+
* Check if tool exists in registry
|
|
3383
|
+
*/
|
|
3384
|
+
hasToolNamed(name) {
|
|
3385
|
+
return this.toolRegistry.has(name) || this.toolNameMapping.has(name) && this.toolRegistry.has(this.toolNameMapping.get(name));
|
|
3386
|
+
}
|
|
3387
|
+
/**
|
|
3388
|
+
* Resolve a tool name to its internal format
|
|
3389
|
+
*/
|
|
3390
|
+
resolveToolName(name) {
|
|
3391
|
+
if (this.toolRegistry.has(name)) {
|
|
3392
|
+
return name;
|
|
3393
|
+
}
|
|
3394
|
+
const mappedName = this.toolNameMapping.get(name);
|
|
3395
|
+
if (mappedName && this.toolRegistry.has(mappedName)) {
|
|
3396
|
+
return mappedName;
|
|
3397
|
+
}
|
|
3398
|
+
if (this.toolConfigs.has(name)) {
|
|
3399
|
+
const cfgMapped = this.toolNameMapping.get(name);
|
|
3400
|
+
if (cfgMapped && this.toolRegistry.has(cfgMapped)) {
|
|
3401
|
+
return cfgMapped;
|
|
3402
|
+
}
|
|
3403
|
+
}
|
|
3404
|
+
return void 0;
|
|
3405
|
+
}
|
|
3406
|
+
/**
|
|
3407
|
+
* Configure tool behavior
|
|
3408
|
+
*/
|
|
3409
|
+
configTool(toolName, config2) {
|
|
3410
|
+
this.toolConfigs.set(toolName, config2);
|
|
3411
|
+
}
|
|
3412
|
+
/**
|
|
3413
|
+
* Get tool configuration
|
|
3414
|
+
*/
|
|
3415
|
+
getToolConfig(toolName) {
|
|
3416
|
+
return this.toolConfigs.get(toolName);
|
|
3417
|
+
}
|
|
3418
|
+
/**
|
|
3419
|
+
* Find tool configuration (with mapping fallback)
|
|
2465
3420
|
*/
|
|
2466
3421
|
findToolConfig(toolId) {
|
|
2467
3422
|
const directConfig = this.toolConfigs.get(toolId);
|
|
@@ -2474,6 +3429,179 @@ var ComposableMCPServer = class extends Server {
|
|
|
2474
3429
|
}
|
|
2475
3430
|
return void 0;
|
|
2476
3431
|
}
|
|
3432
|
+
/**
|
|
3433
|
+
* Remove tool configuration
|
|
3434
|
+
*/
|
|
3435
|
+
removeToolConfig(toolName) {
|
|
3436
|
+
return this.toolConfigs.delete(toolName);
|
|
3437
|
+
}
|
|
3438
|
+
/**
|
|
3439
|
+
* Set tool name mapping
|
|
3440
|
+
*/
|
|
3441
|
+
setToolNameMapping(from, to) {
|
|
3442
|
+
this.toolNameMapping.set(from, to);
|
|
3443
|
+
}
|
|
3444
|
+
/**
|
|
3445
|
+
* Get tool schema if it's hidden (for internal access)
|
|
3446
|
+
*/
|
|
3447
|
+
getHiddenToolSchema(name) {
|
|
3448
|
+
const tool = this.toolRegistry.get(name);
|
|
3449
|
+
const config2 = this.toolConfigs.get(name);
|
|
3450
|
+
if (tool && config2?.visibility?.hidden && tool.schema) {
|
|
3451
|
+
return {
|
|
3452
|
+
description: tool.description,
|
|
3453
|
+
schema: tool.schema
|
|
3454
|
+
};
|
|
3455
|
+
}
|
|
3456
|
+
return void 0;
|
|
3457
|
+
}
|
|
3458
|
+
/**
|
|
3459
|
+
* Get total tool count
|
|
3460
|
+
*/
|
|
3461
|
+
getTotalToolCount() {
|
|
3462
|
+
return this.toolRegistry.size;
|
|
3463
|
+
}
|
|
3464
|
+
/**
|
|
3465
|
+
* Get all tool entries
|
|
3466
|
+
*/
|
|
3467
|
+
getToolEntries() {
|
|
3468
|
+
return Array.from(this.toolRegistry.entries());
|
|
3469
|
+
}
|
|
3470
|
+
/**
|
|
3471
|
+
* Get tool registry (for external access)
|
|
3472
|
+
*/
|
|
3473
|
+
getToolRegistry() {
|
|
3474
|
+
return this.toolRegistry;
|
|
3475
|
+
}
|
|
3476
|
+
};
|
|
3477
|
+
|
|
3478
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/compose.js
|
|
3479
|
+
init_compose_helpers();
|
|
3480
|
+
var ALL_TOOLS_PLACEHOLDER2 = "__ALL__";
|
|
3481
|
+
var ComposableMCPServer = class extends Server {
|
|
3482
|
+
pluginManager;
|
|
3483
|
+
toolManager;
|
|
3484
|
+
logger = createLogger("mcpc.compose");
|
|
3485
|
+
// Legacy property for backward compatibility
|
|
3486
|
+
get toolNameMapping() {
|
|
3487
|
+
return this.toolManager.getToolNameMapping();
|
|
3488
|
+
}
|
|
3489
|
+
constructor(_serverInfo, options) {
|
|
3490
|
+
const enhancedOptions = {
|
|
3491
|
+
...options,
|
|
3492
|
+
capabilities: {
|
|
3493
|
+
logging: {},
|
|
3494
|
+
tools: {},
|
|
3495
|
+
sampling: {},
|
|
3496
|
+
...options?.capabilities ?? {}
|
|
3497
|
+
}
|
|
3498
|
+
};
|
|
3499
|
+
super(_serverInfo, enhancedOptions);
|
|
3500
|
+
this.logger.setServer(this);
|
|
3501
|
+
this.pluginManager = new PluginManager(this);
|
|
3502
|
+
this.toolManager = new ToolManager();
|
|
3503
|
+
}
|
|
3504
|
+
/**
|
|
3505
|
+
* Initialize built-in plugins - called during setup
|
|
3506
|
+
*/
|
|
3507
|
+
async initBuiltInPlugins() {
|
|
3508
|
+
const builtInPlugins = getBuiltInPlugins();
|
|
3509
|
+
const validation = validatePlugins(builtInPlugins);
|
|
3510
|
+
if (!validation.valid) {
|
|
3511
|
+
await this.logger.warning("Built-in plugin validation issues:");
|
|
3512
|
+
for (const error of validation.errors) {
|
|
3513
|
+
await this.logger.warning(` - ${error}`);
|
|
3514
|
+
}
|
|
3515
|
+
}
|
|
3516
|
+
for (const plugin of builtInPlugins) {
|
|
3517
|
+
await this.pluginManager.addPlugin(plugin);
|
|
3518
|
+
}
|
|
3519
|
+
}
|
|
3520
|
+
/**
|
|
3521
|
+
* Apply plugin transformations to tool arguments/results
|
|
3522
|
+
* Supports runtime transformation hooks for input/output processing
|
|
3523
|
+
*/
|
|
3524
|
+
async applyPluginTransforms(toolName, data, direction, originalArgs) {
|
|
3525
|
+
const hookName = direction === "input" ? "transformInput" : "transformOutput";
|
|
3526
|
+
const plugins = this.pluginManager.getPlugins().filter((p2) => p2[hookName]);
|
|
3527
|
+
if (plugins.length === 0) {
|
|
3528
|
+
return data;
|
|
3529
|
+
}
|
|
3530
|
+
const { sortPluginsByOrder: sortPluginsByOrder2 } = await Promise.resolve().then(() => (init_plugin_utils(), plugin_utils_exports));
|
|
3531
|
+
const sortedPlugins = sortPluginsByOrder2(plugins);
|
|
3532
|
+
let currentData = data;
|
|
3533
|
+
const context2 = {
|
|
3534
|
+
toolName,
|
|
3535
|
+
server: this,
|
|
3536
|
+
direction,
|
|
3537
|
+
originalArgs
|
|
3538
|
+
};
|
|
3539
|
+
for (const plugin of sortedPlugins) {
|
|
3540
|
+
const hook = plugin[hookName];
|
|
3541
|
+
if (hook) {
|
|
3542
|
+
try {
|
|
3543
|
+
const result = await hook(currentData, context2);
|
|
3544
|
+
if (result !== void 0) {
|
|
3545
|
+
currentData = result;
|
|
3546
|
+
}
|
|
3547
|
+
} catch (error) {
|
|
3548
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
3549
|
+
await this.logger.error(`Plugin "${plugin.name}" ${hookName} failed for "${toolName}": ${errorMsg}`);
|
|
3550
|
+
}
|
|
3551
|
+
}
|
|
3552
|
+
}
|
|
3553
|
+
return currentData;
|
|
3554
|
+
}
|
|
3555
|
+
/**
|
|
3556
|
+
* Resolve a tool name to its internal format
|
|
3557
|
+
*/
|
|
3558
|
+
resolveToolName(name) {
|
|
3559
|
+
return this.toolManager.resolveToolName(name);
|
|
3560
|
+
}
|
|
3561
|
+
tool(name, description, paramsSchema, cb, options = {}) {
|
|
3562
|
+
const jsonSchemaObj = extractJsonSchema(paramsSchema);
|
|
3563
|
+
this.toolManager.registerTool(name, description, jsonSchemaObj, cb, options);
|
|
3564
|
+
if (!options.internal) {
|
|
3565
|
+
this.toolManager.addPublicTool(name, description, jsonSchemaObj);
|
|
3566
|
+
}
|
|
3567
|
+
if (options.plugins) {
|
|
3568
|
+
for (const plugin of options.plugins) {
|
|
3569
|
+
this.pluginManager.addPlugin(plugin);
|
|
3570
|
+
}
|
|
3571
|
+
}
|
|
3572
|
+
this.setRequestHandler(ListToolsRequestSchema, () => {
|
|
3573
|
+
return {
|
|
3574
|
+
tools: this.toolManager.getPublicTools()
|
|
3575
|
+
};
|
|
3576
|
+
});
|
|
3577
|
+
this.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
|
|
3578
|
+
const { name: toolName, arguments: args } = request.params;
|
|
3579
|
+
const handler = this.getToolCallback(toolName);
|
|
3580
|
+
if (!handler) {
|
|
3581
|
+
throw new Error(`Tool ${toolName} not found`);
|
|
3582
|
+
}
|
|
3583
|
+
const processedArgs = await this.applyPluginTransforms(toolName, args, "input");
|
|
3584
|
+
const result = await handler(processedArgs, extra);
|
|
3585
|
+
return await this.applyPluginTransforms(toolName, result, "output", args);
|
|
3586
|
+
});
|
|
3587
|
+
this.setRequestHandler(SetLevelRequestSchema, (request) => {
|
|
3588
|
+
const { level } = request.params;
|
|
3589
|
+
this.logger.setLevel(level);
|
|
3590
|
+
return {};
|
|
3591
|
+
});
|
|
3592
|
+
}
|
|
3593
|
+
/**
|
|
3594
|
+
* Get tool callback from registry
|
|
3595
|
+
*/
|
|
3596
|
+
getToolCallback(name) {
|
|
3597
|
+
return this.toolManager.getToolCallback(name);
|
|
3598
|
+
}
|
|
3599
|
+
/**
|
|
3600
|
+
* Find tool configuration
|
|
3601
|
+
*/
|
|
3602
|
+
findToolConfig(toolId) {
|
|
3603
|
+
return this.toolManager.findToolConfig(toolId);
|
|
3604
|
+
}
|
|
2477
3605
|
/**
|
|
2478
3606
|
* Call any registered tool directly, whether it's public or internal
|
|
2479
3607
|
*/
|
|
@@ -2486,207 +3614,84 @@ var ComposableMCPServer = class extends Server {
|
|
|
2486
3614
|
if (!callback) {
|
|
2487
3615
|
throw new Error(`Tool ${name} not found`);
|
|
2488
3616
|
}
|
|
2489
|
-
const processedArgs = this.applyPluginTransforms(resolvedName, args, "input");
|
|
3617
|
+
const processedArgs = await this.applyPluginTransforms(resolvedName, args, "input");
|
|
2490
3618
|
const result = await callback(processedArgs);
|
|
2491
|
-
return this.applyPluginTransforms(resolvedName, result, "output", args);
|
|
2492
|
-
}
|
|
2493
|
-
/**
|
|
2494
|
-
* Get all internal tool names
|
|
2495
|
-
*/
|
|
2496
|
-
getInternalToolNames() {
|
|
2497
|
-
return Array.from(this.toolConfigs.entries()).filter(([_name, config2]) => config2.visibility?.internal).map(([name]) => this.resolveToolName(name) ?? name);
|
|
3619
|
+
return await this.applyPluginTransforms(resolvedName, result, "output", args);
|
|
2498
3620
|
}
|
|
2499
3621
|
/**
|
|
2500
|
-
* Get all public tool names
|
|
3622
|
+
* Get all public tool names (exposed to MCP clients)
|
|
2501
3623
|
*/
|
|
2502
3624
|
getPublicToolNames() {
|
|
2503
|
-
return
|
|
3625
|
+
return this.toolManager.getPublicToolNames();
|
|
2504
3626
|
}
|
|
2505
3627
|
/**
|
|
2506
|
-
* Get all
|
|
3628
|
+
* Get all public tools (for AI SDK integration)
|
|
2507
3629
|
*/
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
const publicSet = new Set(this.getPublicToolNames());
|
|
2511
|
-
const internalSet = new Set(this.getInternalToolNames());
|
|
2512
|
-
const hiddenSet = new Set(this.getHiddenToolNames());
|
|
2513
|
-
return allRegistered.filter((n) => !publicSet.has(n) && !internalSet.has(n) && !hiddenSet.has(n));
|
|
3630
|
+
getPublicTools() {
|
|
3631
|
+
return this.toolManager.getPublicTools();
|
|
2514
3632
|
}
|
|
2515
3633
|
/**
|
|
2516
3634
|
* Get all hidden tool names
|
|
2517
3635
|
*/
|
|
2518
3636
|
getHiddenToolNames() {
|
|
2519
|
-
return
|
|
3637
|
+
return this.toolManager.getHiddenToolNames();
|
|
2520
3638
|
}
|
|
2521
3639
|
/**
|
|
2522
|
-
* Get
|
|
3640
|
+
* Get hidden tool schema by name (for internal access)
|
|
2523
3641
|
*/
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
const config2 = this.toolConfigs.get(name);
|
|
2527
|
-
if (tool && config2?.visibility?.internal && tool.schema) {
|
|
2528
|
-
return {
|
|
2529
|
-
description: tool.description,
|
|
2530
|
-
schema: tool.schema
|
|
2531
|
-
};
|
|
2532
|
-
}
|
|
2533
|
-
return void 0;
|
|
3642
|
+
getHiddenToolSchema(name) {
|
|
3643
|
+
return this.toolManager.getHiddenToolSchema(name);
|
|
2534
3644
|
}
|
|
2535
3645
|
/**
|
|
2536
|
-
* Check if a tool exists (visible or
|
|
3646
|
+
* Check if a tool exists (visible or hidden)
|
|
2537
3647
|
*/
|
|
2538
3648
|
hasToolNamed(name) {
|
|
2539
|
-
return this.
|
|
3649
|
+
return this.toolManager.hasToolNamed(name);
|
|
2540
3650
|
}
|
|
2541
3651
|
/**
|
|
2542
|
-
* Configure tool behavior
|
|
2543
|
-
* @example
|
|
2544
|
-
* ```typescript
|
|
2545
|
-
* // Override description
|
|
2546
|
-
* server.configTool('myTool', {
|
|
2547
|
-
* callback: originalCallback,
|
|
2548
|
-
* description: 'Enhanced tool description'
|
|
2549
|
-
* });
|
|
2550
|
-
*
|
|
2551
|
-
* // Hide tool from agentic execution
|
|
2552
|
-
* server.configTool('myTool', {
|
|
2553
|
-
* callback: originalCallback,
|
|
2554
|
-
* description: 'Hidden tool',
|
|
2555
|
-
* visibility: { hide: true }
|
|
2556
|
-
* });
|
|
2557
|
-
*
|
|
2558
|
-
* // Make tool globally available
|
|
2559
|
-
* server.configTool('myTool', {
|
|
2560
|
-
* callback: originalCallback,
|
|
2561
|
-
* description: 'Global tool',
|
|
2562
|
-
* visibility: { global: true }
|
|
2563
|
-
* });
|
|
2564
|
-
* ```
|
|
3652
|
+
* Configure tool behavior
|
|
2565
3653
|
*/
|
|
2566
3654
|
configTool(toolName, config2) {
|
|
2567
|
-
this.
|
|
3655
|
+
this.toolManager.configTool(toolName, config2);
|
|
2568
3656
|
}
|
|
2569
3657
|
/**
|
|
2570
3658
|
* Get tool configuration
|
|
2571
3659
|
*/
|
|
2572
3660
|
getToolConfig(toolName) {
|
|
2573
|
-
return this.
|
|
3661
|
+
return this.toolManager.getToolConfig(toolName);
|
|
2574
3662
|
}
|
|
2575
3663
|
/**
|
|
2576
3664
|
* Remove tool configuration
|
|
2577
3665
|
*/
|
|
2578
3666
|
removeToolConfig(toolName) {
|
|
2579
|
-
return this.
|
|
3667
|
+
return this.toolManager.removeToolConfig(toolName);
|
|
2580
3668
|
}
|
|
2581
3669
|
/**
|
|
2582
|
-
* Register a tool plugin
|
|
2583
|
-
* @example
|
|
2584
|
-
* ```typescript
|
|
2585
|
-
* // Global plugin for all tools
|
|
2586
|
-
* server.addPlugin({
|
|
2587
|
-
* name: 'logger',
|
|
2588
|
-
* transformTool: (tool, context) => {
|
|
2589
|
-
* const originalExecute = tool.execute;
|
|
2590
|
-
* tool.execute = async (args, extra) => {
|
|
2591
|
-
* console.log(`Calling ${tool.name} with:`, args);
|
|
2592
|
-
* const result = await originalExecute(args, extra);
|
|
2593
|
-
* console.log(`Result:`, result);
|
|
2594
|
-
* return result;
|
|
2595
|
-
* };
|
|
2596
|
-
* return tool;
|
|
2597
|
-
* }
|
|
2598
|
-
* });
|
|
2599
|
-
* ```
|
|
3670
|
+
* Register a tool plugin with validation and error handling
|
|
2600
3671
|
*/
|
|
2601
3672
|
async addPlugin(plugin) {
|
|
2602
|
-
|
|
2603
|
-
await plugin.configureServer(this);
|
|
2604
|
-
}
|
|
2605
|
-
this.globalPlugins.push(plugin);
|
|
3673
|
+
await this.pluginManager.addPlugin(plugin);
|
|
2606
3674
|
}
|
|
2607
3675
|
/**
|
|
2608
3676
|
* Load and register a plugin from a file path with optional parameters
|
|
2609
|
-
*
|
|
2610
|
-
* Supports parameter passing via query string syntax:
|
|
2611
|
-
* loadPluginFromPath("path/to/plugin.ts?param1=value1¶m2=value2")
|
|
2612
3677
|
*/
|
|
2613
|
-
async loadPluginFromPath(pluginPath
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
/**
|
|
2618
|
-
* Apply transformTool hook to a tool during composition
|
|
2619
|
-
*/
|
|
2620
|
-
async applyTransformToolHooks(tool, toolName, mode) {
|
|
2621
|
-
const transformPlugins = this.globalPlugins.filter((p2) => p2.transformTool && shouldApplyPlugin(p2, mode));
|
|
2622
|
-
if (transformPlugins.length === 0) {
|
|
2623
|
-
return tool;
|
|
2624
|
-
}
|
|
2625
|
-
const sortedPlugins = [
|
|
2626
|
-
...transformPlugins.filter((p2) => p2.enforce === "pre"),
|
|
2627
|
-
...transformPlugins.filter((p2) => !p2.enforce),
|
|
2628
|
-
...transformPlugins.filter((p2) => p2.enforce === "post")
|
|
2629
|
-
];
|
|
2630
|
-
const context = {
|
|
2631
|
-
toolName,
|
|
2632
|
-
server: this,
|
|
2633
|
-
mode
|
|
2634
|
-
};
|
|
2635
|
-
let currentTool = tool;
|
|
2636
|
-
for (const plugin of sortedPlugins) {
|
|
2637
|
-
if (plugin.transformTool) {
|
|
2638
|
-
const result = await plugin.transformTool(currentTool, context);
|
|
2639
|
-
if (result) {
|
|
2640
|
-
currentTool = result;
|
|
2641
|
-
}
|
|
2642
|
-
}
|
|
2643
|
-
}
|
|
2644
|
-
return currentTool;
|
|
3678
|
+
async loadPluginFromPath(pluginPath, options = {
|
|
3679
|
+
cache: true
|
|
3680
|
+
}) {
|
|
3681
|
+
await this.pluginManager.loadPluginFromPath(pluginPath, options);
|
|
2645
3682
|
}
|
|
2646
3683
|
/**
|
|
2647
3684
|
* Apply plugins to all tools in registry and handle visibility configurations
|
|
2648
3685
|
*/
|
|
2649
3686
|
async processToolsWithPlugins(externalTools, mode) {
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
type: "object",
|
|
2653
|
-
properties: {},
|
|
2654
|
-
additionalProperties: true
|
|
2655
|
-
};
|
|
2656
|
-
const tempTool = {
|
|
2657
|
-
name: toolId,
|
|
2658
|
-
description: toolData.description,
|
|
2659
|
-
inputSchema: toolData.schema || defaultSchema,
|
|
2660
|
-
execute: toolData.callback
|
|
2661
|
-
};
|
|
2662
|
-
const processedTool = await this.applyTransformToolHooks(tempTool, toolId, mode);
|
|
2663
|
-
this.toolRegistry.set(toolId, {
|
|
2664
|
-
callback: processedTool.execute,
|
|
2665
|
-
description: processedTool.description || toolData.description,
|
|
2666
|
-
schema: processedTool.inputSchema
|
|
2667
|
-
});
|
|
2668
|
-
if (externalTools[toolId]) {
|
|
2669
|
-
try {
|
|
2670
|
-
const builtIn = await Promise.resolve().then(() => (init_built_in(), built_in_exports));
|
|
2671
|
-
if (builtIn && typeof builtIn.processToolVisibility === "function") {
|
|
2672
|
-
builtIn.processToolVisibility(toolId, processedTool, this, externalTools);
|
|
2673
|
-
}
|
|
2674
|
-
} catch {
|
|
2675
|
-
}
|
|
2676
|
-
externalTools[toolId] = processedTool;
|
|
2677
|
-
}
|
|
2678
|
-
}
|
|
3687
|
+
const { processToolsWithPlugins: processTools } = await Promise.resolve().then(() => (init_compose_helpers(), compose_helpers_exports));
|
|
3688
|
+
await processTools(this, externalTools, mode);
|
|
2679
3689
|
}
|
|
2680
3690
|
/**
|
|
2681
|
-
*
|
|
3691
|
+
* Dispose all plugins and cleanup resources
|
|
2682
3692
|
*/
|
|
2683
|
-
async
|
|
2684
|
-
|
|
2685
|
-
for (const plugin of endPlugins) {
|
|
2686
|
-
if (plugin.composeEnd) {
|
|
2687
|
-
await plugin.composeEnd(context);
|
|
2688
|
-
}
|
|
2689
|
-
}
|
|
3693
|
+
async disposePlugins() {
|
|
3694
|
+
await this.pluginManager.dispose();
|
|
2690
3695
|
}
|
|
2691
3696
|
async compose(name, description, depsConfig = {
|
|
2692
3697
|
mcpServers: {}
|
|
@@ -2698,17 +3703,24 @@ var ComposableMCPServer = class extends Server {
|
|
|
2698
3703
|
"tool",
|
|
2699
3704
|
"fn"
|
|
2700
3705
|
]);
|
|
3706
|
+
await this.pluginManager.triggerComposeStart({
|
|
3707
|
+
serverName: name ?? "anonymous",
|
|
3708
|
+
description,
|
|
3709
|
+
mode: options.mode ?? "agentic",
|
|
3710
|
+
server: this,
|
|
3711
|
+
availableTools: []
|
|
3712
|
+
});
|
|
2701
3713
|
tagToResults.tool.forEach((toolEl) => {
|
|
2702
3714
|
const toolName = toolEl.attribs.name;
|
|
2703
3715
|
const toolDescription = toolEl.attribs.description;
|
|
2704
3716
|
const isHidden = toolEl.attribs.hide !== void 0;
|
|
2705
|
-
const
|
|
3717
|
+
const isPublic = toolEl.attribs.global !== void 0;
|
|
2706
3718
|
if (toolName) {
|
|
2707
|
-
this.
|
|
3719
|
+
this.toolManager.configTool(toolName, {
|
|
2708
3720
|
description: toolDescription,
|
|
2709
3721
|
visibility: {
|
|
2710
|
-
|
|
2711
|
-
|
|
3722
|
+
hidden: isHidden,
|
|
3723
|
+
public: isPublic
|
|
2712
3724
|
}
|
|
2713
3725
|
});
|
|
2714
3726
|
}
|
|
@@ -2727,10 +3739,10 @@ var ComposableMCPServer = class extends Server {
|
|
|
2727
3739
|
availableToolNames.add(toolId);
|
|
2728
3740
|
availableToolNames.add(`${mcpName}.${ALL_TOOLS_PLACEHOLDER2}`);
|
|
2729
3741
|
availableToolNames.add(mcpName);
|
|
2730
|
-
this.
|
|
3742
|
+
this.toolManager.setToolNameMapping(toolNameWithScope, toolId);
|
|
2731
3743
|
const internalName = toolNameWithScope.includes(".") ? toolNameWithScope.split(".").slice(1).join(".") : toolNameWithScope;
|
|
2732
3744
|
if (!this.toolNameMapping.has(internalName)) {
|
|
2733
|
-
this.
|
|
3745
|
+
this.toolManager.setToolNameMapping(internalName, toolId);
|
|
2734
3746
|
}
|
|
2735
3747
|
const matchingStep = options.steps?.find((step) => step.actions.includes(toolNameWithScope));
|
|
2736
3748
|
if (matchingStep) {
|
|
@@ -2750,53 +3762,56 @@ var ComposableMCPServer = class extends Server {
|
|
|
2750
3762
|
});
|
|
2751
3763
|
const unmatchedTools = Array.from(requestedToolNames).filter((toolName) => !availableToolNames.has(toolName));
|
|
2752
3764
|
if (unmatchedTools.length > 0) {
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
}
|
|
2757
|
-
|
|
3765
|
+
await this.logger.warning(`Tool matching warnings for agent "${name}":`);
|
|
3766
|
+
for (const toolName of unmatchedTools) {
|
|
3767
|
+
await this.logger.warning(` \u2022 Tool not found: "${toolName}"`);
|
|
3768
|
+
}
|
|
3769
|
+
await this.logger.warning(` Available tools: ${Array.from(availableToolNames).sort().join(", ")}`);
|
|
2758
3770
|
}
|
|
2759
3771
|
Object.entries(tools).forEach(([toolId, tool]) => {
|
|
2760
|
-
this.
|
|
2761
|
-
callback: tool.execute,
|
|
2762
|
-
description: tool.description || "No description available",
|
|
2763
|
-
schema: tool.inputSchema
|
|
2764
|
-
});
|
|
3772
|
+
this.toolManager.registerTool(toolId, tool.description || "No description available", tool.inputSchema, tool.execute);
|
|
2765
3773
|
});
|
|
2766
3774
|
await this.processToolsWithPlugins(tools, options.mode ?? "agentic");
|
|
3775
|
+
await this.pluginManager.triggerFinalizeComposition(tools, {
|
|
3776
|
+
serverName: name ?? "anonymous",
|
|
3777
|
+
mode: options.mode ?? "agentic",
|
|
3778
|
+
server: this,
|
|
3779
|
+
toolNames: Object.keys(tools)
|
|
3780
|
+
});
|
|
2767
3781
|
this.onclose = async () => {
|
|
2768
3782
|
await cleanupClients();
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
console.log(` \u2514\u2500 Action: cleaned up dependent clients`);
|
|
3783
|
+
await this.disposePlugins();
|
|
3784
|
+
await this.logger.info(`[${name}] Event: closed - cleaned up dependent clients and plugins`);
|
|
2772
3785
|
};
|
|
2773
3786
|
this.onerror = async (error) => {
|
|
2774
|
-
|
|
2775
|
-
console.log(` \u251C\u2500 Event: error, ${error?.stack ?? String(error)}`);
|
|
3787
|
+
await this.logger.error(`[${name}] Event: error - ${error?.stack ?? String(error)}`);
|
|
2776
3788
|
await cleanupClients();
|
|
2777
|
-
|
|
3789
|
+
await this.disposePlugins();
|
|
3790
|
+
await this.logger.info(`[${name}] Action: cleaned up dependent clients and plugins`);
|
|
2778
3791
|
};
|
|
2779
3792
|
const toolNameToDetailList = Object.entries(tools);
|
|
2780
|
-
const
|
|
2781
|
-
const
|
|
2782
|
-
const
|
|
2783
|
-
|
|
2784
|
-
const allToolNames = [
|
|
2785
|
-
...contextToolNames,
|
|
2786
|
-
...internalToolNames
|
|
2787
|
-
];
|
|
2788
|
-
globalToolNames.forEach((toolId) => {
|
|
3793
|
+
const publicToolNames = this.getPublicToolNames();
|
|
3794
|
+
const hiddenToolNames = this.getHiddenToolNames();
|
|
3795
|
+
const contextToolNames = toolNameToDetailList.map(([name2]) => name2).filter((n) => !hiddenToolNames.includes(n));
|
|
3796
|
+
publicToolNames.forEach((toolId) => {
|
|
2789
3797
|
const tool = tools[toolId];
|
|
2790
3798
|
if (!tool) {
|
|
2791
|
-
throw new Error(`
|
|
3799
|
+
throw new Error(`Public tool ${toolId} not found in registry, available: ${Object.keys(tools).join(", ")}`);
|
|
2792
3800
|
}
|
|
2793
|
-
this.tool(toolId, tool.description || "No description available",
|
|
3801
|
+
this.tool(toolId, tool.description || "No description available", jsonSchema(tool.inputSchema), tool.execute, {
|
|
3802
|
+
internal: false
|
|
3803
|
+
});
|
|
2794
3804
|
});
|
|
2795
|
-
await this.
|
|
3805
|
+
await this.pluginManager.triggerComposeEnd({
|
|
2796
3806
|
toolName: name,
|
|
2797
|
-
pluginNames: this.
|
|
3807
|
+
pluginNames: this.pluginManager.getPluginNames(),
|
|
2798
3808
|
mode: options.mode ?? "agentic",
|
|
2799
|
-
server: this
|
|
3809
|
+
server: this,
|
|
3810
|
+
stats: {
|
|
3811
|
+
totalTools: this.toolManager.getTotalToolCount(),
|
|
3812
|
+
publicTools: publicToolNames.length,
|
|
3813
|
+
hiddenTools: hiddenToolNames.length
|
|
3814
|
+
}
|
|
2800
3815
|
});
|
|
2801
3816
|
if (!name) {
|
|
2802
3817
|
return;
|
|
@@ -2809,50 +3824,11 @@ var ComposableMCPServer = class extends Server {
|
|
|
2809
3824
|
...desTags,
|
|
2810
3825
|
description,
|
|
2811
3826
|
tools,
|
|
2812
|
-
toolOverrides:
|
|
3827
|
+
toolOverrides: /* @__PURE__ */ new Map(),
|
|
2813
3828
|
toolNameMapping: toolNameToIdMapping
|
|
2814
3829
|
});
|
|
2815
|
-
const
|
|
2816
|
-
toolNameToDetailList
|
|
2817
|
-
if (hideToolNames.includes(this.resolveToolName(toolName) ?? "") || globalToolNames.includes(this.resolveToolName(toolName) ?? "")) {
|
|
2818
|
-
return;
|
|
2819
|
-
}
|
|
2820
|
-
if (!tool) {
|
|
2821
|
-
throw new Error(`Action ${toolName} not found, available action list: ${allToolNames.join(", ")}`);
|
|
2822
|
-
}
|
|
2823
|
-
const baseSchema = (
|
|
2824
|
-
// Compatiable with ComposiableleMCPServer.tool() definition
|
|
2825
|
-
tool.inputSchema.jsonSchema ?? // Standard definition
|
|
2826
|
-
tool.inputSchema ?? {
|
|
2827
|
-
type: "object",
|
|
2828
|
-
properties: {},
|
|
2829
|
-
required: []
|
|
2830
|
-
}
|
|
2831
|
-
);
|
|
2832
|
-
const baseProperties = baseSchema.type === "object" && baseSchema.properties ? baseSchema.properties : {};
|
|
2833
|
-
const baseRequired = baseSchema.type === "object" && Array.isArray(baseSchema.required) ? baseSchema.required : [];
|
|
2834
|
-
const updatedProperties = updateRefPaths(baseProperties, toolName);
|
|
2835
|
-
depGroups[toolName] = {
|
|
2836
|
-
type: "object",
|
|
2837
|
-
description: tool.description,
|
|
2838
|
-
properties: updatedProperties,
|
|
2839
|
-
required: [
|
|
2840
|
-
...baseRequired
|
|
2841
|
-
],
|
|
2842
|
-
additionalProperties: false
|
|
2843
|
-
};
|
|
2844
|
-
});
|
|
2845
|
-
internalToolNames.forEach((toolName) => {
|
|
2846
|
-
const toolSchema = this.getInternalToolSchema(toolName);
|
|
2847
|
-
if (toolSchema) {
|
|
2848
|
-
depGroups[toolName] = {
|
|
2849
|
-
...toolSchema.schema,
|
|
2850
|
-
description: toolSchema.description
|
|
2851
|
-
};
|
|
2852
|
-
} else {
|
|
2853
|
-
throw new Error(`Internal tool schema not found for: ${toolName}`);
|
|
2854
|
-
}
|
|
2855
|
-
});
|
|
3830
|
+
const allToolNames = contextToolNames;
|
|
3831
|
+
const depGroups = buildDependencyGroups(toolNameToDetailList, hiddenToolNames, publicToolNames, this);
|
|
2856
3832
|
switch (options.mode ?? "agentic") {
|
|
2857
3833
|
case "agentic":
|
|
2858
3834
|
registerAgenticTool(this, {
|
|
@@ -2881,17 +3857,17 @@ var ComposableMCPServer = class extends Server {
|
|
|
2881
3857
|
}
|
|
2882
3858
|
};
|
|
2883
3859
|
|
|
2884
|
-
// ../
|
|
2885
|
-
import
|
|
2886
|
-
var isSCF = () => Boolean(
|
|
3860
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/env.js
|
|
3861
|
+
import process6 from "node:process";
|
|
3862
|
+
var isSCF = () => Boolean(process6.env.SCF_RUNTIME || process6.env.PROD_SCF);
|
|
2887
3863
|
if (isSCF()) {
|
|
2888
3864
|
console.log({
|
|
2889
3865
|
isSCF: isSCF(),
|
|
2890
|
-
SCF_RUNTIME:
|
|
3866
|
+
SCF_RUNTIME: process6.env.SCF_RUNTIME
|
|
2891
3867
|
});
|
|
2892
3868
|
}
|
|
2893
3869
|
|
|
2894
|
-
// ../
|
|
3870
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/set-up-mcp-compose.js
|
|
2895
3871
|
function parseMcpcConfigs(conf) {
|
|
2896
3872
|
const mcpcConfigs = conf ?? [];
|
|
2897
3873
|
const newMcpcConfigs = [];
|
|
@@ -2932,7 +3908,10 @@ async function mcpc(serverConf, composeConf, setupCallback) {
|
|
|
2932
3908
|
return server2;
|
|
2933
3909
|
}
|
|
2934
3910
|
|
|
2935
|
-
// ../
|
|
3911
|
+
// ../__mcpc__cli_latest/node_modules/@jsr/mcpc__core/mod.js
|
|
3912
|
+
init_schema();
|
|
3913
|
+
|
|
3914
|
+
// ../__mcpc__cli_latest/node_modules/@mcpc/cli/src/app.js
|
|
2936
3915
|
var createServer = async (config2) => {
|
|
2937
3916
|
const serverConfig = config2 || {
|
|
2938
3917
|
name: "large-result-plugin-example",
|
|
@@ -2953,20 +3932,80 @@ var createServer = async (config2) => {
|
|
|
2953
3932
|
version: serverConfig.version || "0.1.0"
|
|
2954
3933
|
},
|
|
2955
3934
|
{
|
|
2956
|
-
capabilities: serverConfig
|
|
3935
|
+
capabilities: serverConfig?.capabilities || {
|
|
2957
3936
|
tools: {},
|
|
2958
|
-
sampling: {}
|
|
3937
|
+
sampling: {},
|
|
3938
|
+
logging: {}
|
|
2959
3939
|
}
|
|
2960
3940
|
}
|
|
2961
3941
|
], serverConfig.agents);
|
|
2962
3942
|
};
|
|
2963
3943
|
|
|
2964
|
-
// ../
|
|
3944
|
+
// ../__mcpc__cli_latest/node_modules/@mcpc/cli/src/config/loader.js
|
|
2965
3945
|
import { readFile } from "node:fs/promises";
|
|
2966
3946
|
import { resolve } from "node:path";
|
|
2967
|
-
import
|
|
3947
|
+
import process7 from "node:process";
|
|
3948
|
+
function printHelp() {
|
|
3949
|
+
console.log(`
|
|
3950
|
+
MCPC CLI - Model Context Protocol Composer
|
|
3951
|
+
|
|
3952
|
+
USAGE:
|
|
3953
|
+
npx -y deno run -A jsr:@mcpc/cli/bin [OPTIONS]
|
|
3954
|
+
|
|
3955
|
+
OPTIONS:
|
|
3956
|
+
--help, -h Show this help message
|
|
3957
|
+
--config <json> Inline JSON configuration string
|
|
3958
|
+
--config-url <url> Fetch configuration from URL
|
|
3959
|
+
--config-file <path> Load configuration from file path
|
|
3960
|
+
--request-headers <header>, -H <header>
|
|
3961
|
+
Add custom HTTP header for URL fetching
|
|
3962
|
+
Format: "Key: Value" or "Key=Value"
|
|
3963
|
+
Can be used multiple times
|
|
3964
|
+
|
|
3965
|
+
ENVIRONMENT VARIABLES:
|
|
3966
|
+
MCPC_CONFIG Inline JSON configuration (same as --config)
|
|
3967
|
+
MCPC_CONFIG_URL URL to fetch config from (same as --config-url)
|
|
3968
|
+
MCPC_CONFIG_FILE Path to config file (same as --config-file)
|
|
3969
|
+
|
|
3970
|
+
EXAMPLES:
|
|
3971
|
+
# Show help
|
|
3972
|
+
npx -y deno run -A jsr:@mcpc/cli/bin --help
|
|
3973
|
+
|
|
3974
|
+
# Load from URL
|
|
3975
|
+
npx -y deno run -A jsr:@mcpc/cli/bin --config-url \\
|
|
3976
|
+
"https://raw.githubusercontent.com/mcpc-tech/mcpc/main/packages/cli/examples/configs/codex-fork.json"
|
|
3977
|
+
|
|
3978
|
+
# Load from URL with custom headers
|
|
3979
|
+
npx -y deno run -A jsr:@mcpc/cli/bin \\
|
|
3980
|
+
--config-url "https://api.example.com/config.json" \\
|
|
3981
|
+
-H "Authorization: Bearer token123" \\
|
|
3982
|
+
-H "X-Custom-Header: value"
|
|
3983
|
+
|
|
3984
|
+
# Load from file
|
|
3985
|
+
npx -y deno run -A jsr:@mcpc/cli/bin --config-file ./my-config.json
|
|
3986
|
+
|
|
3987
|
+
# Using environment variable
|
|
3988
|
+
export MCPC_CONFIG='[{"name":"agent","description":"..."}]'
|
|
3989
|
+
npx -y deno run -A jsr:@mcpc/cli/bin
|
|
3990
|
+
|
|
3991
|
+
# Use default configuration (./mcpc.config.json)
|
|
3992
|
+
npx -y deno run -A jsr:@mcpc/cli/bin
|
|
3993
|
+
|
|
3994
|
+
CONFIGURATION:
|
|
3995
|
+
Configuration files support environment variable substitution using $VAR_NAME syntax.
|
|
3996
|
+
|
|
3997
|
+
Priority order:
|
|
3998
|
+
1. --config (inline JSON)
|
|
3999
|
+
2. MCPC_CONFIG environment variable
|
|
4000
|
+
3. --config-url or MCPC_CONFIG_URL
|
|
4001
|
+
4. --config-file or MCPC_CONFIG_FILE
|
|
4002
|
+
5. ./mcpc.config.json (default)
|
|
4003
|
+
|
|
4004
|
+
For more information, visit: https://github.com/mcpc-tech/mcpc
|
|
4005
|
+
`);
|
|
4006
|
+
}
|
|
2968
4007
|
function parseArgs() {
|
|
2969
|
-
const args =
|
|
4008
|
+
const args = process7.argv.slice(2);
|
|
2970
4009
|
const result = {};
|
|
2971
4010
|
for (let i = 0; i < args.length; i++) {
|
|
2972
4011
|
const arg = args[i];
|
|
@@ -2976,12 +4015,31 @@ function parseArgs() {
|
|
|
2976
4015
|
result.configUrl = args[++i];
|
|
2977
4016
|
} else if (arg === "--config-file" && i + 1 < args.length) {
|
|
2978
4017
|
result.configFile = args[++i];
|
|
4018
|
+
} else if ((arg === "--request-headers" || arg === "-H") && i + 1 < args.length) {
|
|
4019
|
+
const headerStr = args[++i];
|
|
4020
|
+
const colonIdx = headerStr.indexOf(":");
|
|
4021
|
+
const equalIdx = headerStr.indexOf("=");
|
|
4022
|
+
const separatorIdx = colonIdx !== -1 ? equalIdx !== -1 ? Math.min(colonIdx, equalIdx) : colonIdx : equalIdx;
|
|
4023
|
+
if (separatorIdx !== -1) {
|
|
4024
|
+
const key = headerStr.substring(0, separatorIdx).trim();
|
|
4025
|
+
const value = headerStr.substring(separatorIdx + 1).trim();
|
|
4026
|
+
if (!result.requestHeaders) {
|
|
4027
|
+
result.requestHeaders = {};
|
|
4028
|
+
}
|
|
4029
|
+
result.requestHeaders[key] = value;
|
|
4030
|
+
}
|
|
4031
|
+
} else if (arg === "--help" || arg === "-h") {
|
|
4032
|
+
result.help = true;
|
|
2979
4033
|
}
|
|
2980
4034
|
}
|
|
2981
4035
|
return result;
|
|
2982
4036
|
}
|
|
2983
4037
|
async function loadConfig() {
|
|
2984
4038
|
const args = parseArgs();
|
|
4039
|
+
if (args.help) {
|
|
4040
|
+
printHelp();
|
|
4041
|
+
process7.exit(0);
|
|
4042
|
+
}
|
|
2985
4043
|
if (args.config) {
|
|
2986
4044
|
try {
|
|
2987
4045
|
const parsed = JSON.parse(args.config);
|
|
@@ -2991,9 +4049,25 @@ async function loadConfig() {
|
|
|
2991
4049
|
throw error;
|
|
2992
4050
|
}
|
|
2993
4051
|
}
|
|
2994
|
-
if (
|
|
4052
|
+
if (process7.env.MCPC_CONFIG) {
|
|
4053
|
+
try {
|
|
4054
|
+
const parsed = JSON.parse(process7.env.MCPC_CONFIG);
|
|
4055
|
+
return normalizeConfig(parsed);
|
|
4056
|
+
} catch (error) {
|
|
4057
|
+
console.error("Failed to parse MCPC_CONFIG environment variable:", error);
|
|
4058
|
+
throw error;
|
|
4059
|
+
}
|
|
4060
|
+
}
|
|
4061
|
+
const configUrl = args.configUrl || process7.env.MCPC_CONFIG_URL;
|
|
4062
|
+
if (configUrl) {
|
|
2995
4063
|
try {
|
|
2996
|
-
const
|
|
4064
|
+
const headers = {
|
|
4065
|
+
"User-Agent": "MCPC-CLI/0.1.0",
|
|
4066
|
+
...args.requestHeaders
|
|
4067
|
+
};
|
|
4068
|
+
const response = await fetch(configUrl, {
|
|
4069
|
+
headers
|
|
4070
|
+
});
|
|
2997
4071
|
if (!response.ok) {
|
|
2998
4072
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
2999
4073
|
}
|
|
@@ -3001,26 +4075,27 @@ async function loadConfig() {
|
|
|
3001
4075
|
const parsed = JSON.parse(content);
|
|
3002
4076
|
return normalizeConfig(parsed);
|
|
3003
4077
|
} catch (error) {
|
|
3004
|
-
console.error(`Failed to fetch config from ${
|
|
4078
|
+
console.error(`Failed to fetch config from ${configUrl}:`, error);
|
|
3005
4079
|
throw error;
|
|
3006
4080
|
}
|
|
3007
4081
|
}
|
|
3008
|
-
|
|
4082
|
+
const configFile = args.configFile || process7.env.MCPC_CONFIG_FILE;
|
|
4083
|
+
if (configFile) {
|
|
3009
4084
|
try {
|
|
3010
|
-
const content = await readFile(
|
|
4085
|
+
const content = await readFile(configFile, "utf-8");
|
|
3011
4086
|
const parsed = JSON.parse(content);
|
|
3012
4087
|
return normalizeConfig(parsed);
|
|
3013
4088
|
} catch (error) {
|
|
3014
4089
|
if (error.code === "ENOENT") {
|
|
3015
|
-
console.error(`Config file not found: ${
|
|
4090
|
+
console.error(`Config file not found: ${configFile}`);
|
|
3016
4091
|
throw error;
|
|
3017
4092
|
} else {
|
|
3018
|
-
console.error(`Failed to load config from ${
|
|
4093
|
+
console.error(`Failed to load config from ${configFile}:`, error);
|
|
3019
4094
|
throw error;
|
|
3020
4095
|
}
|
|
3021
4096
|
}
|
|
3022
4097
|
}
|
|
3023
|
-
const defaultConfigPath = resolve(
|
|
4098
|
+
const defaultConfigPath = resolve(process7.cwd(), "mcpc.config.json");
|
|
3024
4099
|
try {
|
|
3025
4100
|
const content = await readFile(defaultConfigPath, "utf-8");
|
|
3026
4101
|
const parsed = JSON.parse(content);
|
|
@@ -3036,7 +4111,7 @@ async function loadConfig() {
|
|
|
3036
4111
|
}
|
|
3037
4112
|
function replaceEnvVars(str) {
|
|
3038
4113
|
return str.replace(/\$([A-Z_][A-Z0-9_]*)/g, (_match, varName) => {
|
|
3039
|
-
return
|
|
4114
|
+
return process7.env[varName] || "";
|
|
3040
4115
|
});
|
|
3041
4116
|
}
|
|
3042
4117
|
function replaceEnvVarsInConfig(obj) {
|
|
@@ -3084,7 +4159,7 @@ function normalizeAgents(agents) {
|
|
|
3084
4159
|
});
|
|
3085
4160
|
}
|
|
3086
4161
|
|
|
3087
|
-
// ../
|
|
4162
|
+
// ../__mcpc__cli_latest/node_modules/@mcpc/cli/src/bin.ts
|
|
3088
4163
|
var config = await loadConfig();
|
|
3089
4164
|
if (config) {
|
|
3090
4165
|
console.error(`Loaded configuration with ${config.agents.length} agent(s)`);
|