Documentation
¶
Overview ¶
Package config provides configuration loading for the MCP server.
Index ¶
- Constants
- 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 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 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"`
// 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 ProxyConfig `yaml:"proxy"`
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 ObservabilityConfig ¶
type ObservabilityConfig struct {
MetricsEnabled bool `yaml:"metrics_enabled"`
MetricsPort int `yaml:"metrics_port"`
}
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 Dex.
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"`
// 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"`
// 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 {
// 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.
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"`
// 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.
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.