client

package
v0.26.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package client provides shared MCP client creation and initialization logic used by both the CLI and TUI.

It wraps the mcp-go SDK client constructors and handles transport selection, auto-detection (streamable-http with SSE fallback), and the MCP initialize handshake using the ToolHive version reported by versions.GetVersionInfo.

Index

Constants

View Source
const TransportAuto = "auto"

TransportAuto is the sentinel value that triggers auto-detection of the transport type (try streamable-http first, then fall back to SSE).

Variables

This section is empty.

Functions

func Connect

func Connect(ctx context.Context, serverURL, transport, clientName string) (*mcpclient.Client, error)

Connect creates an MCP SDK client for the given serverURL and transport, starts the underlying transport, and performs the MCP initialize handshake.

The clientName is included in the ClientInfo sent during initialization (e.g. "toolhive-cli" or "toolhive-tui").

transport must be one of:

  • TransportAuto -- try streamable-http, fall back to SSE
  • "sse"
  • "streamable-http"

The returned client is fully connected and ready for use. The caller is responsible for calling Close when done.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL