config

package
v1.223.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

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

View Source
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 Exists

func Exists(file, name string) (bool, error)

Exists reports whether mcp.servers.<name> is already present in file.

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

func InferName(target string) string

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

func ParseHeaderPairs(pairs []string) (map[string]string, error)

ParseHeaderPairs parses repeatable "Key: Value" flags into a map.

func ParseKeyValuePairs

func ParseKeyValuePairs(pairs []string) (map[string]string, error)

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 Remove

func Remove(file, name string) error

Remove deletes mcp.servers.<name> from file.

func ResolveFile

func ResolveFile(cmd *cobra.Command, atmosConfig *schema.AtmosConfiguration) (string, error)

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 Presets

func Presets() []Preset

Presets returns all built-in presets, for --help/listing.

func ResolvePreset

func ResolvePreset(name string) (Preset, bool)

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.

Jump to

Keyboard shortcuts

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