Skip to content

Commit 9bec4ea

Browse files
committed
Fixes modelcontextprotocol#248 - Add CultureInfo.InvariantCulture to string interpolation for langitude and longitude so the sample works everywhere.
1 parent 0c502c4 commit 9bec4ea

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

samples/QuickstartWeatherServer/Tools/WeatherTools.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using ModelContextProtocol;
22
using ModelContextProtocol.Server;
33
using System.ComponentModel;
4+
using System.Globalization;
45
using System.Text.Json;
56

67
namespace QuickstartWeatherServer.Tools;
@@ -41,7 +42,8 @@ public static async Task<string> GetForecast(
4142
[Description("Latitude of the location.")] double latitude,
4243
[Description("Longitude of the location.")] double longitude)
4344
{
44-
using var jsonDocument = await client.ReadJsonDocumentAsync($"/points/{latitude},{longitude}");
45+
var pointUrl = string.Format(CultureInfo.InvariantCulture, "points/{0},{1}", latitude, longitude);
46+
using var jsonDocument = await client.ReadJsonDocumentAsync(pointUrl);
4547
var forecastUrl = jsonDocument.RootElement.GetProperty("properties").GetProperty("forecast").GetString()
4648
?? throw new Exception($"No forecast URL provided by {client.BaseAddress}points/{latitude},{longitude}");
4749

0 commit comments

Comments
 (0)