Documentation
¶
Index ¶
- func ExampleConfigPath() string
- func FailedFallbackSourcePaths(err error) []string
- func LoadFallbackServers() (map[string]ServerConfig, error)
- func LoadFallbackSourceForImport(path, cwd string) (map[string]FallbackImportEntry, error)
- func MergeFallbackServers(cfg *Config) error
- func MergeFallbackServersForCWD(cfg *Config, cwd string) error
- func RuntimeConfigSourcePathsForCWD(cfg *Config, cwd string) []string
- func Save(cfg *Config) error
- func SaveTo(path string, cfg *Config) error
- func Validate(cfg *Config) error
- func ValidateForCurrentEnv(cfg *Config) error
- func ValidateServerConfig(name string, srv ServerConfig) error
- type Config
- type FallbackImportEntry
- type FallbackImportLayers
- type FallbackSourceError
- type ServerConfig
- type ServerOrigin
- type ServerOriginKind
- type ToolConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExampleConfigPath ¶
func ExampleConfigPath() string
ExampleConfigPath returns the default config file path (for help messages).
func FailedFallbackSourcePaths ¶ added in v1.0.1
FailedFallbackSourcePaths extracts failed fallback source paths from err.
func LoadFallbackServers ¶
func LoadFallbackServers() (map[string]ServerConfig, error)
LoadFallbackServers imports server configs from standard mcpServers JSON documents used by existing MCP clients.
func LoadFallbackSourceForImport ¶ added in v1.2.0
func LoadFallbackSourceForImport(path, cwd string) (map[string]FallbackImportEntry, error)
LoadFallbackSourceForImport reads one JSON MCP source without expanding environment placeholders so an explicit import can persist references rather than credential values.
func MergeFallbackServers ¶
MergeFallbackServers fills cfg.Servers from external MCP fallback sources. Fallback discovery is skipped when cfg already has servers loaded from the managed mcpx config. When discovery runs, reserved utility command names are omitted so fallback input cannot shadow the CLI surface.
func MergeFallbackServersForCWD ¶ added in v0.1.6
MergeFallbackServersForCWD is like MergeFallbackServers but resolves project-scoped fallback files against the provided working directory. When cwd is empty, it falls back to the process working directory.
func RuntimeConfigSourcePathsForCWD ¶ added in v1.0.1
RuntimeConfigSourcePathsForCWD returns the ordered file paths that can affect the runtime config for the given working directory.
func ValidateForCurrentEnv ¶ added in v0.1.13
ValidateForCurrentEnv checks config invariants after expanding ${ENV_VAR} placeholders against the current process environment.
func ValidateServerConfig ¶ added in v1.0.0
func ValidateServerConfig(name string, srv ServerConfig) error
ValidateServerConfig checks invariants for a single named server.
Types ¶
type Config ¶
type Config struct {
Servers map[string]ServerConfig `toml:"servers"`
FallbackSources []string `toml:"fallback_sources"`
// ServerOrigins records where each server entry came from at runtime.
// It is runtime metadata only and is not persisted to config.toml.
ServerOrigins map[string]ServerOrigin `toml:"-" json:"-"`
}
Config is the top-level mcpx configuration.
func Load ¶
Load reads the config file and returns the parsed Config. If the config file does not exist, it returns an empty Config (no error).
func LoadForEdit ¶ added in v0.1.13
LoadForEdit reads the config file for in-place edits. Unlike Load, it preserves raw ${ENV_VAR} placeholders.
func LoadForEditFrom ¶ added in v0.1.13
LoadForEditFrom reads and parses a config file at the given path for edits. It intentionally skips env expansion so writes do not bake secrets.
type FallbackImportEntry ¶ added in v1.2.0
type FallbackImportEntry struct {
Server ServerConfig
TransportType string
Disabled bool
OAuthScopes []string
OAuthClientMetadataURL string
OAuthUnsupportedReason string
}
FallbackImportEntry preserves source metadata needed while promoting a file-backed server into managed config.
type FallbackImportLayers ¶ added in v1.2.0
type FallbackImportLayers struct {
MatchedProject map[string]FallbackImportEntry
TopLevel map[string]FallbackImportEntry
}
FallbackImportLayers preserves the two precedence layers represented by JSON documents such as Claude Code's ~/.claude.json.
func LoadFallbackSourceLayersForImport ¶ added in v1.2.0
func LoadFallbackSourceLayersForImport(path, cwd string) (FallbackImportLayers, error)
LoadFallbackSourceLayersForImport reads the matched project and top-level entries separately so an adapter can interleave other source scopes.
type FallbackSourceError ¶ added in v1.0.1
FallbackSourceError reports a source file that failed to load.
func (*FallbackSourceError) Error ¶ added in v1.0.1
func (e *FallbackSourceError) Error() string
func (*FallbackSourceError) Unwrap ¶ added in v1.0.1
func (e *FallbackSourceError) Unwrap() error
type ServerConfig ¶
type ServerConfig struct {
// Stdio transport
Command string `toml:"command"`
Args []string `toml:"args"`
CWD string `toml:"cwd,omitempty"`
Env map[string]string `toml:"env"`
// Import provenance supports explicit refreshes without affecting runtime
// transport selection. ImportContext is opaque to config and interpreted by
// the owning source adapter.
ImportSource string `toml:"import_source,omitempty"`
ImportName string `toml:"import_name,omitempty"`
ImportContext string `toml:"import_context,omitempty"`
// HTTP transport
URL string `toml:"url"`
Headers map[string]string `toml:"headers"`
OAuth bool `toml:"oauth,omitempty"`
// OAuthScopes optionally narrows scopes requested during first-class login.
OAuthScopes []string `toml:"oauth_scopes,omitempty"`
// OAuthClientMetadataURL enables Client ID Metadata Document registration.
// DCR remains the fallback when the authorization server supports it.
OAuthClientMetadataURL string `toml:"oauth_client_metadata_url,omitempty"`
// Caching
DefaultCacheTTL string `toml:"default_cache_ttl"`
NoCacheTools []string `toml:"no_cache_tools"`
Tools map[string]ToolConfig `toml:"tools"`
}
ServerConfig describes how to connect to a single MCP server.
func ExpandServerForCurrentEnv ¶ added in v0.1.13
func ExpandServerForCurrentEnv(server ServerConfig) ServerConfig
ExpandServerForCurrentEnv returns a copy of server with ${ENV_VAR} placeholders expanded from the current process environment.
func (ServerConfig) HasAuthorizationHeader ¶ added in v1.1.0
func (s ServerConfig) HasAuthorizationHeader() bool
HasAuthorizationHeader reports whether an explicit Authorization value wins over first-class OAuth for this server.
func (ServerConfig) IsHTTP ¶
func (s ServerConfig) IsHTTP() bool
IsHTTP returns true if the server uses HTTP transport.
func (ServerConfig) IsStdio ¶
func (s ServerConfig) IsStdio() bool
IsStdio returns true if the server uses stdio transport.
type ServerOrigin ¶ added in v0.1.14
type ServerOrigin struct {
Kind ServerOriginKind `json:"kind"`
Path string `json:"path,omitempty"`
}
ServerOrigin describes the source of a resolved server entry.
func NewServerOrigin ¶ added in v0.1.14
func NewServerOrigin(kind ServerOriginKind, path string) ServerOrigin
func NormalizeServerOrigin ¶ added in v0.1.14
func NormalizeServerOrigin(origin ServerOrigin) ServerOrigin
type ServerOriginKind ¶ added in v0.1.14
type ServerOriginKind string
const ( ServerOriginKindCodexApps ServerOriginKind = "codex_apps" ServerOriginKindMCPXConfig ServerOriginKind = "mcpx_config" ServerOriginKindCursor ServerOriginKind = "cursor" ServerOriginKindCodex ServerOriginKind = "codex" ServerOriginKindClaude ServerOriginKind = "claude" ServerOriginKindKiro ServerOriginKind = "kiro" ServerOriginKindFallbackCustom ServerOriginKind = "fallback_custom" ServerOriginKindRuntimeEphemeral ServerOriginKind = "runtime_ephemeral" )
type ToolConfig ¶
type ToolConfig struct {
Cache *bool `toml:"cache"`
}
ToolConfig holds per-tool overrides.