config

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package config loads named datasources from config.toml, builds a datasource from MYSQL_* environment variables (compatible with the original MCP), and resolves a final datasource with precedence: CLI overrides > env > file > default.

Index

Constants

This section is empty.

Variables

View Source
var ErrPlaceholderUnset = errors.New("placeholder env var unset")

ErrPlaceholderUnset is returned when a password ${ENV} placeholder references an unset env var.

View Source
var ErrUnknownDatasource = errors.New("unknown datasource")

ErrUnknownDatasource is returned when a named datasource cannot be found.

Functions

This section is empty.

Types

type Config

type Config struct {
	Datasources       map[string]Datasource `toml:"datasource"`
	DefaultDatasource string                `toml:"default"`
}

Config is the parsed set of named datasources.

func LoadFile

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

LoadFile parses a config.toml at path.

type Datasource

type Datasource struct {
	Host           string
	Port           int
	User           string
	Password       string
	Database       string
	SSLMode        string
	SSLCA          string
	ConnectTimeout int
	SQLMode        string
	Charset        string
	Collation      string
	AuthPlugin     string
	SSH            *SSHConfig
}

Datasource is a single MySQL connection target.

func FromEnv

func FromEnv() (Datasource, error)

FromEnv returns a datasource from env vars (with defaults). Used for pure-env mode.

func Resolve

func Resolve(cfg *Config, name string, overrides Datasource) (Datasource, error)

Resolve: flag > env > file > default.

type SSHConfig

type SSHConfig struct {
	Enable     bool
	Host       string
	Port       int
	User       string
	KeyPath    string
	RemoteHost string
	RemotePort int
	LocalPort  int
}

SSHConfig mirrors the original MCP's MYSQL_SSH_* options.

Jump to

Keyboard shortcuts

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