config

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 12 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 turns the command line and the environment into a validated Config.

Index

Constants

View Source
const (
	// Restricted is the default access mode: read-only, with the SQL safety checks.
	Restricted = "restricted"
	// Unrestricted lets tools modify the database.
	Unrestricted = "unrestricted"
)

Access modes.

View Source
const (
	// Stdio serves MCP over stdin and stdout.
	Stdio = "stdio"
	// StreamableHTTP serves MCP streamable HTTP on /mcp.
	StreamableHTTP = "streamable-http"
	// SSE serves the deprecated MCP SSE transport on /sse.
	SSE = "sse"
)

Transports.

Variables

View Source
var Groups = []string{"schema", "query", "explain", "stats", "health", "index", "locks"}

Groups lists the tool groups, in the order used by error messages.

Functions

func IsLoopback

func IsLoopback(host string) bool

IsLoopback reports whether host is the name localhost or an address of 127.0.0.0/8 or ::1.

Types

type Config

type Config struct {
	DSN                           string
	AccessMode                    string // Restricted or Unrestricted
	Transport                     string // Stdio, StreamableHTTP or SSE
	Host                          string // HTTP transports: bind address
	Port                          int    // HTTP transports: bind port
	AllowRemote                   bool   // HTTP transports: allow a non-loopback Host
	AllowedHosts, AllowedOrigins  []string
	Tools                         []string // enabled groups, "all" expanded
	MaxRows, MaxRowsLimit         int
	MaxBytes, MaxCell             int
	MaxCellLimit                  int
	StatementTimeout              time.Duration
	AllowFunctions, DenyFunctions []string
	ShowVersion                   bool // --version: Parse returned before any other validation
}

Config is the effective configuration of one server process.

func Parse

func Parse(args []string, env func(string) string) (*Config, error)

Parse reads the flags in args (without the program name) and the environment. The returned error text is meant to be printed after "error: ".

func (*Config) Redacted

func (c *Config) Redacted() string

Redacted returns the target as user@host:port/db, without the password.

func (*Config) ToolEnabled

func (c *Config) ToolEnabled(group string) bool

ToolEnabled reports whether the tool group is enabled by --tools.

Jump to

Keyboard shortcuts

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