Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,14 @@
import org.eclipse.lemminx.customservice.synapse.mediator.tryout.TryOutManager;
import org.eclipse.lemminx.customservice.synapse.InvalidConfigurationException;
import org.eclipse.lemminx.customservice.synapse.mediator.tryout.pojo.MediatorTryoutRequest;
import org.eclipse.lemminx.customservice.synapse.mediatorService.AIConnectorHandler;
import org.eclipse.lemminx.customservice.synapse.mediatorService.MediatorHandler;
import org.eclipse.lemminx.customservice.synapse.mediatorService.pojo.MediatorRequest;
import org.eclipse.lemminx.customservice.synapse.mediatorService.pojo.SynapseConfigRequest;
import org.eclipse.lemminx.customservice.synapse.mediatorService.pojo.SynapseConfigResponse;
import org.eclipse.lemminx.customservice.synapse.mediatorService.pojo.UISchemaRequest;
import org.eclipse.lemminx.customservice.synapse.mediatorService.pojo.MCPToolRequest;
import org.eclipse.lemminx.customservice.synapse.mediatorService.pojo.MCPToolResponse;
import org.eclipse.lemminx.customservice.synapse.parser.ConfigDetails;
import org.eclipse.lemminx.customservice.synapse.parser.Constants;
import org.eclipse.lemminx.customservice.synapse.parser.DependencyStatusResponse;
Expand Down Expand Up @@ -795,6 +798,14 @@ public CompletableFuture<List<List<Object>>> getInputOutputMappings(MappingsGenR
return CompletableFuture.supplyAsync(() -> Constant.INPUT.equals(param.type) ?
QueryGenerator.getInputMappings(param.query) : QueryGenerator.getOutputMappings(param));
}

@Override
public CompletableFuture<MCPToolResponse> getMCPTools(MCPToolRequest param) {

Connections connections = ConnectionFinder.findConnections(projectUri, Constant.LOWERCASE_AI, connectorHolder, isLegacyProject).getLeft();
AIConnectorHandler aiConnectorHandler = new AIConnectorHandler(mediatorHandler, projectUri);
return CompletableFuture.supplyAsync(() -> aiConnectorHandler.fetchMcpTools(connections.getConnections(), param.connectionName));
}

