tools

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tools connects to MCP servers and offers the tools the config lists as abilities. Only reading tools exist yet: what a tool returns is fenced as material, never instructions, and every call is logged and counted against a daily cap. A local server is given only PATH, HOME and the variables the config names, never the rest of the environment.

Index

Constants

This section is empty.

Variables

View Source
var ErrOverCap = errors.New("over today's limit of tool calls")

Functions

This section is empty.

Types

type Action

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

Action is a tool that changes things: it is never run as it is proposed, only once the gate (its class) allows it.

func (Action) Check

func (a Action) Check(raw string) error

Check reads raw as the tool's arguments, without calling it.

func (Action) Class

func (a Action) Class() action.Class

Class is the autonomy class the gate checks before it runs.

func (Action) Describe

func (a Action) Describe() string

func (Action) Destructive

func (a Action) Destructive() bool

Destructive is true unless its server says it only adds: a tool that says nothing is taken to be destructive.

func (Action) Do

func (a Action) Do(ctx context.Context, raw string, at time.Time) (string, error)

Do runs it with raw as its arguments, logging the call.

func (Action) Name

func (t Action) Name() string

type Connected

type Connected struct {
	Server   *Server
	Tools    []Tool
	Actions  []Action
	Watchers []Watcher
	Err      error
}

Connected is a server, its reading tools (abilities) and its tools that change things (actions); Err says why it has none (it couldn't be reached, or a tool isn't there).

func Connect

func Connect(ctx context.Context, cfg config.Tools, limit int, st Store, log *slog.Logger) []Connected

Connect reaches every server, keeping those it can: a server it can't reach is reported in its Connected's Err, not a reason to stop. limit is the reading calls a day across all of them.

type Server

type Server struct {
	Name string
	// contains filtered or unexported fields
}

Server is one MCP server's connection: made again once if it drops.

func (*Server) Close

func (s *Server) Close()

type Store

type Store interface {
	LogWeb(ctx context.Context, kind, what string, costUSD float64, at time.Time) error
	WebSince(ctx context.Context, kind string, since time.Time) (int, error)
}

Store is where calls are logged and counted (the web log).

type Tool

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

Tool is a reading tool, offered as an ability: its query is its arguments.

func (Tool) Describe

func (t Tool) Describe() string

func (Tool) Name

func (t Tool) Name() string

func (Tool) Next

func (t Tool) Next() []ability.Ability

func (Tool) Prepare

func (t Tool) Prepare(ctx context.Context, a ability.Act) (ability.Material, error)

func (Tool) Risk

func (t Tool) Risk() ability.Risk

type Watcher

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

Watcher looks with one of a server's reading tools on a schedule (config.Watch) and returns what it found, item by item.

func (Watcher) Every

func (w Watcher) Every() time.Duration

func (Watcher) Look

func (w Watcher) Look(ctx context.Context, at time.Time) ([]memory.Watched, error)

Look calls the tool and splits what it returns into items: their ID is their id field, or else a hash of what they say, so one seen before is known again. Looks are logged but not counted against the day's calls: they run on their own schedule.

func (Watcher) Name

func (w Watcher) Name() string

Jump to

Keyboard shortcuts

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