config

package
v0.0.57 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultDropInConfigDir = "conf.d"
)

Variables

This section is empty.

Functions

func ConfigDirPathFromContext added in v0.0.54

func ConfigDirPathFromContext(ctx context.Context) string

func HasDefaultOverrides added in v0.0.54

func HasDefaultOverrides() bool

HasDefaultOverrides indicates whether the internal defaultOverrides function provides any overrides or an empty StaticConfig.

func RegisterProviderConfig added in v0.0.54

func RegisterProviderConfig(name string, parser ExtendedConfigParser)

func RegisterToolsetConfig added in v0.0.55

func RegisterToolsetConfig(name string, parser ExtendedConfigParser)

Types

type ExtendedConfigParser added in v0.0.55

type ExtendedConfigParser func(ctx context.Context, primitive toml.Primitive, md toml.MetaData) (api.ExtendedConfig, error)

type ReadConfigOpt added in v0.0.54

type ReadConfigOpt func(cfg *StaticConfig)

func WithDirPath added in v0.0.55

func WithDirPath(path string) ReadConfigOpt

WithDirPath returns a ReadConfigOpt that sets the config directory path.

type StaticConfig

type StaticConfig struct {
	DeniedResources []api.GroupVersionKind `toml:"denied_resources"`

	LogLevel   int    `toml:"log_level,omitzero"`
	Port       string `toml:"port,omitempty"`
	SSEBaseURL string `toml:"sse_base_url,omitempty"`
	KubeConfig string `toml:"kubeconfig,omitempty"`
	ListOutput string `toml:"list_output,omitempty"`
	// Stateless configures the MCP server to operate in stateless mode.
	// When true, the server will not send notifications to clients (e.g., tools/list_changed, prompts/list_changed).
	// This is useful for container deployments, load balancing, and serverless environments where
	// maintaining client state is not desired or possible. However, this disables dynamic tool
	// and prompt updates, requiring clients to manually refresh their tool/prompt lists.
	// Defaults to false (stateful mode with notifications enabled).
	Stateless bool `toml:"stateless,omitempty"`
	// When true, expose only tools annotated with readOnlyHint=true
	ReadOnly bool `toml:"read_only,omitempty"`
	// When true, disable tools annotated with destructiveHint=true
	DisableDestructive bool     `toml:"disable_destructive,omitempty"`
	Toolsets           []string `toml:"toolsets,omitempty"`
	// Tool configuration
	EnabledTools  []string `toml:"enabled_tools,omitempty"`
	DisabledTools []string `toml:"disabled_tools,omitempty"`
	// Prompt configuration
	Prompts []api.Prompt `toml:"prompts,omitempty"`

	// Authorization-related fields
	// RequireOAuth indicates whether the server requires OAuth for authentication.
	RequireOAuth bool `toml:"require_oauth,omitempty"`
	// OAuthAudience is the valid audience for the OAuth tokens, used for offline JWT claim validation.
	OAuthAudience string `toml:"oauth_audience,omitempty"`
	// AuthorizationURL is the URL of the OIDC authorization server.
	// It is used for token validation and for STS token exchange.
	AuthorizationURL string `toml:"authorization_url,omitempty"`
	// DisableDynamicClientRegistration indicates whether dynamic client registration is disabled.
	// If true, the .well-known endpoints will not expose the registration endpoint.
	DisableDynamicClientRegistration bool `toml:"disable_dynamic_client_registration,omitempty"`
	// OAuthScopes are the supported **client** scopes requested during the **client/frontend** OAuth flow.
	OAuthScopes []string `toml:"oauth_scopes,omitempty"`
	// StsClientId is the OAuth client ID used for backend token exchange
	StsClientId string `toml:"sts_client_id,omitempty"`
	// StsClientSecret is the OAuth client secret used for backend token exchange
	StsClientSecret string `toml:"sts_client_secret,omitempty"`
	// StsAudience is the audience for the STS token exchange.
	StsAudience string `toml:"sts_audience,omitempty"`
	// StsScopes is the scopes for the STS token exchange.
	StsScopes            []string `toml:"sts_scopes,omitempty"`
	CertificateAuthority string   `toml:"certificate_authority,omitempty"`
	ServerURL            string   `toml:"server_url,omitempty"`
	// ClusterProviderStrategy is how the server finds clusters.
	// If set to "kubeconfig", the clusters will be loaded from those in the kubeconfig.
	// If set to "in-cluster", the server will use the in cluster config
	ClusterProviderStrategy string `toml:"cluster_provider_strategy,omitempty"`

	// ClusterProvider-specific configurations
	// This map holds raw TOML primitives that will be parsed by registered provider parsers
	ClusterProviderConfigs map[string]toml.Primitive `toml:"cluster_provider_configs,omitempty"`

	// Toolset-specific configurations
	// This map holds raw TOML primitives that will be parsed by registered toolset parsers
	ToolsetConfigs map[string]toml.Primitive `toml:"toolset_configs,omitempty"`

	// Server instructions to be provided by the MCP server to the MCP client
	// This can be used to provide specific instructions on how the client should use the server
	ServerInstructions string `toml:"server_instructions,omitempty"`

	// Telemetry contains OpenTelemetry configuration options.
	// These can also be configured via OTEL_* environment variables.
	Telemetry TelemetryConfig `toml:"telemetry,omitempty"`
	// contains filtered or unexported fields
}

StaticConfig is the configuration for the server. It allows to configure server specific settings and tools to be enabled or disabled.

func Default added in v0.0.51

func Default() *StaticConfig

func Read added in v0.0.51

func Read(configPath, dropInConfigDir string) (*StaticConfig, error)

Read reads the toml file, applies drop-in configs from configDir (if provided), and returns the StaticConfig with any opts applied. Loading order: defaults → main config file → drop-in files (lexically sorted)

func ReadToml added in v0.0.51

func ReadToml(configData []byte, opts ...ReadConfigOpt) (*StaticConfig, error)

ReadToml reads the toml data, loads and applies drop-in configs from configDir (if provided), and returns the StaticConfig with any opts applied. Loading order: defaults → main config file → drop-in files (lexically sorted)

func (*StaticConfig) GetClusterProviderStrategy added in v0.0.56

func (c *StaticConfig) GetClusterProviderStrategy() string

func (*StaticConfig) GetDeniedResources added in v0.0.56

func (c *StaticConfig) GetDeniedResources() []api.GroupVersionKind

func (*StaticConfig) GetKubeConfigPath added in v0.0.56

func (c *StaticConfig) GetKubeConfigPath() string

func (*StaticConfig) GetProviderConfig added in v0.0.54

func (c *StaticConfig) GetProviderConfig(strategy string) (api.ExtendedConfig, bool)

func (*StaticConfig) GetStsAudience added in v0.0.57

func (c *StaticConfig) GetStsAudience() string

func (*StaticConfig) GetStsClientId added in v0.0.57

func (c *StaticConfig) GetStsClientId() string

func (*StaticConfig) GetStsClientSecret added in v0.0.57

func (c *StaticConfig) GetStsClientSecret() string

func (*StaticConfig) GetStsScopes added in v0.0.57

func (c *StaticConfig) GetStsScopes() []string

func (*StaticConfig) GetToolsetConfig added in v0.0.55

func (c *StaticConfig) GetToolsetConfig(name string) (api.ExtendedConfig, bool)

func (*StaticConfig) IsRequireOAuth added in v0.0.56

func (c *StaticConfig) IsRequireOAuth() bool

type TelemetryConfig added in v0.0.57

type TelemetryConfig struct {
	// Enabled explicitly enables or disables telemetry.
	// If nil (not set), telemetry is auto-enabled when Endpoint is configured.
	// If explicitly set to false, telemetry is disabled even if env vars are set.
	Enabled *bool `toml:"enabled,omitempty"`

	// Endpoint is the OTLP endpoint URL (e.g., "http://localhost:4317").
	// Can be overridden by OTEL_EXPORTER_OTLP_ENDPOINT env var.
	Endpoint string `toml:"endpoint,omitempty"`

	// Protocol specifies the OTLP protocol: "grpc" (default) or "http/protobuf".
	// Can be overridden by OTEL_EXPORTER_OTLP_PROTOCOL env var.
	Protocol string `toml:"protocol,omitempty"`

	// TracesSampler specifies the trace sampling strategy.
	// Supported values: "always_on", "always_off", "traceidratio",
	// "parentbased_always_on", "parentbased_traceidratio".
	// Can be overridden by OTEL_TRACES_SAMPLER env var.
	TracesSampler string `toml:"traces_sampler,omitempty"`

	// TracesSamplerArg is the sampling ratio for ratio-based samplers (0.0 to 1.0).
	// Can be overridden by OTEL_TRACES_SAMPLER_ARG env var.
	TracesSamplerArg *float64 `toml:"traces_sampler_arg,omitempty"`
}

TelemetryConfig contains OpenTelemetry configuration options. Values can be set via TOML config file or environment variables. Environment variables take precedence over TOML config values.

func (*TelemetryConfig) GetEndpoint added in v0.0.57

func (c *TelemetryConfig) GetEndpoint() string

GetEndpoint returns the OTLP endpoint. Environment variable OTEL_EXPORTER_OTLP_ENDPOINT takes precedence over config.

func (*TelemetryConfig) GetProtocol added in v0.0.57

func (c *TelemetryConfig) GetProtocol() string

GetProtocol returns the OTLP protocol. Environment variable OTEL_EXPORTER_OTLP_PROTOCOL takes precedence over config.

func (*TelemetryConfig) GetTracesSampler added in v0.0.57

func (c *TelemetryConfig) GetTracesSampler() string

GetTracesSampler returns the trace sampler type. Environment variable OTEL_TRACES_SAMPLER takes precedence over config.

func (*TelemetryConfig) GetTracesSamplerArg added in v0.0.57

func (c *TelemetryConfig) GetTracesSamplerArg() string

GetTracesSamplerArg returns the trace sampler argument as a string. Environment variable OTEL_TRACES_SAMPLER_ARG takes precedence over config.

func (*TelemetryConfig) IsEnabled added in v0.0.57

func (c *TelemetryConfig) IsEnabled() bool

IsEnabled returns true if telemetry should be enabled. Logic:

  • If Enabled is explicitly set to false, return false (explicit disable)
  • If Enabled is explicitly set to true, return true only if endpoint is available
  • If Enabled is nil (not set), return true if endpoint is available (auto-enable)

Jump to

Keyboard shortcuts

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