Documentation
¶
Index ¶
- Constants
- func AppDirName() string
- func EnsureAtLeastRegularDir(path string) error
- func EnsureAtLeastSecureDir(path string) error
- func UserSpecificCacheDir() (string, error)
- func UserSpecificConfigDir() (string, error)
- type DefaultLoader
- type ExecutionContextConfig
- func (c *ExecutionContextConfig) Get(name string) (ServerExecutionContext, bool)
- func (c *ExecutionContextConfig) List() []ServerExecutionContext
- func (c *ExecutionContextConfig) SaveConfig() error
- func (c *ExecutionContextConfig) SaveExportedConfig() error
- func (c *ExecutionContextConfig) Upsert(ec ServerExecutionContext) (UpsertResult, error)
- type Exporter
- type Loader
- type Modifier
- type ServerExecutionContext
- type UpsertResult
Constants ¶
const ( // EnvVarXDGConfigHome is the XDG Base Directory env var name for config files. EnvVarXDGConfigHome = "XDG_CONFIG_HOME" // EnvVarXDGCacheHome is the XDG Base Directory env var name for cache file. EnvVarXDGCacheHome = "XDG_CACHE_HOME" )
Variables ¶
This section is empty.
Functions ¶
func AppDirName ¶
func AppDirName() string
AppDirName returns the name of the application directory for use in user-specific operations where data is being written.
func EnsureAtLeastRegularDir ¶
EnsureAtLeastRegularDir creates a directory with standard permissions if it doesn't exist, and verifies that it has at least the required regular permissions if it already exists. It does not attempt to repair ownership or permissions: if they are wrong, it returns an error. Used for cache directories, data directories, and documentation.
func EnsureAtLeastSecureDir ¶
EnsureAtLeastSecureDir creates a directory with secure permissions if it doesn't exist, and verifies that it has at least the required secure permissions if it already exists. It does not attempt to repair ownership or permissions: if they are wrong, it returns an error.
func UserSpecificCacheDir ¶
UserSpecificCacheDir returns the directory that should be used to store any user-specific cache files. It adheres to the XDG Base Directory Specification, respecting the XDG_CACHE_HOME environment variable. When XDG_CACHE_HOME is not set, it defaults to ~/.cache/mcpd/ See: https://specifications.freedesktop.org/basedir-spec/latest/
func UserSpecificConfigDir ¶
UserSpecificConfigDir returns the directory that should be used to store any user-specific configuration. It adheres to the XDG Base Directory Specification, respecting the XDG_CONFIG_HOME environment variable. When XDG_CONFIG_HOME is not set, it defaults to ~/.config/mcpd/ See: https://specifications.freedesktop.org/basedir-spec/latest/
Types ¶
type DefaultLoader ¶
type DefaultLoader struct{}
DefaultLoader loads execution context configurations.
type ExecutionContextConfig ¶
type ExecutionContextConfig struct { Servers map[string]ServerExecutionContext `toml:"servers"` // contains filtered or unexported fields }
ExecutionContextConfig stores execution context data for all configured MCP servers.
func NewExecutionContextConfig ¶
func NewExecutionContextConfig(path string) *ExecutionContextConfig
NewExecutionContextConfig returns a newly initialized ExecutionContextConfig.
func (*ExecutionContextConfig) Get ¶
func (c *ExecutionContextConfig) Get(name string) (ServerExecutionContext, bool)
Get retrieves the execution context for the specified server name.
func (*ExecutionContextConfig) List ¶
func (c *ExecutionContextConfig) List() []ServerExecutionContext
List returns all server execution contexts sorted by name.
func (*ExecutionContextConfig) SaveConfig ¶
func (c *ExecutionContextConfig) SaveConfig() error
SaveConfig saves the execution context configuration to a file with secure permissions. Used for runtime execution contexts that may contain sensitive data.
func (*ExecutionContextConfig) SaveExportedConfig ¶
func (c *ExecutionContextConfig) SaveExportedConfig() error
SaveExportedConfig saves the execution context configuration to a file with regular permissions. Used for exported configurations that are sanitized and suitable for sharing.
func (*ExecutionContextConfig) Upsert ¶
func (c *ExecutionContextConfig) Upsert(ec ServerExecutionContext) (UpsertResult, error)
Upsert updates the execution context for the given server name. If the context is empty and does not exist in config, it does nothing. If the context is empty and previously existed in config, it deletes the entry. If the context differs from the existing one in config, it updates it. If the context is new and non-empty, it adds it. Returns the operation performed (Created, Updated, Deleted, or Noop), and writes changes to disk if applicable.
type Exporter ¶
type Exporter interface { // Export handles exporting runtime execution context data to the specified path. // It returns a map which can be used by the caller, and is intended to contain // additional information such as the contract data for processing. Export(path string) (map[string]string, error) }
type Modifier ¶
type Modifier interface { Get(name string) (ServerExecutionContext, bool) Upsert(ctx ServerExecutionContext) (UpsertResult, error) List() []ServerExecutionContext }
type ServerExecutionContext ¶
type ServerExecutionContext struct { // Name is the server name. Name string `toml:"-"` // Args contains command-line arguments with environment variables expanded. // NOTE: Use runtime.Server.SafeArgs() for filtered access when starting servers. Args []string `toml:"args,omitempty"` // Env contains environment variables with values expanded. // NOTE: Use runtime.Server.SafeEnv() for filtered access when starting servers. Env map[string]string `toml:"env,omitempty"` // RawEnv stores unexpanded environment variables used for cross-server filtering decisions. RawEnv map[string]string `toml:"-"` // RawArgs stores unexpanded command-line arguments used for cross-server filtering decisions. RawArgs []string `toml:"-"` }
ServerExecutionContext stores execution context data for an MCP server.
The Args and Env fields contain expanded values with environment variables resolved. These should not be used directly when starting MCP servers, as they may contain cross-server references that pose security risks.
Instead, use the server's SafeArgs() and SafeEnv() methods (in the runtime package) which filter out cross-server references using the RawArgs and RawEnv fields.
func (*ServerExecutionContext) Equals ¶
func (s *ServerExecutionContext) Equals(b ServerExecutionContext) bool
Equals checks if this ServerExecutionContext is equal to another.
func (*ServerExecutionContext) IsEmpty ¶
func (s *ServerExecutionContext) IsEmpty() bool
IsEmpty returns true if the ServerExecutionContext has no args or env vars.
type UpsertResult ¶
type UpsertResult string
const ( Created UpsertResult = "created" Updated UpsertResult = "updated" Deleted UpsertResult = "deleted" Noop UpsertResult = "noop" )