tools

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ToolNameManageEntities    = "manage-entities"
	ToolNameExecuteAutomation = "execute-automation"
	ToolNameGetResource       = "get-resource"
	ToolNameSearchEntities    = "search-entities"
)

Variables

This section is empty.

Functions

func NewDateAwareHandler added in v0.3.1

func NewDateAwareHandler[TParams, TResult any](handler func(ctx context.Context, req mcp.CallToolRequest, args TParams) (TResult, error)) server.ToolHandlerFunc

NewDateAwareHandler creates a handler with automatic date processing for any result type

func WithValidation added in v0.3.1

func WithValidation[TParams, TResult any](tool Tool[TParams, TResult]) server.ToolHandlerFunc

WithValidation wraps a tool's Handler with validation and date processing

Types

type BaseTool added in v0.3.1

type BaseTool interface {
	Name() string
	Definition() mcp.Tool
	Handler() server.ToolHandlerFunc
}

BaseTool is the non-generic interface for tool registration

type Registry

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

Registry manages tool registration

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Register

func (r *Registry) Register(tool BaseTool)

func (*Registry) RegisterAll

func (r *Registry) RegisterAll(s *server.MCPServer)

type Tool

type Tool[TParams, TResult any] interface {
	BaseTool
	Handle(ctx context.Context, request mcp.CallToolRequest, params TParams) (TResult, error)
	ValidateParams(params *TParams) error
	ValidatePermissions(ctx context.Context, params TParams) error
}

Tool represents an MCP tool with typed parameters

type ToolError added in v0.3.1

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

Error represents a tool error with optional context

func NewToolError added in v0.3.1

func NewToolError(message string) *ToolError

New creates a new tool error

func NewToolErrorf added in v0.3.1

func NewToolErrorf(format string, args ...interface{}) *ToolError

Newf creates a new tool error with formatting

func (*ToolError) API added in v0.3.1

func (e *ToolError) API(resp *http.Response) *ToolError

API adds the API response for debugging Note: This method consumes and closes the response body

func (*ToolError) Cause added in v0.3.1

func (e *ToolError) Cause(err error) *ToolError

Cause adds the underlying error

func (*ToolError) Error added in v0.3.1

func (e *ToolError) Error() string

Error implements the error interface

func (*ToolError) Hint added in v0.3.1

func (e *ToolError) Hint(hint string) *ToolError

Hint adds a hint message

func (*ToolError) Hintf added in v0.3.1

func (e *ToolError) Hintf(format string, args ...interface{}) *ToolError

Hintf adds a formatted hint message

func (*ToolError) Schema added in v0.3.1

func (e *ToolError) Schema(entityType, operation string) *ToolError

Schema adds a hint pointing to the schema resource

func (*ToolError) ToMap added in v0.3.1

func (e *ToolError) ToMap() map[string]interface{}

ToMap returns the error as a structured map for JSON serialization

func (*ToolError) Unwrap added in v0.3.1

func (e *ToolError) Unwrap() error

Unwrap returns the underlying cause for errors.Is/As support

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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