Documentation
¶
Overview ¶
Package mcptools is the single registry of gofer's OWN MCP tools (the gofer_* tools internal/mcpserver exposes) and of what each one does to state.
It exists because two very different places need the same answer:
- internal/mcpserver turns every entry into the tool's MCP `annotations` (readOnlyHint / destructiveHint / idempotentHint), so an MCP client can tell a list/get tool from one that writes before it calls either;
- the approval gate (internal/runner/acp) auto-allows a permission request for one of these read-only tools no matter what kind the agent reported, so a steward asking gofer_work_list does not park on a human.
The registry is deliberately here — a leaf package both may import — instead of in internal/mcpserver (an entry-layer package the runner must not depend on). It is a whitelist of exact names, never a name-prefix guess: a tool another MCP server names gofer_work_list is not gofer's, and stays gated.
Index ¶
- Constants
- func AutoApprovedTools() []string
- func BaseName(raw string) string
- func IsAdvisory(name string) bool
- func IsReadOnly(name string) bool
- func IsStewardTool(name string) bool
- func MailReplyToolName(raw string) (string, bool)
- func ServerOf(raw string) (string, bool)
- func StewardReason(name string) (string, bool)
- func StewardTools() []string
- func ToolName(raw string) (string, bool)
- type Class
- type Tool
Constants ¶
const MailReplyTool = "gofer_session_mail_reply"
MailReplyTool is the mailbox's answer tool. It is a Write tool, but the resident 收件会话 may call it without a human (gofer-sh7r): answering a letter that arrived in this session is the whole job. Callers still gate every other gofer write tool.
const ServerName = "gofer"
ServerName is the name gofer's own MCP server is advertised under when gofer injects it (the steward's and a resident 收件会话's session both get exactly this name). It is the canonical server segment of an MCP-qualified tool name, and the approval gate takes gofer's tool names only from it (or from a name this server itself advertised for the same gofer binary) — never from any other MCP server's namespace.
Variables ¶
This section is empty.
Functions ¶
func AutoApprovedTools ¶ added in v0.193.0
func AutoApprovedTools() []string
AutoApprovedTools returns the exact names of the tools the approval gate may run without a human by DEFAULT under mode=ask (config.DefaultApprovalAutoAllowTools): every read-only tool, then every advisory one, in registry order. The list is data, not a prefix rule — a tool another MCP server names the same way is never included.
func BaseName ¶ added in v0.193.0
BaseName returns the tool segment of a raw or mcp__<server>__<tool> name, lowercased and unquoted ("gofer_work_list" for both "gofer_work_list" and "mcp__other__gofer_work_list"). It deliberately does NOT say whether the name is gofer's: config's tool lists are matched through it for tools of ANY MCP server.
func IsAdvisory ¶ added in v0.193.0
IsAdvisory reports whether name is one of gofer's advice-only write tools.
func IsReadOnly ¶
IsReadOnly reports whether name is one of gofer's read-only tools.
func IsStewardTool ¶ added in v0.196.0
IsStewardTool reports whether name is one of StewardTools.
func MailReplyToolName ¶ added in v0.187.0
MailReplyToolName reports the gofer mailbox reply tool raw names, if it names one. It uses the same exact-name resolution as ToolName, so a tool qualified by another MCP server (or a name that only looks like it) is not gofer's and stays gated.
func ServerOf ¶ added in v0.193.0
ServerOf returns the server segment of an mcp__<server>__<tool> name ("gofer" for "mcp__gofer__gofer_work_list"). ok is false for a bare name and for any other namespacing scheme, which is what lets a caller tell "the agent said this is gofer's tool" from "the agent sent a bare name gofer cannot attribute".
func StewardReason ¶ added in v0.196.0
StewardReason reports why a steward session may run name without a human; ok is false for a tool that is not in StewardTools (the gate then decides by the policy alone).
func StewardTools ¶ added in v0.196.0
func StewardTools() []string
StewardTools returns the exact names of the gofer WRITE tools a steward session's own job may run without a human (Tool.Steward), in registry order. It is the steward's half of the default steward approval policy (config.DefaultStewardApproval): gofer's read-only / advice-only tools are approved for every gate, these only for the steward's. A tool missing here is asked about even in the steward's session.
func ToolName ¶
ToolName resolves the gofer tool a raw name refers to. raw is either the bare tool name (what suga and most ACP agents put in a tool call's title, e.g. "gofer_work_list") or an MCP-qualified name in the mcp__<server>__<tool> shape ("mcp__gofer__gofer_work_list"). A name qualified by ANOTHER server is not gofer's tool even when the last segment matches, and anything else that looks namespaced is refused rather than guessed: the caller uses this to skip a human approval, so a false positive is the expensive mistake.
Types ¶
type Class ¶
type Class string
Class says how a tool treats state. The three values map onto the MCP annotation hints, and only ReadOnly is ever auto-approved by the approval gate.
const ( // ReadOnly tools list, read, search or compute; they change nothing a caller has // to confirm. ReadOnly Class = "read_only" // Write tools create or change state in an additive way (submit a job, append a // note, send a letter). Write Class = "write" // Destructive tools delete or overwrite stored data (remove a memory, overwrite // one, cancel a job, end a session, withdraw a letter). Destructive Class = "destructive" )
type Tool ¶
type Tool struct {
Name string
Class Class
// Idempotent marks a write that leaves the same state when repeated with the same
// arguments (a "set" rather than an "append"). Read-only tools are always
// idempotent and do not need it.
Idempotent bool
// Advisory marks a WRITE that only records a suggestion for a person to accept or
// ignore (gofer_today_advise, gofer_work_merge_suggest). It is
// still a Write — it stores a row — but it changes no state a caller has to confirm
// and executes nothing, so the approval gate may run it without a human.
Advisory bool
// Steward is WHY a steward session's own job may run this write without a human
// (gofer-j0aq): the steward's work IS this call — noting, reminding, asking a session
// to report, keeping its own notes — so an `approval: ask` gate that asks for every
// gofer write parked the daily tidy-up on a human until it timed out as a refusal.
// Non-empty = in StewardTools, and only a steward job's own policy lists them; every
// other ACP session still asks. Empty = gated for the steward too. Only a
// non-destructive Write may carry a reason (TestRegistryIsConsistent).
Steward string
}
Tool is one entry: the tool's exact MCP name and its class.