Skip to content

Commit 578446a

Browse files
committed
rename Delegate to Transport; update callsites
1 parent 67c2f12 commit 578446a

File tree

14 files changed

+26
-26
lines changed

14 files changed

+26
-26
lines changed

examples/client/listfeatures/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func main() {
4141
ctx := context.Background()
4242
cmd := exec.Command(args[0], args[1:]...)
4343
client := mcp.NewClient(&mcp.Implementation{Name: "mcp-client", Version: "v1.0.0"}, nil)
44-
cs, err := client.Connect(ctx, mcp.NewCommandTransport(cmd), nil)
44+
cs, err := client.Connect(ctx, &mcp.CommandTransport{Command: cmd}, nil)
4545
if err != nil {
4646
log.Fatal(err)
4747
}

examples/server/hello/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func main() {
5858
log.Printf("MCP handler listening at %s", *httpAddr)
5959
http.ListenAndServe(*httpAddr, handler)
6060
} else {
61-
t := &mcp.LoggingTransport{Delegate: &mcp.StdioTransport{}, Writer: os.Stderr}
61+
t := &mcp.LoggingTransport{Transport: &mcp.StdioTransport{}, Writer: os.Stderr}
6262
if err := server.Run(context.Background(), t); err != nil {
6363
log.Printf("Server failed: %v", err)
6464
}

examples/server/memory/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func main() {
137137
log.Printf("MCP handler listening at %s", *httpAddr)
138138
http.ListenAndServe(*httpAddr, handler)
139139
} else {
140-
t := mcp.NewLoggingTransport(mcp.NewStdioTransport(), os.Stderr)
140+
t := &mcp.LoggingTransport{Transport: &mcp.StdioTransport{}, Writer: os.Stderr}
141141
if err := server.Run(context.Background(), t); err != nil {
142142
log.Printf("Server failed: %v", err)
143143
}

examples/server/sequentialthinking/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ func main() {
536536
log.Fatal(err)
537537
}
538538
} else {
539-
t := mcp.NewLoggingTransport(mcp.NewStdioTransport(), os.Stderr)
539+
t := &mcp.LoggingTransport{Transport: &mcp.StdioTransport{}, Writer: os.Stderr}
540540
if err := server.Run(context.Background(), t); err != nil {
541541
log.Printf("Server failed: %v", err)
542542
}

internal/readme/client/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func main() {
2020
client := mcp.NewClient(&mcp.Implementation{Name: "mcp-client", Version: "v1.0.0"}, nil)
2121

2222
// Connect to a server over stdin/stdout
23-
transport := mcp.NewCommandTransport(exec.Command("myserver"))
23+
transport := &mcp.CommandTransport{Command: exec.Command("myserver")}
2424
session, err := client.Connect(ctx, transport, nil)
2525
if err != nil {
2626
log.Fatal(err)

internal/readme/server/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func main() {
2828

2929
mcp.AddTool(server, &mcp.Tool{Name: "greet", Description: "say hi"}, SayHi)
3030
// Run the server over stdin/stdout, until the client disconnects
31-
if err := server.Run(context.Background(), mcp.NewStdioTransport()); err != nil {
31+
if err := server.Run(context.Background(), &mcp.StdioTransport{}); err != nil {
3232
log.Fatal(err)
3333
}
3434
}

mcp/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type CommandTransport struct {
2929
//
3030
//go:fix inline
3131
func NewCommandTransport(cmd *exec.Cmd) *CommandTransport {
32-
return &CommandTransport{cmd}
32+
return &CommandTransport{Command: cmd}
3333
}
3434

3535
// Connect starts the command, and connects to it over stdin/stdout.

mcp/cmd_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func runServer() {
4949

5050
server := mcp.NewServer(testImpl, nil)
5151
mcp.AddTool(server, &mcp.Tool{Name: "greet", Description: "say hi"}, SayHi)
52-
if err := server.Run(ctx, mcp.NewStdioTransport()); err != nil {
52+
if err := server.Run(ctx, &mcp.StdioTransport{}); err != nil {
5353
log.Fatal(err)
5454
}
5555
}
@@ -59,7 +59,7 @@ func runCancelContextServer() {
5959
defer done()
6060

6161
server := mcp.NewServer(testImpl, nil)
62-
if err := server.Run(ctx, mcp.NewStdioTransport()); err != nil {
62+
if err := server.Run(ctx, &mcp.StdioTransport{}); err != nil {
6363
log.Fatal(err)
6464
}
6565
}
@@ -116,7 +116,7 @@ func TestServerInterrupt(t *testing.T) {
116116
cmd := createServerCommand(t, "default")
117117

118118
client := mcp.NewClient(testImpl, nil)
119-
_, err := client.Connect(ctx, mcp.NewCommandTransport(cmd), nil)
119+
_, err := client.Connect(ctx, &mcp.CommandTransport{Command: cmd}, nil)
120120
if err != nil {
121121
t.Fatal(err)
122122
}
@@ -198,7 +198,7 @@ func TestCmdTransport(t *testing.T) {
198198
cmd := createServerCommand(t, "default")
199199

200200
client := mcp.NewClient(&mcp.Implementation{Name: "client", Version: "v0.0.1"}, nil)
201-
session, err := client.Connect(ctx, mcp.NewCommandTransport(cmd), nil)
201+
session, err := client.Connect(ctx, &mcp.CommandTransport{Command: cmd}, nil)
202202
if err != nil {
203203
t.Fatal(err)
204204
}

mcp/mcp_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ func TestNoJSONNull(t *testing.T) {
774774

775775
// Collect logs, to sanity check that we don't write JSON null anywhere.
776776
var logbuf safeBuffer
777-
ct = NewLoggingTransport(ct, &logbuf)
777+
ct = &LoggingTransport{Transport: ct, Writer: &logbuf}
778778

779779
s := NewServer(testImpl, nil)
780780
ss, err := s.Connect(ctx, st, nil)

mcp/sse.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,6 @@ type SSEClientTransportOptions struct {
347347
// NewSSEClientTransport returns a new client transport that connects to the
348348
// SSE server at the provided URL.
349349
//
350-
// NewSSEClientTransport panics if the given URL is invalid.
351-
//
352350
// Deprecated: use an SSEClientTransport literal.
353351
//
354352
//go:fix inline

0 commit comments

Comments
 (0)