From 84947bc6edf5efd3e08330b4b3ae4eaec2ae9407 Mon Sep 17 00:00:00 2001 From: cucl2-similis <78360973+cucl2-similis@users.noreply.github.com> Date: Sat, 21 Feb 2026 23:20:32 +0900 Subject: [PATCH 1/4] fix: update MCP JSON mapper initialization - The static factory method `McpJsonMapper.createDefault()` was removed in the latest MCP Java SDK. - This commit replaces removed `McpJsonMapper.createDefault()` with `McpJsonDefaults.getMapper()`. Refs: https://github.com/modelcontextprotocol/java-sdk/pull/779 Signed-off-by: cucl2-similis <78360973+cucl2-similis@users.noreply.github.com> --- .../org/springframework/ai/mcp/sample/client/ClientStdio.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model-context-protocol/weather/starter-stdio-server/src/main/java/org/springframework/ai/mcp/sample/client/ClientStdio.java b/model-context-protocol/weather/starter-stdio-server/src/main/java/org/springframework/ai/mcp/sample/client/ClientStdio.java index 5dbc90c..242b702 100644 --- a/model-context-protocol/weather/starter-stdio-server/src/main/java/org/springframework/ai/mcp/sample/client/ClientStdio.java +++ b/model-context-protocol/weather/starter-stdio-server/src/main/java/org/springframework/ai/mcp/sample/client/ClientStdio.java @@ -20,7 +20,7 @@ import io.modelcontextprotocol.client.McpClient; import io.modelcontextprotocol.client.transport.ServerParameters; import io.modelcontextprotocol.client.transport.StdioClientTransport; -import io.modelcontextprotocol.json.McpJsonMapper; +import io.modelcontextprotocol.json.McpJsonDefaults; import io.modelcontextprotocol.spec.McpSchema.CallToolRequest; import io.modelcontextprotocol.spec.McpSchema.CallToolResult; import io.modelcontextprotocol.spec.McpSchema.ListToolsResult; @@ -42,7 +42,7 @@ public static void main(String[] args) { "model-context-protocol/weather/starter-stdio-server/target/mcp-weather-stdio-server-0.0.1-SNAPSHOT.jar") .build(); - var transport = new StdioClientTransport(stdioParams, McpJsonMapper.createDefault()); + var transport = new StdioClientTransport(stdioParams, McpJsonDefaults.getMapper()); var client = McpClient.sync(transport).build(); client.initialize(); From 8f98e4057cf3a4d105f149530df56e85060a229b Mon Sep 17 00:00:00 2001 From: cucl2-similis <78360973+cucl2-similis@users.noreply.github.com> Date: Sat, 21 Feb 2026 23:41:58 +0900 Subject: [PATCH 2/4] fix: remove empty console logging pattern - Encountered Logback configuration error: "ERROR in ch.qos.logback.classic.PatternLayout("") - Empty or null pattern." - Caused by `logging.pattern.console=` being defined without a value - Removed the empty property to restore default Spring Boot logging behavior Signed-off-by: cucl2-similis <78360973+cucl2-similis@users.noreply.github.com> --- .../src/main/resources/application.properties | 1 - 1 file changed, 1 deletion(-) diff --git a/model-context-protocol/weather/starter-stdio-server/src/main/resources/application.properties b/model-context-protocol/weather/starter-stdio-server/src/main/resources/application.properties index a10c4a6..7ae1dc5 100644 --- a/model-context-protocol/weather/starter-stdio-server/src/main/resources/application.properties +++ b/model-context-protocol/weather/starter-stdio-server/src/main/resources/application.properties @@ -3,7 +3,6 @@ spring.main.web-application-type=none # NOTE: You must disable the banner and the console logging # to allow the STDIO transport to work !!! spring.main.banner-mode=off -logging.pattern.console= spring.ai.mcp.server.name=my-weather-server spring.ai.mcp.server.version=0.0.1 From 6e39e7d07516cbf8ab3d10e48e7523ca3e99fccd Mon Sep 17 00:00:00 2001 From: cucl2-similis <78360973+cucl2-similis@users.noreply.github.com> Date: Sun, 22 Feb 2026 00:11:13 +0900 Subject: [PATCH 3/4] fix: update MCP tool annotation and remove incompatible Bean - Replaced `@Tool` with `@McpTool` to fix `NoSuchMethodError` in SDK - Removed `weatherTools` Bean definition to resolve `BeanCreationException` - Fixed "No @Tool annotated methods found" error caused by annotation migration Signed-off-by: cucl2-similis <78360973+cucl2-similis@users.noreply.github.com> --- .../ai/mcp/sample/server/McpServerApplication.java | 8 -------- .../ai/mcp/sample/server/WeatherService.java | 10 +++++----- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/model-context-protocol/weather/starter-stdio-server/src/main/java/org/springframework/ai/mcp/sample/server/McpServerApplication.java b/model-context-protocol/weather/starter-stdio-server/src/main/java/org/springframework/ai/mcp/sample/server/McpServerApplication.java index 2e96703..586f8d8 100644 --- a/model-context-protocol/weather/starter-stdio-server/src/main/java/org/springframework/ai/mcp/sample/server/McpServerApplication.java +++ b/model-context-protocol/weather/starter-stdio-server/src/main/java/org/springframework/ai/mcp/sample/server/McpServerApplication.java @@ -1,10 +1,7 @@ package org.springframework.ai.mcp.sample.server; -import org.springframework.ai.tool.ToolCallbackProvider; -import org.springframework.ai.tool.method.MethodToolCallbackProvider; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; @SpringBootApplication public class McpServerApplication { @@ -13,9 +10,4 @@ public static void main(String[] args) { SpringApplication.run(McpServerApplication.class, args); } - @Bean - public ToolCallbackProvider weatherTools(WeatherService weatherService) { - return MethodToolCallbackProvider.builder().toolObjects(weatherService).build(); - } - } diff --git a/model-context-protocol/weather/starter-stdio-server/src/main/java/org/springframework/ai/mcp/sample/server/WeatherService.java b/model-context-protocol/weather/starter-stdio-server/src/main/java/org/springframework/ai/mcp/sample/server/WeatherService.java index 2c08e0b..3cebe29 100644 --- a/model-context-protocol/weather/starter-stdio-server/src/main/java/org/springframework/ai/mcp/sample/server/WeatherService.java +++ b/model-context-protocol/weather/starter-stdio-server/src/main/java/org/springframework/ai/mcp/sample/server/WeatherService.java @@ -22,8 +22,8 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import org.springframework.ai.tool.annotation.Tool; -import org.springframework.ai.tool.annotation.ToolParam; +import org.springaicommunity.mcp.annotation.McpTool; +import org.springaicommunity.mcp.annotation.McpToolParam; import org.springframework.stereotype.Service; import org.springframework.web.client.RestClient; import org.springframework.web.client.RestClientException; @@ -91,7 +91,7 @@ public record Properties(@JsonProperty("event") String event, @JsonProperty("are * @return The forecast for the given location * @throws RestClientException if the request fails */ - @Tool(description = "Get weather forecast for a specific latitude/longitude") + @McpTool(description = "Get weather forecast for a specific latitude/longitude") public String getWeatherForecastByLocation(double latitude, double longitude) { var points = restClient.get() @@ -120,8 +120,8 @@ public String getWeatherForecastByLocation(double latitude, double longitude) { * @return Human readable alert information * @throws RestClientException if the request fails */ - @Tool(description = "Get weather alerts for a US state. Input is Two-letter US state code (e.g. CA, NY)") - public String getAlerts(@ToolParam( description = "Two-letter US state code (e.g. CA, NY") String state) { + @McpTool(description = "Get weather alerts for a US state. Input is Two-letter US state code (e.g. CA, NY)") + public String getAlerts(@McpToolParam( description = "Two-letter US state code (e.g. CA, NY") String state) { Alert alert = restClient.get().uri("/alerts/active/area/{state}", state).retrieve().body(Alert.class); return alert.features() From 3e60bf3ce894fc9e63c145683eebcbad4922ce2f Mon Sep 17 00:00:00 2001 From: cucl2-similis <78360973+cucl2-similis@users.noreply.github.com> Date: Sun, 22 Feb 2026 00:28:21 +0900 Subject: [PATCH 4/4] fix: redirect console logs to stderr for MCP transport - Created `logback-spring.xml` to redirect all console logs to `System.err` - Prevented log messages from interfering with the MCP STDIO transport - Ensured MCP communication on STDOUT remains clean from logging noise Signed-off-by: cucl2-similis <78360973+cucl2-similis@users.noreply.github.com> --- .../src/main/resources/logback-spring.xml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 model-context-protocol/weather/starter-stdio-server/src/main/resources/logback-spring.xml diff --git a/model-context-protocol/weather/starter-stdio-server/src/main/resources/logback-spring.xml b/model-context-protocol/weather/starter-stdio-server/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..135f5a9 --- /dev/null +++ b/model-context-protocol/weather/starter-stdio-server/src/main/resources/logback-spring.xml @@ -0,0 +1,16 @@ + + + + + + System.err + + ${CONSOLE_LOG_PATTERN} + ${CONSOLE_LOG_CHARSET} + + + + + + +