tools

package
v0.0.0-...-19b05ac Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package tools is the godemode-style tool registry. The same registry backs both surfaces of git-mem: the native MCP tools (tools/list, tools/call) and the "code mode" run tool, where interpreted Go calls registry.Call(...).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterMemoryTools

func RegisterMemoryTools(r *Registry, st store.Store) error

RegisterMemoryTools wires the memory operations onto a registry, backed by st. These are the capabilities exposed both as native MCP tools and to code mode.

Types

type CallEvent

type CallEvent struct {
	Name     string                 `json:"name"`
	Args     map[string]interface{} `json:"args"`
	Result   interface{}            `json:"result,omitempty"`
	Err      string                 `json:"error,omitempty"`
	Duration time.Duration          `json:"duration_ns"`
	At       time.Time              `json:"at"`
}

CallEvent is one observed tool invocation. Every Call — whether it arrives via the native MCP tools/call handler, the code-mode interpreter, or the web UI — flows through Registry.Call, so a single observer sees the complete activity trail. Err is nil on success.

type Handler

type Handler func(ctx context.Context, args map[string]interface{}) (interface{}, error)

Handler executes a tool. args are the decoded JSON arguments.

type Param

type Param struct {
	Name        string
	Type        string // "string" | "number" | "boolean" | "object" | "array"
	Description string
	Required    bool
}

Param describes one argument of a tool, used to build MCP JSON schemas and the prompt-time documentation handed to the agent.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry maps tool names to tools. Safe for concurrent use.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates an empty registry.

func (*Registry) Call

func (r *Registry) Call(ctx context.Context, name string, args map[string]interface{}) (interface{}, error)

Call invokes a tool by name. This is the single execution path shared by the MCP tools/call handler and the code-mode interpreter facade.

func (*Registry) Get

func (r *Registry) Get(name string) (*Tool, bool)

Get returns a tool by name.

func (*Registry) List

func (r *Registry) List() []*Tool

List returns all tools sorted by name (stable output for tools/list).

func (*Registry) Observe

func (r *Registry) Observe(fn func(CallEvent))

Observe registers a single callback invoked after every Call completes. It is used by the web UI to record an activity/audit trail across MCP, code mode, and direct API calls. Passing nil disables observation. The callback runs synchronously on the calling goroutine, so it must not block.

func (*Registry) Register

func (r *Registry) Register(t *Tool) error

Register adds a tool, erroring on duplicate names.

type Tool

type Tool struct {
	Name        string
	Description string
	Params      []Param
	Handler     Handler
}

Tool is a single registered capability.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL