config

package
v1.4.8 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: MIT Imports: 5 Imported by: 0

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

func (c *Config) DeleteWorkspace(name string)

DeleteWorkspace removes a workspace configuration

func (*Config) GetLinearCredentials

func (c *Config) GetLinearCredentials(workspace string) (clientID, clientSecret string)

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

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the configuration is valid

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

func NewManager(configPath string) *Manager

NewManager creates a new configuration manager

func (*Manager) ConfigExistsWithError

func (m *Manager) ConfigExistsWithError() (bool, error)

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

func (m *Manager) GetConfigPath() string

GetConfigPath returns the configuration file path

func (*Manager) Load

func (m *Manager) Load() (*Config, error)

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

func (m *Manager) Save(cfg *Config) error

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.

type WorkspaceConfig

type WorkspaceConfig struct {
	Name               string `yaml:"name"`
	LinearClientID     string `yaml:"linear_client_id"`
	LinearClientSecret string `yaml:"linear_client_secret"`
	Description        string `yaml:"description,omitempty"`
}

WorkspaceConfig represents a Linear workspace configuration

Jump to

Keyboard shortcuts

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