config

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FlagPrefixLong represents the expected prefix for a long format flag (e.g. --flag).
	FlagPrefixLong = "--"

	// FlagPrefixShort represents the expected prefix for a short format flag (e.g. -f).
	FlagPrefixShort = "-"

	// FlagValueSeparator represents the value which is used to separate the flag name from the value.
	FlagValueSeparator = "="
)

Variables

View Source
var (
	ErrInvalidValue     = errors.New("config value invalid")
	ErrInvalidKey       = errors.New("config key invalid")
	ErrConfigLoadFailed = errors.New("failed to load configuration")
)

Functions

func Flows

func Flows() map[Flow]struct{}

Flows returns the canonical set of allowed flows. Returns a clone to prevent modification of the internal map.

func MergeArgs

func MergeArgs(a, b []string) []string

MergeArgs merges all args present in 'b' into 'a', overwriting collisions. Any value originally in 'a' but not in 'b' are preserved. Supports args in the format --arg1 (bool flags) and --arg1=value1 (key/value flags). The returned slice preserves the order of 'a', and appends new flags from 'b' in order.

func MergeArgsWithPositionalHandling

func MergeArgsWithPositionalHandling(existing, new []string) []string

MergeArgsWithPositionalHandling implements Option 1 behavior: - Replaces all positional arguments from 'existing' with those from 'new' - Merges flags from 'new' into 'existing' (new flags override existing ones) Returns the combined result with positional args first, then merged flags.

func NewErrInvalidValue

func NewErrInvalidValue(key string, value string) error

NewErrInvalidValue returns an error for an invalid configuration value.

func NormalizeArgs

func NormalizeArgs(rawArgs []string) []string

NormalizeArgs normalizes a slice of (CLI) arguments by extracting and formatting only flags.

It transforms:

--flag value     -> --flag=value
-f value         -> -f=value
--flag=value     -> preserved as-is
-xyz             -> -x, -y, -z (expanded short flags)

Positional arguments are excluded.

This function is intended for internal normalization of flag arguments only.

func OrderedFlowNames

func OrderedFlowNames() []string

OrderedFlowNames returns the names of allowed flows in order.

func ParseFlowsDistinct

func ParseFlowsDistinct(flags []string) map[Flow]struct{}

ParseFlowsDistinct validates and reduces flow strings to a distinct set. Flow strings are normalized before validation. Invalid flows are silently ignored. Returns an empty map if no valid flows are found.

func ProcessAllArgs

func ProcessAllArgs(rawArgs []string) []string

ProcessAllArgs processes a slice of arguments, normalizing flags while preserving positional arguments. It processes arguments sequentially, normalizing flag groups as it encounters them, and returns them in their original relative order.

Examples:

  • ["--flag", "value", "pos1", "pos2"] -> ["--flag=value", "pos1", "pos2"]
  • ["pos1", "--flag=value", "pos2"] -> ["pos1", "--flag=value", "pos2"]
  • ["/path/to/dir", "--verbose"] -> ["/path/to/dir", "--verbose"]

func RemoveMatchingFlags

func RemoveMatchingFlags(args []string, toRemove []string) []string

RemoveMatchingFlags filters out all (CLI) flags from the input 'args' slice that match (based on a prefix and case) any of the specified flag names in 'toRemove'. The returned slice contains the filtered args with their order preserved.

func ValidHTTPRequestMethods

func ValidHTTPRequestMethods() map[string]struct{}

ValidHTTPRequestMethods returns a map of all valid HTTP request methods. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Methods

func ValidatePluginBinaries

func ValidatePluginBinaries(cfg *Config) error

ValidatePluginBinaries validates that configured plugin binaries exist on the filesystem.

Types

type APIConfigSection

