config

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package config provides configuration loading for the MCP server.

Index

Constants

View Source
const MaxSandboxTimeout = 600

MaxSandboxTimeout is the maximum allowed sandbox timeout in seconds.

Variables

This section is empty.

Functions

This section is empty.

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"`
	SemanticSearch SemanticSearchConfig `yaml:"semantic_search"`
	// contains filtered or unexported fields
}

Config is the main configuration structure.

func Load

func Load(path string) (*Config, error)

Load loads configuration from a YAML file with environment variable substitution.

func (*Config) Path

func (c *Config) Path() string

Path returns the resolved path this config was loaded from.

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration.

type ObservabilityConfig

type ObservabilityConfig struct {
	MetricsEnabled bool `yaml:"metrics_enabled"`
	MetricsPort    int  `yaml:"metrics_port"`
}

ObservabilityConfig holds observability configuration.

type ProxyAuthConfig

type ProxyAuthConfig struct {
	// 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"`
}

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"`
	HostSharedPath string  `yaml:"host_shared_path,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 SemanticSearchConfig

type SemanticSearchConfig struct {
	// ModelPath is the path to the ONNX embedding model directory.
	// The directory must contain model.onnx and tokenizer.json.
	ModelPath string `yaml:"model_path,omitempty"`
}

SemanticSearchConfig holds configuration for semantic example search.

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"`
}

StorageConfig holds configuration for local file storage.

Jump to

Keyboard shortcuts

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