Skip to content

Commit dad5178

Browse files
authored
Upgrade go-sdk to v1.6.0 and consolidate session-missing detection (#6017)
This module is the core MCP dependency in `gh-aw-mcpg`, and the repo was one minor version behind on `modelcontextprotocol/go-sdk`. This PR updates the SDK and tightens a small MCP transport code path called out in the review by removing duplicated session-not-found string matching. - **Dependency refresh** - Bumps `github.com/modelcontextprotocol/go-sdk` from `v1.5.0` to `v1.6.0`. - Updates transitive module metadata/checksums (including `github.com/google/jsonschema-go`). - **Session-not-found detection cleanup** - Introduces a shared constant for the backend session-missing message in `internal/mcp/http_transport.go`. - Reuses that constant in both helpers: - `isSessionNotFoundError` - `isSessionNotFoundHTTPResponse` - Keeps behavior unchanged while removing duplicated literals. - **SDK contract annotation update** - Updates the bypass-validation contract note in `internal/server/tool_registry.go` to reflect verification against go-sdk `v1.6.0`. ```go const ( HTTPTransportPlainJSON HTTPTransportType = "plain-json" sessionNotFoundMessage = "session not found" ) func isSessionNotFoundError(err error) bool { if errors.Is(err, sdk.ErrSessionMissing) { return true } return strings.Contains(strings.ToLower(err.Error()), sessionNotFoundMessage) } ```
2 parents 88effd1 + 42d7077 commit dad5178

6 files changed

Lines changed: 14 additions & 12 deletions

File tree

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.25.0
44

55
require (
66
github.com/BurntSushi/toml v1.6.0
7-
github.com/modelcontextprotocol/go-sdk v1.5.0
7+
github.com/modelcontextprotocol/go-sdk v1.6.0
88
github.com/spf13/cobra v1.10.2
99
golang.org/x/term v0.41.0
1010
)
@@ -27,7 +27,7 @@ require (
2727
github.com/davecgh/go-spew v1.1.1 // indirect
2828
github.com/go-logr/logr v1.4.3 // indirect
2929
github.com/go-logr/stdr v1.2.2 // indirect
30-
github.com/google/jsonschema-go v0.4.2 // indirect
30+
github.com/google/jsonschema-go v0.4.3 // indirect
3131
github.com/google/uuid v1.6.0 // indirect
3232
github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0 // indirect
3333
github.com/inconshreveable/mousetrap v1.1.0 // indirect

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek
1818
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
1919
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
2020
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
21-
github.com/google/jsonschema-go v0.4.2 h1:tmrUohrwoLZZS/P3x7ex0WAVknEkBZM46iALbcqoRA8=
22-
github.com/google/jsonschema-go v0.4.2/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE=
21+
github.com/google/jsonschema-go v0.4.3 h1:/DBOLZTfDow7pe2GmaJNhltueGTtDKICi8V8p+DQPd0=
22+
github.com/google/jsonschema-go v0.4.3/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE=
2323
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
2424
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
2525
github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0 h1:HWRh5R2+9EifMyIHV7ZV+MIZqgz+PMpZ14Jynv3O2Zs=
@@ -34,8 +34,8 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
3434
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
3535
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
3636
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
37-
github.com/modelcontextprotocol/go-sdk v1.5.0 h1:CHU0FIX9kpueNkxuYtfYQn1Z0slhFzBZuq+x6IiblIU=
38-
github.com/modelcontextprotocol/go-sdk v1.5.0/go.mod h1:gggDIhoemhWs3BGkGwd1umzEXCEMMvAnhTrnbXJKKKA=
37+
github.com/modelcontextprotocol/go-sdk v1.6.0 h1:PPLS3kn7WtOEnR+Af4X5H96SG0qSab8R/ZQT/HkhPkY=
38+
github.com/modelcontextprotocol/go-sdk v1.6.0/go.mod h1:kzm3kzFL1/+AziGOE0nUs3gvPoNxMCvkxokMkuFapXQ=
3939
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4040
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
4141
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=

internal/mcp/connection.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ func (c *Connection) reconnectSDKTransport() error {
364364
HTTPClient: headerClient,
365365
// MaxRetries: -1 disables SDK-level reconnect retries (0 = SDK default 5 retries;
366366
// negative = 0 retries). The gateway handles reconnection itself, so we set -1 to
367-
// prevent double-retry behaviour. Verified against go-sdk v1.5.0 streamable.go:1547-1552.
367+
// prevent double-retry behaviour. Verified against go-sdk v1.6.0 streamable.go:1547-1552.
368368
// See TestMaxRetriesSentinelCanary for an automated guard against SDK changes.
369369
MaxRetries: -1,
370370
DisableStandaloneSSE: true,

internal/mcp/http_transport.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ const (
3434
HTTPTransportPlainJSON HTTPTransportType = "plain-json"
3535
)
3636

37+
const sessionNotFoundMessage = "session not found"
38+
3739
// MCPProtocolVersion is the MCP protocol version used only by the plain JSON-RPC
3840
// fallback path in this package. Streamable and SSE transports are SDK-managed
3941
// and negotiate protocol versions internally.
@@ -86,7 +88,7 @@ func isSessionNotFoundError(err error) bool {
8688
// TODO(tech-debt): remove this string-matching fallback once the plain JSON-RPC
8789
// transport (HTTPTransportPlainJSON) is retired. The plain JSON-RPC path exists
8890
// only for compatibility with backends that predate the 2024-11-05 MCP spec.
89-
return strings.Contains(strings.ToLower(err.Error()), "session not found")
91+
return strings.Contains(strings.ToLower(err.Error()), sessionNotFoundMessage)
9092
}
9193

9294
// isSessionNotFoundHTTPResponse checks if an HTTP response indicates the backend session was not found.
@@ -95,7 +97,7 @@ func isSessionNotFoundHTTPResponse(statusCode int, body []byte) bool {
9597
if statusCode != http.StatusNotFound {
9698
return false
9799
}
98-
return strings.Contains(strings.ToLower(string(body)), "session not found")
100+
return strings.Contains(strings.ToLower(string(body)), sessionNotFoundMessage)
99101
}
100102

101103
// parseSSEResponse extracts JSON data from SSE-formatted response
@@ -457,7 +459,7 @@ func tryStreamableHTTPTransport(ctx context.Context, cancel context.CancelFunc,
457459
HTTPClient: httpClient,
458460
// MaxRetries: -1 disables SDK-level reconnect retries (0 = SDK default 5 retries;
459461
// negative = 0 retries). We fall through to SSE or plain JSON-RPC on failure.
460-
// Verified against go-sdk v1.5.0 streamable.go:1547-1552.
462+
// Verified against go-sdk v1.6.0 streamable.go:1547-1552.
461463
// See TestMaxRetriesSentinelCanary for an automated guard against SDK changes.
462464
MaxRetries: -1,
463465
// DisableStandaloneSSE prevents the SDK from issuing a GET request for a

internal/mcp/http_transport_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,7 @@ func TestOIDCRoundTripper_ErrorPropagation(t *testing.T) {
12961296
// gateway's reconnect logic would silently permit extra retries and this test
12971297
// would fail to alert.
12981298
//
1299-
// SDK source: streamable.go:1547-1552 (verified against go-sdk v1.5.0):
1299+
// SDK source: streamable.go:1547-1552 (verified against go-sdk v1.6.0):
13001300
//
13011301
// maxRetries := t.MaxRetries
13021302
// if maxRetries == 0 {

internal/server/tool_registry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ type launchResult struct {
5050
// does require that InputSchema is non-nil and has type "object" (enforced since v1.5.0), but
5151
// it does not validate the argument values — that responsibility belongs to the caller.
5252
// This distinction relies on internal SDK behaviour and must be re-verified on every SDK upgrade.
53-
// Verified correct for go-sdk v1.5.0 (see server.go:Server.AddTool vs AddTool[In,Out]).
53+
// Verified correct for go-sdk v1.6.0 (see server.go:Server.AddTool vs AddTool[In,Out]).
5454
func registerToolWithoutValidation(server *sdk.Server, tool *sdk.Tool, handler func(context.Context, *sdk.CallToolRequest, interface{}) (*sdk.CallToolResult, interface{}, error)) {
5555
server.AddTool(tool, func(ctx context.Context, req *sdk.CallToolRequest) (*sdk.CallToolResult, error) {
5656
result, _, err := handler(ctx, req, nil)

0 commit comments

Comments
 (0)