config

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 7 Imported by: ? 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 provides unified configuration loading for all MCP servers. Configuration is layered: YAML file → environment variables → CLI flags. Each MCP server specifies its own EnvPrefix to namespace env vars.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyDefaults

func ApplyDefaults(cfg *Config, opts Options)

ApplyDefaults fills zero-value fields with sensible defaults.

func ApplyEnv

func ApplyEnv(cfg *Config, prefix string)

ApplyEnv overlays environment variables with the given prefix onto cfg.

func SplitCSV

func SplitCSV(s string) []string

SplitCSV splits a comma-separated string into trimmed, non-empty parts.

Types

type CacheConfig

type CacheConfig struct {
	Dir          string        `yaml:"dir"`
	SyncInterval time.Duration `yaml:"sync_interval"`
}

CacheConfig controls local caching of remote repository content.

type Config

type Config struct {
	Sources     Sources              `yaml:"sources"`
	Cache       CacheConfig          `yaml:"cache"`
	Proxy       httputil.ProxyConfig `yaml:"proxy"`
	LLM         optimizer.LLMConfig  `yaml:"llm"`
	Transport   string               `yaml:"transport"`
	Addr        string               `yaml:"addr"`
	GitHubToken string               `yaml:"github_token,omitempty"`
}

Config holds configuration shared by all MCP servers.

func Load

func Load(opts Options) *Config

Load reads configuration layered: YAML file → env vars → CLI flags → defaults.

func LoadFromFile

func LoadFromFile(path string) *Config

LoadFromFile reads a YAML config file. Returns empty Config if path is empty or missing.

func (*Config) ParsedRepos

func (c *Config) ParsedRepos() []RepoRef

ParsedRepos returns parsed RepoRef values from Sources.Repos.

type Options

type Options struct {
	// EnvPrefix namespaces environment variables (e.g. "INSTRUCTIONS" → INSTRUCTIONS_DIRS).
	EnvPrefix string
	// DefaultAddr is the default HTTP listen address.
	DefaultAddr string
	// DefaultCacheName is the cache subdirectory name (e.g. "mcp-instructions").
	DefaultCacheName string
}

Options configures how Load resolves env vars and defaults per MCP server.

type RepoRef

type RepoRef struct {
	Owner string
	Repo  string
	Ref   string // branch/tag/sha; empty = default branch
}

RepoRef represents a parsed "owner/repo@ref" reference.

func ParseRepoRef

func ParseRepoRef(s string) RepoRef

ParseRepoRef parses "owner/repo" or "owner/repo@ref" into a RepoRef.

type Sources

type Sources struct {
	Dirs  []string `yaml:"dirs"`
	Repos []string `yaml:"repos"` // "owner/repo" or "owner/repo@ref"
}

Sources defines where to find content (local dirs and GitHub repos).

Jump to

Keyboard shortcuts

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