@mcpc-tech/cli 0.1.19 → 0.1.21
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.cjs +4899 -0
- package/bin/mcpc.mjs +251 -247
- package/package.json +13 -7
package/bin/mcpc.mjs
CHANGED
|
@@ -80,7 +80,7 @@ function getUserConfigDir() {
|
|
|
80
80
|
function getUserConfigPath() {
|
|
81
81
|
return join(getUserConfigDir(), "config.json");
|
|
82
82
|
}
|
|
83
|
-
async function saveUserConfig(
|
|
83
|
+
async function saveUserConfig(config, newAgentName) {
|
|
84
84
|
const configPath = getUserConfigPath();
|
|
85
85
|
const configDir = dirname(configPath);
|
|
86
86
|
try {
|
|
@@ -99,7 +99,7 @@ async function saveUserConfig(config2, newAgentName) {
|
|
|
99
99
|
`);
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
|
-
existingConfig.agents.push(...
|
|
102
|
+
existingConfig.agents.push(...config.agents);
|
|
103
103
|
await writeFile(configPath, JSON.stringify(existingConfig, null, 2), "utf-8");
|
|
104
104
|
console.error(`
|
|
105
105
|
\u2713 Added agent "${newAgentName}" (total: ${existingConfig.agents.length})
|
|
@@ -111,7 +111,7 @@ async function saveUserConfig(config2, newAgentName) {
|
|
|
111
111
|
await mkdir(configDir, {
|
|
112
112
|
recursive: true
|
|
113
113
|
});
|
|
114
|
-
await writeFile(configPath, JSON.stringify(
|
|
114
|
+
await writeFile(configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
115
115
|
console.error(`
|
|
116
116
|
\u2713 Configuration saved to: ${configPath}
|
|
117
117
|
Run: mcpc
|
|
@@ -142,7 +142,7 @@ async function createWrapConfig(args) {
|
|
|
142
142
|
Command: ${spec.command} ${spec.args.join(" ")}`);
|
|
143
143
|
}
|
|
144
144
|
const agentName = args.name || `${serverNames.join("__")}--orchestrator`;
|
|
145
|
-
const
|
|
145
|
+
const config = {
|
|
146
146
|
name: "mcpc-wrap-config",
|
|
147
147
|
version: "0.1.0",
|
|
148
148
|
capabilities: {
|
|
@@ -168,9 +168,9 @@ Mode: ${args.mode}` : "";
|
|
|
168
168
|
console.error(`
|
|
169
169
|
Created configuration for ${serverNames.length} MCP server(s)${modeInfo}`);
|
|
170
170
|
if (args.saveConfig) {
|
|
171
|
-
await saveUserConfig(
|
|
171
|
+
await saveUserConfig(config, agentName);
|
|
172
172
|
}
|
|
173
|
-
return
|
|
173
|
+
return config;
|
|
174
174
|
}
|
|
175
175
|
function printHelp() {
|
|
176
176
|
console.log(`
|
|
@@ -447,25 +447,25 @@ function replaceEnvVarsInConfig(obj) {
|
|
|
447
447
|
}
|
|
448
448
|
return obj;
|
|
449
449
|
}
|
|
450
|
-
function applyModeOverride(
|
|
451
|
-
if (!mode) return
|
|
452
|
-
|
|
450
|
+
function applyModeOverride(config, mode) {
|
|
451
|
+
if (!mode) return config;
|
|
452
|
+
config.agents.forEach((agent) => {
|
|
453
453
|
if (!agent.options) agent.options = {};
|
|
454
454
|
agent.options.mode = mode;
|
|
455
455
|
});
|
|
456
|
-
return
|
|
456
|
+
return config;
|
|
457
457
|
}
|
|
458
|
-
function normalizeConfig(
|
|
459
|
-
|
|
460
|
-
if (Array.isArray(
|
|
458
|
+
function normalizeConfig(config) {
|
|
459
|
+
config = replaceEnvVarsInConfig(config);
|
|
460
|
+
if (Array.isArray(config)) {
|
|
461
461
|
return {
|
|
462
462
|
name: "mcpc-server",
|
|
463
463
|
version: "0.1.0",
|
|
464
|
-
agents: normalizeAgents(
|
|
464
|
+
agents: normalizeAgents(config)
|
|
465
465
|
};
|
|
466
466
|
}
|
|
467
|
-
if (
|
|
468
|
-
const cfg =
|
|
467
|
+
if (config && typeof config === "object") {
|
|
468
|
+
const cfg = config;
|
|
469
469
|
return {
|
|
470
470
|
name: cfg.name || "mcpc-server",
|
|
471
471
|
version: cfg.version || "0.1.0",
|
|
@@ -646,31 +646,6 @@ import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
|
646
646
|
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
647
647
|
import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
|
|
648
648
|
|
|
649
|
-
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/registory.js
|
|
650
|
-
function connectToSmitheryServer(smitheryConfig) {
|
|
651
|
-
const serverUrl = new URL(smitheryConfig.deploymentUrl);
|
|
652
|
-
serverUrl.searchParams.set("config", btoa(JSON.stringify(smitheryConfig.config)));
|
|
653
|
-
serverUrl.searchParams.set("api_key", smitheryConfig?.smitheryApiKey ?? smitheryConfig?.config?.smitheryApiKey);
|
|
654
|
-
return {
|
|
655
|
-
url: serverUrl.toString()
|
|
656
|
-
};
|
|
657
|
-
}
|
|
658
|
-
function smitheryToolNameCompatibale(name, scope) {
|
|
659
|
-
if (!name.startsWith("toolbox_")) {
|
|
660
|
-
return {
|
|
661
|
-
toolNameWithScope: `${scope}.${name}`,
|
|
662
|
-
toolName: name
|
|
663
|
-
};
|
|
664
|
-
}
|
|
665
|
-
const [, ...toolNames] = name.split("_");
|
|
666
|
-
const toolName = toolNames.join("_");
|
|
667
|
-
const toolNameWithScope = `${scope}.${toolName}`;
|
|
668
|
-
return {
|
|
669
|
-
toolNameWithScope,
|
|
670
|
-
toolName
|
|
671
|
-
};
|
|
672
|
-
}
|
|
673
|
-
|
|
674
649
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/config.js
|
|
675
650
|
import process3 from "node:process";
|
|
676
651
|
var GEMINI_PREFERRED_FORMAT = process3.env.GEMINI_PREFERRED_FORMAT === "0" ? false : true;
|
|
@@ -682,27 +657,38 @@ import { jsonrepair as jsonrepair2 } from "jsonrepair";
|
|
|
682
657
|
function sanitizePropertyKey(name) {
|
|
683
658
|
return name.replace(/[@.,/\\:;!?#$%^&*()[\]{}]/g, "_").substring(0, 64);
|
|
684
659
|
}
|
|
685
|
-
var
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
const
|
|
690
|
-
|
|
660
|
+
var createModelCompatibleJSONSchema = (schema) => {
|
|
661
|
+
const validatorOnlyKeys = [
|
|
662
|
+
"errorMessage"
|
|
663
|
+
];
|
|
664
|
+
const geminiRestrictedKeys = GEMINI_PREFERRED_FORMAT ? [
|
|
665
|
+
"additionalProperties"
|
|
666
|
+
] : [];
|
|
667
|
+
const keysToRemove = /* @__PURE__ */ new Set([
|
|
668
|
+
...validatorOnlyKeys,
|
|
669
|
+
...geminiRestrictedKeys
|
|
670
|
+
]);
|
|
671
|
+
let cleanSchema = schema;
|
|
672
|
+
if (GEMINI_PREFERRED_FORMAT) {
|
|
673
|
+
const { oneOf: _oneOf, allOf: _allOf, anyOf: _anyOf, ...rest2 } = schema;
|
|
674
|
+
cleanSchema = rest2;
|
|
675
|
+
}
|
|
676
|
+
const cleanRecursively = (obj) => {
|
|
691
677
|
if (Array.isArray(obj)) {
|
|
692
|
-
return obj.map(
|
|
678
|
+
return obj.map(cleanRecursively);
|
|
693
679
|
}
|
|
694
680
|
if (obj && typeof obj === "object") {
|
|
695
681
|
const result = {};
|
|
696
682
|
for (const [key, value] of Object.entries(obj)) {
|
|
697
|
-
if (key
|
|
698
|
-
result[key] =
|
|
683
|
+
if (!keysToRemove.has(key)) {
|
|
684
|
+
result[key] = cleanRecursively(value);
|
|
699
685
|
}
|
|
700
686
|
}
|
|
701
687
|
return result;
|
|
702
688
|
}
|
|
703
689
|
return obj;
|
|
704
690
|
};
|
|
705
|
-
return
|
|
691
|
+
return cleanRecursively(cleanSchema);
|
|
706
692
|
};
|
|
707
693
|
|
|
708
694
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/mcp.js
|
|
@@ -781,13 +767,13 @@ async function getOrCreateMcpClient(defKey, def) {
|
|
|
781
767
|
if (entry) entry.refCount += 1;
|
|
782
768
|
return client;
|
|
783
769
|
}
|
|
784
|
-
const
|
|
770
|
+
const transport = createTransport(def);
|
|
785
771
|
const connecting = (async () => {
|
|
786
772
|
const client = new Client({
|
|
787
773
|
name: `mcp_${shortHash(defSignature(def))}`,
|
|
788
774
|
version: "1.0.0"
|
|
789
775
|
});
|
|
790
|
-
await client.connect(
|
|
776
|
+
await client.connect(transport, {
|
|
791
777
|
timeout: 6e4 * 10
|
|
792
778
|
});
|
|
793
779
|
return client;
|
|
@@ -849,7 +835,8 @@ async function composeMcpDepTools(mcpConfig, filterIn) {
|
|
|
849
835
|
allClients[serverId] = client;
|
|
850
836
|
const { tools } = await client.listTools();
|
|
851
837
|
tools.forEach((tool) => {
|
|
852
|
-
const
|
|
838
|
+
const toolNameWithScope = `${name}.${tool.name}`;
|
|
839
|
+
const internalToolName = tool.name;
|
|
853
840
|
const rawToolId = `${serverId}_${internalToolName}`;
|
|
854
841
|
const toolId = sanitizePropertyKey(rawToolId);
|
|
855
842
|
if (filterIn && !filterIn({
|
|
@@ -933,10 +920,10 @@ var createConfigPlugin = () => ({
|
|
|
933
920
|
version: "1.0.0",
|
|
934
921
|
enforce: "pre",
|
|
935
922
|
transformTool: (tool, context2) => {
|
|
936
|
-
const
|
|
937
|
-
const
|
|
938
|
-
if (
|
|
939
|
-
tool.description =
|
|
923
|
+
const server = context2.server;
|
|
924
|
+
const config = server.findToolConfig?.(context2.toolName);
|
|
925
|
+
if (config?.description) {
|
|
926
|
+
tool.description = config.description;
|
|
940
927
|
}
|
|
941
928
|
return tool;
|
|
942
929
|
}
|
|
@@ -949,19 +936,19 @@ var createToolNameMappingPlugin = () => ({
|
|
|
949
936
|
version: "1.0.0",
|
|
950
937
|
enforce: "pre",
|
|
951
938
|
transformTool: (tool, context2) => {
|
|
952
|
-
const
|
|
939
|
+
const server = context2.server;
|
|
953
940
|
const toolName = context2.toolName;
|
|
954
941
|
const originalName = tool._originalName || toolName;
|
|
955
942
|
const dotNotation = originalName.replace(/_/g, ".");
|
|
956
943
|
const underscoreNotation = originalName.replace(/\./g, "_");
|
|
957
|
-
if (dotNotation !== originalName &&
|
|
958
|
-
|
|
944
|
+
if (dotNotation !== originalName && server.toolNameMapping) {
|
|
945
|
+
server.toolNameMapping.set(dotNotation, toolName);
|
|
959
946
|
}
|
|
960
|
-
if (underscoreNotation !== originalName &&
|
|
961
|
-
|
|
947
|
+
if (underscoreNotation !== originalName && server.toolNameMapping) {
|
|
948
|
+
server.toolNameMapping.set(underscoreNotation, toolName);
|
|
962
949
|
}
|
|
963
|
-
if (originalName !== toolName &&
|
|
964
|
-
|
|
950
|
+
if (originalName !== toolName && server.toolNameMapping) {
|
|
951
|
+
server.toolNameMapping.set(originalName, toolName);
|
|
965
952
|
}
|
|
966
953
|
return tool;
|
|
967
954
|
}
|
|
@@ -983,12 +970,12 @@ var MCPLogger = class _MCPLogger {
|
|
|
983
970
|
server;
|
|
984
971
|
loggerName;
|
|
985
972
|
minLevel = "debug";
|
|
986
|
-
constructor(loggerName = "mcpc",
|
|
973
|
+
constructor(loggerName = "mcpc", server) {
|
|
987
974
|
this.loggerName = loggerName;
|
|
988
|
-
this.server =
|
|
975
|
+
this.server = server;
|
|
989
976
|
}
|
|
990
|
-
setServer(
|
|
991
|
-
this.server =
|
|
977
|
+
setServer(server) {
|
|
978
|
+
this.server = server;
|
|
992
979
|
}
|
|
993
980
|
setLevel(level) {
|
|
994
981
|
this.minLevel = level;
|
|
@@ -1045,8 +1032,8 @@ var MCPLogger = class _MCPLogger {
|
|
|
1045
1032
|
}
|
|
1046
1033
|
};
|
|
1047
1034
|
var logger = new MCPLogger("mcpc");
|
|
1048
|
-
function createLogger(name,
|
|
1049
|
-
return new MCPLogger(name,
|
|
1035
|
+
function createLogger(name, server) {
|
|
1036
|
+
return new MCPLogger(name, server);
|
|
1050
1037
|
}
|
|
1051
1038
|
|
|
1052
1039
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/plugins/built-in/logging-plugin.js
|
|
@@ -1066,10 +1053,10 @@ var createLoggingPlugin = (options = {}) => {
|
|
|
1066
1053
|
await logger2.info(`[${context2.toolName}] Composition complete`);
|
|
1067
1054
|
await logger2.info(` \u251C\u2500 Plugins: ${context2.pluginNames.join(", ")}`);
|
|
1068
1055
|
const { stats } = context2;
|
|
1069
|
-
const
|
|
1070
|
-
const publicTools = Array.from(new Set(
|
|
1071
|
-
const internalTools = Array.from(new Set(
|
|
1072
|
-
const hiddenTools = Array.from(new Set(
|
|
1056
|
+
const server = context2.server;
|
|
1057
|
+
const publicTools = Array.from(new Set(server.getPublicToolNames().map(String)));
|
|
1058
|
+
const internalTools = Array.from(new Set(server.getInternalToolNames().map(String)));
|
|
1059
|
+
const hiddenTools = Array.from(new Set(server.getHiddenToolNames().map(String)));
|
|
1073
1060
|
const normalInternal = internalTools.filter((name) => !hiddenTools.includes(name));
|
|
1074
1061
|
if (publicTools.length > 0) {
|
|
1075
1062
|
await logger2.info(` \u251C\u2500 Public: ${publicTools.join(", ")}`);
|
|
@@ -1441,19 +1428,32 @@ ${JSON.stringify(steps, null, 2)}`;
|
|
|
1441
1428
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/schema-validator.js
|
|
1442
1429
|
import { Ajv } from "ajv";
|
|
1443
1430
|
import addFormats from "ajv-formats";
|
|
1431
|
+
import ajvErrors from "ajv-errors";
|
|
1444
1432
|
import { AggregateAjvError } from "@segment/ajv-human-errors";
|
|
1445
1433
|
var ajv = new Ajv({
|
|
1446
1434
|
allErrors: true,
|
|
1447
1435
|
verbose: true
|
|
1448
1436
|
});
|
|
1449
1437
|
addFormats.default(ajv);
|
|
1438
|
+
ajvErrors.default(ajv);
|
|
1450
1439
|
function validateSchema(args, schema) {
|
|
1451
1440
|
const validate = ajv.compile(schema);
|
|
1452
1441
|
if (!validate(args)) {
|
|
1453
|
-
const errors =
|
|
1442
|
+
const errors = validate.errors;
|
|
1443
|
+
const customErrors = errors.filter((err) => err.keyword === "errorMessage");
|
|
1444
|
+
if (customErrors.length > 0) {
|
|
1445
|
+
const messages = [
|
|
1446
|
+
...new Set(customErrors.map((err) => err.message))
|
|
1447
|
+
];
|
|
1448
|
+
return {
|
|
1449
|
+
valid: false,
|
|
1450
|
+
error: messages.join("; ")
|
|
1451
|
+
};
|
|
1452
|
+
}
|
|
1453
|
+
const aggregateError = new AggregateAjvError(errors);
|
|
1454
1454
|
return {
|
|
1455
1455
|
valid: false,
|
|
1456
|
-
error:
|
|
1456
|
+
error: aggregateError.message
|
|
1457
1457
|
};
|
|
1458
1458
|
}
|
|
1459
1459
|
return {
|
|
@@ -1471,11 +1471,11 @@ import { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION } from "@opentelemetry/semantic
|
|
|
1471
1471
|
var tracerProvider = null;
|
|
1472
1472
|
var tracer = null;
|
|
1473
1473
|
var isInitialized = false;
|
|
1474
|
-
function initializeTracing(
|
|
1474
|
+
function initializeTracing(config = {}) {
|
|
1475
1475
|
if (isInitialized) {
|
|
1476
1476
|
return;
|
|
1477
1477
|
}
|
|
1478
|
-
const { enabled = true, serviceName = "mcpc-sampling", serviceVersion = "0.2.0", exportTo = "console", otlpEndpoint = "http://localhost:4318/v1/traces", otlpHeaders = {} } =
|
|
1478
|
+
const { enabled = true, serviceName = "mcpc-sampling", serviceVersion = "0.2.0", exportTo = "console", otlpEndpoint = "http://localhost:4318/v1/traces", otlpHeaders = {} } = config;
|
|
1479
1479
|
if (!enabled) {
|
|
1480
1480
|
isInitialized = true;
|
|
1481
1481
|
return;
|
|
@@ -1538,14 +1538,14 @@ var AgenticExecutor = class {
|
|
|
1538
1538
|
USE_TOOL_KEY;
|
|
1539
1539
|
logger;
|
|
1540
1540
|
tracingEnabled;
|
|
1541
|
-
constructor(name, allToolNames, toolNameToDetailList,
|
|
1541
|
+
constructor(name, allToolNames, toolNameToDetailList, server, USE_TOOL_KEY = "useTool") {
|
|
1542
1542
|
this.name = name;
|
|
1543
1543
|
this.allToolNames = allToolNames;
|
|
1544
1544
|
this.toolNameToDetailList = toolNameToDetailList;
|
|
1545
|
-
this.server =
|
|
1545
|
+
this.server = server;
|
|
1546
1546
|
this.USE_TOOL_KEY = USE_TOOL_KEY;
|
|
1547
1547
|
this.tracingEnabled = false;
|
|
1548
|
-
this.logger = createLogger(`mcpc.agentic.${name}`,
|
|
1548
|
+
this.logger = createLogger(`mcpc.agentic.${name}`, server);
|
|
1549
1549
|
try {
|
|
1550
1550
|
this.tracingEnabled = process5.env.MCPC_TRACING_ENABLED === "true";
|
|
1551
1551
|
if (this.tracingEnabled) {
|
|
@@ -1604,11 +1604,17 @@ var AgenticExecutor = class {
|
|
|
1604
1604
|
});
|
|
1605
1605
|
endSpan(executeSpan);
|
|
1606
1606
|
}
|
|
1607
|
-
const
|
|
1607
|
+
const result = {
|
|
1608
1608
|
content: []
|
|
1609
1609
|
};
|
|
1610
|
-
this.appendToolSchemas(
|
|
1611
|
-
|
|
1610
|
+
this.appendToolSchemas(result, definitionsOf, hasDefinitions);
|
|
1611
|
+
if (result.content.length === 0 && definitionsOf.length > 0) {
|
|
1612
|
+
result.content.push({
|
|
1613
|
+
type: "text",
|
|
1614
|
+
text: `All requested tool schemas are already in hasDefinitions. You can now call a tool using "${this.USE_TOOL_KEY}".`
|
|
1615
|
+
});
|
|
1616
|
+
}
|
|
1617
|
+
return result;
|
|
1612
1618
|
}
|
|
1613
1619
|
if (executeSpan) {
|
|
1614
1620
|
try {
|
|
@@ -1658,8 +1664,8 @@ var AgenticExecutor = class {
|
|
|
1658
1664
|
selectTool: useTool
|
|
1659
1665
|
});
|
|
1660
1666
|
try {
|
|
1661
|
-
const
|
|
1662
|
-
const callToolResult =
|
|
1667
|
+
const result = await this.server.callTool(useTool, args[useTool]);
|
|
1668
|
+
const callToolResult = result ?? {
|
|
1663
1669
|
content: []
|
|
1664
1670
|
};
|
|
1665
1671
|
this.appendToolSchemas(callToolResult, definitionsOf, hasDefinitions);
|
|
@@ -1700,16 +1706,15 @@ var AgenticExecutor = class {
|
|
|
1700
1706
|
});
|
|
1701
1707
|
endSpan(executeSpan);
|
|
1702
1708
|
}
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1709
|
+
return {
|
|
1710
|
+
content: [
|
|
1711
|
+
{
|
|
1712
|
+
type: "text",
|
|
1713
|
+
text: `Tool "${useTool}" not found. Available tools: ${this.allToolNames.join(", ")}.`
|
|
1714
|
+
}
|
|
1715
|
+
],
|
|
1716
|
+
isError: true
|
|
1710
1717
|
};
|
|
1711
|
-
this.appendToolSchemas(result, definitionsOf, hasDefinitions);
|
|
1712
|
-
return result;
|
|
1713
1718
|
} catch (error) {
|
|
1714
1719
|
if (executeSpan) {
|
|
1715
1720
|
endSpan(executeSpan, error);
|
|
@@ -1937,7 +1942,10 @@ Workflow step definitions - provide ONLY on initial call.
|
|
|
1937
1942
|
decision: () => ({
|
|
1938
1943
|
type: "string",
|
|
1939
1944
|
enum: Object.values(DECISION_OPTIONS),
|
|
1940
|
-
description: `**Step control: \`${DECISION_OPTIONS.PROCEED}\` = next step, \`${DECISION_OPTIONS.RETRY}\` = retry/repeat current, \`${DECISION_OPTIONS.COMPLETE}\` = finish workflow
|
|
1945
|
+
description: `**Step control: \`${DECISION_OPTIONS.PROCEED}\` = next step, \`${DECISION_OPTIONS.RETRY}\` = retry/repeat current, \`${DECISION_OPTIONS.COMPLETE}\` = finish workflow**`,
|
|
1946
|
+
errorMessage: {
|
|
1947
|
+
enum: `Invalid decision. Must be one of: ${Object.values(DECISION_OPTIONS).join(", ")}.`
|
|
1948
|
+
}
|
|
1941
1949
|
}),
|
|
1942
1950
|
action: () => ({
|
|
1943
1951
|
type: "string",
|
|
@@ -1945,7 +1953,10 @@ Workflow step definitions - provide ONLY on initial call.
|
|
|
1945
1953
|
enum: allToolNames,
|
|
1946
1954
|
required: [
|
|
1947
1955
|
"action"
|
|
1948
|
-
]
|
|
1956
|
+
],
|
|
1957
|
+
errorMessage: {
|
|
1958
|
+
enum: `Invalid action. Must be one of: ${allToolNames.join(", ")}.`
|
|
1959
|
+
}
|
|
1949
1960
|
}),
|
|
1950
1961
|
forTool: function() {
|
|
1951
1962
|
return this.common({});
|
|
@@ -1987,58 +1998,17 @@ Workflow step definitions - provide ONLY on initial call.
|
|
|
1987
1998
|
required: [
|
|
1988
1999
|
"userRequest",
|
|
1989
2000
|
"context"
|
|
1990
|
-
]
|
|
2001
|
+
],
|
|
2002
|
+
errorMessage: {
|
|
2003
|
+
required: {
|
|
2004
|
+
userRequest: "Missing required field 'userRequest'. Please provide a clear task description.",
|
|
2005
|
+
context: "Missing required field 'context'. Please provide relevant context (e.g., current working directory)."
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
1991
2008
|
};
|
|
1992
2009
|
},
|
|
1993
2010
|
forAgentic: function(toolNameToDetailList, _sampling = false, USE_TOOL_KEY = "useTool") {
|
|
1994
2011
|
const allOf = [
|
|
1995
|
-
// When hasDefinitions is empty, definitionsOf must be provided
|
|
1996
|
-
{
|
|
1997
|
-
if: {
|
|
1998
|
-
properties: {
|
|
1999
|
-
hasDefinitions: {
|
|
2000
|
-
type: "array",
|
|
2001
|
-
maxItems: 0
|
|
2002
|
-
}
|
|
2003
|
-
},
|
|
2004
|
-
required: [
|
|
2005
|
-
"hasDefinitions"
|
|
2006
|
-
]
|
|
2007
|
-
},
|
|
2008
|
-
then: {
|
|
2009
|
-
required: [
|
|
2010
|
-
"definitionsOf"
|
|
2011
|
-
]
|
|
2012
|
-
}
|
|
2013
|
-
},
|
|
2014
|
-
// When useTool is present, hasDefinitions must contain that tool
|
|
2015
|
-
...toolNameToDetailList.map(([toolName, _toolDetail]) => {
|
|
2016
|
-
return {
|
|
2017
|
-
if: {
|
|
2018
|
-
properties: {
|
|
2019
|
-
[USE_TOOL_KEY]: {
|
|
2020
|
-
const: toolName
|
|
2021
|
-
}
|
|
2022
|
-
},
|
|
2023
|
-
required: [
|
|
2024
|
-
USE_TOOL_KEY
|
|
2025
|
-
]
|
|
2026
|
-
},
|
|
2027
|
-
then: {
|
|
2028
|
-
properties: {
|
|
2029
|
-
hasDefinitions: {
|
|
2030
|
-
type: "array",
|
|
2031
|
-
contains: {
|
|
2032
|
-
const: toolName
|
|
2033
|
-
}
|
|
2034
|
-
}
|
|
2035
|
-
},
|
|
2036
|
-
required: [
|
|
2037
|
-
"hasDefinitions"
|
|
2038
|
-
]
|
|
2039
|
-
}
|
|
2040
|
-
};
|
|
2041
|
-
}),
|
|
2042
2012
|
// When a specific tool is selected, its parameters must be provided
|
|
2043
2013
|
...toolNameToDetailList.map(([toolName, _toolDetail]) => {
|
|
2044
2014
|
return {
|
|
@@ -2055,7 +2025,12 @@ Workflow step definitions - provide ONLY on initial call.
|
|
|
2055
2025
|
then: {
|
|
2056
2026
|
required: [
|
|
2057
2027
|
toolName
|
|
2058
|
-
]
|
|
2028
|
+
],
|
|
2029
|
+
errorMessage: {
|
|
2030
|
+
required: {
|
|
2031
|
+
[toolName]: `Tool "${toolName}" is selected but its parameters are missing. Please provide "${toolName}": { ...parameters }.`
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2059
2034
|
}
|
|
2060
2035
|
};
|
|
2061
2036
|
})
|
|
@@ -2071,7 +2046,10 @@ Workflow step definitions - provide ONLY on initial call.
|
|
|
2071
2046
|
[USE_TOOL_KEY]: {
|
|
2072
2047
|
type: "string",
|
|
2073
2048
|
enum: allToolNames,
|
|
2074
|
-
description: useToolDescription
|
|
2049
|
+
description: useToolDescription,
|
|
2050
|
+
errorMessage: {
|
|
2051
|
+
enum: `Invalid tool name. Available tools: ${allToolNames.join(", ")}.`
|
|
2052
|
+
}
|
|
2075
2053
|
},
|
|
2076
2054
|
hasDefinitions: {
|
|
2077
2055
|
type: "array",
|
|
@@ -2094,6 +2072,41 @@ Workflow step definitions - provide ONLY on initial call.
|
|
|
2094
2072
|
if (allOf.length > 0) {
|
|
2095
2073
|
schema.allOf = allOf;
|
|
2096
2074
|
}
|
|
2075
|
+
if (allToolNames.length > 0) {
|
|
2076
|
+
const thenClause = {
|
|
2077
|
+
required: [
|
|
2078
|
+
USE_TOOL_KEY
|
|
2079
|
+
],
|
|
2080
|
+
errorMessage: {
|
|
2081
|
+
required: {
|
|
2082
|
+
[USE_TOOL_KEY]: `No tool selected. Please specify "${USE_TOOL_KEY}" to select one of: ${allToolNames.join(", ")}. Or use "definitionsOf" with tool names to get their schemas first.`
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
};
|
|
2086
|
+
Object.assign(schema, {
|
|
2087
|
+
if: {
|
|
2088
|
+
// definitionsOf is not provided OR is empty array
|
|
2089
|
+
anyOf: [
|
|
2090
|
+
{
|
|
2091
|
+
not: {
|
|
2092
|
+
required: [
|
|
2093
|
+
"definitionsOf"
|
|
2094
|
+
]
|
|
2095
|
+
}
|
|
2096
|
+
},
|
|
2097
|
+
{
|
|
2098
|
+
properties: {
|
|
2099
|
+
definitionsOf: {
|
|
2100
|
+
type: "array",
|
|
2101
|
+
maxItems: 0
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
]
|
|
2106
|
+
},
|
|
2107
|
+
then: thenClause
|
|
2108
|
+
});
|
|
2109
|
+
}
|
|
2097
2110
|
return schema;
|
|
2098
2111
|
},
|
|
2099
2112
|
forNextState: function(state) {
|
|
@@ -2138,9 +2151,9 @@ NOTE: The \`steps\` has been predefined` : `**You MUST execute this tool with fo
|
|
|
2138
2151
|
}
|
|
2139
2152
|
|
|
2140
2153
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/executors/agentic/agentic-tool-registrar.js
|
|
2141
|
-
function registerAgenticTool(
|
|
2154
|
+
function registerAgenticTool(server, { description, name, allToolNames, depGroups, toolNameToDetailList }) {
|
|
2142
2155
|
const createArgsDef = createArgsDefFactory(name, allToolNames, depGroups, void 0, void 0);
|
|
2143
|
-
const agenticExecutor = new AgenticExecutor(name, allToolNames, toolNameToDetailList,
|
|
2156
|
+
const agenticExecutor = new AgenticExecutor(name, allToolNames, toolNameToDetailList, server);
|
|
2144
2157
|
description = CompiledPrompts.autonomousExecution({
|
|
2145
2158
|
toolName: name,
|
|
2146
2159
|
description
|
|
@@ -2151,7 +2164,7 @@ function registerAgenticTool(server2, { description, name, allToolNames, depGrou
|
|
|
2151
2164
|
type: "object",
|
|
2152
2165
|
properties: {}
|
|
2153
2166
|
};
|
|
2154
|
-
|
|
2167
|
+
server.tool(name, description, jsonSchema(createModelCompatibleJSONSchema(schema)), async (args) => {
|
|
2155
2168
|
return await agenticExecutor.execute(args, schema);
|
|
2156
2169
|
});
|
|
2157
2170
|
}
|
|
@@ -2354,12 +2367,12 @@ var WorkflowExecutor = class {
|
|
|
2354
2367
|
predefinedSteps;
|
|
2355
2368
|
ensureStepActions;
|
|
2356
2369
|
toolNameToIdMapping;
|
|
2357
|
-
constructor(name, allToolNames, toolNameToDetailList, createArgsDef,
|
|
2370
|
+
constructor(name, allToolNames, toolNameToDetailList, createArgsDef, server, predefinedSteps, ensureStepActions, toolNameToIdMapping) {
|
|
2358
2371
|
this.name = name;
|
|
2359
2372
|
this.allToolNames = allToolNames;
|
|
2360
2373
|
this.toolNameToDetailList = toolNameToDetailList;
|
|
2361
2374
|
this.createArgsDef = createArgsDef;
|
|
2362
|
-
this.server =
|
|
2375
|
+
this.server = server;
|
|
2363
2376
|
this.predefinedSteps = predefinedSteps;
|
|
2364
2377
|
this.ensureStepActions = ensureStepActions;
|
|
2365
2378
|
this.toolNameToIdMapping = toolNameToIdMapping;
|
|
@@ -2654,9 +2667,9 @@ ${this.formatProgress(state)}`
|
|
|
2654
2667
|
};
|
|
2655
2668
|
|
|
2656
2669
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/executors/workflow/workflow-tool-registrar.js
|
|
2657
|
-
function registerAgenticWorkflowTool(
|
|
2670
|
+
function registerAgenticWorkflowTool(server, { description, name, allToolNames, depGroups, toolNameToDetailList, predefinedSteps, ensureStepActions, toolNameToIdMapping }) {
|
|
2658
2671
|
const createArgsDef = createArgsDefFactory(name, allToolNames, depGroups, predefinedSteps, ensureStepActions);
|
|
2659
|
-
const workflowExecutor = new WorkflowExecutor(name, allToolNames, toolNameToDetailList, createArgsDef,
|
|
2672
|
+
const workflowExecutor = new WorkflowExecutor(name, allToolNames, toolNameToDetailList, createArgsDef, server, predefinedSteps, ensureStepActions, toolNameToIdMapping);
|
|
2660
2673
|
const workflowState = new WorkflowState();
|
|
2661
2674
|
const planningInstructions = predefinedSteps ? "- Set `init: true` (steps are predefined)" : "- Set `init: true` and define complete `steps` array";
|
|
2662
2675
|
const baseDescription = CompiledPrompts.workflowExecution({
|
|
@@ -2666,7 +2679,7 @@ function registerAgenticWorkflowTool(server2, { description, name, allToolNames,
|
|
|
2666
2679
|
});
|
|
2667
2680
|
const argsDef = createArgsDef.forTool();
|
|
2668
2681
|
const toolDescription = createArgsDef.forToolDescription(baseDescription, workflowState);
|
|
2669
|
-
|
|
2682
|
+
server.tool(name, toolDescription, jsonSchema(createModelCompatibleJSONSchema(argsDef)), async (args) => {
|
|
2670
2683
|
try {
|
|
2671
2684
|
return await workflowExecutor.execute(args, workflowState);
|
|
2672
2685
|
} catch (error) {
|
|
@@ -2720,24 +2733,24 @@ var BaseSamplingExecutor = class {
|
|
|
2720
2733
|
logger;
|
|
2721
2734
|
tracingEnabled;
|
|
2722
2735
|
summarize;
|
|
2723
|
-
constructor(name, description, allToolNames, toolNameToDetailList,
|
|
2736
|
+
constructor(name, description, allToolNames, toolNameToDetailList, server, config) {
|
|
2724
2737
|
this.name = name;
|
|
2725
2738
|
this.description = description;
|
|
2726
2739
|
this.allToolNames = allToolNames;
|
|
2727
2740
|
this.toolNameToDetailList = toolNameToDetailList;
|
|
2728
|
-
this.server =
|
|
2741
|
+
this.server = server;
|
|
2729
2742
|
this.conversationHistory = [];
|
|
2730
2743
|
this.maxIterations = 55;
|
|
2731
2744
|
this.currentIteration = 0;
|
|
2732
2745
|
this.tracingEnabled = false;
|
|
2733
2746
|
this.summarize = true;
|
|
2734
|
-
if (
|
|
2735
|
-
this.maxIterations =
|
|
2747
|
+
if (config?.maxIterations) {
|
|
2748
|
+
this.maxIterations = config.maxIterations;
|
|
2736
2749
|
}
|
|
2737
|
-
if (
|
|
2738
|
-
this.summarize =
|
|
2750
|
+
if (config?.summarize !== void 0) {
|
|
2751
|
+
this.summarize = config.summarize;
|
|
2739
2752
|
}
|
|
2740
|
-
this.logger = createLogger(`mcpc.sampling.${name}`,
|
|
2753
|
+
this.logger = createLogger(`mcpc.sampling.${name}`, server);
|
|
2741
2754
|
try {
|
|
2742
2755
|
const tracingConfig = {
|
|
2743
2756
|
enabled: process6.env.MCPC_TRACING_ENABLED === "true",
|
|
@@ -3072,9 +3085,9 @@ VALID: {"key":"value"}` }) {
|
|
|
3072
3085
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/executors/sampling/agentic-sampling-executor.js
|
|
3073
3086
|
var SamplingExecutor = class extends BaseSamplingExecutor {
|
|
3074
3087
|
agenticExecutor;
|
|
3075
|
-
constructor(name, description, allToolNames, toolNameToDetailList,
|
|
3076
|
-
super(name, description, allToolNames, toolNameToDetailList,
|
|
3077
|
-
this.agenticExecutor = new AgenticExecutor(name, allToolNames, toolNameToDetailList,
|
|
3088
|
+
constructor(name, description, allToolNames, toolNameToDetailList, server, config) {
|
|
3089
|
+
super(name, description, allToolNames, toolNameToDetailList, server, config);
|
|
3090
|
+
this.agenticExecutor = new AgenticExecutor(name, allToolNames, toolNameToDetailList, server);
|
|
3078
3091
|
}
|
|
3079
3092
|
buildDepGroups() {
|
|
3080
3093
|
const depGroups = {};
|
|
@@ -3175,9 +3188,9 @@ When you need to use a tool, specify the tool name in 'action' and provide tool-
|
|
|
3175
3188
|
};
|
|
3176
3189
|
|
|
3177
3190
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/executors/agentic/agentic-sampling-registrar.js
|
|
3178
|
-
function registerAgenticSamplingTool(
|
|
3191
|
+
function registerAgenticSamplingTool(server, { description, name, allToolNames, depGroups, toolNameToDetailList, samplingConfig }) {
|
|
3179
3192
|
const createArgsDef = createArgsDefFactory(name, allToolNames, depGroups, void 0, void 0);
|
|
3180
|
-
const samplingExecutor = new SamplingExecutor(name, description, allToolNames, toolNameToDetailList,
|
|
3193
|
+
const samplingExecutor = new SamplingExecutor(name, description, allToolNames, toolNameToDetailList, server, samplingConfig);
|
|
3181
3194
|
description = CompiledPrompts.samplingExecution({
|
|
3182
3195
|
toolName: name,
|
|
3183
3196
|
description,
|
|
@@ -3188,7 +3201,7 @@ function registerAgenticSamplingTool(server2, { description, name, allToolNames,
|
|
|
3188
3201
|
type: "object",
|
|
3189
3202
|
properties: {}
|
|
3190
3203
|
};
|
|
3191
|
-
|
|
3204
|
+
server.tool(name, description, jsonSchema(createModelCompatibleJSONSchema(schema)), async (args) => {
|
|
3192
3205
|
return await samplingExecutor.executeSampling(args, schema);
|
|
3193
3206
|
});
|
|
3194
3207
|
}
|
|
@@ -3218,9 +3231,9 @@ var WorkflowSamplingExecutor = class extends BaseSamplingExecutor {
|
|
|
3218
3231
|
createArgsDef;
|
|
3219
3232
|
predefinedSteps;
|
|
3220
3233
|
workflowExecutor;
|
|
3221
|
-
constructor(name, description, allToolNames, toolNameToDetailList, createArgsDef,
|
|
3222
|
-
super(name, description, allToolNames, toolNameToDetailList,
|
|
3223
|
-
this.workflowExecutor = new WorkflowExecutor(name, allToolNames, toolNameToDetailList, createArgsDef,
|
|
3234
|
+
constructor(name, description, allToolNames, toolNameToDetailList, createArgsDef, server, predefinedSteps, config) {
|
|
3235
|
+
super(name, description, allToolNames, toolNameToDetailList, server, config), this.createArgsDef = createArgsDef, this.predefinedSteps = predefinedSteps;
|
|
3236
|
+
this.workflowExecutor = new WorkflowExecutor(name, allToolNames, toolNameToDetailList, createArgsDef, server, predefinedSteps);
|
|
3224
3237
|
}
|
|
3225
3238
|
async executeWorkflowSampling(args, schema, state) {
|
|
3226
3239
|
const validationResult = validateSchema(args, schema);
|
|
@@ -3288,9 +3301,9 @@ Current Task: <user_request>${args.userRequest}</user_request>${contextInfo}`;
|
|
|
3288
3301
|
};
|
|
3289
3302
|
|
|
3290
3303
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/executors/workflow/workflow-sampling-registrar.js
|
|
3291
|
-
function registerWorkflowSamplingTool(
|
|
3304
|
+
function registerWorkflowSamplingTool(server, { description, name, allToolNames, depGroups, toolNameToDetailList, predefinedSteps, samplingConfig, ensureStepActions, toolNameToIdMapping: _toolNameToIdMapping }) {
|
|
3292
3305
|
const createArgsDef = createArgsDefFactory(name, allToolNames, depGroups, predefinedSteps, ensureStepActions);
|
|
3293
|
-
const workflowSamplingExecutor = new WorkflowSamplingExecutor(name, description, allToolNames, toolNameToDetailList, createArgsDef,
|
|
3306
|
+
const workflowSamplingExecutor = new WorkflowSamplingExecutor(name, description, allToolNames, toolNameToDetailList, createArgsDef, server, predefinedSteps, samplingConfig);
|
|
3294
3307
|
const workflowState = new WorkflowState();
|
|
3295
3308
|
const baseDescription = CompiledPrompts.samplingExecution({
|
|
3296
3309
|
toolName: name,
|
|
@@ -3302,7 +3315,7 @@ function registerWorkflowSamplingTool(server2, { description, name, allToolNames
|
|
|
3302
3315
|
type: "object",
|
|
3303
3316
|
properties: {}
|
|
3304
3317
|
};
|
|
3305
|
-
|
|
3318
|
+
server.tool(name, baseDescription, jsonSchema(createModelCompatibleJSONSchema(schema)), async (args) => {
|
|
3306
3319
|
try {
|
|
3307
3320
|
return await workflowSamplingExecutor.executeWorkflowSampling(args, schema, workflowState);
|
|
3308
3321
|
} catch (error) {
|
|
@@ -3552,11 +3565,11 @@ var PluginManager = class {
|
|
|
3552
3565
|
server;
|
|
3553
3566
|
plugins;
|
|
3554
3567
|
logger;
|
|
3555
|
-
constructor(
|
|
3556
|
-
this.server =
|
|
3568
|
+
constructor(server) {
|
|
3569
|
+
this.server = server;
|
|
3557
3570
|
this.plugins = [];
|
|
3558
3571
|
this.logger = createLogger("mcpc.plugin-manager");
|
|
3559
|
-
this.logger.setServer(
|
|
3572
|
+
this.logger.setServer(server);
|
|
3560
3573
|
}
|
|
3561
3574
|
/**
|
|
3562
3575
|
* Get all registered plugins
|
|
@@ -3782,27 +3795,27 @@ var ToolManager = class {
|
|
|
3782
3795
|
* Check if a tool is public (exposed to MCP clients)
|
|
3783
3796
|
*/
|
|
3784
3797
|
isPublic(name) {
|
|
3785
|
-
const
|
|
3786
|
-
return
|
|
3798
|
+
const config = this.toolConfigs.get(name);
|
|
3799
|
+
return config?.visibility?.public === true;
|
|
3787
3800
|
}
|
|
3788
3801
|
/**
|
|
3789
3802
|
* Check if a tool is hidden from agent context
|
|
3790
3803
|
*/
|
|
3791
3804
|
isHidden(name) {
|
|
3792
|
-
const
|
|
3793
|
-
return
|
|
3805
|
+
const config = this.toolConfigs.get(name);
|
|
3806
|
+
return config?.visibility?.hidden === true;
|
|
3794
3807
|
}
|
|
3795
3808
|
/**
|
|
3796
3809
|
* Get all public tool names (exposed to MCP clients)
|
|
3797
3810
|
*/
|
|
3798
3811
|
getPublicToolNames() {
|
|
3799
|
-
return Array.from(this.toolConfigs.entries()).filter(([_name,
|
|
3812
|
+
return Array.from(this.toolConfigs.entries()).filter(([_name, config]) => config.visibility?.public === true).map(([name]) => this.resolveToolName(name) ?? name);
|
|
3800
3813
|
}
|
|
3801
3814
|
/**
|
|
3802
3815
|
* Get all hidden tool names
|
|
3803
3816
|
*/
|
|
3804
3817
|
getHiddenToolNames() {
|
|
3805
|
-
return Array.from(this.toolConfigs.entries()).filter(([_name,
|
|
3818
|
+
return Array.from(this.toolConfigs.entries()).filter(([_name, config]) => config.visibility?.hidden === true).map(([name]) => this.resolveToolName(name) ?? name);
|
|
3806
3819
|
}
|
|
3807
3820
|
/**
|
|
3808
3821
|
* Get all public tools
|
|
@@ -3854,8 +3867,8 @@ var ToolManager = class {
|
|
|
3854
3867
|
/**
|
|
3855
3868
|
* Configure tool behavior
|
|
3856
3869
|
*/
|
|
3857
|
-
configTool(toolName,
|
|
3858
|
-
this.toolConfigs.set(toolName,
|
|
3870
|
+
configTool(toolName, config) {
|
|
3871
|
+
this.toolConfigs.set(toolName, config);
|
|
3859
3872
|
}
|
|
3860
3873
|
/**
|
|
3861
3874
|
* Get tool configuration
|
|
@@ -3894,8 +3907,8 @@ var ToolManager = class {
|
|
|
3894
3907
|
*/
|
|
3895
3908
|
getHiddenToolSchema(name) {
|
|
3896
3909
|
const tool = this.toolRegistry.get(name);
|
|
3897
|
-
const
|
|
3898
|
-
if (tool &&
|
|
3910
|
+
const config = this.toolConfigs.get(name);
|
|
3911
|
+
if (tool && config?.visibility?.hidden && tool.schema) {
|
|
3899
3912
|
return {
|
|
3900
3913
|
description: tool.description,
|
|
3901
3914
|
schema: tool.schema
|
|
@@ -3978,9 +3991,9 @@ function updateRefPaths(schema, wrapperPath) {
|
|
|
3978
3991
|
}
|
|
3979
3992
|
|
|
3980
3993
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/compose-helpers.js
|
|
3981
|
-
async function processToolsWithPlugins(
|
|
3982
|
-
const toolManager =
|
|
3983
|
-
const pluginManager =
|
|
3994
|
+
async function processToolsWithPlugins(server, _externalTools, mode) {
|
|
3995
|
+
const toolManager = server.toolManager;
|
|
3996
|
+
const pluginManager = server.pluginManager;
|
|
3984
3997
|
for (const [toolId, toolData] of toolManager.getToolEntries()) {
|
|
3985
3998
|
const defaultSchema = {
|
|
3986
3999
|
type: "object",
|
|
@@ -3995,7 +4008,7 @@ async function processToolsWithPlugins(server2, _externalTools, mode) {
|
|
|
3995
4008
|
};
|
|
3996
4009
|
const processedTool = await pluginManager.applyTransformToolHooks(tempTool, {
|
|
3997
4010
|
toolName: toolId,
|
|
3998
|
-
server
|
|
4011
|
+
server,
|
|
3999
4012
|
mode,
|
|
4000
4013
|
originalTool: {
|
|
4001
4014
|
...tempTool
|
|
@@ -4005,9 +4018,9 @@ async function processToolsWithPlugins(server2, _externalTools, mode) {
|
|
|
4005
4018
|
toolManager.registerTool(toolId, processedTool.description || toolData.description, processedTool.inputSchema, processedTool.execute);
|
|
4006
4019
|
}
|
|
4007
4020
|
}
|
|
4008
|
-
function buildDependencyGroups(toolNameToDetailList, hiddenToolNames, publicToolNames,
|
|
4021
|
+
function buildDependencyGroups(toolNameToDetailList, hiddenToolNames, publicToolNames, server) {
|
|
4009
4022
|
const depGroups = {};
|
|
4010
|
-
const toolManager =
|
|
4023
|
+
const toolManager = server.toolManager;
|
|
4011
4024
|
toolNameToDetailList.forEach(([toolName, tool]) => {
|
|
4012
4025
|
const resolvedName = toolManager.resolveToolName(toolName);
|
|
4013
4026
|
if (hiddenToolNames.includes(resolvedName ?? "") || publicToolNames.includes(resolvedName ?? "")) {
|
|
@@ -4223,8 +4236,8 @@ var ComposableMCPServer = class extends Server {
|
|
|
4223
4236
|
/**
|
|
4224
4237
|
* Configure tool behavior
|
|
4225
4238
|
*/
|
|
4226
|
-
configTool(toolName,
|
|
4227
|
-
this.toolManager.configTool(toolName,
|
|
4239
|
+
configTool(toolName, config) {
|
|
4240
|
+
this.toolManager.configTool(toolName, config);
|
|
4228
4241
|
}
|
|
4229
4242
|
/**
|
|
4230
4243
|
* Get tool configuration
|
|
@@ -4464,43 +4477,30 @@ if (isSCF()) {
|
|
|
4464
4477
|
|
|
4465
4478
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/set-up-mcp-compose.js
|
|
4466
4479
|
function parseMcpcConfigs(conf) {
|
|
4467
|
-
|
|
4468
|
-
const newMcpcConfigs = [];
|
|
4469
|
-
for (const mcpcConfig of mcpcConfigs) {
|
|
4470
|
-
if (mcpcConfig?.deps?.mcpServers) {
|
|
4471
|
-
for (const [name, config2] of Object.entries(mcpcConfig.deps.mcpServers)) {
|
|
4472
|
-
if (config2.smitheryConfig) {
|
|
4473
|
-
const streamConfig = connectToSmitheryServer(config2.smitheryConfig);
|
|
4474
|
-
mcpcConfig.deps.mcpServers[name] = streamConfig;
|
|
4475
|
-
}
|
|
4476
|
-
}
|
|
4477
|
-
}
|
|
4478
|
-
newMcpcConfigs.push(mcpcConfig);
|
|
4479
|
-
}
|
|
4480
|
-
return newMcpcConfigs;
|
|
4480
|
+
return conf ?? [];
|
|
4481
4481
|
}
|
|
4482
4482
|
async function mcpc(serverConf, composeConf, setupCallback) {
|
|
4483
|
-
const
|
|
4483
|
+
const server = new ComposableMCPServer(...serverConf);
|
|
4484
4484
|
const parsed = parseMcpcConfigs(composeConf);
|
|
4485
|
-
await
|
|
4485
|
+
await server.initBuiltInPlugins();
|
|
4486
4486
|
for (const mcpcConfig of parsed) {
|
|
4487
4487
|
if (mcpcConfig.plugins) {
|
|
4488
4488
|
for (const plugin of mcpcConfig.plugins) {
|
|
4489
4489
|
if (typeof plugin === "string") {
|
|
4490
|
-
await
|
|
4490
|
+
await server.loadPluginFromPath(plugin);
|
|
4491
4491
|
} else {
|
|
4492
|
-
await
|
|
4492
|
+
await server.addPlugin(plugin);
|
|
4493
4493
|
}
|
|
4494
4494
|
}
|
|
4495
4495
|
}
|
|
4496
4496
|
}
|
|
4497
4497
|
if (setupCallback) {
|
|
4498
|
-
await setupCallback(
|
|
4498
|
+
await setupCallback(server);
|
|
4499
4499
|
}
|
|
4500
4500
|
for (const mcpcConfig of parsed) {
|
|
4501
|
-
await
|
|
4501
|
+
await server.compose(mcpcConfig.name, mcpcConfig.description ?? "", mcpcConfig.deps, mcpcConfig.options);
|
|
4502
4502
|
}
|
|
4503
|
-
return
|
|
4503
|
+
return server;
|
|
4504
4504
|
}
|
|
4505
4505
|
|
|
4506
4506
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/plugins/large-result.js
|
|
@@ -4523,8 +4523,8 @@ function createSearchPlugin(options = {}) {
|
|
|
4523
4523
|
return {
|
|
4524
4524
|
name: "plugin-search",
|
|
4525
4525
|
version: "1.0.0",
|
|
4526
|
-
configureServer: (
|
|
4527
|
-
|
|
4526
|
+
configureServer: (server) => {
|
|
4527
|
+
server.tool("search-tool-result", `Search for text patterns in files and directories. Use this to find specific content, code, or information within files. Provide a simple literal string or a regular expression. If your pattern is a regex, ensure it's valid; otherwise use quotes or escape special characters to treat it as a literal string.
|
|
4528
4528
|
Only search within the allowed directory: ${allowedSearchDir}`, jsonSchema({
|
|
4529
4529
|
type: "object",
|
|
4530
4530
|
properties: {
|
|
@@ -4750,11 +4750,11 @@ function createLargeResultPlugin(options = {}) {
|
|
|
4750
4750
|
name: "plugin-large-result-handler",
|
|
4751
4751
|
version: "1.0.0",
|
|
4752
4752
|
dependencies: [],
|
|
4753
|
-
configureServer: async (
|
|
4754
|
-
if (!configuredServers.has(
|
|
4753
|
+
configureServer: async (server) => {
|
|
4754
|
+
if (!configuredServers.has(server)) {
|
|
4755
4755
|
const searchPlugin = createSearchPlugin(searchConfig);
|
|
4756
|
-
await
|
|
4757
|
-
configuredServers.set(
|
|
4756
|
+
await server.addPlugin(searchPlugin);
|
|
4757
|
+
configuredServers.set(server, true);
|
|
4758
4758
|
}
|
|
4759
4759
|
},
|
|
4760
4760
|
transformTool: (tool, context2) => {
|
|
@@ -4816,8 +4816,8 @@ var defaultLargeResultPlugin = createLargeResultPlugin({
|
|
|
4816
4816
|
|
|
4817
4817
|
// __mcpc__cli_latest/node_modules/@mcpc/cli/src/app.js
|
|
4818
4818
|
import { codeExecutionPlugin } from "@mcpc-tech/plugin-code-execution";
|
|
4819
|
-
var createServer = async (
|
|
4820
|
-
const serverConfig =
|
|
4819
|
+
var createServer = async (config) => {
|
|
4820
|
+
const serverConfig = config || {
|
|
4821
4821
|
name: "mcpc-server",
|
|
4822
4822
|
version: "0.1.0",
|
|
4823
4823
|
agents: [
|
|
@@ -4826,7 +4826,7 @@ var createServer = async (config2) => {
|
|
|
4826
4826
|
description: "",
|
|
4827
4827
|
plugins: [
|
|
4828
4828
|
createLargeResultPlugin({}),
|
|
4829
|
-
codeExecutionPlugin
|
|
4829
|
+
codeExecutionPlugin
|
|
4830
4830
|
],
|
|
4831
4831
|
options: {
|
|
4832
4832
|
mode: "code_execution"
|
|
@@ -4851,24 +4851,28 @@ var createServer = async (config2) => {
|
|
|
4851
4851
|
|
|
4852
4852
|
// __mcpc__cli_latest/node_modules/@mcpc/cli/src/bin.ts
|
|
4853
4853
|
import { createCodeExecutionPlugin } from "@mcpc-tech/plugin-code-execution";
|
|
4854
|
-
|
|
4855
|
-
config
|
|
4856
|
-
|
|
4857
|
-
agent.plugins
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4854
|
+
(async () => {
|
|
4855
|
+
const config = await loadConfig();
|
|
4856
|
+
config?.agents.forEach((agent) => {
|
|
4857
|
+
if (agent.plugins?.length ?? true) {
|
|
4858
|
+
agent.plugins = [];
|
|
4859
|
+
}
|
|
4860
|
+
agent.plugins?.push(
|
|
4861
|
+
createCodeExecutionPlugin({
|
|
4862
|
+
sandbox: {
|
|
4863
|
+
timeout: 3e5
|
|
4864
|
+
}
|
|
4865
|
+
})
|
|
4866
|
+
);
|
|
4867
|
+
});
|
|
4868
|
+
if (config) {
|
|
4869
|
+
console.error(`Loaded configuration with ${config.agents.length} agent(s)`);
|
|
4870
|
+
} else {
|
|
4871
|
+
console.error(
|
|
4872
|
+
"No configuration found, using default example configuration"
|
|
4873
|
+
);
|
|
4874
|
+
}
|
|
4875
|
+
const server = await createServer(config || void 0);
|
|
4876
|
+
const transport = new StdioServerTransport();
|
|
4877
|
+
await server.connect(transport);
|
|
4878
|
+
})();
|