Skip to content

Commit 53a7af5

Browse files
sobychackoilayaperumalg
authored andcommitted
Addressing the remaining checkstyle failures
Signed-off-by: Soby Chacko <[email protected]>
1 parent aaf1589 commit 53a7af5

File tree

87 files changed

+547
-458
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+547
-458
lines changed

auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/McpClientAutoConfiguration.java

+23-23
Original file line numberDiff line numberDiff line change
@@ -175,22 +175,6 @@ public List<McpSyncClient> mcpSyncClients(McpSyncClientConfigurer mcpSyncClientC
175175
return mcpSyncClients;
176176
}
177177

178-
/**
179-
* Record class that implements {@link AutoCloseable} to ensure proper cleanup of MCP
180-
* clients.
181-
*
182-
* <p>
183-
* This class is responsible for closing all MCP sync clients when the application
184-
* context is closed, preventing resource leaks.
185-
*/
186-
public record CloseableMcpSyncClients(List<McpSyncClient> clients) implements AutoCloseable {
187-
188-
@Override
189-
public void close() {
190-
this.clients.forEach(McpSyncClient::close);
191-
}
192-
}
193-
194178
/**
195179
* Creates a closeable wrapper for MCP sync clients to ensure proper resource cleanup.
196180
* @param clients the list of MCP sync clients to manage
@@ -258,13 +242,6 @@ public List<McpAsyncClient> mcpAsyncClients(McpAsyncClientConfigurer mcpSyncClie
258242
return mcpSyncClients;
259243
}
260244

261-
public record CloseableMcpAsyncClients(List<McpAsyncClient> clients) implements AutoCloseable {
262-
@Override
263-
public void close() {
264-
this.clients.forEach(McpAsyncClient::close);
265-
}
266-
}
267-
268245
@Bean
269246
@ConditionalOnProperty(prefix = McpClientCommonProperties.CONFIG_PREFIX, name = "type", havingValue = "ASYNC")
270247
public CloseableMcpAsyncClients makeAsynClientsClosable(List<McpAsyncClient> clients) {
@@ -278,4 +255,27 @@ McpAsyncClientConfigurer mcpAsyncClientConfigurer(ObjectProvider<McpAsyncClientC
278255
return new McpAsyncClientConfigurer(customizerProvider.orderedStream().toList());
279256
}
280257

258+
/**
259+
* Record class that implements {@link AutoCloseable} to ensure proper cleanup of MCP
260+
* clients.
261+
*
262+
* <p>
263+
* This class is responsible for closing all MCP sync clients when the application
264+
* context is closed, preventing resource leaks.
265+
*/
266+
public record CloseableMcpSyncClients(List<McpSyncClient> clients) implements AutoCloseable {
267+
268+
@Override
269+
public void close() {
270+
this.clients.forEach(McpSyncClient::close);
271+
}
272+
}
273+
274+
public record CloseableMcpAsyncClients(List<McpAsyncClient> clients) implements AutoCloseable {
275+
@Override
276+
public void close() {
277+
this.clients.forEach(McpAsyncClient::close);
278+
}
279+
}
280+
281281
}

auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/McpToolCallbackAutoConfiguration.java