type APIConfigSection struct {
	// Address to bind the API server (e.g., "0.0.0.0:8090")
	// Maps to CLI flag --addr
	Addr *string `json:"addr,omitempty" toml:"addr,omitempty" yaml:"addr,omitempty"`

	// Nested timeout configuration for API operations
	Timeout *APITimeoutConfigSection `json:"timeout,omitempty" toml:"timeout,omitempty" yaml:"timeout,omitempty"`

	// Nested CORS configuration for cross-origin requests
	CORS *CORSConfigSection `json:"cors,omitempty" toml:"cors,omitempty" yaml:"cors,omitempty"`
}

APIConfigSection contains API server configuration settings.

NOTE: if you add/remove fields you must review the associated Getter, Setter and Validator implementations, along with /docs/daemon-configuration.md.

func (*APIConfigSection) AvailableKeys

func (a *APIConfigSection) AvailableKeys() []SchemaKey

AvailableKeys implements SchemaProvider for APIConfigSection.

func (*APIConfigSection) Get

func (a *APIConfigSection) Get(keys ...string) (any, error)

Get implements Getter for APIConfigSection. Returns all API configuration when called with no keys, or specific values when keys are provided.

func (*APIConfigSection) Set

func (a *APIConfigSection) Set(path string, value string) (context.UpsertResult, error)

Set implements Setter for APIConfigSection. Handles API configuration at the top level and routes to subsections.

func (*APIConfigSection) Validate

func (a *APIConfigSection) Validate() error

Validate implements Validator for APIConfigSection. Validates API configuration values.

type APITimeoutConfigSection

type APITimeoutConfigSection struct {
	// Shutdown timeout for graceful API server shutdown
	// Maps to CLI flag --timeout-api-shutdown
	Shutdown *Duration `json:"shutdown,omitempty" toml:"shutdown,omitempty" yaml:"shutdown,omitempty"`
}

APITimeoutConfigSection contains timeout settings for API operations.

NOTE: if you add/remove fields you must review the associated Getter, Setter and Validator implementations, along with /docs/daemon-configuration.md.

func (*APITimeoutConfigSection) AvailableKeys

func (a *APITimeoutConfigSection) AvailableKeys() []SchemaKey

AvailableKeys implements SchemaProvider for APITimeoutConfigSection.

func (*APITimeoutConfigSection) Get

func (a *APITimeoutConfigSection) Get(keys ...string) (any, error)

Get implements Getter for APITimeoutConfigSection. Returns all timeout configuration when called with no keys, or specific values when keys are provided.

func (*APITimeoutConfigSection) Set

Set implements Setter for APITimeoutConfigSection. Handles API timeout configuration at the leaf level.

func (*APITimeoutConfigSection) Validate

func (a *APITimeoutConfigSection) Validate() error

Validate implements Validator for APITimeoutConfigSection. Validates API timeout configuration values.

type CORSConfigSection

type CORSConfigSection struct {
	// Enable CORS support
	// Maps to CLI flag --cors-enable
	Enable *bool `json:"enable,omitempty" toml:"enable,omitempty" yaml:"enable,omitempty"`

	// Allowed origins for CORS requests
	// Maps to CLI flag --cors-origins
	Origins []string `json:"allowOrigins,omitempty" toml:"allow_origins,omitempty" yaml:"allow_origins,omitempty"`

	// Allowed HTTP methods for CORS requests
	// Maps to CLI flag --cors-methods
	Methods []string `json:"allowMethods,omitempty" toml:"allow_methods,omitempty" yaml:"allow_methods,omitempty"`

	// Allowed headers for CORS requests
	// Maps to CLI flag --cors-headers
	Headers []string `json:"allowHeaders,omitempty" toml:"allow_headers,omitempty" yaml:"allow_headers,omitempty"`

	// Headers exposed to the client
	// Maps to CLI flag --cors-expose-headers
	ExposeHeaders []string `json:"exposeHeaders,omitempty" toml:"expose_headers,omitempty" yaml:"expose_headers,omitempty"`

	// Allow credentials in CORS requests
	// Maps to CLI flag --cors-credentials
	Credentials *bool `json:"allowCredentials,omitempty" toml:"allow_credentials,omitempty" yaml:"allow_credentials,omitempty"`

	// Maximum age for CORS preflight cache
	// Maps to CLI flag --cors-max-age
	MaxAge *Duration `json:"maxAge,omitempty" toml:"max_age,omitempty" yaml:"max_age,omitempty"`
}

