Implements the client half of the SEP-2575 / `2026-06-30` protocol. This CL is client-only; server-side `server/discover` is still a `MethodNotFound` stub. ### Changes - **`server/discover` probe in `Client.Connect()`** (`client.go`). When the caller opts into `protocolVersion >= 2026-06-30`, the client probes the server with `server/discover` before falling back to the legacy `initialize` handshake. - **Per-request `_meta` injection** (`shared.go`, `injectRequestMeta`). For`>= 2026-06-30` sessions every outgoing request gets the SEP-2575 triple (`protocolVersion`, `clientInfo`, `clientCapabilities`). - **Server-side fix**: `ServerSession.handle` no longer pre-populates `state.InitializeParams` from a `server/discover` request's `_meta`, so a subsequent fallback `initialize` is not rejected as a duplicate. ### Fallback rules Client falls back to the legacy `initialize` handshake when discover returns: - `MethodNotFound` (-32601), - `UnsupportedProtocolVersionError` (-32004), - an HTTP `Bad Request` (substring-matched on the error message, to interop with pre-2026-06-30 servers). Fixes #966
40 lines
2.2 KiB
Go
40 lines
2.2 KiB
Go
// Copyright 2025 The Go MCP SDK Authors. All rights reserved.
|
|
// Use of this source code is governed by an MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// This file holds the request types.
|
|
|
|
package mcp
|
|
|
|
type (
|
|
CallToolRequest = ServerRequest[*CallToolParamsRaw]
|
|
CompleteRequest = ServerRequest[*CompleteParams]
|
|
GetPromptRequest = ServerRequest[*GetPromptParams]
|
|
InitializedRequest = ServerRequest[*InitializedParams]
|
|
ListPromptsRequest = ServerRequest[*ListPromptsParams]
|
|
ListResourcesRequest = ServerRequest[*ListResourcesParams]
|
|
ListResourceTemplatesRequest = ServerRequest[*ListResourceTemplatesParams]
|
|
ListToolsRequest = ServerRequest[*ListToolsParams]
|
|
ProgressNotificationServerRequest = ServerRequest[*ProgressNotificationParams]
|
|
ReadResourceRequest = ServerRequest[*ReadResourceParams]
|
|
RootsListChangedRequest = ServerRequest[*RootsListChangedParams]
|
|
SubscribeRequest = ServerRequest[*SubscribeParams]
|
|
UnsubscribeRequest = ServerRequest[*UnsubscribeParams]
|
|
)
|
|
|
|
type (
|
|
CreateMessageRequest = ClientRequest[*CreateMessageParams]
|
|
CreateMessageWithToolsRequest = ClientRequest[*CreateMessageWithToolsParams]
|
|
DiscoverRequest = ClientRequest[*DiscoverParams]
|
|
ElicitRequest = ClientRequest[*ElicitParams]
|
|
initializedClientRequest = ClientRequest[*InitializedParams]
|
|
InitializeRequest = ClientRequest[*InitializeParams]
|
|
ListRootsRequest = ClientRequest[*ListRootsParams]
|
|
LoggingMessageRequest = ClientRequest[*LoggingMessageParams]
|
|
ProgressNotificationClientRequest = ClientRequest[*ProgressNotificationParams]
|
|
PromptListChangedRequest = ClientRequest[*PromptListChangedParams]
|
|
ResourceListChangedRequest = ClientRequest[*ResourceListChangedParams]
|
|
ResourceUpdatedNotificationRequest = ClientRequest[*ResourceUpdatedNotificationParams]
|
|
ToolListChangedRequest = ClientRequest[*ToolListChangedParams]
|
|
ElicitationCompleteNotificationRequest = ClientRequest[*ElicitationCompleteParams]
|
|
)
|