Skip to content

Commit b1c75f0

Browse files
committed
mcp: remove deprecated transport constructors
In #272, we made transports open structs and deprecated their constructors. However, we left the constructors in place to allow go:fix directives to facilitate migration. Now let's remove the constructors before cutting the release. Fixes #305
1 parent 5bbca40 commit b1c75f0

File tree

5 files changed

+1
-124
lines changed

5 files changed

+1
-124
lines changed

mcp/cmd.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,6 @@ type CommandTransport struct {
2727
TerminateDuration time.Duration
2828
}
2929

30-
// NewCommandTransport returns a [CommandTransport] that runs the given command
31-
// and communicates with it over stdin/stdout.
32-
//
33-
// The resulting transport takes ownership of the command, starting it during
34-
// [CommandTransport.Connect], and stopping it when the connection is closed.
35-
//
36-
// Deprecated: use a CommandTransport literal.
37-
//
38-
//go:fix inline
39-
func NewCommandTransport(cmd *exec.Cmd) *CommandTransport {
40-
return &CommandTransport{Command: cmd}
41-
}
42-
4330
// Connect starts the command, and connects to it over stdin/stdout.
4431
func (t *CommandTransport) Connect(ctx context.Context) (Connection, error) {
4532
stdout, err := t.Command.StdoutPipe()

mcp/sse.go

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -114,19 +114,6 @@ type SSEServerTransport struct {
114114
done chan struct{} // closed when the connection is closed
115115
}
116116

117-
// NewSSEServerTransport creates a new SSE transport for the given messages
118-
// endpoint, and hanging GET response.
119-
//
120-
// Deprecated: use an SSEServerTransport literal.
121-
//
122-
//go:fix inline
123-
func NewSSEServerTransport(endpoint string, w http.ResponseWriter) *SSEServerTransport {
124-
return &SSEServerTransport{
125-
Endpoint: endpoint,
126-
Response: w,
127-
}
128-
}
129-
130117
// ServeHTTP handles POST requests to the transport endpoint.
131118
func (t *SSEServerTransport) ServeHTTP(w http.ResponseWriter, req *http.Request) {
132119
if t.incoming == nil {
@@ -334,30 +321,6 @@ type SSEClientTransport struct {
334321
HTTPClient *http.Client
335322
}
336323

337-
// SSEClientTransportOptions provides options for the [NewSSEClientTransport]
338-
// constructor.
339-
//
340-
// Deprecated: use an SSEClientTransport literal.
341-
type SSEClientTransportOptions struct {
342-
// HTTPClient is the client to use for making HTTP requests. If nil,
343-
// http.DefaultClient is used.
344-
HTTPClient *http.Client
345-
}
346-
347-
// NewSSEClientTransport returns a new client transport that connects to the
348-
// SSE server at the provided URL.
349-
//
350-
// Deprecated: use an SSEClientTransport literal.
351-
//
352-
//go:fix inline
353-
func NewSSEClientTransport(endpoint string, opts *SSEClientTransportOptions) *SSEClientTransport {
354-
t := &SSEClientTransport{Endpoint: endpoint}
355-
if opts != nil {
356-
t.HTTPClient = opts.HTTPClient
357-
}
358-
return t
359-
}
360-
361324
// Connect connects through the client endpoint.
362325
func (c *SSEClientTransport) Connect(ctx context.Context) (Connection, error) {
363326
parsedURL, err := url.Parse(c.Endpoint)

mcp/streamable.go

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -323,15 +323,6 @@ func (h *StreamableHTTPHandler) ServeHTTP(w http.ResponseWriter, req *http.Reque
323323
transport.ServeHTTP(w, req)
324324
}
325325

326-
// StreamableServerTransportOptions configures the stramable server transport.
327-
//
328-
// Deprecated: use a StreamableServerTransport literal.
329-
type StreamableServerTransportOptions struct {
330-
// Storage for events, to enable stream resumption.
331-
// If nil, a [MemoryEventStore] with the default maximum size will be used.
332-
EventStore EventStore
333-
}
334-
335326
// A StreamableServerTransport implements the server side of the MCP streamable
336327
// transport.
337328
//
@@ -385,22 +376,6 @@ type StreamableServerTransport struct {
385376
connection *streamableServerConn
386377
}
387378

388-
// NewStreamableServerTransport returns a new [StreamableServerTransport] with
389-
// the given session ID and options.
390-
//
391-
// Deprecated: use a StreamableServerTransport literal.
392-
//
393-
//go:fix inline.
394-
func NewStreamableServerTransport(sessionID string, opts *StreamableServerTransportOptions) *StreamableServerTransport {
395-
t := &StreamableServerTransport{
396-
SessionID: sessionID,
397-
}
398-
if opts != nil {
399-
t.EventStore = opts.EventStore
400-
}
401-
return t
402-
}
403-
404379
// Connect implements the [Transport] interface.
405380
func (t *StreamableServerTransport) Connect(ctx context.Context) (Connection, error) {
406381
if t.connection != nil {
@@ -1025,34 +1000,6 @@ const (
10251000
reconnectMaxDelay = 30 * time.Second
10261001
)
10271002

1028-
// StreamableClientTransportOptions provides options for the
1029-
// [NewStreamableClientTransport] constructor.
1030-
//
1031-
// Deprecated: use a StremableClientTransport literal.
1032-
type StreamableClientTransportOptions struct {
1033-
// HTTPClient is the client to use for making HTTP requests. If nil,
1034-
// http.DefaultClient is used.
1035-
HTTPClient *http.Client
1036-
// MaxRetries is the maximum number of times to attempt a reconnect before giving up.
1037-
// It defaults to 5. To disable retries, use a negative number.
1038-
MaxRetries int
1039-
}
1040-
1041-
// NewStreamableClientTransport returns a new client transport that connects to
1042-
// the streamable HTTP server at the provided URL.
1043-
//
1044-
// Deprecated: use a StreamableClientTransport literal.
1045-
//
1046-
//go:fix inline
1047-
func NewStreamableClientTransport(url string, opts *StreamableClientTransportOptions) *StreamableClientTransport {
1048-
t := &StreamableClientTransport{Endpoint: url}
1049-
if opts != nil {
1050-
t.HTTPClient = opts.HTTPClient
1051-
t.MaxRetries = opts.MaxRetries
1052-
}
1053-
return t
1054-
}
1055-
10561003
// Connect implements the [Transport] interface.
10571004
//
10581005
// The resulting [Connection] writes messages via POST requests to the

mcp/streamable_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,7 @@ func TestTokenInfo(t *testing.T) {
12111211
httpServer := httptest.NewServer(handler)
12121212
defer httpServer.Close()
12131213

1214-
transport := NewStreamableClientTransport(httpServer.URL, nil)
1214+
transport := &StreamableClientTransport{Endpoint: httpServer.URL}
12151215
client := NewClient(testImpl, nil)
12161216
session, err := client.Connect(ctx, transport, nil)
12171217
if err != nil {

mcp/transport.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,6 @@ func (*StdioTransport) Connect(context.Context) (Connection, error) {
9393
return newIOConn(rwc{os.Stdin, os.Stdout}), nil
9494
}
9595

96-
// NewStdioTransport constructs a transport that communicates over
97-
// stdin/stdout.
98-
//
99-
// Deprecated: use a StdioTransport literal.
100-
//
101-
//go:fix inline
102-
func NewStdioTransport() *StdioTransport {
103-
return &StdioTransport{}
104-
}
105-
10696
// An InMemoryTransport is a [Transport] that communicates over an in-memory
10797
// network connection, using newline-delimited JSON.
10898
type InMemoryTransport struct {
@@ -215,16 +205,6 @@ type LoggingTransport struct {
215205
Writer io.Writer
216206
}
217207

218-
// NewLoggingTransport creates a new LoggingTransport that delegates to the
219-
// provided transport, writing RPC logs to the provided io.Writer.
220-
//
221-
// Deprecated: use a LoggingTransport literal.
222-
//
223-
//go:fix inline
224-
func NewLoggingTransport(delegate Transport, w io.Writer) *LoggingTransport {
225-
return &LoggingTransport{Transport: delegate, Writer: w}
226-
}
227-
228208
// Connect connects the underlying transport, returning a [Connection] that writes
229209
// logs to the configured destination.
230210
func (t *LoggingTransport) Connect(ctx context.Context) (Connection, error) {

0 commit comments

Comments
 (0)