Documentation
¶
Overview ¶
Package config parses `atmos mcp add` inputs into schema.MCPServerConfig values and reads/writes them under mcp.servers in atmos.yaml, backing the `atmos mcp add`/`remove` commands.
Index ¶
- Constants
- func Exists(file, name string) (bool, error)
- func HasServerWithURL(servers map[string]schema.MCPServerConfig, url string) bool
- func InferName(target string) string
- func ParseHeaderPairs(pairs []string) (map[string]string, error)
- func ParseKeyValuePairs(pairs []string) (map[string]string, error)
- func ParseServerSpec(atmosConfig *schema.AtmosConfiguration, spec ServerSpec) (string, schema.MCPServerConfig, error)
- func Remove(file, name string) error
- func ResolveFile(cmd *cobra.Command, atmosConfig *schema.AtmosConfiguration) (string, error)
- func Write(file, name string, cfg schema.MCPServerConfig) error
- type Preset
- type ServerSpec
Constants ¶
const ( PresetSelf = "self" PresetAtmosPro = "atmos-pro" )
PresetSelf and PresetAtmosPro are the built-in preset names recognized by `atmos mcp add`.
Variables ¶
This section is empty.
Functions ¶
func HasServerWithURL ¶
func HasServerWithURL(servers map[string]schema.MCPServerConfig, url string) bool
HasServerWithURL reports whether any server in servers resolves to url -- used by the Atmos Pro nudge, matched by URL value rather than conventional key name so a renamed entry (via --name) doesn't trigger a false nudge.
func InferName ¶
InferName derives a server name from a URL or command string, sanitized to the [A-Za-z0-9_-]+ charset atmos.yaml keys and MCP client configs expect.
func ParseHeaderPairs ¶
ParseHeaderPairs parses repeatable "Key: Value" flags into a map.
func ParseKeyValuePairs ¶
ParseKeyValuePairs parses repeatable KEY=VALUE flags (env) into a map.
func ParseServerSpec ¶
func ParseServerSpec(atmosConfig *schema.AtmosConfiguration, spec ServerSpec) (string, schema.MCPServerConfig, error)
ParseServerSpec builds a schema.MCPServerConfig from `atmos mcp add` inputs, inferring a name when spec.Name is empty. The spec.Target field may be a known preset name (see ResolvePreset), an http(s) URL, or a stdio command (optionally with arguments, e.g. "npx -y @org/mcp-server --flag value").
func ResolveFile ¶
ResolveFile picks the atmos.yaml file `add`/`remove` should edit, honoring an explicit --config override the same way `atmos config set`/`get` does.
func Write ¶
func Write(file, name string, cfg schema.MCPServerConfig) error
Write serializes cfg to a compact JSON literal (valid YAML flow syntax) and writes it at mcp.servers.<name> in file as a single atomic subtree replace -- avoids leaving stale fields behind if a server's shape changes (e.g. stdio to http) on overwrite, and preserves comments/formatting.
Types ¶
type Preset ¶
type Preset struct {
Name string
// DefaultServerName is the mcp.servers key used unless the user passes
// --name explicitly.
DefaultServerName string
Description string
// RequiresMCPEnabled marks presets that only work when mcp.enabled is
// true (i.e. Atmos itself needs to be able to run as an MCP server).
RequiresMCPEnabled bool
Resolve func(atmosConfig *schema.AtmosConfiguration) schema.MCPServerConfig
}
Preset is a named, built-in server definition `atmos mcp add` can resolve without the user typing out a URL or command.
func ResolvePreset ¶
ResolvePreset looks up a built-in preset by name.
type ServerSpec ¶
type ServerSpec struct {
Target string
Name string
Transport string
Description string
Identity string
Timeout string
Env []string
Headers []string
AutoStart bool
}
ServerSpec holds the `atmos mcp add` flag inputs used to build a schema.MCPServerConfig via ParseServerSpec. Grouped into a struct per the Options pattern rather than passed as positional parameters, since the full flag surface (name, transport, env, headers, description, identity, timeout, auto-start) is more than a handful of arguments.