@@ -1504,7 +1504,7 @@ namespace QuickstartWeatherServer.Tools;
1504
1504
public static class WeatherTools
1505
1505
{
1506
1506
[McpServerTool ,
1507
- Description (@"
1507
+ Description (@"
1508
1508
Get weather alerts for a US state.
1509
1509
Args:
1510
1510
State: Two-letter US state code (e.g. CA, NY)
@@ -1521,39 +1521,41 @@ public static class WeatherTools
1521
1521
return " No active alerts for this state." ;
1522
1522
}
1523
1523
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 $"""
1528
1529
Event: {properties .GetProperty (" event" ).GetString ()}
1529
1530
Area: {properties .GetProperty (" areaDesc" ).GetString ()}
1530
1531
Severity: {properties .GetProperty (" severity" ).GetString ()}
1531
1532
Description: {properties .GetProperty (" description" ).GetString ()}
1532
1533
Instruction: {properties .GetProperty (" instruction" ).GetString ()}
1533
1534
""" ;
1534
- }));
1535
+ }));
1535
1536
}
1536
1537
1537
1538
[McpServerTool ,
1538
1539
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.
1544
1544
" )]
1545
1545
public static async Task <string > GetForecast (
1546
1546
HttpClient client ,
1547
1547
[Description (" Latitude of the location." )] double latitude ,
1548
1548
[Description (" Longitude of the location." )] double longitude )
1549
1549
{
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 );
1551
1552
var forecastUrl = jsonElement .GetProperty (" properties" ).GetProperty (" forecast" ).GetString ();
1552
1553
1553
1554
jsonElement = await client .GetFromJsonAsync <JsonElement >(forecastUrl );
1554
1555
var periods = jsonElement .GetProperty (" properties" ).GetProperty (" periods" ).EnumerateArray ();
1555
1556
1556
- return string .Join (" \n ---\n " , periods .Select (period => $"""
1557
+ return string .Join (" \n ---\n " ,
1558
+ periods .Select (period => $"""
1557
1559
{period .GetProperty (" name" ).GetString ()}
1558
1560
Temperature: {period .GetProperty (" temperature" ).GetInt32 ()}°F
1559
1561
Wind: {period .GetProperty (" windSpeed" ).GetString ()} {period .GetProperty (" windDirection" ).GetString ()}
0 commit comments