quickstart-resources/weather-server-go
Repository files (latest commit first)
Filename Latest commit message Latest commit date
olaservo 8ec30b939c Stop advertising the deprecated logging capability
go-sdk defaults ServerCapabilities to {"logging":{}} when ServerOptions is
nil — "for historical reasons", as its own doc comment puts it. This server
does no logging, and logging is deprecated as of 2026-07-28 (SEP-2577), so an
example for that revision should not be advertising it.

Passing an empty Capabilities suppresses the default. The tools capability is
still inferred from the registered tools, so server/discover now reports
{"tools":{"listChanged":true}} rather than logging alongside it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-09 15:36:33 -07:00
..
go.mod Update to go-sdk v1.7.0 and drop two committed binaries 2026-08-09 15:36:33 -07:00
go.sum Update to go-sdk v1.7.0 and drop two committed binaries 2026-08-09 15:36:33 -07:00
main.go Stop advertising the deprecated logging capability 2026-08-09 15:36:33 -07:00
README.md Update to go-sdk v1.7.0 and drop two committed binaries 2026-08-09 15:36:33 -07:00

A Simple MCP Weather Server written in Go

See the Build an MCP server tutorial for more information.

Building

go build -o weather

Running

./weather

The server will communicate via stdio and expose two MCP tools:

  • get_forecast - Get weather forecast for a location (requires latitude and longitude)
  • get_alerts - Get weather alerts for a US state (requires two-letter state code)

Structured output

Both tools advertise an outputSchema and return StructuredContent. get_forecast returns an object; get_alerts returns a top-level JSON array, which protocol revision 2026-07-28 is the first to allow — see Structured Content in the spec.

get_forecast sets no OutputSchema on the Tool: the SDK infers one from the handler's return type, which is the idiomatic Go spelling. get_alerts overrides it, because inference widens a slice to ["null", "array"] — a nil slice marshals to null — and the tool never returns nil.

Note that an array-rooted schema requires a 2026-07-28 client: the SDK sends it as written on every connection rather than projecting it down, so an older client rejects the tool list.