Documentation
¶
Overview ¶
Package registry is the single source of truth for tools (spec §5): metadata, input and output types, JSON Schemas, and the function that runs each tool. The CLI, the MCP server and the generated documentation are all built from it.
Index ¶
- Constants
- type Credential
- type Env
- func (e *Env) Clock() time.Time
- func (e *Env) Display(ptr any)
- func (e *Env) Masker() sanitize.Masker
- func (e *Env) PersonalRefs(s string) []string
- func (e *Env) RequireAPI() (*api.Client, error)
- func (e *Env) RequireLocal() (*local.Runner, error)
- func (e *Env) RequirePrivacy() (*privacy.Key, error)
- func (e *Env) ShowPersonalData() bool
- func (e *Env) UntrustedRefs(s string) []string
- type Meta
- type Registry
- func (r *Registry) Add(t Tool) error
- func (r *Registry) All() []Tool
- func (r *Registry) ByCommand(area, verb string) (Tool, bool)
- func (r *Registry) Get(name string) (Tool, bool)
- func (r *Registry) MustAdd(tools ...Tool)
- func (r *Registry) Profile(profile string, enableAlpha bool) ([]Tool, error)
- func (r *Registry) ReadScopes() []string
- type Stage
- type Tier
- type Tool
Constants ¶
const ResultStringMax = sanitize.DefaultMax
ResultStringMax is the byte cap on one untrusted string in a result. Pseudonym filters read what a result still shows after the cap (UntrustedRefs), so the cap is applied and read here and nowhere else.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Credential ¶
type Credential string
Credential is the credential class a tool uses (spec §7.1).
const ( CredRead Credential = "read" CredNone Credential = "none" )
type Env ¶
type Env struct {
API *api.Client // nil when no credential is configured; APIErr says why
APIErr error
Local *local.Runner // nil when no tailscale CLI was found; LocalErr says why
LocalErr error
Config *config.Loaded
// Privacy names masked values and keys audit-log digests (spec §7.6); nil
// when no key was provided, and PrivacyErr then says why if one was malformed.
Privacy *privacy.Key
PrivacyErr error
Now func() time.Time
}
Env is everything a tool may use at run time.
func (*Env) Display ¶
Display rewrites ptr, which a tool owns, into what a result shows: masked unless the owner opted in, then escaped and capped. Mask comes before the cap: an address cut short by it would no longer parse and would keep its first octets. A tool that needs the bytes a caller will see (a sort key, say) runs it on a deep copy.
func (*Env) PersonalRefs ¶
PersonalRefs returns the pseudonym a result shows for the personal field holding s (a login or a display name), as the registry masks and caps it.
func (*Env) RequireAPI ¶
RequireAPI returns the API client or the reason it is unavailable.
func (*Env) RequireLocal ¶
RequireLocal returns the local runner or the reason it is unavailable.
func (*Env) RequirePrivacy ¶
RequirePrivacy returns the privacy key, or why there is none.
func (*Env) ShowPersonalData ¶
ShowPersonalData reports whether the owner opted in to unmasked personal data ("personalData": "show"). By default results are masked (spec Appendix C).
func (*Env) UntrustedRefs ¶
UntrustedRefs returns the pseudonyms a result shows for the untrusted string s, as the registry masks and caps it.
type Meta ¶
type Meta struct {
Name string
Area string // CLI group, e.g. "devices"
Verb string // CLI command, e.g. "list"
Summary string
Tier Tier
Stage Stage
PlanGate string // documented plan gating; "" means all plans
Credential Credential
Scopes []string // minimal OAuth scopes, companions included
// PartialScopes means each scope reads part of the result (settings fields,
// key types): a missing one narrows the result instead of failing the tool.
PartialScopes bool
Notes string // extra facts for the docs, e.g. an unverified scope
// Operations are the API operations the tool calls, as "METHOD /path" with the
// path spelled as Tailscale's OpenAPI document spells it (spec §20).
Operations []string
// MaxResultChars raises the result size an MCP host keeps for this tool
// (Claude Code's anthropic/maxResultSizeChars); 0 leaves the default, which
// list tools raise to 200,000 characters.
MaxResultChars int
}
Meta is a tool's declared metadata.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds tools by name.
func (*Registry) Profile ¶
Profile returns the tools an MCP profile advertises (spec §5.4). Profiles are a context-budget control on stdio, not a security boundary.
func (*Registry) ReadScopes ¶
ReadScopes returns the union of scopes of all read tools, sorted.
type Stage ¶
type Stage string
Stage is the documented release stage of the underlying Tailscale feature.
type Tool ¶
type Tool struct {
Meta Meta
InputType reflect.Type
OutputType reflect.Type
InputSchema *jsonschema.Schema
OutputSchema *jsonschema.Schema
UntrustedFields []string // JSON paths of untrusted output fields
PersonalFields []string // JSON paths of identifiers masked whole unless personalData is "show"
PlainFields []string // JSON paths of untrusted fields kept unmasked (configuration such as routes)
EmailFields []string // JSON paths of untrusted fields whose email addresses alone are masked
// contains filtered or unexported fields
}
Tool is a registered tool.
func Define ¶
Define builds a Tool from its metadata and a typed run function. Personal data is masked (unless the owner opted in) and untrusted output fields are sanitized in place after every run, so run must return values it owns, never shared or cached ones.