Skip to content

bug: client.Intialize errors when using transport.NewStdioWithOptions #583

@scotthew1

Description

@scotthew1

Description

As of #564, calls to client.Start now skip starting any transport of type *transport.Stdio which is great if you're using NewStdioMCPClientWithOptions, but when setting up a transport directly with transport.NewStdioWithOptions you have to explicitly start the transport before starting the client.

This behavior change caused runtime errors in our service after upgrading from v0.38.0 to v0.39.1

Code Sample

tport := transport.NewStdioWithOptions(/* ... */) cli := client.NewClient(tport) if err := cli.Start(ctx); err != nil { return fmt.Errorf("starting MCP server: %w", err) } result, err := cli.Initialize(initCtx, mcp.InitializeRequest{}) if err != nil { return fmt.Errorf("initializing MCP server: %w", err) }

Logs or Error Messages

The above code snippet works just fine in v0.38.0, but produces an error in v0.39.1

initializing MCP server: transport error: stdio client not started 

Environment

  • Go version (see go.mod): go1.25.1
  • mcp-go version (see go.mod): v0.39.1

Possible Solution

If you want to avoid starting the transport twice, client.Start should do something to check if the transport is running rather than assuming it has started based solely on the type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions