This is an automated email from the ASF dual-hosted git repository.
ldemasi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 4f82de7fd6d0 CAMEL-23178: [camel-jbang-mcp] Allow configuring
additional Maven repositories for catalog resolution
4f82de7fd6d0 is described below
commit 4f82de7fd6d05366d99f8c73fe0e958a611eff07
Author: Luigi De Masi <[email protected]>
AuthorDate: Thu Mar 12 09:33:12 2026 +0100
CAMEL-23178: [camel-jbang-mcp] Allow configuring additional Maven
repositories for catalog resolution
---
.../dsl/jbang/core/commands/mcp/CatalogTools.java | 17 +++--
.../jbang/core/commands/mcp/CatalogToolsTest.java | 86 ++++++++++++++++++++++
2 files changed, 98 insertions(+), 5 deletions(-)
diff --git
a/dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/CatalogTools.java
b/dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/CatalogTools.java
index bab82da3b9ed..02baeb9bb801 100644
---
a/dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/CatalogTools.java
+++
b/dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/CatalogTools.java
@@ -18,6 +18,7 @@ package org.apache.camel.dsl.jbang.core.commands.mcp;
import java.util.ArrayList;
import java.util.List;
+import java.util.Optional;
import java.util.stream.Collectors;
import jakarta.enterprise.context.ApplicationScoped;
@@ -33,6 +34,7 @@ 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.eclipse.microprofile.config.inject.ConfigProperty;
/**
* MCP Tools for querying the Camel Catalog using Quarkus MCP Server.
@@ -40,6 +42,9 @@ import org.apache.camel.tooling.model.LanguageModel;
@ApplicationScoped
public class CatalogTools {
+ @ConfigProperty(name = "camel.catalog.repos")
+ Optional<String> catalogRepos;
+
private CamelCatalog catalog;
public CatalogTools() {
@@ -307,24 +312,26 @@ public class CatalogTools {
// Catalog loading
private CamelCatalog loadCatalog(String runtime, String camelVersion)
throws Exception {
+ String repos = catalogRepos.orElse(null);
+
// If a specific version is requested, load that version's catalog
if (camelVersion != null && !camelVersion.isBlank()) {
RuntimeType runtimeType = resolveRuntime(runtime);
if (runtimeType == RuntimeType.springBoot) {
- return CatalogLoader.loadSpringBootCatalog(null, camelVersion,
true);
+ return CatalogLoader.loadSpringBootCatalog(repos,
camelVersion, true);
} else if (runtimeType == RuntimeType.quarkus) {
- return CatalogLoader.loadQuarkusCatalog(null, camelVersion,
null, true);
+ return CatalogLoader.loadQuarkusCatalog(repos, camelVersion,
null, true);
} else {
- return CatalogLoader.loadCatalog(null, camelVersion, true);
+ return CatalogLoader.loadCatalog(repos, camelVersion, true);
}
}
// No specific version, use runtime-specific catalog or default
RuntimeType runtimeType = resolveRuntime(runtime);
if (runtimeType == RuntimeType.springBoot) {
- return CatalogLoader.loadSpringBootCatalog(null, null, true);
+ return CatalogLoader.loadSpringBootCatalog(repos, null, true);
} else if (runtimeType == RuntimeType.quarkus) {
- return CatalogLoader.loadQuarkusCatalog(null,
RuntimeType.QUARKUS_VERSION, null, true);
+ return CatalogLoader.loadQuarkusCatalog(repos,
RuntimeType.QUARKUS_VERSION, null, true);
}
return catalog;
diff --git
a/dsl/camel-jbang/camel-jbang-mcp/src/test/java/org/apache/camel/dsl/jbang/core/commands/mcp/CatalogToolsTest.java
b/dsl/camel-jbang/camel-jbang-mcp/src/test/java/org/apache/camel/dsl/jbang/core/commands/mcp/CatalogToolsTest.java
new file mode 100644
index 000000000000..1a7283cac144
--- /dev/null
+++
b/dsl/camel-jbang/camel-jbang-mcp/src/test/java/org/apache/camel/dsl/jbang/core/commands/mcp/CatalogToolsTest.java
@@ -0,0 +1,86 @@
+/*
+ * 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.Optional;
+
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+class CatalogToolsTest {
+
+ private CatalogTools createTools(String repos) {
+ CatalogTools tools = new CatalogTools();
+ tools.catalogRepos = Optional.ofNullable(repos);
+ return tools;
+ }
+
+ @Test
+ void defaultCatalogWithNoRepos() {
+ CatalogTools tools = createTools(null);
+
+ // Should use the default catalog (no version specified, no repos)
+ CatalogTools.ComponentListResult result =
tools.camel_catalog_components(null, null, 5, null, null);
+
+ assertThat(result).isNotNull();
+ assertThat(result.camelVersion()).isNotNull();
+ }
+
+ @Test
+ void defaultCatalogWithEmptyRepos() {
+ CatalogTools tools = createTools("");
+
+ CatalogTools.ComponentListResult result =
tools.camel_catalog_components(null, null, 5, null, null);
+
+ assertThat(result).isNotNull();
+ assertThat(result.camelVersion()).isNotNull();
+ }
+
+ @Test
+ void catalogWithExtraRepos() {
+ CatalogTools tools =
createTools("https://maven.repository.redhat.com/ga/");
+
+ // Should still work — the extra repo is added but default catalog
doesn't need it
+ CatalogTools.ComponentListResult result =
tools.camel_catalog_components(null, null, 5, null, null);
+
+ assertThat(result).isNotNull();
+ assertThat(result.camelVersion()).isNotNull();
+ }
+
+ @Test
+ void catalogWithMultipleRepos() {
+ CatalogTools tools = createTools(
+
"https://maven.repository.redhat.com/ga/,https://repository.jboss.org/nexus/content/groups/public/");
+
+ CatalogTools.ComponentListResult result =
tools.camel_catalog_components(null, null, 5, null, null);
+
+ assertThat(result).isNotNull();
+ assertThat(result.camelVersion()).isNotNull();
+ }
+
+ @Test
+ void componentDocWithRepos() {
+ CatalogTools tools =
createTools("https://maven.repository.redhat.com/ga/");
+
+ // timer is a core component, should always be available
+ CatalogTools.ComponentDetailResult result =
tools.camel_catalog_component_doc("timer", null, null);
+
+ assertThat(result).isNotNull();
+ assertThat(result.name()).isEqualTo("timer");
+ }
+}