config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config loads, defaults, and validates the gateway's declarative YAML configuration. Loading fails fast: a malformed file, an unknown field, a missing referenced secret, or a rule naming an unknown downstream or client is an error at startup rather than a surprise at request time (design §7, §8).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Audit

type Audit struct {
	// Sink is "stdout" or "file:/path/to/audit.jsonl".
	Sink string `yaml:"sink"`
	// Buffer is the bounded handoff buffer size.
	Buffer int `yaml:"buffer"`
	// HighWaterMark is the buffer fraction above which success records shed.
	HighWaterMark float64 `yaml:"high_water_mark"`
	// Flush controls batch flushing to the OS page cache.
	Flush Flush `yaml:"flush"`
	// FsyncInterval is the group-commit interval to disk.
	FsyncInterval Duration `yaml:"fsync_interval"`
	// Overflow is the success-record overflow policy: "shed" or "block".
	Overflow OverflowPolicy `yaml:"overflow"`
	// SecurityBlockTimeout bounds how long a security record blocks before the
	// request is failed closed.
	SecurityBlockTimeout Duration `yaml:"security_block_timeout"`
}

Audit configures the async audit write path.

type Client

type Client struct {
	ID        string `yaml:"id"`
	APIKeyEnv string `yaml:"api_key_env"`
}

Client maps a named identity to the environment variable holding its API key.

type Config

type Config struct {
	// Listen is the host:port the client-facing server binds.
	Listen string `yaml:"listen"`
	// AllowedOrigins is the Origin allowlist for the DNS-rebinding guard.
	AllowedOrigins []string `yaml:"allowed_origins"`
	// Clients are the authenticated client identities.
	Clients []Client `yaml:"clients"`
	// Downstreams are the MCP servers the gateway proxies.
	Downstreams []Downstream `yaml:"downstreams"`
	// Policy is the deny-by-default access policy.
	Policy Policy `yaml:"policy"`
	// Redaction configures outbound secret and PII redaction.
	Redaction Redaction `yaml:"redaction"`
	// Audit configures the audit write path.
	Audit Audit `yaml:"audit"`
}

Config is the gateway configuration.

func Load

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

Load reads, defaults, and validates the configuration at path. Any failure — unreadable file, malformed YAML, unknown field, or a validation error — is returned, so a bad configuration stops startup rather than surfacing later.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks the configuration and returns a combined error describing every problem found, or nil if the configuration is sound. It is the fail-fast gate: a missing referenced secret, an unknown transport or session_mode, a rule naming an unknown client or downstream, an uncompilable redaction pattern, or an out-of-range tuning value is reported here rather than at request time (design §7, §8).

type Downstream

type Downstream struct {
	Name string `yaml:"name"`
	// Transport is "stdio" or "http".
	Transport Transport `yaml:"transport"`
	// Command is the stdio subprocess argv (stdio transport only).
	Command []string `yaml:"command"`
	// URL is the remote endpoint (http transport only).
	URL string `yaml:"url"`
	// SessionMode applies to stdio downstreams; it defaults to per_client.
	SessionMode SessionMode `yaml:"session_mode"`
	// Pool bounds the stdio subprocess pool (stdio transport only).
	Pool Pool `yaml:"pool"`
	// Secrets are connection-level credentials injected by the gateway, keyed by
	// env var (stdio) or header name (http), each resolved from an env var.
	Secrets map[string]SecretRef `yaml:"secrets"`
	// Health configures the downstream health check.
	Health Health `yaml:"health"`
}

Downstream is one downstream MCP server.

type Duration

type Duration time.Duration

Duration is a time.Duration that unmarshals from a YAML string such as "2s" or "90s", so durations read naturally in the config file.

func (Duration) Duration

func (d Duration) Duration() time.Duration

Duration returns the value as a time.Duration.

func (Duration) String

func (d Duration) String() string

String renders the duration like time.Duration does.

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML parses a duration string with time.ParseDuration.

type Flush

type Flush struct {
	MaxRecords  int      `yaml:"max_records"`
	MaxInterval Duration `yaml:"max_interval"`
}

Flush controls audit batch flushing.

type Health

type Health struct {
	Interval Duration `yaml:"interval"`
}

Health configures a downstream health check.

type OverflowPolicy

type OverflowPolicy string

OverflowPolicy is the audit buffer's policy for success records under load.

const (
	OverflowShed  OverflowPolicy = "shed"
	OverflowBlock OverflowPolicy = "block"
)

type Pattern

type Pattern struct {
	Name   string `yaml:"name"`
	Regex  string `yaml:"regex"`
	Anchor string `yaml:"anchor"`
}

Pattern is a literal-gated PII regex: the regex runs only when Anchor is present in the scanned text.

type Policy

type Policy struct {
	Default PolicyDefault `yaml:"default"`
	Rules   []Rule        `yaml:"rules"`
}

Policy is the access policy.

type PolicyDefault

type PolicyDefault string

PolicyDefault is the default access decision when no rule matches.

const (
	DefaultDeny  PolicyDefault = "deny"
	DefaultAllow PolicyDefault = "allow"
)

type Pool

type Pool struct {
	Max            int      `yaml:"max"`
	AcquireTimeout Duration `yaml:"acquire_timeout"`
	IdleTTL        Duration `yaml:"idle_ttl"`
}

Pool bounds an stdio subprocess pool.

type Redaction

type Redaction struct {
	Patterns []Pattern `yaml:"patterns"`
	// MaxResultBytes caps a buffered tool result before scanning.
	MaxResultBytes int `yaml:"max_result_bytes"`
}

Redaction configures outbound redaction.

type Rule

type Rule struct {
	Client string   `yaml:"client"`
	Allow  []string `yaml:"allow"`
}

Rule allows a client to call a set of namespaced tools (wildcards permitted).

type SecretRef

type SecretRef struct {
	Env string `yaml:"env"`
}

SecretRef names the environment variable holding a secret value.

type SessionMode

type SessionMode string

SessionMode controls how stdio subprocesses are shared across client sessions.

const (
	SessionPerClient SessionMode = "per_client"
	SessionShared    SessionMode = "shared"
)

type Transport

type Transport string

Transport is a downstream transport kind.

const (
	TransportStdio Transport = "stdio"
	TransportHTTP  Transport = "http"
)

Jump to

Keyboard shortcuts

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