mirror of
https://github.com/hanzoai/traces.git
synced 2026-10-30 18:20:41 +00:00
0da392be19
--- updated-dependencies: - dependency-name: github.com/mark3labs/mcp-go dependency-version: 0.34.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
23 lines
722 B
Go
23 lines
722 B
Go
package client
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/mark3labs/mcp-go/client/transport"
|
|
)
|
|
|
|
// NewStreamableHttpClient is a convenience method that creates a new streamable-http-based MCP client
|
|
// with the given base URL. Returns an error if the URL is invalid.
|
|
func NewStreamableHttpClient(baseURL string, options ...transport.StreamableHTTPCOption) (*Client, error) {
|
|
trans, err := transport.NewStreamableHTTP(baseURL, options...)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to create SSE transport: %w", err)
|
|
}
|
|
clientOptions := make([]ClientOption, 0)
|
|
sessionID := trans.GetSessionId()
|
|
if sessionID != "" {
|
|
clientOptions = append(clientOptions, WithSession())
|
|
}
|
|
return NewClient(trans, clientOptions...), nil
|
|
}
|