Documentation
¶
Index ¶
- Constants
- func AIScriptTool(name string) bool
- func ExecuteTool(name string, params map[string]interface{}, user *model.User) (interface{}, error)
- func ExecuteToolContext(ctx context.Context, name string, params map[string]interface{}, ...) (interface{}, error)
- func GetAllMCPTools() []mcp.MCPTool
- func GetEmbeddedFS() fs.FS
- func GetMCPTools(visibility string) []mcp.MCPTool
- func LoadTools(toolsPath string, disabledTools []string) error
- func ParseAlwaysConfirm(tomlContent []byte) any
- func ParseHandler(tomlContent []byte) string
- func ParseMetadata(tomlContent []byte) (*toolmetadata.ToolMetadata, error)
- func ParseRequiresApproval(tomlContent []byte) bool
- func ReloadTools(toolsPath string, disabledTools []string) (int, error)
- func ToolHints(tomlContent string) (*mcp.ToolAnnotations, map[string]any)
- func UserCanRunAIScripts(user *model.User) bool
- func WithSurface(ctx context.Context, surface Surface) context.Context
- type GoToolHandler
- type Surface
- type Tool
Constants ¶
const ( // RunScriptToolName runs a script the AI assistant wrote. RunScriptToolName = "run_script" // ScriptDocsToolName serves the documentation for writing one. ScriptDocsToolName = "script_docs" )
const ( SurfaceWebChat = toolsurface.WebChat SurfaceMCP = toolsurface.MCP )
Variables ¶
This section is empty.
Functions ¶
func AIScriptTool ¶ added in v0.45.0
AIScriptTool reports whether a tool is one of the AI script tools, which only users holding the Run AI Scripts permission are offered.
func ExecuteTool ¶
func ExecuteToolContext ¶ added in v0.45.0
func ExecuteToolContext(ctx context.Context, name string, params map[string]interface{}, user *model.User) (interface{}, error)
ExecuteToolContext runs a built-in tool. ctx is the MCP request's: Go tools read the calling surface from it.
func GetAllMCPTools ¶
GetAllMCPTools returns all MCP tools with their Visibility field set appropriately
func GetEmbeddedFS ¶
func GetMCPTools ¶
func ParseAlwaysConfirm ¶ added in v0.45.0
ParseAlwaysConfirm returns a tool's always_confirm setting as the value of its lmchatkit.AlwaysConfirmMetaKey _meta entry: true when every call must be confirmed, or a map of the argument values that pick the calls that must (always_confirm = { mode = "write" }). The web assistant asks for those calls every time and offers no "Always Allow". Nil when unset.
func ParseHandler ¶ added in v0.45.0
ParseHandler returns the tool's handler kind: "go" for a tool implemented in Go (go_tools.go), "" for a scripted tool (the .py beside the TOML).
func ParseMetadata ¶
func ParseMetadata(tomlContent []byte) (*toolmetadata.ToolMetadata, error)
func ParseRequiresApproval ¶ added in v0.25.1
ParseRequiresApproval reports whether a tool's TOML sets requires_approval (or its older name requires_permission).
func ToolHints ¶ added in v0.45.0
func ToolHints(tomlContent string) (*mcp.ToolAnnotations, map[string]any)
ToolHints returns the annotations and _meta a user script tool's TOML asks for: requires_approval and always_confirm give destructiveHint, and always_confirm also the lmchatkit always-confirm rule. Both nil when the TOML asks for neither.
func UserCanRunAIScripts ¶ added in v0.45.0
UserCanRunAIScripts reports whether run_script and script_docs are loaded and the user holds the permission to use them.
Types ¶
type GoToolHandler ¶ added in v0.45.0
type GoToolHandler func(ctx context.Context, params map[string]interface{}, user *model.User) (interface{}, error)
GoToolHandler implements a built-in tool in Go. ctx is the MCP request's.
type Surface ¶ added in v0.45.0
type Surface = toolsurface.Surface
Surface names where a tool call came from, so a tool can tell whether a person approved it. The web assistant asks the user before tool calls and shows their arguments; an MCP client is expected to do the same for a tool marked destructive. The OpenAI compatible endpoints, scripts calling knot.mcp and in-process API calls run tools with no one to ask, and carry no surface (in-process calls strip it, see toolsurface.Strip).
func SurfaceFrom ¶ added in v0.45.0
SurfaceFrom returns the surface ctx was marked with, "" when none.
type Tool ¶
type Tool struct {
Name string
Script string
Metadata *toolmetadata.ToolMetadata
RequiresApproval bool
// AlwaysConfirm is the tool's always_confirm setting (ParseAlwaysConfirm),
// published in its tools/list _meta; nil when unset.
AlwaysConfirm any
// Handler is set for a tool implemented in Go (handler = "go" in its
// TOML, see go_tools.go), which has no script.
Handler GoToolHandler
}