+20-20
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,6 @@
4040
@Conditional(McpToolCallbackAutoConfiguration.McpToolCallbackAutoconfigurationCondition.class)
4141
public class McpToolCallbackAutoConfiguration {
4242

43-
public static class McpToolCallbackAutoconfigurationCondition extends AllNestedConditions {
44-
45-
public McpToolCallbackAutoconfigurationCondition() {
46-
super(ConfigurationPhase.PARSE_CONFIGURATION);
47-
}
48-
49-
@ConditionalOnProperty(prefix = McpClientCommonProperties.CONFIG_PREFIX, name = "enabled", havingValue = "true",
50-
matchIfMissing = true)
51-
static class McpAutoConfigEnabled {
52-
53-
}
54-
55-
@ConditionalOnProperty(prefix = McpClientCommonProperties.CONFIG_PREFIX + ".toolcallback", name = "enabled",
56-
havingValue = "true", matchIfMissing = false)
57-
static class ToolCallbackProviderEnabled {
58-
59-
}
60-
61-
}
62-
6343
/**
6444
* Creates tool callbacks for all configured MCP clients.
6545
*
@@ -84,4 +64,24 @@ public ToolCallbackProvider mcpAsyncToolCallbacks(ObjectProvider<List<McpAsyncCl
8464
return new AsyncMcpToolCallbackProvider(mcpClients);
8565
}
8666

67+
public static class McpToolCallbackAutoconfigurationCondition extends AllNestedConditions {
68+
69+
public McpToolCallbackAutoconfigurationCondition() {
70+
super(ConfigurationPhase.PARSE_CONFIGURATION);
71+
}
72+
73+
@ConditionalOnProperty(prefix = McpClientCommonProperties.CONFIG_PREFIX, name = "enabled", havingValue = "true",
74+
matchIfMissing = true)
75+
static class McpAutoConfigEnabled {
76+
77+
}
78+
79+
@ConditionalOnProperty(prefix = McpClientCommonProperties.CONFIG_PREFIX + ".toolcallback", name = "enabled",
80+
havingValue = "true", matchIfMissing = false)
81+
static class ToolCallbackProviderEnabled {
82+
83+
}
84+
85+
}
86+
8787
}

auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/NamedClientMcpTransport.java

+15-14
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
/*
2-
* Copyright 2024 - 2024 the original author or authors.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* https://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
2+
* Copyright 2025-2025 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
1617
package org.springframework.ai.mcp.client.autoconfigure;
1718

1819
import io.modelcontextprotocol.spec.McpClientTransport;

auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/SseHttpClientTransportAutoConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
import io.modelcontextprotocol.client.transport.HttpClientSseClientTransport;
2727
import io.modelcontextprotocol.spec.McpSchema;
2828

29-
import org.springframework.beans.factory.ObjectProvider;
3029
import org.springframework.ai.mcp.client.autoconfigure.properties.McpClientCommonProperties;
3130
import org.springframework.ai.mcp.client.autoconfigure.properties.McpSseClientProperties;
3231
import org.springframework.ai.mcp.client.autoconfigure.properties.McpSseClientProperties.SseParameters;
32+
import org.springframework.beans.factory.ObjectProvider;
3333
import org.springframework.boot.autoconfigure.AutoConfiguration;
3434
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
3535
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;

auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/SseWebFluxTransportAutoConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
import com.fasterxml.jackson.databind.ObjectMapper;
2424
import io.modelcontextprotocol.client.transport.WebFluxSseClientTransport;
2525

26-
import org.springframework.beans.factory.ObjectProvider;
2726
import org.springframework.ai.mcp.client.autoconfigure.properties.McpClientCommonProperties;
2827
import org.springframework.ai.mcp.client.autoconfigure.properties.McpSseClientProperties;
2928
import org.springframework.ai.mcp.client.autoconfigure.properties.McpSseClientProperties.SseParameters;
29+
import org.springframework.beans.factory.ObjectProvider;
3030
import org.springframework.boot.autoconfigure.AutoConfiguration;
3131
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
3232
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;

auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/properties/McpSseClientProperties.java

+23-22
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
/*
2-
* Copyright 2024 - 2024 the original author or authors.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* https://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
2+
* Copyright 2025-2025 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
1617
package org.springframework.ai.mcp.client.autoconfigure.properties;
1718

1819
import java.util.HashMap;
@@ -46,14 +47,6 @@ public class McpSseClientProperties {
4647

4748
public static final String CONFIG_PREFIX = "spring.ai.mcp.client.sse";
4849

49-
/**
50-
* Parameters for configuring an SSE connection to an MCP server.
51-
*
52-
* @param url the URL endpoint for SSE communication with the MCP server
53-
*/
54-
public record SseParameters(String url) {
55-
}
56-
5750
/**
5851
* Map of named SSE connection configurations.
5952
* <p>
@@ -70,4 +63,12 @@ public Map<String, SseParameters> getConnections() {
7063
return this.connections;
7164
}
7265

66+
/**
67+
* Parameters for configuring an SSE connection to an MCP server.
68+
*
69+
* @param url the URL endpoint for SSE communication with the MCP server
70+
*/
71+
public record SseParameters(String url) {
72+
}
73+
7374
}

auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/properties/McpStdioClientProperties.java

+26-26
Original file line numberDiff line numberDiff line change
@@ -73,32 +73,6 @@ public Map<String, Parameters> getConnections() {
7373
return this.connections;
7474
}
7575

