You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "oscerd (via GitHub)" <gi...@apache.org> on 2026/01/22 08:45:48 UTC

[PR] CAMEL-22886 - Camel-Jbang: Add an MCP module [camel]

oscerd opened a new pull request, #20976:
URL: https://github.com/apache/camel/pull/20976

   # Description
   
   - Add new Camel MCP (Model Context Protocol) module for AI assistant integration
   - Provides tools for querying the Camel Catalog (components, EIPs, data formats, languages)
   - Includes route validation and route explanation capabilities
   - Built on Quarkus MCP Server with LangChain4j integration for LLM support
   
   To add this we have two way:
   
   - Pure java
   ```
   {
       "mcpServers": {
         "camel": {
           "command": "java",
           "args": [
             "-jar",
             "/path/to/camel/dsl/camel-jbang/camel-jbang-mcp/target/quarkus-app/quarkus-run.jar"
           ],
           "env": {
             "QUARKUS_LANGCHAIN4J_OLLAMA_BASE_URL": "http://localhost:11434",
             "QUARKUS_LANGCHAIN4J_OLLAMA_CHAT_MODEL_MODEL_ID": "llama3.2"
           }
         }
       }
     }
   ```
   
   
   - jbang
   
   ```
     {
       "mcpServers": {
         "camel": {
           "command": "jbang",
           "args": [
             "org.apache.camel:camel-jbang-mcp:4.18.0-SNAPSHOT:runner"
           ],
           "env": {
             "QUARKUS_LANGCHAIN4J_OLLAMA_BASE_URL": "http://localhost:11434",
             "QUARKUS_LANGCHAIN4J_OLLAMA_CHAT_MODEL_MODEL_ID": "llama3.2"
           }
         }
       }
     }
   ```
   
   Also any OpenAI compatible endpoint could be used
   
   ```
     {
       "mcpServers": {
         "camel": {
           "command": "java",
           "args": [
             "-jar",
             "/path/to/camel/dsl/camel-jbang/camel-jbang-mcp/target/quarkus-app/quarkus-run.jar"
           ],
           "env": {
             "QUARKUS_LANGCHAIN4J_OPENAI_API_KEY": "your-openai-api-key",
             "QUARKUS_LANGCHAIN4J_OPENAI_CHAT_MODEL_MODEL_NAME": "gpt-4"
           }
         }
       }
     }
   ```
   
   The tools for the moment:
   
     | Tool                        | Description                                        |
     |-----------------------------|----------------------------------------------------|
     | camel_catalog_components    | List Camel components with filtering               |
     | camel_catalog_component_doc | Get detailed component documentation               |
     | camel_catalog_dataformats   | List data formats (json, xml, csv, etc.)           |
     | camel_catalog_languages     | List expression languages (simple, jsonpath, etc.) |
     | camel_catalog_eips          | List Enterprise Integration Patterns               |
     | camel_catalog_eip_doc       | Get detailed EIP documentation                     |
     | camel_validate_route        | Validate endpoint URIs and routes                  |
     | camel_explain_route         | Route explanation                       |
   
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it).
   
   <!--
   # *Note*: trivial changes like, typos, minor documentation fixes and other small items do not require a JIRA issue. In this case your pull request should address just this issue, without pulling in other changes.
   -->
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful subject line and body.
   
   <!--
   If you're unsure, you can format the pull request title like `[CAMEL-XXX] Fixes bug in camel-file component`, where you replace `CAMEL-XXX` with the appropriate JIRA issue.
   -->
   
   - [x] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes.
   
   <!--
   You can run the aforementioned command in your module so that the build auto-formats your code. This will also be verified as part of the checks and your PR may be rejected if if there are uncommited changes after running `mvn clean install -DskipTests`.
   
   You can learn more about the contribution guidelines at https://github.com/apache/camel/blob/main/CONTRIBUTING.md
   -->
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22886 - Camel-Jbang: Add an MCP module [camel]

Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd commented on code in PR #20976:
URL: https://github.com/apache/camel/pull/20976#discussion_r2715970361