CORSConfigSection contains Cross-Origin Resource Sharing (CORS) configuration.

NOTE: if you add/remove fields you must review the associated Getter, Setter and Validator implementations, along with /docs/daemon-configuration.md.

func (*CORSConfigSection) AvailableKeys

func (c *CORSConfigSection) AvailableKeys() []SchemaKey

AvailableKeys implements SchemaProvider for CORSConfigSection.

func (*CORSConfigSection) EnableOrDefault

func (c *CORSConfigSection) EnableOrDefault(defaultEnable bool) bool

EnableOrDefault returns the CORS enable setting, falling back to defaultEnable if not set.

func (*CORSConfigSection) Get

func (c *CORSConfigSection) Get(keys ...string) (any, error)

Get implements Getter for CORSConfigSection. Returns all CORS configuration when called with no keys, or specific values when keys are provided.

func (*CORSConfigSection) Set

func (c *CORSConfigSection) Set(path string, value string) (context.UpsertResult, error)

Set implements Setter for CORSConfigSection. Handles CORS configuration at the leaf level.

func (*CORSConfigSection) Validate

func (c *CORSConfigSection) Validate() error

Validate implements Validator for CORSConfigSection. Validates CORS configuration values.

type Categories

type Categories []Category

Categories represents collection of Category types.

func OrderedCategories

func OrderedCategories() Categories

OrderedCategories returns the list of categories in the order they are executed in the plugin pipeline. This ordering is important for consistent plugin execution across the system.

func (Categories) String

func (c Categories) String() string

String implements fmt.Stringer for a collection of plugin categories, converting them to a comma separated string.

type Category

type Category string

Category represents a plugin category.

const (
	// CategoryAuthentication represents authentication plugins.
	CategoryAuthentication Category = "authentication"

	// CategoryAuthorization represents authorization plugins.
	CategoryAuthorization Category = "authorization"

	// CategoryRateLimiting represents rate limiting plugins.
	CategoryRateLimiting Category = "rate_limiting"

	// CategoryValidation represents validation plugins.
	CategoryValidation Category = "validation"

	// CategoryContent represents content transformation plugins.
	CategoryContent Category = "content"

	// CategoryObservability represents observability plugins.
	CategoryObservability Category = "observability"

	// CategoryAudit represents audit/compliance logging plugins.
	CategoryAudit Category = "audit"
)

func (*Category) Set

func (c *Category) Set(v string) error

Set is used by Cobra to set the category value from a string. NOTE: This is also required by Cobra as part of implementing flag.Value.

func (*Category) String

func (c *Category) String() string

func (*Category) Type

func (c *Category) Type() string

Type is used by Cobra/pflag to describe the flag's underlying type.

type Config

type Config struct {
	Servers []ServerEntry `toml:"servers"`
	Daemon  *DaemonConfig `toml:"daemon,omitempty"`
	Plugins *PluginConfig `toml:"plugins,omitempty"`
	// contains filtered or unexported fields
}

Config represents the .mcpd.toml file structure.

func (*Config) AddServer

func (c *Config) AddServer(entry ServerEntry) error

AddServer attempts to persist a new MCP Server to the configuration file (.mcpd.toml).

func (*Config) DeletePlugin

func (c *Config) DeletePlugin(category Category, name string) (context.UpsertResult, error)

DeletePlugin removes a plugin entry and saves the configuration.

func (*Config) ListServers

func (c *Config) ListServers() []ServerEntry

ListServers returns a copy of the currently configured server entries. This provides read-only access to the internal configuration without exposing direct mutation of the underlying slice.

