Documentation
¶
Overview ¶
Package tools provides interfaces and implementations for MCP tools
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidParams = errors.New("invalid parameters") ErrNotImplemented = errors.New("operation not implemented") ErrResourceNotFound = errors.New("resource not found") ErrPermissionDenied = errors.New("permission denied") ErrExternalAPIError = errors.New("external API error") ErrInternalError = errors.New("internal server error") )
Standard errors for consistent error handling
Functions ¶
func GetOpenAITools ¶
func GetOpenAITools(tools []Tool) []openai.ChatCompletionToolParam
GetOpenAITools converts a slice of tools to OpenAI format
func NewErrorResult ¶
func NewErrorResult(err error) *mcp.CallToolResult
NewErrorResult creates a standard error result
func NewTextResult ¶
func NewTextResult(text string) *mcp.CallToolResult
NewTextResult creates a standard text result
Types ¶
type BaseTool ¶
type BaseTool struct {
// contains filtered or unexported fields
}
BaseTool provides common functionality for all tools
func NewBaseTool ¶
NewBaseTool creates a new BaseTool with the given name and handle
type Handler ¶
type Handler func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error)
Handler processes tool requests and returns responses
func DefaultHandler ¶
DefaultHandler provides a default implementation for tool handlers
func ErrorHandler ¶
ErrorHandler provides an error implementation for tool handlers
func NotImplementedHandler ¶
func NotImplementedHandler() Handler
NotImplementedHandler returns a handler that indicates a feature is not implemented
type Tool ¶
type Tool interface { // Handle returns the underlying MCP tool Handle() mcp.Tool // ToOpenAITool converts the tool to OpenAI format ToOpenAITool() openai.ChatCompletionToolParam // Handler processes tool requests and returns responses Handler(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) // Name returns the name of the tool Name() string }
Tool defines the interface for all tools in the system