##########
dsl/camel-jbang/camel-jbang-mcp/src/generated/resources/META-INF/services/org/apache/camel/camel-jbang-plugin/camel-jbang-plugin-mcp:
##########
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.dsl.jbang.core.commands.mcp.McpPlugin

Review Comment:
   This is a leftover. I'm removing it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22886 - Camel-Jbang: Add an MCP module [camel]

Posted by "Croway (via GitHub)" <gi...@apache.org>.
Croway commented on code in PR #20976:
URL: https://github.com/apache/camel/pull/20976#discussion_r2716331330


##########
dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/CatalogTools.java:
##########
@@ -0,0 +1,363 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.mcp;
+
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.quarkiverse.mcp.server.Tool;
+import io.quarkiverse.mcp.server.ToolArg;
+import io.quarkiverse.mcp.server.ToolCallException;
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.catalog.DefaultCamelCatalog;
+import org.apache.camel.tooling.model.ComponentModel;
+import org.apache.camel.tooling.model.DataFormatModel;
+import org.apache.camel.tooling.model.EipModel;
+import org.apache.camel.tooling.model.LanguageModel;
+import org.apache.camel.util.json.JsonArray;
+import org.apache.camel.util.json.JsonObject;
+
+/**
+ * MCP Tools for querying the Camel Catalog using Quarkus MCP Server.
+ */
+@ApplicationScoped
+public class CatalogTools {
+
+    private final CamelCatalog catalog;
+
+    @Inject
+    ObjectMapper mapper;
+
+    public CatalogTools() {
+        this.catalog = new DefaultCamelCatalog();
+    }
+
+    /**
+     * Tool to list available Camel components.
+     */
+    @Tool(description = "List available Camel components from the catalog. " +
+                        "Returns component name, description, and labels. " +
+                        "Use filter to search by name, label to filter by category.")
+    public String camel_catalog_components(
+            @ToolArg(description = "Filter components by name (case-insensitive substring match)") String filter,
+            @ToolArg(description = "Filter by category label (e.g., cloud, messaging, database, file)") String label,
+            @ToolArg(description = "Maximum number of results to return (default: 50)") Integer limit) {
+
+        int maxResults = limit != null ? limit : 50;
+
+        try {
+            List<Map<String, Object>> components = catalog.findComponentNames().stream()
+                    .map(catalog::componentModel)
+                    .filter(m -> m != null)
+                    .filter(m -> matchesFilter(m.getScheme(), m.getTitle(), m.getDescription(), filter))
+                    .filter(m -> matchesLabel(m.getLabel(), label))
+                    .limit(maxResults)
+                    .map(this::componentToMap)
+                    .collect(Collectors.toList());
+
+            JsonObject resultJson = new JsonObject();

Review Comment:
   ok
   
   <img width="632" height="800" alt="image" src="https://github.com/user-attachments/assets/49ff305e-ce74-4d70-a20c-a7292287b39c" />
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22886 - Camel-Jbang: Add an MCP module [camel]

Posted by "christophd (via GitHub)" <gi...@apache.org>.
christophd commented on code in PR #20976:
URL: https://github.com/apache/camel/pull/20976#discussion_r2715940467


##########
dsl/camel-jbang/camel-jbang-mcp/pom.xml:
##########
@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>camel-jbang-parent</artifactId>
+        <version>4.18.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>camel-jbang-mcp</artifactId>
+    <packaging>jar</packaging>
+
+    <name>Camel :: JBang :: MCP</name>
+    <description>Camel JBang MCP (Model Context Protocol) Server using Quarkus</description>
+
+    <properties>
+        <firstVersion>4.18.0</firstVersion>
+        <label>jbang,mcp,ai</label>
+        <supportLevel>Preview</supportLevel>
+        <camel-prepare-component>false</camel-prepare-component>
+        <quarkus-mcp-server-version>1.2.0</quarkus-mcp-server-version>
+        <quarkus.platform.version>3.30.6</quarkus.platform.version>
+        <!-- Build uber-jar for easy JBang execution -->
+        <quarkus.package.jar.type>uber-jar</quarkus.package.jar.type>
+    </properties>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>io.quarkus.platform</groupId>
+                <artifactId>quarkus-bom</artifactId>
+                <version>${quarkus.platform.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <dependencies>
+        <!-- Quarkus MCP Server with STDIO transport -->
+        <dependency>
+            <groupId>io.quarkiverse.mcp</groupId>
+            <artifactId>quarkus-mcp-server-stdio</artifactId>

Review Comment:
   Do we plan to make this also available as a remote MCP server that listens on a port for incoming requests?



##########
dsl/camel-jbang/camel-jbang-mcp/src/generated/resources/META-INF/services/org/apache/camel/camel-jbang-plugin/camel-jbang-plugin-mcp:
##########
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.dsl.jbang.core.commands.mcp.McpPlugin

Review Comment:
   I do not see this in the commit, I guess this will be added in a 2nd iteration?



##########
dsl/camel-jbang/pom.xml:
##########
@@ -37,6 +37,7 @@
         <module>camel-jbang-console</module>
         <module>camel-jbang-core</module>
         <module>camel-jbang-main</module>
+        <module>camel-jbang-mcp</module>

Review Comment:
   if its a Camel JBang plugin I'd suggest to use `camel-jbang-plugin-mcp`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22886 - Camel-Jbang: Add an MCP module [camel]

Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd commented on code in PR #20976:
URL: https://github.com/apache/camel/pull/20976#discussion_r2715992480


##########
dsl/camel-jbang/pom.xml:
##########
@@ -37,6 +37,7 @@
         <module>camel-jbang-console</module>
         <module>camel-jbang-core</module>
         <module>camel-jbang-main</module>
+        <module>camel-jbang-mcp</module>

Review Comment:
   In reality is not even a plugin, because this could really live alone.. but for naming convention it makes sense to call it plugin-mcp
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22886 - Camel-Jbang: Add an MCP module [camel]

Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd commented on code in PR #20976:
URL: https://github.com/apache/camel/pull/20976#discussion_r2716354822


##########
dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/CatalogTools.java:
##########
@@ -0,0 +1,363 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.mcp;
+
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.quarkiverse.mcp.server.Tool;
+import io.quarkiverse.mcp.server.ToolArg;
+import io.quarkiverse.mcp.server.ToolCallException;
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.catalog.DefaultCamelCatalog;
+import org.apache.camel.tooling.model.ComponentModel;
+import org.apache.camel.tooling.model.DataFormatModel;
+import org.apache.camel.tooling.model.EipModel;
+import org.apache.camel.tooling.model.LanguageModel;
+import org.apache.camel.util.json.JsonArray;
+import org.apache.camel.util.json.JsonObject;
+
+/**
+ * MCP Tools for querying the Camel Catalog using Quarkus MCP Server.
+ */
+@ApplicationScoped
+public class CatalogTools {
+
+    private final CamelCatalog catalog;
+
+    @Inject
+    ObjectMapper mapper;
+
+    public CatalogTools() {
+        this.catalog = new DefaultCamelCatalog();
+    }
+
+    /**
+     * Tool to list available Camel components.
+     */
+    @Tool(description = "List available Camel components from the catalog. " +
+                        "Returns component name, description, and labels. " +
+                        "Use filter to search by name, label to filter by category.")
+    public String camel_catalog_components(
+            @ToolArg(description = "Filter components by name (case-insensitive substring match)") String filter,
+            @ToolArg(description = "Filter by category label (e.g., cloud, messaging, database, file)") String label,
+            @ToolArg(description = "Maximum number of results to return (default: 50)") Integer limit) {
+
+        int maxResults = limit != null ? limit : 50;
+
+        try {
+            List<Map<String, Object>> components = catalog.findComponentNames().stream()
+                    .map(catalog::componentModel)
+                    .filter(m -> m != null)
+                    .filter(m -> matchesFilter(m.getScheme(), m.getTitle(), m.getDescription(), filter))
+                    .filter(m -> matchesLabel(m.getLabel(), label))
+                    .limit(maxResults)
+                    .map(this::componentToMap)
+                    .collect(Collectors.toList());
+
+            JsonObject resultJson = new JsonObject();

Review Comment:
   ![magda](https://github.com/user-attachments/assets/00c2546b-db3d-473a-a120-a6713fd121cf)
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22886 - Camel-Jbang: Add an MCP module [camel]

Posted by "Croway (via GitHub)" <gi...@apache.org>.
Croway commented on code in PR #20976:
URL: https://github.com/apache/camel/pull/20976#discussion_r2716297448


##########
dsl/camel-jbang/camel-jbang-mcp/pom.xml:
##########
@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>camel-jbang-parent</artifactId>

Review Comment:
   Why is this project under camel jbang? it does not need camel-jbang at all, it uses the catalog



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22886 - Camel-Jbang: Add an MCP module [camel]

Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd merged PR #20976:
URL: https://github.com/apache/camel/pull/20976


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22886 - Camel-Jbang: Add an MCP module [camel]

Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd commented on code in PR #20976:
URL: https://github.com/apache/camel/pull/20976#discussion_r2716320228


##########
dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/ExplainTools.java:
##########
@@ -0,0 +1,212 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.mcp;
+
+import java.util.Arrays;
+import java.util.List;
+
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+
+import dev.langchain4j.model.chat.ChatModel;
+import io.quarkiverse.mcp.server.Tool;
+import io.quarkiverse.mcp.server.ToolArg;
+import io.quarkiverse.mcp.server.ToolCallException;
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.catalog.DefaultCamelCatalog;
+import org.apache.camel.tooling.model.ComponentModel;
+import org.apache.camel.tooling.model.EipModel;
+import org.apache.camel.util.json.JsonObject;
+
+/**
+ * MCP Tool for explaining Camel routes using AI/LLM services.
+ * <p>
+ * The LLM is configured at the application level via application.properties. Supported configurations include:
+ * <ul>
+ * <li>Ollama: quarkus.langchain4j.ollama.*</li>
+ * <li>OpenAI: quarkus.langchain4j.openai.*</li>
+ * </ul>
+ */
+@ApplicationScoped
+public class ExplainTools {

Review Comment:
   Yes, this is because it is doing like the explain command from the CLI, but effectively it doesn't make sense.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22886 - Camel-Jbang: Add an MCP module [camel]

Posted by "Croway (via GitHub)" <gi...@apache.org>.
Croway commented on code in PR #20976:
URL: https://github.com/apache/camel/pull/20976#discussion_r2716300454


##########
dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/CatalogTools.java:
##########
@@ -0,0 +1,363 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.mcp;
+
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.quarkiverse.mcp.server.Tool;
+import io.quarkiverse.mcp.server.ToolArg;
+import io.quarkiverse.mcp.server.ToolCallException;
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.catalog.DefaultCamelCatalog;
+import org.apache.camel.tooling.model.ComponentModel;
+import org.apache.camel.tooling.model.DataFormatModel;
+import org.apache.camel.tooling.model.EipModel;
+import org.apache.camel.tooling.model.LanguageModel;
+import org.apache.camel.util.json.JsonArray;
+import org.apache.camel.util.json.JsonObject;
+
+/**
+ * MCP Tools for querying the Camel Catalog using Quarkus MCP Server.
+ */
+@ApplicationScoped
+public class CatalogTools {
+
+    private final CamelCatalog catalog;
+
+    @Inject
+    ObjectMapper mapper;
+
+    public CatalogTools() {
+        this.catalog = new DefaultCamelCatalog();
+    }
+
+    /**
+     * Tool to list available Camel components.
+     */
+    @Tool(description = "List available Camel components from the catalog. " +
+                        "Returns component name, description, and labels. " +
+                        "Use filter to search by name, label to filter by category.")
+    public String camel_catalog_components(
+            @ToolArg(description = "Filter components by name (case-insensitive substring match)") String filter,
+            @ToolArg(description = "Filter by category label (e.g., cloud, messaging, database, file)") String label,
+            @ToolArg(description = "Maximum number of results to return (default: 50)") Integer limit) {
+
+        int maxResults = limit != null ? limit : 50;
+
+        try {
+            List<Map<String, Object>> components = catalog.findComponentNames().stream()
+                    .map(catalog::componentModel)
+                    .filter(m -> m != null)
+                    .filter(m -> matchesFilter(m.getScheme(), m.getTitle(), m.getDescription(), filter))
+                    .filter(m -> matchesLabel(m.getLabel(), label))
+                    .limit(maxResults)
+                    .map(this::componentToMap)
+                    .collect(Collectors.toList());
+
+            JsonObject resultJson = new JsonObject();

Review Comment:
   it might be me.. why not use pojos instead? and let quarkus + jackson do the marshal?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22886 - Camel-Jbang: Add an MCP module [camel]

Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd commented on code in PR #20976:
URL: https://github.com/apache/camel/pull/20976#discussion_r2715971877


##########
dsl/camel-jbang/camel-jbang-mcp/pom.xml:
##########
@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>camel-jbang-parent</artifactId>
+        <version>4.18.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>camel-jbang-mcp</artifactId>
+    <packaging>jar</packaging>
+
+    <name>Camel :: JBang :: MCP</name>
+    <description>Camel JBang MCP (Model Context Protocol) Server using Quarkus</description>
+
+    <properties>
+        <firstVersion>4.18.0</firstVersion>
+        <label>jbang,mcp,ai</label>
+        <supportLevel>Preview</supportLevel>
+        <camel-prepare-component>false</camel-prepare-component>
+        <quarkus-mcp-server-version>1.2.0</quarkus-mcp-server-version>
+        <quarkus.platform.version>3.30.6</quarkus.platform.version>
+        <!-- Build uber-jar for easy JBang execution -->
+        <quarkus.package.jar.type>uber-jar</quarkus.package.jar.type>
+    </properties>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>io.quarkus.platform</groupId>
+                <artifactId>quarkus-bom</artifactId>
+                <version>${quarkus.platform.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <dependencies>
+        <!-- Quarkus MCP Server with STDIO transport -->
+        <dependency>
+            <groupId>io.quarkiverse.mcp</groupId>
+            <artifactId>quarkus-mcp-server-stdio</artifactId>

Review Comment:
   yes, we do. This was only the first iteration to make it available for review and testing.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22886 - Camel-Jbang: Add an MCP module [camel]

Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd commented on code in PR #20976:
URL: https://github.com/apache/camel/pull/20976#discussion_r2716306063


##########
dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/CatalogTools.java:
##########
@@ -0,0 +1,363 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.mcp;
+
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.quarkiverse.mcp.server.Tool;
+import io.quarkiverse.mcp.server.ToolArg;
+import io.quarkiverse.mcp.server.ToolCallException;
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.catalog.DefaultCamelCatalog;
+import org.apache.camel.tooling.model.ComponentModel;
+import org.apache.camel.tooling.model.DataFormatModel;
+import org.apache.camel.tooling.model.EipModel;
+import org.apache.camel.tooling.model.LanguageModel;
+import org.apache.camel.util.json.JsonArray;
+import org.apache.camel.util.json.JsonObject;
+
+/**
+ * MCP Tools for querying the Camel Catalog using Quarkus MCP Server.
+ */
+@ApplicationScoped
+public class CatalogTools {
+
+    private final CamelCatalog catalog;
+
+    @Inject
+    ObjectMapper mapper;
+
+    public CatalogTools() {
+        this.catalog = new DefaultCamelCatalog();
+    }
+
+    /**
+     * Tool to list available Camel components.
+     */
+    @Tool(description = "List available Camel components from the catalog. " +
+                        "Returns component name, description, and labels. " +
+                        "Use filter to search by name, label to filter by category.")
+    public String camel_catalog_components(
+            @ToolArg(description = "Filter components by name (case-insensitive substring match)") String filter,
+            @ToolArg(description = "Filter by category label (e.g., cloud, messaging, database, file)") String label,
+            @ToolArg(description = "Maximum number of results to return (default: 50)") Integer limit) {
+
+        int maxResults = limit != null ? limit : 50;
+
+        try {
+            List<Map<String, Object>> components = catalog.findComponentNames().stream()
+                    .map(catalog::componentModel)
+                    .filter(m -> m != null)
+                    .filter(m -> matchesFilter(m.getScheme(), m.getTitle(), m.getDescription(), filter))
+                    .filter(m -> matchesLabel(m.getLabel(), label))
+                    .limit(maxResults)
+                    .map(this::componentToMap)
+                    .collect(Collectors.toList());
+
+            JsonObject resultJson = new JsonObject();

Review Comment:
   This way is a bit more manageable in my opinion



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22886 - Camel-Jbang: Add an MCP module [camel]

Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd commented on code in PR #20976:
URL: https://github.com/apache/camel/pull/20976#discussion_r2716318133


##########
dsl/camel-jbang/camel-jbang-mcp/pom.xml:
##########
@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>camel-jbang-parent</artifactId>

Review Comment:
   Because it is mimicking jbang commands, so in terms of logical position it should stay in jbang



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22886 - Camel-Jbang: Add an MCP module [camel]

Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd commented on code in PR #20976:
URL: https://github.com/apache/camel/pull/20976#discussion_r2716670838


##########
dsl/camel-jbang/camel-jbang-mcp/pom.xml:
##########
@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>camel-jbang-parent</artifactId>

Review Comment:
   Not it's using jbang



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22886 - Camel-Jbang: Add an MCP module [camel]

Posted by "Croway (via GitHub)" <gi...@apache.org>.
Croway commented on code in PR #20976:
URL: https://github.com/apache/camel/pull/20976#discussion_r2716287468


##########
dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/ExplainTools.java:
##########
@@ -0,0 +1,212 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.mcp;
+
+import java.util.Arrays;
+import java.util.List;
+
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+
+import dev.langchain4j.model.chat.ChatModel;
+import io.quarkiverse.mcp.server.Tool;
+import io.quarkiverse.mcp.server.ToolArg;
+import io.quarkiverse.mcp.server.ToolCallException;
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.catalog.DefaultCamelCatalog;
+import org.apache.camel.tooling.model.ComponentModel;
+import org.apache.camel.tooling.model.EipModel;
+import org.apache.camel.util.json.JsonObject;
+
+/**
+ * MCP Tool for explaining Camel routes using AI/LLM services.
+ * <p>
+ * The LLM is configured at the application level via application.properties. Supported configurations include:
+ * <ul>
+ * <li>Ollama: quarkus.langchain4j.ollama.*</li>
+ * <li>OpenAI: quarkus.langchain4j.openai.*</li>
+ * </ul>
+ */
+@ApplicationScoped
+public class ExplainTools {

Review Comment:
   Now I do understand why the ollama dependency is needed, but I think this is wrong, or I am missing something (most probably).
   
   This MCP is used by an LLM (let's say gpt), therefore the sequence diagram would look like:
   
   `gpt -> call explain tools -> use ollama to explain -> back to gpt`
   
   The caller LLM is able to (or at least should be) explain the route, maybe the explain tools may provide some additional information only?
   
   `gpt -> explain tool -> back to gpt with additional context`
   
   I do not think an MCP Server should depend on an LLM implementation (ChatModel) 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22886 - Camel-Jbang: Add an MCP module [camel]

Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd commented on code in PR #20976:
URL: https://github.com/apache/camel/pull/20976#discussion_r2716017095


##########
dsl/camel-jbang/pom.xml:
##########
@@ -37,6 +37,7 @@
         <module>camel-jbang-console</module>
         <module>camel-jbang-core</module>
         <module>camel-jbang-main</module>
+        <module>camel-jbang-mcp</module>

Review Comment:
   So I'll leave it as camel-jbang-mcp, it's not a plugin..



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org