@mcpc-tech/cli 0.1.10 → 0.1.11
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/bin/mcpc.mjs +424 -421
- package/package.json +1 -1
package/bin/mcpc.mjs
CHANGED
|
@@ -25,7 +25,7 @@ function jsonSchema(schema, options = {}) {
|
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
function isWrappedSchema(value) {
|
|
28
|
-
return typeof value === "object" && value !== null && schemaSymbol in value && value[schemaSymbol] === true;
|
|
28
|
+
return typeof value === "object" && value !== null && (schemaSymbol in value && value[schemaSymbol] === true || vercelSchemaSymbol in value && value[vercelSchemaSymbol] === true);
|
|
29
29
|
}
|
|
30
30
|
function extractJsonSchema(schema) {
|
|
31
31
|
if (isWrappedSchema(schema)) {
|
|
@@ -33,10 +33,11 @@ function extractJsonSchema(schema) {
|
|
|
33
33
|
}
|
|
34
34
|
return schema;
|
|
35
35
|
}
|
|
36
|
-
var schemaSymbol, validatorSymbol;
|
|
36
|
+
var schemaSymbol, vercelSchemaSymbol, validatorSymbol;
|
|
37
37
|
var init_schema = __esm({
|
|
38
38
|
"__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/schema.js"() {
|
|
39
39
|
schemaSymbol = Symbol.for("mcpc.schema");
|
|
40
|
+
vercelSchemaSymbol = Symbol.for("vercel.ai.schema");
|
|
40
41
|
validatorSymbol = Symbol.for("mcpc.validator");
|
|
41
42
|
}
|
|
42
43
|
});
|
|
@@ -59,7 +60,7 @@ var init_json = __esm({
|
|
|
59
60
|
|
|
60
61
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/provider.js
|
|
61
62
|
function sanitizePropertyKey(name) {
|
|
62
|
-
return name.replace(/[
|
|
63
|
+
return name.replace(/[@.,/\\:;!?#$%^&*()[\]{}]/g, "_").substring(0, 64);
|
|
63
64
|
}
|
|
64
65
|
var createGoogleCompatibleJSONSchema;
|
|
65
66
|
var init_provider = __esm({
|
|
@@ -251,12 +252,21 @@ var init_logging_plugin = __esm({
|
|
|
251
252
|
const { stats } = context2;
|
|
252
253
|
const server2 = context2.server;
|
|
253
254
|
const publicTools = Array.from(new Set(server2.getPublicToolNames().map(String)));
|
|
255
|
+
const internalTools = Array.from(new Set(server2.getInternalToolNames().map(String)));
|
|
254
256
|
const hiddenTools = Array.from(new Set(server2.getHiddenToolNames().map(String)));
|
|
257
|
+
const normalInternal = internalTools.filter((name) => !hiddenTools.includes(name));
|
|
255
258
|
if (publicTools.length > 0) {
|
|
256
259
|
await logger2.info(` \u251C\u2500 Public: ${publicTools.join(", ")}`);
|
|
257
260
|
}
|
|
258
|
-
if (
|
|
259
|
-
|
|
261
|
+
if (internalTools.length > 0) {
|
|
262
|
+
const parts = [];
|
|
263
|
+
if (normalInternal.length > 0) {
|
|
264
|
+
parts.push(normalInternal.join(", "));
|
|
265
|
+
}
|
|
266
|
+
if (hiddenTools.length > 0) {
|
|
267
|
+
parts.push(`(${hiddenTools.join(", ")})`);
|
|
268
|
+
}
|
|
269
|
+
await logger2.info(` \u251C\u2500 Internal: ${parts.join(", ")}`);
|
|
260
270
|
}
|
|
261
271
|
await logger2.info(` \u2514\u2500 Total: ${stats.totalTools} tools`);
|
|
262
272
|
}
|
|
@@ -296,218 +306,6 @@ var init_built_in = __esm({
|
|
|
296
306
|
}
|
|
297
307
|
});
|
|
298
308
|
|
|
299
|
-
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/plugin-utils.js
|
|
300
|
-
var plugin_utils_exports = {};
|
|
301
|
-
__export(plugin_utils_exports, {
|
|
302
|
-
checkCircularDependencies: () => checkCircularDependencies,
|
|
303
|
-
clearPluginCache: () => clearPluginCache,
|
|
304
|
-
getPluginsWithHook: () => getPluginsWithHook,
|
|
305
|
-
isValidPlugin: () => isValidPlugin,
|
|
306
|
-
loadPlugin: () => loadPlugin,
|
|
307
|
-
shouldApplyPlugin: () => shouldApplyPlugin,
|
|
308
|
-
sortPluginsByOrder: () => sortPluginsByOrder,
|
|
309
|
-
validatePlugins: () => validatePlugins
|
|
310
|
-
});
|
|
311
|
-
function shouldApplyPlugin(plugin, mode) {
|
|
312
|
-
if (!plugin.apply) return true;
|
|
313
|
-
if (typeof plugin.apply === "string") {
|
|
314
|
-
return mode.includes(plugin.apply);
|
|
315
|
-
}
|
|
316
|
-
if (typeof plugin.apply === "function") {
|
|
317
|
-
try {
|
|
318
|
-
return plugin.apply(mode);
|
|
319
|
-
} catch (error) {
|
|
320
|
-
console.warn(`Plugin "${plugin.name}" apply function failed: ${error}. Defaulting to true.`);
|
|
321
|
-
return true;
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
return true;
|
|
325
|
-
}
|
|
326
|
-
function sortPluginsByOrder(plugins) {
|
|
327
|
-
const pluginMap = /* @__PURE__ */ new Map();
|
|
328
|
-
for (const plugin of plugins) {
|
|
329
|
-
pluginMap.set(plugin.name, plugin);
|
|
330
|
-
}
|
|
331
|
-
const visited = /* @__PURE__ */ new Set();
|
|
332
|
-
const sorted = [];
|
|
333
|
-
function visit(plugin) {
|
|
334
|
-
if (visited.has(plugin.name)) return;
|
|
335
|
-
visited.add(plugin.name);
|
|
336
|
-
if (plugin.dependencies) {
|
|
337
|
-
for (const depName of plugin.dependencies) {
|
|
338
|
-
const dep = pluginMap.get(depName);
|
|
339
|
-
if (dep) {
|
|
340
|
-
visit(dep);
|
|
341
|
-
} else {
|
|
342
|
-
console.warn(`Plugin "${plugin.name}" depends on "${depName}" which is not loaded`);
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
sorted.push(plugin);
|
|
347
|
-
}
|
|
348
|
-
const prePlugins = plugins.filter((p2) => p2.enforce === "pre");
|
|
349
|
-
const normalPlugins = plugins.filter((p2) => !p2.enforce);
|
|
350
|
-
const postPlugins = plugins.filter((p2) => p2.enforce === "post");
|
|
351
|
-
[
|
|
352
|
-
...prePlugins,
|
|
353
|
-
...normalPlugins,
|
|
354
|
-
...postPlugins
|
|
355
|
-
].forEach(visit);
|
|
356
|
-
return sorted;
|
|
357
|
-
}
|
|
358
|
-
function getPluginsWithHook(plugins, hookName) {
|
|
359
|
-
return plugins.filter((p2) => typeof p2[hookName] === "function");
|
|
360
|
-
}
|
|
361
|
-
function isValidPlugin(plugin) {
|
|
362
|
-
if (!plugin || typeof plugin !== "object") return false;
|
|
363
|
-
const p2 = plugin;
|
|
364
|
-
if (!p2.name || typeof p2.name !== "string" || p2.name.trim() === "") {
|
|
365
|
-
return false;
|
|
366
|
-
}
|
|
367
|
-
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";
|
|
368
|
-
if (!hasHook) return false;
|
|
369
|
-
if (p2.enforce && p2.enforce !== "pre" && p2.enforce !== "post") {
|
|
370
|
-
return false;
|
|
371
|
-
}
|
|
372
|
-
if (p2.apply && typeof p2.apply !== "string" && typeof p2.apply !== "function") {
|
|
373
|
-
return false;
|
|
374
|
-
}
|
|
375
|
-
if (p2.dependencies && !Array.isArray(p2.dependencies)) {
|
|
376
|
-
return false;
|
|
377
|
-
}
|
|
378
|
-
return true;
|
|
379
|
-
}
|
|
380
|
-
function parseQueryParams(params) {
|
|
381
|
-
const typedParams = {};
|
|
382
|
-
for (const [key, value] of Object.entries(params)) {
|
|
383
|
-
const numValue = Number(value);
|
|
384
|
-
if (!isNaN(numValue) && value.trim() !== "") {
|
|
385
|
-
typedParams[key] = numValue;
|
|
386
|
-
continue;
|
|
387
|
-
}
|
|
388
|
-
if (value === "true") {
|
|
389
|
-
typedParams[key] = true;
|
|
390
|
-
continue;
|
|
391
|
-
}
|
|
392
|
-
if (value === "false") {
|
|
393
|
-
typedParams[key] = false;
|
|
394
|
-
continue;
|
|
395
|
-
}
|
|
396
|
-
if (value.includes(",")) {
|
|
397
|
-
typedParams[key] = value.split(",").map((v) => v.trim());
|
|
398
|
-
continue;
|
|
399
|
-
}
|
|
400
|
-
typedParams[key] = value;
|
|
401
|
-
}
|
|
402
|
-
return typedParams;
|
|
403
|
-
}
|
|
404
|
-
async function loadPlugin(pluginPath, options = {
|
|
405
|
-
cache: true
|
|
406
|
-
}) {
|
|
407
|
-
if (options.cache && pluginCache.has(pluginPath)) {
|
|
408
|
-
return pluginCache.get(pluginPath);
|
|
409
|
-
}
|
|
410
|
-
try {
|
|
411
|
-
const [rawPath, queryString] = pluginPath.split("?", 2);
|
|
412
|
-
const searchParams = new URLSearchParams(queryString || "");
|
|
413
|
-
const params = Object.fromEntries(searchParams.entries());
|
|
414
|
-
const importPath = rawPath;
|
|
415
|
-
const pluginModule = await import(importPath);
|
|
416
|
-
const pluginFactory = pluginModule.createPlugin;
|
|
417
|
-
const defaultPlugin = pluginModule.default;
|
|
418
|
-
let plugin;
|
|
419
|
-
if (Object.keys(params).length > 0) {
|
|
420
|
-
if (typeof pluginFactory !== "function") {
|
|
421
|
-
throw new Error(`Plugin "${rawPath}" has parameters but no createPlugin export function`);
|
|
422
|
-
}
|
|
423
|
-
const typedParams = parseQueryParams(params);
|
|
424
|
-
plugin = pluginFactory(typedParams);
|
|
425
|
-
} else {
|
|
426
|
-
if (defaultPlugin) {
|
|
427
|
-
plugin = defaultPlugin;
|
|
428
|
-
} else if (typeof pluginFactory === "function") {
|
|
429
|
-
plugin = pluginFactory();
|
|
430
|
-
} else {
|
|
431
|
-
throw new Error(`Plugin "${rawPath}" has no default export or createPlugin function`);
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
if (!isValidPlugin(plugin)) {
|
|
435
|
-
throw new Error(`Invalid plugin format in "${rawPath}": must have a unique name and at least one lifecycle hook`);
|
|
436
|
-
}
|
|
437
|
-
if (options.cache) {
|
|
438
|
-
pluginCache.set(pluginPath, plugin);
|
|
439
|
-
}
|
|
440
|
-
return plugin;
|
|
441
|
-
} catch (error) {
|
|
442
|
-
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
443
|
-
throw new Error(`Failed to load plugin from "${pluginPath}": ${errorMsg}`);
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
function clearPluginCache() {
|
|
447
|
-
pluginCache.clear();
|
|
448
|
-
}
|
|
449
|
-
function checkCircularDependencies(plugins) {
|
|
450
|
-
const errors = [];
|
|
451
|
-
const pluginMap = /* @__PURE__ */ new Map();
|
|
452
|
-
for (const plugin of plugins) {
|
|
453
|
-
pluginMap.set(plugin.name, plugin);
|
|
454
|
-
}
|
|
455
|
-
function checkCircular(pluginName, visited, path) {
|
|
456
|
-
if (visited.has(pluginName)) {
|
|
457
|
-
const cycle = [
|
|
458
|
-
...path,
|
|
459
|
-
pluginName
|
|
460
|
-
].join(" -> ");
|
|
461
|
-
errors.push(`Circular dependency detected: ${cycle}`);
|
|
462
|
-
return;
|
|
463
|
-
}
|
|
464
|
-
const plugin = pluginMap.get(pluginName);
|
|
465
|
-
if (!plugin || !plugin.dependencies) return;
|
|
466
|
-
visited.add(pluginName);
|
|
467
|
-
path.push(pluginName);
|
|
468
|
-
for (const dep of plugin.dependencies) {
|
|
469
|
-
checkCircular(dep, new Set(visited), [
|
|
470
|
-
...path
|
|
471
|
-
]);
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
for (const plugin of plugins) {
|
|
475
|
-
checkCircular(plugin.name, /* @__PURE__ */ new Set(), []);
|
|
476
|
-
}
|
|
477
|
-
return errors;
|
|
478
|
-
}
|
|
479
|
-
function validatePlugins(plugins) {
|
|
480
|
-
const errors = [];
|
|
481
|
-
const names = /* @__PURE__ */ new Map();
|
|
482
|
-
for (const plugin of plugins) {
|
|
483
|
-
const count = names.get(plugin.name) || 0;
|
|
484
|
-
names.set(plugin.name, count + 1);
|
|
485
|
-
}
|
|
486
|
-
for (const [name, count] of names.entries()) {
|
|
487
|
-
if (count > 1) {
|
|
488
|
-
errors.push(`Duplicate plugin name: "${name}" (${count} instances)`);
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
const circularErrors = checkCircularDependencies(plugins);
|
|
492
|
-
errors.push(...circularErrors);
|
|
493
|
-
for (const plugin of plugins) {
|
|
494
|
-
if (!isValidPlugin(plugin)) {
|
|
495
|
-
const name = plugin.name || "unknown";
|
|
496
|
-
errors.push(`Invalid plugin: "${name}"`);
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
return {
|
|
500
|
-
valid: errors.length === 0,
|
|
501
|
-
errors
|
|
502
|
-
};
|
|
503
|
-
}
|
|
504
|
-
var pluginCache;
|
|
505
|
-
var init_plugin_utils = __esm({
|
|
506
|
-
"__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/plugin-utils.js"() {
|
|
507
|
-
pluginCache = /* @__PURE__ */ new Map();
|
|
508
|
-
}
|
|
509
|
-
});
|
|
510
|
-
|
|
511
309
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/schema.js
|
|
512
310
|
import traverse from "json-schema-traverse";
|
|
513
311
|
function updateRefPaths(schema, wrapperPath) {
|
|
@@ -1050,160 +848,166 @@ var SystemPrompts = {
|
|
|
1050
848
|
/**
|
|
1051
849
|
* Base system prompt for autonomous MCP execution
|
|
1052
850
|
*/
|
|
1053
|
-
AUTONOMOUS_EXECUTION: `
|
|
851
|
+
AUTONOMOUS_EXECUTION: `Agentic tool \`{toolName}\` that executes complex tasks by iteratively calling actions, gathering results, and deciding next steps until completion. Use this tool when the task matches the manual below.
|
|
1054
852
|
|
|
1055
|
-
<
|
|
853
|
+
You must follow the <manual/>, obey the <execution_rules/>, and use the <call_format/>.
|
|
1056
854
|
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
855
|
+
<manual>
|
|
856
|
+
{description}
|
|
857
|
+
</manual>
|
|
858
|
+
|
|
859
|
+
<execution_rules>
|
|
860
|
+
1. **Execute** one action per call
|
|
861
|
+
2. **Collect** feedback from each action result
|
|
862
|
+
3. **Decide** next step based on feedback:
|
|
1063
863
|
- **proceed**: More work needed
|
|
1064
|
-
- **complete**:
|
|
864
|
+
- **complete**: Task finished (omit action field)
|
|
1065
865
|
- **retry**: Current action failed
|
|
1066
|
-
|
|
1067
|
-
|
|
866
|
+
4. **Provide** parameters matching the action name
|
|
867
|
+
5. **Continue** until task is complete
|
|
868
|
+
6. Note: You are an agent exposed as an MCP tool - **"action" is an internal parameter, NOT an external MCP tool you can call**
|
|
869
|
+
</execution_rules>
|
|
1068
870
|
|
|
1069
|
-
|
|
871
|
+
<call_format>
|
|
1070
872
|
\`\`\`json
|
|
1071
873
|
{
|
|
1072
|
-
"action": "
|
|
874
|
+
"action": "action_name",
|
|
1073
875
|
"decision": "proceed|retry",
|
|
1074
|
-
"
|
|
876
|
+
"action_name": { /* action parameters */ }
|
|
1075
877
|
}
|
|
1076
878
|
\`\`\`
|
|
1077
879
|
|
|
1078
|
-
|
|
880
|
+
When complete:
|
|
1079
881
|
\`\`\`json
|
|
1080
882
|
{
|
|
1081
883
|
"decision": "complete"
|
|
1082
884
|
}
|
|
1083
|
-
|
|
885
|
+
\`\`\`
|
|
886
|
+
</call_format>`,
|
|
1084
887
|
/**
|
|
1085
888
|
* Workflow execution system prompt
|
|
1086
889
|
*/
|
|
1087
|
-
WORKFLOW_EXECUTION: `
|
|
1088
|
-
|
|
1089
|
-
<
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
{planningInstructions}
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
- **RETRY STEP**: Set \`decision: "retry"\`
|
|
1100
|
-
- **COMPLETE WORKFLOW**: Set \`decision: "complete"\` when ready to finish
|
|
1101
|
-
|
|
1102
|
-
**\u{1F6AB} Do NOT include \`steps\` parameter during normal execution**
|
|
1103
|
-
**\u2705 Include \`steps\` parameter ONLY when restarting workflow with \`init: true\`**
|
|
1104
|
-
**\u26A0\uFE0F CRITICAL: When retrying failed steps, MUST use \`decision: "retry"\`**`,
|
|
890
|
+
WORKFLOW_EXECUTION: `Workflow tool \`{toolName}\` that executes multi-step workflows. Use this when your task requires sequential steps.
|
|
891
|
+
|
|
892
|
+
<manual>
|
|
893
|
+
{description}
|
|
894
|
+
</manual>
|
|
895
|
+
|
|
896
|
+
<rules>
|
|
897
|
+
1. First call: {planningInstructions}
|
|
898
|
+
2. Subsequent calls: Provide only current step parameters
|
|
899
|
+
3. Use \`decision: "proceed"\` to advance, \`"retry"\` to retry, \`"complete"\` when done
|
|
900
|
+
4. Include \`steps\` ONLY with \`init: true\`, never during execution
|
|
901
|
+
</rules>`,
|
|
1105
902
|
/**
|
|
1106
|
-
* JSON-only execution system prompt
|
|
903
|
+
* JSON-only execution system prompt for autonomous sampling mode
|
|
904
|
+
*
|
|
905
|
+
* Note: Sampling mode runs an internal LLM loop that autonomously calls tools until complete.
|
|
1107
906
|
*/
|
|
1108
|
-
SAMPLING_EXECUTION: `
|
|
1109
|
-
|
|
1110
|
-
<
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
907
|
+
SAMPLING_EXECUTION: `Agent \`{toolName}\` that completes tasks by calling tools in an autonomous loop.
|
|
908
|
+
|
|
909
|
+
<manual>
|
|
910
|
+
{description}
|
|
911
|
+
</manual>
|
|
912
|
+
|
|
913
|
+
<rules>
|
|
914
|
+
1. Return valid JSON only (no markdown, no explanations)
|
|
915
|
+
2. Execute one action per iteration
|
|
916
|
+
3. When \`action\` is "X", include parameter "X" with tool inputs
|
|
917
|
+
4. Adapt based on results from previous actions
|
|
918
|
+
5. Continue until task is complete
|
|
919
|
+
</rules>
|
|
920
|
+
|
|
921
|
+
<format>
|
|
922
|
+
During execution:
|
|
1123
923
|
\`\`\`json
|
|
1124
924
|
{
|
|
1125
925
|
"action": "tool_name",
|
|
1126
926
|
"decision": "proceed|retry",
|
|
1127
|
-
"tool_name": { /*
|
|
927
|
+
"tool_name": { /* parameters */ }
|
|
1128
928
|
}
|
|
1129
929
|
\`\`\`
|
|
1130
930
|
|
|
1131
|
-
|
|
931
|
+
When complete (omit action):
|
|
1132
932
|
\`\`\`json
|
|
1133
|
-
{
|
|
1134
|
-
"decision": "complete"
|
|
1135
|
-
}
|
|
933
|
+
{ "decision": "complete" }
|
|
1136
934
|
\`\`\`
|
|
1137
935
|
|
|
1138
|
-
|
|
1139
|
-
|
|
936
|
+
Decisions:
|
|
937
|
+
- \`proceed\` = action succeeded, continue
|
|
938
|
+
- \`retry\` = action failed, try again
|
|
939
|
+
- \`complete\` = task finished
|
|
940
|
+
</format>
|
|
941
|
+
|
|
942
|
+
<tools>
|
|
943
|
+
{toolList}
|
|
944
|
+
</tools>`,
|
|
1140
945
|
/**
|
|
1141
946
|
* Sampling workflow execution system prompt combining sampling with workflow capabilities
|
|
947
|
+
*
|
|
948
|
+
* Note: Sampling mode runs an internal LLM loop that autonomously executes workflows.
|
|
1142
949
|
*/
|
|
1143
|
-
SAMPLING_WORKFLOW_EXECUTION: `
|
|
1144
|
-
|
|
1145
|
-
<
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
1.
|
|
1151
|
-
2.
|
|
1152
|
-
3.
|
|
1153
|
-
4.
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
950
|
+
SAMPLING_WORKFLOW_EXECUTION: `Workflow agent \`{toolName}\` that executes multi-step workflows autonomously.
|
|
951
|
+
|
|
952
|
+
<manual>
|
|
953
|
+
{description}
|
|
954
|
+
</manual>
|
|
955
|
+
|
|
956
|
+
<rules>
|
|
957
|
+
1. Return valid JSON only
|
|
958
|
+
2. First iteration: Plan workflow and initialize with \`init: true\`
|
|
959
|
+
3. Subsequent iterations: Execute current step
|
|
960
|
+
4. Adapt based on step results
|
|
961
|
+
5. Continue until all steps complete
|
|
962
|
+
</rules>
|
|
963
|
+
|
|
964
|
+
<format>
|
|
965
|
+
Initialize workflow (first iteration):
|
|
966
|
+
\`\`\`json
|
|
967
|
+
{
|
|
968
|
+
"action": "{toolName}",
|
|
969
|
+
"init": true,
|
|
970
|
+
"steps": [/* workflow steps */]
|
|
971
|
+
}
|
|
972
|
+
\`\`\`
|
|
973
|
+
|
|
974
|
+
Execute step (subsequent iterations):
|
|
975
|
+
\`\`\`json
|
|
976
|
+
{
|
|
977
|
+
"action": "{toolName}",
|
|
978
|
+
"decision": "proceed|retry",
|
|
979
|
+
/* step parameters */
|
|
980
|
+
}
|
|
981
|
+
\`\`\`
|
|
982
|
+
|
|
983
|
+
Complete workflow (omit action):
|
|
984
|
+
\`\`\`json
|
|
985
|
+
{ "decision": "complete" }
|
|
986
|
+
\`\`\`
|
|
987
|
+
|
|
988
|
+
Decisions:
|
|
989
|
+
- \`proceed\` = step succeeded, next step
|
|
990
|
+
- \`retry\` = step failed, retry current
|
|
991
|
+
- \`complete\` = workflow finished
|
|
992
|
+
|
|
993
|
+
Rules:
|
|
994
|
+
- Include \`steps\` ONLY with \`init: true\`
|
|
995
|
+
- Omit \`steps\` during step execution
|
|
996
|
+
- Use \`decision: "retry"\` for failed steps
|
|
997
|
+
</format>`
|
|
1187
998
|
};
|
|
1188
999
|
var WorkflowPrompts = {
|
|
1189
1000
|
/**
|
|
1190
1001
|
* Workflow initialization instructions
|
|
1191
1002
|
*/
|
|
1192
|
-
WORKFLOW_INIT: `Workflow initialized with {stepCount} steps.
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
{
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
-
|
|
1200
|
-
- **Do NOT include 'steps' parameter during normal step execution**
|
|
1201
|
-
- **MUST Use the provided JSON schema definition above for parameter generation and validation**
|
|
1202
|
-
- **ADVANCE STEP: Set 'decision' to "proceed" to advance to next step**
|
|
1203
|
-
- **RETRY STEP: Set 'decision' to "retry" to re-execute current step**
|
|
1204
|
-
- **FINAL STEP: Execute normally for workflow completion, do NOT use 'decision: complete' unless workflow is truly finished**
|
|
1205
|
-
- **\u26A0\uFE0F CRITICAL: When retrying failed steps, MUST set 'decision' to "retry"**
|
|
1206
|
-
- **\u26A0\uFE0F CRITICAL: Only use 'decision: complete' when the entire workflow has been successfully executed**
|
|
1003
|
+
WORKFLOW_INIT: `Workflow initialized with {stepCount} steps. Execute step 1: \`{currentStepDescription}\`
|
|
1004
|
+
|
|
1005
|
+
Schema: {schemaDefinition}
|
|
1006
|
+
|
|
1007
|
+
Call \`{toolName}\` with:
|
|
1008
|
+
- Parameters matching schema above
|
|
1009
|
+
- \`decision: "proceed"\` to advance, \`"retry"\` to retry, \`"complete"\` when done
|
|
1010
|
+
- Omit \`steps\` (only used with \`init: true\`)
|
|
1207
1011
|
|
|
1208
1012
|
{workflowSteps}`,
|
|
1209
1013
|
/**
|
|
@@ -1224,45 +1028,31 @@ var WorkflowPrompts = {
|
|
|
1224
1028
|
/**
|
|
1225
1029
|
* Next step decision prompt
|
|
1226
1030
|
*/
|
|
1227
|
-
NEXT_STEP_DECISION:
|
|
1228
|
-
|
|
1229
|
-
Previous step completed. Choose your action:
|
|
1031
|
+
NEXT_STEP_DECISION: `Previous step completed.
|
|
1230
1032
|
|
|
1231
|
-
|
|
1232
|
-
- Call \`{toolName}\` with
|
|
1233
|
-
-
|
|
1234
|
-
|
|
1235
|
-
**\u25B6\uFE0F PROCEED to Next Step:**
|
|
1236
|
-
- Call \`{toolName}\` with parameters below
|
|
1237
|
-
- Set \`decision: "proceed"\`
|
|
1238
|
-
|
|
1239
|
-
Next step: \`{nextStepDescription}\`
|
|
1033
|
+
Choose action:
|
|
1034
|
+
- RETRY: Call \`{toolName}\` with \`decision: "retry"\`
|
|
1035
|
+
- PROCEED: Call \`{toolName}\` with \`decision: "proceed"\` and parameters below
|
|
1240
1036
|
|
|
1037
|
+
Next: \`{nextStepDescription}\`
|
|
1241
1038
|
{nextStepSchema}
|
|
1242
1039
|
|
|
1243
|
-
|
|
1040
|
+
(Omit \`steps\` parameter)`,
|
|
1244
1041
|
/**
|
|
1245
1042
|
* Final step completion prompt
|
|
1246
1043
|
*/
|
|
1247
|
-
FINAL_STEP_COMPLETION:
|
|
1044
|
+
FINAL_STEP_COMPLETION: `Final step executed {statusIcon} - {statusText}
|
|
1248
1045
|
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
**\u{1F195} NEW:** Call \`{toolName}\` with \`init: true\`{newWorkflowInstructions}`,
|
|
1046
|
+
Choose:
|
|
1047
|
+
- RETRY: \`decision: "retry"\`
|
|
1048
|
+
- COMPLETE: \`decision: "complete"\`
|
|
1049
|
+
- NEW: \`init: true\`{newWorkflowInstructions}`,
|
|
1254
1050
|
/**
|
|
1255
1051
|
* Workflow completion success message
|
|
1256
1052
|
*/
|
|
1257
|
-
WORKFLOW_COMPLETED:
|
|
1258
|
-
|
|
1259
|
-
All workflow steps have been executed and the workflow is now complete.
|
|
1053
|
+
WORKFLOW_COMPLETED: `Workflow completed ({totalSteps} steps)
|
|
1260
1054
|
|
|
1261
|
-
|
|
1262
|
-
- Total steps: {totalSteps}
|
|
1263
|
-
- All steps executed successfully
|
|
1264
|
-
|
|
1265
|
-
Agent can now start a new workflow if needed by calling \`{toolName}\` with \`init: true\`{newWorkflowInstructions}.`,
|
|
1055
|
+
Start new workflow: \`{toolName}\` with \`init: true\`{newWorkflowInstructions}`,
|
|
1266
1056
|
/**
|
|
1267
1057
|
* Error messages
|
|
1268
1058
|
*/
|
|
@@ -1281,57 +1071,41 @@ var ResponseTemplates = {
|
|
|
1281
1071
|
/**
|
|
1282
1072
|
* Success response for action execution
|
|
1283
1073
|
*/
|
|
1284
|
-
ACTION_SUCCESS:
|
|
1285
|
-
|
|
1286
|
-
Previous action (\`{currentAction}\`) executed successfully.
|
|
1287
|
-
|
|
1288
|
-
**Next Action Required:** \`{nextAction}\`
|
|
1289
|
-
|
|
1290
|
-
Agent MUST call tool \`{toolName}\` again with the \`{nextAction}\` action to continue the autonomous execution sequence.
|
|
1074
|
+
ACTION_SUCCESS: `Action \`{currentAction}\` completed.
|
|
1291
1075
|
|
|
1292
|
-
|
|
1293
|
-
- Analyze the result from previous action: \`{currentAction}\`
|
|
1294
|
-
- Execute the next planned action: \`{nextAction}\`
|
|
1295
|
-
- Maintain execution context and progress toward the final goal`,
|
|
1076
|
+
Next: Execute \`{nextAction}\` by calling \`{toolName}\` again.`,
|
|
1296
1077
|
/**
|
|
1297
1078
|
* Planning prompt when no next action is specified
|
|
1298
1079
|
*/
|
|
1299
|
-
PLANNING_PROMPT:
|
|
1080
|
+
PLANNING_PROMPT: `Action \`{currentAction}\` completed. Determine next step:
|
|
1300
1081
|
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
1. **Analyze Results:** Review the outcome of \`{currentAction}\`
|
|
1305
|
-
2. **Assess Progress:** Determine how close you are to fulfilling the user request
|
|
1306
|
-
3. **Plan Next Action:** Identify the most appropriate next action (if needed)
|
|
1307
|
-
4. **Execute Decision:** Call \`{toolName}\` with the planned action
|
|
1308
|
-
|
|
1309
|
-
**Options:**
|
|
1310
|
-
- **Continue:** If more actions are needed to fulfill the request
|
|
1311
|
-
- **Complete:** If the user request has been fully satisfied
|
|
1312
|
-
|
|
1313
|
-
Choose the next action that best advances toward completing the user's request.`,
|
|
1082
|
+
1. Analyze results from \`{currentAction}\`
|
|
1083
|
+
2. Decide: Continue with another action or Complete?
|
|
1084
|
+
3. Call \`{toolName}\` with chosen action or \`decision: "complete"\``,
|
|
1314
1085
|
/**
|
|
1315
|
-
* Error response
|
|
1086
|
+
* Error response templates
|
|
1316
1087
|
*/
|
|
1317
|
-
ERROR_RESPONSE: `
|
|
1318
|
-
|
|
1319
|
-
|
|
1088
|
+
ERROR_RESPONSE: `Validation failed: {errorMessage}
|
|
1089
|
+
|
|
1090
|
+
Adjust parameters and retry.`,
|
|
1091
|
+
WORKFLOW_ERROR_RESPONSE: `Step failed: {errorMessage}
|
|
1092
|
+
|
|
1093
|
+
Fix parameters and call with \`decision: "retry"\``,
|
|
1320
1094
|
/**
|
|
1321
1095
|
* Completion message
|
|
1322
1096
|
*/
|
|
1323
|
-
COMPLETION_MESSAGE: `
|
|
1097
|
+
COMPLETION_MESSAGE: `Task completed.`,
|
|
1324
1098
|
/**
|
|
1325
1099
|
* Security validation messages
|
|
1326
1100
|
*/
|
|
1327
1101
|
SECURITY_VALIDATION: {
|
|
1328
|
-
PASSED: `Security
|
|
1329
|
-
FAILED: `Security
|
|
1102
|
+
PASSED: `Security check passed: {operation} on {path}`,
|
|
1103
|
+
FAILED: `Security check failed: {operation} on {path}`
|
|
1330
1104
|
},
|
|
1331
1105
|
/**
|
|
1332
1106
|
* Audit log messages
|
|
1333
1107
|
*/
|
|
1334
|
-
AUDIT_LOG: `
|
|
1108
|
+
AUDIT_LOG: `[{timestamp}] {level}: {action} on {resource}{userInfo}`
|
|
1335
1109
|
};
|
|
1336
1110
|
var CompiledPrompts = {
|
|
1337
1111
|
autonomousExecution: p(SystemPrompts.AUTONOMOUS_EXECUTION),
|
|
@@ -1378,14 +1152,14 @@ ${JSON.stringify(steps, null, 2)}`;
|
|
|
1378
1152
|
*/
|
|
1379
1153
|
formatWorkflowProgress: (progressData) => {
|
|
1380
1154
|
const statusIcons = {
|
|
1381
|
-
pending: "
|
|
1382
|
-
running: "
|
|
1383
|
-
completed: "
|
|
1384
|
-
failed: "
|
|
1155
|
+
pending: "[PENDING]",
|
|
1156
|
+
running: "[RUNNING]",
|
|
1157
|
+
completed: "[DONE]",
|
|
1158
|
+
failed: "[FAILED]"
|
|
1385
1159
|
};
|
|
1386
1160
|
return progressData.steps.map((step, index) => {
|
|
1387
1161
|
const status = progressData.statuses[index] || "pending";
|
|
1388
|
-
const icon = statusIcons[status] || "
|
|
1162
|
+
const icon = statusIcons[status] || "[PENDING]";
|
|
1389
1163
|
const current = index === progressData.currentStepIndex ? " **[CURRENT]**" : "";
|
|
1390
1164
|
const actions = step.actions.length > 0 ? ` | Action: ${step.actions.join(", ")}` : "";
|
|
1391
1165
|
return `${icon} **Step ${index + 1}:** ${step.description}${actions}${current}`;
|
|
@@ -3229,10 +3003,199 @@ function processToolTags({ description, tagToResults, $, tools, toolOverrides, t
|
|
|
3229
3003
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/compose.js
|
|
3230
3004
|
init_built_in();
|
|
3231
3005
|
init_logger();
|
|
3232
|
-
|
|
3006
|
+
|
|
3007
|
+
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/plugin-utils.js
|
|
3008
|
+
var pluginCache = /* @__PURE__ */ new Map();
|
|
3009
|
+
function shouldApplyPlugin(plugin, mode) {
|
|
3010
|
+
if (!plugin.apply) return true;
|
|
3011
|
+
if (typeof plugin.apply === "string") {
|
|
3012
|
+
return mode.includes(plugin.apply);
|
|
3013
|
+
}
|
|
3014
|
+
if (typeof plugin.apply === "function") {
|
|
3015
|
+
try {
|
|
3016
|
+
return plugin.apply(mode);
|
|
3017
|
+
} catch (error) {
|
|
3018
|
+
console.warn(`Plugin "${plugin.name}" apply function failed: ${error}. Defaulting to true.`);
|
|
3019
|
+
return true;
|
|
3020
|
+
}
|
|
3021
|
+
}
|
|
3022
|
+
return true;
|
|
3023
|
+
}
|
|
3024
|
+
function sortPluginsByOrder(plugins) {
|
|
3025
|
+
const pluginMap = /* @__PURE__ */ new Map();
|
|
3026
|
+
for (const plugin of plugins) {
|
|
3027
|
+
pluginMap.set(plugin.name, plugin);
|
|
3028
|
+
}
|
|
3029
|
+
const visited = /* @__PURE__ */ new Set();
|
|
3030
|
+
const sorted = [];
|
|
3031
|
+
function visit(plugin) {
|
|
3032
|
+
if (visited.has(plugin.name)) return;
|
|
3033
|
+
visited.add(plugin.name);
|
|
3034
|
+
if (plugin.dependencies) {
|
|
3035
|
+
for (const depName of plugin.dependencies) {
|
|
3036
|
+
const dep = pluginMap.get(depName);
|
|
3037
|
+
if (dep) {
|
|
3038
|
+
visit(dep);
|
|
3039
|
+
} else {
|
|
3040
|
+
console.warn(`Plugin "${plugin.name}" depends on "${depName}" which is not loaded`);
|
|
3041
|
+
}
|
|
3042
|
+
}
|
|
3043
|
+
}
|
|
3044
|
+
sorted.push(plugin);
|
|
3045
|
+
}
|
|
3046
|
+
const prePlugins = plugins.filter((p2) => p2.enforce === "pre");
|
|
3047
|
+
const normalPlugins = plugins.filter((p2) => !p2.enforce);
|
|
3048
|
+
const postPlugins = plugins.filter((p2) => p2.enforce === "post");
|
|
3049
|
+
[
|
|
3050
|
+
...prePlugins,
|
|
3051
|
+
...normalPlugins,
|
|
3052
|
+
...postPlugins
|
|
3053
|
+
].forEach(visit);
|
|
3054
|
+
return sorted;
|
|
3055
|
+
}
|
|
3056
|
+
function isValidPlugin(plugin) {
|
|
3057
|
+
if (!plugin || typeof plugin !== "object") return false;
|
|
3058
|
+
const p2 = plugin;
|
|
3059
|
+
if (!p2.name || typeof p2.name !== "string" || p2.name.trim() === "") {
|
|
3060
|
+
return false;
|
|
3061
|
+
}
|
|
3062
|
+
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";
|
|
3063
|
+
if (!hasHook) return false;
|
|
3064
|
+
if (p2.enforce && p2.enforce !== "pre" && p2.enforce !== "post") {
|
|
3065
|
+
return false;
|
|
3066
|
+
}
|
|
3067
|
+
if (p2.apply && typeof p2.apply !== "string" && typeof p2.apply !== "function") {
|
|
3068
|
+
return false;
|
|
3069
|
+
}
|
|
3070
|
+
if (p2.dependencies && !Array.isArray(p2.dependencies)) {
|
|
3071
|
+
return false;
|
|
3072
|
+
}
|
|
3073
|
+
return true;
|
|
3074
|
+
}
|
|
3075
|
+
function parseQueryParams(params) {
|
|
3076
|
+
const typedParams = {};
|
|
3077
|
+
for (const [key, value] of Object.entries(params)) {
|
|
3078
|
+
const numValue = Number(value);
|
|
3079
|
+
if (!isNaN(numValue) && value.trim() !== "") {
|
|
3080
|
+
typedParams[key] = numValue;
|
|
3081
|
+
continue;
|
|
3082
|
+
}
|
|
3083
|
+
if (value === "true") {
|
|
3084
|
+
typedParams[key] = true;
|
|
3085
|
+
continue;
|
|
3086
|
+
}
|
|
3087
|
+
if (value === "false") {
|
|
3088
|
+
typedParams[key] = false;
|
|
3089
|
+
continue;
|
|
3090
|
+
}
|
|
3091
|
+
if (value.includes(",")) {
|
|
3092
|
+
typedParams[key] = value.split(",").map((v) => v.trim());
|
|
3093
|
+
continue;
|
|
3094
|
+
}
|
|
3095
|
+
typedParams[key] = value;
|
|
3096
|
+
}
|
|
3097
|
+
return typedParams;
|
|
3098
|
+
}
|
|
3099
|
+
async function loadPlugin(pluginPath, options = {
|
|
3100
|
+
cache: true
|
|
3101
|
+
}) {
|
|
3102
|
+
if (options.cache && pluginCache.has(pluginPath)) {
|
|
3103
|
+
return pluginCache.get(pluginPath);
|
|
3104
|
+
}
|
|
3105
|
+
try {
|
|
3106
|
+
const [rawPath, queryString] = pluginPath.split("?", 2);
|
|
3107
|
+
const searchParams = new URLSearchParams(queryString || "");
|
|
3108
|
+
const params = Object.fromEntries(searchParams.entries());
|
|
3109
|
+
const resolveFn = import.meta.resolve;
|
|
3110
|
+
const importPath = typeof resolveFn === "function" ? resolveFn(rawPath) : new URL(rawPath, import.meta.url).href;
|
|
3111
|
+
const pluginModule = await import(importPath);
|
|
3112
|
+
const pluginFactory = pluginModule.createPlugin;
|
|
3113
|
+
const defaultPlugin = pluginModule.default;
|
|
3114
|
+
let plugin;
|
|
3115
|
+
if (Object.keys(params).length > 0) {
|
|
3116
|
+
if (typeof pluginFactory !== "function") {
|
|
3117
|
+
throw new Error(`Plugin "${rawPath}" has parameters but no createPlugin export function`);
|
|
3118
|
+
}
|
|
3119
|
+
const typedParams = parseQueryParams(params);
|
|
3120
|
+
plugin = pluginFactory(typedParams);
|
|
3121
|
+
} else {
|
|
3122
|
+
if (defaultPlugin) {
|
|
3123
|
+
plugin = defaultPlugin;
|
|
3124
|
+
} else if (typeof pluginFactory === "function") {
|
|
3125
|
+
plugin = pluginFactory();
|
|
3126
|
+
} else {
|
|
3127
|
+
throw new Error(`Plugin "${rawPath}" has no default export or createPlugin function`);
|
|
3128
|
+
}
|
|
3129
|
+
}
|
|
3130
|
+
if (!isValidPlugin(plugin)) {
|
|
3131
|
+
throw new Error(`Invalid plugin format in "${rawPath}": must have a unique name and at least one lifecycle hook`);
|
|
3132
|
+
}
|
|
3133
|
+
if (options.cache) {
|
|
3134
|
+
pluginCache.set(pluginPath, plugin);
|
|
3135
|
+
}
|
|
3136
|
+
return plugin;
|
|
3137
|
+
} catch (error) {
|
|
3138
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
3139
|
+
throw new Error(`Failed to load plugin from "${pluginPath}": ${errorMsg}`);
|
|
3140
|
+
}
|
|
3141
|
+
}
|
|
3142
|
+
function checkCircularDependencies(plugins) {
|
|
3143
|
+
const errors = [];
|
|
3144
|
+
const pluginMap = /* @__PURE__ */ new Map();
|
|
3145
|
+
for (const plugin of plugins) {
|
|
3146
|
+
pluginMap.set(plugin.name, plugin);
|
|
3147
|
+
}
|
|
3148
|
+
function checkCircular(pluginName, visited, path) {
|
|
3149
|
+
if (visited.has(pluginName)) {
|
|
3150
|
+
const cycle = [
|
|
3151
|
+
...path,
|
|
3152
|
+
pluginName
|
|
3153
|
+
].join(" -> ");
|
|
3154
|
+
errors.push(`Circular dependency detected: ${cycle}`);
|
|
3155
|
+
return;
|
|
3156
|
+
}
|
|
3157
|
+
const plugin = pluginMap.get(pluginName);
|
|
3158
|
+
if (!plugin || !plugin.dependencies) return;
|
|
3159
|
+
visited.add(pluginName);
|
|
3160
|
+
path.push(pluginName);
|
|
3161
|
+
for (const dep of plugin.dependencies) {
|
|
3162
|
+
checkCircular(dep, new Set(visited), [
|
|
3163
|
+
...path
|
|
3164
|
+
]);
|
|
3165
|
+
}
|
|
3166
|
+
}
|
|
3167
|
+
for (const plugin of plugins) {
|
|
3168
|
+
checkCircular(plugin.name, /* @__PURE__ */ new Set(), []);
|
|
3169
|
+
}
|
|
3170
|
+
return errors;
|
|
3171
|
+
}
|
|
3172
|
+
function validatePlugins(plugins) {
|
|
3173
|
+
const errors = [];
|
|
3174
|
+
const names = /* @__PURE__ */ new Map();
|
|
3175
|
+
for (const plugin of plugins) {
|
|
3176
|
+
const count = names.get(plugin.name) || 0;
|
|
3177
|
+
names.set(plugin.name, count + 1);
|
|
3178
|
+
}
|
|
3179
|
+
for (const [name, count] of names.entries()) {
|
|
3180
|
+
if (count > 1) {
|
|
3181
|
+
errors.push(`Duplicate plugin name: "${name}" (${count} instances)`);
|
|
3182
|
+
}
|
|
3183
|
+
}
|
|
3184
|
+
const circularErrors = checkCircularDependencies(plugins);
|
|
3185
|
+
errors.push(...circularErrors);
|
|
3186
|
+
for (const plugin of plugins) {
|
|
3187
|
+
if (!isValidPlugin(plugin)) {
|
|
3188
|
+
const name = plugin.name || "unknown";
|
|
3189
|
+
errors.push(`Invalid plugin: "${name}"`);
|
|
3190
|
+
}
|
|
3191
|
+
}
|
|
3192
|
+
return {
|
|
3193
|
+
valid: errors.length === 0,
|
|
3194
|
+
errors
|
|
3195
|
+
};
|
|
3196
|
+
}
|
|
3233
3197
|
|
|
3234
3198
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/plugin-manager.js
|
|
3235
|
-
init_plugin_utils();
|
|
3236
3199
|
init_logger();
|
|
3237
3200
|
var PluginManager = class {
|
|
3238
3201
|
server;
|
|
@@ -3400,6 +3363,7 @@ var PluginManager = class {
|
|
|
3400
3363
|
};
|
|
3401
3364
|
|
|
3402
3365
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/tool-manager.js
|
|
3366
|
+
init_schema();
|
|
3403
3367
|
var ToolManager = class {
|
|
3404
3368
|
toolRegistry = /* @__PURE__ */ new Map();
|
|
3405
3369
|
toolConfigs = /* @__PURE__ */ new Map();
|
|
@@ -3584,10 +3548,33 @@ var ToolManager = class {
|
|
|
3584
3548
|
getToolRegistry() {
|
|
3585
3549
|
return this.toolRegistry;
|
|
3586
3550
|
}
|
|
3551
|
+
/**
|
|
3552
|
+
* Get all registered tools as ComposedTool objects
|
|
3553
|
+
* This includes tools registered via server.tool() in setup hooks
|
|
3554
|
+
*/
|
|
3555
|
+
getRegisteredToolsAsComposed() {
|
|
3556
|
+
const composedTools = {};
|
|
3557
|
+
for (const [name, tool] of this.toolRegistry.entries()) {
|
|
3558
|
+
if (this.toolConfigs.get(name)?.visibility?.public === true) {
|
|
3559
|
+
continue;
|
|
3560
|
+
}
|
|
3561
|
+
composedTools[name] = {
|
|
3562
|
+
name,
|
|
3563
|
+
description: tool.description,
|
|
3564
|
+
inputSchema: jsonSchema(tool.schema || {
|
|
3565
|
+
type: "object",
|
|
3566
|
+
properties: {}
|
|
3567
|
+
}),
|
|
3568
|
+
execute: tool.callback
|
|
3569
|
+
};
|
|
3570
|
+
}
|
|
3571
|
+
return composedTools;
|
|
3572
|
+
}
|
|
3587
3573
|
};
|
|
3588
3574
|
|
|
3589
3575
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/compose.js
|
|
3590
3576
|
init_compose_helpers();
|
|
3577
|
+
init_provider();
|
|
3591
3578
|
var ALL_TOOLS_PLACEHOLDER2 = "__ALL__";
|
|
3592
3579
|
var ComposableMCPServer = class extends Server {
|
|
3593
3580
|
pluginManager;
|
|
@@ -3638,8 +3625,7 @@ var ComposableMCPServer = class extends Server {
|
|
|
3638
3625
|
if (plugins.length === 0) {
|
|
3639
3626
|
return data;
|
|
3640
3627
|
}
|
|
3641
|
-
const
|
|
3642
|
-
const sortedPlugins = sortPluginsByOrder2(plugins);
|
|
3628
|
+
const sortedPlugins = sortPluginsByOrder(plugins);
|
|
3643
3629
|
let currentData = data;
|
|
3644
3630
|
const context2 = {
|
|
3645
3631
|
toolName,
|
|
@@ -3747,6 +3733,14 @@ var ComposableMCPServer = class extends Server {
|
|
|
3747
3733
|
getHiddenToolNames() {
|
|
3748
3734
|
return this.toolManager.getHiddenToolNames();
|
|
3749
3735
|
}
|
|
3736
|
+
/**
|
|
3737
|
+
* Get all internal tool names (tools that are not public)
|
|
3738
|
+
*/
|
|
3739
|
+
getInternalToolNames() {
|
|
3740
|
+
const allToolNames = Array.from(this.toolManager.getToolRegistry().keys());
|
|
3741
|
+
const publicToolNames = this.getPublicToolNames();
|
|
3742
|
+
return allToolNames.filter((name) => !publicToolNames.includes(name));
|
|
3743
|
+
}
|
|
3750
3744
|
/**
|
|
3751
3745
|
* Get hidden tool schema by name (for internal access)
|
|
3752
3746
|
*/
|
|
@@ -3841,15 +3835,13 @@ var ComposableMCPServer = class extends Server {
|
|
|
3841
3835
|
const availableToolNames = /* @__PURE__ */ new Set();
|
|
3842
3836
|
tagToResults.tool.forEach((tool) => {
|
|
3843
3837
|
if (tool.attribs.name) {
|
|
3844
|
-
requestedToolNames.add(tool.attribs.name);
|
|
3838
|
+
requestedToolNames.add(sanitizePropertyKey(tool.attribs.name));
|
|
3845
3839
|
}
|
|
3846
3840
|
});
|
|
3847
3841
|
const { tools, cleanupClients } = await composeMcpDepTools(depsConfig, ({ mcpName, toolNameWithScope, toolId }) => {
|
|
3848
3842
|
toolNameToIdMapping.set(toolNameWithScope, toolId);
|
|
3849
3843
|
availableToolNames.add(toolNameWithScope);
|
|
3850
3844
|
availableToolNames.add(toolId);
|
|
3851
|
-
availableToolNames.add(`${mcpName}.${ALL_TOOLS_PLACEHOLDER2}`);
|
|
3852
|
-
availableToolNames.add(mcpName);
|
|
3853
3845
|
this.toolManager.setToolNameMapping(toolNameWithScope, toolId);
|
|
3854
3846
|
const internalName = toolNameWithScope.includes(".") ? toolNameWithScope.split(".").slice(1).join(".") : toolNameWithScope;
|
|
3855
3847
|
if (!this.toolNameMapping.has(internalName)) {
|
|
@@ -3871,23 +3863,34 @@ var ComposableMCPServer = class extends Server {
|
|
|
3871
3863
|
return tool.attribs.name === toolNameWithScope || tool.attribs.name === toolId;
|
|
3872
3864
|
});
|
|
3873
3865
|
});
|
|
3874
|
-
|
|
3866
|
+
Object.entries(tools).forEach(([toolId, tool]) => {
|
|
3867
|
+
this.toolManager.registerTool(toolId, tool.description || "", tool.inputSchema, tool.execute);
|
|
3868
|
+
});
|
|
3869
|
+
const registeredTools = this.toolManager.getRegisteredToolsAsComposed();
|
|
3870
|
+
const allTools = {
|
|
3871
|
+
...tools
|
|
3872
|
+
};
|
|
3873
|
+
Object.entries(registeredTools).forEach(([toolName, tool]) => {
|
|
3874
|
+
if (!allTools[toolName]) {
|
|
3875
|
+
allTools[toolName] = tool;
|
|
3876
|
+
}
|
|
3877
|
+
availableToolNames.add(toolName);
|
|
3878
|
+
});
|
|
3879
|
+
const unmatchedTools = Array.from(requestedToolNames).filter((toolName) => !allTools[toolName]);
|
|
3875
3880
|
if (unmatchedTools.length > 0) {
|
|
3876
3881
|
await this.logger.warning(`Tool matching warnings for agent "${name}":`);
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
}
|
|
3880
|
-
|
|
3882
|
+
unmatchedTools.forEach((toolName) => {
|
|
3883
|
+
this.logger.warning(` \u2022 Tool not found: "${toolName}"`);
|
|
3884
|
+
});
|
|
3885
|
+
const available = Array.from(availableToolNames).sort().join(", ");
|
|
3886
|
+
await this.logger.warning(` Available tools: ${available}`);
|
|
3881
3887
|
}
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
});
|
|
3885
|
-
await this.processToolsWithPlugins(tools, options.mode ?? "agentic");
|
|
3886
|
-
await this.pluginManager.triggerFinalizeComposition(tools, {
|
|
3888
|
+
await this.processToolsWithPlugins(allTools, options.mode ?? "agentic");
|
|
3889
|
+
await this.pluginManager.triggerFinalizeComposition(allTools, {
|
|
3887
3890
|
serverName: name ?? "anonymous",
|
|
3888
3891
|
mode: options.mode ?? "agentic",
|
|
3889
3892
|
server: this,
|
|
3890
|
-
toolNames: Object.keys(
|
|
3893
|
+
toolNames: Object.keys(allTools)
|
|
3891
3894
|
});
|
|
3892
3895
|
this.onclose = async () => {
|
|
3893
3896
|
await cleanupClients();
|
|
@@ -3900,16 +3903,16 @@ var ComposableMCPServer = class extends Server {
|
|
|
3900
3903
|
await this.disposePlugins();
|
|
3901
3904
|
await this.logger.info(`[${name}] Action: cleaned up dependent clients and plugins`);
|
|
3902
3905
|
};
|
|
3903
|
-
const toolNameToDetailList = Object.entries(
|
|
3906
|
+
const toolNameToDetailList = Object.entries(allTools);
|
|
3904
3907
|
const publicToolNames = this.getPublicToolNames();
|
|
3905
3908
|
const hiddenToolNames = this.getHiddenToolNames();
|
|
3906
3909
|
const contextToolNames = toolNameToDetailList.map(([name2]) => name2).filter((n) => !hiddenToolNames.includes(n));
|
|
3907
3910
|
publicToolNames.forEach((toolId) => {
|
|
3908
|
-
const tool =
|
|
3911
|
+
const tool = allTools[toolId];
|
|
3909
3912
|
if (!tool) {
|
|
3910
|
-
throw new Error(`Public tool ${toolId} not found in registry, available: ${Object.keys(
|
|
3913
|
+
throw new Error(`Public tool ${toolId} not found in registry, available: ${Object.keys(allTools).join(", ")}`);
|
|
3911
3914
|
}
|
|
3912
|
-
this.tool(toolId, tool.description || "
|
|
3915
|
+
this.tool(toolId, tool.description || "", jsonSchema(tool.inputSchema), tool.execute, {
|
|
3913
3916
|
internal: false
|
|
3914
3917
|
});
|
|
3915
3918
|
});
|
|
@@ -3934,7 +3937,7 @@ var ComposableMCPServer = class extends Server {
|
|
|
3934
3937
|
description = processToolTags({
|
|
3935
3938
|
...desTags,
|
|
3936
3939
|
description,
|
|
3937
|
-
tools,
|
|
3940
|
+
tools: allTools,
|
|
3938
3941
|
toolOverrides: /* @__PURE__ */ new Map(),
|
|
3939
3942
|
toolNameMapping: toolNameToIdMapping
|
|
3940
3943
|
});
|