app

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2025 License: Apache-2.0 Imports: 70 Imported by: 0

Documentation

Overview

Package app provides the entry point for the toolhive command-line application.

Index

Constants

View Source
const (
	// FormatJSON is the JSON output format
	FormatJSON = "json"
	// FormatText is the text output format
	FormatText = "text"
)

Output format constants

View Source
const (
	ServerTypeRemote    = "remote"
	ServerTypeContainer = "container"
)

ServerType constants

Variables

View Source
var OtelCmd = &cobra.Command{
	Use:   "otel",
	Short: "Manage OpenTelemetry configuration",
	Long:  "Configure OpenTelemetry settings for observability and monitoring of MCP servers.",
}

OtelCmd is the parent command for OpenTelemetry configuration

Functions

func AddBuildFlags added in v0.2.3

func AddBuildFlags(cmd *cobra.Command, config *BuildFlags)

AddBuildFlags adds all the build flags to a command

func AddOIDCFlags

func AddOIDCFlags(cmd *cobra.Command)

AddOIDCFlags adds OIDC validation flags to the provided command.

func AddRemoteAuthFlags added in v0.2.10

func AddRemoteAuthFlags(cmd *cobra.Command, config *RemoteAuthFlags)

AddRemoteAuthFlags adds the common remote authentication flags to a command

func AddRunFlags added in v0.2.1

func AddRunFlags(cmd *cobra.Command, config *RunFlags)

AddRunFlags adds all the run flags to a command

func BuildRunnerConfig added in v0.2.1

func BuildRunnerConfig(
	ctx context.Context,
	runFlags *RunFlags,
	serverOrImage string,
	cmdArgs []string,
	debugMode bool,
	cmd *cobra.Command,
	groupName string,
) (*runner.RunConfig, error)

BuildRunnerConfig creates a runner.RunConfig from the configuration

func GetStringFlagOrEmpty

func GetStringFlagOrEmpty(cmd *cobra.Command, flagName string) string

GetStringFlagOrEmpty tries to get the string value of the given flag. If the flag doesn't exist or there's an error, it returns an empty string.

func IsCompletionCommand

func IsCompletionCommand(args []string) bool

IsCompletionCommand checks if the command being run is the completion command

func IsInformationalCommand added in v0.3.3

func IsInformationalCommand(args []string) bool

IsInformationalCommand checks if the command being run is an informational command that doesn't need container runtime

func IsOIDCEnabled

func IsOIDCEnabled(cmd *cobra.Command) bool

IsOIDCEnabled returns true if OIDC validation is enabled for the given command. OIDC validation is considered enabled if either the OIDC issuer or the JWKS URL flag is provided.

func NewRootCmd

func NewRootCmd(enableUpdates bool) *cobra.Command

NewRootCmd creates a new root command for the ToolHive CLI.

func SetSecretsProvider

func SetSecretsProvider(provider secrets.ProviderType) error

SetSecretsProvider sets the secrets provider type in the configuration. It validates the input, tests the provider functionality, and updates the configuration. Choices are `encrypted`, `1password`, and `none`.

func ValidateAndNormaliseHostFlag added in v0.0.34

func ValidateAndNormaliseHostFlag(host string) (string, error)

ValidateAndNormaliseHostFlag validates and normalizes the host flag resolving it to an IP address if hostname is provided

Types

type BuildFlags added in v0.2.3

type BuildFlags struct {
	Tag    string
	Output string
	DryRun bool
}

BuildFlags holds the configuration for building MCP server containers

type RemoteAuthFlags added in v0.2.10

type RemoteAuthFlags struct {
	EnableRemoteAuth           bool
	RemoteAuthClientID         string
	RemoteAuthClientSecret     string
	RemoteAuthClientSecretFile string
	RemoteAuthScopes           []string
	RemoteAuthSkipBrowser      bool
	RemoteAuthTimeout          time.Duration
	RemoteAuthCallbackPort     int
	RemoteAuthIssuer           string
	RemoteAuthAuthorizeURL     string
	RemoteAuthTokenURL         string
	RemoteAuthResource         string

	// Token Exchange Configuration
	TokenExchangeURL              string
	TokenExchangeClientID         string
	TokenExchangeClientSecret     string
	TokenExchangeClientSecretFile string
	TokenExchangeAudience         string
	TokenExchangeScopes           []string
	TokenExchangeSubjectTokenType string
	TokenExchangeHeaderName       string
}

RemoteAuthFlags holds the common remote authentication configuration

func (*RemoteAuthFlags) BuildTokenExchangeConfig added in v0.3.8

func (f *RemoteAuthFlags) BuildTokenExchangeConfig() (*tokenexchange.Config, error)

BuildTokenExchangeConfig creates a TokenExchangeConfig from the RemoteAuthFlags. Returns nil if TokenExchangeURL is empty (token exchange is not configured). Returns error if there is a configuration error (e.g., file read failure).

type RunFlags added in v0.2.1

type RunFlags struct {
	// Transport and proxy settings
	Transport  string
	ProxyMode  string
	Host       string
	ProxyPort  int
	TargetPort int
	TargetHost string

	// Server configuration
	Name              string
	Group             string
	PermissionProfile string
	Env               []string
	Volumes           []string
	Secrets           []string

	// Remote MCP server support
	RemoteURL string

	// Security and audit
	AuthzConfig string
	AuditConfig string
	EnableAudit bool
	K8sPodPatch string

	// Image verification
	CACertPath  string
	VerifyImage string

	// OIDC configuration
	ThvCABundle        string
	JWKSAuthTokenFile  string
	JWKSAllowPrivateIP bool
	InsecureAllowHTTP  bool

	// OAuth discovery configuration
	ResourceURL string

	// Telemetry configuration
	OtelEndpoint                    string
	OtelServiceName                 string
	OtelTracingEnabled              bool
	OtelMetricsEnabled              bool
	OtelSamplingRate                float64
	OtelHeaders                     []string
	OtelInsecure                    bool
	OtelEnablePrometheusMetricsPath bool
	OtelEnvironmentVariables        []string // renamed binding to otel-env-vars
	OtelCustomAttributes            string   // Custom attributes in key=value format

	// Network isolation
	IsolateNetwork bool

	// Proxy headers
	TrustProxyHeaders bool

	// Network mode
	Network string

	// Labels
	Labels []string

	// Execution mode
	Foreground bool

	// Tools filter
	ToolsFilter []string
	// Tools override file
	ToolsOverride string

	// Configuration import
	FromConfig string

	// Environment file processing
	EnvFile    string
	EnvFileDir string

	// Ignore functionality
	IgnoreGlobally bool
	PrintOverlays  bool

	// Remote authentication
	RemoteAuthFlags RemoteAuthFlags
	OAuthParams     map[string]string
}

RunFlags holds the configuration for running MCP servers

Directories

Path Synopsis
Package inspector contains definitions for the inspector command.
Package inspector contains definitions for the inspector command.
Package ui provides terminal UI helpers for the ToolHive CLI.
Package ui provides terminal UI helpers for the ToolHive CLI.

Jump to

Keyboard shortcuts

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