func (*Config) MovePlugin

func (c *Config) MovePlugin(category Category, name string, opts ...MoveOption) (context.UpsertResult, error)

MovePlugin moves a plugin within or between categories. Use MoveOption functions to specify the operation:

  • WithToCategory: move to a different category
  • WithBefore/WithAfter: position relative to another plugin
  • WithPosition: move to absolute position (1-based)
  • WithForce: overwrite existing plugin in target category

func (*Config) Plugin

func (c *Config) Plugin(category Category, name string) (PluginEntry, bool)

Plugin retrieves a plugin by category and name.

func (*Config) RemoveServer

func (c *Config) RemoveServer(name string) error

RemoveServer removes a server entry by name from the configuration file (.mcpd.toml).

func (*Config) SaveConfig

func (c *Config) SaveConfig() error

SaveConfig saves the current configuration to the config file.

func (*Config) UpsertPlugin

func (c *Config) UpsertPlugin(category Category, entry PluginEntry) (context.UpsertResult, error)

UpsertPlugin creates or updates a plugin entry and saves the configuration.

type DaemonConfig

type DaemonConfig struct {
	// API configuration (includes address and nested timeout/cors)
	API *APIConfigSection `json:"api,omitempty" toml:"api,omitempty" yaml:"api,omitempty"`

	// MCP configuration (includes nested timeout and interval settings)
	MCP *MCPConfigSection `json:"mcp,omitempty" toml:"mcp,omitempty" yaml:"mcp,omitempty"`
}

DaemonConfig represents daemon-specific configuration that can be stored in .mcpd.toml. This extends the existing Config struct with daemon settings.

NOTE: if you add/remove fields you must review the associated Getter, Setter and Validator implementations, along with /docs/daemon-configuration.md.

func (*DaemonConfig) AvailableKeys

func (d *DaemonConfig) AvailableKeys() []SchemaKey

AvailableKeys implements SchemaProvider for DaemonConfig.

func (*DaemonConfig) Get

func (d *DaemonConfig) Get(keys ...string) (any, error)

Get implements Getter for DaemonConfig. Routes configuration retrieval to the appropriate subsection. When called with no keys, returns the entire daemon configuration structure.

func (*DaemonConfig) Set

func (d *DaemonConfig) Set(path string, value string) (context.UpsertResult, error)

Set implements Setter for DaemonConfig. Routes configuration changes to the appropriate subsection.

func (*DaemonConfig) Validate

func (d *DaemonConfig) Validate() error

Validate implements Validator for DaemonConfig. Validates daemon configuration by delegating to subsections.

type DefaultLoader

type DefaultLoader struct{}

func (*DefaultLoader) Init

func (d *DefaultLoader) Init(path string) error

Init creates the base skeleton configuration file for the mcpd project.

func (*DefaultLoader) Load

func (d *DefaultLoader) Load(path string) (Modifier, error)

type Duration

type Duration time.Duration

Duration is a custom time.Duration type that provides improved marshaling.

func (*Duration) MarshalText

func (d *Duration) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler for Duration.

func (*Duration) String

func (d *Duration) String() string

String returns a human-readable string representation of the duration.

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler for Duration.

type Flow

type Flow string

Flow represents the execution phase for a plugin.

const (
	// FlowRequest indicates the plugin executes during the request phase.
	FlowRequest Flow = "request"

	// FlowResponse indicates the plugin executes during the response phase.
	FlowResponse Flow = "response"
)

func (Flow) IsValid

func (f Flow) IsValid() bool

IsValid returns true if the Flow is a recognized value.

type Getter

type Getter interface {
	// Get retrieves a configuration value using path segments, or all configured values when no key specified.
	// Single argument gets a specific key, multiple arguments traverse nested structure.
	// Returns the value or any error encountered during retrieval.
	// NOTE: When used without any keys, no errors are returned for missing configuration.
	Get(keys ...string) (any, error)
}

