plugins

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterGlobalMetadata

func RegisterGlobalMetadata(pluginName string, metadata *PluginMetadata)

RegisterGlobalMetadata registers metadata in the global registry

func RegisterGlobalTool

func RegisterGlobalTool(toolType string, factory func() Tool) error

RegisterGlobalTool registers a tool in the global registry

Types

type CallResult

type CallResult struct {
	Content interface{} `json:"content"`
	IsText  bool        `json:"isText"`
	Error   string      `json:"error,omitempty"`
}

CallResult represents the result of a tool method call

type Context

type Context struct {
	// SecretManager provides access to secrets
	SecretManager SecretManager

	// Logger provides logging capabilities
	Logger Logger

	// Config provides access to plugin configuration
	Config map[string]interface{}

	// ProjectRoot is the root directory of the project
	ProjectRoot string
}

Context provides shared services to plugins

type DefaultRegistry

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

DefaultRegistry provides the default plugin registry implementation

func NewRegistry

func NewRegistry() *DefaultRegistry

NewRegistry creates a new plugin registry

func (*DefaultRegistry) GetMetadata

func (r *DefaultRegistry) GetMetadata(pluginName string) (*PluginMetadata, error)

GetMetadata returns plugin metadata

func (*DefaultRegistry) GetTool

func (r *DefaultRegistry) GetTool(toolType string) (Tool, error)

GetTool creates a tool instance by type

func (*DefaultRegistry) ListTools

func (r *DefaultRegistry) ListTools() []string

ListTools returns all registered tool types

func (*DefaultRegistry) RegisterMetadata

func (r *DefaultRegistry) RegisterMetadata(pluginName string, metadata *PluginMetadata)

RegisterMetadata registers metadata for a plugin

func (*DefaultRegistry) RegisterTool

func (r *DefaultRegistry) RegisterTool(toolType string, factory func() Tool) error

RegisterTool registers a tool type with a factory function

type Logger

type Logger interface {
	Debug(msg string, args ...interface{})
	Info(msg string, args ...interface{})
	Warn(msg string, args ...interface{})
	Error(msg string, args ...interface{})
}

Logger interface for plugin logging

type Manager

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

Manager manages plugin lifecycle and provides runtime services

func NewManager

func NewManager(registry PluginRegistry, context *Context) *Manager

NewManager creates a new plugin manager

func (*Manager) DisableTool

func (m *Manager) DisableTool(name string) error

DisableTool disables a tool

func (*Manager) EnableTool

func (m *Manager) EnableTool(name string) error

EnableTool enables a tool

func (*Manager) GetContext

func (m *Manager) GetContext() *Context

GetContext returns the plugin context

func (*Manager) GetTool

func (m *Manager) GetTool(name string) (Tool, error)

GetTool returns a loaded tool by name

func (*Manager) ListLoadedTools

func (m *Manager) ListLoadedTools() []string

ListLoadedTools returns all loaded tool names

func (*Manager) LoadTool

func (m *Manager) LoadTool(name, toolType string, config map[string]interface{}) error

LoadTool loads and initializes a tool

func (*Manager) UnloadTool

func (m *Manager) UnloadTool(name string) error

UnloadTool removes a tool from the manager

type MethodInfo

type MethodInfo struct {
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	Parameters  map[string]interface{} `json:"parameters,omitempty"`
	Required    []string               `json:"required,omitempty"`
}

MethodInfo describes a tool method

type PluginMetadata

type PluginMetadata struct {
	Name        string                 `json:"name"`
	Version     string                 `json:"version"`
	Description string                 `json:"description"`
	Author      string                 `json:"author,omitempty"`
	Tags        []string               `json:"tags,omitempty"`
	Homepage    string                 `json:"homepage,omitempty"`
	Repository  string                 `json:"repository,omitempty"`
	License     string                 `json:"license,omitempty"`
	Keywords    []string               `json:"keywords,omitempty"`
	Config      map[string]interface{} `json:"config,omitempty"`
}

Plugin metadata

type PluginRegistry

type PluginRegistry interface {
	// RegisterTool registers a tool type
	RegisterTool(toolType string, factory func() Tool) error

	// GetTool creates a tool instance by type
	GetTool(toolType string) (Tool, error)

	// ListTools returns all registered tool types
	ListTools() []string

	// GetMetadata returns plugin metadata
	GetMetadata(pluginName string) (*PluginMetadata, error)
}

PluginRegistry manages plugin registration and discovery

func GetGlobalRegistry

func GetGlobalRegistry() PluginRegistry

GetGlobalRegistry returns the global plugin registry

type SecretManager

type SecretManager interface {
	Get(key string) (string, error)
	GetAll() (map[string]string, error)
	Exists(key string) bool
	ListKeys() ([]string, error)
	SanitizeForMCP(data interface{}) interface{}
}

SecretManager interface for accessing secrets

type Tool

type Tool interface {
	// Name returns the unique name of this tool
	Name() string

	// Description returns a human-readable description of the tool
	Description() string

	// Methods returns the list of available methods for this tool
	Methods() []MethodInfo

	// Call executes a method with the given parameters
	Call(ctx context.Context, method string, params map[string]interface{}) (*CallResult, error)

	// Dependencies returns the list of dependencies this tool requires
	Dependencies() []string

	// Config returns the configuration schema for this tool
	Config() ToolConfig

	// Initialize sets up the tool with the given configuration
	Initialize(config map[string]interface{}) error

	// IsEnabled returns whether this tool is currently enabled
	IsEnabled() bool

	// SetEnabled sets the enabled state of this tool
	SetEnabled(enabled bool)
}

Tool represents an MCP tool plugin

type ToolConfig

type ToolConfig struct {
	Type         string                 `json:"type"`
	Schema       map[string]interface{} `json:"schema,omitempty"`
	Dependencies []string               `json:"dependencies,omitempty"`
	Enabled      bool                   `json:"enabled"`
}

ToolConfig represents tool configuration

Jump to

Keyboard shortcuts

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