Skip to content

Commit 6f312e5

Browse files
authored
mcp(deps): upgrade go-sdk used for testing (#1606)
**Description** This upgrades MCP Go SDK used for tests. **Related Issues/PRs (if applicable)** Closes #1476 --------- Signed-off-by: Takeshi Yoneda <[email protected]>
1 parent 6ae3615 commit 6f312e5

File tree

7 files changed

+41
-43
lines changed

7 files changed

+41
-43
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ require (
2828
github.com/google/go-cmp v0.7.0
2929
github.com/google/jsonschema-go v0.3.0
3030
github.com/google/uuid v1.6.0
31-
github.com/modelcontextprotocol/go-sdk v1.0.0
31+
github.com/modelcontextprotocol/go-sdk v1.1.0
3232
github.com/openai/openai-go v1.12.0
3333
github.com/openai/openai-go/v2 v2.7.1
3434
github.com/prometheus/client_golang v1.23.2

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,8 @@ github.com/moby/sys/userns v0.1.0 h1:tVLXkFOxVu9A64/yh59slHVv9ahO9UIev4JZusOLG/g
331331
github.com/moby/sys/userns v0.1.0/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28=
332332
github.com/moby/term v0.5.2 h1:6qk3FJAFDs6i/q3W/pQ97SX192qKfZgGjCQqfCJkgzQ=
333333
github.com/moby/term v0.5.2/go.mod h1:d3djjFCrjnB+fl8NJux+EJzu0msscUP+f8it8hPkFLc=
334-
github.com/modelcontextprotocol/go-sdk v1.0.0 h1:Z4MSjLi38bTgLrd/LjSmofqRqyBiVKRyQSJgw8q8V74=
335-
github.com/modelcontextprotocol/go-sdk v1.0.0/go.mod h1:nYtYQroQ2KQiM0/SbyEPUWQ6xs4B95gJjEalc9AQyOs=
334+
github.com/modelcontextprotocol/go-sdk v1.1.0 h1:Qjayg53dnKC4UZ+792W21e4BpwEZBzwgRW6LrjLWSwA=
335+
github.com/modelcontextprotocol/go-sdk v1.1.0/go.mod h1:6fM3LCm3yV7pAs8isnKLn07oKtB0MP9LHd3DfAcKw10=
336336
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
337337
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
338338
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=

tests/e2e/mcp_route_api_key_auth_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ func TestMCPRouteAPIKeyAuth(t *testing.T) {
8383
Endpoint: fmt.Sprintf("%s/mcp", fwd.Address()),
8484
}, nil)
8585
if err != nil {
86-
if strings.Contains(err.Error(), "401 Unauthorized") {
87-
t.Logf("got expected 401 Unauthorized error: %v", err)
86+
if strings.Contains(err.Error(), "Unauthorized") {
87+
t.Logf("got expected Unauthorized error: %v", err)
8888
return true
8989
}
9090
t.Logf("failed to connect to MCP server: %v", err)
@@ -118,8 +118,8 @@ func TestMCPRouteAPIKeyAuth(t *testing.T) {
118118
HTTPClient: invalidClient,
119119
}, nil)
120120
if err != nil {
121-
if strings.Contains(err.Error(), "401 Unauthorized") {
122-
t.Logf("got expected 401 Unauthorized error: %v", err)
121+
if strings.Contains(err.Error(), "Unauthorized") {
122+
t.Logf("got expected Unauthorized error: %v", err)
123123
return true
124124
}
125125
t.Logf("failed to connect to MCP server: %v", err)

tests/e2e/mcp_route_ext_auth_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ func TestMCPRouteExtAuthz(t *testing.T) {
9595
HTTPClient: deniedClient,
9696
}, nil)
9797
if err != nil {
98-
if strings.Contains(err.Error(), "403 Forbidden") {
99-
t.Logf("got expected 403 Forbidden error: %v", err)
98+
if strings.Contains(err.Error(), "Forbidden") {
99+
t.Logf("got expected Forbidden error: %v", err)
100100
return true
101101
}
102102
t.Logf("failed to connect to MCP server: %v", err)

tests/e2e/mcp_route_oauth_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ func TestMCPRouteOAuth(t *testing.T) {
111111
Endpoint: fmt.Sprintf("%s/mcp", fwd.Address()),
112112
}, nil)
113113
if err != nil {
114-
if strings.Contains(err.Error(), "401 Unauthorized") {
115-
t.Logf("got expected 401 Unauthorized error: %v", err)
114+
if strings.Contains(err.Error(), "Unauthorized") {
115+
t.Logf("got expected Unauthorized error: %v", err)
116116
return true
117117
}
118118
t.Logf("failed to connect to MCP server: %v", err)

tests/extproc/mcp/mcp_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ func testToolCountDown(t *testing.T, m *mcpEnv) {
244244
callErrorCh <- err
245245
doneBool.Store(true)
246246
}()
247-
requireToolSpan(t, m.collector.TakeSpan(), "default-mcp-backend", testmcp.ToolCountDown.Tool.Name, false, "")
248247

249248
// we cannot assume the order of notifications, so we use a set to track them.
250249
counts := sets.New[int]()
@@ -294,11 +293,12 @@ func testToolCountDown(t *testing.T, m *mcpEnv) {
294293
require.Empty(t, expectedLogs)
295294
require.Empty(t, counts)
296295

297-
err = <-callErrorCh
298-
require.NoError(t, err)
296+
require.NoError(t, <-callErrorCh)
299297
require.Eventually(t, func() bool {
300298
return doneBool.Load() == true
301299
}, time.Second, time.Millisecond*10)
300+
// The tool call won't end until the countdown is complete, so check the span here, not before.
301+
requireToolSpan(t, m.collector.TakeSpan(), "default-mcp-backend", testmcp.ToolCountDown.Tool.Name, false, "")
302302
require.False(t, res.IsError)
303303
require.Len(t, res.Content, 1)
304304
require.IsType(t, &mcp.TextContent{}, res.Content[0])

tests/internal/testmcp/tools.go

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -149,36 +149,34 @@ var ToolCountDown = TestTool[ToolCountDownArgs, any]{
149149
if err != nil {
150150
return nil, nil, err
151151
}
152-
// change to use goroutine to not block the handler.
153-
go func() {
154-
for i := args.From; i >= 0; i-- {
155-
// Send a progress notification with the current count.
156-
err := request.Session.NotifyProgress(ctx, &mcp.ProgressNotificationParams{
157-
Message: fmt.Sprintf("count down: %d", i),
158-
ProgressToken: args.From - i,
159-
})
160-
if err != nil {
161-
return
162-
}
163-
// Send a log message with the debug and error levels so that
164-
// we can test that setting log level works.
165-
err = request.Session.Log(ctx, &mcp.LoggingMessageParams{
166-
Level: "debug",
167-
Data: `debug count down: ` + fmt.Sprint(i),
168-
})
169-
if err != nil {
170-
return
171-
}
172-
err = request.Session.Log(ctx, &mcp.LoggingMessageParams{
173-
Level: "error",
174-
Data: `count down: ` + fmt.Sprint(i),
175-
})
176-
if err != nil {
177-
return
178-
}
179-
time.Sleep(interval)
152+
for i := args.From; i >= 0; i-- {
153+
// Send a progress notification with the current count.
154+
request.GetSession()
155+
err := request.Session.NotifyProgress(ctx, &mcp.ProgressNotificationParams{
156+
Message: fmt.Sprintf("count down: %d", i),
157+
ProgressToken: args.From - i,
158+
})
159+
if err != nil {
160+
return nil, nil, err
161+
}
162+
// Send a log message with the debug and error levels so that
163+
// we can test that setting log level works.
164+
err = request.Session.Log(ctx, &mcp.LoggingMessageParams{
165+
Level: "debug",
166+
Data: `debug count down: ` + fmt.Sprint(i),
167+
})
168+
if err != nil {
169+
return nil, nil, err
180170
}
181-
}()
171+
err = request.Session.Log(ctx, &mcp.LoggingMessageParams{
172+
Level: "error",
173+
Data: `count down: ` + fmt.Sprint(i),
174+
})
175+
if err != nil {
176+
return nil, nil, err
177+
}
178+
time.Sleep(interval)
179+
}
182180

183181
return &mcp.CallToolResult{
184182
Content: []mcp.Content{

0 commit comments

Comments
 (0)