* Fixes #248 - Add CultureInfo.InvariantCulture to string interpolation for langitude and longitude so the sample works everywhere. * Update samples/QuickstartWeatherServer/Tools/WeatherTools.cs Co-authored-by: Stephen Toub <stoub@microsoft.com> --------- Co-authored-by: Stephen Toub <stoub@microsoft.com>
This commit is contained in:
parent
0c502c43af
commit
43266ad268
1 changed files with 3 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using ModelContextProtocol;
|
||||
using ModelContextProtocol.Server;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace QuickstartWeatherServer.Tools;
|
||||
|
|
@ -41,7 +42,8 @@ public sealed class WeatherTools
|
|||
[Description("Latitude of the location.")] double latitude,
|
||||
[Description("Longitude of the location.")] double longitude)
|
||||
{
|
||||
using var jsonDocument = await client.ReadJsonDocumentAsync($"/points/{latitude},{longitude}");
|
||||
var pointUrl = string.Create(CultureInfo.InvariantCulture, $"/points/{latitude},{longitude}");
|
||||
using var jsonDocument = await client.ReadJsonDocumentAsync(pointUrl);
|
||||
var forecastUrl = jsonDocument.RootElement.GetProperty("properties").GetProperty("forecast").GetString()
|
||||
?? throw new Exception($"No forecast URL provided by {client.BaseAddress}points/{latitude},{longitude}");
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue