Documentation
¶
Overview ¶
Package shed implements toolshed's operations (install, uninstall, exec, probe) on top of the registry, the client adapters and the keyring. The CLI and the TUI are both thin front ends over this package.
Index ¶
- Variables
- func BuildConfig(e *registry.Entry, vals Values, scope string) (clients.Config, error)
- func CellarToOpt(p string) string
- func CheckApproved(e *registry.Entry) error
- func CheckCommand(e *registry.Entry) error
- func EntryEnv(e *registry.Entry) []string
- func ExecArgs(e *registry.Entry, refs []SecretRef) []string
- func ExecEnv(extra map[string]string, refs []SecretRef) []string
- func Install(e *registry.Entry, vals Values, opts InstallOptions) ([]string, error)
- func SelfPath() (string, error)
- func Targets(e *registry.Entry, opts InstallOptions) []string
- func Uninstall(reg *registry.Registry, e *registry.Entry, inst *clients.Installation, ...) error
- type InstallOptions
- type SecretRef
- type Tool
- type Values
Constants ¶
This section is empty.
Variables ¶
var ErrPending = errors.New("added by your agent and not approved yet")
ErrPending is returned for tools an agent added that the user hasn't approved yet.
var PackageProbeTimeout = 90 * time.Second
PackageProbeTimeout is the longer bound for npx and uvx servers, whose first start downloads the package.
var ProbeTimeout = 20 * time.Second
ProbeTimeout bounds how long Probe waits for a server.
Functions ¶
func BuildConfig ¶
BuildConfig produces the client registration for an entry. Secret values are written to the keyring and the server is wrapped in `toolshed exec`; without a keyring they fall back to plain env vars in the client config.
For project scope the wrapper is the bare `toolshed` command rather than this binary's absolute path, because .mcp.json is shared through the repository and teammates have toolshed installed in other places.
func CellarToOpt ¶
CellarToOpt rewrites /…/Cellar/<formula>/<version>/rest to /…/opt/<formula>/rest.
func CheckApproved ¶ added in v0.1.2
CheckApproved refuses tools an agent added until the user has seen what they run and approved them. Install and Probe both call it, so no front end (CLI, TUI, MCP) can start an unapproved command.
func CheckCommand ¶
CheckCommand verifies a local server's command can be found, so a typo fails at install instead of as a silent "failed to connect" in the client.
func EntryEnv ¶
EntryEnv is ExecEnv for running an entry directly (used by Probe): fixed env, input defaults, and the entry's secrets from the keyring.
func ExecArgs ¶
ExecArgs builds the self-contained arguments for `toolshed exec`:
exec <id> --secret KEY=group ... -- <command> <args...>
Everything exec needs is in the arguments, so a registered server keeps working even if the registry file moves or isn't visible to the client.
func ExecEnv ¶
ExecEnv returns the environment for running a server: the current environment plus extra fixed values, with secrets from the keyring filled in for any key not already set (explicit env always wins).
func Install ¶
Install stores secrets, builds the client config and registers the tool with every target client. It fails if any client fails.
func SelfPath ¶
SelfPath is the absolute path of the running toolshed binary, with Homebrew's versioned Cellar path rewritten to the stable opt symlink so registrations survive `brew upgrade`.
Types ¶
type InstallOptions ¶
type InstallOptions struct {
Scope string // "user" (default) or "project"; project applies to Claude only
Clients []string // targets; empty means every available client the entry supports
}
InstallOptions controls where a tool is installed.
type SecretRef ¶
type SecretRef struct{ Key, Group string }
SecretRef names a keyring entry to load into the environment.
type Tool ¶
type Tool struct {
Name string
Description string
Destructive bool // the server says this tool may modify or delete things
}
Tool is one tool a server advertises.
type Values ¶
Values maps input keys to the values the user chose.
func Resolve ¶
func Resolve(e *registry.Entry, inst *clients.Installation, overrides Values) (Values, []registry.Input)
Resolve fills in input values from, in order: explicit overrides, the currently installed config (so updates keep earlier choices), the keyring (secrets), and defaults. It returns the values plus the required inputs that are still missing, which the caller should prompt for.