client

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 34 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

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLoginRequired  = errors.New("login required; run mcpbridge login for this profile")
	ErrProfileChanged = errors.New("profile was logged in again; restart the MCP connection")
)

Functions

func AdminRequest

func AdminRequest(ctx context.Context, store *Store, name string, opts AdminRequestOptions) error

AdminRequest sends one management operation. Only a 401 can cause one retry; network failures never replay writes. ETags are emitted separately to stderr.

func AuthorizeClient

func AuthorizeClient(ctx context.Context, store *Store, name string, opts ClientOptions) (configstore.ClientGrant, error)

func BrokerControl

func BrokerControl(ctx context.Context, store *Store, operation string) (int, error)

func Connect

func Connect(ctx context.Context, store *Store, name string, opts ConnectOptions) error

func ConnectBroker

func ConnectBroker(ctx context.Context, store *Store, name, id string, opts ConnectOptions) error

func ConnectInteractive added in v2.3.0

func ConnectInteractive(ctx context.Context, store *Store, opts PairOptions, connection ConnectOptions) error

ConnectInteractive initializes the local MCP session before contacting the gateway. Authentication is explicit; business calls are never queued or replayed.

func Login

func Login(ctx context.Context, store *Store, opts LoginOptions) error

func Logout

func Logout(ctx context.Context, store *Store, name string, base *http.Client) (bool, error)

Logout clears local access before any network I/O. An offline revocation leaves only the non-secret session reference for review in the user portal.

func RevokeClient

func RevokeClient(ctx context.Context, store *Store, name, id string, base *http.Client) error

func RunBroker

func RunBroker(ctx context.Context, store *Store, base *http.Client) error

func Setup

func Setup(ctx context.Context, store *Store, name string, opts SetupOptions) error

Setup prompts before consent and prints only credential-free configuration to ConfigOutput. It never modifies an application's existing configuration file.

Types

type AdminRequestOptions

type AdminRequestOptions struct {
	Method, Path, IfMatch string
	Body                  []byte
	Output, Diagnostics   io.Writer
	HTTPClient            *http.Client
}

type ClientOptions

type ClientOptions struct {
	ID            string                        `json:"client_instance_id"`
	Name          string                        `json:"client_name"`
	Endpoint      string                        `json:"endpoint_id"`
	Scopes        []string                      `json:"allowed_scopes"`
	Tools         []string                      `json:"allowed_tools"`
	ResourceRules []config.ResourceRule         `json:"resource_rules"`
	AllowWrite    bool                          `json:"allow_write_requests"`
	Capabilities  configstore.GrantCapabilities `json:"capabilities"`
	TTLSeconds    int64                         `json:"ttl_seconds"`
	Changed       []string                      `json:"-"`
	HTTPClient    *http.Client                  `json:"-"`
	OpenBrowser   func(string) error            `json:"-"`
	Output        io.Writer                     `json:"-"`
}

type ClientStatus

type ClientStatus struct {
	configstore.ClientGrant
	EffectiveScopes    []string
	AuthorizationError string
}

func ListClients

func ListClients(ctx context.Context, store *Store, name string, base *http.Client) ([]ClientStatus, bool, error)

type ConnectOptions

type ConnectOptions struct {
	Input      io.ReadCloser
	Output     io.WriteCloser
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

type DiagnosticCheck

type DiagnosticCheck struct {
	Code    string `json:"code"`
	Status  string `json:"status"`
	Message string `json:"message"`
	Action  string `json:"action,omitempty"`
}

type DoctorOptions

type DoctorOptions struct {
	ClientID   string
	Timeout    time.Duration
	HTTPClient *http.Client
}

type DoctorReport

type DoctorReport struct {
	Profile         string            `json:"profile"`
	ClientID        string            `json:"client_id,omitempty"`
	Server          string            `json:"server,omitempty"`
	Endpoint        string            `json:"endpoint,omitempty"`
	Healthy         bool              `json:"healthy"`
	Checks          []DiagnosticCheck `json:"checks"`
	EffectiveScopes []string          `json:"effective_scopes,omitempty"`
	Tools           []string          `json:"tools,omitempty"`
	MoreTools       bool              `json:"more_tools"`
}

func Doctor

func Doctor(ctx context.Context, store *Store, name string, opts DoctorOptions) DoctorReport

Doctor uses the connector's credential path and read-only MCP initialization and discovery. It may refresh a token, but never opens a browser, starts a Broker, creates an authorization, or calls a tool.

type LoginOptions

type LoginOptions struct {
	Admin        bool
	ServerURL    string
	ClientID     string
	Profile      string
	Scopes       []string
	CallbackPort int
	Output       io.Writer
	OpenBrowser  func(string) error
	HTTPClient   *http.Client
}

type PairOptions added in v2.3.0

type PairOptions struct {
	Server   string
	Profile  string
	ClientID string
	ClientOptions
}

type PairStatus added in v2.3.0

type PairStatus struct {
	Status                  string    `json:"status"`
	RequestID               string    `json:"request_id"`
	UserCode                string    `json:"user_code,omitempty"`
	VerificationURI         string    `json:"verification_uri,omitempty"`
	VerificationURIComplete string    `json:"verification_uri_complete,omitempty"`
	ExpiresAt               time.Time `json:"expires_at,omitempty"`
	Interval                int64     `json:"interval,omitempty"`
	Profile                 string    `json:"profile"`
	ClientID                string    `json:"client_instance_id"`
	Server                  string    `json:"server"`
	Endpoint                string    `json:"endpoint_id,omitempty"`
	NextStep                string    `json:"next_step"`
}

PairStatus is safe to pass to an Agent. It intentionally has no credential fields.

func PairFinish added in v2.3.0

func PairFinish(ctx context.Context, store *Store, id string, wait bool, base *http.Client) (PairStatus, error)

func PairStart added in v2.3.0

func PairStart(ctx context.Context, store *Store, opts PairOptions) (PairStatus, error)

type SetupOptions

type SetupOptions struct {
	ServerURL, ClientID, Command string
	CallbackPort                 int
	Input                        io.Reader
	Output, ConfigOutput         io.Writer
	HTTPClient                   *http.Client
	OpenBrowser                  func(string) error
}

type Status

type Status struct {
	BrokerSession      string
	ClientCount        int
	PendingRevocations int
	Admin              bool
	ServerURL          string
	ClientID           string
	Scopes             []string
	LoggedIn           bool
	ExpiresAt          time.Time
	CanRefresh         bool
}

Status describes cached credentials, without checking their validity at the issuer.

type Store

type Store struct{ Dir string }

func DefaultStore

func DefaultStore() (*Store, error)

func (*Store) Logout

func (s *Store) Logout(ctx context.Context, name string) error

func (*Store) Status

func (s *Store) Status(ctx context.Context, name string) (Status, error)

Jump to

Keyboard shortcuts

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