This is an automated email from the ASF dual-hosted git repository. fmariani pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit 013f0d8a53ad86e9744e471f09d0112c7c54412c Author: Croway <[email protected]> AuthorDate: Wed Mar 11 13:36:15 2026 +0100 Expose MCP Everything with SSE --- .../services/McpEverythingSseInfraService.java | 36 +++++++ ...McpEverythingSseLocalContainerInfraService.java | 118 +++++++++++++++++++++ .../services/McpEverythingSseServiceFactory.java | 39 +++++++ 3 files changed, 193 insertions(+) diff --git a/test-infra/camel-test-infra-mcp-everything/src/main/java/org/apache/camel/test/infra/mcp/everything/services/McpEverythingSseInfraService.java b/test-infra/camel-test-infra-mcp-everything/src/main/java/org/apache/camel/test/infra/mcp/everything/services/McpEverythingSseInfraService.java new file mode 100644 index 000000000000..76e01061460a --- /dev/null +++ b/test-infra/camel-test-infra-mcp-everything/src/main/java/org/apache/camel/test/infra/mcp/everything/services/McpEverythingSseInfraService.java @@ -0,0 +1,36 @@ +/* + * 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.test.infra.mcp.everything.services; + +import org.apache.camel.test.infra.common.services.InfrastructureService; + +/** + * Test infra service for the MCP Everything Server running in SSE transport mode. + */ +public interface McpEverythingSseInfraService extends InfrastructureService { + + String host(); + + int port(); + + /** + * Returns the SSE endpoint URL for connecting an MCP client. + */ + default String sseUrl() { + return String.format("http://%s:%d/sse", host(), port()); + } +} diff --git a/test-infra/camel-test-infra-mcp-everything/src/main/java/org/apache/camel/test/infra/mcp/everything/services/McpEverythingSseLocalContainerInfraService.java b/test-infra/camel-test-infra-mcp-everything/src/main/java/org/apache/camel/test/infra/mcp/everything/services/McpEverythingSseLocalContainerInfraService.java new file mode 100644 index 000000000000..e6e0a2197ed5 --- /dev/null +++ b/test-infra/camel-test-infra-mcp-everything/src/main/java/org/apache/camel/test/infra/mcp/everything/services/McpEverythingSseLocalContainerInfraService.java @@ -0,0 +1,118 @@ +/* + * 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.test.infra.mcp.everything.services; + +import java.time.Duration; + +import org.apache.camel.spi.annotations.InfraService; +import org.apache.camel.test.infra.common.LocalPropertyResolver; +import org.apache.camel.test.infra.common.services.ContainerEnvironmentUtil; +import org.apache.camel.test.infra.common.services.ContainerService; +import org.apache.camel.test.infra.mcp.everything.common.McpEverythingProperties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.wait.strategy.Wait; +import org.testcontainers.utility.DockerImageName; + +/** + * Runs the MCP Everything Server as a Docker container in SSE transport mode, exposing port 3001. + */ +@InfraService(service = McpEverythingSseInfraService.class, + description = "MCP Everything Server (SSE transport)", + serviceAlias = { "mcp-everything-sse" }) +public class McpEverythingSseLocalContainerInfraService + implements McpEverythingSseInfraService, ContainerService<GenericContainer<?>> { + + private static final Logger LOG = LoggerFactory.getLogger(McpEverythingSseLocalContainerInfraService.class); + + private static final String DEFAULT_CONTAINER = "tzolov/mcp-everything-server:v3"; + + private final GenericContainer<?> container; + + public McpEverythingSseLocalContainerInfraService() { + this(LocalPropertyResolver.getProperty(McpEverythingSseLocalContainerInfraService.class, + McpEverythingProperties.MCP_EVERYTHING_CONTAINER)); + } + + public McpEverythingSseLocalContainerInfraService(String imageName) { + container = initContainer(imageName); + String name = ContainerEnvironmentUtil.containerName(this.getClass()); + if (name != null) { + container.withCreateContainerCmdModifier(cmd -> cmd.withName(name)); + } + } + + public McpEverythingSseLocalContainerInfraService(GenericContainer<?> container) { + this.container = container; + } + + protected GenericContainer<?> initContainer(String imageName) { + String image = imageName != null ? imageName : DEFAULT_CONTAINER; + + class TestInfraMcpEverythingSseContainer extends GenericContainer<TestInfraMcpEverythingSseContainer> { + public TestInfraMcpEverythingSseContainer(boolean fixedPort) { + super(DockerImageName.parse(image)); + + withCommand("node", "dist/index.js", "sse"); + waitingFor(Wait.forLogMessage(".*(?:listening on port|Server is running on port).*\\n", 1)) + .withStartupTimeout(Duration.ofMinutes(2L)); + + ContainerEnvironmentUtil.configurePort(this, fixedPort, McpEverythingProperties.DEFAULT_PORT); + } + } + + return new TestInfraMcpEverythingSseContainer(ContainerEnvironmentUtil.isFixedPort(this.getClass())); + } + + @Override + public void registerProperties() { + System.setProperty(McpEverythingProperties.MCP_EVERYTHING_URL, sseUrl()); + System.setProperty(McpEverythingProperties.MCP_EVERYTHING_HOST, host()); + System.setProperty(McpEverythingProperties.MCP_EVERYTHING_PORT, String.valueOf(port())); + } + + @Override + public void initialize() { + LOG.info("Trying to start the MCP Everything Server container (SSE mode)"); + container.start(); + + registerProperties(); + LOG.info("MCP Everything Server (SSE) running at {}", sseUrl()); + } + + @Override + public void shutdown() { + LOG.info("Stopping the MCP Everything Server container (SSE mode)"); + container.stop(); + } + + @Override + public GenericContainer<?> getContainer() { + return container; + } + + @Override + public String host() { + return container.getHost(); + } + + @Override + public int port() { + return container.getMappedPort(McpEverythingProperties.DEFAULT_PORT); + } +} diff --git a/test-infra/camel-test-infra-mcp-everything/src/main/java/org/apache/camel/test/infra/mcp/everything/services/McpEverythingSseServiceFactory.java b/test-infra/camel-test-infra-mcp-everything/src/main/java/org/apache/camel/test/infra/mcp/everything/services/McpEverythingSseServiceFactory.java new file mode 100644 index 000000000000..a8bca0e5e018 --- /dev/null +++ b/test-infra/camel-test-infra-mcp-everything/src/main/java/org/apache/camel/test/infra/mcp/everything/services/McpEverythingSseServiceFactory.java @@ -0,0 +1,39 @@ +/* + * 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.test.infra.mcp.everything.services; + +import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; + +public final class McpEverythingSseServiceFactory { + + private McpEverythingSseServiceFactory() { + } + + public static SimpleTestServiceBuilder<McpEverythingSseService> builder() { + return new SimpleTestServiceBuilder<>("mcp-everything-sse"); + } + + public static McpEverythingSseService createService() { + return builder() + .addLocalMapping(McpEverythingSseLocalContainerService::new) + .build(); + } + + public static class McpEverythingSseLocalContainerService extends McpEverythingSseLocalContainerInfraService + implements McpEverythingSseService { + } +}
