Skip to content

Commit c29d3a7

Browse files
committed
mcp: implement review feedback
1 parent 415ff56 commit c29d3a7

File tree

5 files changed

+6
-29
lines changed

5 files changed

+6
-29
lines changed

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ require (
77
github.com/google/go-cmp v0.7.0
88
github.com/google/jsonschema-go v0.3.0
99
github.com/yosida95/uritemplate/v3 v3.0.2
10-
go.uber.org/goleak v1.3.0
1110
golang.org/x/oauth2 v0.30.0
1211
golang.org/x/tools v0.34.0
1312
)

go.sum

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
1-
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2-
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
31
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
42
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
53
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
64
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
75
github.com/google/jsonschema-go v0.3.0 h1:6AH2TxVNtk3IlvkkhjrtbUc4S8AvO0Xii0DxIygDg+Q=
86
github.com/google/jsonschema-go v0.3.0/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE=
9-
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
10-
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
11-
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
12-
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
137
github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4=
148
github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4=
15-
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
16-
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
179
golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI=
1810
golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU=
1911
golang.org/x/tools v0.34.0 h1:qIpSLOxeCYGg9TrcJokLBG4KFA6d795g0xkBkiESGlo=
2012
golang.org/x/tools v0.34.0/go.mod h1:pAP9OwEaY1CAW3HOmg3hLZC5Z0CCmzjAF2UQMSqNARg=
21-
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
22-
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

mcp/client_example_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ func Example_roots() {
4242

4343
// Connect the server and client...
4444
t1, t2 := mcp.NewInMemoryTransports()
45-
sess1, err := s.Connect(ctx, t1, nil)
45+
serverSession, err := s.Connect(ctx, t1, nil)
4646
if err != nil {
4747
log.Fatal(err)
4848
}
49-
defer sess1.Close()
49+
defer serverSession.Close()
5050

51-
sess2, err := c.Connect(ctx, t2, nil)
51+
clientSession, err := c.Connect(ctx, t2, nil)
5252
if err != nil {
5353
log.Fatal(err)
5454
}
55-
defer sess2.Close()
55+
defer clientSession.Close()
5656

5757
// ...and add a root. The server is notified about the change.
5858
c.AddRoots(&mcp.Root{URI: "file://b"})

mcp/cmd_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ package mcp_test
77
import (
88
"context"
99
"errors"
10-
"flag"
1110
"log"
1211
"os"
1312
"os/exec"
@@ -19,15 +18,10 @@ import (
1918

2019
"github.com/google/go-cmp/cmp"
2120
"github.com/modelcontextprotocol/go-sdk/mcp"
22-
"go.uber.org/goleak"
2321
)
2422

2523
const runAsServer = "_MCP_RUN_AS_SERVER"
2624

27-
// TODO: remove this flag and always check for goroutine leaks once
28-
// . https://github.com/modelcontextprotocol/go-sdk/issues/499 is fixed
29-
var leakCheck = flag.Bool("leak", false, "enable goroutine leak checking")
30-
3125
type SayHiParams struct {
3226
Name string `json:"name"`
3327
}
@@ -52,13 +46,6 @@ func TestMain(m *testing.M) {
5246
run()
5347
return
5448
}
55-
56-
flag.Parse()
57-
if *leakCheck {
58-
goleak.VerifyTestMain(m)
59-
return
60-
}
61-
6249
os.Exit(m.Run())
6350
}
6451

mcp/streamable_example_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818

1919
// !+streamablehandler
2020

21+
// TODO: Until we have a way to clean up abandoned sessions, this test will leak goroutines (see #499)
2122
func ExampleStreamableHTTPHandler() {
2223
// Create a new streamable handler, using the same MCP server for every request.
2324
//
@@ -26,7 +27,7 @@ func ExampleStreamableHTTPHandler() {
2627
server := mcp.NewServer(&mcp.Implementation{Name: "server", Version: "v0.1.0"}, nil)
2728
handler := mcp.NewStreamableHTTPHandler(func(r *http.Request) *mcp.Server {
2829
return server
29-
}, &mcp.StreamableHTTPOptions{JSONResponse: true, Stateless: true})
30+
}, &mcp.StreamableHTTPOptions{JSONResponse: true})
3031
httpServer := httptest.NewServer(handler)
3132
defer httpServer.Close()
3233

0 commit comments

Comments
 (0)