agent-swarm-kit 1.1.6 → 1.1.7

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/build/index.cjs CHANGED
@@ -53,6 +53,7 @@ const connectionServices$1 = {
53
53
  stateConnectionService: Symbol('stateConnectionService'),
54
54
  sharedStateConnectionService: Symbol('sharedStateConnectionService'),
55
55
  policyConnectionService: Symbol('policyConnectionService'),
56
+ mcpConnectionService: Symbol('mcpConnectionService'),
56
57
  };
57
58
  const schemaServices$1 = {
58
59
  completionSchemaService: Symbol('completionSchemaService'),
@@ -65,6 +66,7 @@ const schemaServices$1 = {
65
66
  memorySchemaService: Symbol('memorySchemaService'),
66
67
  policySchemaService: Symbol('policySchemaService'),
67
68
  wikiSchemaService: Symbol('wikiSchemaService'),
69
+ mcpSchemaService: Symbol('mcpSchemaService'),
68
70
  };
69
71
  const metaServices$1 = {
70
72
  agentMetaService: Symbol('agentMetaService'),
@@ -80,6 +82,7 @@ const publicServices$1 = {
80
82
  statePublicService: Symbol('statePublicService'),
81
83
  sharedStatePublicService: Symbol('sharedStatePublicService'),
82
84
  policyPublicService: Symbol('policyPublicService'),
85
+ mcpPublicService: Symbol('mcpPublicService'),
83
86
  };
84
87
  const validationServices$1 = {
85
88
  agentValidationService: Symbol('agentValidationService'),
@@ -92,6 +95,7 @@ const validationServices$1 = {
92
95
  policyValidationService: Symbol('policyValidationService'),
93
96
  navigationValidationService: Symbol('navigationValidationService'),
94
97
  wikiValidationService: Symbol('wikiValidationService'),
98
+ mcpValidationService: Symbol('mcpValidationService'),
95
99
  };
96
100
  const TYPES = {
97
101
  ...baseServices$1,
@@ -2611,6 +2615,7 @@ class LoggerUtils {
2611
2615
  stateName: "",
2612
2616
  storageName: "",
2613
2617
  swarmName: "",
2618
+ mcpName: "",
2614
2619
  });
2615
2620
  });
2616
2621
  /**
@@ -2639,6 +2644,7 @@ class LoggerUtils {
2639
2644
  stateName: "",
2640
2645
  storageName: "",
2641
2646
  swarmName: "",
2647
+ mcpName: "",
2642
2648
  });
2643
2649
  });
2644
2650
  /**
@@ -2667,6 +2673,7 @@ class LoggerUtils {
2667
2673
  stateName: "",
2668
2674
  storageName: "",
2669
2675
  swarmName: "",
2676
+ mcpName: "",
2670
2677
  });
2671
2678
  });
2672
2679
  /**
@@ -3434,6 +3441,16 @@ class AgentSchemaService {
3434
3441
  if (agentSchema.tools?.some((value) => typeof value !== "string")) {
3435
3442
  throw new Error(`agent-swarm agent schema validation failed: invalid tools for agentName=${agentSchema.agentName} tools=[${agentSchema.tools}]`);
3436
3443
  }
3444
+ if (agentSchema.mcp && !Array.isArray(agentSchema.mcp)) {
3445
+ throw new Error(`agent-swarm agent schema validation failed: invalid mcp for agentName=${agentSchema.agentName} mcp=${agentSchema.mcp}`);
3446
+ }
3447
+ if (agentSchema.mcp &&
3448
+ agentSchema.mcp.length !== new Set(agentSchema.mcp).size) {
3449
+ throw new Error(`agent-swarm agent schema validation failed: found duplicate mcp for agentName=${agentSchema.agentName} mcp=[${agentSchema.mcp}]`);
3450
+ }
3451
+ if (agentSchema.mcp?.some((value) => typeof value !== "string")) {
3452
+ throw new Error(`agent-swarm agent schema validation failed: invalid mcp for agentName=${agentSchema.agentName} mcp=[${agentSchema.mcp}]`);
3453
+ }
3437
3454
  };
3438
3455
  /**
3439
3456
  * Registers a new agent schema in the registry after validation.
@@ -3579,6 +3596,51 @@ const createToolCall = async (idx, tool, toolCalls, targetFn, self) => {
3579
3596
  self._toolErrorSubject.next(TOOL_ERROR_SYMBOL);
3580
3597
  }
3581
3598
  };
3599
+ /**
3600
+ * Maps an MCP (Model-Context-Protocol) tool definition to an `IAgentTool` object.
3601
+ * This function transforms the MCP tool's schema and properties into a format compatible with the agent's tool system.
3602
+ * It also defines the tool's behavior, including its call method and parameter validation.
3603
+ *
3604
+ * @param {Object} tool - The MCP tool definition containing its name, description, and input schema.
3605
+ * @param {string} tool.name - The name of the MCP tool.
3606
+ * @param {string} [tool.description=tool.name] - A description of the MCP tool. Defaults to the tool's name if not provided.
3607
+ * @param {Object} [tool.inputSchema] - The input schema for the MCP tool, defining its parameters and validation rules.
3608
+ * @param {Object} [tool.inputSchema.properties] - The properties of the input schema, where each key represents a parameter.
3609
+ * @param {string[]} [tool.inputSchema.required] - An array of required parameter names for the tool.
3610
+ * @param {ClientAgent} self - The `ClientAgent` instance, providing context such as the agent's name, client ID, and logger.
3611
+ *
3612
+ * @returns {IAgentTool} An object representing the mapped tool, including its name, type, function definition, and call behavior.
3613
+ */
3614
+ const mapMcpToolCall = ({ name, description = name, inputSchema }, self) => {
3615
+ const mcpProperties = inputSchema
3616
+ ? inputSchema.properties ?? {}
3617
+ : {};
3618
+ return {
3619
+ toolName: `mcp_${name}`,
3620
+ type: "function",
3621
+ function: {
3622
+ name,
3623
+ description,
3624
+ parameters: {
3625
+ type: "object",
3626
+ properties: Object.entries(mcpProperties).reduce((acm, [key, { type, description = type, enum: e }]) => ({
3627
+ ...acm,
3628
+ [key]: {
3629
+ type,
3630
+ description,
3631
+ enum: e,
3632
+ },
3633
+ }), {}),
3634
+ required: inputSchema.required,
3635
+ },
3636
+ },
3637
+ call: async (dto) => {
3638
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
3639
+ self.params.logger.debug(`ClientAgent agentName=${self.params.agentName} clientId=${self.params.clientId} calling MCP tool toolName=${name}`);
3640
+ await self.params.mcp.callTool(name, dto);
3641
+ },
3642
+ };
3643
+ };
3582
3644
  /**
3583
3645
  * Runs a stateless completion for the incoming message, returning the transformed result.
3584
3646
  * Returns an empty string if tool calls are present or validation fails, avoiding further processing.
@@ -3604,7 +3666,7 @@ const RUN_FN = async (incoming, self) => {
3604
3666
  agentName: self.params.agentName,
3605
3667
  messages,
3606
3668
  mode: "user",
3607
- tools: self.params.tools?.map((t) => lodashEs.omit(t, "toolName", "docNote", "call", "validate", "callbacks")),
3669
+ tools: [],
3608
3670
  };
3609
3671
  const rawMessage = await self.params.completion.getCompletion(args);
3610
3672
  self.params.completion.callbacks?.onComplete &&
@@ -3660,7 +3722,8 @@ const EXECUTE_FN = async (incoming, mode, self) => {
3660
3722
  agentName: self.params.agentName,
3661
3723
  content: incoming.trim(),
3662
3724
  });
3663
- const rawMessage = await self.getCompletion(mode);
3725
+ const toolList = await self._resolveTools();
3726
+ const rawMessage = await self.getCompletion(mode, toolList);
3664
3727
  const message = await self.params.map(rawMessage, self.params.clientId, self.params.agentName);
3665
3728
  if (message.tool_calls?.length) {
3666
3729
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
@@ -3679,10 +3742,10 @@ const EXECUTE_FN = async (incoming, mode, self) => {
3679
3742
  const [runAwaiter, { resolve: run }] = functoolsKit.createAwaiter();
3680
3743
  for (let idx = 0; idx !== toolCalls.length; idx++) {
3681
3744
  const tool = toolCalls[idx];
3682
- const targetFn = self.params.tools?.find((t) => t.function.name === tool.function.name);
3745
+ const targetFn = toolList.find((t) => t.function.name === tool.function.name);
3683
3746
  if (!targetFn) {
3684
3747
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
3685
- self.params.logger.debug(`ClientAgent agentName=${self.params.agentName} clientId=${self.params.clientId} functionName=${tool.function.name} tool function not found`, self.params.tools);
3748
+ self.params.logger.debug(`ClientAgent agentName=${self.params.agentName} clientId=${self.params.clientId} functionName=${tool.function.name} tool function not found`, toolList);
3686
3749
  const result = await self._resurrectModel(mode, `No target function for ${tool.function.name}`);
3687
3750
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
3688
3751
  self.params.logger.debug(`ClientAgent agentName=${self.params.agentName} clientId=${self.params.clientId} execute end result=${result}`);
@@ -3887,6 +3950,33 @@ class ClientAgent {
3887
3950
  });
3888
3951
  this.params.onInit && this.params.onInit(params.clientId, params.agentName);
3889
3952
  }
3953
+ async _resolveTools() {
3954
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
3955
+ this.params.logger.debug(`ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} _resolveTools`);
3956
+ const seen = new Set();
3957
+ const agentToolList = this.params.tools
3958
+ ? this.params.tools
3959
+ : [];
3960
+ const mcpToolList = await this.params.mcp.listTools(this.params.clientId);
3961
+ if (mcpToolList.length) {
3962
+ return agentToolList
3963
+ .concat(mcpToolList.map((tool) => mapMcpToolCall(tool, this)))
3964
+ .filter(({ function: { name } }) => {
3965
+ if (!seen.has(name)) {
3966
+ seen.add(name);
3967
+ return true;
3968
+ }
3969
+ return false;
3970
+ });
3971
+ }
3972
+ return agentToolList.filter(({ function: { name } }) => {
3973
+ if (!seen.has(name)) {
3974
+ seen.add(name);
3975
+ return true;
3976
+ }
3977
+ return false;
3978
+ });
3979
+ }
3890
3980
  /**
3891
3981
  * Resolves the system prompt by combining static and dynamic system messages.
3892
3982
  * Static messages are directly included from the `systemStatic` parameter, while dynamic messages
@@ -4013,7 +4103,7 @@ class ClientAgent {
4013
4103
  await this._resqueSubject.next(MODEL_RESQUE_SYMBOL);
4014
4104
  return placeholder;
4015
4105
  }
4016
- const rawMessage = await this.getCompletion(mode);
4106
+ const rawMessage = await this.getCompletion(mode, []);
4017
4107
  if (rawMessage.tool_calls?.length) {
4018
4108
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
4019
4109
  this.params.logger.debug(`ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} _resurrectModel should not emit tool_calls`);
@@ -4066,7 +4156,7 @@ class ClientAgent {
4066
4156
  * @param {ExecutionMode} mode - The execution mode (e.g., "user" or "tool"), determining context.
4067
4157
  * @returns {Promise<IModelMessage>} The completion message from the model, with content defaulted to an empty string if null.
4068
4158
  */
4069
- async getCompletion(mode) {
4159
+ async getCompletion(mode, tools) {
4070
4160
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
4071
4161
  this.params.logger.debug(`ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} getCompletion`);
4072
4162
  const messages = await this.params.history.toArrayForAgent(this.params.prompt ?? "", await this._resolveSystemPrompt());
@@ -4075,7 +4165,7 @@ class ClientAgent {
4075
4165
  agentName: this.params.agentName,
4076
4166
  messages,
4077
4167
  mode,
4078
- tools: this.params.tools?.map((t) => lodashEs.omit(t, "toolName", "docNote", "call", "validate", "callbacks")),
4168
+ tools: tools.map((t) => lodashEs.omit(t, "toolName", "docNote", "call", "validate", "callbacks")),
4079
4169
  };
4080
4170
  const output = await this.params.completion.getCompletion(args);
4081
4171
  if (GLOBAL_CONFIG.CC_RESQUE_STRATEGY === "flush") {
@@ -4119,7 +4209,7 @@ class ClientAgent {
4119
4209
  agentName: this.params.agentName,
4120
4210
  messages,
4121
4211
  mode,
4122
- tools: this.params.tools?.map((t) => lodashEs.omit(t, "toolName", "docNote", "call", "validate", "callbacks")),
4212
+ tools: tools.map((t) => lodashEs.omit(t, "toolName", "docNote", "call", "validate", "callbacks")),
4123
4213
  };
4124
4214
  const output = await this.params.completion.getCompletion(args);
4125
4215
  this.params.completion.callbacks?.onComplete &&
@@ -4557,6 +4647,84 @@ class ClientOperator {
4557
4647
  }
4558
4648
  }
4559
4649
 
4650
+ class NoopMCP {
4651
+ constructor(agentName) {
4652
+ this.agentName = agentName;
4653
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
4654
+ swarm$1.loggerService.debug(`NoopMCP CTOR agentName=${agentName}`);
4655
+ }
4656
+ async listTools(clientId) {
4657
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
4658
+ swarm$1.loggerService.debug(`NoopMCP listTools agentName=${this.agentName}`, {
4659
+ clientId,
4660
+ });
4661
+ return [];
4662
+ }
4663
+ hasTool(toolName, clientId) {
4664
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
4665
+ swarm$1.loggerService.debug(`NoopMCP hasTool agentName=${this.agentName}`, {
4666
+ toolName,
4667
+ clientId,
4668
+ });
4669
+ return Promise.resolve(false);
4670
+ }
4671
+ async callTool(toolName, dto) {
4672
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
4673
+ swarm$1.loggerService.debug(`NoopMCP callTool agentName=${this.agentName}`, {
4674
+ toolName,
4675
+ dto,
4676
+ });
4677
+ throw new Error(`NoopPolicy callTool should not be called agentName=${this.agentName} toolName=${toolName}`);
4678
+ }
4679
+ }
4680
+ class MergeMCP {
4681
+ constructor(mcpList, agentName) {
4682
+ this.mcpList = mcpList;
4683
+ this.agentName = agentName;
4684
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
4685
+ swarm$1.loggerService.debug(`MergeMCP CTOR agentName=${agentName}`, {
4686
+ mcpList,
4687
+ });
4688
+ }
4689
+ async listTools(clientId) {
4690
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
4691
+ swarm$1.loggerService.debug(`MergeMCP listTools agentName=${this.agentName}`, {
4692
+ clientId,
4693
+ });
4694
+ const toolList = [];
4695
+ for (const mcp of this.mcpList) {
4696
+ toolList.push(await mcp.listTools(clientId));
4697
+ }
4698
+ return toolList.flatMap((tools) => tools);
4699
+ }
4700
+ async hasTool(toolName, clientId) {
4701
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
4702
+ swarm$1.loggerService.debug(`MergeMCP hasTool agentName=${this.agentName}`, {
4703
+ toolName,
4704
+ clientId,
4705
+ });
4706
+ for (const mcp of this.mcpList) {
4707
+ if (await mcp.hasTool(toolName, clientId)) {
4708
+ return true;
4709
+ }
4710
+ }
4711
+ return false;
4712
+ }
4713
+ async callTool(toolName, dto) {
4714
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
4715
+ swarm$1.loggerService.debug(`MergeMCP callTool agentName=${this.agentName}`, {
4716
+ toolName,
4717
+ dto,
4718
+ });
4719
+ for (const mcp of this.mcpList) {
4720
+ if (await mcp.hasTool(toolName, dto.clientId)) {
4721
+ return await mcp.callTool(toolName, dto);
4722
+ }
4723
+ }
4724
+ throw new Error(`MergeMCP callTool agentName=${this.agentName} tool not found toolName=${toolName}`);
4725
+ }
4726
+ }
4727
+
4560
4728
  /**
4561
4729
  * Service class for managing agent connections and operations in the swarm system.
4562
4730
  * Implements IAgent to provide an interface for agent instantiation, execution, message handling, and lifecycle management.
@@ -4637,6 +4805,13 @@ class AgentConnectionService {
4637
4805
  * @private
4638
4806
  */
4639
4807
  this.completionSchemaService = inject(TYPES.completionSchemaService);
4808
+ /**
4809
+ * MCP connection service instance, injected via DI, for retrieving external tools
4810
+ * Provides mcp integration logic to ClientAgent in getAgent, supporting agent tool execution.
4811
+ * @type {CompletionSchemaService}
4812
+ * @private
4813
+ */
4814
+ this.mcpConnectionService = inject(TYPES.mcpConnectionService);
4640
4815
  /**
4641
4816
  * Retrieves or creates a memoized ClientAgent instance for a given client and agent.
4642
4817
  * Uses functools-kit’s memoize to cache instances by a composite key (clientId-agentName), ensuring efficient reuse across calls.
@@ -4647,7 +4822,7 @@ class AgentConnectionService {
4647
4822
  * @returns {ClientAgent} The memoized ClientAgent instance configured for the client and agent.
4648
4823
  */
4649
4824
  this.getAgent = functoolsKit.memoize(([clientId, agentName]) => `${clientId}-${agentName}`, (clientId, agentName) => {
4650
- const { prompt, system, operator, systemStatic = system, systemDynamic, tools, transform = GLOBAL_CONFIG.CC_AGENT_OUTPUT_TRANSFORM, map = GLOBAL_CONFIG.CC_AGENT_OUTPUT_MAP, maxToolCalls = GLOBAL_CONFIG.CC_MAX_TOOL_CALLS, mapToolCalls = GLOBAL_CONFIG.CC_AGENT_MAP_TOOLS, callbacks, storages, states, connectOperator = GLOBAL_CONFIG.CC_DEFAULT_CONNECT_OPERATOR, completion: completionName, validate = validateDefault, } = this.agentSchemaService.get(agentName);
4825
+ const { prompt, system, operator, systemStatic = system, systemDynamic, tools, transform = GLOBAL_CONFIG.CC_AGENT_OUTPUT_TRANSFORM, map = GLOBAL_CONFIG.CC_AGENT_OUTPUT_MAP, maxToolCalls = GLOBAL_CONFIG.CC_MAX_TOOL_CALLS, mapToolCalls = GLOBAL_CONFIG.CC_AGENT_MAP_TOOLS, callbacks, storages, states, mcp, connectOperator = GLOBAL_CONFIG.CC_DEFAULT_CONNECT_OPERATOR, completion: completionName, validate = validateDefault, } = this.agentSchemaService.get(agentName);
4651
4826
  const history = this.historyConnectionService.getHistory(clientId, agentName);
4652
4827
  this.sessionValidationService.addAgentUsage(clientId, agentName);
4653
4828
  storages?.forEach((storageName) => this.storageConnectionService
@@ -4675,6 +4850,9 @@ class AgentConnectionService {
4675
4850
  mapToolCalls,
4676
4851
  logger: this.loggerService,
4677
4852
  bus: this.busService,
4853
+ mcp: mcp
4854
+ ? new MergeMCP(mcp.map(this.mcpConnectionService.getMCP), agentName)
4855
+ : new NoopMCP(agentName),
4678
4856
  history,
4679
4857
  prompt,
4680
4858
  systemStatic,
@@ -4840,7 +5018,7 @@ class AgentConnectionService {
4840
5018
  }
4841
5019
 
4842
5020
  /** @private Constant defining the method name for logging purposes */
4843
- const METHOD_NAME$1b = "function.common.getPayload";
5021
+ const METHOD_NAME$1d = "function.common.getPayload";
4844
5022
  /**
4845
5023
  * Retrieves the payload from the current PayloadContextService context.
4846
5024
  * Returns null if no context is available. Logs the operation if logging is enabled.
@@ -4851,7 +5029,7 @@ const METHOD_NAME$1b = "function.common.getPayload";
4851
5029
  * console.log(payload); // { id: number } or null
4852
5030
  */
4853
5031
  const getPayload = () => {
4854
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$1b);
5032
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$1d);
4855
5033
  if (PayloadContextService.hasContext()) {
4856
5034
  const { payload } = swarm$1.payloadContextService.context;
4857
5035
  return payload;
@@ -7129,6 +7307,7 @@ class AgentPublicService {
7129
7307
  swarmName: "",
7130
7308
  storageName: "",
7131
7309
  stateName: "",
7310
+ mcpName: "",
7132
7311
  });
7133
7312
  };
7134
7313
  /**
@@ -7161,6 +7340,7 @@ class AgentPublicService {
7161
7340
  swarmName: "",
7162
7341
  storageName: "",
7163
7342
  stateName: "",
7343
+ mcpName: "",
7164
7344
  });
7165
7345
  };
7166
7346
  /**
@@ -7191,6 +7371,7 @@ class AgentPublicService {
7191
7371
  swarmName: "",
7192
7372
  storageName: "",
7193
7373
  stateName: "",
7374
+ mcpName: "",
7194
7375
  });
7195
7376
  };
7196
7377
  /**
@@ -7219,6 +7400,7 @@ class AgentPublicService {
7219
7400
  swarmName: "",
7220
7401
  storageName: "",
7221
7402
  stateName: "",
7403
+ mcpName: "",
7222
7404
  });
7223
7405
  };
7224
7406
  /**
@@ -7251,6 +7433,7 @@ class AgentPublicService {
7251
7433
  swarmName: "",
7252
7434
  storageName: "",
7253
7435
  stateName: "",
7436
+ mcpName: "",
7254
7437
  });
7255
7438
  };
7256
7439
  /**
@@ -7281,6 +7464,7 @@ class AgentPublicService {
7281
7464
  swarmName: "",
7282
7465
  storageName: "",
7283
7466
  stateName: "",
7467
+ mcpName: "",
7284
7468
  });
7285
7469
  };
7286
7470
  /**
@@ -7311,6 +7495,7 @@ class AgentPublicService {
7311
7495
  swarmName: "",
7312
7496
  storageName: "",
7313
7497
  stateName: "",
7498
+ mcpName: "",
7314
7499
  });
7315
7500
  };
7316
7501
  /**
@@ -7342,6 +7527,7 @@ class AgentPublicService {
7342
7527
  swarmName: "",
7343
7528
  storageName: "",
7344
7529
  stateName: "",
7530
+ mcpName: "",
7345
7531
  });
7346
7532
  };
7347
7533
  /**
@@ -7370,6 +7556,7 @@ class AgentPublicService {
7370
7556
  swarmName: "",
7371
7557
  storageName: "",
7372
7558
  stateName: "",
7559
+ mcpName: "",
7373
7560
  });
7374
7561
  };
7375
7562
  /**
@@ -7398,6 +7585,7 @@ class AgentPublicService {
7398
7585
  swarmName: "",
7399
7586
  storageName: "",
7400
7587
  stateName: "",
7588
+ mcpName: "",
7401
7589
  });
7402
7590
  };
7403
7591
  /**
@@ -7426,6 +7614,7 @@ class AgentPublicService {
7426
7614
  swarmName: "",
7427
7615
  storageName: "",
7428
7616
  stateName: "",
7617
+ mcpName: "",
7429
7618
  });
7430
7619
  };
7431
7620
  /**
@@ -7454,6 +7643,7 @@ class AgentPublicService {
7454
7643
  swarmName: "",
7455
7644
  storageName: "",
7456
7645
  stateName: "",
7646
+ mcpName: "",
7457
7647
  });
7458
7648
  };
7459
7649
  }
@@ -7509,6 +7699,7 @@ class HistoryPublicService {
7509
7699
  swarmName: "",
7510
7700
  storageName: "",
7511
7701
  stateName: "",
7702
+ mcpName: "",
7512
7703
  });
7513
7704
  };
7514
7705
  /**
@@ -7537,6 +7728,7 @@ class HistoryPublicService {
7537
7728
  swarmName: "",
7538
7729
  storageName: "",
7539
7730
  stateName: "",
7731
+ mcpName: "",
7540
7732
  });
7541
7733
  };
7542
7734
  /**
@@ -7566,6 +7758,7 @@ class HistoryPublicService {
7566
7758
  swarmName: "",
7567
7759
  storageName: "",
7568
7760
  stateName: "",
7761
+ mcpName: "",
7569
7762
  });
7570
7763
  };
7571
7764
  /**
@@ -7594,6 +7787,7 @@ class HistoryPublicService {
7594
7787
  swarmName: "",
7595
7788
  storageName: "",
7596
7789
  stateName: "",
7790
+ mcpName: "",
7597
7791
  });
7598
7792
  };
7599
7793
  /**
@@ -7621,6 +7815,7 @@ class HistoryPublicService {
7621
7815
  swarmName: "",
7622
7816
  storageName: "",
7623
7817
  stateName: "",
7818
+ mcpName: "",
7624
7819
  });
7625
7820
  };
7626
7821
  }
@@ -7696,6 +7891,7 @@ class SessionPublicService {
7696
7891
  agentName: "",
7697
7892
  storageName: "",
7698
7893
  stateName: "",
7894
+ mcpName: "",
7699
7895
  });
7700
7896
  };
7701
7897
  /**
@@ -7726,6 +7922,7 @@ class SessionPublicService {
7726
7922
  agentName: "",
7727
7923
  storageName: "",
7728
7924
  stateName: "",
7925
+ mcpName: "",
7729
7926
  });
7730
7927
  };
7731
7928
  /**
@@ -7757,6 +7954,7 @@ class SessionPublicService {
7757
7954
  agentName: "",
7758
7955
  storageName: "",
7759
7956
  stateName: "",
7957
+ mcpName: "",
7760
7958
  });
7761
7959
  };
7762
7960
  /**
@@ -7786,6 +7984,7 @@ class SessionPublicService {
7786
7984
  agentName: "",
7787
7985
  storageName: "",
7788
7986
  stateName: "",
7987
+ mcpName: "",
7789
7988
  });
7790
7989
  };
7791
7990
  /**
@@ -7868,6 +8067,7 @@ class SessionPublicService {
7868
8067
  agentName: "",
7869
8068
  storageName: "",
7870
8069
  stateName: "",
8070
+ mcpName: "",
7871
8071
  });
7872
8072
  };
7873
8073
  /**
@@ -7898,6 +8098,7 @@ class SessionPublicService {
7898
8098
  agentName: "",
7899
8099
  storageName: "",
7900
8100
  stateName: "",
8101
+ mcpName: "",
7901
8102
  });
7902
8103
  };
7903
8104
  /**
@@ -7928,6 +8129,7 @@ class SessionPublicService {
7928
8129
  agentName: "",
7929
8130
  storageName: "",
7930
8131
  stateName: "",
8132
+ mcpName: "",
7931
8133
  });
7932
8134
  };
7933
8135
  /**
@@ -7959,6 +8161,7 @@ class SessionPublicService {
7959
8161
  agentName: "",
7960
8162
  storageName: "",
7961
8163
  stateName: "",
8164
+ mcpName: "",
7962
8165
  });
7963
8166
  };
7964
8167
  /**
@@ -7986,6 +8189,7 @@ class SessionPublicService {
7986
8189
  agentName: "",
7987
8190
  storageName: "",
7988
8191
  stateName: "",
8192
+ mcpName: "",
7989
8193
  });
7990
8194
  };
7991
8195
  /**
@@ -8013,6 +8217,7 @@ class SessionPublicService {
8013
8217
  agentName: "",
8014
8218
  storageName: "",
8015
8219
  stateName: "",
8220
+ mcpName: "",
8016
8221
  });
8017
8222
  };
8018
8223
  /**
@@ -8041,6 +8246,7 @@ class SessionPublicService {
8041
8246
  agentName: "",
8042
8247
  storageName: "",
8043
8248
  stateName: "",
8249
+ mcpName: "",
8044
8250
  });
8045
8251
  };
8046
8252
  }
@@ -8096,6 +8302,7 @@ class SwarmPublicService {
8096
8302
  agentName: "",
8097
8303
  storageName: "",
8098
8304
  stateName: "",
8305
+ mcpName: "",
8099
8306
  });
8100
8307
  };
8101
8308
  /**
@@ -8123,6 +8330,7 @@ class SwarmPublicService {
8123
8330
  agentName: "",
8124
8331
  storageName: "",
8125
8332
  stateName: "",
8333
+ mcpName: "",
8126
8334
  });
8127
8335
  };
8128
8336
  /**
@@ -8150,6 +8358,7 @@ class SwarmPublicService {
8150
8358
  agentName: "",
8151
8359
  storageName: "",
8152
8360
  stateName: "",
8361
+ mcpName: "",
8153
8362
  });
8154
8363
  };
8155
8364
  /**
@@ -8178,6 +8387,7 @@ class SwarmPublicService {
8178
8387
  agentName: "",
8179
8388
  storageName: "",
8180
8389
  stateName: "",
8390
+ mcpName: "",
8181
8391
  });
8182
8392
  };
8183
8393
  /**
@@ -8206,6 +8416,7 @@ class SwarmPublicService {
8206
8416
  agentName: "",
8207
8417
  storageName: "",
8208
8418
  stateName: "",
8419
+ mcpName: "",
8209
8420
  });
8210
8421
  };
8211
8422
  /**
@@ -8233,6 +8444,7 @@ class SwarmPublicService {
8233
8444
  agentName: "",
8234
8445
  storageName: "",
8235
8446
  stateName: "",
8447
+ mcpName: "",
8236
8448
  });
8237
8449
  };
8238
8450
  /**
@@ -8265,6 +8477,7 @@ class SwarmPublicService {
8265
8477
  agentName: "",
8266
8478
  storageName: "",
8267
8479
  stateName: "",
8480
+ mcpName: "",
8268
8481
  });
8269
8482
  };
8270
8483
  /**
@@ -8295,6 +8508,7 @@ class SwarmPublicService {
8295
8508
  agentName: "",
8296
8509
  storageName: "",
8297
8510
  stateName: "",
8511
+ mcpName: "",
8298
8512
  });
8299
8513
  };
8300
8514
  /**
@@ -8323,6 +8537,7 @@ class SwarmPublicService {
8323
8537
  agentName: "",
8324
8538
  storageName: "",
8325
8539
  stateName: "",
8540
+ mcpName: "",
8326
8541
  });
8327
8542
  };
8328
8543
  }
@@ -8362,6 +8577,14 @@ class AgentValidationService {
8362
8577
  * @readonly
8363
8578
  */
8364
8579
  this.wikiValidationService = inject(TYPES.wikiValidationService);
8580
+ /**
8581
+ * MCP validation service instance for validating mcp associated with agents.
8582
+ * Injected via DI, used in validate method to check agent mcp list.
8583
+ * @type {WikiValidationService}
8584
+ * @private
8585
+ * @readonly
8586
+ */
8587
+ this.mcpValidationService = inject(TYPES.mcpValidationService);
8365
8588
  /**
8366
8589
  * Completion validation service instance for validating completion configurations of agents.
8367
8590
  * Injected via DI, used in validate method to check agent completion.
@@ -8589,6 +8812,12 @@ class AgentValidationService {
8589
8812
  }
8590
8813
  this.wikiValidationService.validate(wikiName, source);
8591
8814
  });
8815
+ agent.mcp?.forEach((mcpName) => {
8816
+ if (typeof mcpName !== "string") {
8817
+ throw new Error(`agent-swarm agent ${agentName} mcp list is invalid (mcpName=${String(mcpName)}) source=${source}`);
8818
+ }
8819
+ this.mcpValidationService.validate(mcpName, source);
8820
+ });
8592
8821
  });
8593
8822
  }
8594
8823
  }
@@ -10195,6 +10424,7 @@ class StoragePublicService {
10195
10424
  agentName: "",
10196
10425
  swarmName: "",
10197
10426
  stateName: "",
10427
+ mcpName: "",
10198
10428
  });
10199
10429
  };
10200
10430
  /**
@@ -10224,6 +10454,7 @@ class StoragePublicService {
10224
10454
  agentName: "",
10225
10455
  swarmName: "",
10226
10456
  stateName: "",
10457
+ mcpName: "",
10227
10458
  });
10228
10459
  };
10229
10460
  /**
@@ -10253,6 +10484,7 @@ class StoragePublicService {
10253
10484
  agentName: "",
10254
10485
  swarmName: "",
10255
10486
  stateName: "",
10487
+ mcpName: "",
10256
10488
  });
10257
10489
  };
10258
10490
  /**
@@ -10283,6 +10515,7 @@ class StoragePublicService {
10283
10515
  agentName: "",
10284
10516
  swarmName: "",
10285
10517
  stateName: "",
10518
+ mcpName: "",
10286
10519
  });
10287
10520
  };
10288
10521
  /**
@@ -10312,6 +10545,7 @@ class StoragePublicService {
10312
10545
  agentName: "",
10313
10546
  swarmName: "",
10314
10547
  stateName: "",
10548
+ mcpName: "",
10315
10549
  });
10316
10550
  };
10317
10551
  /**
@@ -10340,6 +10574,7 @@ class StoragePublicService {
10340
10574
  agentName: "",
10341
10575
  swarmName: "",
10342
10576
  stateName: "",
10577
+ mcpName: "",
10343
10578
  });
10344
10579
  };
10345
10580
  /**
@@ -10367,6 +10602,7 @@ class StoragePublicService {
10367
10602
  agentName: "",
10368
10603
  swarmName: "",
10369
10604
  stateName: "",
10605
+ mcpName: "",
10370
10606
  });
10371
10607
  };
10372
10608
  }
@@ -11008,6 +11244,7 @@ class StatePublicService {
11008
11244
  agentName: "",
11009
11245
  swarmName: "",
11010
11246
  storageName: "",
11247
+ mcpName: "",
11011
11248
  });
11012
11249
  };
11013
11250
  /**
@@ -11036,6 +11273,7 @@ class StatePublicService {
11036
11273
  agentName: "",
11037
11274
  swarmName: "",
11038
11275
  storageName: "",
11276
+ mcpName: "",
11039
11277
  });
11040
11278
  };
11041
11279
  /**
@@ -11063,6 +11301,7 @@ class StatePublicService {
11063
11301
  agentName: "",
11064
11302
  swarmName: "",
11065
11303
  storageName: "",
11304
+ mcpName: "",
11066
11305
  });
11067
11306
  };
11068
11307
  /**
@@ -11091,6 +11330,7 @@ class StatePublicService {
11091
11330
  agentName: "",
11092
11331
  swarmName: "",
11093
11332
  storageName: "",
11333
+ mcpName: "",
11094
11334
  });
11095
11335
  };
11096
11336
  }
@@ -11815,7 +12055,7 @@ class DocService {
11815
12055
  result.push("```");
11816
12056
  result.push("");
11817
12057
  }
11818
- if (agentSchema.system) {
12058
+ if (agentSchema.systemStatic) {
11819
12059
  result.push(`## System prompt`);
11820
12060
  result.push("");
11821
12061
  for (let i = 0; i !== agentSchema.system.length; i++) {
@@ -11826,6 +12066,10 @@ class DocService {
11826
12066
  result.push("");
11827
12067
  }
11828
12068
  }
12069
+ if (agentSchema.systemDynamic) {
12070
+ result.push("***Dynamic system prompt found***");
12071
+ result.push("");
12072
+ }
11829
12073
  if (agentSchema.dependsOn) {
11830
12074
  result.push(`## Depends on`);
11831
12075
  result.push("");
@@ -12433,6 +12677,7 @@ class SharedStatePublicService {
12433
12677
  agentName: "",
12434
12678
  swarmName: "",
12435
12679
  storageName: "",
12680
+ mcpName: "",
12436
12681
  });
12437
12682
  };
12438
12683
  /**
@@ -12459,6 +12704,7 @@ class SharedStatePublicService {
12459
12704
  agentName: "",
12460
12705
  swarmName: "",
12461
12706
  storageName: "",
12707
+ mcpName: "",
12462
12708
  });
12463
12709
  };
12464
12710
  /**
@@ -12484,6 +12730,7 @@ class SharedStatePublicService {
12484
12730
  agentName: "",
12485
12731
  swarmName: "",
12486
12732
  storageName: "",
12733
+ mcpName: "",
12487
12734
  });
12488
12735
  };
12489
12736
  }
@@ -12541,6 +12788,7 @@ class SharedStoragePublicService {
12541
12788
  agentName: "",
12542
12789
  swarmName: "",
12543
12790
  stateName: "",
12791
+ mcpName: "",
12544
12792
  });
12545
12793
  };
12546
12794
  /**
@@ -12568,6 +12816,7 @@ class SharedStoragePublicService {
12568
12816
  agentName: "",
12569
12817
  swarmName: "",
12570
12818
  stateName: "",
12819
+ mcpName: "",
12571
12820
  });
12572
12821
  };
12573
12822
  /**
@@ -12595,6 +12844,7 @@ class SharedStoragePublicService {
12595
12844
  agentName: "",
12596
12845
  swarmName: "",
12597
12846
  stateName: "",
12847
+ mcpName: "",
12598
12848
  });
12599
12849
  };
12600
12850
  /**
@@ -12623,6 +12873,7 @@ class SharedStoragePublicService {
12623
12873
  agentName: "",
12624
12874
  swarmName: "",
12625
12875
  stateName: "",
12876
+ mcpName: "",
12626
12877
  });
12627
12878
  };
12628
12879
  /**
@@ -12650,6 +12901,7 @@ class SharedStoragePublicService {
12650
12901
  agentName: "",
12651
12902
  swarmName: "",
12652
12903
  stateName: "",
12904
+ mcpName: "",
12653
12905
  });
12654
12906
  };
12655
12907
  /**
@@ -12676,6 +12928,7 @@ class SharedStoragePublicService {
12676
12928
  agentName: "",
12677
12929
  swarmName: "",
12678
12930
  stateName: "",
12931
+ mcpName: "",
12679
12932
  });
12680
12933
  };
12681
12934
  }
@@ -13518,6 +13771,7 @@ class PolicyPublicService {
13518
13771
  policyName,
13519
13772
  storageName: "",
13520
13773
  stateName: "",
13774
+ mcpName: "",
13521
13775
  });
13522
13776
  };
13523
13777
  /**
@@ -13548,6 +13802,7 @@ class PolicyPublicService {
13548
13802
  policyName,
13549
13803
  storageName: "",
13550
13804
  stateName: "",
13805
+ mcpName: "",
13551
13806
  });
13552
13807
  };
13553
13808
  /**
@@ -13580,6 +13835,7 @@ class PolicyPublicService {
13580
13835
  policyName,
13581
13836
  storageName: "",
13582
13837
  stateName: "",
13838
+ mcpName: "",
13583
13839
  });
13584
13840
  };
13585
13841
  /**
@@ -13612,6 +13868,7 @@ class PolicyPublicService {
13612
13868
  policyName,
13613
13869
  storageName: "",
13614
13870
  stateName: "",
13871
+ mcpName: "",
13615
13872
  });
13616
13873
  };
13617
13874
  /**
@@ -13642,6 +13899,7 @@ class PolicyPublicService {
13642
13899
  policyName,
13643
13900
  storageName: "",
13644
13901
  stateName: "",
13902
+ mcpName: "",
13645
13903
  });
13646
13904
  };
13647
13905
  /**
@@ -13672,6 +13930,7 @@ class PolicyPublicService {
13672
13930
  policyName,
13673
13931
  storageName: "",
13674
13932
  stateName: "",
13933
+ mcpName: "",
13675
13934
  });
13676
13935
  };
13677
13936
  }
@@ -14385,6 +14644,239 @@ class WikiValidationService {
14385
14644
  }
14386
14645
  }
14387
14646
 
14647
+ class ClientMCP {
14648
+ constructor(params) {
14649
+ this.params = params;
14650
+ this.fetchTools = functoolsKit.memoize(([clientId]) => `${clientId}`, async (clientId) => {
14651
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
14652
+ this.params.logger.debug(`ClientMCP mcpName=${this.params.mcpName} fetchTools`, {
14653
+ clientId,
14654
+ });
14655
+ const toolList = await this.params.listTools(clientId);
14656
+ return new Map(toolList.map((tool) => [tool.name, tool]));
14657
+ });
14658
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
14659
+ this.params.logger.debug(`ClientMCP mcpName=${this.params.mcpName} CTOR`, {
14660
+ params,
14661
+ });
14662
+ if (this.params.callbacks?.onInit) {
14663
+ this.params.callbacks.onInit();
14664
+ }
14665
+ }
14666
+ async listTools(clientId) {
14667
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
14668
+ this.params.logger.debug(`ClientMCP mcpName=${this.params.mcpName} listTools`, {
14669
+ clientId,
14670
+ });
14671
+ if (this.params.callbacks?.onList) {
14672
+ this.params.callbacks.onList(clientId);
14673
+ }
14674
+ const toolMap = await this.fetchTools(clientId);
14675
+ return Array.from(toolMap.values());
14676
+ }
14677
+ async hasTool(toolName, clientId) {
14678
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
14679
+ this.params.logger.debug(`ClientMCP mcpName=${this.params.mcpName} hasTool`, {
14680
+ toolName,
14681
+ clientId,
14682
+ });
14683
+ const toolMap = await this.fetchTools(clientId);
14684
+ return toolMap.has(toolName);
14685
+ }
14686
+ async callTool(toolName, dto) {
14687
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
14688
+ this.params.logger.debug(`ClientMCP mcpName=${this.params.mcpName} callTool`, {
14689
+ toolName,
14690
+ dto,
14691
+ });
14692
+ if (this.params.callbacks?.onCall) {
14693
+ this.params.callbacks.onCall(toolName, dto);
14694
+ }
14695
+ return await this.params.callTool(toolName, dto);
14696
+ }
14697
+ dispose(clientId) {
14698
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
14699
+ this.params.logger.debug(`ClientMCP mcpName=${this.params.mcpName} dispose`, {
14700
+ clientId,
14701
+ });
14702
+ this.fetchTools.clear(clientId);
14703
+ if (this.params.callbacks?.onDispose) {
14704
+ this.params.callbacks.onDispose(clientId);
14705
+ }
14706
+ }
14707
+ }
14708
+
14709
+ class MCPConnectionService {
14710
+ constructor() {
14711
+ this.loggerService = inject(TYPES.loggerService);
14712
+ this.busService = inject(TYPES.busService);
14713
+ this.methodContextService = inject(TYPES.methodContextService);
14714
+ this.mcpSchemaService = inject(TYPES.mcpSchemaService);
14715
+ this.getMCP = functoolsKit.memoize(([mcpName]) => `${mcpName}`, (mcpName) => {
14716
+ const schema = this.mcpSchemaService.get(mcpName);
14717
+ return new ClientMCP({
14718
+ mcpName,
14719
+ bus: this.busService,
14720
+ logger: this.loggerService,
14721
+ ...schema,
14722
+ });
14723
+ });
14724
+ }
14725
+ async listTools(clientId) {
14726
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
14727
+ this.loggerService.info(`mcpConnectionService listTools`, {
14728
+ clientId,
14729
+ });
14730
+ return await this.getMCP(this.methodContextService.context.mcpName).listTools(clientId);
14731
+ }
14732
+ async hasTool(toolName, clientId) {
14733
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
14734
+ this.loggerService.info(`mcpConnectionService hasTool`, {
14735
+ toolName,
14736
+ clientId,
14737
+ });
14738
+ return await this.getMCP(this.methodContextService.context.mcpName).hasTool(toolName, clientId);
14739
+ }
14740
+ async callTool(toolName, dto) {
14741
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
14742
+ this.loggerService.info(`mcpConnectionService hasTool`, {
14743
+ toolName,
14744
+ dto,
14745
+ });
14746
+ return await this.getMCP(this.methodContextService.context.mcpName).callTool(toolName, dto);
14747
+ }
14748
+ }
14749
+
14750
+ class MCPSchemaService {
14751
+ constructor() {
14752
+ this.loggerService = inject(TYPES.loggerService);
14753
+ this.registry = new functoolsKit.ToolRegistry("mcpSchemaService");
14754
+ this.validateShallow = (mcpSchema) => {
14755
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
14756
+ this.loggerService.info(`mcpSchemaService validateShallow`, {
14757
+ mcpSchema,
14758
+ });
14759
+ if (typeof mcpSchema.mcpName !== "string") {
14760
+ throw new Error(`agent-swarm mcp schema validation failed: missing mcpName`);
14761
+ }
14762
+ if (typeof mcpSchema.callTool !== "function") {
14763
+ throw new Error(`agent-swarm mcp schema validation failed: callTool must be provided mcpName=${mcpSchema.mcpName}`);
14764
+ }
14765
+ if (typeof mcpSchema.listTools !== "function") {
14766
+ throw new Error(`agent-swarm mcp schema validation failed: listTools must be provided mcpName=${mcpSchema.mcpName}`);
14767
+ }
14768
+ };
14769
+ this.register = (key, value) => {
14770
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
14771
+ this.loggerService.info(`mcpSchemaService register`, { key });
14772
+ this.validateShallow(value);
14773
+ this.registry = this.registry.register(key, value);
14774
+ };
14775
+ this.override = (key, value) => {
14776
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
14777
+ this.loggerService.info(`mcpSchemaService override`, { key });
14778
+ this.registry = this.registry.override(key, value);
14779
+ return this.registry.get(key);
14780
+ };
14781
+ this.get = (key) => {
14782
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
14783
+ this.loggerService.info(`mcpSchemaService get`, { key });
14784
+ return this.registry.get(key);
14785
+ };
14786
+ }
14787
+ }
14788
+
14789
+ class MCPPublicService {
14790
+ constructor() {
14791
+ this.loggerService = inject(TYPES.loggerService);
14792
+ this.mcpConnectionService = inject(TYPES.mcpConnectionService);
14793
+ }
14794
+ async listTools(methodName, clientId, mcpName) {
14795
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
14796
+ this.loggerService.info(`mcpPublicService listTools`, {
14797
+ clientId,
14798
+ });
14799
+ return await MethodContextService.runInContext(async () => {
14800
+ return await this.mcpConnectionService.listTools(clientId);
14801
+ }, {
14802
+ methodName,
14803
+ clientId,
14804
+ mcpName,
14805
+ agentName: "",
14806
+ swarmName: "",
14807
+ storageName: "",
14808
+ stateName: "",
14809
+ policyName: "",
14810
+ });
14811
+ }
14812
+ async hasTool(methodName, clientId, mcpName, toolName) {
14813
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
14814
+ this.loggerService.info(`mcpPublicService hasTool`, {
14815
+ toolName,
14816
+ clientId,
14817
+ });
14818
+ return await MethodContextService.runInContext(async () => {
14819
+ return await this.mcpConnectionService.hasTool(toolName, clientId);
14820
+ }, {
14821
+ methodName,
14822
+ clientId,
14823
+ mcpName,
14824
+ agentName: "",
14825
+ swarmName: "",
14826
+ storageName: "",
14827
+ stateName: "",
14828
+ policyName: "",
14829
+ });
14830
+ }
14831
+ async callTool(methodName, clientId, mcpName, toolName, dto) {
14832
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
14833
+ this.loggerService.info(`mcpPublicService callTool`, {
14834
+ toolName,
14835
+ dto,
14836
+ });
14837
+ return await MethodContextService.runInContext(async () => {
14838
+ return await this.mcpConnectionService.callTool(toolName, dto);
14839
+ }, {
14840
+ methodName,
14841
+ clientId,
14842
+ mcpName,
14843
+ agentName: "",
14844
+ swarmName: "",
14845
+ storageName: "",
14846
+ stateName: "",
14847
+ policyName: "",
14848
+ });
14849
+ }
14850
+ }
14851
+
14852
+ class MCPValidationService {
14853
+ constructor() {
14854
+ this.loggerService = inject(TYPES.loggerService);
14855
+ this._mcpMap = new Map();
14856
+ this.addMCP = (mcpName, mcpSchema) => {
14857
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
14858
+ this.loggerService.info("mcpValidationService addMCP", {
14859
+ mcpName,
14860
+ mcpSchema,
14861
+ });
14862
+ if (this._mcpMap.has(mcpName)) {
14863
+ throw new Error(`agent-swarm mcp ${mcpName} already exist`);
14864
+ }
14865
+ this._mcpMap.set(mcpName, mcpSchema);
14866
+ };
14867
+ this.validate = functoolsKit.memoize(([mcpName]) => mcpName, (mcpName, source) => {
14868
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
14869
+ this.loggerService.info("mcpValidationService validate", {
14870
+ mcpName,
14871
+ source,
14872
+ });
14873
+ if (!this._mcpMap.has(mcpName)) {
14874
+ throw new Error(`agent-swarm mcp ${mcpName} not found source=${source}`);
14875
+ }
14876
+ });
14877
+ }
14878
+ }
14879
+
14388
14880
  {
14389
14881
  provide(TYPES.docService, () => new DocService());
14390
14882
  provide(TYPES.busService, () => new BusService());
@@ -14407,6 +14899,7 @@ class WikiValidationService {
14407
14899
  provide(TYPES.stateConnectionService, () => new StateConnectionService());
14408
14900
  provide(TYPES.sharedStateConnectionService, () => new SharedStateConnectionService());
14409
14901
  provide(TYPES.policyConnectionService, () => new PolicyConnectionService());
14902
+ provide(TYPES.mcpConnectionService, () => new MCPConnectionService());
14410
14903
  }
14411
14904
  {
14412
14905
  provide(TYPES.agentSchemaService, () => new AgentSchemaService());
@@ -14419,6 +14912,7 @@ class WikiValidationService {
14419
14912
  provide(TYPES.memorySchemaService, () => new MemorySchemaService());
14420
14913
  provide(TYPES.policySchemaService, () => new PolicySchemaService());
14421
14914
  provide(TYPES.wikiSchemaService, () => new WikiSchemaService());
14915
+ provide(TYPES.mcpSchemaService, () => new MCPSchemaService());
14422
14916
  }
14423
14917
  {
14424
14918
  provide(TYPES.agentPublicService, () => new AgentPublicService());
@@ -14430,6 +14924,7 @@ class WikiValidationService {
14430
14924
  provide(TYPES.statePublicService, () => new StatePublicService());
14431
14925
  provide(TYPES.sharedStatePublicService, () => new SharedStatePublicService());
14432
14926
  provide(TYPES.policyPublicService, () => new PolicyPublicService());
14927
+ provide(TYPES.mcpPublicService, () => new MCPPublicService());
14433
14928
  }
14434
14929
  {
14435
14930
  provide(TYPES.swarmMetaService, () => new SwarmMetaService());
@@ -14446,6 +14941,7 @@ class WikiValidationService {
14446
14941
  provide(TYPES.policyValidationService, () => new PolicyValidationService());
14447
14942
  provide(TYPES.navigationValidationService, () => new NavigationValidationService());
14448
14943
  provide(TYPES.wikiValidationService, () => new WikiValidationService());
14944
+ provide(TYPES.mcpValidationService, () => new MCPValidationService());
14449
14945
  }
14450
14946
 
14451
14947
  const baseServices = {
@@ -14470,6 +14966,7 @@ const connectionServices = {
14470
14966
  stateConnectionService: inject(TYPES.stateConnectionService),
14471
14967
  sharedStateConnectionService: inject(TYPES.sharedStateConnectionService),
14472
14968
  policyConnectionService: inject(TYPES.policyConnectionService),
14969
+ mcpConnectionService: inject(TYPES.mcpConnectionService),
14473
14970
  };
14474
14971
  const schemaServices = {
14475
14972
  agentSchemaService: inject(TYPES.agentSchemaService),
@@ -14482,6 +14979,7 @@ const schemaServices = {
14482
14979
  memorySchemaService: inject(TYPES.memorySchemaService),
14483
14980
  policySchemaService: inject(TYPES.policySchemaService),
14484
14981
  wikiSchemaService: inject(TYPES.wikiSchemaService),
14982
+ mcpSchemaService: inject(TYPES.mcpSchemaService),
14485
14983
  };
14486
14984
  const publicServices = {
14487
14985
  agentPublicService: inject(TYPES.agentPublicService),
@@ -14493,6 +14991,7 @@ const publicServices = {
14493
14991
  statePublicService: inject(TYPES.statePublicService),
14494
14992
  sharedStatePublicService: inject(TYPES.sharedStatePublicService),
14495
14993
  policyPublicService: inject(TYPES.policyPublicService),
14994
+ mcpPublicService: inject(TYPES.mcpPublicService),
14496
14995
  };
14497
14996
  const metaServices = {
14498
14997
  agentMetaService: inject(TYPES.agentMetaService),
@@ -14509,6 +15008,7 @@ const validationServices = {
14509
15008
  policyValidationService: inject(TYPES.policyValidationService),
14510
15009
  navigationValidationService: inject(TYPES.navigationValidationService),
14511
15010
  wikiValidationService: inject(TYPES.wikiValidationService),
15011
+ mcpValidationService: inject(TYPES.mcpValidationService),
14512
15012
  };
14513
15013
  /** @inheritDoc */
14514
15014
  const swarm = {
@@ -14523,7 +15023,7 @@ const swarm = {
14523
15023
  init();
14524
15024
  var swarm$1 = swarm;
14525
15025
 
14526
- const METHOD_NAME$1a = "cli.dumpDocs";
15026
+ const METHOD_NAME$1c = "cli.dumpDocs";
14527
15027
  /**
14528
15028
  * Dumps the documentation for the agents and swarms.
14529
15029
  *
@@ -14533,7 +15033,7 @@ const METHOD_NAME$1a = "cli.dumpDocs";
14533
15033
  */
14534
15034
  const dumpDocs = beginContext((prefix = "swarm", dirName = "./docs/chat", PlantUML) => {
14535
15035
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
14536
- swarm$1.loggerService.log(METHOD_NAME$1a, {
15036
+ swarm$1.loggerService.log(METHOD_NAME$1c, {
14537
15037
  dirName,
14538
15038
  });
14539
15039
  if (PlantUML) {
@@ -14543,10 +15043,10 @@ const dumpDocs = beginContext((prefix = "swarm", dirName = "./docs/chat", PlantU
14543
15043
  }
14544
15044
  swarm$1.agentValidationService
14545
15045
  .getAgentList()
14546
- .forEach((agentName) => swarm$1.agentValidationService.validate(agentName, METHOD_NAME$1a));
15046
+ .forEach((agentName) => swarm$1.agentValidationService.validate(agentName, METHOD_NAME$1c));
14547
15047
  swarm$1.swarmValidationService
14548
15048
  .getSwarmList()
14549
- .forEach((swarmName) => swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$1a));
15049
+ .forEach((swarmName) => swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$1c));
14550
15050
  swarm$1.agentValidationService.getAgentList().forEach((agentName) => {
14551
15051
  const { dependsOn } = swarm$1.agentSchemaService.get(agentName);
14552
15052
  if (!dependsOn) {
@@ -14556,7 +15056,7 @@ const dumpDocs = beginContext((prefix = "swarm", dirName = "./docs/chat", PlantU
14556
15056
  return swarm$1.docService.dumpDocs(prefix, dirName);
14557
15057
  });
14558
15058
 
14559
- const METHOD_NAME$19 = "cli.dumpAgent";
15059
+ const METHOD_NAME$1b = "cli.dumpAgent";
14560
15060
  /**
14561
15061
  * Dumps the agent information into PlantUML format.
14562
15062
  *
@@ -14565,14 +15065,14 @@ const METHOD_NAME$19 = "cli.dumpAgent";
14565
15065
  */
14566
15066
  const dumpAgent = beginContext((agentName, { withSubtree = false } = {}) => {
14567
15067
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
14568
- swarm$1.loggerService.log(METHOD_NAME$19, {
15068
+ swarm$1.loggerService.log(METHOD_NAME$1b, {
14569
15069
  agentName,
14570
15070
  });
14571
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$19);
15071
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$1b);
14572
15072
  return swarm$1.agentMetaService.toUML(agentName, withSubtree);
14573
15073
  });
14574
15074
 
14575
- const METHOD_NAME$18 = "cli.dumpSwarm";
15075
+ const METHOD_NAME$1a = "cli.dumpSwarm";
14576
15076
  /**
14577
15077
  * Dumps the swarm information into PlantUML format.
14578
15078
  *
@@ -14581,14 +15081,14 @@ const METHOD_NAME$18 = "cli.dumpSwarm";
14581
15081
  */
14582
15082
  const dumpSwarm = beginContext((swarmName) => {
14583
15083
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
14584
- swarm$1.loggerService.log(METHOD_NAME$18, {
15084
+ swarm$1.loggerService.log(METHOD_NAME$1a, {
14585
15085
  swarmName,
14586
15086
  });
14587
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$18);
15087
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$1a);
14588
15088
  return swarm$1.swarmMetaService.toUML(swarmName);
14589
15089
  });
14590
15090
 
14591
- const METHOD_NAME$17 = "cli.dumpPerfomance";
15091
+ const METHOD_NAME$19 = "cli.dumpPerfomance";
14592
15092
  const METHOD_NAME_INTERNAL$1 = "cli.dumpPerfomance.internal";
14593
15093
  const METHOD_NAME_INTERVAL = "cli.dumpPerfomance.interval";
14594
15094
  /**
@@ -14607,7 +15107,7 @@ const dumpPerfomanceInternal = beginContext(async (dirName = "./logs/meta") => {
14607
15107
  * @returns {Promise<void>} A promise that resolves when the performance data has been dumped.
14608
15108
  */
14609
15109
  const dumpPerfomance = async (dirName = "./logs/meta") => {
14610
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$17);
15110
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$19);
14611
15111
  await dumpPerfomanceInternal(dirName);
14612
15112
  };
14613
15113
  /**
@@ -14665,7 +15165,7 @@ const listenExecutionEvent = beginContext((clientId, fn) => {
14665
15165
  return swarm$1.busService.subscribe(clientId, "execution-bus", functoolsKit.queued(async (e) => await fn(e)));
14666
15166
  });
14667
15167
 
14668
- const METHOD_NAME$16 = "cli.dumpClientPerformance";
15168
+ const METHOD_NAME$18 = "cli.dumpClientPerformance";
14669
15169
  const METHOD_NAME_INTERNAL = "cli.dumpClientPerformance.internal";
14670
15170
  const METHOD_NAME_EXECUTE = "cli.dumpClientPerformance.execute";
14671
15171
  /**
@@ -14689,7 +15189,7 @@ const dumpClientPerformanceInternal = beginContext(async (clientId, dirName = ".
14689
15189
  * @returns {Promise<void>} A promise that resolves when the performance data has been dumped.
14690
15190
  */
14691
15191
  const dumpClientPerformance = async (clientId, dirName = "./logs/client") => {
14692
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$16);
15192
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$18);
14693
15193
  await dumpClientPerformanceInternal(clientId, dirName);
14694
15194
  };
14695
15195
  /**
@@ -14710,7 +15210,7 @@ dumpClientPerformance.runAfterExecute = beginContext(async (dirName = "./logs/cl
14710
15210
  });
14711
15211
 
14712
15212
  /** @private Constant defining the method name for logging and validation context */
14713
- const METHOD_NAME$15 = "function.commit.commitFlushForce";
15213
+ const METHOD_NAME$17 = "function.commit.commitFlushForce";
14714
15214
  /**
14715
15215
  * Forcefully commits a flush of agent history for a specific client in the swarm system, without checking the active agent.
14716
15216
  * Validates the session and swarm, then proceeds with flushing the history regardless of the current agent state.
@@ -14728,20 +15228,20 @@ const METHOD_NAME$15 = "function.commit.commitFlushForce";
14728
15228
  const commitFlushForce = beginContext(async (clientId) => {
14729
15229
  // Log the flush attempt if enabled
14730
15230
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
14731
- swarm$1.loggerService.log(METHOD_NAME$15, {
15231
+ swarm$1.loggerService.log(METHOD_NAME$17, {
14732
15232
  clientId,
14733
- METHOD_NAME: METHOD_NAME$15,
15233
+ METHOD_NAME: METHOD_NAME$17,
14734
15234
  });
14735
15235
  // Validate the session exists and retrieve the associated swarm
14736
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$15);
15236
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$17);
14737
15237
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
14738
15238
  // Validate the swarm configuration
14739
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$15);
15239
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$17);
14740
15240
  // Commit the flush of agent history via SessionPublicService without agent checks
14741
- await swarm$1.sessionPublicService.commitFlush(METHOD_NAME$15, clientId, swarmName);
15241
+ await swarm$1.sessionPublicService.commitFlush(METHOD_NAME$17, clientId, swarmName);
14742
15242
  });
14743
15243
 
14744
- const METHOD_NAME$14 = "function.commit.commitToolOutputForce";
15244
+ const METHOD_NAME$16 = "function.commit.commitToolOutputForce";
14745
15245
  /**
14746
15246
  * Commits the output of a tool execution to the active agent in a swarm session without checking the active agent.
14747
15247
  *
@@ -14760,24 +15260,24 @@ const METHOD_NAME$14 = "function.commit.commitToolOutputForce";
14760
15260
  const commitToolOutputForce = beginContext(async (toolId, content, clientId) => {
14761
15261
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
14762
15262
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
14763
- swarm$1.loggerService.log(METHOD_NAME$14, {
15263
+ swarm$1.loggerService.log(METHOD_NAME$16, {
14764
15264
  toolId,
14765
15265
  content,
14766
15266
  clientId,
14767
15267
  });
14768
15268
  // Validate the session and swarm to ensure they exist and are accessible
14769
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$14);
15269
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$16);
14770
15270
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
14771
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$14);
15271
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$16);
14772
15272
  // Commit the tool output to the session via the session public service without checking the active agent
14773
- await swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$14, clientId, swarmName);
15273
+ await swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$16, clientId, swarmName);
14774
15274
  });
14775
15275
 
14776
15276
  /**
14777
15277
  * @private Constant defining the method name for logging and validation purposes.
14778
15278
  * Used as an identifier in log messages and validation checks to track calls to `hasNavigation`.
14779
15279
  */
14780
- const METHOD_NAME$13 = "function.common.hasNavigation";
15280
+ const METHOD_NAME$15 = "function.common.hasNavigation";
14781
15281
  /**
14782
15282
  * Checks if a specific agent is part of the navigation route for a given client.
14783
15283
  * Validates the agent and client session, retrieves the associated swarm, and queries the navigation route.
@@ -14788,16 +15288,16 @@ const METHOD_NAME$13 = "function.common.hasNavigation";
14788
15288
  */
14789
15289
  const hasNavigation = async (clientId, agentName) => {
14790
15290
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
14791
- swarm$1.loggerService.log(METHOD_NAME$13, { clientId });
14792
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$13);
14793
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$13);
15291
+ swarm$1.loggerService.log(METHOD_NAME$15, { clientId });
15292
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$15);
15293
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$15);
14794
15294
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
14795
15295
  return swarm$1.navigationValidationService
14796
15296
  .getNavigationRoute(clientId, swarmName)
14797
15297
  .has(agentName);
14798
15298
  };
14799
15299
 
14800
- const METHOD_NAME$12 = "function.history.getRawHistory";
15300
+ const METHOD_NAME$14 = "function.history.getRawHistory";
14801
15301
  /**
14802
15302
  * Retrieves the raw, unmodified history for a given client session.
14803
15303
  *
@@ -14814,10 +15314,10 @@ const METHOD_NAME$12 = "function.history.getRawHistory";
14814
15314
  * const rawHistory = await getRawHistory("client-123");
14815
15315
  * console.log(rawHistory); // Outputs the full raw history array
14816
15316
  */
14817
- const getRawHistory = beginContext(async (clientId, methodName = METHOD_NAME$12) => {
15317
+ const getRawHistory = beginContext(async (clientId, methodName = METHOD_NAME$14) => {
14818
15318
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
14819
15319
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
14820
- swarm$1.loggerService.log(METHOD_NAME$12, {
15320
+ swarm$1.loggerService.log(METHOD_NAME$14, {
14821
15321
  clientId,
14822
15322
  });
14823
15323
  // Validate the session and swarm
@@ -14830,7 +15330,7 @@ const getRawHistory = beginContext(async (clientId, methodName = METHOD_NAME$12)
14830
15330
  return [...history];
14831
15331
  });
14832
15332
 
14833
- const METHOD_NAME$11 = "function.history.getLastUserMessage";
15333
+ const METHOD_NAME$13 = "function.history.getLastUserMessage";
14834
15334
  /**
14835
15335
  * Retrieves the content of the most recent user message from a client's session history.
14836
15336
  *
@@ -14848,16 +15348,16 @@ const METHOD_NAME$11 = "function.history.getLastUserMessage";
14848
15348
  const getLastUserMessage = beginContext(async (clientId) => {
14849
15349
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
14850
15350
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
14851
- swarm$1.loggerService.log(METHOD_NAME$11, {
15351
+ swarm$1.loggerService.log(METHOD_NAME$13, {
14852
15352
  clientId,
14853
15353
  });
14854
15354
  // Fetch raw history and find the last user message
14855
- const history = await getRawHistory(clientId, METHOD_NAME$11);
15355
+ const history = await getRawHistory(clientId, METHOD_NAME$13);
14856
15356
  const last = history.findLast(({ role, mode }) => role === "user" && mode === "user");
14857
15357
  return last ? last.content : null;
14858
15358
  });
14859
15359
 
14860
- const METHOD_NAME$10 = "function.navigate.changeToDefaultAgent";
15360
+ const METHOD_NAME$12 = "function.navigate.changeToDefaultAgent";
14861
15361
  /**
14862
15362
  * Time-to-live for the change agent function in milliseconds.
14863
15363
  * Defines how long the cached change agent function remains valid before expiring.
@@ -14892,7 +15392,7 @@ const createChangeToDefaultAgent = functoolsKit.ttl((clientId) => functoolsKit.q
14892
15392
  }));
14893
15393
  {
14894
15394
  // Dispose of the current agent's resources and set up the new default agent
14895
- const agentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$10, clientId, swarmName);
15395
+ const agentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$12, clientId, swarmName);
14896
15396
  await swarm$1.agentPublicService.dispose(methodName, clientId, agentName);
14897
15397
  await swarm$1.historyPublicService.dispose(methodName, clientId, agentName);
14898
15398
  await swarm$1.swarmPublicService.setAgentRef(methodName, clientId, swarmName, agentName, await swarm$1.agentPublicService.createAgentRef(methodName, clientId, agentName));
@@ -14931,23 +15431,23 @@ const createGc$3 = functoolsKit.singleshot(async () => {
14931
15431
  const changeToDefaultAgent = beginContext(async (clientId) => {
14932
15432
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
14933
15433
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
14934
- swarm$1.loggerService.log(METHOD_NAME$10, {
15434
+ swarm$1.loggerService.log(METHOD_NAME$12, {
14935
15435
  clientId,
14936
15436
  });
14937
15437
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
14938
15438
  const { defaultAgent: agentName } = swarm$1.swarmSchemaService.get(swarmName);
14939
15439
  {
14940
15440
  // Validate session and default agent
14941
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$10);
14942
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$10);
15441
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$12);
15442
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$12);
14943
15443
  }
14944
15444
  // Execute the agent change with TTL and queuing
14945
15445
  const run = await createChangeToDefaultAgent(clientId);
14946
15446
  createGc$3();
14947
- return await run(METHOD_NAME$10, agentName, swarmName);
15447
+ return await run(METHOD_NAME$12, agentName, swarmName);
14948
15448
  });
14949
15449
 
14950
- const METHOD_NAME$$ = "function.target.emitForce";
15450
+ const METHOD_NAME$11 = "function.target.emitForce";
14951
15451
  /**
14952
15452
  * Emits a string as model output without executing an incoming message or checking the active agent.
14953
15453
  *
@@ -14966,19 +15466,19 @@ const METHOD_NAME$$ = "function.target.emitForce";
14966
15466
  const emitForce = beginContext(async (content, clientId) => {
14967
15467
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
14968
15468
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
14969
- swarm$1.loggerService.log(METHOD_NAME$$, {
15469
+ swarm$1.loggerService.log(METHOD_NAME$11, {
14970
15470
  content,
14971
15471
  clientId,
14972
15472
  });
14973
15473
  // Validate the session and swarm
14974
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$$);
15474
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$11);
14975
15475
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
14976
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$$);
15476
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$11);
14977
15477
  // Emit the content directly via the session public service
14978
- return await swarm$1.sessionPublicService.emit(content, METHOD_NAME$$, clientId, swarmName);
15478
+ return await swarm$1.sessionPublicService.emit(content, METHOD_NAME$11, clientId, swarmName);
14979
15479
  });
14980
15480
 
14981
- const METHOD_NAME$_ = "function.target.executeForce";
15481
+ const METHOD_NAME$10 = "function.target.executeForce";
14982
15482
  /**
14983
15483
  * Sends a message to the active agent in a swarm session as if it originated from the client side, forcing execution regardless of agent activity.
14984
15484
  *
@@ -14999,22 +15499,22 @@ const executeForce = beginContext(async (content, clientId) => {
14999
15499
  const executionId = functoolsKit.randomString();
15000
15500
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
15001
15501
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15002
- swarm$1.loggerService.log(METHOD_NAME$_, {
15502
+ swarm$1.loggerService.log(METHOD_NAME$10, {
15003
15503
  content,
15004
15504
  clientId,
15005
15505
  executionId,
15006
15506
  });
15007
15507
  // Validate the session and swarm
15008
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$_);
15508
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$10);
15009
15509
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
15010
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$_);
15510
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$10);
15011
15511
  // Execute the command within an execution context with performance tracking
15012
15512
  return ExecutionContextService.runInContext(async () => {
15013
15513
  let isFinished = false;
15014
15514
  swarm$1.perfService.startExecution(executionId, clientId, content.length);
15015
15515
  try {
15016
15516
  swarm$1.busService.commitExecutionBegin(clientId, { swarmName });
15017
- const result = await swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$_, clientId, swarmName);
15517
+ const result = await swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$10, clientId, swarmName);
15018
15518
  isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
15019
15519
  swarm$1.busService.commitExecutionEnd(clientId, { swarmName });
15020
15520
  return result;
@@ -15031,7 +15531,7 @@ const executeForce = beginContext(async (content, clientId) => {
15031
15531
  });
15032
15532
  });
15033
15533
 
15034
- const METHOD_NAME$Z = "function.template.navigateToTriageAgent";
15534
+ const METHOD_NAME$$ = "function.template.navigateToTriageAgent";
15035
15535
  const DEFAULT_ACCEPT_FN = (_, defaultAgent) => `Successfully navigated to ${defaultAgent}`;
15036
15536
  const DEFAULT_REJECT_FN = (_, defaultAgent) => `Already on ${defaultAgent}`;
15037
15537
  /**
@@ -15080,7 +15580,7 @@ const createNavigateToTriageAgent = async ({ flushMessage, executeMessage, toolO
15080
15580
  */
15081
15581
  return beginContext(async (toolId, clientId) => {
15082
15582
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15083
- swarm$1.loggerService.log(METHOD_NAME$Z, {
15583
+ swarm$1.loggerService.log(METHOD_NAME$$, {
15084
15584
  clientId,
15085
15585
  toolId,
15086
15586
  });
@@ -15110,7 +15610,7 @@ const createNavigateToTriageAgent = async ({ flushMessage, executeMessage, toolO
15110
15610
  });
15111
15611
  };
15112
15612
 
15113
- const METHOD_NAME$Y = "function.navigate.changeToAgent";
15613
+ const METHOD_NAME$_ = "function.navigate.changeToAgent";
15114
15614
  /**
15115
15615
  * Time-to-live for the change agent function in milliseconds.
15116
15616
  * Defines how long the cached change agent function remains valid before expiring.
@@ -15146,7 +15646,7 @@ const createChangeToAgent = functoolsKit.ttl((clientId) => functoolsKit.queued(a
15146
15646
  }));
15147
15647
  {
15148
15648
  // Dispose of the current agent's resources and set up the new agent
15149
- const agentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$Y, clientId, swarmName);
15649
+ const agentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$_, clientId, swarmName);
15150
15650
  await swarm$1.agentPublicService.dispose(methodName, clientId, agentName);
15151
15651
  await swarm$1.historyPublicService.dispose(methodName, clientId, agentName);
15152
15652
  await swarm$1.swarmPublicService.setAgentRef(methodName, clientId, swarmName, agentName, await swarm$1.agentPublicService.createAgentRef(methodName, clientId, agentName));
@@ -15186,16 +15686,16 @@ const createGc$2 = functoolsKit.singleshot(async () => {
15186
15686
  const changeToAgent = beginContext(async (agentName, clientId) => {
15187
15687
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
15188
15688
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15189
- swarm$1.loggerService.log(METHOD_NAME$Y, {
15689
+ swarm$1.loggerService.log(METHOD_NAME$_, {
15190
15690
  agentName,
15191
15691
  clientId,
15192
15692
  });
15193
15693
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
15194
15694
  {
15195
15695
  // Validate session, agent, and dependencies
15196
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$Y);
15197
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$Y);
15198
- const activeAgent = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$Y, clientId, swarmName);
15696
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$_);
15697
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$_);
15698
+ const activeAgent = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$_, clientId, swarmName);
15199
15699
  if (!swarm$1.agentValidationService.hasDependency(activeAgent, agentName)) {
15200
15700
  console.error(`agent-swarm missing dependency detected for activeAgent=${activeAgent} dependencyAgent=${agentName}`);
15201
15701
  }
@@ -15213,10 +15713,10 @@ const changeToAgent = beginContext(async (agentName, clientId) => {
15213
15713
  // Execute the agent change with TTL and queuing
15214
15714
  const run = await createChangeToAgent(clientId);
15215
15715
  createGc$2();
15216
- return await run(METHOD_NAME$Y, agentName, swarmName);
15716
+ return await run(METHOD_NAME$_, agentName, swarmName);
15217
15717
  });
15218
15718
 
15219
- const METHOD_NAME$X = "function.template.navigateToAgent";
15719
+ const METHOD_NAME$Z = "function.template.navigateToAgent";
15220
15720
  /**
15221
15721
  * Default tool output message indicating successful navigation to the specified agent.
15222
15722
  *
@@ -15281,7 +15781,7 @@ const createNavigateToAgent = async ({ executeMessage, emitMessage, flushMessage
15281
15781
  */
15282
15782
  return beginContext(async (toolId, clientId, agentName) => {
15283
15783
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15284
- swarm$1.loggerService.log(METHOD_NAME$X, {
15784
+ swarm$1.loggerService.log(METHOD_NAME$Z, {
15285
15785
  clientId,
15286
15786
  toolId,
15287
15787
  });
@@ -15314,7 +15814,7 @@ const createNavigateToAgent = async ({ executeMessage, emitMessage, flushMessage
15314
15814
  };
15315
15815
 
15316
15816
  /** @constant {string} METHOD_NAME - The name of the method used for logging */
15317
- const METHOD_NAME$W = "function.setup.addWiki";
15817
+ const METHOD_NAME$Y = "function.setup.addWiki";
15318
15818
  /**
15319
15819
  * Adds a wiki schema to the system
15320
15820
  * @function addWiki
@@ -15323,7 +15823,7 @@ const METHOD_NAME$W = "function.setup.addWiki";
15323
15823
  */
15324
15824
  const addWiki = beginContext((wikiSchema) => {
15325
15825
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15326
- swarm$1.loggerService.log(METHOD_NAME$W, {
15826
+ swarm$1.loggerService.log(METHOD_NAME$Y, {
15327
15827
  wikiSchema,
15328
15828
  });
15329
15829
  swarm$1.wikiValidationService.addWiki(wikiSchema.wikiName, wikiSchema);
@@ -15331,7 +15831,7 @@ const addWiki = beginContext((wikiSchema) => {
15331
15831
  return wikiSchema.wikiName;
15332
15832
  });
15333
15833
 
15334
- const METHOD_NAME$V = "function.setup.addAgent";
15834
+ const METHOD_NAME$X = "function.setup.addAgent";
15335
15835
  /**
15336
15836
  * Adds a new agent to the agent registry for use within the swarm system.
15337
15837
  *
@@ -15351,7 +15851,7 @@ const METHOD_NAME$V = "function.setup.addAgent";
15351
15851
  const addAgent = beginContext((agentSchema) => {
15352
15852
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
15353
15853
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15354
- swarm$1.loggerService.log(METHOD_NAME$V, {
15854
+ swarm$1.loggerService.log(METHOD_NAME$X, {
15355
15855
  agentSchema,
15356
15856
  });
15357
15857
  // Register the agent in the validation and schema services
@@ -15361,7 +15861,7 @@ const addAgent = beginContext((agentSchema) => {
15361
15861
  return agentSchema.agentName;
15362
15862
  });
15363
15863
 
15364
- const METHOD_NAME$U = "function.setup.addCompletion";
15864
+ const METHOD_NAME$W = "function.setup.addCompletion";
15365
15865
  /**
15366
15866
  * Adds a completion engine to the registry for use by agents in the swarm system.
15367
15867
  *
@@ -15381,7 +15881,7 @@ const METHOD_NAME$U = "function.setup.addCompletion";
15381
15881
  const addCompletion = beginContext((completionSchema) => {
15382
15882
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
15383
15883
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15384
- swarm$1.loggerService.log(METHOD_NAME$U, {
15884
+ swarm$1.loggerService.log(METHOD_NAME$W, {
15385
15885
  completionSchema,
15386
15886
  });
15387
15887
  // Register the completion in the validation and schema services
@@ -15391,7 +15891,7 @@ const addCompletion = beginContext((completionSchema) => {
15391
15891
  return completionSchema.completionName;
15392
15892
  });
15393
15893
 
15394
- const METHOD_NAME$T = "function.setup.addSwarm";
15894
+ const METHOD_NAME$V = "function.setup.addSwarm";
15395
15895
  /**
15396
15896
  * Adds a new swarm to the system for managing client sessions.
15397
15897
  *
@@ -15411,7 +15911,7 @@ const METHOD_NAME$T = "function.setup.addSwarm";
15411
15911
  const addSwarm = beginContext((swarmSchema) => {
15412
15912
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
15413
15913
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15414
- swarm$1.loggerService.log(METHOD_NAME$T, {
15914
+ swarm$1.loggerService.log(METHOD_NAME$V, {
15415
15915
  swarmSchema,
15416
15916
  });
15417
15917
  // Register the swarm in the validation and schema services
@@ -15421,7 +15921,7 @@ const addSwarm = beginContext((swarmSchema) => {
15421
15921
  return swarmSchema.swarmName;
15422
15922
  });
15423
15923
 
15424
- const METHOD_NAME$S = "function.setup.addTool";
15924
+ const METHOD_NAME$U = "function.setup.addTool";
15425
15925
  /**
15426
15926
  * Adds a new tool to the tool registry for use by agents in the swarm system.
15427
15927
  *
@@ -15443,7 +15943,7 @@ const METHOD_NAME$S = "function.setup.addTool";
15443
15943
  const addTool = beginContext((toolSchema) => {
15444
15944
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
15445
15945
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15446
- swarm$1.loggerService.log(METHOD_NAME$S, {
15946
+ swarm$1.loggerService.log(METHOD_NAME$U, {
15447
15947
  toolSchema,
15448
15948
  });
15449
15949
  // Register the tool in the validation and schema services
@@ -15453,7 +15953,18 @@ const addTool = beginContext((toolSchema) => {
15453
15953
  return toolSchema.toolName;
15454
15954
  });
15455
15955
 
15456
- const METHOD_NAME$R = "function.setup.addState";
15956
+ const METHOD_NAME$T = "function.setup.addMCP";
15957
+ const addMCP = beginContext((mcpSchema) => {
15958
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15959
+ swarm$1.loggerService.log(METHOD_NAME$T, {
15960
+ mcpSchema,
15961
+ });
15962
+ swarm$1.mcpValidationService.addMCP(mcpSchema.mcpName, mcpSchema);
15963
+ swarm$1.mcpSchemaService.register(mcpSchema.mcpName, mcpSchema);
15964
+ return mcpSchema.mcpName;
15965
+ });
15966
+
15967
+ const METHOD_NAME$S = "function.setup.addState";
15457
15968
  /**
15458
15969
  * Adds a new state to the state registry for use within the swarm system.
15459
15970
  *
@@ -15475,7 +15986,7 @@ const METHOD_NAME$R = "function.setup.addState";
15475
15986
  const addState = beginContext((stateSchema) => {
15476
15987
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
15477
15988
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15478
- swarm$1.loggerService.log(METHOD_NAME$R, {
15989
+ swarm$1.loggerService.log(METHOD_NAME$S, {
15479
15990
  stateSchema,
15480
15991
  });
15481
15992
  // Register the state in the schema service
@@ -15490,7 +16001,7 @@ const addState = beginContext((stateSchema) => {
15490
16001
  return stateSchema.stateName;
15491
16002
  });
15492
16003
 
15493
- const METHOD_NAME$Q = "function.setup.addEmbedding";
16004
+ const METHOD_NAME$R = "function.setup.addEmbedding";
15494
16005
  /**
15495
16006
  * Adds a new embedding engine to the embedding registry for use within the swarm system.
15496
16007
  *
@@ -15510,7 +16021,7 @@ const METHOD_NAME$Q = "function.setup.addEmbedding";
15510
16021
  const addEmbedding = beginContext((embeddingSchema) => {
15511
16022
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
15512
16023
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15513
- swarm$1.loggerService.log(METHOD_NAME$Q, {
16024
+ swarm$1.loggerService.log(METHOD_NAME$R, {
15514
16025
  embeddingSchema,
15515
16026
  });
15516
16027
  // Register the embedding in the validation and schema services
@@ -15520,7 +16031,7 @@ const addEmbedding = beginContext((embeddingSchema) => {
15520
16031
  return embeddingSchema.embeddingName;
15521
16032
  });
15522
16033
 
15523
- const METHOD_NAME$P = "function.setup.addStorage";
16034
+ const METHOD_NAME$Q = "function.setup.addStorage";
15524
16035
  /**
15525
16036
  * Adds a new storage engine to the storage registry for use within the swarm system.
15526
16037
  *
@@ -15542,7 +16053,7 @@ const METHOD_NAME$P = "function.setup.addStorage";
15542
16053
  const addStorage = beginContext((storageSchema) => {
15543
16054
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
15544
16055
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15545
- swarm$1.loggerService.log(METHOD_NAME$P, {
16056
+ swarm$1.loggerService.log(METHOD_NAME$Q, {
15546
16057
  storageSchema,
15547
16058
  });
15548
16059
  // Register the storage in the validation and schema services
@@ -15559,7 +16070,7 @@ const addStorage = beginContext((storageSchema) => {
15559
16070
  });
15560
16071
 
15561
16072
  /** @private Constant defining the method name for logging and validation context */
15562
- const METHOD_NAME$O = "function.setup.addPolicy";
16073
+ const METHOD_NAME$P = "function.setup.addPolicy";
15563
16074
  /**
15564
16075
  * Adds a new policy for agents in the swarm system by registering it with validation and schema services.
15565
16076
  * Registers the policy with PolicyValidationService for runtime validation and PolicySchemaService for schema management.
@@ -15575,7 +16086,7 @@ const METHOD_NAME$O = "function.setup.addPolicy";
15575
16086
  const addPolicy = beginContext((policySchema) => {
15576
16087
  // Log the policy addition attempt if enabled
15577
16088
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15578
- swarm$1.loggerService.log(METHOD_NAME$O, {
16089
+ swarm$1.loggerService.log(METHOD_NAME$P, {
15579
16090
  policySchema,
15580
16091
  });
15581
16092
  // Register the policy with PolicyValidationService for runtime validation
@@ -15586,7 +16097,7 @@ const addPolicy = beginContext((policySchema) => {
15586
16097
  return policySchema.policyName;
15587
16098
  });
15588
16099
 
15589
- const METHOD_NAME$N = "function.test.overrideAgent";
16100
+ const METHOD_NAME$O = "function.test.overrideAgent";
15590
16101
  /**
15591
16102
  * Overrides an existing agent schema in the swarm system with a new or partial schema.
15592
16103
  * This function updates the configuration of an agent identified by its `agentName`, applying the provided schema properties.
@@ -15610,13 +16121,13 @@ const METHOD_NAME$N = "function.test.overrideAgent";
15610
16121
  */
15611
16122
  const overrideAgent = beginContext((agentSchema) => {
15612
16123
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15613
- swarm$1.loggerService.log(METHOD_NAME$N, {
16124
+ swarm$1.loggerService.log(METHOD_NAME$O, {
15614
16125
  agentSchema,
15615
16126
  });
15616
16127
  return swarm$1.agentSchemaService.override(agentSchema.agentName, agentSchema);
15617
16128
  });
15618
16129
 
15619
- const METHOD_NAME$M = "function.test.overrideCompletion";
16130
+ const METHOD_NAME$N = "function.test.overrideCompletion";
15620
16131
  /**
15621
16132
  * Overrides an existing completion schema in the swarm system with a new or partial schema.
15622
16133
  * This function updates the configuration of a completion mechanism identified by its `completionName`, applying the provided schema properties.
@@ -15640,13 +16151,13 @@ const METHOD_NAME$M = "function.test.overrideCompletion";
15640
16151
  */
15641
16152
  const overrideCompletion = beginContext((completionSchema) => {
15642
16153
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15643
- swarm$1.loggerService.log(METHOD_NAME$M, {
16154
+ swarm$1.loggerService.log(METHOD_NAME$N, {
15644
16155
  completionSchema,
15645
16156
  });
15646
16157
  return swarm$1.completionSchemaService.override(completionSchema.completionName, completionSchema);
15647
16158
  });
15648
16159
 
15649
- const METHOD_NAME$L = "function.test.overrideEmbeding";
16160
+ const METHOD_NAME$M = "function.test.overrideEmbeding";
15650
16161
  /**
15651
16162
  * Overrides an existing embedding schema in the swarm system with a new or partial schema.
15652
16163
  * This function updates the configuration of an embedding mechanism identified by its `embeddingName`, applying the provided schema properties.
@@ -15672,13 +16183,13 @@ const METHOD_NAME$L = "function.test.overrideEmbeding";
15672
16183
  */
15673
16184
  const overrideEmbeding = beginContext((embeddingSchema) => {
15674
16185
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15675
- swarm$1.loggerService.log(METHOD_NAME$L, {
16186
+ swarm$1.loggerService.log(METHOD_NAME$M, {
15676
16187
  embeddingSchema,
15677
16188
  });
15678
16189
  return swarm$1.embeddingSchemaService.override(embeddingSchema.embeddingName, embeddingSchema);
15679
16190
  });
15680
16191
 
15681
- const METHOD_NAME$K = "function.test.overridePolicy";
16192
+ const METHOD_NAME$L = "function.test.overridePolicy";
15682
16193
  /**
15683
16194
  * Overrides an existing policy schema in the swarm system with a new or partial schema.
15684
16195
  * This function updates the configuration of a policy identified by its `policyName`, applying the provided schema properties.
@@ -15702,13 +16213,13 @@ const METHOD_NAME$K = "function.test.overridePolicy";
15702
16213
  */
15703
16214
  const overridePolicy = beginContext((policySchema) => {
15704
16215
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15705
- swarm$1.loggerService.log(METHOD_NAME$K, {
16216
+ swarm$1.loggerService.log(METHOD_NAME$L, {
15706
16217
  policySchema,
15707
16218
  });
15708
16219
  return swarm$1.policySchemaService.override(policySchema.policyName, policySchema);
15709
16220
  });
15710
16221
 
15711
- const METHOD_NAME$J = "function.test.overrideState";
16222
+ const METHOD_NAME$K = "function.test.overrideState";
15712
16223
  /**
15713
16224
  * Overrides an existing state schema in the swarm system with a new or partial schema.
15714
16225
  * This function updates the configuration of a state identified by its `stateName`, applying the provided schema properties.
@@ -15733,13 +16244,13 @@ const METHOD_NAME$J = "function.test.overrideState";
15733
16244
  */
15734
16245
  const overrideState = beginContext((stateSchema) => {
15735
16246
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15736
- swarm$1.loggerService.log(METHOD_NAME$J, {
16247
+ swarm$1.loggerService.log(METHOD_NAME$K, {
15737
16248
  stateSchema,
15738
16249
  });
15739
16250
  return swarm$1.stateSchemaService.override(stateSchema.stateName, stateSchema);
15740
16251
  });
15741
16252
 
15742
- const METHOD_NAME$I = "function.test.overrideStorage";
16253
+ const METHOD_NAME$J = "function.test.overrideStorage";
15743
16254
  /**
15744
16255
  * Overrides an existing storage schema in the swarm system with a new or partial schema.
15745
16256
  * This function updates the configuration of a storage identified by its `storageName`, applying the provided schema properties.
@@ -15765,13 +16276,13 @@ const METHOD_NAME$I = "function.test.overrideStorage";
15765
16276
  */
15766
16277
  const overrideStorage = beginContext((storageSchema) => {
15767
16278
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15768
- swarm$1.loggerService.log(METHOD_NAME$I, {
16279
+ swarm$1.loggerService.log(METHOD_NAME$J, {
15769
16280
  storageSchema,
15770
16281
  });
15771
16282
  return swarm$1.storageSchemaService.override(storageSchema.storageName, storageSchema);
15772
16283
  });
15773
16284
 
15774
- const METHOD_NAME$H = "function.test.overrideSwarm";
16285
+ const METHOD_NAME$I = "function.test.overrideSwarm";
15775
16286
  /**
15776
16287
  * Overrides an existing swarm schema in the swarm system with a new or partial schema.
15777
16288
  * This function updates the configuration of a swarm identified by its `swarmName`, applying the provided schema properties.
@@ -15795,13 +16306,13 @@ const METHOD_NAME$H = "function.test.overrideSwarm";
15795
16306
  */
15796
16307
  const overrideSwarm = beginContext((swarmSchema) => {
15797
16308
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15798
- swarm$1.loggerService.log(METHOD_NAME$H, {
16309
+ swarm$1.loggerService.log(METHOD_NAME$I, {
15799
16310
  swarmSchema,
15800
16311
  });
15801
16312
  return swarm$1.swarmSchemaService.override(swarmSchema.swarmName, swarmSchema);
15802
16313
  });
15803
16314
 
15804
- const METHOD_NAME$G = "function.test.overrideTool";
16315
+ const METHOD_NAME$H = "function.test.overrideTool";
15805
16316
  /**
15806
16317
  * Overrides an existing tool schema in the swarm system with a new or partial schema.
15807
16318
  * This function updates the configuration of a tool identified by its `toolName`, applying the provided schema properties.
@@ -15825,12 +16336,21 @@ const METHOD_NAME$G = "function.test.overrideTool";
15825
16336
  */
15826
16337
  const overrideTool = beginContext((toolSchema) => {
15827
16338
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15828
- swarm$1.loggerService.log(METHOD_NAME$G, {
16339
+ swarm$1.loggerService.log(METHOD_NAME$H, {
15829
16340
  toolSchema,
15830
16341
  });
15831
16342
  return swarm$1.toolSchemaService.override(toolSchema.toolName, toolSchema);
15832
16343
  });
15833
16344
 
16345
+ const METHOD_NAME$G = "function.test.overrideMCP";
16346
+ const overrideMCP = beginContext((mcpSchema) => {
16347
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16348
+ swarm$1.loggerService.log(METHOD_NAME$G, {
16349
+ mcpSchema,
16350
+ });
16351
+ return swarm$1.mcpSchemaService.override(mcpSchema.mcpName, mcpSchema);
16352
+ });
16353
+
15834
16354
  const METHOD_NAME$F = "function.test.overrideWiki";
15835
16355
  /**
15836
16356
  * Overrides an existing wiki schema in the swarm system with a new or partial schema.
@@ -15887,6 +16407,7 @@ const markOnline = async (clientId, swarmName) => {
15887
16407
  policyName: "",
15888
16408
  stateName: "",
15889
16409
  storageName: "",
16410
+ mcpName: "",
15890
16411
  swarmName,
15891
16412
  clientId,
15892
16413
  });
@@ -15919,6 +16440,7 @@ const markOffline = async (clientId, swarmName) => {
15919
16440
  policyName: "",
15920
16441
  stateName: "",
15921
16442
  storageName: "",
16443
+ mcpName: "",
15922
16444
  swarmName,
15923
16445
  clientId,
15924
16446
  });
@@ -20113,6 +20635,7 @@ exports.Utils = Utils;
20113
20635
  exports.addAgent = addAgent;
20114
20636
  exports.addCompletion = addCompletion;
20115
20637
  exports.addEmbedding = addEmbedding;
20638
+ exports.addMCP = addMCP;
20116
20639
  exports.addPolicy = addPolicy;
20117
20640
  exports.addState = addState;
20118
20641
  exports.addStorage = addStorage;
@@ -20192,6 +20715,7 @@ exports.notifyForce = notifyForce;
20192
20715
  exports.overrideAgent = overrideAgent;
20193
20716
  exports.overrideCompletion = overrideCompletion;
20194
20717
  exports.overrideEmbeding = overrideEmbeding;
20718
+ exports.overrideMCP = overrideMCP;
20195
20719
  exports.overridePolicy = overridePolicy;
20196
20720
  exports.overrideState = overrideState;
20197
20721
  exports.overrideStorage = overrideStorage;