Documentation
¶
Index ¶
- Variables
- type Content
- type Registry
- func (r *Registry) DeregisterTool(name string) bool
- func (r *Registry) Execute(ctx context.Context, name string, params map[string]interface{}, ...) (interface{}, error)
- func (r *Registry) GetAllTools() []*Tool
- func (r *Registry) GetTool(name string) (*Tool, bool)
- func (r *Registry) GetToolsByCategory(category string) []*Tool
- func (r *Registry) PrintTools()
- func (r *Registry) RegisterTool(tool *Tool)
- func (r *Registry) ValidateToolInput(name string, params map[string]interface{}) error
- type Result
- type Tool
- type ToolError
- type ToolExecutionOptions
- type ToolHandler
- type ToolInputSchema
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidToolInput = &ToolError{
Code: "invalid_tool_input",
Message: "Invalid tool input",
}
ErrInvalidToolInput is returned when the input parameters are invalid
var ErrToolExecutionFailed = &ToolError{
Code: "tool_execution_failed",
Message: "Tool execution failed",
}
ErrToolExecutionFailed is returned when a tool execution fails
var ErrToolNotFound = &ToolError{
Code: "tool_not_found",
Message: "Tool not found",
}
ErrToolNotFound is returned when a tool is not found
Functions ¶
This section is empty.
Types ¶
type Content ¶
Content represents content in a tool execution result
func NewTextContent ¶
NewTextContent creates a new text content
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is a registry of tools
func GetRegistry ¶ added in v1.5.0
func GetRegistry() *Registry
GetRegistry returns the global registry instance
func (*Registry) DeregisterTool ¶
DeregisterTool removes a tool from the registry
func (*Registry) Execute ¶ added in v1.5.0
func (r *Registry) Execute(ctx context.Context, name string, params map[string]interface{}, opts *ToolExecutionOptions) (interface{}, error)
Execute executes a tool by name with the given parameters
func (*Registry) GetAllTools ¶
GetAllTools returns all registered tools
func (*Registry) GetToolsByCategory ¶
GetToolsByCategory returns tools filtered by category
func (*Registry) PrintTools ¶ added in v1.5.0
func (r *Registry) PrintTools()
PrintTools prints all registered tools for debugging
func (*Registry) RegisterTool ¶
RegisterTool registers a tool with the registry
type Result ¶
type Result struct { Result interface{} `json:"result,omitempty"` Content []Content `json:"content,omitempty"` IsError bool `json:"isError,omitempty"` }
Result represents a tool execution result
type Tool ¶
type Tool struct { Name string `json:"name"` Description string `json:"description,omitempty"` InputSchema ToolInputSchema `json:"inputSchema"` Handler ToolHandler // Optional metadata for the tool Category string `json:"-"` // Category for grouping tools CreatedAt time.Time `json:"-"` // When the tool was registered RawSchema interface{} `json:"-"` // Alternative to InputSchema for complex schemas }
Tool represents a tool that can be executed by the MCP server
type ToolExecutionOptions ¶
type ToolExecutionOptions struct { Timeout time.Duration ProgressCB func(progress float64, message string) // Optional progress callback TraceID string // For tracing/logging UserContext map[string]interface{} // User-specific context }
ToolExecutionOptions provides options for tool execution
type ToolHandler ¶
ToolHandler is a function that handles a tool execution Enhanced to use context for cancellation and timeouts
type ToolInputSchema ¶
type ToolInputSchema struct { Type string `json:"type"` Properties map[string]interface{} `json:"properties,omitempty"` Required []string `json:"required,omitempty"` }
ToolInputSchema represents the schema for tool input parameters