Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit 47ffd2f

Browse files
committed
Added Globalization, and minor formatting cleanup.
1 parent 3b93f07 commit 47ffd2f

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

quickstart/server.mdx

+16-13
Original file line numberDiff line numberDiff line change
@@ -1497,14 +1497,15 @@ using ModelContextProtocol.Server;
14971497
using System.ComponentModel;
14981498
using System.Net.Http.Json;
14991499
using System.Text.Json;
1500+
using System.Globalization;
15001501

15011502
namespace QuickstartWeatherServer.Tools;
15021503

15031504
[McpServerToolType]
15041505
public static class WeatherTools
15051506
{
15061507
[McpServerTool,
1507-
Description(@"
1508+
Description(@"
15081509
Get weather alerts for a US state.
15091510
Args:
15101511
State: Two-letter US state code (e.g. CA, NY)
@@ -1521,39 +1522,41 @@ public static class WeatherTools
15211522
return "No active alerts for this state.";
15221523
}
15231524

1524-
return string.Join("\n--\n", alerts.Select(alert =>
1525-
{
1526-
JsonElement properties = alert.GetProperty("properties");
1527-
return $"""
1525+
return string.Join("\n--\n",
1526+
alerts.Select(alert =>
1527+
{
1528+
JsonElement properties = alert.GetProperty("properties");
1529+
return $"""
15281530
Event: {properties.GetProperty("event").GetString()}
15291531
Area: {properties.GetProperty("areaDesc").GetString()}
15301532
Severity: {properties.GetProperty("severity").GetString()}
15311533
Description: {properties.GetProperty("description").GetString()}
15321534
Instruction: {properties.GetProperty("instruction").GetString()}
15331535
""";
1534-
}));
1536+
}));
15351537
}
15361538

15371539
[McpServerTool,
15381540
Description(@"
1539-
Get weather forecast for a location.
1540-
1541-
Args:
1542-
Latitude: Latitude of the location.
1543-
Longitude: Longitude of the location.
1541+
Get weather forecast for a location.
1542+
Args:
1543+
Latitude: Latitude of the location.
1544+
Longitude: Longitude of the location.
15441545
")]
15451546
public static async Task<string> GetForecast(
15461547
HttpClient client,
15471548
[Description("Latitude of the location.")] double latitude,
15481549
[Description("Longitude of the location.")] double longitude)
15491550
{
1550-
var jsonElement = await client.GetFromJsonAsync<JsonElement>($"/points/{latitude},{longitude}");
1551+
var pointUrl = string.Format(CultureInfo.InvariantCulture, "points/{0},{1}", latitude, longitude);
1552+
var jsonElement = await client.GetFromJsonAsync<JsonElement>(pointUrl);
15511553
var forecastUrl = jsonElement.GetProperty("properties").GetProperty("forecast").GetString();
15521554

15531555
jsonElement = await client.GetFromJsonAsync<JsonElement>(forecastUrl);
15541556
var periods = jsonElement.GetProperty("properties").GetProperty("periods").EnumerateArray();
15551557

1556-
return string.Join("\n---\n", periods.Select(period => $"""
1558+
return string.Join("\n---\n",
1559+
periods.Select(period => $"""
15571560
{period.GetProperty("name").GetString()}
15581561
Temperature: {period.GetProperty("temperature").GetInt32()}°F
15591562
Wind: {period.GetProperty("windSpeed").GetString()} {period.GetProperty("windDirection").GetString()}

0 commit comments

Comments
 (0)