Getter defines the interface for getting configuration values using path segments. Implementations should handle path routing and value retrieval appropriate to their level.

type Initializer

type Initializer interface {
	Init(path string) error
}

type Loader

type Loader interface {
	Load(path string) (Modifier, error)
}

type MCPConfigSection

type MCPConfigSection struct {
	// Nested timeout configuration for MCP operations
	Timeout *MCPTimeoutConfigSection `json:"timeout,omitempty" toml:"timeout,omitempty" yaml:"timeout,omitempty"`

	// Nested interval configuration for MCP periodic operations
	Interval *MCPIntervalConfigSection `json:"interval,omitempty" toml:"interval,omitempty" yaml:"interval,omitempty"`
}

MCPConfigSection contains MCP (Model Context Protocol) server configuration settings.

NOTE: if you add/remove fields you must review the associated Getter, Setter and Validator implementations, along with /docs/daemon-configuration.md.

func (*MCPConfigSection) AvailableKeys

func (m *MCPConfigSection) AvailableKeys() []SchemaKey

AvailableKeys implements SchemaProvider for MCPConfigSection.

func (*MCPConfigSection) Get

func (m *MCPConfigSection) Get(keys ...string) (any, error)

Get implements Getter for MCPConfigSection. Returns all MCP configuration when called with no keys, or routes to subsections when keys are provided.

func (*MCPConfigSection) Set

func (m *MCPConfigSection) Set(path string, value string) (context.UpsertResult, error)

Set implements Setter for MCPConfigSection. Routes MCP configuration changes to the appropriate subsection.

func (*MCPConfigSection) Validate

func (m *MCPConfigSection) Validate() error

Validate implements Validator for MCPConfigSection. Validates MCP configuration by delegating to subsections.

type MCPIntervalConfigSection

type MCPIntervalConfigSection struct {
	// Health check interval for MCP servers
	// Maps to CLI flag --interval-mcp-health
	Health *Duration `json:"health,omitempty" toml:"health,omitempty" yaml:"health,omitempty"`
}

MCPIntervalConfigSection contains interval settings for periodic MCP operations.

NOTE: if you add/remove fields you must review the associated Getter, Setter and Validator implementations, along with /docs/daemon-configuration.md.

func (*MCPIntervalConfigSection) AvailableKeys

func (m *MCPIntervalConfigSection) AvailableKeys() []SchemaKey

AvailableKeys implements SchemaProvider for MCPIntervalConfigSection.

func (*MCPIntervalConfigSection) Get

func (m *MCPIntervalConfigSection) Get(keys ...string) (any, error)

Get implements Getter for MCPIntervalConfigSection. Returns all interval configuration when called with no keys, or specific values when keys are provided.

func (*MCPIntervalConfigSection) Set

Set implements Setter for MCPIntervalConfigSection. Handles MCP interval configuration at the leaf level.

func (*MCPIntervalConfigSection) Validate

func (m *MCPIntervalConfigSection) Validate() error

Validate implements Validator for MCPIntervalConfigSection. Validates MCP interval configuration values.

type MCPTimeoutConfigSection

type MCPTimeoutConfigSection struct {
	// Shutdown timeout for graceful MCP server shutdown
	// Maps to CLI flag --timeout-mcp-shutdown
	Shutdown *Duration `json:"shutdown,omitempty" toml:"shutdown,omitempty" yaml:"shutdown,omitempty"`

	// Initialization timeout for MCP server startup
	// Maps to CLI flag --timeout-mcp-init
	Init *Duration `json:"init,omitempty" toml:"init,omitempty" yaml:"init,omitempty"`

	// Health check timeout for MCP servers
	// Maps to CLI flag --timeout-mcp-health
	Health *Duration `json:"health,omitempty" toml:"health,omitempty" yaml:"health,omitempty"`
}

MCPTimeoutConfigSection contains timeout settings for MCP operations.