76-
/**
77-
* Record representing the parameters for an MCP server connection.
78-
* <p>
79-
* Includes the command to execute, command arguments, and environment variables.
80-
*/
81-
@JsonInclude(JsonInclude.Include.NON_ABSENT)
82-
public record Parameters(
83-
/**
84-
* The command to execute for the MCP server.
85-
*/
86-
@JsonProperty("command") String command,
87-
/**
88-
* List of command arguments.
89-
*/
90-
@JsonProperty("args") List<String> args,
91-
/**
92-
* Map of environment variables for the server process.
93-
*/
94-
@JsonProperty("env") Map<String, String> env) {
95-
96-
public ServerParameters toServerParameters() {
97-
return ServerParameters.builder(this.command()).args(this.args()).env(this.env()).build();
98-
}
99-
100-
}
101-
10276
private Map<String, ServerParameters> resourceToServerParameters() {
10377
try {
10478
Map<String, Map<String, Parameters>> stdioConnection = new ObjectMapper().readValue(
@@ -133,4 +107,30 @@ public Map<String, ServerParameters> toServerParameters() {
133107
return serverParameters;
134108
}
135109

110+
/**
111+
* Record representing the parameters for an MCP server connection.
112+
* <p>
113+
* Includes the command to execute, command arguments, and environment variables.
114+
*/
115+
@JsonInclude(JsonInclude.Include.NON_ABSENT)
116+
public record Parameters(
117+
/**
118+
* The command to execute for the MCP server.
119+
*/
120+
@JsonProperty("command") String command,
121+
/**
122+
* List of command arguments.
123+
*/
124+
@JsonProperty("args") List<String> args,
125+
/**
126+
* Map of environment variables for the server process.
127+
*/
128+
@JsonProperty("env") Map<String, String> env) {
129+
130+
public ServerParameters toServerParameters() {
131+
return ServerParameters.builder(this.command()).args(this.args()).env(this.env()).build();
132+
}
133+
134+
}
135+
136136
}

auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/test/java/org/springframework/ai/mcp/client/autoconfigure/McpClientAutoConfigurationIT.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ void toolCallbacksCreation() {
121121

122122
@Test
123123
void closeableWrappersCreation() {
124-
this.contextRunner.withUserConfiguration(TestTransportConfiguration.class).run(context -> {
125-
assertThat(context).hasSingleBean(McpClientAutoConfiguration.CloseableMcpSyncClients.class);
126-
});
124+
this.contextRunner.withUserConfiguration(TestTransportConfiguration.class)
125+
.run(context -> assertThat(context)
126+
.hasSingleBean(McpClientAutoConfiguration.CloseableMcpSyncClients.class));
127127
}
128128

129129
@Configuration

auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/test/java/org/springframework/ai/mcp/client/autoconfigure/McpToolCallbackAutoConfigurationTests.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,21 @@ public class McpToolCallbackAutoConfigurationTests {
3131
@Test
3232
void disabledByDeafault() {
3333

34-
this.applicationContext.run((context) -> {
34+
this.applicationContext.run(context -> {
3535
assertThat(context).doesNotHaveBean("mcpToolCallbacks");
3636
assertThat(context).doesNotHaveBean("mcpAsyncToolCallbacks");
3737
});
3838

3939
this.applicationContext
4040
.withPropertyValues("spring.ai.mcp.client.enabled=true", "spring.ai.mcp.client.type=SYNC")
41-
.run((context) -> {
41+
.run(context -> {
4242
assertThat(context).doesNotHaveBean("mcpToolCallbacks");
4343
assertThat(context).doesNotHaveBean("mcpAsyncToolCallbacks");
4444
});
4545

4646
this.applicationContext
4747
.withPropertyValues("spring.ai.mcp.client.enabled=true", "spring.ai.mcp.client.type=ASYNC")
48-
.run((context) -> {
48+
.run(context -> {
4949
assertThat(context).doesNotHaveBean("mcpToolCallbacks");
5050
assertThat(context).doesNotHaveBean("mcpAsyncToolCallbacks");
5151
});
@@ -55,31 +55,31 @@ void disabledByDeafault() {
5555
void enabledMcpToolCallbackAutoconfiguration() {
5656

5757
// sync
58-
this.applicationContext.withPropertyValues("spring.ai.mcp.client.toolcallback.enabled=true").run((context) -> {
58+
this.applicationContext.withPropertyValues("spring.ai.mcp.client.toolcallback.enabled=true").run(context -> {
5959
assertThat(context).hasBean("mcpToolCallbacks");
6060
assertThat(context).doesNotHaveBean("mcpAsyncToolCallbacks");
6161
});
6262

6363
this.applicationContext
6464
.withPropertyValues("spring.ai.mcp.client.enabled=true", "spring.ai.mcp.client.toolcallback.enabled=true",
6565
"spring.ai.mcp.client.type=SYNC")
66-
.run((context) -> {
66+
.run(context -> {
6767
assertThat(context).hasBean("mcpToolCallbacks");
6868
assertThat(context).doesNotHaveBean("mcpAsyncToolCallbacks");
6969
});
7070

7171
// Async
7272
this.applicationContext
7373
.withPropertyValues("spring.ai.mcp.client.toolcallback.enabled=true", "spring.ai.mcp.client.type=ASYNC")
74-
.run((context) -> {
74+
.run(context -> {
7575
assertThat(context).doesNotHaveBean("mcpToolCallbacks");
7676
assertThat(context).hasBean("mcpAsyncToolCallbacks");
7777
});
7878

7979
this.applicationContext
8080
.withPropertyValues("spring.ai.mcp.client.enabled=true", "spring.ai.mcp.client.toolcallback.enabled=true",
8181
"spring.ai.mcp.client.type=ASYNC")
82-
.run((context) -> {
82+
.run(context -> {
8383
assertThat(context).doesNotHaveBean("mcpToolCallbacks");
8484
assertThat(context).hasBean("mcpAsyncToolCallbacks");
8585
});

0 commit comments

Comments
 (0)