public String getProjectUri() {
return projectUri;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
import org.eclipse.lemminx.customservice.synapse.mediatorService.pojo.SynapseConfigRequest;
import org.eclipse.lemminx.customservice.synapse.mediatorService.pojo.SynapseConfigResponse;
import org.eclipse.lemminx.customservice.synapse.mediatorService.pojo.UISchemaRequest;
import org.eclipse.lemminx.customservice.synapse.mediatorService.pojo.MCPToolRequest;
import org.eclipse.lemminx.customservice.synapse.mediatorService.pojo.MCPToolResponse;
import org.eclipse.lemminx.customservice.synapse.parser.ConfigDetails;
import org.eclipse.lemminx.customservice.synapse.parser.DependencyStatusResponse;
import org.eclipse.lemminx.customservice.synapse.parser.DeployPluginDetails;
Expand Down Expand Up @@ -298,4 +300,7 @@ public interface ISynapseLanguageService {

@JsonRequest
CompletableFuture<List<List<Object>>> getInputOutputMappings(MappingsGenRequestParams param);

@JsonRequest
CompletableFuture<MCPToolResponse> getMCPTools(MCPToolRequest param);
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ public void setExpression(String expression) {
this.expression = expression;
}

public String getName() {

return name;
}

public String getValue() {

return value;
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2026, WSO2 LLC. (http://www.wso2.com).
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* WSO2 LLC - support for WSO2 Micro Integrator Configuration
*/

package org.eclipse.lemminx.customservice.synapse.mediatorService.pojo;

import java.util.Map;

public class MCPToolRequest {

public String connectionName;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2026, WSO2 LLC. (http://www.wso2.com).
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* WSO2 LLC - support for WSO2 Micro Integrator Configuration
*/

package org.eclipse.lemminx.customservice.synapse.mediatorService.pojo;

import org.eclipse.lsp4j.Range;

import java.util.Map;

public class MCPToolResponse {

public Map<String, String> tools;
public String error;
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ public List<TextEdit> getTextEdits() {

public void addTextEdit(TextEdit edit) {

textEdits.add(edit);
if (edit != null) {
textEdits.add(edit);
}
}

public void sort() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,32 @@ private void populateTools(AIAgent aiAgent, DOMElement element) {
List<DOMNode> toolElements = toolsElement.getChildren();
for (DOMNode toolElement : toolElements) {
if (toolElement instanceof DOMElement && Constant.TOOL.equals(toolElement.getNodeName())) {
String templateName = toolElement.getAttribute(Constant.TEMPLATE);
try {
String templatePath = ConfigFinder.getTemplatePath(templateName, getProjectPath());
Mediator mediator = getMediatorFromTemplate(templatePath);
if (toolElement.hasAttribute(Constant.TYPE) &&
Constant.MCP.equals(toolElement.getAttribute(Constant.TYPE))) {
AgentTool agentTool = new AgentTool();
agentTool.elementNode((DOMElement) toolElement);
agentTool.setName(toolElement.getAttribute(Constant.NAME));
agentTool.setTemplate(templateName);
agentTool.setTemplatePath(templatePath);
agentTool.setDescription(toolElement.getAttribute(Constant.DESCRIPTION));
agentTool.setResultExpression(toolElement.getAttribute(Constant.RESULT_EXPRESSION));
agentTool.setMediator(mediator);
agentTool.setMcpConnection(toolElement.getAttribute(Constant.MCP_CONNECTION));
agentTool.setMcpTool(true);
agentTools.addTool(agentTool);
} catch (IOException e) {
LOGGER.log(Level.SEVERE, "Error while reading the template file", e);
} else {
String templateName = toolElement.getAttribute(Constant.TEMPLATE);
try {
String templatePath = ConfigFinder.getTemplatePath(templateName, getProjectPath());
Mediator mediator = getMediatorFromTemplate(templatePath);
AgentTool agentTool = new AgentTool();
agentTool.elementNode((DOMElement) toolElement);
agentTool.setName(toolElement.getAttribute(Constant.NAME));
agentTool.setTemplate(templateName);
agentTool.setTemplatePath(templatePath);
agentTool.setDescription(toolElement.getAttribute(Constant.DESCRIPTION));
agentTool.setResultExpression(toolElement.getAttribute(Constant.RESULT_EXPRESSION));
agentTool.setMediator(mediator);
agentTools.addTool(agentTool);
} catch (IOException e) {
LOGGER.log(Level.SEVERE, "Error while reading the template file", e);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class AgentTool extends STNode {
private String resultExpression;
private Mediator mediator;
private String templatePath;
private String mcpConnection;
private boolean isMcpTool;

public String getName() {

Expand Down Expand Up @@ -85,4 +87,22 @@ public void setResultExpression(String resultExpression) {

this.resultExpression = resultExpression;
}

public void setMcpConnection(String mcpConnection) {

this.mcpConnection = mcpConnection;
}

public String getMcpConnection() {

return mcpConnection;
}

public boolean isMcpTool() {
return isMcpTool;
}

public void setMcpTool(boolean mcpTool) {
isMcpTool = mcpTool;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class Constant {
public static final String METHODS = "methods";
public static final String SEQUENCE = "sequence";
public static final String TYPE = "type";
public static final String MCP = "mcp";
public static final String MAX_SIZE = "maxSize";
public static final String TARGET = "target";
public static final String SOURCE = "source";
Expand Down Expand Up @@ -602,6 +603,7 @@ public class Constant {
public static final String MEMORY_CONFIG_KEY = "memoryConfigKey";
public static final String TOOLS = "tools";
public static final String TOOL = "tool";
public static final String MCP_TOOLS = "mcpTools";
public static final String AI_AGENT_TAG = "ai.agent";
public static final String ATTRIBUTE_GROUP = "attributeGroup";
public static final String CURRENT_VALUE = "currentValue";
Expand All @@ -612,6 +614,7 @@ public class Constant {
public static final Map<String, String> AI_CONNECTOR_VISITOR_FUNCTION = new HashMap<>();
public static final String CHECK_BOX = "checkbox";
public static final String AI = "AI";
public static final String LOWERCASE_AI = "ai";
public static final String AGENT_ID = "agentID";
public static final String RESULT_EXPRESSION = "resultExpression";
public static final String AI_AGENT = "AI_AGENT";
Expand Down Expand Up @@ -654,6 +657,7 @@ public class Constant {
put("4.4.0", "4.4.0");
put("4.5.0", "4.4.0");
}};
public static final String MCP_CONNECTION = "mcpConnection";

static {
// AI Connection to Display Name bi-Mapping
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<{{name}}>{{value}}</{{name}}>
{{/connections}}
</connections>
{{#supportTools}}<mcpConnections>
</mcpConnections>{{/supportTools}}
{{#parameters}}
<{{{name}}} {{#value}}{{#namespaces}} xmlns:{{{prefix}}}="{{{uri}}}"{{/namespaces}}>{{#isCDATA}}<![CDATA[{{{value}}}]]>{{/isCDATA}}{{^isCDATA}}{{value}}{{/isCDATA}}{{/value}}</{{{name}}}>
{{/parameters}}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<mcpConfigKey>{{mcpConnection}}</mcpConfigKey>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<mcpConnections>
{{#mcpConnections}}{{{.}}}{{/mcpConnections}}
</mcpConnections>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<tool name="{{name}}" template="{{template}}"{{#resultExpression}} resultExpression="{{resultExpression}}"{{/resultExpression}} description="{{description}}"/>
<tool name="{{name}}" {{#isMCP}}type="mcp" mcpConnection="{{mcpConnection}}"{{/isMCP}}{{^isMCP}}template="{{template}}"{{#resultExpression}} resultExpression="{{resultExpression}}"{{/resultExpression}}{{/isMCP}} description="{{description}}"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<tools>
{{#tools}}
{{{.}}}
{{/tools}}
</tools>
Loading