tools

package
v0.1.7 Latest Latest
Warning

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

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

Documentation

Overview

Package tools provides ToolRegistry implementation and schema helpers for building JSON Schema parameter definitions in a type-safe way.

Example:

func (t *SearchTool) Parameters() interfaces.JSONSchema {
    return tools.Params(
        map[string]interfaces.JSONSchema{
            "query": tools.ParamString("Search query"),
            "limit": tools.ParamInteger("Max results (default 10)"),
        },
        "query",
    )
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParamArray

func ParamArray(description string, items interfaces.JSONSchema) interfaces.JSONSchema

ParamArray returns a JSON Schema for an array parameter.

func ParamBool

func ParamBool(description string) interfaces.JSONSchema

ParamBool returns a JSON Schema for a boolean parameter.

func ParamEnum

func ParamEnum(description string, values ...any) interfaces.JSONSchema

ParamEnum returns a JSON Schema for an enum parameter.

func ParamInteger

func ParamInteger(description string) interfaces.JSONSchema

ParamInteger returns a JSON Schema for an integer parameter.

func ParamNumber

func ParamNumber(description string) interfaces.JSONSchema

ParamNumber returns a JSON Schema for a number parameter.

func ParamString

func ParamString(description string) interfaces.JSONSchema

ParamString returns a JSON Schema for a string parameter.

func Params

func Params(properties map[string]interfaces.JSONSchema, required ...string) interfaces.JSONSchema

Params builds the full parameters schema for a tool. Properties is a map of parameter name to its schema. Required lists parameter names that must be provided.

Types

type Registry

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

Registry is an in-memory ToolRegistry implementation.

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns a new empty ToolRegistry.

func (*Registry) Get

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

Get returns the tool by name, or (nil, false) if not found.

func (*Registry) Register

func (r *Registry) Register(tool interfaces.Tool)

Register adds a tool. Overwrites if a tool with the same name exists.

func (*Registry) Tools

func (r *Registry) Tools() []interfaces.Tool

Tools returns all registered tools in registration order.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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