1package client
 2
 3import (
 4	"fmt"
 5
 6	"github.com/mark3labs/mcp-go/client/transport"
 7)
 8
 9// NewStreamableHttpClient is a convenience method that creates a new streamable-http-based MCP client
10// with the given base URL. Returns an error if the URL is invalid.
11func NewStreamableHttpClient(baseURL string, options ...transport.StreamableHTTPCOption) (*Client, error) {
12	trans, err := transport.NewStreamableHTTP(baseURL, options...)
13	if err != nil {
14		return nil, fmt.Errorf("failed to create SSE transport: %w", err)
15	}
16	clientOptions := make([]ClientOption, 0)
17	sessionID := trans.GetSessionId()
18	if sessionID != "" {
19		clientOptions = append(clientOptions, WithSession())
20	}
21	return NewClient(trans, clientOptions...), nil
22}