client

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package client finds and connects to a sailwright-gateway from inside a container.

Discovery order:

  1. SAILWRIGHT_GATEWAY_URL, either http(s)://host:port/mcp or unix:///path/to/gateway.sock
  2. the agent socket in SAILWRIGHT_GATEWAY_DIR (default /run/sailwright-gateway), if it accepts connections (Linux containers with the agent dir bind-mounted)
  3. http://host.docker.internal:7391/mcp (Docker Desktop on macOS and Windows)

The token comes from SAILWRIGHT_GATEWAY_TOKEN or <dir>/token.

Index

Constants

View Source
const (
	EnvURL   = "SAILWRIGHT_GATEWAY_URL"
	EnvToken = "SAILWRIGHT_GATEWAY_TOKEN"
	EnvDir   = "SAILWRIGHT_GATEWAY_DIR"

	DefaultDir    = "/run/sailwright-gateway"
	DefaultTCPURL = "http://host.docker.internal:7391/mcp"
)

Environment variables and defaults used for discovery.

Variables

This section is empty.

Functions

func Connect

func Connect(ctx context.Context, endpoint Endpoint, impl *mcp.Implementation) (*mcp.ClientSession, error)

Connect opens an MCP client session to the gateway.

Types

type Bridge

type Bridge struct {
	Endpoint Endpoint
	Version  string
	// contains filtered or unexported fields
}

Bridge serves the gateway's tools over another MCP transport (usually stdio), so any agent harness that can start a command can use the gateway. Tool calls are forwarded unchanged; the gateway enforces its policy as usual.

func (*Bridge) Run

func (b *Bridge) Run(ctx context.Context, transport mcp.Transport) error

Run connects upstream, mirrors its tools and serves them on transport until the downstream client disconnects or ctx is cancelled.

type Endpoint

type Endpoint struct {
	// URL is the HTTP endpoint; for socket endpoints it is a placeholder host.
	URL string
	// Socket is the Unix socket path, if the gateway is reached over a socket.
	Socket string
	Token  string
	// Source explains how the endpoint was found.
	Source string
}

Endpoint is a resolved gateway address plus token.

func Discover

func Discover(getenv func(string) string) (Endpoint, error)

Discover resolves the gateway endpoint from the environment and the mounted agent dir.

func (Endpoint) HTTPClient

func (e Endpoint) HTTPClient() *http.Client

HTTPClient returns an HTTP client that reaches the endpoint and sends the token.

func (Endpoint) String

func (e Endpoint) String() string

String describes the endpoint without the token.

Jump to

Keyboard shortcuts

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