config

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package config loads and validates runtime configuration.

Environment variables (GDOCS_*) are the source of truth because every MCP client (Claude Code, Claude Desktop, Cursor) passes only command, args and env to a stdio server. Each setting also has a flag bound to the same name; a flag given explicitly overrides the environment. Validation runs once at start so a misconfigured server fails before it announces itself.

Index

Constants

View Source
const EnvPrefix = "GDOCS_"

EnvPrefix is prepended to every environment variable name.

Variables

View Source
var ErrInvalid = errors.New("config: invalid")

ErrInvalid wraps every validation failure.

Functions

func NewLogger

func NewLogger(c Config, w io.Writer) *slog.Logger

NewLogger builds the process logger. It writes to w, which must be stderr in the server path: stdout carries only JSON-RPC frames.

Types

type Config

type Config struct {
	Profile           string
	LogLevel          LogLevel
	LogFormat         LogFormat
	Preview           bool
	DefaultWriteMode  WriteMode
	ReadOnly          bool
	EnableDestructive bool
	ExportDir         string
	HTTPTimeout       time.Duration
	ClientSecretPath  string
}

Config is the validated runtime configuration.

func (Config) AvailableWriteModes

func (c Config) AvailableWriteModes() []WriteMode

AvailableWriteModes lists the modes this configuration can honour.

type LogFormat

type LogFormat string

LogFormat is a typed enum constrained at load time.

const (
	LogText LogFormat = "text"
	LogJSON LogFormat = "json"
)

Allowed LogFormat values.

type LogLevel

type LogLevel string

LogLevel is a typed enum constrained at load time.

const (
	LogDebug LogLevel = "debug"
	LogInfo  LogLevel = "info"
	LogWarn  LogLevel = "warn"
	LogError LogLevel = "error"
)

Allowed LogLevel values.

func (LogLevel) Slog

func (l LogLevel) Slog() slog.Level

Slog returns the slog.Level for this level.

type Settings

type Settings struct {
	Profile           string
	LogLevel          string
	LogFormat         string
	Preview           string
	DefaultWriteMode  string
	ReadOnly          string
	EnableDestructive string
	ExportDir         string
	HTTPTimeout       string
	ClientSecretPath  string
}

Settings holds the raw string values before validation. Flags and the environment both feed it; Build turns it into a Config.

func Define

func Define(fs *flag.FlagSet, env func(string) string) *Settings

Define registers one flag per setting on fs. Each flag defaults to the matching GDOCS_* variable (read through env) so that a flag passed on the command line wins over the environment, and the environment wins over the built-in default.

func (*Settings) Build

func (s *Settings) Build() (Config, error)

Build validates the settings and returns a Config.

type WriteMode

type WriteMode string

WriteMode says how a write lands in the document.

const (
	WriteSuggest WriteMode = "suggest"
	WriteDirect  WriteMode = "direct"
	WriteComment WriteMode = "comment"
)

Write modes. Suggest needs Developer Preview; Comment works everywhere.

Jump to

Keyboard shortcuts

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