tools

package
v1.4.6 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package tools provides a thread-safe registry for MCP-compatible tools that agents can invoke during execution. Tools are registered by name and looked up at runtime when an agent's plan includes tool calls.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateAgainstSchema

func ValidateAgainstSchema(schema json.RawMessage, params json.RawMessage) error

ValidateAgainstSchema validates params against a JSON Schema definition. Returns nil when schema is empty/null or params are valid.

Types

type ArgumentValidator

type ArgumentValidator interface {
	ValidateArguments(params json.RawMessage) error
}

ArgumentValidator is an optional interface that tools can implement to provide custom argument validation beyond JSON Schema. The runner first performs automatic JSON Schema validation using InputSchema(), then calls ValidateArguments for tools that implement this interface.

type Tool

type Tool interface {
	Name() string
	Description() string
	InputSchema() json.RawMessage
	Execute(ctx context.Context, params json.RawMessage) (json.RawMessage, error)
}

Tool is the interface all MCP-compatible tools must implement.

type ToolRegistry

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

ToolRegistry manages registered tools for agent execution. Thread-safe for concurrent access.

func NewRegistry

func NewRegistry() *ToolRegistry

NewRegistry creates an empty tool registry.

func (*ToolRegistry) Get

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

Get returns a tool by name.

func (*ToolRegistry) List

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

List returns all registered tools.

func (*ToolRegistry) Register

func (r *ToolRegistry) Register(tool Tool)

Register adds a tool to the registry.

Jump to

Keyboard shortcuts

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