Documentation
¶
Overview ¶
Package registry loads, validates and edits toolshed's catalog of tools.
The catalog is the built-in examples (registry.yaml, compiled in) with the user's own registry layered on top (~/.toolshed/registry.yaml). User entries win on ID collisions, and `examples: false` in the user file hides the built-ins entirely.
Index ¶
- Constants
- func AddUserEntry(e Entry) error
- func ApproveUserEntry(id string) error
- func EnsureUserFile() error
- func Home() string
- func IsValidID(s string) bool
- func RemoveUserEntry(id string) error
- func SetUserArgs(id string, args []string) error
- func SuggestID(kind, source string) string
- func UserPath() string
- func ValidateEntry(e *Entry) error
- type Entry
- type File
- type Input
- type Registry
- type Spec
Constants ¶
const ( SourceBuiltin = "builtin" SourceUser = "user" )
const ( KindCommand = "command" // any executable that speaks MCP over stdio KindNPX = "npx" // an npm package run with `npx -y` KindUVX = "uvx" // a Python package run with `uvx` KindURL = "url" // a remote MCP server )
Kinds of tool a Spec can describe.
Variables ¶
This section is empty.
Functions ¶
func AddUserEntry ¶
AddUserEntry validates e and appends it to the user registry, replacing any existing user entry with the same ID. Comments elsewhere in the file are preserved.
func ApproveUserEntry ¶ added in v0.1.2
ApproveUserEntry clears the pending flag on a tool an agent added, so it can be started and installed.
func EnsureUserFile ¶
func EnsureUserFile() error
EnsureUserFile creates the user registry (with an explanatory header) if it doesn't exist yet.
func RemoveUserEntry ¶
RemoveUserEntry deletes a tool from the user registry. Built-in examples can't be removed (hide them all with `examples: false`).
func SetUserArgs ¶ added in v0.1.3
SetUserArgs replaces a user tool's args (used by `toolshed upgrade` to move a pinned package to a new version), leaving the rest of the file as it is.
func SuggestID ¶
SuggestID derives a tool ID from what the user typed: "@acme/mcp-server-notes" → "notes", "https://mcp.deepwiki.com/mcp" → "deepwiki".
func UserPath ¶
func UserPath() string
UserPath is the user registry: $TOOLSHED_REGISTRY or ~/.toolshed/registry.yaml.
func ValidateEntry ¶
ValidateEntry checks one entry for mistakes that would otherwise surface as confusing failures inside Claude Code or Codex.
Types ¶
type Entry ¶
type Entry struct {
ID string `yaml:"id"`
Name string `yaml:"name,omitempty"`
Description string `yaml:"description,omitempty"`
Command string `yaml:"command,omitempty"` // stdio server: executable (on PATH or absolute)
Args []string `yaml:"args,omitempty"` // stdio server: arguments
URL string `yaml:"url,omitempty"` // remote server (streamable HTTP)
HeaderCmd string `yaml:"headers_helper,omitempty"` // remote: command printing JSON headers (Claude only)
Env map[string]string `yaml:"env,omitempty"` // fixed environment variables
Inputs []Input `yaml:"inputs,omitempty"` // values prompted for at install
Clients []string `yaml:"clients,omitempty"` // restrict to "claude" and/or "codex"
// Pending marks a tool an agent added through `toolshed mcp`. toolshed
// won't start or install it until the user approves it (`toolshed
// approve`, or the TUI), so an agent can't run a command of its choosing.
Pending bool `yaml:"pending,omitempty"`
Source string `yaml:"-"` // "builtin" or "user"
}
Entry is one tool: an MCP server toolshed can install into Claude Code and Codex. The yaml tags are the public file schema (docs/registry.md).
func (*Entry) CommandLine ¶ added in v0.1.2
CommandLine is what toolshed would run (or connect to) for this entry, for showing to the user before they approve it.
func (*Entry) DisplayName ¶
DisplayName falls back to the ID when no name is set.
func (*Entry) SecretGroup ¶
SecretGroup returns the keyring group an input's value is stored under.
func (*Entry) SecretKeys ¶ added in v0.1.2
SecretKeys lists the entry's secret inputs (what it gets from the keyring).
func (*Entry) SupportsClient ¶
SupportsClient reports whether the entry may be installed into client. Remote servers with a headers helper are Claude-only (Codex has no equivalent), regardless of the clients list.
type File ¶
type File struct {
Examples *bool `yaml:"examples,omitempty"` // user file only: false hides the built-in examples
Tools []Entry `yaml:"tools"`
}
File is the on-disk shape of a registry.
type Input ¶
type Input struct {
Key string `yaml:"key"`
Label string `yaml:"label,omitempty"`
Help string `yaml:"help,omitempty"`
Secret bool `yaml:"secret,omitempty"`
Optional bool `yaml:"optional,omitempty"`
Default string `yaml:"default,omitempty"`
}
Input is a value the user provides at install time, passed to the server as an environment variable. Secret inputs live in the OS keyring.
type Registry ¶
type Registry struct {
Entries []*Entry // display order: user entries first, then built-ins
UserPath string
// contains filtered or unexported fields
}
Registry is the merged, validated catalog.
type Spec ¶
type Spec struct {
Kind string
Source string // command line, package (+ args), or URL
ID string // optional; derived from Source when empty
Name string
Description string
Secrets []string // env vars to prompt for and keep in the keyring
}
Spec is the short form of a new tool, as typed by a person (or an agent): a kind plus "what to run". The TUI's add form, `toolshed add` and `toolshed mcp` all build entries through it.