Documentation
¶
Overview ¶
Package config provides configuration loading for the MCP server.
Index ¶
- Constants
- func BaseUsesProxyList(path string) (bool, error)
- func BuildOverrideMap(fields []OverrideField) map[string]any
- func DeepMerge(base, overlay map[string]any) map[string]any
- func DefaultUserConfigPath() string
- func LoadUserConfigMap(path string) (map[string]any, error)
- func SaveUserConfig(path string, values map[string]any) error
- func UserConfigPath(mainConfigPath string) string
- func UserConfigPlaceholder() string
- func ValidateMergedConfig(basePath string, overrides map[string]any) error
- type ClientConfig
- type Config
- type ConsensusSpecsConfig
- type LocalProxyClickHouseConfig
- type LocalProxyConfig
- type LocalProxyDatasetBinding
- type ObservabilityConfig
- type OverrideField
- type ProxyAuthConfig
- type ProxyConfig
- type SandboxConfig
- type SandboxLoggingConfig
- type ServerConfig
- type SessionConfig
- type StorageConfig
Constants ¶
const MaxSandboxTimeout = 7_776_000
MaxSandboxTimeout is the maximum allowed sandbox timeout in seconds (~3 months).
const (
// UserConfigFilename is the name of the user override config file.
UserConfigFilename = "config.user.yaml"
)
Variables ¶
This section is empty.
Functions ¶
func BaseUsesProxyList ¶ added in v0.30.0
BaseUsesProxyList reports whether the base config file declares a non-empty proxies list. User overrides are intentionally ignored.
func BuildOverrideMap ¶ added in v0.21.0
func BuildOverrideMap(fields []OverrideField) map[string]any
BuildOverrideMap constructs a minimal override map from field descriptors. Only fields where the current value differs from the base default are included.
func DeepMerge ¶ added in v0.21.0
DeepMerge recursively merges overlay into base. Overlay values win for leaf values; nested maps are merged recursively. Neither input map is modified.
func DefaultUserConfigPath ¶ added in v0.21.0
func DefaultUserConfigPath() string
DefaultUserConfigPath returns the user config path in the default config directory.
func LoadUserConfigMap ¶ added in v0.21.0
LoadUserConfigMap loads the user config file as a raw map. Returns an empty map if the file does not exist.
func SaveUserConfig ¶ added in v0.21.0
SaveUserConfig writes user override values to the given path. Values should be a nested map matching the config YAML structure, containing only the fields the user has overridden.
func UserConfigPath ¶ added in v0.21.0
UserConfigPath returns the path to the user config override file, derived as a sibling of the given main config path.
func UserConfigPlaceholder ¶ added in v0.21.0
func UserConfigPlaceholder() string
UserConfigPlaceholder returns the content for an empty user config placeholder file.
Types ¶
type ClientConfig ¶
type ClientConfig struct {
Server ServerConfig `yaml:"server"`
Proxy ProxyConfig `yaml:"proxy"`
Proxies []ProxyConfig `yaml:"proxies,omitempty"`
// contains filtered or unexported fields
}
ClientConfig is the subset of configuration needed by the CLI when operating as a server client.
func LoadClient ¶
func LoadClient(path string) (*ClientConfig, error)
LoadClient loads client configuration from the standard config locations.
func (*ClientConfig) Path ¶
func (c *ClientConfig) Path() string
Path returns the resolved path this client config was loaded from.
func (*ClientConfig) ServerURL ¶
func (c *ClientConfig) ServerURL() string
ServerURL returns the resolved server base URL for client use.
type Config ¶
type Config struct {
Server ServerConfig `yaml:"server"`
Sandbox SandboxConfig `yaml:"sandbox"`
// Proxy is the legacy single-proxy form, promoted to Proxies[0] for
// back-compat. Prefer Proxies (see config.example.yaml).
Proxy ProxyConfig `yaml:"proxy"`
Proxies []ProxyConfig `yaml:"proxies,omitempty"`
LocalProxy LocalProxyConfig `yaml:"local_proxy,omitempty"`
Storage StorageConfig `yaml:"storage"`
Observability ObservabilityConfig `yaml:"observability"`
ConsensusSpecs ConsensusSpecsConfig `yaml:"consensus_specs,omitempty"`
// contains filtered or unexported fields
}
Config is the main configuration structure.
func LoadWithUserOverrides ¶ added in v0.21.0
LoadWithUserOverrides loads the base config and merges any user overrides from config.user.yaml found alongside the main config file.
type ConsensusSpecsConfig ¶ added in v0.21.0
type ConsensusSpecsConfig struct {
// Repository is the GitHub owner/repo (e.g. "ethereum/consensus-specs").
// Defaults to "ethereum/consensus-specs".
Repository string `yaml:"repository,omitempty"`
// Ref is the git ref (branch, tag, or SHA) to fetch.
// When empty, the latest GitHub release tag is used.
Ref string `yaml:"ref,omitempty"`
}
ConsensusSpecsConfig configures how consensus-specs are fetched from GitHub.
type LocalProxyClickHouseConfig ¶ added in v0.26.0
type LocalProxyClickHouseConfig struct {
// Name is the datasource name to expose when the probe is live.
Name string `yaml:"name"`
// Description is the human-readable datasource description.
Description string `yaml:"description,omitempty"`
// Host is the ClickHouse host to proxy.
Host string `yaml:"host"`
// Port is the ClickHouse HTTP port to proxy.
Port int `yaml:"port"`
// Database is the default database for proxied queries.
Database string `yaml:"database,omitempty"`
// Username is the optional datasource username.
Username string `yaml:"username,omitempty"`
// Password is the optional datasource password.
Password string `yaml:"password,omitempty"`
// Secure switches the proxied ClickHouse target to HTTPS.
Secure bool `yaml:"secure,omitempty"`
// Autodiscover probes this datasource and only exposes it while live.
Autodiscover bool `yaml:"autodiscover,omitempty"`
// AutodiscoverInterval is how often to check liveness.
AutodiscoverInterval time.Duration `yaml:"autodiscover_interval,omitempty"`
// Contains declares the datasets stored in this datasource, mirroring the
// standalone proxy's contains entries. Passed through to discovery verbatim.
Contains []LocalProxyDatasetBinding `yaml:"contains,omitempty"`
}
LocalProxyClickHouseConfig configures a ClickHouse datasource for the embedded proxy.
type LocalProxyConfig ¶ added in v0.26.0
type LocalProxyConfig struct {
// Enabled controls whether the server starts an in-process local proxy.
// Defaults to true.
Enabled *bool `yaml:"enabled,omitempty"`
// ClickHouse configures local ClickHouse datasources for the embedded proxy.
ClickHouse []LocalProxyClickHouseConfig `yaml:"clickhouse,omitempty"`
}
LocalProxyConfig configures the embedded local proxy used for local datasource autodiscovery.
func (*LocalProxyConfig) IsEnabled ¶ added in v0.26.0
func (c *LocalProxyConfig) IsEnabled() bool
IsEnabled returns whether the embedded local proxy is enabled.
type LocalProxyDatasetBinding ¶ added in v0.32.0
type LocalProxyDatasetBinding struct {
Dataset string `yaml:"dataset"`
Params map[string]string `yaml:"params,omitempty"`
Notes string `yaml:"notes,omitempty"`
}
LocalProxyDatasetBinding declares a dataset stored in a local datasource. Dataset names a knowledge pack shipped with the release; Params are opaque placement hints interpreted by that pack; Notes says what distinguishes this copy from the dataset's other copies.
type ObservabilityConfig ¶
type ObservabilityConfig struct {
MetricsEnabled bool `yaml:"metrics_enabled"`
MetricsPort int `yaml:"metrics_port"`
// MetricsAddr is the full address (host:port) to serve metrics on. When set,
// it takes precedence over MetricsPort.
MetricsAddr string `yaml:"metrics_addr,omitempty"`
}
ObservabilityConfig holds observability configuration.
type OverrideField ¶ added in v0.21.0
type OverrideField struct {
// Path is the dot-separated config key (e.g., "sandbox.timeout").
Path string
// Value is the current value (as it should appear in YAML).
Value any
// Default is the base config value; if Value == Default, the field is omitted.
Default any
}
OverrideField describes a single configurable field for building override maps.
type ProxyAuthConfig ¶
type ProxyAuthConfig struct {
// Mode describes the proxy auth flow. "oauth" is the legacy embedded proxy issuer,
// "oidc" is an external OpenID Connect issuer such as Authentik, and
// "client_credentials" is the non-interactive service-account flow: access
// tokens are minted from the issuer's token endpoint using Username +
// Password (Authentik service-account form), cached in memory, and
// re-minted before expiry. No credential files are written.
Mode string `yaml:"mode,omitempty"`
// IssuerURL is the OAuth issuer URL for proxy authentication.
IssuerURL string `yaml:"issuer_url"`
// ClientID is the OAuth client ID for authentication.
ClientID string `yaml:"client_id"`
// Username is the service-account username for mode "client_credentials".
Username string `yaml:"username,omitempty"`
// Password is the service-account app password for mode "client_credentials".
// Use ${ENV_VAR} substitution to source it from the environment.
Password string `yaml:"password,omitempty"`
// Resource is the optional OAuth resource indicator to request.
// Leave empty for standard OIDC providers that do not use RFC 8707 resource parameters.
Resource string `yaml:"resource,omitempty"`
// Scopes are the OAuth scopes requested at login. When empty, the auth client
// requests its defaults (openid, email, groups, offline_access). When set,
// this list is sent verbatim — so include those base scopes plus any extras.
// For example, requesting the workflow-engine audience makes Authentik
// cross-grant that audience to the panda-proxy token so the same credential
// works against the workflow engine in passthrough mode. Omitting
// offline_access means no refresh token is issued.
Scopes []string `yaml:"scopes,omitempty"`
// RefreshTokenTTL is the expected lifetime of the refresh token issued by the
// OIDC provider. When set, the client will proactively refresh at 50% of this
// duration to keep the refresh token alive via provider rotation.
RefreshTokenTTL time.Duration `yaml:"refresh_token_ttl,omitempty"`
}
ProxyAuthConfig configures authentication for the proxy.
type ProxyConfig ¶
type ProxyConfig struct {
// Name is the configured proxy identifier used to tag datasource ownership.
Name string `yaml:"name,omitempty"`
// URL is the base URL of the proxy server (e.g., http://localhost:18081).
URL string `yaml:"url"`
// Auth configures authentication for the proxy.
// Optional - if not set, the proxy must allow unauthenticated access.
Auth *ProxyAuthConfig `yaml:"auth,omitempty"`
}
ProxyConfig holds proxy connection configuration. The MCP server always connects to a proxy server via this config.
func (ProxyConfig) ResolvedAuthIssuerURL ¶ added in v0.37.0
func (p ProxyConfig) ResolvedAuthIssuerURL() string
ResolvedAuthIssuerURL returns the OIDC issuer used for this proxy's auth: the explicit issuer_url, or the proxy URL when unset. It is the single source of truth so the proxy token source and the server's credential controller derive the same credential file.
func (ProxyConfig) ResolvedAuthResource ¶ added in v0.37.0
func (p ProxyConfig) ResolvedAuthResource() string
ResolvedAuthResource returns the RFC 8707 resource used for this proxy's auth, applying the same defaulting the credential store keys on: empty for external issuers (oidc, client_credentials), and the proxy URL for the legacy embedded oauth issuer. Kept in lockstep with ResolvedAuthIssuerURL so credential paths never diverge between the proxy client and the server's auth controller.
type SandboxConfig ¶
type SandboxConfig struct {
Backend string `yaml:"backend"`
Image string `yaml:"image"`
Timeout int `yaml:"timeout"`
MemoryLimit string `yaml:"memory_limit"`
CPULimit float64 `yaml:"cpu_limit"`
Network string `yaml:"network"`
// Instance identifies this server's sandbox containers with a custom label.
// Used to distinguish containers from different server instances (e.g., probe runner vs production).
// When set, containers are labeled with "io.ethpandaops-panda.instance=<value>".
Instance string `yaml:"instance,omitempty"`
// Session configuration for persistent execution environments.
Sessions SessionConfig `yaml:"sessions"`
// Logging configuration for sandbox executions.
Logging SandboxLoggingConfig `yaml:"logging"`
}
SandboxConfig holds sandbox execution configuration.
type SandboxLoggingConfig ¶
type SandboxLoggingConfig struct {
// LogCode logs the full Python code submitted to execute_python.
// Disabled by default as code may contain sensitive data.
LogCode bool `yaml:"log_code"`
// LogOutput logs stdout and stderr from execution.
// Disabled by default as output may be large or contain sensitive data.
LogOutput bool `yaml:"log_output"`
}
SandboxLoggingConfig holds logging configuration for sandbox executions.
type ServerConfig ¶
type ServerConfig struct {
Host string `yaml:"host"`
Port int `yaml:"port"`
BaseURL string `yaml:"base_url"`
SandboxURL string `yaml:"sandbox_url,omitempty"`
URL string `yaml:"url,omitempty"`
// Uploads gates the `panda upload` surface (the upload/publish API and the
// /u/ preview pages). Unset means enabled; set it to false to opt out.
// Nothing leaves the machine without an explicit publish either way.
Uploads *bool `yaml:"uploads,omitempty"`
// Deprecated: Transport is accepted for backwards compatibility but ignored.
// The server always runs HTTP with both SSE and streamable-http transports.
Transport string `yaml:"transport,omitempty"`
}
ServerConfig holds server-specific configuration.
func (ServerConfig) UploadsEnabled ¶ added in v0.38.0
func (c ServerConfig) UploadsEnabled() bool
UploadsEnabled reports whether the `panda upload` surface is on (the default when server.uploads is unset).
type SessionConfig ¶
type SessionConfig struct {
// Enabled controls whether session support is available. Defaults to true.
Enabled *bool `yaml:"enabled,omitempty"`
// TTL is the duration after which an idle session is destroyed (since last use).
TTL time.Duration `yaml:"ttl"`
// MaxDuration is the maximum lifetime of a session regardless of activity.
MaxDuration time.Duration `yaml:"max_duration"`
// MaxSessions is the maximum number of concurrent sessions allowed.
MaxSessions int `yaml:"max_sessions"`
}
SessionConfig holds configuration for persistent sandbox sessions.
func (*SessionConfig) IsEnabled ¶
func (c *SessionConfig) IsEnabled() bool
IsEnabled returns whether sessions are enabled (defaults to true).
type StorageConfig ¶
type StorageConfig struct {
// BaseDir is the directory where uploaded files are stored.
// Defaults to ~/.panda/data/storage.
BaseDir string `yaml:"base_dir,omitempty"`
// CacheDir is the directory for the local embedding vector cache.
// Defaults to a "cache" sibling of BaseDir.
CacheDir string `yaml:"cache_dir,omitempty"`
}
StorageConfig holds configuration for local file storage.