agent-swarm-kit 1.1.6 → 1.1.8

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