NOTE: if you add/remove fields you must review the associated Getter, Setter and Validator implementations, along with /docs/daemon-configuration.md.

func (*MCPTimeoutConfigSection) AvailableKeys

func (m *MCPTimeoutConfigSection) AvailableKeys() []SchemaKey

AvailableKeys implements SchemaProvider for MCPTimeoutConfigSection.

func (*MCPTimeoutConfigSection) Get

func (m *MCPTimeoutConfigSection) Get(keys ...string) (any, error)

Get implements Getter for MCPTimeoutConfigSection. Returns all timeout configuration when called with no keys, or specific values when keys are provided.

func (*MCPTimeoutConfigSection) Set

Set implements Setter for MCPTimeoutConfigSection. Handles MCP timeout configuration at the leaf level.

func (*MCPTimeoutConfigSection) Validate

func (m *MCPTimeoutConfigSection) Validate() error

Validate implements Validator for MCPTimeoutConfigSection. Validates MCP timeout configuration values.

type Modifier

type Modifier interface {
	AddServer(entry ServerEntry) error
	RemoveServer(name string) error
	ListServers() []ServerEntry
	SaveConfig() error
}

type MoveOption

type MoveOption func(*moveOptions) error

MoveOption defines a functional option for configuring plugin move operations.

func WithAfter

func WithAfter(name string) MoveOption

WithAfter positions the plugin after the named plugin.

func WithBefore

func WithBefore(name string) MoveOption

WithBefore positions the plugin before the named plugin.

func WithForce

func WithForce(force bool) MoveOption

WithForce overwrites an existing plugin with the same name in the target category.

func WithPosition

func WithPosition(pos int) MoveOption

WithPosition sets the absolute position (1-based).

func WithToCategory

func WithToCategory(category Category) MoveOption

WithToCategory moves the plugin to a different category.

type PluginConfig

type PluginConfig struct {
	// Dir specifies the directory containing plugin binaries.
	Dir string `json:"dir,omitempty" toml:"dir,omitempty" yaml:"dir,omitempty"`

	// Authentication plugins execute first, validating identity.
	Authentication []PluginEntry `json:"authentication,omitempty" toml:"authentication,omitempty" yaml:"authentication,omitempty"`

	// Authorization plugins verify permissions after authentication.
	Authorization []PluginEntry `json:"authorization,omitempty" toml:"authorization,omitempty" yaml:"authorization,omitempty"`

	// RateLimiting plugins enforce request rate limits.
	RateLimiting []PluginEntry `json:"rateLimiting,omitempty" toml:"rate_limiting,omitempty" yaml:"rate_limiting,omitempty"`

	// Validation plugins check request/response structure and content.
	Validation []PluginEntry `json:"validation,omitempty" toml:"validation,omitempty" yaml:"validation,omitempty"`

	// Content plugins transform request/response payloads.
	Content []PluginEntry `json:"content,omitempty" toml:"content,omitempty" yaml:"content,omitempty"`

	// Observability plugins collect metrics and traces (non-blocking).
	Observability []PluginEntry `json:"observability,omitempty" toml:"observability,omitempty" yaml:"observability,omitempty"`

	// Audit plugins log compliance and security events (typically required).
	Audit []PluginEntry `json:"audit,omitempty" toml:"audit,omitempty" yaml:"audit,omitempty"`
}

PluginConfig represents the top-level plugin configuration.

NOTE: if you add/remove fields you must review the associated validation implementation.

func (*PluginConfig) AllCategories

func (p *PluginConfig) AllCategories() map[Category][]PluginEntry

AllCategories returns all plugin entries organized by category. Only categories with configured plugins are included in the returned map.

func (*PluginConfig) ListPlugins

func (p *PluginConfig) ListPlugins(category Category) []PluginEntry

ListPlugins returns all plugins in a category.

func (*PluginConfig) PluginNamesDistinct

func (p *PluginConfig) PluginNamesDistinct() map[string]struct{}

