Fix api.weather.gov/points response handling in WeatherTools#134
Fix api.weather.gov/points response handling in WeatherTools#134halter73 merged 12 commits intomodelcontextprotocol:mainfrom
Conversation
|
|
PederHP
left a comment
There was a problem hiding this comment.
Looks good to me.
nit: I prefer string.Join to Aggregate
|
The intent of the sample was to be parity with https://github.com/modelcontextprotocol/quickstart-resources/blob/main/weather-server-python/weather.py#L57-L90 and https://github.com/modelcontextprotocol/quickstart-resources/blob/main/weather-server-typescript/src/index.ts#L141-L203 but the change here deviates from it, so I don't think it's needed. |
|
@aaronpowell, how does this relate to the claim in the opening post that I'm still not clear... is the sample broken as it currently is? |
|
@stephentoub I think we have a different bug, I've just tried it out on |
That's because you didn't add HttpClient to DI, so McpServerTool can't satisfy that parameter from the IServiceProvider. |
|
Sorry, I take that back, you did add it here: |
|
It's a bug in an argument in WithTools. I'll fix it. |
|
Hey @aaronpowell sorry, still not clear to me. The code initially failed for me since the call can't get the attribute and then it fails. Plus, Weather API point to use /forecast they provide in docs. Did I miss a recent change or something else added recently to sort it out? |
|
As noted, there's a bug that causes the pipeline to think that Once #152 merges in, it should fix that problem. |
|
Thanks. In that case, @stvansolano, can this be closed? |
|
Fixed conflicts. @aaronpowell @stephentoub should we merge this one on the API calls / fix sample or is already covered per other discussions/fixes/PRs? Sorry, got confused again 😆 |
|
@halter73 went through some weird PR build issues for the past days. Now they're gone. Can we merge this? |
|
Jftr, as #230 is mentioned, which I wrote: There's still a problem with internationalization, as the double values latitude/longitude are transformed e.g. in germany (where I live) as comma-seperated, not dot-separated strings. This lets the api call fail, effectively rendering the example not working for all folks in those areas. It's already fixed in modelcontextprotocol/docs#228 , and I'm not sure you have it on the radar, so before the other one gets closed and this one makes it, I wanted to call it out and hope you'll add the (trivial) fix - see my comment on modelcontextprotocol/docs#230 |
|
Can we track it as improvement or separate PR maybe @DGuhr? @stephentoub thoughts? |
There was a problem hiding this comment.
I definitely agree perfect shouldn't be the enemy of good, and I see the current WeatherTools.GetForecast implementation gives a "the given key was not present in the dictionary" error when I pass it 47.6,-122.3 (Seattle) for the lat,lon pair, so we should definitely fix it.
However, I don't want to merge it with the ?? $"/{properties.GetProperty("gridId")}... logic since that will never work considering it doesn't start with "/gridpoints". We should just fail whenever the forecast URL isn't supplied by the /points/lat,lon response. The likelihood of us being able to guess the gridpoints URL from response.properties if api.weather.gov removes response.properties.forecast part is basically none.
Co-authored-by: Stephen Halter <halter73@gmail.com>
Calls to #GetForecast fail for a basic query.
Periodsis not present so using/Forecastattribute insteadForecast docs: https://www.weather.gov/documentation/services-web-api
For example: https://api.weather.gov/gridpoints/TOP/31,80/forecast
Motivation and Context
Fixes sample code for WeatherTools
How Has This Been Tested?
Breaking Changes
N/A
Types of changes
Checklist
Additional context
N/A