Documentation
¶
Overview ¶
Package config manages configuration and environment settings for the Linear MCP server. It provides centralized configuration management with support for multiple sources including environment variables, configuration files, and default values.
The package handles the complexity of configuration precedence, validation, and secure storage of sensitive configuration values like API credentials.
Configuration Sources ¶
Configuration is loaded from multiple sources in order of precedence:
1. Environment variables (highest precedence) 2. Configuration file (~/.config/linear/config.yaml) 3. Default values (lowest precedence)
Environment Variables ¶
The package recognizes the following environment variables:
LINEAR_CLIENT_ID - OAuth2 client ID for Linear application LINEAR_CLIENT_SECRET - OAuth2 client secret (stored securely) LINEAR_TOKEN - Direct API token for testing/development LINEAR_REDIRECT_URL - OAuth2 callback URL (default: http://localhost:8080/callback)
Configuration File ¶
The configuration file is stored at ~/.config/linear/config.yaml with restricted permissions (0600) to prevent unauthorized access. The file structure:
{
"client_id": "your-client-id",
"client_secret": "encrypted-secret",
"redirect_url": "http://localhost:8080/callback"
}
Security ¶
The package implements several security measures:
- Configuration files have restricted permissions (0600)
- Sensitive values are never logged
- Client secrets are stored encrypted when possible
- Environment variables are preferred for CI/CD environments
Usage ¶
Get configuration instance:
cfg := config.GetConfig() clientID := cfg.GetClientID() clientSecret := cfg.GetClientSecret()
Update configuration:
err := cfg.SetClientID("new-client-id")
if err != nil {
log.Fatal(err)
}
Error Handling ¶
The package provides detailed errors for configuration issues:
- Missing required configuration values
- Invalid configuration file format
- Permission errors when accessing configuration files
- Validation errors for configuration values
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
LogLevel string `yaml:"log_level"` // Logging verbosity: debug, info, warn, error
LogFile string `yaml:"log_file,omitempty"` // Optional log file path
PollingInterval string `yaml:"polling_interval"` // How often to check for updates (e.g., "60s")
Linear LinearConfig `yaml:"linear,omitempty"` // Global Linear OAuth credentials
Workspaces map[string]WorkspaceConfig `yaml:"workspaces,omitempty"` // Per-workspace configurations
}
Config represents the application configuration. It supports multiple configuration sources with environment variables taking precedence over file-based configuration.
func (*Config) DeleteWorkspace ¶
DeleteWorkspace removes a workspace configuration
func (*Config) GetLinearCredentials ¶
GetLinearCredentials returns the Linear credentials to use It checks workspace-specific credentials first, then falls back to global
func (*Config) GetWorkspace ¶
func (c *Config) GetWorkspace(name string) (WorkspaceConfig, bool)
GetWorkspace returns a workspace configuration by name
func (*Config) SetWorkspace ¶
func (c *Config) SetWorkspace(name string, ws WorkspaceConfig)
SetWorkspace adds or updates a workspace configuration
type LinearConfig ¶
type LinearConfig struct {
ClientID string `yaml:"client_id,omitempty"`
ClientSecret string `yaml:"client_secret,omitempty"`
Port int `yaml:"port,omitempty"` // OAuth callback port (default: 37412)
}
LinearConfig holds Linear OAuth credentials
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles configuration file operations with support for: - YAML file persistence - Environment variable overrides - Secure file permissions - Default value initialization
func NewManager ¶
NewManager creates a new configuration manager
func (*Manager) ConfigExistsWithError ¶
ConfigExistsWithError checks if the config file exists and returns detailed error information Returns (false, nil) if file doesn't exist - this is not an error condition Returns (false, error) if there's an actual error like permission denied
func (*Manager) GetConfigPath ¶
GetConfigPath returns the configuration file path
func (*Manager) Load ¶
Load reads the configuration from file with environment variable overrides.
Configuration precedence (highest to lowest): 1. Environment variables (LINEAR_CLIENT_ID, LINEAR_CLIENT_SECRET, etc.) 2. Configuration file (~/.config/linear/config.yaml) 3. Default values
Why this order: Environment variables allow secure credential injection in CI/CD and containerized environments without modifying config files.
func (*Manager) Save ¶
Save writes the configuration to file with secure permissions.
Security considerations: - Directory created with 0700 (owner access only) - Config file created with 0600 (owner read/write only) - Credentials are stored in the config file
Why YAML: Human-readable format that's easy to edit manually, supports comments, and handles complex nested structures well.