PluginNamesDistinct returns the names of all distinct plugins specified in config.

func (*PluginConfig) Validate

func (p *PluginConfig) Validate() error

Validate validates plugin configuration structure (names, flows, etc.)

type PluginEntry

type PluginEntry struct {
	// Name of the plugin binary in the plugins directory.
	Name string `json:"name" toml:"name" yaml:"name"`

	// CommitHash for validating plugin version against metadata.
	CommitHash *string `json:"commitHash,omitempty" toml:"commit_hash,omitempty" yaml:"commit_hash,omitempty"`

	// Required indicates if plugin failure should block the request.
	Required *bool `json:"required,omitempty" toml:"required,omitempty" yaml:"required,omitempty"`

	// Flows specifies when the plugin executes (request, response, or both).
	// Treated as a set - duplicates are rejected during validation.
	Flows []Flow `json:"flows" toml:"flows" yaml:"flows"`
}

PluginEntry represents a single plugin configuration within a category.

func (*PluginEntry) Equals

func (e *PluginEntry) Equals(other *PluginEntry) bool

Equals compares two PluginEntry instances for equality.

func (*PluginEntry) FlowsDistinct

func (e *PluginEntry) FlowsDistinct() map[Flow]struct{}

FlowsDistinct converts the Flows slice to a set for efficient lookup.

func (*PluginEntry) HasFlow

func (e *PluginEntry) HasFlow(flow Flow) bool

HasFlow checks if the plugin is configured for the specified flow.

func (*PluginEntry) Validate

func (e *PluginEntry) Validate() error

Validate validates a single PluginEntry.

type PluginModifier

type PluginModifier interface {
	// Plugin retrieves a plugin by category and name.
	Plugin(category Category, name string) (PluginEntry, bool)

	// UpsertPlugin creates or updates a plugin entry.
	UpsertPlugin(category Category, entry PluginEntry) (context.UpsertResult, error)

	// DeletePlugin removes a plugin entry.
	DeletePlugin(category Category, name string) (context.UpsertResult, error)

	// ListPlugins returns all plugins in a category.
	ListPlugins(category Category) []PluginEntry
}

PluginModifier defines operations for managing plugin configuration.

type Provider

type Provider interface {
	Initializer
	Loader
}

type SchemaKey

type SchemaKey struct {
	// Path is the configuration key path (e.g., "addr", "enable", "shutdown").
	Path string
	// Type describes the expected value type (e.g., "string", "bool", "duration", "[]string").
	Type string
	// Description provides a human-readable explanation of the configuration key.
	Description string
}

SchemaKey represents a single configuration key with metadata.

type SchemaProvider

type SchemaProvider interface {
	// AvailableKeys returns all configuration keys available at this level.
	// Keys are returned without prefixes - parent sections add prefixes when recursing.
	AvailableKeys() []SchemaKey
}

SchemaProvider defines the interface for getting available configuration keys. Implementations should return all possible configuration keys with their types and descriptions.

type ServerEntry

type ServerEntry struct {
	// Name is the unique name/ID from the registry, referenced by the user.
	// e.g. 'github-server'
	Name string `json:"name" toml:"name" yaml:"name"`

	// Package contains the identifier including runtime and version.
	// e.g. 'uvx::modelcontextprotocol/[email protected]'
	Package string `json:"package" toml:"package" yaml:"package"`

	// Tools lists the names of the tools which should be allowed on this server.
	// e.g. 'create_repository'
	Tools []string `json:"tools" toml:"tools" yaml:"tools"`

	// RequiredEnvVars captures any environment variables required to run the server.
	RequiredEnvVars []string `json:"requiredEnv,omitempty" toml:"required_env,omitempty" yaml:"required_env,omitempty"`

	// RequiredPositionalArgs captures any command line args that must be positional, and which are required to run the server.
	// The arguments must be ordered by their position (ascending).
	RequiredPositionalArgs []string `json:"requiredPositionalArgs,omitempty" toml:"required_args_positional,omitempty"`

	// RequiredValueArgs captures any command line args that need values, which are required to run the server.
	RequiredValueArgs []string `json:"requiredArgs,omitempty" toml:"required_args,omitempty" yaml:"required_args,omitempty"`

	// RequiredBoolArgs captures any command line args that are boolean flags when present, which are required to run the server.
	RequiredBoolArgs []string `json:"requiredArgsBool,omitempty" toml:"required_args_bool,omitempty" yaml:"required_args_bool,omitempty"`

	// Volumes maps volume names to their Docker volume configuration.
	Volumes VolumesEntry `json:"volumes,omitempty" toml:"volumes,omitempty" yaml:"volumes,omitempty"`
}

