Skip to content
Closed
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
<kotlin.compiler.jvmTarget>${java.version}</kotlin.compiler.jvmTarget>

<!-- production dependencies -->
<spring-boot.version>3.5.0</spring-boot.version>
<spring-boot.version>3.5.1</spring-boot.version>
<ST4.version>4.3.4</ST4.version>
<azure-open-ai-client.version>1.0.0-beta.16</azure-open-ai-client.version>
<jtokkit.version>1.1.0</jtokkit.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ The following service connection factories are provided in the `spring-ai-spring
| `ChromaConnectionDetails`
| Containers of type `ChromaDBContainer`

| `McpSseClientConnectionDetails`
| Containers of type `DockerMcpGatewayContainer`

| `MilvusServiceClientConnectionDetails`
| Containers of type `MilvusContainer`

Expand Down
15 changes: 15 additions & 0 deletions spring-ai-spring-boot-testcontainers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,20 @@
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-autoconfigure-mcp-client-httpclient</artifactId>
<version>${project.version}</version>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-autoconfigure-mcp-client-webflux</artifactId>
<version>${project.version}</version>
<optional>true</optional>
</dependency>

<!-- production dependencies -->

<dependency>
Expand Down Expand Up @@ -239,6 +253,7 @@
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.21.3</version>
<optional>true</optional>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright 2023-2025 the original author or authors.
*
* Licensed 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
*
* https://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.springframework.ai.testcontainers.service.connection.docker;

import java.util.Map;

import org.testcontainers.containers.DockerMcpGatewayContainer;

import org.springframework.ai.mcp.client.common.autoconfigure.McpSseClientConnectionDetails;
import org.springframework.ai.mcp.client.common.autoconfigure.properties.McpSseClientProperties;
import org.springframework.boot.testcontainers.service.connection.ContainerConnectionDetailsFactory;
import org.springframework.boot.testcontainers.service.connection.ContainerConnectionSource;

/**
* @author Eddú Meléndez
*/
class DockerMcpGatewayContainerConnectionDetailsFactory
extends ContainerConnectionDetailsFactory<DockerMcpGatewayContainer, McpSseClientConnectionDetails> {

@Override
public McpSseClientConnectionDetails getContainerConnectionDetails(
ContainerConnectionSource<DockerMcpGatewayContainer> source) {
return new DockerMcpGatewayContainerConnectionDetails(source);
}

/**
* {@link McpSseClientConnectionDetails} backed by a
* {@link ContainerConnectionSource}.
*/
private static final class DockerMcpGatewayContainerConnectionDetails
extends ContainerConnectionDetails<DockerMcpGatewayContainer> implements McpSseClientConnectionDetails {

private DockerMcpGatewayContainerConnectionDetails(
ContainerConnectionSource<DockerMcpGatewayContainer> source) {
super(source);
}

@Override
public Map<String, McpSseClientProperties.SseParameters> getConnections() {
return Map.of("gateway", new McpSseClientProperties.SseParameters(getContainer().getEndpoint(), "/sse"));
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#
org.springframework.boot.autoconfigure.service.connection.ConnectionDetailsFactory=\
org.springframework.ai.testcontainers.service.connection.chroma.ChromaContainerConnectionDetailsFactory,\
org.springframework.ai.testcontainers.service.connection.docker.DockerMcpGatewayContainerConnectionDetailsFactory,\
org.springframework.ai.testcontainers.service.connection.milvus.MilvusContainerConnectionDetailsFactory,\
org.springframework.ai.testcontainers.service.connection.mongo.MongoDbAtlasLocalContainerConnectionDetailsFactory,\
org.springframework.ai.testcontainers.service.connection.ollama.OllamaContainerConnectionDetailsFactory,\
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright 2023-2025 the original author or authors.
*
* Licensed 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
*
* https://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.springframework.ai.testcontainers.service.connection.docker;

import org.junit.jupiter.api.Test;
import org.testcontainers.containers.DockerMcpGatewayContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;

import org.springframework.ai.mcp.client.common.autoconfigure.McpSseClientConnectionDetails;
import org.springframework.ai.mcp.client.common.autoconfigure.properties.McpSseClientProperties;
import org.springframework.ai.mcp.client.httpclient.autoconfigure.SseHttpClientTransportAutoConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;

import static org.assertj.core.api.Assertions.assertThat;

@SpringJUnitConfig
@Testcontainers
class DockerMcpGatewayContainerConnectionDetailsFactoryIT {

@Container
@ServiceConnection
private static final DockerMcpGatewayContainer MCP_GATEWAY = new DockerMcpGatewayContainer("docker/mcp-gateway:v2");

@Autowired
private McpSseClientConnectionDetails connectionDetails;

@Test
void test() {
assertThat(this.connectionDetails.getConnections()).containsEntry("gateway",
new McpSseClientProperties.SseParameters(MCP_GATEWAY.getEndpoint(), "/sse"));
}

@Configuration(proxyBeanMethods = false)
@ImportAutoConfiguration(SseHttpClientTransportAutoConfiguration.class)
static class Config {

}

}