Documentation
¶
Index ¶
- type BaseToolBuilder
- type ConfigOption
- type ToolBuildConfig
- type ToolBuilder
- type ToolConfig
- type ToolHandlerFunc
- type ToolMetadata
- type ToolRegistry
- func (r *ToolRegistry) BuildAll(configs map[string]ToolBuildConfig) ([]server.ServerTool, error)
- func (r *ToolRegistry) BuildAllWithFeatures(readOnly bool, features []string) ([]server.ServerTool, error)
- func (r *ToolRegistry) BuildSingle(name string, config ToolBuildConfig) ([]server.ServerTool, error)
- func (r *ToolRegistry) Clear()
- func (r *ToolRegistry) Count() int
- func (r *ToolRegistry) GetBuilder(name string) (ToolBuilder, bool)
- func (r *ToolRegistry) GetMetadata(name string) (ToolMetadata, bool)
- func (r *ToolRegistry) ListBuilders() []string
- func (r *ToolRegistry) ListMetadata() map[string]ToolMetadata
- func (r *ToolRegistry) MustRegister(builder ToolBuilder)
- func (r *ToolRegistry) Register(builder ToolBuilder) error
- func (r *ToolRegistry) Unregister(name string) bool
- type ToolsConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseToolBuilder ¶
type BaseToolBuilder struct {
// contains filtered or unexported fields
}
BaseToolBuilder provides common functionality implementation for all builders It serves as the foundation for concrete tool builder implementations
func NewBaseToolBuilder ¶
func NewBaseToolBuilder(metadata ToolMetadata, features []string) *BaseToolBuilder
NewBaseToolBuilder creates a new base tool builder instance
func (*BaseToolBuilder) GetMetadata ¶
func (b *BaseToolBuilder) GetMetadata() ToolMetadata
GetMetadata returns the tool metadata
func (*BaseToolBuilder) GetName ¶
func (b *BaseToolBuilder) GetName() string
GetName returns the builder name
func (*BaseToolBuilder) GetRequiredFeatures ¶
func (b *BaseToolBuilder) GetRequiredFeatures() []string
GetRequiredFeatures returns the list of required features
func (*BaseToolBuilder) HasAnyRequiredFeature ¶
func (b *BaseToolBuilder) HasAnyRequiredFeature(features []string) bool
HasAnyRequiredFeature checks if any required feature is present
func (*BaseToolBuilder) Validate ¶
func (b *BaseToolBuilder) Validate(config ToolBuildConfig) error
Validate validates the builder configuration It checks if the configuration contains at least one required feature
type ConfigOption ¶
type ConfigOption func(*ToolBuildConfig)
ConfigOption defines the function type for configuration options
func WithFeatures ¶
func WithFeatures(features ...string) ConfigOption
WithFeatures sets the feature list
func WithMaxRetries ¶
func WithMaxRetries(maxRetries int) ConfigOption
WithMaxRetries sets the maximum retry count option
func WithOption ¶
func WithOption(key string, value interface{}) ConfigOption
WithOption sets a configuration option
func WithReadOnly ¶
func WithReadOnly(readOnly bool) ConfigOption
WithReadOnly sets the read-only mode
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ConfigOption
WithTimeout sets the timeout option
type ToolBuildConfig ¶
type ToolBuildConfig struct {
ReadOnly bool `json:"readOnly"`
Features []string `json:"features"`
Options map[string]interface{} `json:"options,omitempty"`
}
ToolBuildConfig contains all configuration information needed to build tools It specifies build parameters such as read-only mode, features, and options
func NewToolBuildConfig ¶
func NewToolBuildConfig(options ...ConfigOption) ToolBuildConfig
NewToolBuildConfig creates a new tool build configuration
type ToolBuilder ¶
type ToolBuilder interface {
// GetName returns the builder name
GetName() string
// GetRequiredFeatures returns the list of required features
GetRequiredFeatures() []string
// BuildTools builds and returns a list of server tools
BuildTools(ctx context.Context, config ToolBuildConfig) ([]server.ServerTool, error)
// Validate validates the builder configuration
Validate(config ToolBuildConfig) error
}
ToolBuilder defines the interface that all tool builders must implement It specifies the methods required for building and managing MCP tools
type ToolConfig ¶
type ToolConfig struct {
Enabled bool `yaml:"enabled"`
ReadOnly bool `yaml:"readOnly"`
Features []string `yaml:"features"`
Options map[string]interface{} `yaml:"options,omitempty"`
}
ToolConfig represents the configuration for a single tool
func (*ToolConfig) Validate ¶
func (tc *ToolConfig) Validate() error
Validate validates the tool configuration
type ToolHandlerFunc ¶
type ToolHandlerFunc func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error)
ToolHandlerFunc defines the tool handler function type It maintains consistency with server.ToolHandlerFunc
type ToolMetadata ¶
type ToolMetadata struct {
Name string `json:"name"`
Version string `json:"version"`
Description string `json:"description"`
Category string `json:"category"`
Dependencies []string `json:"dependencies,omitempty"`
Tags []string `json:"tags,omitempty"`
}
ToolMetadata describes the basic information and attributes of a tool It contains descriptive information about the tool builder
type ToolRegistry ¶
type ToolRegistry struct {
// contains filtered or unexported fields
}
ToolRegistry manages the registration and building of all tool builders It provides centralized management for tool builder registration and tool construction
func NewToolRegistry ¶
func NewToolRegistry() *ToolRegistry
NewToolRegistry creates a new tool registry instance
func (*ToolRegistry) BuildAll ¶
func (r *ToolRegistry) BuildAll(configs map[string]ToolBuildConfig) ([]server.ServerTool, error)
BuildAll builds tools for all specified configurations Returns all successfully built tools and any errors encountered
func (*ToolRegistry) BuildAllWithFeatures ¶
func (r *ToolRegistry) BuildAllWithFeatures(readOnly bool, features []string) ([]server.ServerTool, error)
BuildAllWithFeatures builds all relevant tools based on the feature list Automatically creates configuration for each builder
func (*ToolRegistry) BuildSingle ¶
func (r *ToolRegistry) BuildSingle(name string, config ToolBuildConfig) ([]server.ServerTool, error)
BuildSingle builds tools for a single tool builder
func (*ToolRegistry) Count ¶
func (r *ToolRegistry) Count() int
Count returns the number of registered builders
func (*ToolRegistry) GetBuilder ¶
func (r *ToolRegistry) GetBuilder(name string) (ToolBuilder, bool)
GetBuilder retrieves the tool builder with the specified name
func (*ToolRegistry) GetMetadata ¶
func (r *ToolRegistry) GetMetadata(name string) (ToolMetadata, bool)
GetMetadata retrieves the metadata for the specified builder
func (*ToolRegistry) ListBuilders ¶
func (r *ToolRegistry) ListBuilders() []string
ListBuilders returns a list of all registered builder names
func (*ToolRegistry) ListMetadata ¶
func (r *ToolRegistry) ListMetadata() map[string]ToolMetadata
ListMetadata returns metadata for all registered builders
func (*ToolRegistry) MustRegister ¶
func (r *ToolRegistry) MustRegister(builder ToolBuilder)
MustRegister registers a tool builder and panics if it fails
func (*ToolRegistry) Register ¶
func (r *ToolRegistry) Register(builder ToolBuilder) error
Register registers a tool builder Returns an error if the builder already exists
func (*ToolRegistry) Unregister ¶
func (r *ToolRegistry) Unregister(name string) bool
Unregister removes the specified tool builder
type ToolsConfig ¶
type ToolsConfig struct {
Tools map[string]ToolConfig `yaml:"tools"`
}
ToolsConfig represents the structure of the tools configuration file
func DefaultToolsConfig ¶
func DefaultToolsConfig() *ToolsConfig
DefaultToolsConfig creates a default tool configuration
func (*ToolsConfig) GetEnabledTools ¶
func (tc *ToolsConfig) GetEnabledTools() []string
GetEnabledTools returns the names of all enabled tools
func (*ToolsConfig) IsToolEnabled ¶
func (tc *ToolsConfig) IsToolEnabled(name string) bool
IsToolEnabled checks if the specified tool is enabled
func (*ToolsConfig) SetToolEnabled ¶
func (tc *ToolsConfig) SetToolEnabled(name string, enabled bool)
SetToolEnabled sets the enabled status of a tool
func (*ToolsConfig) ToToolBuildConfigs ¶
func (tc *ToolsConfig) ToToolBuildConfigs() map[string]ToolBuildConfig
ToToolBuildConfigs converts tool configuration to build configurations
func (*ToolsConfig) Validate ¶
func (tc *ToolsConfig) Validate() error
Validate validates the entire tools configuration file