ServerEntry represents the configuration of a single versioned MCP Server and tools.

func (*ServerEntry) EqualExceptTools

func (s *ServerEntry) EqualExceptTools(other *ServerEntry) bool

EqualExceptTools compares this server with another and returns true if only the Tools field differs. All other configuration fields must be identical for this to return true.

func (*ServerEntry) Equals

func (s *ServerEntry) Equals(other *ServerEntry) bool

Equals compares two ServerEntry instances for equality. Returns true if all fields are equal. RequiredPositionalArgs order matters (positional), all other slices are order-independent.

func (*ServerEntry) PackageName

func (s *ServerEntry) PackageName() string

func (*ServerEntry) PackageVersion

func (s *ServerEntry) PackageVersion() string

func (*ServerEntry) RequiredArguments

func (s *ServerEntry) RequiredArguments() []string

RequiredArguments returns all required CLI arguments, including positional, value-based and boolean flags. NOTE: The order of these arguments matters, so positional arguments appear first.

func (*ServerEntry) Runtime

func (s *ServerEntry) Runtime() string

Runtime returns the runtime (e.g. uvx, npx) portion of the package string, or an empty string when the runtime cannot be identified.

type Setter

type Setter interface {
	// Set applies a configuration value using dot-separated path notation.
	// An empty value removes/clears the configuration at the given path.
	// Returns the operation performed (Created, Updated, Deleted, Noop) and any validation error.
	Set(path string, value string) (context.UpsertResult, error)
}

Setter defines the interface for setting configuration values using dot-separated path notation. Implementations should handle path routing, value parsing, and validation appropriate to their level.

type ValidatingLoader

type ValidatingLoader struct {
	Loader
	// contains filtered or unexported fields
}

ValidatingLoader wraps a Loader to run additional validation predicates at load time. Uses decorator pattern to preserve custom loader implementations while adding validation.

func NewValidatingLoader

func NewValidatingLoader(inner Loader, predicates ...ValidationPredicate) (*ValidatingLoader, error)

NewValidatingLoader creates a loader that runs validation predicates after Load().

func (*ValidatingLoader) Load

func (l *ValidatingLoader) Load(path string) (Modifier, error)

Load delegates to inner loader, then runs validation predicates.

type ValidationPredicate

type ValidationPredicate func(*Config) error

ValidationPredicate evaluates a loaded Config and returns an error if invalid.

type Validator

type Validator interface {
	// Validate checks the configuration for errors and returns combined validation errors.
	// Uses errors.Join to combine multiple validation errors from child sections.
	Validate() error
}

Validator defines the interface for validating configuration values. Implementations should validate their own fields and recurse to child sections.

type VolumeEntry

type VolumeEntry struct {
	// Path is the container mount path.
	// e.g., "/workspace", "/home/nonroot/.kube/config".
	Path string `toml:"path"`

	// Required indicates whether the volume must be configured by the user.
	Required bool `toml:"required"`
}

VolumeEntry represents a single Docker volume configuration.

type VolumesEntry

type VolumesEntry map[string]VolumeEntry

VolumesEntry maps volume names to their configuration.

Jump to

Keyboard shortcuts

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