catalog

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package catalog ships clawtool's built-in source catalog.

Per ADR-008, the catalog is the fast path for `clawtool source add <name>`. Each entry knows the canonical package, runtime, required env vars, and auth flow hint for one well-known MCP source server. The catalog is a single TOML file embedded in the binary — no network calls during a `source add`, no first-run download, fully offline-capable.

External catalog federation (Docker MCP Catalog, MCP Registry, Smithery) is a planned extension; this package currently exposes only the built-in.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Catalog

type Catalog struct {
	SchemaVersion int              `toml:"schema_version"`
	Entries       map[string]Entry `toml:"entries"`
}

Catalog is the in-memory representation of one catalog file.

func Builtin

func Builtin() (*Catalog, error)

Builtin parses the embedded catalog. Returns an error only when the embedded TOML itself is malformed — i.e., a build-time bug we want to surface loudly.

func (*Catalog) List

func (c *Catalog) List() []NamedEntry

List returns all entries sorted by name. Drives `clawtool source list --available` (a future flag) and any introspection surface.

func (*Catalog) Lookup

func (c *Catalog) Lookup(name string) (Entry, bool)

Lookup resolves a bare name (e.g. "github") to its entry. Returns ok=false when the name is not in the catalog so callers can fall back to the long-form path or report a curated suggestion.

func (*Catalog) SuggestSimilar

func (c *Catalog) SuggestSimilar(name string, limit int) []string

SuggestSimilar returns up to `limit` candidate names that share a substring with `name` in either direction. Catches both partial input (`git` → `github`) and typos with extra characters (`github-typo` → `github`).

We don't reach for full Levenshtein here because catalog names are short and bidirectional substring matching covers the realistic typo patterns users hit at the CLI.

type Entry

type Entry struct {
	Description string   `toml:"description"`
	Runtime     string   `toml:"runtime"`
	Package     string   `toml:"package"`
	Args        []string `toml:"args,omitempty"`
	RequiredEnv []string `toml:"required_env,omitempty"`
	AuthHint    string   `toml:"auth_hint,omitempty"`
	Homepage    string   `toml:"homepage,omitempty"`
	Maintained  string   `toml:"maintained,omitempty"`
}

Entry is one source-server description.

func (Entry) EnvTemplate

func (e Entry) EnvTemplate() map[string]string

EnvTemplate returns a map keyed by required_env names with `${VAR}`-style values that secrets resolution will fill in at spawn time. Empty when no auth required.

func (Entry) ToSourceCommand

func (e Entry) ToSourceCommand() ([]string, error)

ToSourceCommand renders the runtime + package + args into the argv that would be exec'd to spawn this source. Used by CLI source-add to populate `[sources.<name>].command` in config.toml. Variable references like `${FILESYSTEM_ROOT}` are preserved verbatim — interpolation happens at spawn time against secrets + env, not now.

Mapping (per ADR-008):

npx     →  npx -y <package> [args...]
node    →  node node_modules/<package>/index.js [args...]
python  →  uvx <package> [args...]   (uvx is the modern uv-managed runner)
docker  →  docker run -i --rm <image> [args...]
binary  →  <package> [args...]       (PATH-resolved)

type NamedEntry

type NamedEntry struct {
	Name  string
	Entry Entry
}

NamedEntry pairs an entry with its catalog key (name) for sorted listing.

Jump to

Keyboard shortcuts

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