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 5dbc90c3..242b702a 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(); 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 2e96703d..586f8d89 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 2c08e0b9..3cebe296 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() 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 a10c4a62..7ae1dc59 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 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 00000000..135f5a9e --- /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} + + + + + + +