Documentation
¶
Index ¶
- type Handler
- type ReflectTool
- type Registry
- func (r *Registry) CallTool(ctx context.Context, name string, arguments map[string]interface{}) (*protocol.ToolResult, error)
- func (r *Registry) ListTools(cursor string) ([]protocol.Tool, string, error)
- func (r *Registry) RegisterTool(tool Tool)
- func (r *Registry) RegisterToolWithHandler(tool Tool, handler Handler)
- func (r *Registry) UnregisterTool(name string)
- type Tool
- type ToolImpl
- func (t *ToolImpl) Call(ctx context.Context, arguments map[string]interface{}) (*protocol.ToolResult, error)
- func (t *ToolImpl) GetDescription() string
- func (t *ToolImpl) GetInputSchema() json.RawMessage
- func (t *ToolImpl) GetName() string
- func (t *ToolImpl) GetToolDefinition() protocol.Tool
- func (t *ToolImpl) MarshalJSON() ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler func(ctx context.Context, tool Tool, arguments map[string]interface{}) (*protocol.ToolResult, error)
Handler is a function that executes a tool with given arguments
type ReflectTool ¶
type ReflectTool struct {
*ToolImpl
// contains filtered or unexported fields
}
ReflectTool is a Tool implementation that uses reflection to create a tool from a Go function
func NewReflectTool ¶
func NewReflectTool(name string, description string, fn interface{}) (*ReflectTool, error)
NewReflectTool creates a new ReflectTool from a function
func (*ReflectTool) Call ¶
func (t *ReflectTool) Call(ctx context.Context, arguments map[string]interface{}) (*protocol.ToolResult, error)
Call implements the Tool interface by using reflection to call the underlying function
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry provides a simple way to register individual tools
func (*Registry) CallTool ¶
func (r *Registry) CallTool(ctx context.Context, name string, arguments map[string]interface{}) (*protocol.ToolResult, error)
CallTool implements ToolProvider interface
func (*Registry) RegisterTool ¶
RegisterTool adds a tool to the registry
func (*Registry) RegisterToolWithHandler ¶
RegisterToolWithHandler adds a tool with a custom handler
func (*Registry) UnregisterTool ¶
UnregisterTool removes a tool from the registry
type Tool ¶
type Tool interface {
GetName() string
GetDescription() string
GetInputSchema() json.RawMessage
GetToolDefinition() protocol.Tool
Call(ctx context.Context, arguments map[string]interface{}) (*protocol.ToolResult, error)
}
Tool represents a tool that can be invoked
type ToolImpl ¶
type ToolImpl struct {
// contains filtered or unexported fields
}
ToolImpl is a basic implementation of the Tool interface
func NewToolImpl ¶
NewToolImpl creates a new ToolImpl with the given parameters
func (*ToolImpl) Call ¶
func (t *ToolImpl) Call(ctx context.Context, arguments map[string]interface{}) (*protocol.ToolResult, error)
Call implements the Tool interface but panics as it should be overridden
func (*ToolImpl) GetDescription ¶
GetDescription returns the tool's description
func (*ToolImpl) GetInputSchema ¶
func (t *ToolImpl) GetInputSchema() json.RawMessage
GetInputSchema returns the tool's input schema
func (*ToolImpl) GetToolDefinition ¶
GetToolDefinition returns the tool's definition
func (*ToolImpl) MarshalJSON ¶
MarshalJSON implements json.Marshaler