Documentation
¶
Overview ¶
Callable tools the model may invoke, with a registry that runs them safely
Index ¶
- func CallFrom(ctx context.Context) (protocol.ToolCall, bool)
- func Report(ctx context.Context, p Progress)
- func ValidName(name string) bool
- func ValidSchema(raw json.RawMessage) error
- func WithCall(ctx context.Context, call protocol.ToolCall) context.Context
- func WithReporter(ctx context.Context, r Reporter) context.Context
- type Annotated
- type Annotations
- type Outcome
- type Progress
- type Registry
- func (r *Registry) Add(tools ...Tool) error
- func (r *Registry) Definitions() []protocol.Tool
- func (r *Registry) Disabled() []string
- func (r *Registry) Enabled(name string) bool
- func (r *Registry) Len() int
- func (r *Registry) Lookup(name string) (Tool, bool)
- func (r *Registry) Names() []string
- func (r *Registry) OnChange(fn func())
- func (r *Registry) ReadOnly() []string
- func (r *Registry) Remove(name string) bool
- func (r *Registry) Run(ctx context.Context, call protocol.ToolCall) (out Outcome)
- func (r *Registry) RunEach(ctx context.Context, calls []protocol.ToolCall, done func(i int, out Outcome)) []Outcome
- func (r *Registry) SetEnabled(name string, on bool)
- type Reporter
- type Result
- type Tool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidName ¶
Reports whether name is acceptable to every supported protocol, letters, digits, underscores and dashes up to 64 bytes
func ValidSchema ¶
func ValidSchema(raw json.RawMessage) error
Checks that a parameter schema is a JSON object describing an object
Types ¶
type Annotated ¶
type Annotated interface {
Annotations() Annotations
}
Tool that declares its annotations
type Annotations ¶
Behavior hints in the shape MCP defines, the scheduler reading ReadOnly and Idempotent and policies the rest
func Describe ¶
func Describe(t Tool) Annotations
Reports the annotations of t, with every hint off for tools that declare none
type Progress ¶
type Progress struct {
CallID string
Tool string
// Name of the output stream the text belongs to, such as stdout or stderr
Stream string
Text string
Done int
Total int
}
Partial output or a progress mark a running tool reports while it works
type Registry ¶
type Registry struct {
// Budget for one run, unlimited when zero
Timeout time.Duration
// contains filtered or unexported fields
}
Ordered set of tools keyed by name
func (*Registry) Add ¶
Adds tools in order, rejecting bad names, missing schemas and duplicates without registering any
func (*Registry) Definitions ¶
Lists definitions of enabled tools in registration order for a protocol request
func (*Registry) OnChange ¶
func (r *Registry) OnChange(fn func())
Registers a callback run after every change to the set of tools
func (*Registry) Run ¶
Runs one call, turning unknown tools, errors, panics and cancellation into error results
func (*Registry) RunEach ¶
func (r *Registry) RunEach(ctx context.Context, calls []protocol.ToolCall, done func(i int, out Outcome)) []Outcome
Runs read only calls concurrently and every other call alone in order, reporting each outcome through done as soon as it is known
func (*Registry) SetEnabled ¶
Turns a tool on or off by name, an off tool withheld from requests and refused when called
type Result ¶
type Result struct {
Content []protocol.Part
IsError bool
// Structured form of the outcome for callers that render rather than read, never sent to the model
Data any
}
Outcome of one run, before the registry attaches the call identity
Directories
¶
| Path | Synopsis |
|---|---|
|
File tools that read, write, edit, glob and grep inside an optional root
|
File tools that read, write, edit, glob and grep inside an optional root |
|
Model Context Protocol client that exposes the tools of a server as local tools
|
Model Context Protocol client that exposes the tools of a server as local tools |
|
Web tool that fetches a URL and returns its content as readable text
|
Web tool that fetches a URL and returns its content as readable text |