@mcpc-tech/core 0.2.9 → 0.2.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/index.mjs +249 -229
- package/package.json +1 -1
- package/types/src/compose.d.ts +3 -0
- package/types/src/compose.d.ts.map +1 -1
package/index.mjs
CHANGED
|
@@ -92,7 +92,7 @@ var init_json = __esm({
|
|
|
92
92
|
|
|
93
93
|
// __mcpc__core_latest/node_modules/@mcpc/core/src/utils/common/provider.js
|
|
94
94
|
function sanitizePropertyKey(name) {
|
|
95
|
-
return name.replace(/[
|
|
95
|
+
return name.replace(/[@.,/\\:;!?#$%^&*()[\]{}]/g, "_").substring(0, 64);
|
|
96
96
|
}
|
|
97
97
|
var createGoogleCompatibleJSONSchema;
|
|
98
98
|
var init_provider = __esm({
|
|
@@ -284,12 +284,21 @@ var init_logging_plugin = __esm({
|
|
|
284
284
|
const { stats } = context2;
|
|
285
285
|
const server = context2.server;
|
|
286
286
|
const publicTools = Array.from(new Set(server.getPublicToolNames().map(String)));
|
|
287
|
+
const internalTools = Array.from(new Set(server.getInternalToolNames().map(String)));
|
|
287
288
|
const hiddenTools = Array.from(new Set(server.getHiddenToolNames().map(String)));
|
|
289
|
+
const normalInternal = internalTools.filter((name) => !hiddenTools.includes(name));
|
|
288
290
|
if (publicTools.length > 0) {
|
|
289
291
|
await logger2.info(` \u251C\u2500 Public: ${publicTools.join(", ")}`);
|
|
290
292
|
}
|
|
291
|
-
if (
|
|
292
|
-
|
|
293
|
+
if (internalTools.length > 0) {
|
|
294
|
+
const parts = [];
|
|
295
|
+
if (normalInternal.length > 0) {
|
|
296
|
+
parts.push(normalInternal.join(", "));
|
|
297
|
+
}
|
|
298
|
+
if (hiddenTools.length > 0) {
|
|
299
|
+
parts.push(`(${hiddenTools.join(", ")})`);
|
|
300
|
+
}
|
|
301
|
+
await logger2.info(` \u251C\u2500 Internal: ${parts.join(", ")}`);
|
|
293
302
|
}
|
|
294
303
|
await logger2.info(` \u2514\u2500 Total: ${stats.totalTools} tools`);
|
|
295
304
|
}
|
|
@@ -329,218 +338,6 @@ var init_built_in = __esm({
|
|
|
329
338
|
}
|
|
330
339
|
});
|
|
331
340
|
|
|
332
|
-
// __mcpc__core_latest/node_modules/@mcpc/core/src/plugin-utils.js
|
|
333
|
-
var plugin_utils_exports = {};
|
|
334
|
-
__export(plugin_utils_exports, {
|
|
335
|
-
checkCircularDependencies: () => checkCircularDependencies,
|
|
336
|
-
clearPluginCache: () => clearPluginCache,
|
|
337
|
-
getPluginsWithHook: () => getPluginsWithHook,
|
|
338
|
-
isValidPlugin: () => isValidPlugin,
|
|
339
|
-
loadPlugin: () => loadPlugin,
|
|
340
|
-
shouldApplyPlugin: () => shouldApplyPlugin,
|
|
341
|
-
sortPluginsByOrder: () => sortPluginsByOrder,
|
|
342
|
-
validatePlugins: () => validatePlugins
|
|
343
|
-
});
|
|
344
|
-
function shouldApplyPlugin(plugin, mode) {
|
|
345
|
-
if (!plugin.apply) return true;
|
|
346
|
-
if (typeof plugin.apply === "string") {
|
|
347
|
-
return mode.includes(plugin.apply);
|
|
348
|
-
}
|
|
349
|
-
if (typeof plugin.apply === "function") {
|
|
350
|
-
try {
|
|
351
|
-
return plugin.apply(mode);
|
|
352
|
-
} catch (error) {
|
|
353
|
-
console.warn(`Plugin "${plugin.name}" apply function failed: ${error}. Defaulting to true.`);
|
|
354
|
-
return true;
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
return true;
|
|
358
|
-
}
|
|
359
|
-
function sortPluginsByOrder(plugins) {
|
|
360
|
-
const pluginMap = /* @__PURE__ */ new Map();
|
|
361
|
-
for (const plugin of plugins) {
|
|
362
|
-
pluginMap.set(plugin.name, plugin);
|
|
363
|
-
}
|
|
364
|
-
const visited = /* @__PURE__ */ new Set();
|
|
365
|
-
const sorted = [];
|
|
366
|
-
function visit(plugin) {
|
|
367
|
-
if (visited.has(plugin.name)) return;
|
|
368
|
-
visited.add(plugin.name);
|
|
369
|
-
if (plugin.dependencies) {
|
|
370
|
-
for (const depName of plugin.dependencies) {
|
|
371
|
-
const dep = pluginMap.get(depName);
|
|
372
|
-
if (dep) {
|
|
373
|
-
visit(dep);
|
|
374
|
-
} else {
|
|
375
|
-
console.warn(`Plugin "${plugin.name}" depends on "${depName}" which is not loaded`);
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
sorted.push(plugin);
|
|
380
|
-
}
|
|
381
|
-
const prePlugins = plugins.filter((p2) => p2.enforce === "pre");
|
|
382
|
-
const normalPlugins = plugins.filter((p2) => !p2.enforce);
|
|
383
|
-
const postPlugins = plugins.filter((p2) => p2.enforce === "post");
|
|
384
|
-
[
|
|
385
|
-
...prePlugins,
|
|
386
|
-
...normalPlugins,
|
|
387
|
-
...postPlugins
|
|
388
|
-
].forEach(visit);
|
|
389
|
-
return sorted;
|
|
390
|
-
}
|
|
391
|
-
function getPluginsWithHook(plugins, hookName) {
|
|
392
|
-
return plugins.filter((p2) => typeof p2[hookName] === "function");
|
|
393
|
-
}
|
|
394
|
-
function isValidPlugin(plugin) {
|
|
395
|
-
if (!plugin || typeof plugin !== "object") return false;
|
|
396
|
-
const p2 = plugin;
|
|
397
|
-
if (!p2.name || typeof p2.name !== "string" || p2.name.trim() === "") {
|
|
398
|
-
return false;
|
|
399
|
-
}
|
|
400
|
-
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";
|
|
401
|
-
if (!hasHook) return false;
|
|
402
|
-
if (p2.enforce && p2.enforce !== "pre" && p2.enforce !== "post") {
|
|
403
|
-
return false;
|
|
404
|
-
}
|
|
405
|
-
if (p2.apply && typeof p2.apply !== "string" && typeof p2.apply !== "function") {
|
|
406
|
-
return false;
|
|
407
|
-
}
|
|
408
|
-
if (p2.dependencies && !Array.isArray(p2.dependencies)) {
|
|
409
|
-
return false;
|
|
410
|
-
}
|
|
411
|
-
return true;
|
|
412
|
-
}
|
|
413
|
-
function parseQueryParams(params) {
|
|
414
|
-
const typedParams = {};
|
|
415
|
-
for (const [key, value] of Object.entries(params)) {
|
|
416
|
-
const numValue = Number(value);
|
|
417
|
-
if (!isNaN(numValue) && value.trim() !== "") {
|
|
418
|
-
typedParams[key] = numValue;
|
|
419
|
-
continue;
|
|
420
|
-
}
|
|
421
|
-
if (value === "true") {
|
|
422
|
-
typedParams[key] = true;
|
|
423
|
-
continue;
|
|
424
|
-
}
|
|
425
|
-
if (value === "false") {
|
|
426
|
-
typedParams[key] = false;
|
|
427
|
-
continue;
|
|
428
|
-
}
|
|
429
|
-
if (value.includes(",")) {
|
|
430
|
-
typedParams[key] = value.split(",").map((v) => v.trim());
|
|
431
|
-
continue;
|
|
432
|
-
}
|
|
433
|
-
typedParams[key] = value;
|
|
434
|
-
}
|
|
435
|
-
return typedParams;
|
|
436
|
-
}
|
|
437
|
-
async function loadPlugin(pluginPath, options = {
|
|
438
|
-
cache: true
|
|
439
|
-
}) {
|
|
440
|
-
if (options.cache && pluginCache.has(pluginPath)) {
|
|
441
|
-
return pluginCache.get(pluginPath);
|
|
442
|
-
}
|
|
443
|
-
try {
|
|
444
|
-
const [rawPath, queryString] = pluginPath.split("?", 2);
|
|
445
|
-
const searchParams = new URLSearchParams(queryString || "");
|
|
446
|
-
const params = Object.fromEntries(searchParams.entries());
|
|
447
|
-
const importPath = rawPath;
|
|
448
|
-
const pluginModule = await import(importPath);
|
|
449
|
-
const pluginFactory = pluginModule.createPlugin;
|
|
450
|
-
const defaultPlugin = pluginModule.default;
|
|
451
|
-
let plugin;
|
|
452
|
-
if (Object.keys(params).length > 0) {
|
|
453
|
-
if (typeof pluginFactory !== "function") {
|
|
454
|
-
throw new Error(`Plugin "${rawPath}" has parameters but no createPlugin export function`);
|
|
455
|
-
}
|
|
456
|
-
const typedParams = parseQueryParams(params);
|
|
457
|
-
plugin = pluginFactory(typedParams);
|
|
458
|
-
} else {
|
|
459
|
-
if (defaultPlugin) {
|
|
460
|
-
plugin = defaultPlugin;
|
|
461
|
-
} else if (typeof pluginFactory === "function") {
|
|
462
|
-
plugin = pluginFactory();
|
|
463
|
-
} else {
|
|
464
|
-
throw new Error(`Plugin "${rawPath}" has no default export or createPlugin function`);
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
if (!isValidPlugin(plugin)) {
|
|
468
|
-
throw new Error(`Invalid plugin format in "${rawPath}": must have a unique name and at least one lifecycle hook`);
|
|
469
|
-
}
|
|
470
|
-
if (options.cache) {
|
|
471
|
-
pluginCache.set(pluginPath, plugin);
|
|
472
|
-
}
|
|
473
|
-
return plugin;
|
|
474
|
-
} catch (error) {
|
|
475
|
-
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
476
|
-
throw new Error(`Failed to load plugin from "${pluginPath}": ${errorMsg}`);
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
function clearPluginCache() {
|
|
480
|
-
pluginCache.clear();
|
|
481
|
-
}
|
|
482
|
-
function checkCircularDependencies(plugins) {
|
|
483
|
-
const errors = [];
|
|
484
|
-
const pluginMap = /* @__PURE__ */ new Map();
|
|
485
|
-
for (const plugin of plugins) {
|
|
486
|
-
pluginMap.set(plugin.name, plugin);
|
|
487
|
-
}
|
|
488
|
-
function checkCircular(pluginName, visited, path) {
|
|
489
|
-
if (visited.has(pluginName)) {
|
|
490
|
-
const cycle = [
|
|
491
|
-
...path,
|
|
492
|
-
pluginName
|
|
493
|
-
].join(" -> ");
|
|
494
|
-
errors.push(`Circular dependency detected: ${cycle}`);
|
|
495
|
-
return;
|
|
496
|
-
}
|
|
497
|
-
const plugin = pluginMap.get(pluginName);
|
|
498
|
-
if (!plugin || !plugin.dependencies) return;
|
|
499
|
-
visited.add(pluginName);
|
|
500
|
-
path.push(pluginName);
|
|
501
|
-
for (const dep of plugin.dependencies) {
|
|
502
|
-
checkCircular(dep, new Set(visited), [
|
|
503
|
-
...path
|
|
504
|
-
]);
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
for (const plugin of plugins) {
|
|
508
|
-
checkCircular(plugin.name, /* @__PURE__ */ new Set(), []);
|
|
509
|
-
}
|
|
510
|
-
return errors;
|
|
511
|
-
}
|
|
512
|
-
function validatePlugins(plugins) {
|
|
513
|
-
const errors = [];
|
|
514
|
-
const names = /* @__PURE__ */ new Map();
|
|
515
|
-
for (const plugin of plugins) {
|
|
516
|
-
const count = names.get(plugin.name) || 0;
|
|
517
|
-
names.set(plugin.name, count + 1);
|
|
518
|
-
}
|
|
519
|
-
for (const [name, count] of names.entries()) {
|
|
520
|
-
if (count > 1) {
|
|
521
|
-
errors.push(`Duplicate plugin name: "${name}" (${count} instances)`);
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
const circularErrors = checkCircularDependencies(plugins);
|
|
525
|
-
errors.push(...circularErrors);
|
|
526
|
-
for (const plugin of plugins) {
|
|
527
|
-
if (!isValidPlugin(plugin)) {
|
|
528
|
-
const name = plugin.name || "unknown";
|
|
529
|
-
errors.push(`Invalid plugin: "${name}"`);
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
return {
|
|
533
|
-
valid: errors.length === 0,
|
|
534
|
-
errors
|
|
535
|
-
};
|
|
536
|
-
}
|
|
537
|
-
var pluginCache;
|
|
538
|
-
var init_plugin_utils = __esm({
|
|
539
|
-
"__mcpc__core_latest/node_modules/@mcpc/core/src/plugin-utils.js"() {
|
|
540
|
-
pluginCache = /* @__PURE__ */ new Map();
|
|
541
|
-
}
|
|
542
|
-
});
|
|
543
|
-
|
|
544
341
|
// __mcpc__core_latest/node_modules/@mcpc/core/src/utils/common/schema.js
|
|
545
342
|
import traverse from "json-schema-traverse";
|
|
546
343
|
function updateRefPaths(schema, wrapperPath) {
|
|
@@ -3249,10 +3046,199 @@ function processToolTags({ description, tagToResults, $, tools, toolOverrides, t
|
|
|
3249
3046
|
// __mcpc__core_latest/node_modules/@mcpc/core/src/compose.js
|
|
3250
3047
|
init_built_in();
|
|
3251
3048
|
init_logger();
|
|
3252
|
-
|
|
3049
|
+
|
|
3050
|
+
// __mcpc__core_latest/node_modules/@mcpc/core/src/plugin-utils.js
|
|
3051
|
+
var pluginCache = /* @__PURE__ */ new Map();
|
|
3052
|
+
function shouldApplyPlugin(plugin, mode) {
|
|
3053
|
+
if (!plugin.apply) return true;
|
|
3054
|
+
if (typeof plugin.apply === "string") {
|
|
3055
|
+
return mode.includes(plugin.apply);
|
|
3056
|
+
}
|
|
3057
|
+
if (typeof plugin.apply === "function") {
|
|
3058
|
+
try {
|
|
3059
|
+
return plugin.apply(mode);
|
|
3060
|
+
} catch (error) {
|
|
3061
|
+
console.warn(`Plugin "${plugin.name}" apply function failed: ${error}. Defaulting to true.`);
|
|
3062
|
+
return true;
|
|
3063
|
+
}
|
|
3064
|
+
}
|
|
3065
|
+
return true;
|
|
3066
|
+
}
|
|
3067
|
+
function sortPluginsByOrder(plugins) {
|
|
3068
|
+
const pluginMap = /* @__PURE__ */ new Map();
|
|
3069
|
+
for (const plugin of plugins) {
|
|
3070
|
+
pluginMap.set(plugin.name, plugin);
|
|
3071
|
+
}
|
|
3072
|
+
const visited = /* @__PURE__ */ new Set();
|
|
3073
|
+
const sorted = [];
|
|
3074
|
+
function visit(plugin) {
|
|
3075
|
+
if (visited.has(plugin.name)) return;
|
|
3076
|
+
visited.add(plugin.name);
|
|
3077
|
+
if (plugin.dependencies) {
|
|
3078
|
+
for (const depName of plugin.dependencies) {
|
|
3079
|
+
const dep = pluginMap.get(depName);
|
|
3080
|
+
if (dep) {
|
|
3081
|
+
visit(dep);
|
|
3082
|
+
} else {
|
|
3083
|
+
console.warn(`Plugin "${plugin.name}" depends on "${depName}" which is not loaded`);
|
|
3084
|
+
}
|
|
3085
|
+
}
|
|
3086
|
+
}
|
|
3087
|
+
sorted.push(plugin);
|
|
3088
|
+
}
|
|
3089
|
+
const prePlugins = plugins.filter((p2) => p2.enforce === "pre");
|
|
3090
|
+
const normalPlugins = plugins.filter((p2) => !p2.enforce);
|
|
3091
|
+
const postPlugins = plugins.filter((p2) => p2.enforce === "post");
|
|
3092
|
+
[
|
|
3093
|
+
...prePlugins,
|
|
3094
|
+
...normalPlugins,
|
|
3095
|
+
...postPlugins
|
|
3096
|
+
].forEach(visit);
|
|
3097
|
+
return sorted;
|
|
3098
|
+
}
|
|
3099
|
+
function isValidPlugin(plugin) {
|
|
3100
|
+
if (!plugin || typeof plugin !== "object") return false;
|
|
3101
|
+
const p2 = plugin;
|
|
3102
|
+
if (!p2.name || typeof p2.name !== "string" || p2.name.trim() === "") {
|
|
3103
|
+
return false;
|
|
3104
|
+
}
|
|
3105
|
+
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";
|
|
3106
|
+
if (!hasHook) return false;
|
|
3107
|
+
if (p2.enforce && p2.enforce !== "pre" && p2.enforce !== "post") {
|
|
3108
|
+
return false;
|
|
3109
|
+
}
|
|
3110
|
+
if (p2.apply && typeof p2.apply !== "string" && typeof p2.apply !== "function") {
|
|
3111
|
+
return false;
|
|
3112
|
+
}
|
|
3113
|
+
if (p2.dependencies && !Array.isArray(p2.dependencies)) {
|
|
3114
|
+
return false;
|
|
3115
|
+
}
|
|
3116
|
+
return true;
|
|
3117
|
+
}
|
|
3118
|
+
function parseQueryParams(params) {
|
|
3119
|
+
const typedParams = {};
|
|
3120
|
+
for (const [key, value] of Object.entries(params)) {
|
|
3121
|
+
const numValue = Number(value);
|
|
3122
|
+
if (!isNaN(numValue) && value.trim() !== "") {
|
|
3123
|
+
typedParams[key] = numValue;
|
|
3124
|
+
continue;
|
|
3125
|
+
}
|
|
3126
|
+
if (value === "true") {
|
|
3127
|
+
typedParams[key] = true;
|
|
3128
|
+
continue;
|
|
3129
|
+
}
|
|
3130
|
+
if (value === "false") {
|
|
3131
|
+
typedParams[key] = false;
|
|
3132
|
+
continue;
|
|
3133
|
+
}
|
|
3134
|
+
if (value.includes(",")) {
|
|
3135
|
+
typedParams[key] = value.split(",").map((v) => v.trim());
|
|
3136
|
+
continue;
|
|
3137
|
+
}
|
|
3138
|
+
typedParams[key] = value;
|
|
3139
|
+
}
|
|
3140
|
+
return typedParams;
|
|
3141
|
+
}
|
|
3142
|
+
async function loadPlugin(pluginPath, options = {
|
|
3143
|
+
cache: true
|
|
3144
|
+
}) {
|
|
3145
|
+
if (options.cache && pluginCache.has(pluginPath)) {
|
|
3146
|
+
return pluginCache.get(pluginPath);
|
|
3147
|
+
}
|
|
3148
|
+
try {
|
|
3149
|
+
const [rawPath, queryString] = pluginPath.split("?", 2);
|
|
3150
|
+
const searchParams = new URLSearchParams(queryString || "");
|
|
3151
|
+
const params = Object.fromEntries(searchParams.entries());
|
|
3152
|
+
const resolveFn = import.meta.resolve;
|
|
3153
|
+
const importPath = typeof resolveFn === "function" ? resolveFn(rawPath) : new URL(rawPath, import.meta.url).href;
|
|
3154
|
+
const pluginModule = await import(importPath);
|
|
3155
|
+
const pluginFactory = pluginModule.createPlugin;
|
|
3156
|
+
const defaultPlugin = pluginModule.default;
|
|
3157
|
+
let plugin;
|
|
3158
|
+
if (Object.keys(params).length > 0) {
|
|
3159
|
+
if (typeof pluginFactory !== "function") {
|
|
3160
|
+
throw new Error(`Plugin "${rawPath}" has parameters but no createPlugin export function`);
|
|
3161
|
+
}
|
|
3162
|
+
const typedParams = parseQueryParams(params);
|
|
3163
|
+
plugin = pluginFactory(typedParams);
|
|
3164
|
+
} else {
|
|
3165
|
+
if (defaultPlugin) {
|
|
3166
|
+
plugin = defaultPlugin;
|
|
3167
|
+
} else if (typeof pluginFactory === "function") {
|
|
3168
|
+
plugin = pluginFactory();
|
|
3169
|
+
} else {
|
|
3170
|
+
throw new Error(`Plugin "${rawPath}" has no default export or createPlugin function`);
|
|
3171
|
+
}
|
|
3172
|
+
}
|
|
3173
|
+
if (!isValidPlugin(plugin)) {
|
|
3174
|
+
throw new Error(`Invalid plugin format in "${rawPath}": must have a unique name and at least one lifecycle hook`);
|
|
3175
|
+
}
|
|
3176
|
+
if (options.cache) {
|
|
3177
|
+
pluginCache.set(pluginPath, plugin);
|
|
3178
|
+
}
|
|
3179
|
+
return plugin;
|
|
3180
|
+
} catch (error) {
|
|
3181
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
3182
|
+
throw new Error(`Failed to load plugin from "${pluginPath}": ${errorMsg}`);
|
|
3183
|
+
}
|
|
3184
|
+
}
|
|
3185
|
+
function checkCircularDependencies(plugins) {
|
|
3186
|
+
const errors = [];
|
|
3187
|
+
const pluginMap = /* @__PURE__ */ new Map();
|
|
3188
|
+
for (const plugin of plugins) {
|
|
3189
|
+
pluginMap.set(plugin.name, plugin);
|
|
3190
|
+
}
|
|
3191
|
+
function checkCircular(pluginName, visited, path) {
|
|
3192
|
+
if (visited.has(pluginName)) {
|
|
3193
|
+
const cycle = [
|
|
3194
|
+
...path,
|
|
3195
|
+
pluginName
|
|
3196
|
+
].join(" -> ");
|
|
3197
|
+
errors.push(`Circular dependency detected: ${cycle}`);
|
|
3198
|
+
return;
|
|
3199
|
+
}
|
|
3200
|
+
const plugin = pluginMap.get(pluginName);
|
|
3201
|
+
if (!plugin || !plugin.dependencies) return;
|
|
3202
|
+
visited.add(pluginName);
|
|
3203
|
+
path.push(pluginName);
|
|
3204
|
+
for (const dep of plugin.dependencies) {
|
|
3205
|
+
checkCircular(dep, new Set(visited), [
|
|
3206
|
+
...path
|
|
3207
|
+
]);
|
|
3208
|
+
}
|
|
3209
|
+
}
|
|
3210
|
+
for (const plugin of plugins) {
|
|
3211
|
+
checkCircular(plugin.name, /* @__PURE__ */ new Set(), []);
|
|
3212
|
+
}
|
|
3213
|
+
return errors;
|
|
3214
|
+
}
|
|
3215
|
+
function validatePlugins(plugins) {
|
|
3216
|
+
const errors = [];
|
|
3217
|
+
const names = /* @__PURE__ */ new Map();
|
|
3218
|
+
for (const plugin of plugins) {
|
|
3219
|
+
const count = names.get(plugin.name) || 0;
|
|
3220
|
+
names.set(plugin.name, count + 1);
|
|
3221
|
+
}
|
|
3222
|
+
for (const [name, count] of names.entries()) {
|
|
3223
|
+
if (count > 1) {
|
|
3224
|
+
errors.push(`Duplicate plugin name: "${name}" (${count} instances)`);
|
|
3225
|
+
}
|
|
3226
|
+
}
|
|
3227
|
+
const circularErrors = checkCircularDependencies(plugins);
|
|
3228
|
+
errors.push(...circularErrors);
|
|
3229
|
+
for (const plugin of plugins) {
|
|
3230
|
+
if (!isValidPlugin(plugin)) {
|
|
3231
|
+
const name = plugin.name || "unknown";
|
|
3232
|
+
errors.push(`Invalid plugin: "${name}"`);
|
|
3233
|
+
}
|
|
3234
|
+
}
|
|
3235
|
+
return {
|
|
3236
|
+
valid: errors.length === 0,
|
|
3237
|
+
errors
|
|
3238
|
+
};
|
|
3239
|
+
}
|
|
3253
3240
|
|
|
3254
3241
|
// __mcpc__core_latest/node_modules/@mcpc/core/src/utils/plugin-manager.js
|
|
3255
|
-
init_plugin_utils();
|
|
3256
3242
|
init_logger();
|
|
3257
3243
|
var PluginManager = class {
|
|
3258
3244
|
server;
|
|
@@ -3604,6 +3590,25 @@ var ToolManager = class {
|
|
|
3604
3590
|
getToolRegistry() {
|
|
3605
3591
|
return this.toolRegistry;
|
|
3606
3592
|
}
|
|
3593
|
+
/**
|
|
3594
|
+
* Get all registered tools as ComposedTool objects
|
|
3595
|
+
* This includes tools registered via server.tool() in setup hooks
|
|
3596
|
+
*/
|
|
3597
|
+
getRegisteredToolsAsComposed() {
|
|
3598
|
+
const composedTools = {};
|
|
3599
|
+
for (const [name, tool] of this.toolRegistry.entries()) {
|
|
3600
|
+
composedTools[name] = {
|
|
3601
|
+
name,
|
|
3602
|
+
description: tool.description,
|
|
3603
|
+
inputSchema: tool.schema || {
|
|
3604
|
+
type: "object",
|
|
3605
|
+
properties: {}
|
|
3606
|
+
},
|
|
3607
|
+
execute: tool.callback
|
|
3608
|
+
};
|
|
3609
|
+
}
|
|
3610
|
+
return composedTools;
|
|
3611
|
+
}
|
|
3607
3612
|
};
|
|
3608
3613
|
|
|
3609
3614
|
// __mcpc__core_latest/node_modules/@mcpc/core/src/compose.js
|
|
@@ -3658,8 +3663,7 @@ var ComposableMCPServer = class extends Server {
|
|
|
3658
3663
|
if (plugins.length === 0) {
|
|
3659
3664
|
return data;
|
|
3660
3665
|
}
|
|
3661
|
-
const
|
|
3662
|
-
const sortedPlugins = sortPluginsByOrder2(plugins);
|
|
3666
|
+
const sortedPlugins = sortPluginsByOrder(plugins);
|
|
3663
3667
|
let currentData = data;
|
|
3664
3668
|
const context2 = {
|
|
3665
3669
|
toolName,
|
|
@@ -3767,6 +3771,14 @@ var ComposableMCPServer = class extends Server {
|
|
|
3767
3771
|
getHiddenToolNames() {
|
|
3768
3772
|
return this.toolManager.getHiddenToolNames();
|
|
3769
3773
|
}
|
|
3774
|
+
/**
|
|
3775
|
+
* Get all internal tool names (tools that are not public)
|
|
3776
|
+
*/
|
|
3777
|
+
getInternalToolNames() {
|
|
3778
|
+
const allToolNames = Array.from(this.toolManager.getToolRegistry().keys());
|
|
3779
|
+
const publicToolNames = this.getPublicToolNames();
|
|
3780
|
+
return allToolNames.filter((name) => !publicToolNames.includes(name));
|
|
3781
|
+
}
|
|
3770
3782
|
/**
|
|
3771
3783
|
* Get hidden tool schema by name (for internal access)
|
|
3772
3784
|
*/
|
|
@@ -3869,7 +3881,6 @@ var ComposableMCPServer = class extends Server {
|
|
|
3869
3881
|
availableToolNames.add(toolNameWithScope);
|
|
3870
3882
|
availableToolNames.add(toolId);
|
|
3871
3883
|
availableToolNames.add(`${mcpName}.${ALL_TOOLS_PLACEHOLDER2}`);
|
|
3872
|
-
availableToolNames.add(mcpName);
|
|
3873
3884
|
this.toolManager.setToolNameMapping(toolNameWithScope, toolId);
|
|
3874
3885
|
const internalName = toolNameWithScope.includes(".") ? toolNameWithScope.split(".").slice(1).join(".") : toolNameWithScope;
|
|
3875
3886
|
if (!this.toolNameMapping.has(internalName)) {
|
|
@@ -3900,14 +3911,23 @@ var ComposableMCPServer = class extends Server {
|
|
|
3900
3911
|
await this.logger.warning(` Available tools: ${Array.from(availableToolNames).sort().join(", ")}`);
|
|
3901
3912
|
}
|
|
3902
3913
|
Object.entries(tools).forEach(([toolId, tool]) => {
|
|
3903
|
-
this.toolManager.registerTool(toolId, tool.description || "
|
|
3914
|
+
this.toolManager.registerTool(toolId, tool.description || "", tool.inputSchema, tool.execute);
|
|
3904
3915
|
});
|
|
3905
|
-
|
|
3906
|
-
|
|
3916
|
+
const registeredTools = this.toolManager.getRegisteredToolsAsComposed();
|
|
3917
|
+
const allTools = {
|
|
3918
|
+
...tools
|
|
3919
|
+
};
|
|
3920
|
+
for (const [toolName, tool] of Object.entries(registeredTools)) {
|
|
3921
|
+
if (!allTools[toolName]) {
|
|
3922
|
+
allTools[toolName] = tool;
|
|
3923
|
+
}
|
|
3924
|
+
}
|
|
3925
|
+
await this.processToolsWithPlugins(allTools, options.mode ?? "agentic");
|
|
3926
|
+
await this.pluginManager.triggerFinalizeComposition(allTools, {
|
|
3907
3927
|
serverName: name ?? "anonymous",
|
|
3908
3928
|
mode: options.mode ?? "agentic",
|
|
3909
3929
|
server: this,
|
|
3910
|
-
toolNames: Object.keys(
|
|
3930
|
+
toolNames: Object.keys(allTools)
|
|
3911
3931
|
});
|
|
3912
3932
|
this.onclose = async () => {
|
|
3913
3933
|
await cleanupClients();
|
|
@@ -3920,16 +3940,16 @@ var ComposableMCPServer = class extends Server {
|
|
|
3920
3940
|
await this.disposePlugins();
|
|
3921
3941
|
await this.logger.info(`[${name}] Action: cleaned up dependent clients and plugins`);
|
|
3922
3942
|
};
|
|
3923
|
-
const toolNameToDetailList = Object.entries(
|
|
3943
|
+
const toolNameToDetailList = Object.entries(allTools);
|
|
3924
3944
|
const publicToolNames = this.getPublicToolNames();
|
|
3925
3945
|
const hiddenToolNames = this.getHiddenToolNames();
|
|
3926
3946
|
const contextToolNames = toolNameToDetailList.map(([name2]) => name2).filter((n) => !hiddenToolNames.includes(n));
|
|
3927
3947
|
publicToolNames.forEach((toolId) => {
|
|
3928
|
-
const tool =
|
|
3948
|
+
const tool = allTools[toolId];
|
|
3929
3949
|
if (!tool) {
|
|
3930
|
-
throw new Error(`Public tool ${toolId} not found in registry, available: ${Object.keys(
|
|
3950
|
+
throw new Error(`Public tool ${toolId} not found in registry, available: ${Object.keys(allTools).join(", ")}`);
|
|
3931
3951
|
}
|
|
3932
|
-
this.tool(toolId, tool.description || "
|
|
3952
|
+
this.tool(toolId, tool.description || "", jsonSchema(tool.inputSchema), tool.execute, {
|
|
3933
3953
|
internal: false
|
|
3934
3954
|
});
|
|
3935
3955
|
});
|
|
@@ -3954,7 +3974,7 @@ var ComposableMCPServer = class extends Server {
|
|
|
3954
3974
|
description = processToolTags({
|
|
3955
3975
|
...desTags,
|
|
3956
3976
|
description,
|
|
3957
|
-
tools,
|
|
3977
|
+
tools: allTools,
|
|
3958
3978
|
toolOverrides: /* @__PURE__ */ new Map(),
|
|
3959
3979
|
toolNameMapping: toolNameToIdMapping
|
|
3960
3980
|
});
|
package/package.json
CHANGED
package/types/src/compose.d.ts
CHANGED
|
@@ -39,6 +39,9 @@ export declare class ComposableMCPServer extends Server {
|
|
|
39
39
|
/**
|
|
40
40
|
* Get all hidden tool names
|
|
41
41
|
*/ getHiddenToolNames(): string[];
|
|
42
|
+
/**
|
|
43
|
+
* Get all internal tool names (tools that are not public)
|
|
44
|
+
*/ getInternalToolNames(): string[];
|
|
42
45
|
/**
|
|
43
46
|
* Get hidden tool schema by name (for internal access)
|
|
44
47
|
*/ getHiddenToolSchema(name: string): {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose.d.ts","sources":["../../src/compose.ts"],"names":[],"mappings":"AAAA,SAGE,KAAK,cAAc,EAGnB,KAAK,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