@@ -1504,7 +1504,7 @@ namespace QuickstartWeatherServer.Tools;
15041504public static class WeatherTools
15051505{
15061506 [McpServerTool ,
1507- Description (@"
1507+ Description (@"
15081508 Get weather alerts for a US state.
15091509 Args:
15101510 State: Two-letter US state code (e.g. CA, NY)
@@ -1521,39 +1521,41 @@ public static class WeatherTools
15211521 return " No active alerts for this state." ;
15221522 }
15231523
1524- return string .Join (" \n --\n " , alerts .Select (alert =>
1525- {
1526- JsonElement properties = alert .GetProperty (" properties" );
1527- return $"""
1524+ return string .Join (" \n --\n " ,
1525+ alerts .Select (alert =>
1526+ {
1527+ JsonElement properties = alert .GetProperty (" properties" );
1528+ return $"""
15281529 Event: {properties .GetProperty (" event" ).GetString ()}
15291530 Area: {properties .GetProperty (" areaDesc" ).GetString ()}
15301531 Severity: {properties .GetProperty (" severity" ).GetString ()}
15311532 Description: {properties .GetProperty (" description" ).GetString ()}
15321533 Instruction: {properties .GetProperty (" instruction" ).GetString ()}
15331534 """ ;
1534- }));
1535+ }));
15351536 }
15361537
15371538 [McpServerTool ,
15381539 Description (@"
1539- Get weather forecast for a location.
1540-
1541- Args:
1542- Latitude: Latitude of the location.
1543- Longitude: Longitude of the location.
1540+ Get weather forecast for a location.
1541+ Args:
1542+ Latitude: Latitude of the location.
1543+ Longitude: Longitude of the location.
15441544 " )]
15451545 public static async Task <string > GetForecast (
15461546 HttpClient client ,
15471547 [Description (" Latitude of the location." )] double latitude ,
15481548 [Description (" Longitude of the location." )] double longitude )
15491549 {
1550- var jsonElement = await client .GetFromJsonAsync <JsonElement >($" /points/{latitude },{longitude }" );
1550+ var pointUrl = string .Format (CultureInfo .InvariantCulture , " points/{0},{1}" , latitude , longitude );
1551+ var jsonElement = await client .GetFromJsonAsync <JsonElement >(pointUrl );
15511552 var forecastUrl = jsonElement .GetProperty (" properties" ).GetProperty (" forecast" ).GetString ();
15521553
15531554 jsonElement = await client .GetFromJsonAsync <JsonElement >(forecastUrl );
15541555 var periods = jsonElement .GetProperty (" properties" ).GetProperty (" periods" ).EnumerateArray ();
15551556
1556- return string .Join (" \n ---\n " , periods .Select (period => $"""
1557+ return string .Join (" \n ---\n " ,
1558+ periods .Select (period => $"""
15571559 {period .GetProperty (" name" ).GetString ()}
15581560 Temperature: {period .GetProperty (" temperature" ).GetInt32 ()}°F
15591561 Wind: {period .GetProperty (" windSpeed" ).GetString ()} {period .GetProperty (" windDirection" ).GetString ()}
0 commit comments